From: Stefan Monnier Date: Wed, 16 Jan 2008 16:11:09 +0000 (+0000) Subject: (mode): Pass the buffer to format-mode-line. X-Git-Tag: emacs-pretest-23.0.90~8542 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=23eabff6db4307e484b26be2e94d0721544e9f2f;p=emacs.git (mode): Pass the buffer to format-mode-line. (ibuffer-update-mode-name): Remove. (ibuffer-redisplay, ibuffer-update, ibuffer-mode): Don't call it. (ibuffer-mode): Use mode-line-process instead. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 19155ed1b6b..6db94872819 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2008-01-16 Stefan Monnier + * ibuffer.el (mode): Pass the buffer to format-mode-line. + (ibuffer-update-mode-name): Remove. + (ibuffer-redisplay, ibuffer-update, ibuffer-mode): Don't call it. + (ibuffer-mode): Use mode-line-process instead. + * ibuf-ext.el (ibuffer-auto-update-changed, ibuffer-auto-mode): Use derived-mode-p. (ibuffer-mark-by-mode-regexp): Pass the buffer to format-mode-line. diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 9e6918e8020..0a26311541c 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -1722,7 +1722,7 @@ If point is on a group name, this function operates on that group." ('mouse-face 'highlight 'keymap ibuffer-mode-name-map 'help-echo "mouse-2: filter by this mode")) - (format-mode-line mode-name)) + (format-mode-line mode-name nil nil (current-buffer))) (define-ibuffer-column process (:summarizer @@ -2097,29 +2097,6 @@ the value of point at the beginning of the line for that buffer." (point)) `(ibuffer-summary t))))) -(defun ibuffer-update-mode-name () - (setq mode-name (format "Ibuffer by %s" (if ibuffer-sorting-mode - ibuffer-sorting-mode - "view time"))) - (when ibuffer-sorting-reversep - (setq mode-name (concat mode-name " [rev]"))) - (when (and (featurep 'ibuf-ext) - ibuffer-auto-mode) - (setq mode-name (concat mode-name " (Auto)"))) - (let ((result "")) - (when (featurep 'ibuf-ext) - (dolist (qualifier ibuffer-filtering-qualifiers) - (setq result - (concat result (ibuffer-format-qualifier qualifier)))) - (if ibuffer-use-header-line - (setq header-line-format - (when ibuffer-filtering-qualifiers - (replace-regexp-in-string "%" "%%" - (concat mode-name result)))) - (progn - (setq mode-name (concat mode-name result)) - (when (boundp 'header-line-format) - (setq header-line-format nil))))))) (defun ibuffer-redisplay (&optional silent) "Redisplay the current list of buffers. @@ -2137,7 +2114,6 @@ If optional arg SILENT is non-nil, do not display progress messages." (message "No buffers! (note: filtering in effect)") (error "No buffers!"))) (ibuffer-redisplay-engine blist t) - (ibuffer-update-mode-name) (unless silent (message "Redisplaying current buffer list...done")) (ibuffer-forward-line 0))) @@ -2174,7 +2150,6 @@ If optional arg SILENT is non-nil, do not display progress messages." (unless silent (message "Updating buffer list...")) (ibuffer-redisplay-engine blist arg) - (ibuffer-update-mode-name) (unless silent (message "Updating buffer list...done"))) (if (eq ibuffer-shrink-to-minimum-size 'onewindow) @@ -2540,6 +2515,25 @@ will be inserted before the group at point." (use-local-map ibuffer-mode-map) (setq major-mode 'ibuffer-mode) (setq mode-name "Ibuffer") + ;; Include state info next to the mode name. + (set (make-local-variable mode-line-process) + '((ibuffer-sorting-mode (:eval (symbol-name ibuffer-sorting-mode)) + "view time") + (ibuffer-sorting-reversep " [rev]") + (ibuffer-auto-mode " (Auto)") + ;; Only list the filters if they're not already in the header-line. + (header-line-format + "" + (:eval (if (functionp 'ibuffer-format-qualifier) + (mapconcat 'ibuffer-format-qualifier + ibuffer-filtering-qualifiers "")))))) + (setq header-line-format + (if ibuffer-use-header-line + ;; Display the part that won't be in the mode-line. + (mapcar (lambda (elem) (if (eq (car-safe elem) 'header-line-format) + (nth 2 elem) elem)) + mode-line-process))) + (setq buffer-read-only t) (buffer-disable-undo) (setq truncate-lines ibuffer-truncate-lines) @@ -2578,9 +2572,7 @@ will be inserted before the group at point." (when ibuffer-default-directory (setq default-directory ibuffer-default-directory)) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) - (run-mode-hooks 'ibuffer-mode-hook) - ;; called after mode hooks to allow the user to add filters - (ibuffer-update-mode-name)) + (run-mode-hooks 'ibuffer-mode-hook)) (provide 'ibuffer) @@ -2590,5 +2582,5 @@ will be inserted before the group at point." ;; coding: iso-8859-1 ;; End: -;;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8 +;; arch-tag: 72581688-0603-4954-b8cf-837c700f62e8 ;;; ibuffer.el ends here