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 ---
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 likemouse-wheel-scroll-amount
. If that fails, also check your system-wide settings for mouse wheel scroll. – lawlist Sep 11 '16 at 02:01mouse-wheel-mode
is enabled by default, which can be verified withemacs -q
by typing:M-x describe-variable RET mouse-wheel-mode RET
-- the value ist
. The same goes true for the variablemouse-wheel-follow-mouse
-- i.e., typingM-x describe-variable RET mouse-wheel-follow-mouse RET
shows the value ist
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(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(setq scroll-conservatively 101)
-- anything over 100 is the same result. The most likely suspect isscroll-preserve-screen-position
. Leave the default value ofscroll-step
the way it was -- i.e.,0
-- the doc-string forscroll-step
states: "If you want scrolling to always be a line at a time, you should setscroll-conservatively
to a large value rather than set this to 1." – lawlist Sep 11 '16 at 03:06