ibuffer.el 111 KB

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