From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Buffer menu fix Date: Wed, 07 Sep 2005 01:01:37 +0200 Message-ID: References: <87slwkfxt9.fsf@stupidchicken.com> <87slwjpug0.fsf@stupidchicken.com> <87wtlvrwet.fsf@stupidchicken.com> <878xyavuw2.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1126048336 22827 80.91.229.2 (6 Sep 2005 23:12:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 6 Sep 2005 23:12:16 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 07 01:12:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ECmaa-0008F9-Sb for ged-emacs-devel@m.gmane.org; Wed, 07 Sep 2005 01:10:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ECmf6-0004GM-JE for ged-emacs-devel@m.gmane.org; Tue, 06 Sep 2005 19:15:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ECmWh-00016a-V2 for emacs-devel@gnu.org; Tue, 06 Sep 2005 19:06:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ECmWd-00014F-Kh for emacs-devel@gnu.org; Tue, 06 Sep 2005 19:06:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ECmWc-00013X-31 for emacs-devel@gnu.org; Tue, 06 Sep 2005 19:06:46 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ECmW4-0005VX-UD; Tue, 06 Sep 2005 19:06:13 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id 61C00262840; Wed, 7 Sep 2005 01:01:55 +0200 (CEST) Original-To: Chong Yidong In-Reply-To: <878xyavuw2.fsf@stupidchicken.com> (Chong Yidong's message of "Tue, 06 Sep 2005 15:49:49 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:42678 Archived-At: Chong Yidong writes: > Eli Zaretskii writes: > >>> The only way I can think of to get around this is to bind to a single >>> function that tries to re-construct the value of `column' based on >>> where the mouse was clicked. But that seems like a strange thing to >>> do -- you're throwing away information that you had (i.e., the value >>> of `column'), only to do a lot of work find out what it was later on. > [...] > It's a giant headache to code. Not if you use the right approach. Try this patch (not fully tested, but shows the principle): *** buff-menu.el 06 Sep 2005 23:52:33 +0200 1.91 --- buff-menu.el 07 Sep 2005 00:57:01 +0200 *************** *** 633,660 **** (insert m2))) (forward-line))))) (defun Buffer-menu-make-sort-button (name column) (if (equal column Buffer-menu-sort-column) (setq column nil)) (let* ((downname (downcase name)) ! (map (make-sparse-keymap)) ! (fun `(lambda (&optional e) ! ,(concat "Sort the buffer menu by " downname ".") ! (interactive (list last-input-event)) ! (if e (mouse-select-window e)) ! (Buffer-menu-sort ,column))) ! (sym (intern (format "Buffer-menu-sort-by-%s-%s" name column)))) ! ;; Use a symbol rather than an anonymous function, to make the output of ! ;; C-h k less intimidating. ! (fset sym fun) ! (setq fun sym) ;; This keymap handles both nil and non-nil ;; values for Buffer-menu-use-header-line. ! (define-key map [header-line mouse-1] fun) ! (define-key map [header-line mouse-2] fun) ! (define-key map [mouse-2] fun) (define-key map [follow-link] 'mouse-face) ! (define-key map "\C-m" fun) (propertize name 'help-echo (concat (if Buffer-menu-use-header-line "mouse-1, mouse-2: sort by " --- 633,658 ---- (insert m2))) (forward-line))))) + (defun Buffer-menu-sort-by-column (&optional e) + "Sort the buffer menu by this column." + (interactive "e") + (if e (mouse-select-window e)) + (let ((obj (posn-object (event-start e)))) + (Buffer-menu-sort (get-text-property (cdr obj) 'column (car obj))))) + (defun Buffer-menu-make-sort-button (name column) (if (equal column Buffer-menu-sort-column) (setq column nil)) (let* ((downname (downcase name)) ! (map (make-sparse-keymap))) ;; This keymap handles both nil and non-nil ;; values for Buffer-menu-use-header-line. ! (define-key map [header-line mouse-1] 'Buffer-menu-sort-by-column) ! (define-key map [header-line mouse-2] 'Buffer-menu-sort-by-column) ! (define-key map [mouse-2] 'Buffer-menu-sort-by-column) (define-key map [follow-link] 'mouse-face) ! (define-key map "\C-m" 'Buffer-menu-sort-by-column) (propertize name + 'column column 'help-echo (concat (if Buffer-menu-use-header-line "mouse-1, mouse-2: sort by " -- Kim F. Storm http://www.cua.dk