Emacs-hacks

From Theory of Measurements Wiki

Jump to: navigation, search

revert-all-buffers

Here's some code which is quite handy eg. after doing a CVS update, which results in lots of files being updated. The following function reverts all Emacs file buffers.

(defun revert-all-buffers ()
  (interactive)
  (let ((current-buffer (buffer-name)))
    (loop for buf in (buffer-list)
          do
          (unless (null (buffer-file-name buf))
            (switch-to-buffer (buffer-name buf))
            (revert-buffer nil t)))
    (switch-to-buffer current-buffer)
    (message "All buffers reverted!")))

Stupid scrolling

Sometimes, eg on Cygwin, mouse scroll wheel events are not mapped... they show up as button4 and button5 keypresses. The following works at least.

(defun scroll-down-ten ()
  (interactive)
  (loop for x from 0 to 9 do (scroll-down-one)))
(defun scroll-up-ten ()
  (interactive)
  (loop for x from 0 to 9 do (scroll-up-one)))
(global-set-key 'button4 'scroll-down-ten)
(global-set-key 'button5 'scroll-up-ten)
Personal tools