From: Dan Nicolaescu Date: Fri, 25 Jan 2008 05:38:31 +0000 (+0000) Subject: * ibuffer.el (ibuffer-default-sorting-mode): Add option to sort by X-Git-Tag: emacs-pretest-23.0.90~8418 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d57941800355c2a967705089d9bc790a58d18a3a;p=emacs.git * ibuffer.el (ibuffer-default-sorting-mode): Add option to sort by file name. (ibuffer-mode-map): Add binding to sort by file name. (ibuffer-filename/process-header-map): New variable. (filename-and-process): Add a header that sorts by file name. (ibuffer-mode): Mention sorting by file name. * ibuf-ext.el (filename/process): New sorter. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b93a5f3a37b..68cac6e786e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2008-01-25 Dan Nicolaescu + + * ibuffer.el (ibuffer-default-sorting-mode): Add option to sort by + file name. + (ibuffer-mode-map): Add binding to sort by file name. + (ibuffer-filename/process-header-map): New variable. + (filename-and-process): Add a header that sorts by file name. + (ibuffer-mode): Mention sorting by file name. + + * ibuf-ext.el (filename/process): New sorter. + 2008-01-25 Sven Joachim * view.el (kill-buffer-if-not-modified): Don't pass t to diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 0499fab51aa..82face5eccb 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -1155,6 +1155,20 @@ Ordering is lexicographic." (with-current-buffer (car b) (buffer-size)))) +;;;###autoload (autoload 'ibuffer-do-sort-by-filename/process "ibuf-ext") +(define-ibuffer-sorter filename/process + "Sort the buffers by their file name/process name." + (:description "file name") + (string-lessp + ;; FIXME: For now just compare the file name and the process name + ;; (if it exists). Is there a better way to do this? + (or (buffer-file-name (car a)) + (let ((pr-a (get-buffer-process (car a)))) + (and (processp pr-a) (process-name pr-a)))) + (or (buffer-file-name (car b)) + (let ((pr-b (get-buffer-process (car b)))) + (and (processp pr-b) (process-name pr-b)))))) + ;;; Functions to emulate bs.el ;;;###autoload diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index dcf840fc584..7c6da00cf0f 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -209,6 +209,7 @@ view of the buffers." :type '(choice (const :tag "Last view time" :value recency) (const :tag "Lexicographic" :value alphabetic) (const :tag "Buffer size" :value size) + (const :tag "File name" :value filename/process) (const :tag "Major mode" :value major-mode)) :group 'ibuffer) (defvar ibuffer-sorting-mode nil) @@ -447,6 +448,7 @@ directory, like `default-directory'." (define-key map (kbd "s a") 'ibuffer-do-sort-by-alphabetic) (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency) (define-key map (kbd "s s") 'ibuffer-do-sort-by-size) + (define-key map (kbd "s f") 'ibuffer-do-sort-by-filename/process) (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode) (define-key map (kbd "/ m") 'ibuffer-filter-by-mode) @@ -828,6 +830,11 @@ directory, like `default-directory'." (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu) map)) +(defvar ibuffer-filename/process-header-map + (let ((map (make-sparse-keymap))) + (define-key map [(mouse-1)] 'ibuffer-do-sort-by-filename/process) + map)) + (defvar ibuffer-mode-name-map (let ((map (make-sparse-keymap))) (define-key map [(mouse-2)] 'ibuffer-mouse-filter-by-mode) @@ -1753,6 +1760,7 @@ If point is on a group name, this function operates on that group." (define-ibuffer-column filename-and-process (:name "Filename/Process" + :header-mouse-map ibuffer-filename/process-header-map :summarizer (lambda (strings) (setq strings (delete "" strings)) @@ -2433,6 +2441,7 @@ Sorting commands: '\\[ibuffer-toggle-sorting-mode]' - Rotate between the various sorting modes. '\\[ibuffer-invert-sorting]' - Reverse the current sorting order. '\\[ibuffer-do-sort-by-alphabetic]' - Sort the buffers lexicographically. + '\\[ibuffer-do-sort-by-filename/process]' - Sort the buffers by the file name. '\\[ibuffer-do-sort-by-recency]' - Sort the buffers by last viewing time. '\\[ibuffer-do-sort-by-size]' - Sort the buffers by size. '\\[ibuffer-do-sort-by-major-mode]' - Sort the buffers by major mode.