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