summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2005-09-07 18:48:34 +0000
committerChong Yidong <cyd@stupidchicken.com>2005-09-07 18:48:34 +0000
commit104fc809f95472cb143388230cdac95052bbefb5 (patch)
tree70b6c5d0a10cbd426429714decd0484a0ecdfb39 /lisp
parentedf3d146cc73256b2c992a90e6379680c797d54e (diff)
downloademacs-104fc809f95472cb143388230cdac95052bbefb5.tar.gz
*** empty log message ***
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/buff-menu.el61
2 files changed, 39 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2143bc17cf3..bd0c2e87e70 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2005-09-08 Chong Yidong <cyd@stupidchicken.com>
+
+ * buff-menu.el (Buffer-menu-sort-by-column): New function.
+ Suggested by Kim F. Storm.
+ (Buffer-menu-sort-button-map): Global keymap for sort buttons.
+ (Buffer-menu-make-sort-button): Use global keymap.
+
2005-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
* buff-menu.el (Buffer-menu-make-sort-button): Add docstrings, use
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 18ba3bf25ca..4c45847df0f 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -633,37 +633,40 @@ For more information, see the function `buffer-menu'."
(insert m2)))
(forward-line)))))
+(defun Buffer-menu-sort-by-column (&optional e)
+ "Sort the buffer menu by the column clicked on."
+ (interactive (list last-input-event))
+ (if e (mouse-select-window e))
+ (let* ((pos (event-start e))
+ (obj (posn-object pos))
+ (col (if obj
+ (get-text-property (cdr obj) 'column (car obj))
+ (get-text-property (posn-point pos) 'column))))
+ (Buffer-menu-sort col)))
+
+(defvar Buffer-menu-sort-button-map
+ (let ((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)
+ map)
+ "Local keymap for Buffer menu sort buttons.")
+
(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 "
- "mouse-2, RET: sort by ")
- ;; No clue what this is for, but I preserved the
- ;; behavior, just in case. --Stef
- (if column downname "visited order"))
- 'mouse-face 'highlight
- 'keymap map)))
+ (propertize name
+ 'column column
+ 'help-echo (concat
+ (if Buffer-menu-use-header-line
+ "mouse-1, mouse-2: sort by "
+ "mouse-2, RET: sort by ")
+ (if column (downcase name) "visited order"))
+ 'mouse-face 'highlight
+ 'keymap Buffer-menu-sort-button-map))
(defun list-buffers-noselect (&optional files-only buffer-list)
"Create and return a buffer with a list of names of existing buffers.