71 |
;; (put 'ibuffer-save-marks 'lisp-indent-function 0) |
;; (put 'ibuffer-save-marks 'lisp-indent-function 0) |
72 |
|
|
73 |
;;;###autoload |
;;;###autoload |
74 |
(defmacro* define-ibuffer-column (symbol (&key name inline props) &rest body) |
(defmacro* define-ibuffer-column (symbol (&key name inline props |
75 |
|
summarizer) &rest body) |
76 |
"Define a column SYMBOL for use with `ibuffer-formats'. |
"Define a column SYMBOL for use with `ibuffer-formats'. |
77 |
|
|
78 |
BODY will be called with `buffer' bound to the buffer object, and |
BODY will be called with `buffer' bound to the buffer object, and |
82 |
If NAME is given, it will be used as a title for the column. |
If NAME is given, it will be used as a title for the column. |
83 |
Otherwise, the title will default to a capitalized version of the |
Otherwise, the title will default to a capitalized version of the |
84 |
SYMBOL's name. PROPS is a plist of additional properties to add to |
SYMBOL's name. PROPS is a plist of additional properties to add to |
85 |
the text, such as `mouse-face'. |
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. |
88 |
|
|
89 |
Note that this macro expands into a `defun' for a function named |
Note that this macro expands into a `defun' for a function named |
90 |
ibuffer-make-column-NAME. If INLINE is non-nil, then the form will be |
ibuffer-make-column-NAME. If INLINE is non-nil, then the form will be |
93 |
`ibuffer-recompile-formats'." |
`ibuffer-recompile-formats'." |
94 |
(let* ((sym (intern (concat "ibuffer-make-column-" |
(let* ((sym (intern (concat "ibuffer-make-column-" |
95 |
(symbol-name symbol)))) |
(symbol-name symbol)))) |
96 |
(bod-1 `(with-current-buffer buffer |
(bod-2 `(with-current-buffer buffer |
97 |
,@body)) |
,@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)) |
104 |
(bod (if props |
(bod (if props |
105 |
`(propertize |
`(propertize |
106 |
,bod-1 |
,bod-1 |
115 |
,(if (stringp name) |
,(if (stringp name) |
116 |
name |
name |
117 |
(capitalize (symbol-name symbol)))) |
(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)) |
125 |
:autoload-end))) |
:autoload-end))) |
126 |
;; (put 'define-ibuffer-column 'lisp-indent-function 'defun) |
;; (put 'define-ibuffer-column 'lisp-indent-function 'defun) |
127 |
|
|