all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: buff-menu.el
Date: Tue, 24 May 2005 20:32:10 -0500 (CDT)	[thread overview]
Message-ID: <200505250132.j4P1WAQ20807@raven.dms.auburn.edu> (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)))
  
============================================================

             reply	other threads:[~2005-05-25  1:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-25  1:32 Luc Teirlinck [this message]
2005-05-25 15:03 ` buff-menu.el Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200505250132.j4P1WAQ20807@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.