* semantic/wisent/javascript.el (js-mode): Define `js-mode' as
[bpt/emacs.git] / lisp / ibuffer.el
CommitLineData
25d2f683
CW
1;;; ibuffer.el --- operate on buffers like dired
2
acaf905b 3;; Copyright (C) 2000-2012 Free Software Foundation, Inc.
25d2f683
CW
4
5;; Author: Colin Walters <walters@verbum.org>
4e4a724c 6;; Maintainer: John Paul Wallington <jpw@gnu.org>
25d2f683 7;; Created: 8 Sep 2000
25d2f683 8;; Keywords: buffer, convenience
25d2f683 9
b5cd37ea 10;; This file is part of GNU Emacs.
25d2f683 11
eb3fa2cf
GM
12;; GNU Emacs is free software: you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
25d2f683 16
eb3fa2cf
GM
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
25d2f683
CW
21
22;; You should have received a copy of the GNU General Public License
eb3fa2cf 23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25d2f683
CW
24
25;;; Commentary:
26
27;; ibuffer.el is an advanced replacement for the `buffer-menu' which
28;; is normally distributed with Emacs. Its interface is intended to
29;; be analogous to that of Dired.
30
31;;; Code:
32
33(eval-when-compile
34 (require 'cl)
35 (require 'ibuf-macs)
36 (require 'dired))
37
730da5b2 38(require 'font-core)
fd225d80 39
735d7026
JB
40;; These come from ibuf-ext.el, which can not be require'd at compile time
41;; because it has a recursive dependency on ibuffer.el
42(defvar ibuffer-auto-mode)
43(defvar ibuffer-cached-filter-formats)
44(defvar ibuffer-compiled-filter-formats)
45(defvar ibuffer-filter-format-alist)
46(defvar ibuffer-filter-group-kill-ring)
47(defvar ibuffer-filter-groups)
48(defvar ibuffer-filtering-qualifiers)
6d11a78b 49(defvar ibuffer-header-line-format)
735d7026
JB
50(defvar ibuffer-hidden-filter-groups)
51(defvar ibuffer-inline-columns)
52(defvar ibuffer-show-empty-filter-groups)
53(defvar ibuffer-tmp-hide-regexps)
54(defvar ibuffer-tmp-show-regexps)
63f0a166 55
2ead9289 56(declare-function ibuffer-mark-on-buffer "ibuf-ext"
004a00f4 57 (func &optional ibuffer-mark-on-buffer-mark group))
2ead9289 58(declare-function ibuffer-generate-filter-groups "ibuf-ext"
004a00f4
DN
59 (bmarklist &optional noempty nodefault))
60(declare-function ibuffer-format-filter-group-data "ibuf-ext" (filter))
61
25d2f683
CW
62(defgroup ibuffer nil
63 "An advanced replacement for `buffer-menu'.
64
65Ibuffer allows you to operate on buffers in a manner much like Dired.
66Operations include sorting, marking by regular expression, and
67the ability to filter the displayed buffers by various criteria."
bf247b6e 68 :version "22.1"
25d2f683
CW
69 :group 'convenience)
70
ac3c7293
JPW
71(defcustom ibuffer-formats '((mark modified read-only " " (name 18 18 :left :elide)
72 " " (size 9 -1 :right)
b9debd54 73 " " (mode 16 16 :left :elide) " " filename-and-process)
25d2f683
CW
74 (mark " " (name 16 -1) " " filename))
75 "A list of ways to display buffer lines.
76
77With Ibuffer, you are not limited to displaying just certain
78attributes of a buffer such as size, name, and mode in a particular
cba63a2d 79order. Through this variable, you can completely customize and
25d2f683
CW
80control the appearance of an Ibuffer buffer. See also
81`define-ibuffer-column', which allows you to define your own columns
82for display.
83
84This variable has the form
2e4fae7d 85 ((COLUMN COLUMN ...) (COLUMN COLUMN ...) ...)
25d2f683
CW
86Each element in `ibuffer-formats' should be a list containing COLUMN
87specifiers. A COLUMN can be any of the following:
88
89 SYMBOL - A symbol naming the column. Predefined columns are:
90 mark modified read-only name size mode process filename
91 When you define your own columns using `define-ibuffer-column', just
92 use their name like the predefined columns here. This entry can
93 also be a function of two arguments, which should return a string.
94 The first argument is the buffer object, and the second is the mark
95 on that buffer.
96 or
97 \"STRING\" - A literal string to display.
98 or
99 (SYMBOL MIN-SIZE MAX-SIZE &optional ALIGN ELIDE) - SYMBOL is a
100 symbol naming the column, and MIN-SIZE and MAX-SIZE are integers (or
101 functions of no arguments returning an integer) which constrict the
102 size of a column. If MAX-SIZE is -1, there is no upper bound. The
103 default values are 0 and -1, respectively. If MIN-SIZE is negative,
104 use the end of the string. The optional element ALIGN describes the
105 alignment of the column; it can be :left, :center or :right. The
106 optional element ELIDE describes whether or not to elide the column
107 if it is too long; valid values are :elide and nil. The default is
108 nil (don't elide).
109
110Some example of valid entries in `ibuffer-formats', with
111description (also, feel free to try them out, and experiment with your
112own!):
113
114 (mark \" \" name)
115 This format just displays the current mark (if any) and the name of
116 the buffer, separated by a space.
117 (mark modified read-only \" \" (name 16 16 :left) \" \" (size 6 -1 :right))
118 This format displays the current mark (if any), its modification and
119 read-only status, as well as the name of the buffer and its size. In
120 this format, the name is restricted to 16 characters (longer names
523304ed 121 will be truncated, and shorter names will be padded with spaces), and
cba63a2d 122 the name is also aligned to the left. The size of the buffer will
25d2f683
CW
123 be padded with spaces up to a minimum of six characters, but there is
124 no upper limit on its size. The size will also be aligned to the
125 right.
126
127Thus, if you wanted to use these two formats, add
128
129 (setq ibuffer-formats '((mark \" \" name)
130 (mark modified read-only
131 (name 16 16 :left) (size 6 -1 :right))))
132
133to your ~/.emacs file.
134
135Using \\[ibuffer-switch-format], you can rotate the display between
136the specified formats in the list."
137 :type '(repeat sexp)
138 :group 'ibuffer)
139
140(defcustom ibuffer-always-compile-formats (featurep 'bytecomp)
141 "If non-nil, then use the byte-compiler to optimize `ibuffer-formats'.
142This will increase the redisplay speed, at the cost of loading the
143elisp byte-compiler."
144 :type 'boolean
145 :group 'ibuffer)
146
147(defcustom ibuffer-fontification-alist
40c10465 148 `((10 buffer-read-only font-lock-constant-face)
9fe14abe
JPW
149 (15 (and buffer-file-name
150 (string-match ibuffer-compressed-file-name-regexp
151 buffer-file-name))
152 font-lock-doc-face)
153 (20 (string-match "^*" (buffer-name)) font-lock-keyword-face)
154 (25 (and (string-match "^ " (buffer-name))
da337a28
JPW
155 (null buffer-file-name))
156 italic)
9fe14abe
JPW
157 (30 (memq major-mode ibuffer-help-buffer-modes) font-lock-comment-face)
158 (35 (eq major-mode 'dired-mode) font-lock-function-name-face))
25d2f683
CW
159 "An alist describing how to fontify buffers.
160Each element should be of the form (PRIORITY FORM FACE), where
161PRIORITY is an integer, FORM is an arbitrary form to evaluate in the
162buffer, and FACE is the face to use for fontification. If the FORM
163evaluates to non-nil, then FACE will be put on the buffer name. The
fd225d80
CW
164element with the highest PRIORITY takes precedence.
165
4e4a724c 166If you change this variable, you must kill the Ibuffer buffer and
fd225d80 167recreate it for the change to take effect."
25d2f683
CW
168 :type '(repeat
169 (list (integer :tag "Priority")
170 (sexp :tag "Test Form")
171 face))
172 :group 'ibuffer)
173
174(defcustom ibuffer-use-other-window nil
7ad5b902 175 "If non-nil, display Ibuffer in another window by default."
25d2f683
CW
176 :type 'boolean
177 :group 'ibuffer)
178
179(defcustom ibuffer-default-shrink-to-minimum-size nil
180 "If non-nil, minimize the size of the Ibuffer window by default."
181 :type 'boolean
182 :group 'ibuffer)
183(defvar ibuffer-shrink-to-minimum-size nil)
184
0740098c
JPW
185(defcustom ibuffer-display-summary t
186 "If non-nil, summarize Ibuffer columns."
187 :type 'boolean
188 :group 'ibuffer)
189
3eda3649
CW
190(defcustom ibuffer-truncate-lines t
191 "If non-nil, do not display continuation lines."
192 :type 'boolean
193 :group 'ibuffer)
194
25d2f683
CW
195(defcustom ibuffer-case-fold-search case-fold-search
196 "If non-nil, ignore case when searching."
197 :type 'boolean
198 :group 'ibuffer)
199
200(defcustom ibuffer-default-sorting-mode 'recency
201 "The criteria by which to sort the buffers.
202
4e4a724c
JPW
203Note that this variable is local to each Ibuffer buffer. Thus, you
204can have multiple Ibuffer buffers open, each with a different sorted
25d2f683
CW
205view of the buffers."
206 :type '(choice (const :tag "Last view time" :value recency)
207 (const :tag "Lexicographic" :value alphabetic)
208 (const :tag "Buffer size" :value size)
d5794180 209 (const :tag "File name" :value filename/process)
25d2f683
CW
210 (const :tag "Major mode" :value major-mode))
211 :group 'ibuffer)
212(defvar ibuffer-sorting-mode nil)
e7820654 213(defvar ibuffer-last-sorting-mode nil)
25d2f683
CW
214
215(defcustom ibuffer-default-sorting-reversep nil
216 "If non-nil, reverse the default sorting order."
217 :type 'boolean
218 :group 'ibuffer)
219(defvar ibuffer-sorting-reversep nil)
220
221(defcustom ibuffer-elide-long-columns nil
972b8f82 222 "If non-nil, then elide column entries which exceed their max length."
25d2f683
CW
223 :type 'boolean
224 :group 'ibuffer)
972b8f82
JB
225(make-obsolete-variable 'ibuffer-elide-long-columns
226 "use the :elide argument of `ibuffer-formats'."
227 "22.1")
25d2f683
CW
228
229(defcustom ibuffer-eliding-string "..."
230 "The string to use for eliding long columns."
231 :type 'string
232 :group 'ibuffer)
233
234(defcustom ibuffer-maybe-show-predicates `(,(lambda (buf)
235 (and (string-match "^ " (buffer-name buf))
236 (null buffer-file-name))))
4e4a724c
JPW
237 "A list of predicates for buffers to display conditionally.
238
239A predicate can be a regexp or a function.
25d2f683
CW
240If a regexp, then it will be matched against the buffer's name.
241If a function, it will be called with the buffer as an argument, and
242should return non-nil if this buffer should be shown.
243
957237cb 244Viewing of buffers hidden because of these predicates may be customized
bf247b6e 245via `ibuffer-default-display-maybe-show-predicates' and is toggled by
957237cb
JPW
246giving a non-nil prefix argument to `ibuffer-update'.
247Note that this specialized filtering occurs before real filtering."
25d2f683
CW
248 :type '(repeat (choice regexp function))
249 :group 'ibuffer)
250
957237cb
JPW
251(defcustom ibuffer-default-display-maybe-show-predicates nil
252 "Non-nil means show buffers that match `ibuffer-maybe-show-predicates'."
253 :type 'boolean
254 :group 'ibuffer)
255
256(defvar ibuffer-display-maybe-show-predicates nil)
257
25d2f683
CW
258(defvar ibuffer-current-format nil)
259
0ce780e1
CW
260(defcustom ibuffer-movement-cycle t
261 "If non-nil, then forward and backwards movement commands cycle."
262 :type 'boolean
263 :group 'ibuffer)
264
25d2f683
CW
265(defcustom ibuffer-modified-char ?*
266 "The character to display for modified buffers."
267 :type 'character
268 :group 'ibuffer)
269
270(defcustom ibuffer-read-only-char ?%
271 "The character to display for read-only buffers."
272 :type 'character
273 :group 'ibuffer)
274
275(defcustom ibuffer-marked-char ?>
276 "The character to display for marked buffers."
277 :type 'character
278 :group 'ibuffer)
279
280(defcustom ibuffer-deletion-char ?D
281 "The character to display for buffers marked for deletion."
282 :type 'character
283 :group 'ibuffer)
284
285(defcustom ibuffer-expert nil
286 "If non-nil, don't ask for confirmation of \"dangerous\" operations."
287 :type 'boolean
288 :group 'ibuffer)
289
290(defcustom ibuffer-view-ibuffer nil
291 "If non-nil, display the current Ibuffer buffer itself.
292Note that this has a drawback - the data about the current Ibuffer
293buffer will most likely be inaccurate. This includes modification
294state, size, etc."
295 :type 'boolean
296 :group 'ibuffer)
297
298(defcustom ibuffer-always-show-last-buffer nil
4e4a724c
JPW
299 "If non-nil, always display the previous buffer.
300This variable takes precedence over filtering, and even
25d2f683
CW
301`ibuffer-never-show-predicates'."
302 :type '(choice (const :tag "Always" :value t)
303 (const :tag "Never" :value nil)
304 (const :tag "Always except minibuffer" :value :nomini))
305 :group 'ibuffer)
306
0bdd7ae4
JPW
307(defcustom ibuffer-jump-offer-only-visible-buffers nil
308 "If non-nil, only offer buffers visible in the Ibuffer buffer
309in completion lists of the `ibuffer-jump-to-buffer' command."
310 :type 'boolean
311 :group 'ibuffer)
312
25d2f683 313(defcustom ibuffer-use-header-line (boundp 'header-line-format)
7ad5b902 314 "If non-nil, display a header line containing current filters."
25d2f683
CW
315 :type 'boolean
316 :group 'ibuffer)
317
318(defcustom ibuffer-default-directory nil
4e4a724c 319 "The default directory to use for a new Ibuffer buffer.
2e4fae7d 320If nil, inherit the directory of the buffer in which `ibuffer' was
25d2f683
CW
321called. Otherwise, this variable should be a string naming a
322directory, like `default-directory'."
323 :type '(choice (const :tag "Inherit" :value nil)
324 string)
325 :group 'ibuffer)
326
4e4a724c
JPW
327(defcustom ibuffer-help-buffer-modes
328 '(help-mode apropos-mode Info-mode Info-edit-mode)
60356fb5
CW
329 "List of \"Help\" major modes."
330 :type '(repeat function)
331 :group 'ibuffer)
332
9fe14abe 333(defcustom ibuffer-compressed-file-name-regexp
4c964351 334 "\\.\\(arj\\|bgz\\|bz2\\|gz\\|lzh\\|taz\\|tgz\\|xz\\|zip\\|z\\)$"
9fe14abe 335 "Regexp to match compressed file names."
4c964351 336 :version "24.1" ; added xz
9fe14abe 337 :type 'regexp
c7f5c0a8 338 :group 'ibuffer)
9fe14abe 339
cd6ef82d
GM
340(define-obsolete-variable-alias 'ibuffer-hooks 'ibuffer-hook "22.1")
341
e9e96ba0 342(defcustom ibuffer-hook nil
4e4a724c 343 "Hook run when `ibuffer' is called."
25d2f683
CW
344 :type 'hook
345 :group 'ibuffer)
cd6ef82d
GM
346
347(define-obsolete-variable-alias 'ibuffer-mode-hooks 'ibuffer-mode-hook "22.1")
25d2f683 348
e9e96ba0 349(defcustom ibuffer-mode-hook nil
4e4a724c 350 "Hook run upon entry into `ibuffer-mode'."
25d2f683
CW
351 :type 'hook
352 :group 'ibuffer)
353
4e4a724c
JPW
354(defcustom ibuffer-load-hook nil
355 "Hook run when Ibuffer is loaded."
356 :type 'hook
357 :group 'ibuffer)
358
f22f4808 359(defcustom ibuffer-marked-face 'warning
25d2f683
CW
360 "Face used for displaying marked buffers."
361 :type 'face
362 :group 'ibuffer)
363
f22f4808 364(defcustom ibuffer-deletion-face 'error
25d2f683
CW
365 "Face used for displaying buffers marked for deletion."
366 :type 'face
367 :group 'ibuffer)
368
369(defcustom ibuffer-title-face 'font-lock-type-face
370 "Face used for the title string."
371 :type 'face
372 :group 'ibuffer)
373
b5cd37ea
CW
374(defcustom ibuffer-filter-group-name-face 'bold
375 "Face used for displaying filtering group names."
376 :type 'face
377 :group 'ibuffer)
378
25d2f683
CW
379(defcustom ibuffer-directory-abbrev-alist nil
380 "An alist of file name abbreviations like `directory-abbrev-alist'."
381 :type '(repeat (cons :format "%v"
382 :value ("" . "")
383 (regexp :tag "From")
384 (regexp :tag "To")))
385 :group 'ibuffer)
386
b016851c
SM
387(defvar ibuffer-mode-groups-popup
388 (let ((groups-map (make-sparse-keymap "Filter Groups")))
389 ;; Filter groups
390
391 (define-key-after groups-map [filters-to-filter-group]
392 '(menu-item "Create filter group from current filters..."
393 ibuffer-filters-to-filter-group
394 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)))
395 (define-key-after groups-map [forward-filter-group]
396 '(menu-item "Move point to the next filter group"
397 ibuffer-forward-filter-group))
398 (define-key-after groups-map [backward-filter-group]
399 '(menu-item "Move point to the previous filter group"
400 ibuffer-backward-filter-group))
401 (define-key-after groups-map [jump-to-filter-group]
402 '(menu-item "Move point to a specific filter group..."
403 ibuffer-jump-to-filter-group))
404 (define-key-after groups-map [kill-filter-group]
405 '(menu-item "Kill filter group named..."
406 ibuffer-kill-filter-group
407 :enable (and (featurep 'ibuf-ext) ibuffer-filter-groups)))
408 (define-key-after groups-map [yank-filter-group]
409 '(menu-item "Yank last killed filter group before..."
410 ibuffer-yank-filter-group
411 :enable (and (featurep 'ibuf-ext) ibuffer-filter-group-kill-ring)))
412 (define-key-after groups-map [pop-filter-group]
413 '(menu-item "Remove top filter group"
414 ibuffer-pop-filter-group
415 :enable (and (featurep 'ibuf-ext) ibuffer-filter-groups)))
416 (define-key-after groups-map [clear-filter-groups]
417 '(menu-item "Remove all filter groups"
418 ibuffer-clear-filter-groups
419 :enable (and (featurep 'ibuf-ext) ibuffer-filter-groups)))
420 (define-key-after groups-map [pop-filter-group]
421 '(menu-item "Decompose filter group..."
422 ibuffer-pop-filter-group
423 :help "\"Unmake\" a filter group"
424 :enable (and (featurep 'ibuf-ext) ibuffer-filter-groups)))
425 (define-key-after groups-map [save-filter-groups]
426 '(menu-item "Save current filter groups permanently..."
427 ibuffer-save-filter-groups
428 :enable (and (featurep 'ibuf-ext) ibuffer-filter-groups)
c80e3b4a 429 :help "Use a mnemonic name to store current filter groups"))
b016851c
SM
430 (define-key-after groups-map [switch-to-saved-filter-groups]
431 '(menu-item "Restore permanently saved filters..."
432 ibuffer-switch-to-saved-filter-groups
433 :enable (and (featurep 'ibuf-ext) ibuffer-saved-filter-groups)
434 :help "Replace current filters with a saved stack"))
435 (define-key-after groups-map [delete-saved-filter-groups]
436 '(menu-item "Delete permanently saved filter groups..."
437 ibuffer-delete-saved-filter-groups
438 :enable (and (featurep 'ibuf-ext) ibuffer-saved-filter-groups)))
439 (define-key-after groups-map [set-filter-groups-by-mode]
440 '(menu-item "Set current filter groups to filter by mode"
441 ibuffer-set-filter-groups-by-mode))
442
443 groups-map))
4e4a724c 444
b016851c
SM
445(defvar ibuffer-mode-map
446 (let ((map (make-keymap)))
25d2f683
CW
447 (define-key map (kbd "0") 'digit-argument)
448 (define-key map (kbd "1") 'digit-argument)
449 (define-key map (kbd "2") 'digit-argument)
450 (define-key map (kbd "3") 'digit-argument)
451 (define-key map (kbd "4") 'digit-argument)
452 (define-key map (kbd "5") 'digit-argument)
453 (define-key map (kbd "6") 'digit-argument)
454 (define-key map (kbd "7") 'digit-argument)
455 (define-key map (kbd "8") 'digit-argument)
456 (define-key map (kbd "9") 'digit-argument)
457
458 (define-key map (kbd "m") 'ibuffer-mark-forward)
459 (define-key map (kbd "t") 'ibuffer-toggle-marks)
460 (define-key map (kbd "u") 'ibuffer-unmark-forward)
461 (define-key map (kbd "=") 'ibuffer-diff-with-file)
462 (define-key map (kbd "j") 'ibuffer-jump-to-buffer)
0bdd7ae4 463 (define-key map (kbd "M-g") 'ibuffer-jump-to-buffer)
78176075
JL
464 (define-key map (kbd "M-s a C-s") 'ibuffer-do-isearch)
465 (define-key map (kbd "M-s a M-C-s") 'ibuffer-do-isearch-regexp)
25d2f683
CW
466 (define-key map (kbd "DEL") 'ibuffer-unmark-backward)
467 (define-key map (kbd "M-DEL") 'ibuffer-unmark-all)
468 (define-key map (kbd "* *") 'ibuffer-unmark-all)
469 (define-key map (kbd "* M") 'ibuffer-mark-by-mode)
470 (define-key map (kbd "* m") 'ibuffer-mark-modified-buffers)
471 (define-key map (kbd "* u") 'ibuffer-mark-unsaved-buffers)
472 (define-key map (kbd "* s") 'ibuffer-mark-special-buffers)
473 (define-key map (kbd "* r") 'ibuffer-mark-read-only-buffers)
474 (define-key map (kbd "* /") 'ibuffer-mark-dired-buffers)
475 (define-key map (kbd "* e") 'ibuffer-mark-dissociated-buffers)
476 (define-key map (kbd "* h") 'ibuffer-mark-help-buffers)
9fe14abe 477 (define-key map (kbd "* z") 'ibuffer-mark-compressed-file-buffers)
25d2f683 478 (define-key map (kbd ".") 'ibuffer-mark-old-buffers)
71296446 479
25d2f683
CW
480 (define-key map (kbd "d") 'ibuffer-mark-for-delete)
481 (define-key map (kbd "C-d") 'ibuffer-mark-for-delete-backwards)
482 (define-key map (kbd "k") 'ibuffer-mark-for-delete)
483 (define-key map (kbd "x") 'ibuffer-do-kill-on-deletion-marks)
71296446 484
25d2f683
CW
485 ;; immediate operations
486 (define-key map (kbd "n") 'ibuffer-forward-line)
487 (define-key map (kbd "SPC") 'forward-line)
488 (define-key map (kbd "p") 'ibuffer-backward-line)
489 (define-key map (kbd "M-}") 'ibuffer-forward-next-marked)
490 (define-key map (kbd "M-{") 'ibuffer-backwards-next-marked)
491 (define-key map (kbd "l") 'ibuffer-redisplay)
492 (define-key map (kbd "g") 'ibuffer-update)
493 (define-key map "`" 'ibuffer-switch-format)
494 (define-key map "-" 'ibuffer-add-to-tmp-hide)
495 (define-key map "+" 'ibuffer-add-to-tmp-show)
496 (define-key map "b" 'ibuffer-bury-buffer)
497 (define-key map (kbd ",") 'ibuffer-toggle-sorting-mode)
498 (define-key map (kbd "s i") 'ibuffer-invert-sorting)
499 (define-key map (kbd "s a") 'ibuffer-do-sort-by-alphabetic)
500 (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency)
501 (define-key map (kbd "s s") 'ibuffer-do-sort-by-size)
d5794180 502 (define-key map (kbd "s f") 'ibuffer-do-sort-by-filename/process)
25d2f683
CW
503 (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode)
504
505 (define-key map (kbd "/ m") 'ibuffer-filter-by-mode)
5bc06df9 506 (define-key map (kbd "/ M") 'ibuffer-filter-by-used-mode)
25d2f683
CW
507 (define-key map (kbd "/ n") 'ibuffer-filter-by-name)
508 (define-key map (kbd "/ c") 'ibuffer-filter-by-content)
509 (define-key map (kbd "/ e") 'ibuffer-filter-by-predicate)
510 (define-key map (kbd "/ f") 'ibuffer-filter-by-filename)
511 (define-key map (kbd "/ >") 'ibuffer-filter-by-size-gt)
512 (define-key map (kbd "/ <") 'ibuffer-filter-by-size-lt)
513 (define-key map (kbd "/ r") 'ibuffer-switch-to-saved-filters)
514 (define-key map (kbd "/ a") 'ibuffer-add-saved-filters)
515 (define-key map (kbd "/ x") 'ibuffer-delete-saved-filters)
516 (define-key map (kbd "/ d") 'ibuffer-decompose-filter)
517 (define-key map (kbd "/ s") 'ibuffer-save-filters)
518 (define-key map (kbd "/ p") 'ibuffer-pop-filter)
519 (define-key map (kbd "/ !") 'ibuffer-negate-filter)
520 (define-key map (kbd "/ t") 'ibuffer-exchange-filters)
521 (define-key map (kbd "/ TAB") 'ibuffer-exchange-filters)
522 (define-key map (kbd "/ o") 'ibuffer-or-filter)
b5cd37ea
CW
523 (define-key map (kbd "/ g") 'ibuffer-filters-to-filter-group)
524 (define-key map (kbd "/ P") 'ibuffer-pop-filter-group)
2bd26a6f 525 (define-key map (kbd "/ D") 'ibuffer-decompose-filter-group)
25d2f683 526 (define-key map (kbd "/ /") 'ibuffer-filter-disable)
b5cd37ea
CW
527
528 (define-key map (kbd "M-n") 'ibuffer-forward-filter-group)
77aec221 529 (define-key map "\t" 'ibuffer-forward-filter-group)
b5cd37ea 530 (define-key map (kbd "M-p") 'ibuffer-backward-filter-group)
77aec221 531 (define-key map [backtab] 'ibuffer-backward-filter-group)
b5cd37ea 532 (define-key map (kbd "M-j") 'ibuffer-jump-to-filter-group)
cba63a2d
CW
533 (define-key map (kbd "C-k") 'ibuffer-kill-line)
534 (define-key map (kbd "C-y") 'ibuffer-yank)
535 (define-key map (kbd "/ S") 'ibuffer-save-filter-groups)
536 (define-key map (kbd "/ R") 'ibuffer-switch-to-saved-filter-groups)
537 (define-key map (kbd "/ X") 'ibuffer-delete-saved-filter-groups)
538 (define-key map (kbd "/ \\") 'ibuffer-clear-filter-groups)
71296446 539
25d2f683
CW
540 (define-key map (kbd "q") 'ibuffer-quit)
541 (define-key map (kbd "h") 'describe-mode)
542 (define-key map (kbd "?") 'describe-mode)
543
544 (define-key map (kbd "% n") 'ibuffer-mark-by-name-regexp)
545 (define-key map (kbd "% m") 'ibuffer-mark-by-mode-regexp)
546 (define-key map (kbd "% f") 'ibuffer-mark-by-file-name-regexp)
71296446 547
25d2f683
CW
548 (define-key map (kbd "C-t") 'ibuffer-visit-tags-table)
549
550 (define-key map (kbd "|") 'ibuffer-do-shell-command-pipe)
551 (define-key map (kbd "!") 'ibuffer-do-shell-command-file)
552 (define-key map (kbd "~") 'ibuffer-do-toggle-modified)
553 ;; marked operations
554 (define-key map (kbd "A") 'ibuffer-do-view)
555 (define-key map (kbd "D") 'ibuffer-do-delete)
556 (define-key map (kbd "E") 'ibuffer-do-eval)
557 (define-key map (kbd "F") 'ibuffer-do-shell-command-file)
558 (define-key map (kbd "I") 'ibuffer-do-query-replace-regexp)
559 (define-key map (kbd "H") 'ibuffer-do-view-other-frame)
560 (define-key map (kbd "N") 'ibuffer-do-shell-command-pipe-replace)
561 (define-key map (kbd "M") 'ibuffer-do-toggle-modified)
562 (define-key map (kbd "O") 'ibuffer-do-occur)
563 (define-key map (kbd "P") 'ibuffer-do-print)
564 (define-key map (kbd "Q") 'ibuffer-do-query-replace)
565 (define-key map (kbd "R") 'ibuffer-do-rename-uniquely)
566 (define-key map (kbd "S") 'ibuffer-do-save)
567 (define-key map (kbd "T") 'ibuffer-do-toggle-read-only)
568 (define-key map (kbd "U") 'ibuffer-do-replace-regexp)
569 (define-key map (kbd "V") 'ibuffer-do-revert)
570 (define-key map (kbd "W") 'ibuffer-do-view-and-eval)
571 (define-key map (kbd "X") 'ibuffer-do-shell-command-pipe)
71296446 572
25d2f683
CW
573 (define-key map (kbd "k") 'ibuffer-do-kill-lines)
574 (define-key map (kbd "w") 'ibuffer-copy-filename-as-kill)
575
576 (define-key map (kbd "RET") 'ibuffer-visit-buffer)
577 (define-key map (kbd "e") 'ibuffer-visit-buffer)
578 (define-key map (kbd "f") 'ibuffer-visit-buffer)
579 (define-key map (kbd "C-x C-f") 'ibuffer-find-file)
580 (define-key map (kbd "o") 'ibuffer-visit-buffer-other-window)
581 (define-key map (kbd "C-o") 'ibuffer-visit-buffer-other-window-noselect)
582 (define-key map (kbd "M-o") 'ibuffer-visit-buffer-1-window)
583 (define-key map (kbd "v") 'ibuffer-do-view)
584 (define-key map (kbd "C-x v") 'ibuffer-do-view-horizontally)
585 (define-key map (kbd "C-c C-a") 'ibuffer-auto-mode)
586 (define-key map (kbd "C-x 4 RET") 'ibuffer-visit-buffer-other-window)
587 (define-key map (kbd "C-x 5 RET") 'ibuffer-visit-buffer-other-frame)
588
589 (define-key map [menu-bar view]
590 (cons "View" (make-sparse-keymap "View")))
591
592 (define-key-after map [menu-bar view visit-buffer]
593 '(menu-item "View this buffer" ibuffer-visit-buffer))
594 (define-key-after map [menu-bar view visit-buffer-other-window]
595 '(menu-item "View (other window)" ibuffer-visit-buffer-other-window))
596 (define-key-after map [menu-bar view visit-buffer-other-frame]
597 '(menu-item "View (other frame)" ibuffer-visit-buffer-other-frame))
598 (define-key-after map [menu-bar view ibuffer-update]
599 '(menu-item "Update" ibuffer-update
b016851c 600 :help "Regenerate the list of buffers"))
25d2f683
CW
601 (define-key-after map [menu-bar view switch-format]
602 '(menu-item "Switch display format" ibuffer-switch-format
b016851c 603 :help "Toggle between available values of `ibuffer-formats'"))
25d2f683
CW
604
605 (define-key-after map [menu-bar view dashes]
606 '("--"))
607
608 (define-key-after map [menu-bar view sort]
609 (cons "Sort" (make-sparse-keymap "Sort")))
610
611 (define-key-after map [menu-bar view sort do-sort-by-major-mode]
cba63a2d 612 '(menu-item "Sort by major mode" ibuffer-do-sort-by-major-mode))
25d2f683 613 (define-key-after map [menu-bar view sort do-sort-by-size]
cba63a2d 614 '(menu-item "Sort by buffer size" ibuffer-do-sort-by-size))
25d2f683
CW
615 (define-key-after map [menu-bar view sort do-sort-by-alphabetic]
616 '(menu-item "Sort lexicographically" ibuffer-do-sort-by-alphabetic
b016851c 617 :help "Sort by the alphabetic order of buffer name"))
25d2f683
CW
618 (define-key-after map [menu-bar view sort do-sort-by-recency]
619 '(menu-item "Sort by view time" ibuffer-do-sort-by-recency
b016851c 620 :help "Sort by the last time the buffer was displayed"))
4e4a724c
JPW
621 (define-key-after map [menu-bar view sort dashes]
622 '("--"))
25d2f683
CW
623 (define-key-after map [menu-bar view sort invert-sorting]
624 '(menu-item "Reverse sorting order" ibuffer-invert-sorting))
625 (define-key-after map [menu-bar view sort toggle-sorting-mode]
626 '(menu-item "Switch sorting mode" ibuffer-toggle-sorting-mode
b016851c 627 :help "Switch between the various sorting criteria"))
25d2f683
CW
628
629 (define-key-after map [menu-bar view filter]
630 (cons "Filter" (make-sparse-keymap "Filter")))
631
632 (define-key-after map [menu-bar view filter filter-disable]
05cc03af 633 '(menu-item "Disable all filtering" ibuffer-filter-disable
b016851c 634 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)))
25d2f683 635 (define-key-after map [menu-bar view filter filter-by-mode]
cba63a2d 636 '(menu-item "Add filter by major mode..." ibuffer-filter-by-mode))
5bc06df9 637 (define-key-after map [menu-bar view filter filter-by-mode]
b016851c
SM
638 '(menu-item "Add filter by major mode in use..."
639 ibuffer-filter-by-used-mode))
25d2f683 640 (define-key-after map [menu-bar view filter filter-by-name]
cba63a2d 641 '(menu-item "Add filter by buffer name..." ibuffer-filter-by-name))
25d2f683 642 (define-key-after map [menu-bar view filter filter-by-filename]
cba63a2d 643 '(menu-item "Add filter by filename..." ibuffer-filter-by-filename))
25d2f683 644 (define-key-after map [menu-bar view filter filter-by-size-lt]
cba63a2d 645 '(menu-item "Add filter by size less than..." ibuffer-filter-by-size-lt))
25d2f683 646 (define-key-after map [menu-bar view filter filter-by-size-gt]
b016851c
SM
647 '(menu-item "Add filter by size greater than..."
648 ibuffer-filter-by-size-gt))
25d2f683 649 (define-key-after map [menu-bar view filter filter-by-content]
b016851c
SM
650 '(menu-item "Add filter by content (regexp)..."
651 ibuffer-filter-by-content))
25d2f683 652 (define-key-after map [menu-bar view filter filter-by-predicate]
b016851c
SM
653 '(menu-item "Add filter by Lisp predicate..."
654 ibuffer-filter-by-predicate))
25d2f683 655 (define-key-after map [menu-bar view filter pop-filter]
05cc03af 656 '(menu-item "Remove top filter" ibuffer-pop-filter
b016851c 657 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)))
25d2f683
CW
658 (define-key-after map [menu-bar view filter or-filter]
659 '(menu-item "OR top two filters" ibuffer-or-filter
b016851c
SM
660 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers
661 (cdr ibuffer-filtering-qualifiers))
662 :help
663 "Create a new filter which is the logical OR of the top two filters"))
25d2f683 664 (define-key-after map [menu-bar view filter negate-filter]
05cc03af 665 '(menu-item "Negate top filter" ibuffer-negate-filter
b016851c 666 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)))
25d2f683
CW
667 (define-key-after map [menu-bar view filter decompose-filter]
668 '(menu-item "Decompose top filter" ibuffer-decompose-filter
b016851c
SM
669 :enable (and (featurep 'ibuf-ext)
670 (memq (car ibuffer-filtering-qualifiers) '(or saved not)))
671 :help "Break down a complex filter like OR or NOT"))
25d2f683 672 (define-key-after map [menu-bar view filter exchange-filters]
05cc03af 673 '(menu-item "Swap top two filters" ibuffer-exchange-filters
b016851c
SM
674 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers
675 (cdr ibuffer-filtering-qualifiers))))
25d2f683
CW
676 (define-key-after map [menu-bar view filter save-filters]
677 '(menu-item "Save current filters permanently..." ibuffer-save-filters
b016851c 678 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)
c80e3b4a 679 :help "Use a mnemonic name to store current filter stack"))
25d2f683 680 (define-key-after map [menu-bar view filter switch-to-saved-filters]
b016851c
SM
681 '(menu-item "Restore permanently saved filters..."
682 ibuffer-switch-to-saved-filters
683 :enable (and (featurep 'ibuf-ext) ibuffer-saved-filters)
684 :help "Replace current filters with a saved stack"))
25d2f683 685 (define-key-after map [menu-bar view filter add-saved-filters]
b016851c
SM
686 '(menu-item "Add to permanently saved filters..."
687 ibuffer-add-saved-filters
688 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)
689 :help "Include already saved stack with current filters"))
25d2f683 690 (define-key-after map [menu-bar view filter delete-saved-filters]
cba63a2d 691 '(menu-item "Delete permanently saved filters..."
b016851c
SM
692 ibuffer-delete-saved-filters
693 :enable (and (featurep 'ibuf-ext) ibuffer-saved-filters)))
cba63a2d 694
b5e80d1a 695 (define-key-after map [menu-bar view filter-groups]
b016851c 696 (cons "Filter Groups" ibuffer-mode-groups-popup))
b5e80d1a 697
25d2f683
CW
698 (define-key-after map [menu-bar view dashes2]
699 '("--"))
700 (define-key-after map [menu-bar view diff-with-file]
701 '(menu-item "Diff with file" ibuffer-diff-with-file
b016851c 702 :help "View the differences between this buffer and its file"))
25d2f683
CW
703 (define-key-after map [menu-bar view auto-mode]
704 '(menu-item "Toggle Auto Mode" ibuffer-auto-mode
b016851c 705 :help "Attempt to automatically update the Ibuffer buffer"))
25d2f683 706 (define-key-after map [menu-bar view customize]
4e4a724c 707 '(menu-item "Customize Ibuffer" ibuffer-customize
b016851c 708 :help "Use Custom to customize Ibuffer"))
25d2f683
CW
709
710 (define-key-after map [menu-bar mark]
711 (cons "Mark" (make-sparse-keymap "Mark")))
712
713 (define-key-after map [menu-bar mark toggle-marks]
714 '(menu-item "Toggle marks" ibuffer-toggle-marks
b016851c 715 :help "Unmark marked buffers, and mark unmarked buffers"))
25d2f683
CW
716 (define-key-after map [menu-bar mark mark-forward]
717 '(menu-item "Mark" ibuffer-mark-forward
b016851c 718 :help "Mark the buffer at point"))
25d2f683
CW
719 (define-key-after map [menu-bar mark unmark-forward]
720 '(menu-item "Unmark" ibuffer-unmark-forward
b016851c 721 :help "Unmark the buffer at point"))
25d2f683
CW
722 (define-key-after map [menu-bar mark mark-by-mode]
723 '(menu-item "Mark by mode..." ibuffer-mark-by-mode
b016851c 724 :help "Mark all buffers in a particular major mode"))
25d2f683
CW
725 (define-key-after map [menu-bar mark mark-modified-buffers]
726 '(menu-item "Mark modified buffers" ibuffer-mark-modified-buffers
b016851c 727 :help "Mark all buffers which have been modified"))
25d2f683
CW
728 (define-key-after map [menu-bar mark mark-unsaved-buffers]
729 '(menu-item "Mark unsaved buffers" ibuffer-mark-unsaved-buffers
b016851c 730 :help "Mark all buffers which have a file and are modified"))
25d2f683
CW
731 (define-key-after map [menu-bar mark mark-read-only-buffers]
732 '(menu-item "Mark read-only buffers" ibuffer-mark-read-only-buffers
b016851c 733 :help "Mark all buffers which are read-only"))
25d2f683
CW
734 (define-key-after map [menu-bar mark mark-special-buffers]
735 '(menu-item "Mark special buffers" ibuffer-mark-special-buffers
b016851c 736 :help "Mark all buffers whose name begins with a *"))
25d2f683
CW
737 (define-key-after map [menu-bar mark mark-dired-buffers]
738 '(menu-item "Mark dired buffers" ibuffer-mark-dired-buffers
b016851c 739 :help "Mark buffers in dired-mode"))
25d2f683
CW
740 (define-key-after map [menu-bar mark mark-dissociated-buffers]
741 '(menu-item "Mark dissociated buffers" ibuffer-mark-dissociated-buffers
b016851c 742 :help "Mark buffers with a non-existent associated file"))
25d2f683
CW
743 (define-key-after map [menu-bar mark mark-help-buffers]
744 '(menu-item "Mark help buffers" ibuffer-mark-help-buffers
b016851c 745 :help "Mark buffers in help-mode"))
9fe14abe 746 (define-key-after map [menu-bar mark mark-compressed-file-buffers]
b016851c
SM
747 '(menu-item "Mark compressed file buffers"
748 ibuffer-mark-compressed-file-buffers
749 :help "Mark buffers which have a file that is compressed"))
25d2f683
CW
750 (define-key-after map [menu-bar mark mark-old-buffers]
751 '(menu-item "Mark old buffers" ibuffer-mark-old-buffers
b016851c 752 :help "Mark buffers which have not been viewed recently"))
25d2f683
CW
753 (define-key-after map [menu-bar mark unmark-all]
754 '(menu-item "Unmark All" ibuffer-unmark-all))
71296446 755
25d2f683
CW
756 (define-key-after map [menu-bar mark dashes]
757 '("--"))
71296446 758
25d2f683
CW
759 (define-key-after map [menu-bar mark mark-by-name-regexp]
760 '(menu-item "Mark by buffer name (regexp)..." ibuffer-mark-by-name-regexp
b016851c 761 :help "Mark buffers whose name matches a regexp"))
25d2f683
CW
762 (define-key-after map [menu-bar mark mark-by-mode-regexp]
763 '(menu-item "Mark by major mode (regexp)..." ibuffer-mark-by-mode-regexp
b016851c 764 :help "Mark buffers whose major mode name matches a regexp"))
25d2f683 765 (define-key-after map [menu-bar mark mark-by-file-name-regexp]
b016851c
SM
766 '(menu-item "Mark by file name (regexp)..."
767 ibuffer-mark-by-file-name-regexp
768 :help "Mark buffers whose file name matches a regexp"))
25d2f683 769
b016851c 770 map))
25d2f683 771
b016851c
SM
772(defvar ibuffer-mode-operate-map
773 (let ((operate-map (make-sparse-keymap "Operate")))
25d2f683
CW
774 (define-key-after operate-map [do-view]
775 '(menu-item "View" ibuffer-do-view))
776 (define-key-after operate-map [do-view-other-frame]
777 '(menu-item "View (separate frame)" ibuffer-do-view-other-frame))
778 (define-key-after operate-map [do-save]
779 '(menu-item "Save" ibuffer-do-save))
780 (define-key-after operate-map [do-replace-regexp]
781 '(menu-item "Replace (regexp)..." ibuffer-do-replace-regexp
b016851c 782 :help "Replace text inside marked buffers"))
25d2f683
CW
783 (define-key-after operate-map [do-query-replace]
784 '(menu-item "Query Replace..." ibuffer-do-query-replace
b016851c 785 :help "Replace text in marked buffers, asking each time"))
25d2f683
CW
786 (define-key-after operate-map [do-query-replace-regexp]
787 '(menu-item "Query Replace (regexp)..." ibuffer-do-query-replace-regexp
b016851c 788 :help "Replace text in marked buffers by regexp, asking each time"))
25d2f683
CW
789 (define-key-after operate-map [do-print]
790 '(menu-item "Print" ibuffer-do-print))
791 (define-key-after operate-map [do-toggle-modified]
792 '(menu-item "Toggle modification flag" ibuffer-do-toggle-modified))
793 (define-key-after operate-map [do-revert]
794 '(menu-item "Revert" ibuffer-do-revert
b016851c 795 :help "Revert marked buffers to their associated file"))
25d2f683
CW
796 (define-key-after operate-map [do-rename-uniquely]
797 '(menu-item "Rename Uniquely" ibuffer-do-rename-uniquely
b016851c 798 :help "Rename marked buffers to a new, unique name"))
25d2f683
CW
799 (define-key-after operate-map [do-delete]
800 '(menu-item "Kill" ibuffer-do-delete))
801 (define-key-after operate-map [do-occur]
802 '(menu-item "List lines matching..." ibuffer-do-occur
b016851c 803 :help "View all lines in marked buffers matching a regexp"))
25d2f683
CW
804 (define-key-after operate-map [do-shell-command-pipe]
805 '(menu-item "Pipe to shell command..." ibuffer-do-shell-command-pipe
b016851c 806 :help "For each marked buffer, send its contents to a shell command"))
25d2f683
CW
807 (define-key-after operate-map [do-shell-command-pipe-replace]
808 '(menu-item "Pipe to shell command (replace)..." ibuffer-do-shell-command-pipe-replace
b016851c 809 :help "For each marked buffer, replace its contents with output of shell command"))
25d2f683
CW
810 (define-key-after operate-map [do-shell-command-file]
811 '(menu-item "Shell command on buffer's file..." ibuffer-do-shell-command-file
b016851c 812 :help "For each marked buffer, run a shell command with its file as argument"))
25d2f683
CW
813 (define-key-after operate-map [do-eval]
814 '(menu-item "Eval..." ibuffer-do-eval
b016851c 815 :help "Evaluate a Lisp form in each marked buffer"))
25d2f683
CW
816 (define-key-after operate-map [do-view-and-eval]
817 '(menu-item "Eval (viewing buffer)..." ibuffer-do-view-and-eval
b016851c 818 :help "Evaluate a Lisp form in each marked buffer while viewing it"))
71296446 819
b016851c 820 operate-map))
2bd26a6f
CW
821
822(define-key ibuffer-mode-groups-popup [kill-filter-group]
4e4a724c
JPW
823 '(menu-item "Kill filter group"
824 ibuffer-kill-line
34a4faa0
JPW
825 :enable (and (featurep 'ibuf-ext)
826 ibuffer-filter-groups)))
545aad2f 827(define-key ibuffer-mode-groups-popup [yank-filter-group]
4e4a724c
JPW
828 '(menu-item "Yank last killed filter group"
829 ibuffer-yank
34a4faa0
JPW
830 :enable (and (featurep 'ibuf-ext)
831 ibuffer-filter-group-kill-ring)))
4e4a724c 832
acf88897 833(defvar ibuffer-name-map
25d2f683 834 (let ((map (make-sparse-keymap)))
25d2f683
CW
835 (define-key map [(mouse-1)] 'ibuffer-mouse-toggle-mark)
836 (define-key map [(mouse-2)] 'ibuffer-mouse-visit-buffer)
837 (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu)
acf88897 838 map))
25d2f683 839
d5794180
DN
840(defvar ibuffer-filename/process-header-map
841 (let ((map (make-sparse-keymap)))
842 (define-key map [(mouse-1)] 'ibuffer-do-sort-by-filename/process)
843 map))
844
acf88897 845(defvar ibuffer-mode-name-map
25d2f683 846 (let ((map (make-sparse-keymap)))
25d2f683
CW
847 (define-key map [(mouse-2)] 'ibuffer-mouse-filter-by-mode)
848 (define-key map (kbd "RET") 'ibuffer-interactive-filter-by-mode)
acf88897 849 map))
25d2f683 850
f0b31589
DN
851(defvar ibuffer-name-header-map
852 (let ((map (make-sparse-keymap)))
853 (define-key map [(mouse-1)] 'ibuffer-do-sort-by-alphabetic)
854 map))
855
856(defvar ibuffer-size-header-map
857 (let ((map (make-sparse-keymap)))
858 (define-key map [(mouse-1)] 'ibuffer-do-sort-by-size)
859 map))
860
861(defvar ibuffer-mode-header-map
862 (let ((map (make-sparse-keymap)))
863 (define-key map [(mouse-1)] 'ibuffer-do-sort-by-major-mode)
864 map))
865
acf88897 866(defvar ibuffer-mode-filter-group-map
b5cd37ea 867 (let ((map (make-sparse-keymap)))
b5cd37ea
CW
868 (define-key map [(mouse-1)] 'ibuffer-mouse-toggle-mark)
869 (define-key map [(mouse-2)] 'ibuffer-mouse-toggle-filter-group)
870 (define-key map (kbd "RET") 'ibuffer-toggle-filter-group)
b5e80d1a 871 (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu)
acf88897 872 map))
b5cd37ea 873
4ed1f829
JPW
874(defvar ibuffer-restore-window-config-on-quit nil
875 "If non-nil, restore previous window configuration upon exiting `ibuffer'.")
876
877(defvar ibuffer-prev-window-config nil
878 "Window configuration before starting Ibuffer.")
25d2f683
CW
879
880(defvar ibuffer-did-modification nil)
881
63f0a166
JB
882(defvar ibuffer-compiled-formats nil)
883(defvar ibuffer-cached-formats nil)
884(defvar ibuffer-cached-eliding-string nil)
885(defvar ibuffer-cached-elide-long-columns 0)
886
25d2f683
CW
887(defvar ibuffer-sorting-functions-alist nil
888 "An alist of functions which describe how to sort buffers.
889
890Note: You most likely do not want to modify this variable directly;
891use `define-ibuffer-sorter' instead.
892
893The alist elements are constructed like (NAME DESCRIPTION FUNCTION)
894Where NAME is a symbol describing the sorting method, DESCRIPTION is a
895short string which will be displayed in the minibuffer and menu, and
896FUNCTION is a function of two arguments, which will be the buffers to
897compare.")
898
899;;; Utility functions
900(defun ibuffer-columnize-and-insert-list (list &optional pad-width)
901 "Insert LIST into the current buffer in as many columns as possible.
902The maximum number of columns is determined by the current window
903width and the longest string in LIST."
904 (unless pad-width
905 (setq pad-width 3))
906 (let ((width (window-width))
907 (max (+ (apply #'max (mapcar #'length list))
908 pad-width)))
909 (let ((columns (/ width max)))
910 (when (zerop columns)
911 (setq columns 1))
912 (while list
913 (dotimes (i (1- columns))
914 (insert (concat (car list) (make-string (- max (length (car list)))
972b8f82 915 ?\s)))
25d2f683
CW
916 (setq list (cdr list)))
917 (when (not (null list))
918 (insert (pop list)))
919 (insert "\n")))))
920
25d2f683
CW
921(defsubst ibuffer-current-mark ()
922 (cadr (get-text-property (line-beginning-position)
923 'ibuffer-properties)))
924
925(defun ibuffer-mouse-toggle-mark (event)
926 "Toggle the marked status of the buffer chosen with the mouse."
927 (interactive "e")
928 (unwind-protect
b5cd37ea
CW
929 (let ((pt (save-excursion
930 (mouse-set-point event)
931 (point))))
932 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
933 (ibuffer-toggle-marks it)
934 (goto-char pt)
935 (let ((mark (ibuffer-current-mark)))
936 (setq buffer-read-only nil)
937 (if (eq mark ibuffer-marked-char)
972b8f82 938 (ibuffer-set-mark ?\s)
b5cd37ea 939 (ibuffer-set-mark ibuffer-marked-char)))))
25d2f683
CW
940 (setq buffer-read-only t)))
941
942(defun ibuffer-find-file (file &optional wildcards)
943 "Like `find-file', but default to the directory of the buffer at point."
944 (interactive
945 (let ((default-directory (let ((buf (ibuffer-current-buffer)))
946 (if (buffer-live-p buf)
947 (with-current-buffer buf
948 default-directory)
949 default-directory))))
950 (list (read-file-name "Find file: " default-directory)
fe78af29
JPW
951 t)))
952 (find-file file wildcards))
25d2f683
CW
953
954(defun ibuffer-mouse-visit-buffer (event)
955 "Visit the buffer chosen with the mouse."
956 (interactive "e")
957 (switch-to-buffer
958 (save-excursion
959 (mouse-set-point event)
b5cd37ea 960 (ibuffer-current-buffer t))))
25d2f683
CW
961
962(defun ibuffer-mouse-popup-menu (event)
963 "Display a menu of operations."
964 (interactive "e")
a1793b2d
JPW
965 (let ((eventpt (posn-point (event-end event)))
966 (origpt (point)))
25d2f683 967 (unwind-protect
51922c04 968 (if (get-text-property eventpt 'ibuffer-filter-group-name)
a1793b2d
JPW
969 (progn
970 (goto-char eventpt)
971 (popup-menu ibuffer-mode-groups-popup))
51922c04 972 (let ((inhibit-read-only t))
b5e80d1a 973 (ibuffer-save-marks
4e4a724c
JPW
974 ;; hm. we could probably do this in a better fashion
975 (ibuffer-unmark-all ?\r)
976 (save-excursion
977 (goto-char eventpt)
978 (ibuffer-set-mark ibuffer-marked-char))
979 (save-excursion
980 (popup-menu ibuffer-mode-operate-map)))))
a1793b2d 981 (setq buffer-read-only t)
4ba16127 982 (if (= eventpt (point))
a1793b2d 983 (goto-char origpt)))))
51922c04 984
b5cd37ea
CW
985(defun ibuffer-skip-properties (props direction)
986 (while (and (not (eobp))
987 (let ((hit nil))
988 (dolist (prop props hit)
989 (when (get-text-property (point) prop)
990 (setq hit t)))))
991 (forward-line direction)
992 (beginning-of-line)))
25d2f683 993
4e4a724c
JPW
994(defun ibuffer-customize ()
995 "Begin customizing Ibuffer interactively."
996 (interactive)
997 (customize-group 'ibuffer))
998
b5cd37ea 999(defun ibuffer-backward-line (&optional arg skip-group-names)
25d2f683
CW
1000 "Move backwards ARG lines, wrapping around the list if necessary."
1001 (interactive "P")
34a4faa0 1002 (or arg (setq arg 1))
25d2f683
CW
1003 (beginning-of-line)
1004 (while (> arg 0)
1005 (forward-line -1)
0ce780e1
CW
1006 (when (and ibuffer-movement-cycle
1007 (or (get-text-property (point) 'ibuffer-title)
1008 (and skip-group-names
34a4faa0
JPW
1009 (get-text-property (point)
1010 'ibuffer-filter-group-name))))
25d2f683 1011 (goto-char (point-max))
60356fb5 1012 (beginning-of-line))
b5cd37ea
CW
1013 (ibuffer-skip-properties (append '(ibuffer-summary)
1014 (when skip-group-names
1015 '(ibuffer-filter-group-name)))
1016 -1)
60356fb5
CW
1017 ;; Handle the special case of no buffers.
1018 (when (get-text-property (point) 'ibuffer-title)
1019 (forward-line 1)
1020 (setq arg 1))
1021 (decf arg)))
25d2f683 1022
b5cd37ea 1023(defun ibuffer-forward-line (&optional arg skip-group-names)
25d2f683
CW
1024 "Move forward ARG lines, wrapping around the list if necessary."
1025 (interactive "P")
34a4faa0 1026 (or arg (setq arg 1))
25d2f683 1027 (beginning-of-line)
0ce780e1
CW
1028 (when (and ibuffer-movement-cycle
1029 (or (eobp)
1030 (get-text-property (point) 'ibuffer-summary)))
214b39be 1031 (goto-char (point-min)))
b5cd37ea
CW
1032 (when (or (get-text-property (point) 'ibuffer-title)
1033 (and skip-group-names
1034 (get-text-property (point) 'ibuffer-filter-group-name)))
1035 (when (> arg 0)
1036 (decf arg))
1037 (ibuffer-skip-properties (append '(ibuffer-title)
1038 (when skip-group-names
1039 '(ibuffer-filter-group-name)))
1040 1))
25d2f683
CW
1041 (if (< arg 0)
1042 (ibuffer-backward-line (- arg))
60356fb5
CW
1043 (while (> arg 0)
1044 (forward-line 1)
0ce780e1
CW
1045 (when (and ibuffer-movement-cycle
1046 (or (eobp)
1047 (get-text-property (point) 'ibuffer-summary)))
60356fb5 1048 (goto-char (point-min)))
b5cd37ea
CW
1049 (decf arg)
1050 (ibuffer-skip-properties (append '(ibuffer-title)
1051 (when skip-group-names
1052 '(ibuffer-filter-group-name)))
1053 1))))
25d2f683 1054
d246cabf
CW
1055(defun ibuffer-visit-buffer (&optional single)
1056 "Visit the buffer on this line.
d246cabf
CW
1057If optional argument SINGLE is non-nil, then also ensure there is only
1058one window."
1059 (interactive "P")
b5cd37ea 1060 (let ((buf (ibuffer-current-buffer t)))
d246cabf
CW
1061 (switch-to-buffer buf)
1062 (when single
1063 (delete-other-windows))))
25d2f683
CW
1064
1065(defun ibuffer-visit-buffer-other-window (&optional noselect)
1066 "Visit the buffer on this line in another window."
1067 (interactive)
b5cd37ea 1068 (let ((buf (ibuffer-current-buffer t)))
25d2f683
CW
1069 (bury-buffer (current-buffer))
1070 (if noselect
1071 (let ((curwin (selected-window)))
1072 (pop-to-buffer buf)
1073 (select-window curwin))
1074 (switch-to-buffer-other-window buf))))
1075
1076(defun ibuffer-visit-buffer-other-window-noselect ()
1077 "Visit the buffer on this line in another window, but don't select it."
1078 (interactive)
1079 (ibuffer-visit-buffer-other-window t))
1080
1081(defun ibuffer-visit-buffer-other-frame ()
1082 "Visit the buffer on this line in another frame."
1083 (interactive)
b5cd37ea 1084 (let ((buf (ibuffer-current-buffer t)))
25d2f683
CW
1085 (bury-buffer (current-buffer))
1086 (switch-to-buffer-other-frame buf)))
1087
1088(defun ibuffer-visit-buffer-1-window ()
1089 "Visit the buffer on this line, and delete other windows."
1090 (interactive)
d246cabf 1091 (ibuffer-visit-buffer t))
25d2f683
CW
1092
1093(defun ibuffer-bury-buffer ()
1094 "Bury the buffer on this line."
1095 (interactive)
b5cd37ea 1096 (let ((buf (ibuffer-current-buffer t))
25d2f683 1097 (line (+ 1 (count-lines 1 (point)))))
25d2f683
CW
1098 (bury-buffer buf)
1099 (ibuffer-update nil t)
e6ce8c42
GM
1100 (goto-char (point-min))
1101 (forward-line (1- line))))
25d2f683
CW
1102
1103(defun ibuffer-visit-tags-table ()
1104 "Visit the tags table in the buffer on this line. See `visit-tags-table'."
1105 (interactive)
b5cd37ea 1106 (let ((file (buffer-file-name (ibuffer-current-buffer t))))
25d2f683
CW
1107 (if file
1108 (visit-tags-table file)
1109 (error "Specified buffer has no file"))))
1110
1111(defun ibuffer-do-view (&optional other-frame)
1112 "View marked buffers, or the buffer on the current line.
1113If optional argument OTHER-FRAME is non-nil, then display each
1114marked buffer in a new frame. Otherwise, display each buffer as
1115a new window in the current frame, splitting vertically."
1116 (interactive)
1117 (ibuffer-do-view-1 (if other-frame 'other-frame 'vertically)))
1118
1119(defun ibuffer-do-view-horizontally (&optional other-frame)
1120 "As `ibuffer-do-view', but split windows horizontally."
1121 (interactive)
1122 (ibuffer-do-view-1 (if other-frame 'other-frame 'horizontally)))
1123
1124(defun ibuffer-do-view-1 (type)
1125 (let ((marked-bufs (ibuffer-get-marked-buffers)))
1126 (when (null marked-bufs)
b5cd37ea 1127 (setq marked-bufs (list (ibuffer-current-buffer t))))
25d2f683
CW
1128 (unless (and (eq type 'other-frame)
1129 (not ibuffer-expert)
1130 (> (length marked-bufs) 3)
1131 (not (y-or-n-p (format "Really create a new frame for %s buffers? "
1132 (length marked-bufs)))))
4e4a724c 1133 (set-buffer-modified-p nil)
25d2f683
CW
1134 (delete-other-windows)
1135 (switch-to-buffer (pop marked-bufs))
1136 (let ((height (/ (1- (if (eq type 'horizontally) (frame-width)
4e4a724c 1137 (frame-height)))
25d2f683
CW
1138 (1+ (length marked-bufs)))))
1139 (mapcar (if (eq type 'other-frame)
06b60517
JB
1140 (lambda (buf)
1141 (let ((curframe (selected-frame)))
1142 (select-frame (make-frame))
1143 (switch-to-buffer buf)
1144 (select-frame curframe)))
1145 (lambda (buf)
1146 (split-window nil height (eq type 'horizontally))
1147 (other-window 1)
1148 (switch-to-buffer buf)))
25d2f683
CW
1149 marked-bufs)))))
1150
1151(defun ibuffer-do-view-other-frame ()
1152 "View each of the marked buffers in a separate frame."
1153 (interactive)
1154 (ibuffer-do-view t))
1155
1156(defsubst ibuffer-map-marked-lines (func)
1157 (prog1 (ibuffer-map-on-mark ibuffer-marked-char func)
1158 (ibuffer-redisplay t)))
1159
1160(defun ibuffer-shrink-to-fit (&optional owin)
54124194
MO
1161 ;; Make sure that redisplay is performed, otherwise there can be a
1162 ;; bad interaction with code in the window-scroll-functions hook
1163 (redisplay t)
25d2f683
CW
1164 (fit-window-to-buffer nil (when owin (/ (frame-height)
1165 (length (window-list (selected-frame)))))))
1166
1167(defun ibuffer-confirm-operation-on (operation names)
1168 "Display a buffer asking whether to perform OPERATION on NAMES."
1169 (or ibuffer-expert
1170 (if (= (length names) 1)
1171 (y-or-n-p (format "Really %s buffer %s? " operation (car names)))
1172 (let ((buf (get-buffer-create "*Ibuffer confirmation*")))
1173 (with-current-buffer buf
1174 (setq buffer-read-only nil)
1175 (erase-buffer)
1176 (ibuffer-columnize-and-insert-list names)
1177 (goto-char (point-min))
1178 (setq buffer-read-only t))
4e4a724c 1179 (let ((lastwin (car (last (window-list nil 'nomini)))))
25d2f683
CW
1180 ;; Now attempt to display the buffer...
1181 (save-window-excursion
1182 (select-window lastwin)
1183 ;; The window might be too small to split; in that case,
7ad5b902 1184 ;; try a few times to increase its size before giving up.
25d2f683
CW
1185 (let ((attempts 0)
1186 (trying t))
1187 (while trying
1188 (condition-case err
1189 (progn
1190 (split-window)
1191 (setq trying nil))
1192 (error
1193 ;; Handle a failure
1194 (if (or (> (incf attempts) 4)
1195 (and (stringp (cadr err))
71296446 1196 ;; This definitely falls in the
4e4a724c 1197 ;; ghetto hack category...
25d2f683 1198 (not (string-match "too small" (cadr err)))))
8131c345 1199 (signal (car err) (cdr err))
25d2f683 1200 (enlarge-window 3))))))
25d2f683
CW
1201 (select-window (next-window))
1202 (switch-to-buffer buf)
1203 (unwind-protect
1204 (progn
1205 (fit-window-to-buffer)
1206 (y-or-n-p (format "Really %s %d buffers? "
1207 operation (length names))))
1208 (kill-buffer buf))))))))
1209
1210(defsubst ibuffer-map-lines-nomodify (function)
1211 "As `ibuffer-map-lines', but don't set the modification flag."
1212 (ibuffer-map-lines function t))
1213
1214(defun ibuffer-buffer-names-with-mark (mark)
1215 (let ((ibuffer-buffer-names-with-mark-result nil))
1216 (ibuffer-map-lines-nomodify
06b60517
JB
1217 (lambda (buf mk)
1218 (when (char-equal mark mk)
1219 (push (buffer-name buf)
1220 ibuffer-buffer-names-with-mark-result))))
25d2f683
CW
1221 ibuffer-buffer-names-with-mark-result))
1222
1223(defsubst ibuffer-marked-buffer-names ()
1224 (ibuffer-buffer-names-with-mark ibuffer-marked-char))
1225
1226(defsubst ibuffer-deletion-marked-buffer-names ()
1227 (ibuffer-buffer-names-with-mark ibuffer-deletion-char))
1228
1229(defun ibuffer-count-marked-lines (&optional all)
1230 (if all
1231 (ibuffer-map-lines-nomodify
06b60517
JB
1232 (lambda (_buf mark)
1233 (not (char-equal mark ?\s))))
25d2f683 1234 (ibuffer-map-lines-nomodify
06b60517
JB
1235 (lambda (_buf mark)
1236 (char-equal mark ibuffer-marked-char)))))
25d2f683
CW
1237
1238(defsubst ibuffer-count-deletion-lines ()
1239 (ibuffer-map-lines-nomodify
06b60517
JB
1240 (lambda (_buf mark)
1241 (char-equal mark ibuffer-deletion-char))))
25d2f683
CW
1242
1243(defsubst ibuffer-map-deletion-lines (func)
1244 (ibuffer-map-on-mark ibuffer-deletion-char func))
1245
87a6a53a 1246(defsubst ibuffer-assert-ibuffer-mode ()
2ead9289 1247 (assert (derived-mode-p 'ibuffer-mode)))
87a6a53a 1248
92cb2eaf
JPW
1249(defun ibuffer-buffer-file-name ()
1250 (or buffer-file-name
1251 (let ((dirname (or (and (boundp 'dired-directory)
1252 (if (stringp dired-directory)
1253 dired-directory
1254 (car dired-directory)))
414408cd 1255 (bound-and-true-p list-buffers-directory))))
9d458edc 1256 (and dirname (expand-file-name dirname)))))
92cb2eaf 1257
fd225d80 1258(define-ibuffer-op ibuffer-do-save ()
25d2f683
CW
1259 "Save marked buffers as with `save-buffer'."
1260 (:complex t
1261 :opstring "saved"
1262 :modifier-p :maybe)
1263 (when (buffer-modified-p buf)
1264 (if (not (with-current-buffer buf
1265 buffer-file-name))
1266 ;; handle the case where we're prompted
1267 ;; for a file name
1268 (save-window-excursion
1269 (switch-to-buffer buf)
1270 (save-buffer))
1271 (with-current-buffer buf
1272 (save-buffer))))
1273 t)
1274
fd225d80 1275(define-ibuffer-op ibuffer-do-toggle-modified ()
25d2f683
CW
1276 "Toggle modification flag of marked buffers."
1277 (:opstring "(un)marked as modified"
1278 :modifier-p t)
1279 (set-buffer-modified-p (not (buffer-modified-p))))
1280
92be491c
RW
1281(define-ibuffer-op ibuffer-do-toggle-read-only (&optional arg)
1282 "Toggle read only status in marked buffers.
320d3e68 1283With optional ARG, make read-only only if ARG is positive."
25d2f683 1284 (:opstring "toggled read only status in"
92be491c 1285 :interactive "P"
25d2f683 1286 :modifier-p t)
92be491c 1287 (toggle-read-only arg))
25d2f683 1288
fd225d80 1289(define-ibuffer-op ibuffer-do-delete ()
25d2f683
CW
1290 "Kill marked buffers as with `kill-this-buffer'."
1291 (:opstring "killed"
1292 :active-opstring "kill"
1293 :dangerous t
1294 :complex t
1295 :modifier-p t)
1296 (if (kill-buffer buf)
1297 'kill
1298 nil))
1299
fd225d80 1300(define-ibuffer-op ibuffer-do-kill-on-deletion-marks ()
25d2f683
CW
1301 "Kill buffers marked for deletion as with `kill-this-buffer'."
1302 (:opstring "killed"
1303 :active-opstring "kill"
1304 :dangerous t
1305 :complex t
1306 :mark :deletion
1307 :modifier-p t)
1308 (if (kill-buffer buf)
1309 'kill
1310 nil))
1311
1312(defun ibuffer-unmark-all (mark)
1313 "Unmark all buffers with mark MARK."
1314 (interactive "cRemove marks (RET means all):")
1315 (if (= (ibuffer-count-marked-lines t) 0)
1316 (message "No buffers marked; use 'm' to mark a buffer")
1317 (cond
1318 ((char-equal mark ibuffer-marked-char)
1319 (ibuffer-map-marked-lines
06b60517
JB
1320 (lambda (_buf _mark)
1321 (ibuffer-set-mark-1 ?\s)
1322 t)))
25d2f683
CW
1323 ((char-equal mark ibuffer-deletion-char)
1324 (ibuffer-map-deletion-lines
06b60517
JB
1325 (lambda (_buf _mark)
1326 (ibuffer-set-mark-1 ?\s)
1327 t)))
25d2f683
CW
1328 (t
1329 (ibuffer-map-lines
06b60517
JB
1330 (lambda (_buf mark)
1331 (when (not (char-equal mark ?\s))
1332 (ibuffer-set-mark-1 ?\s))
1333 t)))))
25d2f683
CW
1334 (ibuffer-redisplay t))
1335
b5cd37ea 1336(defun ibuffer-toggle-marks (&optional group)
25d2f683
CW
1337 "Toggle which buffers are marked.
1338In other words, unmarked buffers become marked, and marked buffers
cba63a2d
CW
1339become unmarked.
1340If point is on a group name, then this function operates on that
1341group."
25d2f683 1342 (interactive)
cba63a2d
CW
1343 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
1344 (setq group it))
25d2f683
CW
1345 (let ((count
1346 (ibuffer-map-lines
06b60517
JB
1347 (lambda (_buf mark)
1348 (cond ((eq mark ibuffer-marked-char)
1349 (ibuffer-set-mark-1 ?\s)
1350 nil)
1351 ((eq mark ?\s)
1352 (ibuffer-set-mark-1 ibuffer-marked-char)
1353 t)
1354 (t
1355 nil)))
b5cd37ea 1356 nil group)))
25d2f683
CW
1357 (message "%s buffers marked" count))
1358 (ibuffer-redisplay t))
1359
1360(defun ibuffer-mark-forward (arg)
cba63a2d
CW
1361 "Mark the buffer on this line, and move forward ARG lines.
1362If point is on a group name, this function operates on that group."
25d2f683
CW
1363 (interactive "P")
1364 (ibuffer-mark-interactive arg ibuffer-marked-char 1))
1365
1366(defun ibuffer-unmark-forward (arg)
cba63a2d
CW
1367 "Unmark the buffer on this line, and move forward ARG lines.
1368If point is on a group name, this function operates on that group."
25d2f683 1369 (interactive "P")
972b8f82 1370 (ibuffer-mark-interactive arg ?\s 1))
25d2f683
CW
1371
1372(defun ibuffer-unmark-backward (arg)
cba63a2d
CW
1373 "Unmark the buffer on this line, and move backward ARG lines.
1374If point is on a group name, this function operates on that group."
25d2f683 1375 (interactive "P")
972b8f82 1376 (ibuffer-mark-interactive arg ?\s -1))
25d2f683
CW
1377
1378(defun ibuffer-mark-interactive (arg mark movement)
87a6a53a 1379 (ibuffer-assert-ibuffer-mode)
34a4faa0 1380 (or arg (setq arg 1))
cba63a2d
CW
1381 (ibuffer-forward-line 0)
1382 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
1383 (progn
1384 (require 'ibuf-ext)
1385 (ibuffer-mark-on-buffer #'identity mark it))
4e4a724c 1386 (ibuffer-forward-line 0 t)
cba63a2d
CW
1387 (let ((inhibit-read-only t))
1388 (while (> arg 0)
1389 (ibuffer-set-mark mark)
1390 (ibuffer-forward-line movement t)
1391 (setq arg (1- arg))))))
25d2f683
CW
1392
1393(defun ibuffer-set-mark (mark)
87a6a53a 1394 (ibuffer-assert-ibuffer-mode)
25d2f683
CW
1395 (let ((inhibit-read-only t))
1396 (ibuffer-set-mark-1 mark)
1397 (setq ibuffer-did-modification t)
559ac4c1
CW
1398 (ibuffer-redisplay-current)
1399 (beginning-of-line)))
25d2f683
CW
1400
1401(defun ibuffer-set-mark-1 (mark)
1402 (let ((beg (line-beginning-position))
1403 (end (line-end-position)))
1404 (put-text-property beg end 'ibuffer-properties
1405 (list (ibuffer-current-buffer)
1406 mark))))
1407
1408(defun ibuffer-mark-for-delete (arg)
cba63a2d
CW
1409 "Mark the buffers on ARG lines forward for deletion.
1410If point is on a group name, this function operates on that group."
25d2f683
CW
1411 (interactive "P")
1412 (ibuffer-mark-interactive arg ibuffer-deletion-char 1))
1413
1414(defun ibuffer-mark-for-delete-backwards (arg)
cba63a2d
CW
1415 "Mark the buffers on ARG lines backward for deletion.
1416If point is on a group name, this function operates on that group."
25d2f683
CW
1417 (interactive "P")
1418 (ibuffer-mark-interactive arg ibuffer-deletion-char -1))
1419
1420(defun ibuffer-current-buffer (&optional must-be-live)
1421 (let ((buf (car (get-text-property (line-beginning-position)
1422 'ibuffer-properties))))
b5cd37ea
CW
1423 (when must-be-live
1424 (if (bufferp buf)
1425 (unless (buffer-live-p buf)
1388485d 1426 (error "Buffer %s has been killed; %s" buf (substitute-command-keys "use `\\[ibuffer-update]' to update")))
b5cd37ea 1427 (error "No buffer on this line")))
25d2f683 1428 buf))
523304ed
CW
1429
1430(defun ibuffer-active-formats-name ()
1431 (if (boundp 'ibuffer-filter-format-alist)
1432 (let ((ret nil))
1433 (dolist (filter ibuffer-filtering-qualifiers ret)
1434 (let ((val (assq (car filter) ibuffer-filter-format-alist)))
1435 (when val
1436 (setq ret (car filter)))))
1437 (if ret
1438 ret
1439 :ibuffer-formats))
1440 :ibuffer-formats))
1441
1442(defun ibuffer-current-formats (uncompiledp)
1443 (let* ((name (ibuffer-active-formats-name)))
1444 (ibuffer-check-formats)
1445 (if (eq name :ibuffer-formats)
1446 (if uncompiledp
1447 ibuffer-formats
1448 ibuffer-compiled-formats)
1449 (cadr (assq name
1450 (if uncompiledp
1451 ibuffer-filter-format-alist
1452 ibuffer-compiled-filter-formats))))))
71296446 1453
523304ed 1454(defun ibuffer-current-format (&optional uncompiledp)
25d2f683
CW
1455 (or ibuffer-current-format
1456 (setq ibuffer-current-format 0))
4e4a724c 1457 (nth ibuffer-current-format (ibuffer-current-formats uncompiledp)))
25d2f683
CW
1458
1459(defun ibuffer-expand-format-entry (form)
1460 (if (or (consp form)
1461 (symbolp form))
4e4a724c
JPW
1462 (let ((sym (intern (concat "ibuffer-make-column-"
1463 (symbol-name (if (consp form)
1464 (car form)
1465 form))))))
1466 (unless (or (fboundp sym)
1467 (assq sym ibuffer-inline-columns))
1468 (error "Unknown column %s in ibuffer-formats" form))
1469 (let (min max align elide)
1470 (if (consp form)
1471 (setq min (or (nth 1 form) 0)
1472 max (or (nth 2 form) -1)
1473 align (or (nth 3 form) :left)
1474 elide (or (nth 4 form) nil))
1475 (setq min 0
1476 max -1
1477 align :left
1478 elide nil))
1479 (list sym min max align elide)))
25d2f683 1480 form))
71296446 1481
25d2f683 1482(defun ibuffer-compile-make-eliding-form (strvar elide from-end-p)
545aad2f 1483 (let ((ellipsis (propertize ibuffer-eliding-string 'font-lock-face 'bold)))
63f0a166 1484 (if (or elide (with-no-warnings ibuffer-elide-long-columns))
25d2f683
CW
1485 `(if (> strlen 5)
1486 ,(if from-end-p
1487 `(concat ,ellipsis
1488 (substring ,strvar
1489 (length ibuffer-eliding-string)))
1490 `(concat
1491 (substring ,strvar 0 (- strlen ,(length ellipsis)))
1492 ,ellipsis))
1493 ,strvar)
1494 strvar)))
1495
1496(defun ibuffer-compile-make-substring-form (strvar maxvar from-end-p)
1497 (if from-end-p
1498 `(substring str
1499 (- strlen ,maxvar))
1500 `(substring ,strvar 0 ,maxvar)))
1501
1502(defun ibuffer-compile-make-format-form (strvar widthform alignment)
972b8f82
JB
1503 (let* ((left `(make-string tmp2 ?\s))
1504 (right `(make-string (- tmp1 tmp2) ?\s)))
25d2f683
CW
1505 `(progn
1506 (setq tmp1 ,widthform
1507 tmp2 (/ tmp1 2))
1508 ,(case alignment
1509 (:right `(concat ,left ,right ,strvar))
1510 (:center `(concat ,left ,strvar ,right))
1511 (:left `(concat ,strvar ,left ,right))
1512 (t (error "Invalid alignment %s" alignment))))))
1513
1514(defun ibuffer-compile-format (format)
1515 (let ((result nil)
cb059426
CW
1516 ;; We use these variables to keep track of which variables
1517 ;; inside the generated function we need to bind, since
1518 ;; binding variables in Emacs takes time.
1519 str-used tmp1-used tmp2-used global-strlen-used)
25d2f683
CW
1520 (dolist (form format)
1521 (push
cb059426
CW
1522 ;; Generate a form based on a particular format entry, like
1523 ;; " ", mark, or (mode 16 16 :right).
25d2f683 1524 (if (stringp form)
cb059426 1525 ;; It's a string; all we need to do is insert it.
25d2f683
CW
1526 `(insert ,form)
1527 (let* ((form (ibuffer-expand-format-entry form))
1528 (sym (nth 0 form))
1529 (min (nth 1 form))
1530 (max (nth 2 form))
1531 (align (nth 3 form))
1532 (elide (nth 4 form)))
1533 (let* ((from-end-p (when (minusp min)
1534 (setq min (- min))
1535 t))
1536 (letbindings nil)
1537 (outforms nil)
1538 minform
1539 maxform
1540 min-used max-used strlen-used)
1541 (when (or (not (integerp min)) (>= min 0))
cb059426
CW
1542 ;; This is a complex case; they want it limited to a
1543 ;; minimum size.
25d2f683
CW
1544 (setq min-used t)
1545 (setq str-used t strlen-used t global-strlen-used t
1546 tmp1-used t tmp2-used t)
cb059426 1547 ;; Generate code to limit the string to a minimum size.
25d2f683
CW
1548 (setq minform `(progn
1549 (setq str
1550 ,(ibuffer-compile-make-format-form
1551 'str
1552 `(- ,(if (integerp min)
1553 min
1554 'min)
1555 strlen)
1556 align)))))
1557 (when (or (not (integerp max)) (> max 0))
1558 (setq str-used t max-used t)
cb059426 1559 ;; Generate code to limit the string to a maximum size.
25d2f683
CW
1560 (setq maxform `(progn
1561 (setq str
1562 ,(ibuffer-compile-make-substring-form
1563 'str
1564 (if (integerp max)
1565 max
1566 'max)
1567 from-end-p))
1568 (setq strlen (length str))
1569 (setq str
b016851c
SM
1570 ,(ibuffer-compile-make-eliding-form
1571 'str elide from-end-p)))))
cb059426
CW
1572 ;; Now, put these forms together with the rest of the code.
1573 (let ((callform
1574 ;; Is this an "inline" column? This means we have
1575 ;; to get the code from the
1576 ;; `ibuffer-inline-columns' alist and insert it
1577 ;; into our generated code. Otherwise, we just
1578 ;; generate a call to the column function.
1579 (ibuffer-aif (assq sym ibuffer-inline-columns)
4e4a724c
JPW
1580 (nth 1 it)
1581 `(,sym buffer mark)))
cb059426
CW
1582 ;; You're not expected to understand this. Hell, I
1583 ;; don't even understand it, and I wrote it five
1584 ;; minutes ago.
b016851c
SM
1585 (insertgenfn
1586 (ibuffer-aif (get sym 'ibuffer-column-summarizer)
1587 ;; I really, really wish Emacs Lisp had closures.
1588 (lambda (arg sym)
1589 `(insert
1590 (let ((ret ,arg))
1591 (put ',sym 'ibuffer-column-summary
1592 (cons ret (get ',sym
1593 'ibuffer-column-summary)))
1594 ret)))
1595 (lambda (arg sym)
1596 `(insert ,arg))))
25d2f683
CW
1597 (mincompform `(< strlen ,(if (integerp min)
1598 min
1599 'min)))
1600 (maxcompform `(> strlen ,(if (integerp max)
1601 max
1602 'max))))
4e4a724c
JPW
1603 (if (or min-used max-used)
1604 ;; The complex case, where we have to limit the
1605 ;; form to a maximum or minimum size.
1606 (progn
1607 (when (and min-used (not (integerp min)))
1608 (push `(min ,min) letbindings))
1609 (when (and max-used (not (integerp max)))
1610 (push `(max ,max) letbindings))
1611 (push
1612 (if (and min-used max-used)
1613 `(if ,mincompform
1614 ,minform
1615 (if ,maxcompform
1616 ,maxform))
1617 (if min-used
1618 `(when ,mincompform
1619 ,minform)
1620 `(when ,maxcompform
1621 ,maxform)))
1622 outforms)
1623 (push (append
1624 `(setq str ,callform)
1625 (when strlen-used
1626 `(strlen (length str))))
1627 outforms)
1628 (setq outforms
b016851c
SM
1629 (append outforms
1630 (list (funcall insertgenfn 'str sym)))))
4e4a724c
JPW
1631 ;; The simple case; just insert the string.
1632 (push (funcall insertgenfn callform sym) outforms))
1633 ;; Finally, return a `let' form which binds the
1634 ;; variables in `letbindings', and contains all the
1635 ;; code in `outforms'.
1636 `(let ,letbindings
1637 ,@outforms)))))
25d2f683
CW
1638 result))
1639 (setq result
cb059426 1640 ;; We don't want to unconditionally load the byte-compiler.
25d2f683
CW
1641 (funcall (if (or ibuffer-always-compile-formats
1642 (featurep 'bytecomp))
1643 #'byte-compile
1644 #'identity)
cb059426
CW
1645 ;; Here, we actually create a lambda form which
1646 ;; inserts all the generated forms for each entry
1647 ;; in the format string.
25d2f683 1648 (nconc (list 'lambda '(buffer mark))
d99b259b 1649 `((let ,(append (when str-used
25d2f683
CW
1650 '(str))
1651 (when global-strlen-used
1652 '(strlen))
1653 (when tmp1-used
1654 '(tmp1))
1655 (when tmp2-used
1656 '(tmp2)))
1657 ,@(nreverse result))))))))
1658
25d2f683
CW
1659(defun ibuffer-recompile-formats ()
1660 "Recompile `ibuffer-formats'."
1661 (interactive)
1662 (setq ibuffer-compiled-formats
4e4a724c 1663 (mapcar #'ibuffer-compile-format ibuffer-formats))
523304ed
CW
1664 (when (boundp 'ibuffer-filter-format-alist)
1665 (setq ibuffer-compiled-filter-formats
06b60517
JB
1666 (mapcar (lambda (entry)
1667 (cons (car entry)
1668 (mapcar (lambda (formats)
1669 (mapcar #'ibuffer-compile-format formats))
1670 (cdr entry))))
523304ed 1671 ibuffer-filter-format-alist))))
25d2f683 1672
cb059426
CW
1673(defun ibuffer-clear-summary-columns (format)
1674 (dolist (form format)
1675 (ibuffer-awhen (and (consp form)
1676 (get (car form) 'ibuffer-column-summarizer))
1677 (put (car form) 'ibuffer-column-summary nil))))
71296446 1678
25d2f683 1679(defun ibuffer-check-formats ()
523304ed
CW
1680 (when (null ibuffer-formats)
1681 (error "No formats!"))
b5cd37ea
CW
1682 (let ((ext-loaded (featurep 'ibuf-ext)))
1683 (when (or (null ibuffer-compiled-formats)
1684 (null ibuffer-cached-formats)
1685 (not (eq ibuffer-cached-formats ibuffer-formats))
1686 (null ibuffer-cached-eliding-string)
1687 (not (equal ibuffer-cached-eliding-string ibuffer-eliding-string))
1688 (eql 0 ibuffer-cached-elide-long-columns)
1689 (not (eql ibuffer-cached-elide-long-columns
63f0a166 1690 (with-no-warnings ibuffer-elide-long-columns)))
b5cd37ea
CW
1691 (and ext-loaded
1692 (not (eq ibuffer-cached-filter-formats
1693 ibuffer-filter-format-alist))
1694 (and ibuffer-filter-format-alist
1695 (null ibuffer-compiled-filter-formats))))
1696 (message "Formats have changed, recompiling...")
1697 (ibuffer-recompile-formats)
1698 (setq ibuffer-cached-formats ibuffer-formats
1699 ibuffer-cached-eliding-string ibuffer-eliding-string
63f0a166 1700 ibuffer-cached-elide-long-columns (with-no-warnings ibuffer-elide-long-columns))
b5cd37ea
CW
1701 (when ext-loaded
1702 (setq ibuffer-cached-filter-formats ibuffer-filter-format-alist))
1703 (message "Formats have changed, recompiling...done"))))
25d2f683
CW
1704
1705(defvar ibuffer-inline-columns nil)
1706
1707(define-ibuffer-column mark (:name " " :inline t)
1708 (string mark))
1709
1710(define-ibuffer-column read-only (:name "R" :inline t)
1711 (if buffer-read-only
34a4faa0 1712 (string ibuffer-read-only-char)
25d2f683
CW
1713 " "))
1714
1715(define-ibuffer-column modified (:name "M" :inline t)
1716 (if (buffer-modified-p)
1717 (string ibuffer-modified-char)
1718 " "))
1719
34a4faa0
JPW
1720(define-ibuffer-column name
1721 (:inline t
f0b31589 1722 :header-mouse-map ibuffer-name-header-map
34a4faa0
JPW
1723 :props
1724 ('mouse-face 'highlight 'keymap ibuffer-name-map
1725 'ibuffer-name-column t
1726 'help-echo '(if tooltip-mode
1727 "mouse-1: mark this buffer\nmouse-2: select this buffer\nmouse-3: operate on this buffer"
1728 "mouse-1: mark buffer mouse-2: select buffer mouse-3: operate"))
1729 :summarizer
1730 (lambda (strings)
1731 (let ((bufs (length strings)))
1732 (cond ((zerop bufs) "No buffers")
1733 ((= 1 bufs) "1 buffer")
1734 (t (format "%s buffers" bufs))))))
545aad2f 1735 (propertize (buffer-name) 'font-lock-face (ibuffer-buffer-name-face buffer mark)))
71296446 1736
34a4faa0
JPW
1737(define-ibuffer-column size
1738 (:inline t
f0b31589 1739 :header-mouse-map ibuffer-size-header-map
34a4faa0
JPW
1740 :summarizer
1741 (lambda (column-strings)
1742 (let ((total 0))
1743 (dolist (string column-strings)
1744 (setq total
1745 ;; like, ewww ...
7ad938e7 1746 (+ (float (string-to-number string))
34a4faa0
JPW
1747 total)))
1748 (format "%.0f" total))))
25d2f683
CW
1749 (format "%s" (buffer-size)))
1750
7ad938e7
JPW
1751(define-ibuffer-column mode
1752 (:inline t
f0b31589 1753 :header-mouse-map ibuffer-mode-header-map
7ad938e7
JPW
1754 :props
1755 ('mouse-face 'highlight
1756 'keymap ibuffer-mode-name-map
1757 'help-echo "mouse-2: filter by this mode"))
23eabff6 1758 (format-mode-line mode-name nil nil (current-buffer)))
25d2f683 1759
34a4faa0
JPW
1760(define-ibuffer-column process
1761 (:summarizer
1762 (lambda (strings)
1763 (let ((total (length (delete "" strings))))
1764 (cond ((zerop total) "No processes")
1765 ((= 1 total) "1 process")
1766 (t (format "%d processes" total))))))
96777edb
CW
1767 (ibuffer-aif (get-buffer-process buffer)
1768 (format "(%s %s)" it (process-status it))
34a4faa0
JPW
1769 ""))
1770
1771(define-ibuffer-column filename
1772 (:summarizer
1773 (lambda (strings)
1774 (let ((total (length (delete "" strings))))
1775 (cond ((zerop total) "No files")
1776 ((= 1 total) "1 file")
1777 (t (format "%d files" total))))))
25d2f683
CW
1778 (let ((directory-abbrev-alist ibuffer-directory-abbrev-alist))
1779 (abbreviate-file-name
9d458edc 1780 (or (ibuffer-buffer-file-name) ""))))
25d2f683 1781
34a4faa0
JPW
1782(define-ibuffer-column filename-and-process
1783 (:name "Filename/Process"
d5794180 1784 :header-mouse-map ibuffer-filename/process-header-map
34a4faa0
JPW
1785 :summarizer
1786 (lambda (strings)
1787 (setq strings (delete "" strings))
1788 (let ((procs 0)
1789 (files 0))
1790 (dolist (string strings)
1791 (if (string-match "\\(\?:\\`(\[\[:ascii:\]\]\+)\\)" string)
1792 (progn (setq procs (1+ procs))
1793 (if (< (match-end 0) (length string))
1794 (setq files (1+ files))))
1795 (setq files (1+ files))))
1796 (concat (cond ((zerop files) "No files")
1797 ((= 1 files) "1 file")
1798 (t (format "%d files" files)))
1799 ", "
1800 (cond ((zerop procs) "no processes")
1801 ((= 1 procs) "1 process")
1802 (t (format "%d processes" procs)))))))
fd225d80 1803 (let ((proc (get-buffer-process buffer))
63e0bf5e 1804 (filename (ibuffer-make-column-filename buffer mark)))
fd225d80 1805 (if proc
34a4faa0 1806 (concat (propertize (format "(%s %s)" proc (process-status proc))
545aad2f 1807 'font-lock-face 'italic)
34a4faa0
JPW
1808 (if (> (length filename) 0)
1809 (format " %s" filename)
1810 ""))
fd225d80
CW
1811 filename)))
1812
25d2f683 1813(defun ibuffer-format-column (str width alignment)
972b8f82
JB
1814 (let ((left (make-string (/ width 2) ?\s))
1815 (right (make-string (- width (/ width 2)) ?\s)))
25d2f683
CW
1816 (case alignment
1817 (:right (concat left right str))
1818 (:center (concat left str right))
1819 (t (concat str left right)))))
1820
545aad2f 1821(defun ibuffer-buffer-name-face (buf mark)
fd225d80 1822 (cond ((char-equal mark ibuffer-marked-char)
545aad2f 1823 ibuffer-marked-face)
fd225d80 1824 ((char-equal mark ibuffer-deletion-char)
545aad2f 1825 ibuffer-deletion-face)
fd225d80
CW
1826 (t
1827 (let ((level -1)
fd225d80
CW
1828 result)
1829 (dolist (e ibuffer-fontification-alist result)
1830 (when (and (> (car e) level)
1831 (with-current-buffer buf
545aad2f 1832 (eval (nth 1 e))))
fd225d80 1833 (setq level (car e)
545aad2f 1834 result (nth 2 e))))))))
25d2f683
CW
1835
1836(defun ibuffer-insert-buffer-line (buffer mark format)
1837 "Insert a line describing BUFFER and MARK using FORMAT."
87a6a53a 1838 (ibuffer-assert-ibuffer-mode)
25d2f683 1839 (let ((beg (point)))
25d2f683 1840 (funcall format buffer mark)
cb059426
CW
1841 (put-text-property beg (point) 'ibuffer-properties (list buffer mark)))
1842 (insert "\n"))
25d2f683 1843
cb059426 1844;; This function knows a bit too much of the internals. It would be
b5cd37ea 1845;; nice if it was all abstracted away.
25d2f683 1846(defun ibuffer-redisplay-current ()
87a6a53a 1847 (ibuffer-assert-ibuffer-mode)
25d2f683
CW
1848 (when (eobp)
1849 (forward-line -1))
1850 (beginning-of-line)
cb059426
CW
1851 (let ((curformat (mapcar #'ibuffer-expand-format-entry
1852 (ibuffer-current-format t))))
1853 (ibuffer-clear-summary-columns curformat)
1854 (let ((buf (ibuffer-current-buffer)))
1855 (when buf
1856 (let ((mark (ibuffer-current-mark)))
ed233dd8
CW
1857 (save-excursion
1858 (delete-region (point) (1+ (line-end-position)))
1859 (ibuffer-insert-buffer-line
1860 buf mark
1861 (ibuffer-current-format)))
cb059426
CW
1862 (when ibuffer-shrink-to-minimum-size
1863 (ibuffer-shrink-to-fit)))))))
71296446 1864
25d2f683
CW
1865(defun ibuffer-map-on-mark (mark func)
1866 (ibuffer-map-lines
06b60517
JB
1867 (lambda (buf mk)
1868 (if (char-equal mark mk)
1869 (funcall func buf mark)
1870 nil))))
25d2f683 1871
b5cd37ea
CW
1872(defun ibuffer-map-lines (function &optional nomodify group)
1873 "Call FUNCTION for each buffer.
4837b516 1874Set the ibuffer modification flag unless NOMODIFY is non-nil.
25d2f683 1875
b5cd37ea
CW
1876If optional argument GROUP is non-nil, then only call FUNCTION on
1877buffers in filtering group GROUP.
1878
4e4a724c
JPW
1879FUNCTION is called with two arguments:
1880the buffer object itself and the current mark symbol."
87a6a53a 1881 (ibuffer-assert-ibuffer-mode)
b5cd37ea
CW
1882 (ibuffer-forward-line 0)
1883 (let* ((orig-target-line (1+ (count-lines (save-excursion
1884 (goto-char (point-min))
1885 (ibuffer-forward-line 0)
1886 (point))
1887 (point))))
1888 (target-line-offset orig-target-line)
1889 (ibuffer-map-lines-total 0)
1890 (ibuffer-map-lines-count 0))
25d2f683 1891 (unwind-protect
57c9cc3e
CW
1892 (progn
1893 (setq buffer-read-only nil)
1894 (goto-char (point-min))
4e4a724c 1895 (ibuffer-forward-line 0 t)
57c9cc3e 1896 (while (and (not (eobp))
b5cd37ea
CW
1897 (not (get-text-property (point) 'ibuffer-summary))
1898 (progn
1899 (ibuffer-forward-line 0 t)
1900 (and (not (eobp))
1901 (not (get-text-property (point) 'ibuffer-summary)))))
57c9cc3e
CW
1902 (let ((result
1903 (if (buffer-live-p (ibuffer-current-buffer))
b5cd37ea
CW
1904 (when (or (null group)
1905 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group)
1906 (equal group it)))
1907 (save-excursion
1908 (funcall function
1909 (ibuffer-current-buffer)
1910 (ibuffer-current-mark))))
57c9cc3e
CW
1911 ;; Kill the line if the buffer is dead
1912 'kill)))
1913 ;; A given mapping function should return:
1914 ;; `nil' if it chose not to affect the buffer
1915 ;; `kill' means the remove line from the buffer list
1916 ;; `t' otherwise
1917 (incf ibuffer-map-lines-total)
1918 (cond ((null result)
1919 (forward-line 1))
1920 ((eq result 'kill)
1921 (delete-region (line-beginning-position)
1922 (1+ (line-end-position)))
1923 (incf ibuffer-map-lines-count)
1924 (when (< ibuffer-map-lines-total
4e4a724c 1925 orig-target-line)
b5cd37ea 1926 (decf target-line-offset)))
57c9cc3e
CW
1927 (t
1928 (incf ibuffer-map-lines-count)
1929 (forward-line 1)))))
1930 ibuffer-map-lines-count)
25d2f683
CW
1931 (progn
1932 (setq buffer-read-only t)
1933 (unless nomodify
1934 (set-buffer-modified-p nil))
57c9cc3e
CW
1935 (goto-char (point-min))
1936 (ibuffer-forward-line 0)
b5cd37ea 1937 (ibuffer-forward-line (1- target-line-offset))))))
25d2f683
CW
1938
1939(defun ibuffer-get-marked-buffers ()
1940 "Return a list of buffer objects currently marked."
1941 (delq nil
06b60517
JB
1942 (mapcar (lambda (e)
1943 (when (eq (cdr e) ibuffer-marked-char)
1944 (car e)))
25d2f683
CW
1945 (ibuffer-current-state-list))))
1946
d246cabf
CW
1947(defun ibuffer-current-state-list (&optional pos)
1948 "Return a list like (BUF . MARK) of all buffers in an ibuffer.
1949If POS is non-nil, return a list like (BUF MARK POINT), where POINT is
1950the value of point at the beginning of the line for that buffer."
25d2f683
CW
1951 (let ((ibuffer-current-state-list-tmp '()))
1952 ;; ah, if only we had closures. I bet this will mysteriously
1953 ;; break later. Don't blame me.
d246cabf
CW
1954 (if pos
1955 (ibuffer-map-lines-nomodify
06b60517 1956 (lambda (buf mark)
d246cabf 1957 (when (buffer-live-p buf)
06b60517
JB
1958 (push (list buf mark (point)) ibuffer-current-state-list-tmp))))
1959 (ibuffer-map-lines-nomodify
1960 (lambda (buf mark)
1961 (when (buffer-live-p buf)
1962 (push (cons buf mark) ibuffer-current-state-list-tmp)))))
25d2f683
CW
1963 (nreverse ibuffer-current-state-list-tmp)))
1964
851476d4 1965(defun ibuffer-current-buffers-with-marks (curbufs)
25d2f683
CW
1966 "Return a list like (BUF . MARK) of all open buffers."
1967 (let ((bufs (ibuffer-current-state-list)))
06b60517
JB
1968 (mapcar (lambda (buf) (let ((e (assq buf bufs)))
1969 (if e
1970 e
1971 (cons buf ?\s))))
851476d4 1972 curbufs)))
25d2f683
CW
1973
1974(defun ibuffer-buf-matches-predicates (buf predicates)
1975 (let ((hit nil)
1976 (name (buffer-name buf)))
1977 (dolist (pred predicates)
1978 (when (if (stringp pred)
1979 (string-match pred name)
1980 (funcall pred buf))
1981 (setq hit t)))
1982 hit))
71296446 1983
25d2f683
CW
1984(defun ibuffer-filter-buffers (ibuffer-buf last bmarklist all)
1985 (let ((ext-loaded (featurep 'ibuf-ext)))
1986 (delq nil
b5cd37ea
CW
1987 (mapcar
1988 ;; element should be like (BUFFER . MARK)
06b60517
JB
1989 (lambda (e)
1990 (let* ((buf (car e)))
1991 (when
1992 ;; This takes precedence over anything else
1993 (or (and ibuffer-always-show-last-buffer
1994 (eq last buf))
1995 (funcall (if ext-loaded
1996 #'ibuffer-ext-visible-p
1997 #'ibuffer-visible-p)
1998 buf all ibuffer-buf))
1999 e)))
b5cd37ea 2000 bmarklist))))
25d2f683
CW
2001
2002(defun ibuffer-visible-p (buf all &optional ibuffer-buf)
2003 (and (or all
2004 (not
2005 (ibuffer-buf-matches-predicates buf ibuffer-maybe-show-predicates)))
2006 (or ibuffer-view-ibuffer
4e4a724c 2007 (and ibuffer-buf
25d2f683
CW
2008 (not (eq ibuffer-buf buf))))))
2009
2010;; This function is a special case; it's not defined by
6081889e 2011;; `define-ibuffer-sorter'.
25d2f683
CW
2012(defun ibuffer-do-sort-by-recency ()
2013 "Sort the buffers by last view time."
2014 (interactive)
2015 (setq ibuffer-sorting-mode 'recency)
e7820654
JPW
2016 (when (eq ibuffer-last-sorting-mode 'recency)
2017 (setq ibuffer-sorting-reversep (not ibuffer-sorting-reversep)))
2018 (ibuffer-update nil t)
2019 (setq ibuffer-last-sorting-mode 'recency))
25d2f683
CW
2020
2021(defun ibuffer-update-format ()
2022 (when (null ibuffer-current-format)
2023 (setq ibuffer-current-format 0))
2024 (when (null ibuffer-formats)
2025 (error "Ibuffer error: no formats!")))
2026
2027(defun ibuffer-switch-format ()
2028 "Switch the current display format."
2029 (interactive)
87a6a53a 2030 (ibuffer-assert-ibuffer-mode)
25d2f683
CW
2031 (unless (consp ibuffer-formats)
2032 (error "Ibuffer error: No formats!"))
2033 (setq ibuffer-current-format
80a06d64 2034 (if (>= ibuffer-current-format (1- (length (ibuffer-current-formats nil))))
25d2f683
CW
2035 0
2036 (1+ ibuffer-current-format)))
2037 (ibuffer-update-format)
2038 (ibuffer-redisplay t))
2039
cb059426 2040(defun ibuffer-update-title-and-summary (format)
87a6a53a 2041 (ibuffer-assert-ibuffer-mode)
25d2f683
CW
2042 ;; Don't do funky font-lock stuff here
2043 (let ((after-change-functions nil))
2044 (if (get-text-property (point-min) 'ibuffer-title)
2045 (delete-region (point-min)
2046 (next-single-property-change
2047 (point-min) 'ibuffer-title)))
2048 (goto-char (point-min))
fd225d80 2049 (add-text-properties
25d2f683
CW
2050 (point)
2051 (progn
2052 (let ((opos (point)))
2053 ;; Insert the title names.
cb059426 2054 (dolist (element format)
25d2f683
CW
2055 (insert
2056 (if (stringp element)
2057 element
2058 (let ((sym (car element))
2059 (min (cadr element))
2060 ;; (max (caddr element))
2061 (align (cadddr element)))
4e4a724c 2062 ;; Ignore a negative min when we're inserting the title
25d2f683
CW
2063 (when (minusp min)
2064 (setq min (- min)))
2065 (let* ((name (or (get sym 'ibuffer-column-name)
2066 (error "Unknown column %s in ibuffer-formats" sym)))
f0b31589
DN
2067 (len (length name))
2068 (hmap (get sym 'header-mouse-map))
2069 (strname (if (< len min)
2070 (ibuffer-format-column name
2071 (- min len)
2072 align)
2073 name)))
2074 (when hmap
2075 (setq
2ead9289 2076 strname
f0b31589
DN
2077 (propertize strname 'mouse-face 'highlight 'keymap hmap)))
2078 strname)))))
fd225d80 2079 (add-text-properties opos (point) `(ibuffer-title-header t))
25d2f683
CW
2080 (insert "\n")
2081 ;; Add the underlines
2082 (let ((str (save-excursion
2083 (forward-line -1)
2084 (beginning-of-line)
2085 (buffer-substring (point) (line-end-position)))))
2086 (apply #'insert (mapcar
06b60517
JB
2087 (lambda (c)
2088 (if (not (or (char-equal c ?\s)
2089 (char-equal c ?\n)))
2090 ?-
2091 ?\s))
25d2f683
CW
2092 str)))
2093 (insert "\n"))
2094 (point))
545aad2f 2095 `(ibuffer-title t font-lock-face ,ibuffer-title-face))
cb059426
CW
2096 ;; Now, insert the summary columns.
2097 (goto-char (point-max))
2098 (if (get-text-property (1- (point-max)) 'ibuffer-summary)
2099 (delete-region (previous-single-property-change
2100 (point-max) 'ibuffer-summary)
2101 (point-max)))
0740098c
JPW
2102 (if ibuffer-display-summary
2103 (add-text-properties
2104 (point)
2105 (progn
2106 (insert "\n")
2107 (dolist (element format)
2108 (insert
2109 (if (stringp element)
972b8f82 2110 (make-string (length element) ?\s)
0740098c
JPW
2111 (let ((sym (car element)))
2112 (let ((min (cadr element))
2113 ;; (max (caddr element))
2114 (align (cadddr element)))
2115 ;; Ignore a negative min when we're inserting the title
2116 (when (minusp min)
2117 (setq min (- min)))
2118 (let* ((summary (if (get sym 'ibuffer-column-summarizer)
2119 (funcall (get sym 'ibuffer-column-summarizer)
2120 (get sym 'ibuffer-column-summary))
2121 (make-string (length (get sym 'ibuffer-column-name))
972b8f82 2122 ?\s)))
0740098c
JPW
2123 (len (length summary)))
2124 (if (< len min)
2125 (ibuffer-format-column summary
2126 (- min len)
2127 align)
2128 summary)))))))
2129 (point))
2130 `(ibuffer-summary t)))))
25d2f683 2131
25d2f683
CW
2132
2133(defun ibuffer-redisplay (&optional silent)
2134 "Redisplay the current list of buffers.
25d2f683
CW
2135This does not show new buffers; use `ibuffer-update' for that.
2136
7ad5b902 2137If optional arg SILENT is non-nil, do not display progress messages."
25d2f683 2138 (interactive)
57c9cc3e 2139 (ibuffer-forward-line 0)
25d2f683
CW
2140 (unless silent
2141 (message "Redisplaying current buffer list..."))
2142 (let ((blist (ibuffer-current-state-list)))
de5939ba
CS
2143 (when (and (null blist)
2144 (featurep 'ibuf-ext)
cba63a2d 2145 (or ibuffer-filtering-qualifiers ibuffer-hidden-filter-groups))
de5939ba 2146 (message "No buffers! (note: filtering in effect)"))
b5cd37ea 2147 (ibuffer-redisplay-engine blist t)
25d2f683 2148 (unless silent
57c9cc3e
CW
2149 (message "Redisplaying current buffer list...done"))
2150 (ibuffer-forward-line 0)))
25d2f683
CW
2151
2152(defun ibuffer-update (arg &optional silent)
2153 "Regenerate the list of all buffers.
957237cb
JPW
2154
2155Prefix arg non-nil means to toggle whether buffers that match
2156`ibuffer-maybe-show-predicates' should be displayed.
25d2f683 2157
7ad5b902 2158If optional arg SILENT is non-nil, do not display progress messages."
25d2f683 2159 (interactive "P")
957237cb
JPW
2160 (if arg
2161 (setq ibuffer-display-maybe-show-predicates
2162 (not ibuffer-display-maybe-show-predicates)))
57c9cc3e 2163 (ibuffer-forward-line 0)
25d2f683
CW
2164 (let* ((bufs (buffer-list))
2165 (blist (ibuffer-filter-buffers
94394914
JPW
2166 (current-buffer)
2167 (if (and
2168 (cadr bufs)
2169 (eq ibuffer-always-show-last-buffer
2170 :nomini)
8e7dbfdb 2171 (minibufferp (cadr bufs)))
da337a28 2172 (caddr bufs)
94394914
JPW
2173 (cadr bufs))
2174 (ibuffer-current-buffers-with-marks bufs)
957237cb 2175 ibuffer-display-maybe-show-predicates)))
25d2f683
CW
2176 (when (null blist)
2177 (if (and (featurep 'ibuf-ext)
2178 ibuffer-filtering-qualifiers)
2179 (message "No buffers! (note: filtering in effect)")
2180 (error "No buffers!")))
2181 (unless silent
2182 (message "Updating buffer list..."))
b5cd37ea 2183 (ibuffer-redisplay-engine blist arg)
25d2f683
CW
2184 (unless silent
2185 (message "Updating buffer list...done")))
2186 (if (eq ibuffer-shrink-to-minimum-size 'onewindow)
2187 (ibuffer-shrink-to-fit t)
2188 (when ibuffer-shrink-to-minimum-size
2189 (ibuffer-shrink-to-fit)))
6d11a78b
SM
2190 (ibuffer-forward-line 0)
2191 ;; I tried to update this automatically from the mode-line-process format,
2192 ;; but changing nil-ness of header-line-format while computing
2193 ;; mode-line-format is asking a bit too much it seems. --Stef
2194 (setq header-line-format
2195 (and ibuffer-use-header-line
2196 ibuffer-filtering-qualifiers
2197 ibuffer-header-line-format)))
25d2f683 2198
b5cd37ea 2199(defun ibuffer-sort-bufferlist (bmarklist)
e19fff38
JB
2200 (unless ibuffer-sorting-functions-alist
2201 ;; make sure the sorting functions are loaded
2202 (require 'ibuf-ext))
b5cd37ea
CW
2203 (let* ((sortdat (assq ibuffer-sorting-mode
2204 ibuffer-sorting-functions-alist))
2205 (func (caddr sortdat)))
2206 (let ((result
2207 ;; actually sort the buffers
2208 (if (and sortdat func)
2209 (sort bmarklist func)
2210 bmarklist)))
2211 ;; perhaps reverse the sorted buffer list
2212 (if ibuffer-sorting-reversep
2213 (nreverse result)
2214 result))))
2215
7fbac645 2216(defun ibuffer-insert-filter-group (name display-name filter-string format bmarklist)
b5cd37ea
CW
2217 (add-text-properties
2218 (point)
2219 (progn
2220 (insert "[ " display-name " ]")
2221 (point))
fd225d80
CW
2222 `(ibuffer-filter-group-name
2223 ,name
545aad2f 2224 font-lock-face ,ibuffer-filter-group-name-face
fd225d80
CW
2225 keymap ,ibuffer-mode-filter-group-map
2226 mouse-face highlight
1cd7affa
JPW
2227 help-echo ,(let ((echo '(if tooltip-mode
2228 "mouse-1: toggle marks in this group\nmouse-2: hide/show this filtering group"
ce3a4c83 2229 "mouse-1: toggle marks mouse-2: hide/show")))
1cd7affa 2230 (if (> (length filter-string) 0)
ce3a4c83
JPW
2231 `(concat ,filter-string
2232 (if tooltip-mode "\n" " ")
2233 ,echo)
1cd7affa 2234 echo))))
b5cd37ea
CW
2235 (insert "\n")
2236 (when bmarklist
2237 (put-text-property
2238 (point)
2239 (progn
2240 (dolist (entry bmarklist)
2241 (ibuffer-insert-buffer-line (car entry) (cdr entry) format))
2242 (point))
2243 'ibuffer-filter-group
2244 name)))
2245
06b60517 2246(defun ibuffer-redisplay-engine (bmarklist &optional _ignore)
87a6a53a 2247 (ibuffer-assert-ibuffer-mode)
b5cd37ea
CW
2248 (let* ((--ibuffer-insert-buffers-and-marks-format
2249 (ibuffer-current-format))
2250 (--ibuffer-expanded-format (mapcar #'ibuffer-expand-format-entry
2251 (ibuffer-current-format t)))
2252 (orig (count-lines (point-min) (point)))
2253 ;; Inhibit font-lock caching tricks, since we're modifying the
2254 ;; entire buffer at once
2255 (after-change-functions nil)
2256 (ext-loaded (featurep 'ibuf-ext))
2257 (bgroups (if ext-loaded
2258 (ibuffer-generate-filter-groups bmarklist)
2259 (list (cons "Default" bmarklist)))))
cb059426 2260 (ibuffer-clear-summary-columns --ibuffer-expanded-format)
25d2f683
CW
2261 (unwind-protect
2262 (progn
2263 (setq buffer-read-only nil)
2264 (erase-buffer)
2265 (ibuffer-update-format)
b5cd37ea
CW
2266 (dolist (group (nreverse bgroups))
2267 (let* ((name (car group))
2268 (disabled (and ext-loaded
cba63a2d 2269 (member name ibuffer-hidden-filter-groups)))
b5cd37ea 2270 (bmarklist (cdr group)))
cba63a2d 2271 (unless (and (null bmarklist)
b90a6a12 2272 (not disabled)
cba63a2d
CW
2273 ext-loaded
2274 (null ibuffer-show-empty-filter-groups))
2275 (ibuffer-insert-filter-group
2276 name
2277 (if disabled (concat name " ...") name)
7fbac645
CW
2278 (if ext-loaded
2279 (ibuffer-format-filter-group-data name)
2280 "")
cba63a2d
CW
2281 --ibuffer-insert-buffers-and-marks-format
2282 (if disabled
2283 nil
2284 (ibuffer-sort-bufferlist bmarklist))))))
cb059426 2285 (ibuffer-update-title-and-summary --ibuffer-expanded-format))
25d2f683
CW
2286 (setq buffer-read-only t)
2287 (set-buffer-modified-p ibuffer-did-modification)
2288 (setq ibuffer-did-modification nil)
e600eb79 2289 (goto-char (point-min))
2ead9289 2290 (forward-line orig))))
25d2f683
CW
2291
2292(defun ibuffer-quit ()
2293 "Quit this `ibuffer' session.
4837b516 2294Try to restore the previous window configuration if
4ed1f829 2295`ibuffer-restore-window-config-on-quit' is non-nil."
25d2f683 2296 (interactive)
4ed1f829 2297 (if ibuffer-restore-window-config-on-quit
7ad938e7 2298 (progn
25d2f683
CW
2299 (bury-buffer)
2300 (unless (= (count-windows) 1)
4ed1f829 2301 (set-window-configuration ibuffer-prev-window-config)))
25d2f683
CW
2302 (bury-buffer)))
2303
2304;;;###autoload
2305(defun ibuffer-list-buffers (&optional files-only)
2306 "Display a list of buffers, in another window.
2307If optional argument FILES-ONLY is non-nil, then add a filter for
2308buffers which are visiting a file."
2309 (interactive "P")
2310 (ibuffer t nil (when files-only
2311 '((filename . ".*"))) t))
2312
2313;;;###autoload
2314(defun ibuffer-other-window (&optional files-only)
2315 "Like `ibuffer', but displayed in another window by default.
2316If optional argument FILES-ONLY is non-nil, then add a filter for
2317buffers which are visiting a file."
2318 (interactive "P")
2319 (ibuffer t nil (when files-only
2320 '((filename . ".*")))))
2321
2322;;;###autoload
b5cd37ea 2323(defun ibuffer (&optional other-window-p name qualifiers noselect
fd225d80 2324 shrink filter-groups formats)
972b8f82 2325 "Begin using Ibuffer to edit a list of buffers.
25d2f683
CW
2326Type 'h' after entering ibuffer for more information.
2327
972b8f82
JB
2328All arguments are optional.
2329OTHER-WINDOW-P says to use another window.
2330NAME specifies the name of the buffer (defaults to \"*Ibuffer*\").
2331QUALIFIERS is an initial set of filtering qualifiers to use;
2332 see `ibuffer-filtering-qualifiers'.
2333NOSELECT means don't select the Ibuffer buffer.
2334SHRINK means shrink the buffer to minimal size. The special
2335 value `onewindow' means always use another window.
2336FILTER-GROUPS is an initial set of filtering groups to use;
2337 see `ibuffer-filter-groups'.
2338FORMATS is the value to use for `ibuffer-formats'.
2339 If specified, then the variable `ibuffer-formats' will have
2340 that value locally in this buffer."
25d2f683
CW
2341 (interactive "P")
2342 (when ibuffer-use-other-window
34b8f593 2343 (setq other-window-p t))
4ed1f829 2344 (setq ibuffer-prev-window-config (current-window-configuration))
34a4faa0 2345 (let ((buf (get-buffer-create (or name "*Ibuffer*"))))
25d2f683 2346 (if other-window-p
06b60517 2347 (funcall (if noselect (lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf)
25d2f683
CW
2348 (funcall (if noselect #'display-buffer #'switch-to-buffer) buf))
2349 (with-current-buffer buf
b5cd37ea
CW
2350 (save-selected-window
2351 ;; We switch to the buffer's window in order to be able
2352 ;; to modify the value of point
fab0d308 2353 (select-window (get-buffer-window buf 0))
34a4faa0
JPW
2354 (or (eq major-mode 'ibuffer-mode)
2355 (ibuffer-mode))
4ed1f829 2356 (setq ibuffer-restore-window-config-on-quit other-window-p)
b5cd37ea
CW
2357 (when shrink
2358 (setq ibuffer-shrink-to-minimum-size shrink))
2359 (when qualifiers
2360 (require 'ibuf-ext)
2361 (setq ibuffer-filtering-qualifiers qualifiers))
2362 (when filter-groups
2363 (require 'ibuf-ext)
cba63a2d 2364 (setq ibuffer-filter-groups filter-groups))
fd225d80
CW
2365 (when formats
2366 (set (make-local-variable 'ibuffer-formats) formats))
b5cd37ea
CW
2367 (ibuffer-update nil)
2368 ;; Skip the group name by default.
2369 (ibuffer-forward-line 0 t)
25d2f683
CW
2370 (unwind-protect
2371 (progn
b5cd37ea 2372 (setq buffer-read-only nil)
7ad5b902 2373 (run-hooks 'ibuffer-hook))
b5cd37ea
CW
2374 (setq buffer-read-only t))
2375 (unless ibuffer-expert
2376 (message "Commands: m, u, t, RET, g, k, S, D, Q; q to quit; h for help"))))))
25d2f683 2377
b23af469 2378(put 'ibuffer-mode 'mode-class 'special)
25d2f683
CW
2379(defun ibuffer-mode ()
2380 "A major mode for viewing a list of buffers.
972b8f82 2381In Ibuffer, you can conveniently perform many operations on the
25d2f683
CW
2382currently open buffers, in addition to filtering your view to a
2383particular subset of them, and sorting by various criteria.
2384
2385Operations on marked buffers:
8e66aebe 2386\\<ibuffer-mode-map>
25d2f683
CW
2387 '\\[ibuffer-do-save]' - Save the marked buffers
2388 '\\[ibuffer-do-view]' - View the marked buffers in this frame.
2389 '\\[ibuffer-do-view-other-frame]' - View the marked buffers in another frame.
2390 '\\[ibuffer-do-revert]' - Revert the marked buffers.
2391 '\\[ibuffer-do-toggle-read-only]' - Toggle read-only state of marked buffers.
2392 '\\[ibuffer-do-delete]' - Kill the marked buffers.
78176075
JL
2393 '\\[ibuffer-do-isearch]' - Do incremental search in the marked buffers.
2394 '\\[ibuffer-do-isearch-regexp]' - Isearch for regexp in the marked buffers.
25d2f683
CW
2395 '\\[ibuffer-do-replace-regexp]' - Replace by regexp in each of the marked
2396 buffers.
2397 '\\[ibuffer-do-query-replace]' - Query replace in each of the marked buffers.
2398 '\\[ibuffer-do-query-replace-regexp]' - As above, with a regular expression.
2399 '\\[ibuffer-do-print]' - Print the marked buffers.
2400 '\\[ibuffer-do-occur]' - List lines in all marked buffers which match
2401 a given regexp (like the function `occur').
2402 '\\[ibuffer-do-shell-command-pipe]' - Pipe the contents of the marked
2403 buffers to a shell command.
2404 '\\[ibuffer-do-shell-command-pipe-replace]' - Replace the contents of the marked
2405 buffers with the output of a shell command.
2406 '\\[ibuffer-do-shell-command-file]' - Run a shell command with the
2407 buffer's file as an argument.
2408 '\\[ibuffer-do-eval]' - Evaluate a form in each of the marked buffers. This
2409 is a very flexible command. For example, if you want to make all
2410 of the marked buffers read only, try using (toggle-read-only 1) as
2411 the input form.
2412 '\\[ibuffer-do-view-and-eval]' - As above, but view each buffer while the form
2413 is evaluated.
2414 '\\[ibuffer-do-kill-lines]' - Remove the marked lines from the *Ibuffer* buffer,
2415 but don't kill the associated buffer.
2416 '\\[ibuffer-do-kill-on-deletion-marks]' - Kill all buffers marked for deletion.
2417
2418Marking commands:
2419
2420 '\\[ibuffer-mark-forward]' - Mark the buffer at point.
2421 '\\[ibuffer-toggle-marks]' - Unmark all currently marked buffers, and mark
2422 all unmarked buffers.
2423 '\\[ibuffer-unmark-forward]' - Unmark the buffer at point.
2424 '\\[ibuffer-unmark-backward]' - Unmark the buffer at point, and move to the
2425 previous line.
2426 '\\[ibuffer-unmark-all]' - Unmark all marked buffers.
2427 '\\[ibuffer-mark-by-mode]' - Mark buffers by major mode.
2428 '\\[ibuffer-mark-unsaved-buffers]' - Mark all \"unsaved\" buffers.
2429 This means that the buffer is modified, and has an associated file.
2430 '\\[ibuffer-mark-modified-buffers]' - Mark all modified buffers,
2431 regardless of whether or not they have an associated file.
2432 '\\[ibuffer-mark-special-buffers]' - Mark all buffers whose name begins and
2433 ends with '*'.
2434 '\\[ibuffer-mark-dissociated-buffers]' - Mark all buffers which have
2435 an associated file, but that file doesn't currently exist.
2436 '\\[ibuffer-mark-read-only-buffers]' - Mark all read-only buffers.
2437 '\\[ibuffer-mark-dired-buffers]' - Mark buffers in `dired' mode.
2438 '\\[ibuffer-mark-help-buffers]' - Mark buffers in `help-mode', `apropos-mode', etc.
2439 '\\[ibuffer-mark-old-buffers]' - Mark buffers older than `ibuffer-old-time'.
2440 '\\[ibuffer-mark-for-delete]' - Mark the buffer at point for deletion.
2441 '\\[ibuffer-mark-by-name-regexp]' - Mark buffers by their name, using a regexp.
2442 '\\[ibuffer-mark-by-mode-regexp]' - Mark buffers by their major mode, using a regexp.
2443 '\\[ibuffer-mark-by-file-name-regexp]' - Mark buffers by their filename, using a regexp.
2444
2445Filtering commands:
2446
2447 '\\[ibuffer-filter-by-mode]' - Add a filter by major mode.
5bc06df9 2448 '\\[ibuffer-filter-by-used-mode]' - Add a filter by major mode now in use.
25d2f683
CW
2449 '\\[ibuffer-filter-by-name]' - Add a filter by buffer name.
2450 '\\[ibuffer-filter-by-content]' - Add a filter by buffer content.
2451 '\\[ibuffer-filter-by-filename]' - Add a filter by filename.
2452 '\\[ibuffer-filter-by-size-gt]' - Add a filter by buffer size.
2453 '\\[ibuffer-filter-by-size-lt]' - Add a filter by buffer size.
2454 '\\[ibuffer-filter-by-predicate]' - Add a filter by an arbitrary Lisp predicate.
2455 '\\[ibuffer-save-filters]' - Save the current filters with a name.
2456 '\\[ibuffer-switch-to-saved-filters]' - Switch to previously saved filters.
2457 '\\[ibuffer-add-saved-filters]' - Add saved filters to current filters.
2458 '\\[ibuffer-or-filter]' - Replace the top two filters with their logical OR.
2459 '\\[ibuffer-pop-filter]' - Remove the top filter.
2460 '\\[ibuffer-negate-filter]' - Invert the logical sense of the top filter.
2461 '\\[ibuffer-decompose-filter]' - Break down the topmost filter.
2462 '\\[ibuffer-filter-disable]' - Remove all filtering currently in effect.
cba63a2d
CW
2463
2464Filter group commands:
2465
2466 '\\[ibuffer-filters-to-filter-group]' - Create filter group from filters.
2467 '\\[ibuffer-pop-filter-group]' - Remove top filter group.
b098e753
CW
2468 '\\[ibuffer-forward-filter-group]' - Move to the next filter group.
2469 '\\[ibuffer-backward-filter-group]' - Move to the previous filter group.
2470 '\\[ibuffer-clear-filter-groups]' - Remove all active filter groups.
2471 '\\[ibuffer-save-filter-groups]' - Save the current groups with a name.
2472 '\\[ibuffer-switch-to-saved-filter-groups]' - Restore previously saved groups.
2473 '\\[ibuffer-delete-saved-filter-groups]' - Delete previously saved groups.
71296446 2474
25d2f683
CW
2475Sorting commands:
2476
2477 '\\[ibuffer-toggle-sorting-mode]' - Rotate between the various sorting modes.
2478 '\\[ibuffer-invert-sorting]' - Reverse the current sorting order.
2479 '\\[ibuffer-do-sort-by-alphabetic]' - Sort the buffers lexicographically.
d5794180 2480 '\\[ibuffer-do-sort-by-filename/process]' - Sort the buffers by the file name.
25d2f683
CW
2481 '\\[ibuffer-do-sort-by-recency]' - Sort the buffers by last viewing time.
2482 '\\[ibuffer-do-sort-by-size]' - Sort the buffers by size.
2483 '\\[ibuffer-do-sort-by-major-mode]' - Sort the buffers by major mode.
2484
2485Other commands:
2486
4c38df30
JPW
2487 '\\[ibuffer-update]' - Regenerate the list of all buffers.
2488 Prefix arg means to toggle whether buffers that match
2489 `ibuffer-maybe-show-predicates' should be displayed.
2490
25d2f683
CW
2491 '\\[ibuffer-switch-format]' - Change the current display format.
2492 '\\[forward-line]' - Move point to the next line.
2493 '\\[previous-line]' - Move point to the previous line.
25d2f683
CW
2494 '\\[ibuffer-quit]' - Bury the Ibuffer buffer.
2495 '\\[describe-mode]' - This help.
2496 '\\[ibuffer-diff-with-file]' - View the differences between this buffer
2497 and its associated file.
2498 '\\[ibuffer-visit-buffer]' - View the buffer on this line.
2499 '\\[ibuffer-visit-buffer-other-window]' - As above, but in another window.
2500 '\\[ibuffer-visit-buffer-other-window-noselect]' - As both above, but don't select
2501 the new window.
2502 '\\[ibuffer-bury-buffer]' - Bury (not kill!) the buffer on this line.
2503
cba63a2d 2504** Information on Filtering:
25d2f683 2505
da6062e6 2506 You can filter your ibuffer view via different criteria. Each Ibuffer
25d2f683
CW
2507buffer has its own stack of active filters. For example, suppose you
2508are working on an Emacs Lisp project. You can create an Ibuffer
2509buffer displays buffers in just `emacs-lisp' modes via
2510'\\[ibuffer-filter-by-mode] emacs-lisp-mode RET'. In this case, there
2511is just one entry on the filtering stack.
2512
2513You can also combine filters. The various filtering commands push a
2514new filter onto the stack, and the filters combine to show just
2515buffers which satisfy ALL criteria on the stack. For example, suppose
2516you only want to see buffers in `emacs-lisp' mode, whose names begin
2517with \"gnus\". You can accomplish this via:
2518'\\[ibuffer-filter-by-mode] emacs-lisp-mode RET
2519\\[ibuffer-filter-by-name] ^gnus RET'.
2520
2521Additionally, you can OR the top two filters together with
2522'\\[ibuffer-or-filters]'. To see all buffers in either
2523`emacs-lisp-mode' or `lisp-interaction-mode', type:
2524
2525'\\[ibuffer-filter-by-mode] emacs-lisp-mode RET \\[ibuffer-filter-by-mode] lisp-interaction-mode RET \\[ibuffer-or-filters]'.
2526
2527Filters can also be saved and restored using mnemonic names: see the
2528functions `ibuffer-save-filters' and `ibuffer-switch-to-saved-filters'.
2529
2530To remove the top filter on the stack, use '\\[ibuffer-pop-filter]', and
2531to disable all filtering currently in effect, use
cba63a2d
CW
2532'\\[ibuffer-filter-disable]'.
2533
2534** Filter Groups:
2535
2536Once one has mastered filters, the next logical step up is \"filter
2537groups\". A filter group is basically a named group of buffers which
2538match a filter, which are displayed together in an Ibuffer buffer. To
2539create a filter group, simply use the regular functions to create a
2540filter, and then type '\\[ibuffer-filters-to-filter-group]'.
2541
2542A quick example will make things clearer. Suppose that one wants to
2543group all of one's Emacs Lisp buffers together. To do this, type
2544
2545'\\[ibuffer-filter-by-mode] emacs-lisp-mode RET \\[ibuffer-filters-to-filter-group] RET emacs lisp buffers RET'
2546
2547You may, of course, name the group whatever you want; it doesn't have
2548to be \"emacs lisp buffers\". Filter groups may be composed of any
2549arbitrary combination of filters.
2550
2551Just like filters themselves, filter groups act as a stack. Buffers
2552will not be displayed multiple times if they would be included in
2553multiple filter groups; instead, the first filter group is used. The
2554filter groups are displayed in this order of precedence.
2555
2556You may rearrange filter groups by using the regular
2557'\\[ibuffer-kill-line]' and '\\[ibuffer-yank]' pair. Yanked groups
2558will be inserted before the group at point."
25d2f683
CW
2559 (kill-all-local-variables)
2560 (use-local-map ibuffer-mode-map)
2561 (setq major-mode 'ibuffer-mode)
2562 (setq mode-name "Ibuffer")
23eabff6 2563 ;; Include state info next to the mode name.
e47b4224 2564 (set (make-local-variable 'mode-line-process)
56618a0a
SM
2565 '(" by "
2566 (ibuffer-sorting-mode (:eval (symbol-name ibuffer-sorting-mode))
23eabff6
SM
2567 "view time")
2568 (ibuffer-sorting-reversep " [rev]")
2569 (ibuffer-auto-mode " (Auto)")
2570 ;; Only list the filters if they're not already in the header-line.
2571 (header-line-format
2572 ""
2573 (:eval (if (functionp 'ibuffer-format-qualifier)
2574 (mapconcat 'ibuffer-format-qualifier
2575 ibuffer-filtering-qualifiers ""))))))
6d11a78b
SM
2576 ;; `ibuffer-update' puts this on header-line-format when needed.
2577 (setq ibuffer-header-line-format
2578 ;; Display the part that won't be in the mode-line.
2579 (list* "" mode-name
2580 (mapcar (lambda (elem)
2581 (if (eq (car-safe elem) 'header-line-format)
2582 (nth 2 elem) elem))
2583 mode-line-process)))
23eabff6 2584
25d2f683
CW
2585 (setq buffer-read-only t)
2586 (buffer-disable-undo)
3eda3649 2587 (setq truncate-lines ibuffer-truncate-lines)
25d2f683
CW
2588 ;; This makes things less ugly for Emacs 21 users with a non-nil
2589 ;; `show-trailing-whitespace'.
2590 (setq show-trailing-whitespace nil)
4ba16127
JPW
2591 ;; disable `show-paren-mode' buffer-locally
2592 (if (bound-and-true-p show-paren-mode)
2593 (set (make-local-variable 'show-paren-mode) nil))
25d2f683
CW
2594 (set (make-local-variable 'revert-buffer-function)
2595 #'ibuffer-update)
2596 (set (make-local-variable 'ibuffer-sorting-mode)
2597 ibuffer-default-sorting-mode)
2598 (set (make-local-variable 'ibuffer-sorting-reversep)
2599 ibuffer-default-sorting-reversep)
2600 (set (make-local-variable 'ibuffer-shrink-to-minimum-size)
2601 ibuffer-default-shrink-to-minimum-size)
957237cb
JPW
2602 (set (make-local-variable 'ibuffer-display-maybe-show-predicates)
2603 ibuffer-default-display-maybe-show-predicates)
25d2f683 2604 (set (make-local-variable 'ibuffer-filtering-qualifiers) nil)
cba63a2d
CW
2605 (set (make-local-variable 'ibuffer-filter-groups) nil)
2606 (set (make-local-variable 'ibuffer-filter-group-kill-ring) nil)
2607 (set (make-local-variable 'ibuffer-hidden-filter-groups) nil)
25d2f683
CW
2608 (set (make-local-variable 'ibuffer-compiled-formats) nil)
2609 (set (make-local-variable 'ibuffer-cached-formats) nil)
2610 (set (make-local-variable 'ibuffer-cached-eliding-string) nil)
2611 (set (make-local-variable 'ibuffer-cached-elide-long-columns) nil)
2612 (set (make-local-variable 'ibuffer-current-format) nil)
4ed1f829 2613 (set (make-local-variable 'ibuffer-restore-window-config-on-quit) nil)
25d2f683 2614 (set (make-local-variable 'ibuffer-did-modification) nil)
b5cd37ea
CW
2615 (set (make-local-variable 'ibuffer-tmp-hide-regexps) nil)
2616 (set (make-local-variable 'ibuffer-tmp-show-regexps) nil)
25d2f683
CW
2617 (define-key ibuffer-mode-map [menu-bar edit] 'undefined)
2618 (define-key ibuffer-mode-map [menu-bar operate] (cons "Operate" ibuffer-mode-operate-map))
2619 (ibuffer-update-format)
2620 (when ibuffer-default-directory
2621 (setq default-directory ibuffer-default-directory))
214fee7a 2622 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
23eabff6 2623 (run-mode-hooks 'ibuffer-mode-hook))
25d2f683 2624
45a68029
GM
2625\f
2626;;; Start of automatically extracted autoloads.
2627\f
2628;;;### (autoloads (ibuffer-do-occur ibuffer-mark-dired-buffers ibuffer-mark-read-only-buffers
2629;;;;;; ibuffer-mark-special-buffers ibuffer-mark-old-buffers ibuffer-mark-compressed-file-buffers
2630;;;;;; ibuffer-mark-help-buffers ibuffer-mark-dissociated-buffers
2631;;;;;; ibuffer-mark-unsaved-buffers ibuffer-mark-modified-buffers
2632;;;;;; ibuffer-mark-by-mode ibuffer-mark-by-file-name-regexp ibuffer-mark-by-mode-regexp
2633;;;;;; ibuffer-mark-by-name-regexp ibuffer-copy-filename-as-kill
2634;;;;;; ibuffer-diff-with-file ibuffer-jump-to-buffer ibuffer-do-kill-lines
2635;;;;;; ibuffer-backwards-next-marked ibuffer-forward-next-marked
2636;;;;;; ibuffer-add-to-tmp-show ibuffer-add-to-tmp-hide ibuffer-bs-show
2637;;;;;; ibuffer-invert-sorting ibuffer-toggle-sorting-mode ibuffer-switch-to-saved-filters
2638;;;;;; ibuffer-add-saved-filters ibuffer-delete-saved-filters ibuffer-save-filters
2639;;;;;; ibuffer-or-filter ibuffer-negate-filter ibuffer-exchange-filters
2640;;;;;; ibuffer-decompose-filter ibuffer-pop-filter ibuffer-filter-disable
2641;;;;;; ibuffer-switch-to-saved-filter-groups ibuffer-delete-saved-filter-groups
2642;;;;;; ibuffer-save-filter-groups ibuffer-yank-filter-group ibuffer-yank
2643;;;;;; ibuffer-kill-line ibuffer-kill-filter-group ibuffer-jump-to-filter-group
2644;;;;;; ibuffer-clear-filter-groups ibuffer-decompose-filter-group
2645;;;;;; ibuffer-pop-filter-group ibuffer-set-filter-groups-by-mode
2646;;;;;; ibuffer-filters-to-filter-group ibuffer-included-in-filters-p
2647;;;;;; ibuffer-backward-filter-group ibuffer-forward-filter-group
2648;;;;;; ibuffer-toggle-filter-group ibuffer-mouse-toggle-filter-group
2649;;;;;; ibuffer-interactive-filter-by-mode ibuffer-mouse-filter-by-mode
cf3304e1 2650;;;;;; ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" "1400db1bc3d4a3010cbc4807a6725072")
45a68029
GM
2651;;; Generated autoloads from ibuf-ext.el
2652
2653(autoload 'ibuffer-auto-mode "ibuf-ext" "\
06e21633
CY
2654Toggle use of Ibuffer's auto-update facility (Ibuffer Auto mode).
2655With a prefix argument ARG, enable Ibuffer Auto mode if ARG is
2656positive, and disable it otherwise. If called from Lisp, enable
2657the mode if ARG is omitted or nil.
45a68029
GM
2658
2659\(fn &optional ARG)" t nil)
2660
2661(autoload 'ibuffer-mouse-filter-by-mode "ibuf-ext" "\
2662Enable or disable filtering by the major mode chosen via mouse.
2663
2664\(fn EVENT)" t nil)
2665
2666(autoload 'ibuffer-interactive-filter-by-mode "ibuf-ext" "\
2667Enable or disable filtering by the major mode at point.
2668
2669\(fn EVENT-OR-POINT)" t nil)
2670
2671(autoload 'ibuffer-mouse-toggle-filter-group "ibuf-ext" "\
2672Toggle the display status of the filter group chosen with the mouse.
2673
2674\(fn EVENT)" t nil)
2675
2676(autoload 'ibuffer-toggle-filter-group "ibuf-ext" "\
2677Toggle the display status of the filter group on this line.
2678
2679\(fn)" t nil)
2680
2681(autoload 'ibuffer-forward-filter-group "ibuf-ext" "\
2682Move point forwards by COUNT filtering groups.
2683
2684\(fn &optional COUNT)" t nil)
2685
2686(autoload 'ibuffer-backward-filter-group "ibuf-ext" "\
2687Move point backwards by COUNT filtering groups.
2688
2689\(fn &optional COUNT)" t nil)
2690 (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext")
2691 (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext")
2692 (autoload 'ibuffer-do-shell-command-file "ibuf-ext")
2693 (autoload 'ibuffer-do-eval "ibuf-ext")
2694 (autoload 'ibuffer-do-view-and-eval "ibuf-ext")
2695 (autoload 'ibuffer-do-rename-uniquely "ibuf-ext")
2696 (autoload 'ibuffer-do-revert "ibuf-ext")
2697 (autoload 'ibuffer-do-isearch "ibuf-ext")
2698 (autoload 'ibuffer-do-isearch-regexp "ibuf-ext")
2699 (autoload 'ibuffer-do-replace-regexp "ibuf-ext")
2700 (autoload 'ibuffer-do-query-replace "ibuf-ext")
2701 (autoload 'ibuffer-do-query-replace-regexp "ibuf-ext")
2702 (autoload 'ibuffer-do-print "ibuf-ext")
2703
2704(autoload 'ibuffer-included-in-filters-p "ibuf-ext" "\
06b60517 2705
45a68029
GM
2706
2707\(fn BUF FILTERS)" nil nil)
2708
2709(autoload 'ibuffer-filters-to-filter-group "ibuf-ext" "\
2710Make the current filters into a filtering group.
2711
2712\(fn NAME)" t nil)
2713
2714(autoload 'ibuffer-set-filter-groups-by-mode "ibuf-ext" "\
2715Set the current filter groups to filter by mode.
2716
2717\(fn)" t nil)
2718
2719(autoload 'ibuffer-pop-filter-group "ibuf-ext" "\
2720Remove the first filter group.
2721
2722\(fn)" t nil)
2723
2724(autoload 'ibuffer-decompose-filter-group "ibuf-ext" "\
2725Decompose the filter group GROUP into active filters.
2726
2727\(fn GROUP)" t nil)
2728
2729(autoload 'ibuffer-clear-filter-groups "ibuf-ext" "\
2730Remove all filter groups.
2731
2732\(fn)" t nil)
2733
2734(autoload 'ibuffer-jump-to-filter-group "ibuf-ext" "\
2735Move point to the filter group whose name is NAME.
2736
2737\(fn NAME)" t nil)
2738
2739(autoload 'ibuffer-kill-filter-group "ibuf-ext" "\
2740Kill the filter group named NAME.
2741The group will be added to `ibuffer-filter-group-kill-ring'.
2742
2743\(fn NAME)" t nil)
2744
2745(autoload 'ibuffer-kill-line "ibuf-ext" "\
2746Kill the filter group at point.
2747See also `ibuffer-kill-filter-group'.
2748
2749\(fn &optional ARG INTERACTIVE-P)" t nil)
2750
2751(autoload 'ibuffer-yank "ibuf-ext" "\
2752Yank the last killed filter group before group at point.
2753
2754\(fn)" t nil)
2755
2756(autoload 'ibuffer-yank-filter-group "ibuf-ext" "\
2757Yank the last killed filter group before group named NAME.
2758
2759\(fn NAME)" t nil)
2760
2761(autoload 'ibuffer-save-filter-groups "ibuf-ext" "\
2762Save all active filter groups GROUPS as NAME.
2763They are added to `ibuffer-saved-filter-groups'. Interactively,
2764prompt for NAME, and use the current filters.
2765
2766\(fn NAME GROUPS)" t nil)
2767
2768(autoload 'ibuffer-delete-saved-filter-groups "ibuf-ext" "\
2769Delete saved filter groups with NAME.
2770They are removed from `ibuffer-saved-filter-groups'.
2771
2772\(fn NAME)" t nil)
2773
2774(autoload 'ibuffer-switch-to-saved-filter-groups "ibuf-ext" "\
2775Set this buffer's filter groups to saved version with NAME.
2776The value from `ibuffer-saved-filter-groups' is used.
2777
2778\(fn NAME)" t nil)
2779
2780(autoload 'ibuffer-filter-disable "ibuf-ext" "\
2781Disable all filters currently in effect in this buffer.
85949b6c
GM
2782With optional arg DELETE-FILTER-GROUPS non-nil, delete all filter
2783group definitions by setting `ibuffer-filter-groups' to nil.
45a68029 2784
85949b6c 2785\(fn &optional DELETE-FILTER-GROUPS)" t nil)
45a68029
GM
2786
2787(autoload 'ibuffer-pop-filter "ibuf-ext" "\
2788Remove the top filter in this buffer.
2789
2790\(fn)" t nil)
2791
2792(autoload 'ibuffer-decompose-filter "ibuf-ext" "\
2793Separate the top compound filter (OR, NOT, or SAVED) in this buffer.
2794
2795This means that the topmost filter on the filtering stack, which must
2796be a complex filter like (OR [name: foo] [mode: bar-mode]), will be
2797turned into two separate filters [name: foo] and [mode: bar-mode].
2798
2799\(fn)" t nil)
2800
2801(autoload 'ibuffer-exchange-filters "ibuf-ext" "\
2802Exchange the top two filters on the stack in this buffer.
2803
2804\(fn)" t nil)
2805
2806(autoload 'ibuffer-negate-filter "ibuf-ext" "\
2807Negate the sense of the top filter in the current buffer.
2808
2809\(fn)" t nil)
2810
2811(autoload 'ibuffer-or-filter "ibuf-ext" "\
2812Replace the top two filters in this buffer with their logical OR.
2813If optional argument REVERSE is non-nil, instead break the top OR
2814filter into parts.
2815
2816\(fn &optional REVERSE)" t nil)
2817
2818(autoload 'ibuffer-save-filters "ibuf-ext" "\
2819Save FILTERS in this buffer with name NAME in `ibuffer-saved-filters'.
2820Interactively, prompt for NAME, and use the current filters.
2821
2822\(fn NAME FILTERS)" t nil)
2823
2824(autoload 'ibuffer-delete-saved-filters "ibuf-ext" "\
2825Delete saved filters with NAME from `ibuffer-saved-filters'.
2826
2827\(fn NAME)" t nil)
2828
2829(autoload 'ibuffer-add-saved-filters "ibuf-ext" "\
2830Add saved filters from `ibuffer-saved-filters' to this buffer's filters.
2831
2832\(fn NAME)" t nil)
2833
2834(autoload 'ibuffer-switch-to-saved-filters "ibuf-ext" "\
2835Set this buffer's filters to filters with NAME from `ibuffer-saved-filters'.
2836
2837\(fn NAME)" t nil)
2838 (autoload 'ibuffer-filter-by-mode "ibuf-ext")
2839 (autoload 'ibuffer-filter-by-used-mode "ibuf-ext")
2840 (autoload 'ibuffer-filter-by-name "ibuf-ext")
2841 (autoload 'ibuffer-filter-by-filename "ibuf-ext")
2842 (autoload 'ibuffer-filter-by-size-gt "ibuf-ext")
2843 (autoload 'ibuffer-filter-by-size-lt "ibuf-ext")
2844 (autoload 'ibuffer-filter-by-content "ibuf-ext")
2845 (autoload 'ibuffer-filter-by-predicate "ibuf-ext")
2846
2847(autoload 'ibuffer-toggle-sorting-mode "ibuf-ext" "\
2848Toggle the current sorting mode.
2849Default sorting modes are:
2850 Recency - the last time the buffer was viewed
2851 Name - the name of the buffer
2852 Major Mode - the name of the major mode of the buffer
2853 Size - the size of the buffer
2854
2855\(fn)" t nil)
2856
2857(autoload 'ibuffer-invert-sorting "ibuf-ext" "\
2858Toggle whether or not sorting is in reverse order.
2859
2860\(fn)" t nil)
2861 (autoload 'ibuffer-do-sort-by-major-mode "ibuf-ext")
2862 (autoload 'ibuffer-do-sort-by-mode-name "ibuf-ext")
2863 (autoload 'ibuffer-do-sort-by-alphabetic "ibuf-ext")
2864 (autoload 'ibuffer-do-sort-by-size "ibuf-ext")
2865 (autoload 'ibuffer-do-sort-by-filename/process "ibuf-ext")
2866
2867(autoload 'ibuffer-bs-show "ibuf-ext" "\
2868Emulate `bs-show' from the bs.el package.
2869
2870\(fn)" t nil)
2871
2872(autoload 'ibuffer-add-to-tmp-hide "ibuf-ext" "\
2873Add REGEXP to `ibuffer-tmp-hide-regexps'.
2874This means that buffers whose name matches REGEXP will not be shown
2875for this Ibuffer session.
2876
2877\(fn REGEXP)" t nil)
2878
2879(autoload 'ibuffer-add-to-tmp-show "ibuf-ext" "\
2880Add REGEXP to `ibuffer-tmp-show-regexps'.
2881This means that buffers whose name matches REGEXP will always be shown
2882for this Ibuffer session.
2883
2884\(fn REGEXP)" t nil)
2885
2886(autoload 'ibuffer-forward-next-marked "ibuf-ext" "\
2887Move forward by COUNT marked buffers (default 1).
2888
2889If MARK is non-nil, it should be a character denoting the type of mark
2890to move by. The default is `ibuffer-marked-char'.
2891
2892If DIRECTION is non-nil, it should be an integer; negative integers
2893mean move backwards, non-negative integers mean move forwards.
2894
2895\(fn &optional COUNT MARK DIRECTION)" t nil)
2896
2897(autoload 'ibuffer-backwards-next-marked "ibuf-ext" "\
2898Move backwards by COUNT marked buffers (default 1).
2899
2900If MARK is non-nil, it should be a character denoting the type of mark
2901to move by. The default is `ibuffer-marked-char'.
2902
2903\(fn &optional COUNT MARK)" t nil)
2904
2905(autoload 'ibuffer-do-kill-lines "ibuf-ext" "\
2906Hide all of the currently marked lines.
2907
2908\(fn)" t nil)
2909
2910(autoload 'ibuffer-jump-to-buffer "ibuf-ext" "\
2911Move point to the buffer whose name is NAME.
2912
2913If called interactively, prompt for a buffer name and go to the
2914corresponding line in the Ibuffer buffer. If said buffer is in a
2915hidden group filter, open it.
2916
2917If `ibuffer-jump-offer-only-visible-buffers' is non-nil, only offer
2918visible buffers in the completion list. Calling the command with
2919a prefix argument reverses the meaning of that variable.
2920
2921\(fn NAME)" t nil)
2922
2923(autoload 'ibuffer-diff-with-file "ibuf-ext" "\
2924View the differences between marked buffers and their associated files.
2925If no buffers are marked, use buffer at point.
2926This requires the external program \"diff\" to be in your `exec-path'.
2927
2928\(fn)" t nil)
2929
2930(autoload 'ibuffer-copy-filename-as-kill "ibuf-ext" "\
2931Copy filenames of marked buffers into the kill ring.
2932
2933The names are separated by a space.
2934If a buffer has no filename, it is ignored.
2935
2936With no prefix arg, use the filename sans its directory of each marked file.
2937With a zero prefix arg, use the complete filename of each marked file.
2938With \\[universal-argument], use the filename of each marked file relative
2939to `ibuffer-default-directory' if non-nil, otherwise `default-directory'.
2940
2941You can then feed the file name(s) to other commands with \\[yank].
2942
2943\(fn &optional ARG)" t nil)
2944
2945(autoload 'ibuffer-mark-by-name-regexp "ibuf-ext" "\
2946Mark all buffers whose name matches REGEXP.
2947
2948\(fn REGEXP)" t nil)
2949
2950(autoload 'ibuffer-mark-by-mode-regexp "ibuf-ext" "\
2951Mark all buffers whose major mode matches REGEXP.
2952
2953\(fn REGEXP)" t nil)
2954
2955(autoload 'ibuffer-mark-by-file-name-regexp "ibuf-ext" "\
2956Mark all buffers whose file name matches REGEXP.
2957
2958\(fn REGEXP)" t nil)
2959
2960(autoload 'ibuffer-mark-by-mode "ibuf-ext" "\
2961Mark all buffers whose major mode equals MODE.
2962
2963\(fn MODE)" t nil)
2964
2965(autoload 'ibuffer-mark-modified-buffers "ibuf-ext" "\
2966Mark all modified buffers.
2967
2968\(fn)" t nil)
2969
2970(autoload 'ibuffer-mark-unsaved-buffers "ibuf-ext" "\
2971Mark all modified buffers that have an associated file.
2972
2973\(fn)" t nil)
2974
2975(autoload 'ibuffer-mark-dissociated-buffers "ibuf-ext" "\
2976Mark all buffers whose associated file does not exist.
2977
2978\(fn)" t nil)
2979
2980(autoload 'ibuffer-mark-help-buffers "ibuf-ext" "\
2981Mark buffers like *Help*, *Apropos*, *Info*.
2982
2983\(fn)" t nil)
2984
2985(autoload 'ibuffer-mark-compressed-file-buffers "ibuf-ext" "\
2986Mark buffers whose associated file is compressed.
2987
2988\(fn)" t nil)
2989
2990(autoload 'ibuffer-mark-old-buffers "ibuf-ext" "\
2991Mark buffers which have not been viewed in `ibuffer-old-time' hours.
2992
2993\(fn)" t nil)
2994
2995(autoload 'ibuffer-mark-special-buffers "ibuf-ext" "\
2996Mark all buffers whose name begins and ends with '*'.
2997
2998\(fn)" t nil)
2999
3000(autoload 'ibuffer-mark-read-only-buffers "ibuf-ext" "\
3001Mark all read-only buffers.
3002
3003\(fn)" t nil)
3004
3005(autoload 'ibuffer-mark-dired-buffers "ibuf-ext" "\
3006Mark all `dired' buffers.
3007
3008\(fn)" t nil)
3009
3010(autoload 'ibuffer-do-occur "ibuf-ext" "\
3011View lines which match REGEXP in all marked buffers.
3012Optional argument NLINES says how many lines of context to display: it
3013defaults to one.
3014
3015\(fn REGEXP &optional NLINES)" t nil)
3016
3017;;;***
3018\f
3019;;; End of automatically extracted autoloads.
3020
3021
25d2f683
CW
3022(provide 'ibuffer)
3023
4e4a724c
JPW
3024(run-hooks 'ibuffer-load-hook)
3025
25d2f683
CW
3026;; Local Variables:
3027;; coding: iso-8859-1
3028;; End:
3029
3030;;; ibuffer.el ends here