X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ac3232837188f7e1c4ffe34b76edede0ccb54f5e..51751aa26f9935609630f04e781a954b54ecc82e:/lisp/ibuf-ext.el diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 485a7351ff..073efaeee2 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -1,12 +1,12 @@ ;;; ibuf-ext.el --- extensions for ibuffer -;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, -;; 2008 Free Software Foundation, Inc. +;; Copyright (C) 2000-2011 Free Software Foundation, Inc. ;; Author: Colin Walters ;; Maintainer: John Paul Wallington ;; Created: 2 Dec 2001 ;; Keywords: buffer, convenience +;; Package: ibuffer ;; This file is part of GNU Emacs. @@ -91,11 +91,6 @@ regardless of any active filters in this buffer." (defvar ibuffer-tmp-show-regexps nil "A list of regexps which should match buffer names to always show.") -(defvar ibuffer-auto-mode nil - "If non-nil, Ibuffer auto-mode should be enabled for this buffer. -Do not set this variable directly! Use the function -`ibuffer-auto-mode' instead.") - (defvar ibuffer-auto-buffers-changed nil) (defcustom ibuffer-saved-filters '(("gnus" @@ -220,6 +215,16 @@ Currently, this only applies to `ibuffer-saved-filters' and (ibuffer-included-in-filters-p buf ibuffer-filtering-qualifiers) (ibuffer-buf-matches-predicates buf ibuffer-always-show-predicates))))) +;;;###autoload +(define-minor-mode ibuffer-auto-mode + "Toggle use of Ibuffer's auto-update facility. +With numeric ARG, enable auto-update if and only if ARG is positive." + nil nil nil + (unless (derived-mode-p 'ibuffer-mode) + (error "This buffer is not in Ibuffer mode")) + (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) ; Initialize state vector + (add-hook 'post-command-hook 'ibuffer-auto-update-changed)) + (defun ibuffer-auto-update-changed () (when (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) (dolist (buf (buffer-list)) @@ -229,20 +234,6 @@ Currently, this only applies to `ibuffer-saved-filters' and (derived-mode-p 'ibuffer-mode)) (ibuffer-update nil t))))))) -;;;###autoload -(defun ibuffer-auto-mode (&optional arg) - "Toggle use of Ibuffer's auto-update facility. -With numeric ARG, enable auto-update if and only if ARG is positive." - (interactive) - (unless (derived-mode-p 'ibuffer-mode) - (error "This buffer is not in Ibuffer mode")) - (set (make-local-variable 'ibuffer-auto-mode) - (if arg - (plusp arg) - (not ibuffer-auto-mode))) - (frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed) ; Initialize state vector - (add-hook 'post-command-hook 'ibuffer-auto-update-changed)) - ;;;###autoload (defun ibuffer-mouse-filter-by-mode (event) "Enable or disable filtering by the major mode chosen via mouse." @@ -514,7 +505,7 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." (assoc (cdr filter) ibuffer-saved-filters))) (unless data - (ibuffer-filter-disable) + (ibuffer-filter-disable t) (error "Unknown saved filter %s" (cdr filter))) (ibuffer-included-in-filters-p buf (cadr data)))) (t @@ -523,7 +514,7 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." ;; filterdat should be like (TYPE DESCRIPTION FUNC) ;; just a sanity check (unless filterdat - (ibuffer-filter-disable) + (ibuffer-filter-disable t) (error "Undefined filter %s" (car filter))) (not (not @@ -544,10 +535,11 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." (dolist (filtergroup filter-group-alist) (let ((filterset (cdr filtergroup))) (multiple-value-bind (hip-crowd lamers) - (ibuffer-split-list (lambda (bufmark) - (ibuffer-included-in-filters-p (car bufmark) - filterset)) - bmarklist) + (values-list + (ibuffer-split-list (lambda (bufmark) + (ibuffer-included-in-filters-p (car bufmark) + filterset)) + bmarklist)) (aset vec i hip-crowd) (incf i) (setq bmarklist lamers)))) @@ -776,10 +768,14 @@ The value from `ibuffer-saved-filter-groups' is used." (ibuffer-update nil t)) ;;;###autoload -(defun ibuffer-filter-disable () - "Disable all filters currently in effect in this buffer." +(defun ibuffer-filter-disable (&optional delete-filter-groups) + "Disable all filters currently in effect in this buffer. +With optional arg DELETE-FILTER-GROUPS non-nil, delete all filter +group definitions by setting `ibuffer-filter-groups' to nil." (interactive) (setq ibuffer-filtering-qualifiers nil) + (if delete-filter-groups + (setq ibuffer-filter-groups nil)) (let ((buf (ibuffer-current-buffer))) (ibuffer-update nil t) (when buf @@ -1160,10 +1156,10 @@ Ordering is lexicographic." (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)) + (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)) + (or (buffer-file-name (car b)) (let ((pr-b (get-buffer-process (car b)))) (and (processp pr-b) (process-name pr-b)))))) @@ -1226,12 +1222,10 @@ mean move backwards, non-negative integers mean move forwards." (setq direction 1)) ;; Skip the title (ibuffer-forward-line 0) - (let ((opos (point)) - curmark) + (let ((opos (point))) (ibuffer-forward-line direction) (while (not (or (= (point) opos) - (eq (setq curmark (ibuffer-current-mark)) - mark))) + (eq (ibuffer-current-mark) mark))) (ibuffer-forward-line direction)) (when (and (= (point) opos) (not (eq (ibuffer-current-mark) mark))) @@ -1254,7 +1248,7 @@ to move by. The default is `ibuffer-marked-char'." (message "No buffers marked; use 'm' to mark a buffer") (let ((count (ibuffer-map-marked-lines - #'(lambda (buf mark) + #'(lambda (_buf _mark) 'kill)))) (message "Killed %s lines" count)))) @@ -1286,7 +1280,7 @@ a prefix argument reverses the meaning of that variable." (let (buf-point) ;; Blindly search for our buffer: it is very likely that it is ;; not in a hidden filter group. - (ibuffer-map-lines #'(lambda (buf marks) + (ibuffer-map-lines #'(lambda (buf _marks) (when (string= (buffer-name buf) name) (setq buf-point (point)) nil)) @@ -1300,7 +1294,7 @@ a prefix argument reverses the meaning of that variable." (dolist (group ibuffer-hidden-filter-groups) (ibuffer-jump-to-filter-group group) (ibuffer-toggle-filter-group) - (ibuffer-map-lines #'(lambda (buf marks) + (ibuffer-map-lines #'(lambda (buf _marks) (when (string= (buffer-name buf) name) (setq buf-point (point)) nil)) @@ -1315,7 +1309,8 @@ a prefix argument reverses the meaning of that variable." (error "No buffer with name %s" name) (goto-char buf-point))))) -(declare-function diff-sentinel "diff" (code)) +(declare-function diff-sentinel "diff" + (code &optional old-temp-file new-temp-file)) (defun ibuffer-diff-buffer-with-file-1 (buffer) (let ((bufferfile (buffer-local-value 'buffer-file-name buffer)) @@ -1337,13 +1332,12 @@ a prefix argument reverses the meaning of that variable." ;; Use explicitly specified switches ,@(if (listp switches) switches (list switches)) ,@(if (or old new) - (list "-L" old + (list "-L" (shell-quote-argument old) "-L" (shell-quote-argument (format "Buffer %s" (buffer-name buffer))))) ,(shell-quote-argument (or oldtmp old)) ,(shell-quote-argument (or newtmp new))) - " ")) - proc) + " "))) (let ((inhibit-read-only t)) (insert command "\n") (diff-sentinel @@ -1402,7 +1396,7 @@ You can then feed the file name(s) to other commands with \\[yank]." (t 'name)))) (ibuffer-map-marked-lines - #'(lambda (buf mark) + #'(lambda (buf _mark) (setq ibuffer-copy-filename-as-kill-result (concat ibuffer-copy-filename-as-kill-result (let ((name (buffer-file-name buf))) @@ -1423,7 +1417,7 @@ You can then feed the file name(s) to other commands with \\[yank]." (defun ibuffer-mark-on-buffer (func &optional ibuffer-mark-on-buffer-mark group) (let ((count (ibuffer-map-lines - #'(lambda (buf mark) + #'(lambda (buf _mark) (when (funcall func buf) (ibuffer-set-mark-1 (or ibuffer-mark-on-buffer-mark ibuffer-marked-char)) @@ -1591,11 +1585,14 @@ defaults to one." (let ((ibuffer-do-occur-bufs nil)) ;; Accumulate a list of marked buffers (ibuffer-map-marked-lines - #'(lambda (buf mark) + #'(lambda (buf _mark) (push buf ibuffer-do-occur-bufs))) (occur-1 regexp nlines ibuffer-do-occur-bufs))) (provide 'ibuf-ext) -;; arch-tag: 9af21953-deda-4c30-b76d-f81d9128e76d +;; Local Variables: +;; generated-autoload-file: "ibuffer.el" +;; End: + ;;; ibuf-ext.el ends here