diff options
| -rw-r--r-- | lisp/ibuf-macs.el | 22 |
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 | ||
| 77 | BODY will be called with `buffer' bound to the buffer object, and | 78 | BODY will be called with `buffer' bound to the buffer object, and |
| @@ -81,7 +82,9 @@ will be `buffer'. | |||
| 81 | If NAME is given, it will be used as a title for the column. | 82 | If NAME is given, it will be used as a title for the column. |
| 82 | Otherwise, the title will default to a capitalized version of the | 83 | Otherwise, the title will default to a capitalized version of the |
| 83 | SYMBOL's name. PROPS is a plist of additional properties to add to | 84 | SYMBOL's name. PROPS is a plist of additional properties to add to |
| 84 | the text, such as `mouse-face'. | 85 | the text, such as `mouse-face'. And SUMMARIZER, if given, is a |
| 86 | function which will be passed a list of all the strings in its column; | ||
| 87 | it should return a string to display at the bottom. | ||
| 85 | 88 | ||
| 86 | Note that this macro expands into a `defun' for a function named | 89 | Note that this macro expands into a `defun' for a function named |
| 87 | ibuffer-make-column-NAME. If INLINE is non-nil, then the form will be | 90 | ibuffer-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 | ||