2

What I've tried in .emacs (note: I don't know elisp, and just tried cobbling this stuff together from googling and from other people's stuff) is

(mouse-wheel-mode 't) ;;; mouse-wheel enabled
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;;; 1 line at a time
;;; (setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))
;;; (setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
(global-set-key (kbd "<mouse-4>") 'scroll-down-command)
(global-set-key (kbd "<mouse-5>") 'scroll-up-command)

The desired behavior is that every small mouse wheel movement should scroll up or down one line at a time. But it scrolls one screenful at a time. That is, the smallest mouse wheel motion scrolls the buffer up or down an entire screenful. How can I get one line at a time? I'm using emacs 24.5.1, and sometimes 24.3.1, under linux (slackware versions 14.2x64, and sometimes 14.1x32).

Edit @lawlist's suggestion in comments below worked when I tried an .emacs file with the one single line

(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))

But my entire .emacs file must be doing something that defeats it, or that does some other bad thing. So below is my entire 50-line .emacs. What's wrong with it?...

(setq major-mode 'text-mode)
(setq auto-mode-alist '(("." . text-mode)))
(setq make-backup-files  nil) ;;; no backup files
(setq auto-save-default  nil) ;;; no auto saving

(setq scroll-step 1)
(setq scroll-margin 0)
(setq scroll-preserve-screen-position 't) ;;; scroll without moving cursor
(setq scroll-conservatively 10000) ;;; (0 or 10000 seems same)
(setq auto-window-vscroll nil)
(setq scroll-up nil)
(setq scroll-down nil)
(setq scroll-up-aggressively nil) ;;; used to be .01
(setq scroll-down-aggressively nil) ;;; used to be .01
;;; (setq track-eol nil) ;;; cursor doesn't track end-of-line
(setq next-screen-context-lines 0)
(mouse-wheel-mode 't) ;;; mouse-wheel enabled
;;; (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;;; 1 line at a time
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))
;;; (setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't) ;;; scroll window under mouse
(global-set-key (kbd "<mouse-4>") 'scroll-down-command)
(global-set-key (kbd "<mouse-5>") 'scroll-up-command)
;;; (scroll-bar-mode -1) ;;; no scroll bar displayed at all
(setq indent-tabs-mode nil)
;;; see http://emacs.stackexchange.com/questions/
;;;     14297/completely-disable-all-auto-indentation
(global-set-key "\C-j" 'newline)   ;;; disable auto-indent? emacs <=24.3
(electric-indent-mode 0)           ;;; disable auto-indent? emacs >=24.4
(setq blink-matching-paren nil)
(setq column-number-mode 't)
(setq size-indication-mode 't)

;;; open with single window
(setq inhibit-startup-screen 't)
(add-hook 'emacs-startup-hook 'delete-other-windows)

;;; initial frame width,height,position
(set-frame-width (selected-frame) 80)        ; #chars wide
(set-frame-height (selected-frame) 52)       ; #lines ling
(set-frame-position (selected-frame) 10 10 ) ; x y from upper-left

;;; insert tab character
(defun insert-tab ()
  (interactive)
  (insert "\t"))
;;;  (insert "        "))
(global-unset-key [tab])
(global-set-key (kbd "TAB") 'insert-tab)
;;; --- end-of-file ---
John Forkosh
  • 121
  • 1
  • 4
  • 1
    Your settings seem to work just fine with no user-configuration whatsoever. Try with `emacs -q`. If your settings work with no additional user-configuration, then recursively bisect your user-configuration by commenting stuff out and restarting Emacs until you find your problem. Otherwise, search your user-configuration files for things like `mouse-wheel-scroll-amount`. If that fails, also check your system-wide settings for mouse wheel scroll. – lawlist Sep 11 '16 at 02:01
  • Thanks @lawlist -- with -q the mouse wheel still works (I guess that mouse-wheel-mode 't isn't necessary), and it **still scrolls one screenful** at a time. I guess all that syntax I put in .emacs adds up to semantics=nothing:) – John Forkosh Sep 11 '16 at 02:06
  • 1
    You are correct in that `mouse-wheel-mode` is enabled by default, which can be verified with `emacs -q` by typing: `M-x describe-variable RET mouse-wheel-mode RET` -- the value is `t`. The same goes true for the variable `mouse-wheel-follow-mouse` -- i.e., typing `M-x describe-variable RET mouse-wheel-follow-mouse RET` shows the value is `t` by default. In fact, just `(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))` should be sufficient to achieve one-line at a time scrolling. – lawlist Sep 11 '16 at 02:22
  • @lawlist From your lips(keyboard) to emacs'(you-know-whose) ears:) But no such luck. I uncommented the setq with "((control) . nil)" (and commented the setq without it), which I believe is what you're suggesting. But no difference either way -- both ways scroll one screenful at a time. – John Forkosh Sep 11 '16 at 02:47
  • 1
    There is really nothing else to do within Emacs. I tested with a GUI version of Emacs for OSX version 24.5 without any user configuration other than just `(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))`. The only other possibilities I am aware of are system-wide settings that are trumping or other mouse-related programs running in the background. The entire test can be boiled down to just one-line within Emacs -- no need for complicating the diagnosis with any other Emacs settings. – lawlist Sep 11 '16 at 03:00
  • @lawlist Turns out you're right. I tried an .emacs file with that one line only, and it works as you advertised (and as I want). But when embedded in my entire 50-line .emacs file, it behaves as I described (scrolls screenful-by-screenful). So I edited question with a copy of the entire 50-line .emacs. Must be some goofy mistake there that is totally over my head. – John Forkosh Sep 11 '16 at 03:03
  • 1
    All of that scroll stuff is probably the problem. You only need `(setq scroll-conservatively 101)` -- anything over 100 is the same result. The most likely suspect is `scroll-preserve-screen-position`. Leave the default value of `scroll-step` the way it was -- i.e., `0` -- the doc-string for `scroll-step` states: "*If you want scrolling to always be a line at a time, you should set `scroll-conservatively` to a large value rather than set this to 1.*" – lawlist Sep 11 '16 at 03:06
  • Thanks again @lawlist I ;;;commented-out both ;(setq scroll-step 1) and also ;(setq scroll-preserve-screen-position 't) But no luck yet. Don't bother looking further yourself. Even though I have no idea what I'm doing in elisp (just general programming skills), I can methodically pare down that file to isolate the problem statement(s). Real-life cockroaches manage to elude me all the time. This bug, however, can run but can't hide much longer **(** and I'll take sadistic pleasure squashing the life out of it **:)** I'll follow-up later with answer. Thanks again. – John Forkosh Sep 11 '16 at 03:24
  • @lawlist Turns out that commenting ;;(global-set-key (kbd "") 'scroll-down-command) and also ;;(global-set-key (kbd "") 'scroll-up-command) does the trick. But now I can't get the point to remain stationary in the window while the buffer contents scroll "underneath" it -- the point just jumps around as I scroll with the mouse. The margin-stuff's scope doesn't seem to include mouse-wheel scrolling. "The revenge of emacs", I guess. – John Forkosh Sep 11 '16 at 03:56

0 Answers0