+2008-01-25 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * 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 <svenjoac@gmx.de>
* view.el (kill-buffer-if-not-modified): Don't pass t to
(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
: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)
(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)
(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)
(define-ibuffer-column filename-and-process
(:name "Filename/Process"
+ :header-mouse-map ibuffer-filename/process-header-map
:summarizer
(lambda (strings)
(setq strings (delete "" strings))
'\\[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.