[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Buffer menu fix
From: |
Kim F. Storm |
Subject: |
Re: Buffer menu fix |
Date: |
Wed, 07 Sep 2005 01:01:37 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Chong Yidong <address@hidden> writes:
> Eli Zaretskii <address@hidden> 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 <address@hidden> http://www.cua.dk
- Buffer menu fix, Chong Yidong, 2005/09/04
- Re: Buffer menu fix, Eli Zaretskii, 2005/09/04
- Re: Buffer menu fix, Chong Yidong, 2005/09/05
- Re: Buffer menu fix, Eli Zaretskii, 2005/09/05
- Re: Buffer menu fix, Chong Yidong, 2005/09/05
- Re: Buffer menu fix, Chong Yidong, 2005/09/05
- Re: Buffer menu fix, Eli Zaretskii, 2005/09/06
- Re: Buffer menu fix, Thien-Thi Nguyen, 2005/09/06
- Re: Buffer menu fix, Chong Yidong, 2005/09/06
- Re: Buffer menu fix,
Kim F. Storm <=
- Re: Buffer menu fix, Chong Yidong, 2005/09/06
- Re: Buffer menu fix, Chong Yidong, 2005/09/07
- Re: Buffer menu fix, Stefan Monnier, 2005/09/07
- Re: Buffer menu fix, Kim F. Storm, 2005/09/07
- Re: Buffer menu fix, Chong Yidong, 2005/09/07
Re: Buffer menu fix, Richard M. Stallman, 2005/09/05
Buffer menu fix, Nick Roberts, 2005/09/05