Mercurial > emacs
comparison lisp/ibuffer.el @ 91367:c70e45a7acfd
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-324
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 30 Jan 2008 07:57:28 +0000 |
parents | 606f2d163a64 4693d30bd9c1 |
children |
comparison
equal
deleted
inserted
replaced
91366:86f3a8f0a3a6 | 91367:c70e45a7acfd |
---|---|
207 can have multiple Ibuffer buffers open, each with a different sorted | 207 can have multiple Ibuffer buffers open, each with a different sorted |
208 view of the buffers." | 208 view of the buffers." |
209 :type '(choice (const :tag "Last view time" :value recency) | 209 :type '(choice (const :tag "Last view time" :value recency) |
210 (const :tag "Lexicographic" :value alphabetic) | 210 (const :tag "Lexicographic" :value alphabetic) |
211 (const :tag "Buffer size" :value size) | 211 (const :tag "Buffer size" :value size) |
212 (const :tag "File name" :value filename/process) | |
212 (const :tag "Major mode" :value major-mode)) | 213 (const :tag "Major mode" :value major-mode)) |
213 :group 'ibuffer) | 214 :group 'ibuffer) |
214 (defvar ibuffer-sorting-mode nil) | 215 (defvar ibuffer-sorting-mode nil) |
215 | 216 |
216 (defcustom ibuffer-default-sorting-reversep nil | 217 (defcustom ibuffer-default-sorting-reversep nil |
445 (define-key map (kbd ",") 'ibuffer-toggle-sorting-mode) | 446 (define-key map (kbd ",") 'ibuffer-toggle-sorting-mode) |
446 (define-key map (kbd "s i") 'ibuffer-invert-sorting) | 447 (define-key map (kbd "s i") 'ibuffer-invert-sorting) |
447 (define-key map (kbd "s a") 'ibuffer-do-sort-by-alphabetic) | 448 (define-key map (kbd "s a") 'ibuffer-do-sort-by-alphabetic) |
448 (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency) | 449 (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency) |
449 (define-key map (kbd "s s") 'ibuffer-do-sort-by-size) | 450 (define-key map (kbd "s s") 'ibuffer-do-sort-by-size) |
451 (define-key map (kbd "s f") 'ibuffer-do-sort-by-filename/process) | |
450 (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode) | 452 (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode) |
451 | 453 |
452 (define-key map (kbd "/ m") 'ibuffer-filter-by-mode) | 454 (define-key map (kbd "/ m") 'ibuffer-filter-by-mode) |
453 (define-key map (kbd "/ M") 'ibuffer-filter-by-used-mode) | 455 (define-key map (kbd "/ M") 'ibuffer-filter-by-used-mode) |
454 (define-key map (kbd "/ n") 'ibuffer-filter-by-name) | 456 (define-key map (kbd "/ n") 'ibuffer-filter-by-name) |
824 (defvar ibuffer-name-map | 826 (defvar ibuffer-name-map |
825 (let ((map (make-sparse-keymap))) | 827 (let ((map (make-sparse-keymap))) |
826 (define-key map [(mouse-1)] 'ibuffer-mouse-toggle-mark) | 828 (define-key map [(mouse-1)] 'ibuffer-mouse-toggle-mark) |
827 (define-key map [(mouse-2)] 'ibuffer-mouse-visit-buffer) | 829 (define-key map [(mouse-2)] 'ibuffer-mouse-visit-buffer) |
828 (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu) | 830 (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu) |
831 map)) | |
832 | |
833 (defvar ibuffer-filename/process-header-map | |
834 (let ((map (make-sparse-keymap))) | |
835 (define-key map [(mouse-1)] 'ibuffer-do-sort-by-filename/process) | |
829 map)) | 836 map)) |
830 | 837 |
831 (defvar ibuffer-mode-name-map | 838 (defvar ibuffer-mode-name-map |
832 (let ((map (make-sparse-keymap))) | 839 (let ((map (make-sparse-keymap))) |
833 (define-key map [(mouse-2)] 'ibuffer-mouse-filter-by-mode) | 840 (define-key map [(mouse-2)] 'ibuffer-mouse-filter-by-mode) |
1720 :header-mouse-map ibuffer-mode-header-map | 1727 :header-mouse-map ibuffer-mode-header-map |
1721 :props | 1728 :props |
1722 ('mouse-face 'highlight | 1729 ('mouse-face 'highlight |
1723 'keymap ibuffer-mode-name-map | 1730 'keymap ibuffer-mode-name-map |
1724 'help-echo "mouse-2: filter by this mode")) | 1731 'help-echo "mouse-2: filter by this mode")) |
1725 (format-mode-line mode-name)) | 1732 (format-mode-line mode-name nil nil (current-buffer))) |
1726 | 1733 |
1727 (define-ibuffer-column process | 1734 (define-ibuffer-column process |
1728 (:summarizer | 1735 (:summarizer |
1729 (lambda (strings) | 1736 (lambda (strings) |
1730 (let ((total (length (delete "" strings)))) | 1737 (let ((total (length (delete "" strings)))) |
1751 (car dired-directory))) | 1758 (car dired-directory))) |
1752 "")))) | 1759 "")))) |
1753 | 1760 |
1754 (define-ibuffer-column filename-and-process | 1761 (define-ibuffer-column filename-and-process |
1755 (:name "Filename/Process" | 1762 (:name "Filename/Process" |
1763 :header-mouse-map ibuffer-filename/process-header-map | |
1756 :summarizer | 1764 :summarizer |
1757 (lambda (strings) | 1765 (lambda (strings) |
1758 (setq strings (delete "" strings)) | 1766 (setq strings (delete "" strings)) |
1759 (let ((procs 0) | 1767 (let ((procs 0) |
1760 (files 0)) | 1768 (files 0)) |
2095 align) | 2103 align) |
2096 summary))))))) | 2104 summary))))))) |
2097 (point)) | 2105 (point)) |
2098 `(ibuffer-summary t))))) | 2106 `(ibuffer-summary t))))) |
2099 | 2107 |
2100 (defun ibuffer-update-mode-name () | |
2101 (setq mode-name (format "Ibuffer by %s" (if ibuffer-sorting-mode | |
2102 ibuffer-sorting-mode | |
2103 "view time"))) | |
2104 (when ibuffer-sorting-reversep | |
2105 (setq mode-name (concat mode-name " [rev]"))) | |
2106 (when (and (featurep 'ibuf-ext) | |
2107 ibuffer-auto-mode) | |
2108 (setq mode-name (concat mode-name " (Auto)"))) | |
2109 (let ((result "")) | |
2110 (when (featurep 'ibuf-ext) | |
2111 (dolist (qualifier ibuffer-filtering-qualifiers) | |
2112 (setq result | |
2113 (concat result (ibuffer-format-qualifier qualifier)))) | |
2114 (if ibuffer-use-header-line | |
2115 (setq header-line-format | |
2116 (when ibuffer-filtering-qualifiers | |
2117 (replace-regexp-in-string "%" "%%" | |
2118 (concat mode-name result)))) | |
2119 (progn | |
2120 (setq mode-name (concat mode-name result)) | |
2121 (when (boundp 'header-line-format) | |
2122 (setq header-line-format nil))))))) | |
2123 | 2108 |
2124 (defun ibuffer-redisplay (&optional silent) | 2109 (defun ibuffer-redisplay (&optional silent) |
2125 "Redisplay the current list of buffers. | 2110 "Redisplay the current list of buffers. |
2126 This does not show new buffers; use `ibuffer-update' for that. | 2111 This does not show new buffers; use `ibuffer-update' for that. |
2127 | 2112 |
2135 (if (and (featurep 'ibuf-ext) | 2120 (if (and (featurep 'ibuf-ext) |
2136 (or ibuffer-filtering-qualifiers ibuffer-hidden-filter-groups)) | 2121 (or ibuffer-filtering-qualifiers ibuffer-hidden-filter-groups)) |
2137 (message "No buffers! (note: filtering in effect)") | 2122 (message "No buffers! (note: filtering in effect)") |
2138 (error "No buffers!"))) | 2123 (error "No buffers!"))) |
2139 (ibuffer-redisplay-engine blist t) | 2124 (ibuffer-redisplay-engine blist t) |
2140 (ibuffer-update-mode-name) | |
2141 (unless silent | 2125 (unless silent |
2142 (message "Redisplaying current buffer list...done")) | 2126 (message "Redisplaying current buffer list...done")) |
2143 (ibuffer-forward-line 0))) | 2127 (ibuffer-forward-line 0))) |
2144 | 2128 |
2145 (defun ibuffer-update (arg &optional silent) | 2129 (defun ibuffer-update (arg &optional silent) |
2172 (message "No buffers! (note: filtering in effect)") | 2156 (message "No buffers! (note: filtering in effect)") |
2173 (error "No buffers!"))) | 2157 (error "No buffers!"))) |
2174 (unless silent | 2158 (unless silent |
2175 (message "Updating buffer list...")) | 2159 (message "Updating buffer list...")) |
2176 (ibuffer-redisplay-engine blist arg) | 2160 (ibuffer-redisplay-engine blist arg) |
2177 (ibuffer-update-mode-name) | |
2178 (unless silent | 2161 (unless silent |
2179 (message "Updating buffer list...done"))) | 2162 (message "Updating buffer list...done"))) |
2180 (if (eq ibuffer-shrink-to-minimum-size 'onewindow) | 2163 (if (eq ibuffer-shrink-to-minimum-size 'onewindow) |
2181 (ibuffer-shrink-to-fit t) | 2164 (ibuffer-shrink-to-fit t) |
2182 (when ibuffer-shrink-to-minimum-size | 2165 (when ibuffer-shrink-to-minimum-size |
2456 Sorting commands: | 2439 Sorting commands: |
2457 | 2440 |
2458 '\\[ibuffer-toggle-sorting-mode]' - Rotate between the various sorting modes. | 2441 '\\[ibuffer-toggle-sorting-mode]' - Rotate between the various sorting modes. |
2459 '\\[ibuffer-invert-sorting]' - Reverse the current sorting order. | 2442 '\\[ibuffer-invert-sorting]' - Reverse the current sorting order. |
2460 '\\[ibuffer-do-sort-by-alphabetic]' - Sort the buffers lexicographically. | 2443 '\\[ibuffer-do-sort-by-alphabetic]' - Sort the buffers lexicographically. |
2444 '\\[ibuffer-do-sort-by-filename/process]' - Sort the buffers by the file name. | |
2461 '\\[ibuffer-do-sort-by-recency]' - Sort the buffers by last viewing time. | 2445 '\\[ibuffer-do-sort-by-recency]' - Sort the buffers by last viewing time. |
2462 '\\[ibuffer-do-sort-by-size]' - Sort the buffers by size. | 2446 '\\[ibuffer-do-sort-by-size]' - Sort the buffers by size. |
2463 '\\[ibuffer-do-sort-by-major-mode]' - Sort the buffers by major mode. | 2447 '\\[ibuffer-do-sort-by-major-mode]' - Sort the buffers by major mode. |
2464 | 2448 |
2465 Other commands: | 2449 Other commands: |
2538 will be inserted before the group at point." | 2522 will be inserted before the group at point." |
2539 (kill-all-local-variables) | 2523 (kill-all-local-variables) |
2540 (use-local-map ibuffer-mode-map) | 2524 (use-local-map ibuffer-mode-map) |
2541 (setq major-mode 'ibuffer-mode) | 2525 (setq major-mode 'ibuffer-mode) |
2542 (setq mode-name "Ibuffer") | 2526 (setq mode-name "Ibuffer") |
2527 ;; Include state info next to the mode name. | |
2528 (set (make-local-variable 'mode-line-process) | |
2529 '(" by " | |
2530 (ibuffer-sorting-mode (:eval (symbol-name ibuffer-sorting-mode)) | |
2531 "view time") | |
2532 (ibuffer-sorting-reversep " [rev]") | |
2533 (ibuffer-auto-mode " (Auto)") | |
2534 ;; Only list the filters if they're not already in the header-line. | |
2535 (header-line-format | |
2536 "" | |
2537 (:eval (if (functionp 'ibuffer-format-qualifier) | |
2538 (mapconcat 'ibuffer-format-qualifier | |
2539 ibuffer-filtering-qualifiers "")))))) | |
2540 (setq header-line-format | |
2541 (if ibuffer-use-header-line | |
2542 ;; Display the part that won't be in the mode-line. | |
2543 (list* "" mode-name | |
2544 (mapcar (lambda (elem) | |
2545 (if (eq (car-safe elem) 'header-line-format) | |
2546 (nth 2 elem) elem)) | |
2547 mode-line-process)))) | |
2548 | |
2543 (setq buffer-read-only t) | 2549 (setq buffer-read-only t) |
2544 (buffer-disable-undo) | 2550 (buffer-disable-undo) |
2545 (setq truncate-lines ibuffer-truncate-lines) | 2551 (setq truncate-lines ibuffer-truncate-lines) |
2546 ;; This makes things less ugly for Emacs 21 users with a non-nil | 2552 ;; This makes things less ugly for Emacs 21 users with a non-nil |
2547 ;; `show-trailing-whitespace'. | 2553 ;; `show-trailing-whitespace'. |
2576 (define-key ibuffer-mode-map [menu-bar operate] (cons "Operate" ibuffer-mode-operate-map)) | 2582 (define-key ibuffer-mode-map [menu-bar operate] (cons "Operate" ibuffer-mode-operate-map)) |
2577 (ibuffer-update-format) | 2583 (ibuffer-update-format) |
2578 (when ibuffer-default-directory | 2584 (when ibuffer-default-directory |
2579 (setq default-directory ibuffer-default-directory)) | 2585 (setq default-directory ibuffer-default-directory)) |
2580 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) | 2586 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
2581 (run-mode-hooks 'ibuffer-mode-hook) | 2587 (run-mode-hooks 'ibuffer-mode-hook)) |
2582 ;; called after mode hooks to allow the user to add filters | |
2583 (ibuffer-update-mode-name)) | |
2584 | 2588 |
2585 (provide 'ibuffer) | 2589 (provide 'ibuffer) |
2586 | 2590 |
2587 (run-hooks 'ibuffer-load-hook) | 2591 (run-hooks 'ibuffer-load-hook) |
2588 | 2592 |
2589 ;; Local Variables: | 2593 ;; Local Variables: |
2590 ;; coding: iso-8859-1 | 2594 ;; coding: iso-8859-1 |
2591 ;; End: | 2595 ;; End: |
2592 | 2596 |
2593 ;;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8 | 2597 ;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8 |
2594 ;;; ibuffer.el ends here | 2598 ;;; ibuffer.el ends here |