diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/buff-menu.el | 61 |
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 @@ | |||
| 1 | 2005-09-08 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * buff-menu.el (Buffer-menu-sort-by-column): New function. | ||
| 4 | Suggested by Kim F. Storm. | ||
| 5 | (Buffer-menu-sort-button-map): Global keymap for sort buttons. | ||
| 6 | (Buffer-menu-make-sort-button): Use global keymap. | ||
| 7 | |||
| 1 | 2005-09-06 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2005-09-06 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * buff-menu.el (Buffer-menu-make-sort-button): Add docstrings, use | 10 | * 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'." | |||
| 633 | (insert m2))) | 633 | (insert m2))) |
| 634 | (forward-line))))) | 634 | (forward-line))))) |
| 635 | 635 | ||
| 636 | (defun Buffer-menu-sort-by-column (&optional e) | ||
| 637 | "Sort the buffer menu by the column clicked on." | ||
| 638 | (interactive (list last-input-event)) | ||
| 639 | (if e (mouse-select-window e)) | ||
| 640 | (let* ((pos (event-start e)) | ||
| 641 | (obj (posn-object pos)) | ||
| 642 | (col (if obj | ||
| 643 | (get-text-property (cdr obj) 'column (car obj)) | ||
| 644 | (get-text-property (posn-point pos) 'column)))) | ||
| 645 | (Buffer-menu-sort col))) | ||
| 646 | |||
| 647 | (defvar Buffer-menu-sort-button-map | ||
| 648 | (let ((map (make-sparse-keymap))) | ||
| 649 | ;; This keymap handles both nil and non-nil values for | ||
| 650 | ;; Buffer-menu-use-header-line. | ||
| 651 | (define-key map [header-line mouse-1] 'Buffer-menu-sort-by-column) | ||
| 652 | (define-key map [header-line mouse-2] 'Buffer-menu-sort-by-column) | ||
| 653 | (define-key map [mouse-2] 'Buffer-menu-sort-by-column) | ||
| 654 | (define-key map [follow-link] 'mouse-face) | ||
| 655 | (define-key map "\C-m" 'Buffer-menu-sort-by-column) | ||
| 656 | map) | ||
| 657 | "Local keymap for Buffer menu sort buttons.") | ||
| 658 | |||
| 636 | (defun Buffer-menu-make-sort-button (name column) | 659 | (defun Buffer-menu-make-sort-button (name column) |
| 637 | (if (equal column Buffer-menu-sort-column) (setq column nil)) | 660 | (if (equal column Buffer-menu-sort-column) (setq column nil)) |
| 638 | (let* ((downname (downcase name)) | 661 | (propertize name |
| 639 | (map (make-sparse-keymap)) | 662 | 'column column |
| 640 | (fun `(lambda (&optional e) | 663 | 'help-echo (concat |
| 641 | ,(concat "Sort the buffer menu by " downname ".") | 664 | (if Buffer-menu-use-header-line |
| 642 | (interactive (list last-input-event)) | 665 | "mouse-1, mouse-2: sort by " |
| 643 | (if e (mouse-select-window e)) | 666 | "mouse-2, RET: sort by ") |
| 644 | (Buffer-menu-sort ,column))) | 667 | (if column (downcase name) "visited order")) |
| 645 | (sym (intern (format "Buffer-menu-sort-by-%s-%s" name column)))) | 668 | 'mouse-face 'highlight |
| 646 | ;; Use a symbol rather than an anonymous function, to make the output of | 669 | 'keymap Buffer-menu-sort-button-map)) |
| 647 | ;; C-h k less intimidating. | ||
| 648 | (fset sym fun) | ||
| 649 | (setq fun sym) | ||
| 650 | ;; This keymap handles both nil and non-nil | ||
| 651 | ;; values for Buffer-menu-use-header-line. | ||
| 652 | (define-key map [header-line mouse-1] fun) | ||
| 653 | (define-key map [header-line mouse-2] fun) | ||
| 654 | (define-key map [mouse-2] fun) | ||
| 655 | (define-key map [follow-link] 'mouse-face) | ||
| 656 | (define-key map "\C-m" fun) | ||
| 657 | (propertize name | ||
| 658 | 'help-echo (concat | ||
| 659 | (if Buffer-menu-use-header-line | ||
| 660 | "mouse-1, mouse-2: sort by " | ||
| 661 | "mouse-2, RET: sort by ") | ||
| 662 | ;; No clue what this is for, but I preserved the | ||
| 663 | ;; behavior, just in case. --Stef | ||
| 664 | (if column downname "visited order")) | ||
| 665 | 'mouse-face 'highlight | ||
| 666 | 'keymap map))) | ||
| 667 | 670 | ||
| 668 | (defun list-buffers-noselect (&optional files-only buffer-list) | 671 | (defun list-buffers-noselect (&optional files-only buffer-list) |
| 669 | "Create and return a buffer with a list of names of existing buffers. | 672 | "Create and return a buffer with a list of names of existing buffers. |