aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ibuf-macs.el22
1 files changed, 19 insertions, 3 deletions
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 3e026de2a08..6ef83594e0c 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -71,7 +71,8 @@ During evaluation of body, bind `it' to the value returned by TEST."
71;; (put 'ibuffer-save-marks 'lisp-indent-function 0) 71;; (put 'ibuffer-save-marks 'lisp-indent-function 0)
72 72
73;;;###autoload 73;;;###autoload
74(defmacro* define-ibuffer-column (symbol (&key name inline props) &rest body) 74(defmacro* define-ibuffer-column (symbol (&key name inline props
75 summarizer) &rest body)
75 "Define a column SYMBOL for use with `ibuffer-formats'. 76 "Define a column SYMBOL for use with `ibuffer-formats'.
76 77
77BODY will be called with `buffer' bound to the buffer object, and 78BODY will be called with `buffer' bound to the buffer object, and
@@ -81,7 +82,9 @@ will be `buffer'.
81If NAME is given, it will be used as a title for the column. 82If NAME is given, it will be used as a title for the column.
82Otherwise, the title will default to a capitalized version of the 83Otherwise, the title will default to a capitalized version of the
83SYMBOL's name. PROPS is a plist of additional properties to add to 84SYMBOL's name. PROPS is a plist of additional properties to add to
84the text, such as `mouse-face'. 85the text, such as `mouse-face'. And SUMMARIZER, if given, is a
86function which will be passed a list of all the strings in its column;
87it should return a string to display at the bottom.
85 88
86Note that this macro expands into a `defun' for a function named 89Note that this macro expands into a `defun' for a function named
87ibuffer-make-column-NAME. If INLINE is non-nil, then the form will be 90ibuffer-make-column-NAME. If INLINE is non-nil, then the form will be
@@ -90,8 +93,14 @@ change its definition, you should explicitly call
90`ibuffer-recompile-formats'." 93`ibuffer-recompile-formats'."
91 (let* ((sym (intern (concat "ibuffer-make-column-" 94 (let* ((sym (intern (concat "ibuffer-make-column-"
92 (symbol-name symbol)))) 95 (symbol-name symbol))))
93 (bod-1 `(with-current-buffer buffer 96 (bod-2 `(with-current-buffer buffer
94 ,@body)) 97 ,@body))
98 (bod-1 (if summarizer
99 `(car
100 (push ,bod-2
101 ,(intern (format "ibuffer-summary-for-column-%s"
102 name))))
103 bod-2))
95 (bod (if props 104 (bod (if props
96 `(propertize 105 `(propertize
97 ,bod-1 106 ,bod-1
@@ -106,6 +115,13 @@ change its definition, you should explicitly call
106 ,(if (stringp name) 115 ,(if (stringp name)
107 name 116 name
108 (capitalize (symbol-name symbol)))) 117 (capitalize (symbol-name symbol))))
118 ,(if summarizer
119 `(put (quote ,sym) 'ibuffer-column-summarizer
120 (quote ,summarizer)))
121 ,(if summarizer
122 `(defvar ,(intern (format "ibuffer-summary-for-column-%s"
123 name))
124 nil))
109 :autoload-end))) 125 :autoload-end)))
110;; (put 'define-ibuffer-column 'lisp-indent-function 'defun) 126;; (put 'define-ibuffer-column 'lisp-indent-function 'defun)
111 127