;; This file is part of GNU Emacs.
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 3, or (at
-;; your option) any later version.
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;; General Public License for more details.
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defsubst ibuffer-map-deletion-lines (func)
(ibuffer-map-on-mark ibuffer-deletion-char func))
+(defsubst ibuffer-assert-ibuffer-mode ()
+ (assert (derived-mode-p 'ibuffer-mode)))
+
+(defun ibuffer-buffer-file-name ()
+ (or buffer-file-name
+ (let ((dirname (or (and (boundp 'dired-directory)
+ (if (stringp dired-directory)
+ dired-directory
+ (car dired-directory)))
+ (bound-and-true-p list-buffers-directory))))
+ (and dirname (expand-file-name dirname)))
+ ""))
+
(define-ibuffer-op ibuffer-do-save ()
"Save marked buffers as with `save-buffer'."
(:complex t
(ibuffer-mark-interactive arg ?\s -1))
(defun ibuffer-mark-interactive (arg mark movement)
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(or arg (setq arg 1))
(ibuffer-forward-line 0)
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
(setq arg (1- arg))))))
(defun ibuffer-set-mark (mark)
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(let ((inhibit-read-only t))
(ibuffer-set-mark-1 mark)
(setq ibuffer-did-modification t)
(t (format "%d files" total))))))
(let ((directory-abbrev-alist ibuffer-directory-abbrev-alist))
(abbreviate-file-name
- (or buffer-file-name
- (and (boundp 'dired-directory)
- (if (stringp dired-directory)
- dired-directory
- (car dired-directory)))
- (and (eq major-mode 'vc-dir-mode)
- (bound-and-true-p default-directory))
- ""))))
+ (ibuffer-buffer-file-name))))
(define-ibuffer-column filename-and-process
(:name "Filename/Process"
(defun ibuffer-insert-buffer-line (buffer mark format)
"Insert a line describing BUFFER and MARK using FORMAT."
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(let ((beg (point)))
(funcall format buffer mark)
(put-text-property beg (point) 'ibuffer-properties (list buffer mark)))
;; This function knows a bit too much of the internals. It would be
;; nice if it was all abstracted away.
(defun ibuffer-redisplay-current ()
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(when (eobp)
(forward-line -1))
(beginning-of-line)
FUNCTION is called with two arguments:
the buffer object itself and the current mark symbol."
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(ibuffer-forward-line 0)
(let* ((orig-target-line (1+ (count-lines (save-excursion
(goto-char (point-min))
(defun ibuffer-switch-format ()
"Switch the current display format."
(interactive)
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(unless (consp ibuffer-formats)
(error "Ibuffer error: No formats!"))
(setq ibuffer-current-format
(ibuffer-redisplay t))
(defun ibuffer-update-title-and-summary (format)
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
;; Don't do funky font-lock stuff here
(let ((after-change-functions nil))
(if (get-text-property (point-min) 'ibuffer-title)
name)))
(defun ibuffer-redisplay-engine (bmarklist &optional ignore)
- (assert (eq major-mode 'ibuffer-mode))
+ (ibuffer-assert-ibuffer-mode)
(let* ((--ibuffer-insert-buffers-and-marks-format
(ibuffer-current-format))
(--ibuffer-expanded-format (mapcar #'ibuffer-expand-format-entry