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