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 ()
  (insert "\t"))
;;;  (insert "        "))
(global-unset-key [tab])
(global-set-key (kbd "TAB") 'insert-tab)
;;; --- end-of-file ---
  • 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, 2016 at 2: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:) Sep 11, 2016 at 2: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, 2016 at 2:22
  • 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, 2016 at 3:00
  • 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, 2016 at 3:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.