Commit 23eabff6 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(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.
parent b5c49962
2008-01-16 Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment