The patch below fixes two problems with the Buffer Menu. The first is that, if Buffer-menu-use-header-line is nil, one currently has no convenient way to use the sorting functions. Remember that, if for some reason one can not use the mouse (blindness for instance), then a header line is useless. So every functionality that is available using a header line should also be available without a header line and without requiring a mouse. The patch below would, if Buffer-menu-use-header-line is nil, bind the sorting functions to Mouse-2 and RET, in those areas where currently the help-echo already (falsely) claims that Mouse-2 will sort. It also makes the help-echo mention RET.
Another problem is that if point is not on a line with a buffer (end of the buffer, regardless of the value of Buffer-menu-use-header-line, and the first two lines if Buffer-menu -use-header-line is nil), then reverting moves point to some place in the last line with a buffer. This is very annoying if one autoreverts the Buffer Menu and unintuitive even if one does not autorevert it. The patch below fixes this by keeping point at the same position if it is in the first two lines and keeping it at the end of the buffer if it already is there. I can install if desired. ===File ~/buff-menu-diff==================================== *** buff-menu.el 21 May 2005 16:06:59 -0500 1.82 --- buff-menu.el 24 May 2005 19:08:27 -0500 *************** *** 203,219 **** (or (eq buffer-undo-list t) (setq buffer-undo-list nil)) ;; We can not use save-excursion here. The buffer gets erased. ! (let ((ocol (current-column)) (oline (progn (move-to-column 4) (get-text-property (point) 'buffer))) (prop (point-min)) ;; do not make undo records for the reversion. (buffer-undo-list t)) (list-buffers-noselect Buffer-menu-files-only) ! (while (setq prop (next-single-property-change prop 'buffer)) ! (when (eq (get-text-property prop 'buffer) oline) ! (goto-char prop) ! (move-to-column ocol))))) (defun Buffer-menu-toggle-files-only (arg) "Toggle whether the current buffer-menu displays only file buffers. --- 203,223 ---- (or (eq buffer-undo-list t) (setq buffer-undo-list nil)) ;; We can not use save-excursion here. The buffer gets erased. ! (let ((opoint (point)) ! (eobp (eobp)) ! (ocol (current-column)) (oline (progn (move-to-column 4) (get-text-property (point) 'buffer))) (prop (point-min)) ;; do not make undo records for the reversion. (buffer-undo-list t)) (list-buffers-noselect Buffer-menu-files-only) ! (if oline ! (while (setq prop (next-single-property-change prop 'buffer)) ! (when (eq (get-text-property prop 'buffer) oline) ! (goto-char prop) ! (move-to-column ocol))) ! (goto-char (if eobp (point-max) opoint))))) (defun Buffer-menu-toggle-files-only (arg) "Toggle whether the current buffer-menu displays only file buffers. *************** *** 633,647 **** (if (equal column Buffer-menu-sort-column) (setq column nil)) (propertize name 'help-echo (if column ! (concat "mouse-2: sort by " (downcase name)) ! "mouse-2: sort by visited order") 'mouse-face 'highlight 'keymap (let ((map (make-sparse-keymap))) ! (define-key map [header-line mouse-2] ! `(lambda (e) ! (interactive "e") ! (save-window-excursion (if e (mouse-select-window e)) (Buffer-menu-sort ,column)))) map))) --- 637,665 ---- (if (equal column Buffer-menu-sort-column) (setq column nil)) (propertize name 'help-echo (if column ! (if Buffer-menu-use-header-line ! (concat "mouse-2: sort by " (downcase name)) ! (concat "mouse-2, RET: sort by " ! (downcase name))) ! (if Buffer-menu-use-header-line ! "mouse-2: sort by visited order" ! "mouse-2, RET: sort by visited order")) 'mouse-face 'highlight 'keymap (let ((map (make-sparse-keymap))) ! (if Buffer-menu-use-header-line ! (define-key map [header-line mouse-2] ! `(lambda (e) ! (interactive "e") ! (save-window-excursion ! (if e (mouse-select-window e)) ! (Buffer-menu-sort ,column)))) ! (define-key map [mouse-2] ! `(lambda (e) ! (interactive "e") (if e (mouse-select-window e)) + (Buffer-menu-sort ,column))) + (define-key map "\C-m" + `(lambda () (interactive) (Buffer-menu-sort ,column)))) map))) ============================================================ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel