From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: buff-menu.el Date: Tue, 24 May 2005 20:32:10 -0500 (CDT) Message-ID: <200505250132.j4P1WAQ20807@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1116985721 3966 80.91.229.2 (25 May 2005 01:48:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 25 May 2005 01:48:41 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 25 03:48:39 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dakzj-0001Vl-RM for ged-emacs-devel@m.gmane.org; Wed, 25 May 2005 03:47:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dal3V-0008F9-D5 for ged-emacs-devel@m.gmane.org; Tue, 24 May 2005 21:51:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dal29-0007r0-At for emacs-devel@gnu.org; Tue, 24 May 2005 21:50:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dal1z-0007mY-FQ for emacs-devel@gnu.org; Tue, 24 May 2005 21:50:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dal1z-0007aa-9b for emacs-devel@gnu.org; Tue, 24 May 2005 21:49:59 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DaklK-0007X6-UQ for emacs-devel@gnu.org; Tue, 24 May 2005 21:32:47 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j4P1WRCK004055 for ; Tue, 24 May 2005 20:32:27 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j4P1WAQ20807; Tue, 24 May 2005 20:32:10 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:37593 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:37593 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))) ============================================================