unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* buff-menu.el
@ 2005-05-25  1:32 Luc Teirlinck
  2005-05-25 15:03 ` buff-menu.el Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Teirlinck @ 2005-05-25  1:32 UTC (permalink / raw)


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)))
  
============================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: buff-menu.el
  2005-05-25  1:32 buff-menu.el Luc Teirlinck
@ 2005-05-25 15:03 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2005-05-25 15:03 UTC (permalink / raw)
  Cc: emacs-devel

It sounds like these are bug fixes, so if you've tested them,
please install them.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-25 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-25  1:32 buff-menu.el Luc Teirlinck
2005-05-25 15:03 ` buff-menu.el Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).