diff options
| author | shipmints | 2025-02-24 17:45:54 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2025-02-26 09:10:27 -0500 |
| commit | 5d75c6e44da9f27d28ff60d5dee308f2247a1cf5 (patch) | |
| tree | 040a0eb76e99733d032fbf9b73c53fbf5eb6a15b | |
| parent | 7ae069b676a19d9a477d629403e2ff236a5303af (diff) | |
| download | emacs-5d75c6e44da9f27d28ff60d5dee308f2247a1cf5.tar.gz emacs-5d75c6e44da9f27d28ff60d5dee308f2247a1cf5.zip | |
Improve 'define-ibuffer-op' macro (bug#76222)
* lisp/ibuf-macs.el (define-ibuffer-op):
Change defun to defalias and place it before the macro-local lets.
* lisp/ibuffer.el:
(ibuffer-do-toggle-lock): Remove declare-function.
(ibuffer-do-toggle-read-only): Remove declare-function.
(ibuffer-do-save): Remove declare-function.
(ibuffer-do-delete): Remove declare-function.
(ibuffer-do-toggle-modified): Remove declare-function.
(ibuffer-do-kill-on-deletion-marks): Remove declare-function.
| -rw-r--r-- | lisp/ibuf-macs.el | 102 | ||||
| -rw-r--r-- | lisp/ibuffer.el | 9 |
2 files changed, 51 insertions, 60 deletions
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 4a283420efd..4595d24da11 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el | |||
| @@ -218,12 +218,10 @@ buffer object. | |||
| 218 | (let ((opstring-sym (make-symbol "opstring")) | 218 | (let ((opstring-sym (make-symbol "opstring")) |
| 219 | (active-opstring-sym (make-symbol "active-opstring"))) | 219 | (active-opstring-sym (make-symbol "active-opstring"))) |
| 220 | `(progn | 220 | `(progn |
| 221 | (let ((,opstring-sym ,opstring) | 221 | (defalias ',(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) |
| 222 | (,active-opstring-sym ,active-opstring)) | 222 | "" "ibuffer-do-") |
| 223 | (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) | 223 | (symbol-name op))) |
| 224 | "" "ibuffer-do-") | 224 | (lambda ,args |
| 225 | (symbol-name op))) | ||
| 226 | ,args | ||
| 227 | ,(if (stringp documentation) | 225 | ,(if (stringp documentation) |
| 228 | documentation | 226 | documentation |
| 229 | (format "%s marked buffers." (if (functionp active-opstring) | 227 | (format "%s marked buffers." (if (functionp active-opstring) |
| @@ -234,45 +232,47 @@ buffer object. | |||
| 234 | '(interactive)) | 232 | '(interactive)) |
| 235 | (cl-assert (derived-mode-p 'ibuffer-mode)) | 233 | (cl-assert (derived-mode-p 'ibuffer-mode)) |
| 236 | (setq ibuffer-did-modification nil) | 234 | (setq ibuffer-did-modification nil) |
| 237 | (let ((marked-names (,(pcase mark | 235 | (let ((,opstring-sym ,opstring) |
| 238 | (:deletion | 236 | (,active-opstring-sym ,active-opstring)) |
| 239 | 'ibuffer-deletion-marked-buffer-names) | 237 | (let ((marked-names (,(pcase mark |
| 240 | (_ | 238 | (:deletion |
| 241 | 'ibuffer-marked-buffer-names))))) | 239 | 'ibuffer-deletion-marked-buffer-names) |
| 242 | (when (null marked-names) | 240 | (_ |
| 243 | (cl-assert (get-text-property (line-beginning-position) | 241 | 'ibuffer-marked-buffer-names))))) |
| 244 | 'ibuffer-properties) | 242 | (when (null marked-names) |
| 245 | nil "No buffer on this line") | 243 | (cl-assert (get-text-property (line-beginning-position) |
| 246 | (setq marked-names (list (buffer-name (ibuffer-current-buffer)))) | 244 | 'ibuffer-properties) |
| 247 | (ibuffer-set-mark ,(pcase mark | 245 | nil "No buffer on this line") |
| 248 | (:deletion | 246 | (setq marked-names (list (buffer-name (ibuffer-current-buffer)))) |
| 249 | 'ibuffer-deletion-char) | 247 | (ibuffer-set-mark ,(pcase mark |
| 250 | (_ | 248 | (:deletion |
| 251 | 'ibuffer-marked-char)))) | 249 | 'ibuffer-deletion-char) |
| 252 | ,(let* ((finish (append | 250 | (_ |
| 253 | '(progn) | 251 | 'ibuffer-marked-char)))) |
| 254 | (if (eq modifier-p t) | 252 | ,(let* ((finish (append |
| 255 | '((setq ibuffer-did-modification t)) | 253 | '(progn) |
| 256 | ()) | 254 | (if (eq modifier-p t) |
| 257 | (and after `(,after)) ; post-operation form. | 255 | '((setq ibuffer-did-modification t)) |
| 258 | `((ibuffer-redisplay t) | 256 | ()) |
| 259 | (message (concat "Operation finished; " | 257 | (and after `(,after)) ; post-operation form. |
| 260 | (if (functionp ,opstring-sym) | 258 | `((ibuffer-redisplay t) |
| 261 | (funcall ,opstring-sym) | 259 | (message (concat "Operation finished; " |
| 262 | ,opstring-sym) | 260 | (if (functionp ,opstring-sym) |
| 263 | " %s %s") | 261 | (funcall ,opstring-sym) |
| 264 | count (ngettext "buffer" "buffers" | 262 | ,opstring-sym) |
| 265 | count))))) | 263 | " %s %s") |
| 266 | (inner-body (if complex | 264 | count (ngettext "buffer" "buffers" |
| 267 | `(progn ,@body) | 265 | count))))) |
| 268 | `(progn | 266 | (inner-body (if complex |
| 267 | `(progn ,@body) | ||
| 268 | `(progn | ||
| 269 | (with-current-buffer buf | 269 | (with-current-buffer buf |
| 270 | (save-excursion | 270 | (save-excursion |
| 271 | ,@body)) | 271 | ,@body)) |
| 272 | t))) | 272 | t))) |
| 273 | (body `(let ((_ ,before) ; pre-operation form. | 273 | (body `(let ((_ ,before) ; pre-operation form. |
| 274 | (count | 274 | (count |
| 275 | (,(pcase mark | 275 | (,(pcase mark |
| 276 | (:deletion | 276 | (:deletion |
| 277 | 'ibuffer-map-deletion-lines) | 277 | 'ibuffer-map-deletion-lines) |
| 278 | (_ | 278 | (_ |
| @@ -290,16 +290,16 @@ buffer object. | |||
| 290 | (setq | 290 | (setq |
| 291 | ibuffer-did-modification t)))) | 291 | ibuffer-did-modification t)))) |
| 292 | inner-body))))) | 292 | inner-body))))) |
| 293 | ,finish))) | 293 | ,finish))) |
| 294 | (if dangerous | 294 | (if dangerous |
| 295 | `(when (ibuffer-confirm-operation-on | 295 | `(when (ibuffer-confirm-operation-on |
| 296 | (if (functionp ,active-opstring-sym) | 296 | (if (functionp ,active-opstring-sym) |
| 297 | (funcall ,active-opstring-sym) | 297 | (funcall ,active-opstring-sym) |
| 298 | ,active-opstring-sym) | 298 | ,active-opstring-sym) |
| 299 | marked-names) | 299 | marked-names) |
| 300 | ,body) | 300 | ,body) |
| 301 | body)))) | 301 | body)))) |
| 302 | :autoload-end)))) | 302 | :autoload-end))))) |
| 303 | 303 | ||
| 304 | ;;;###autoload | 304 | ;;;###autoload |
| 305 | (cl-defmacro define-ibuffer-filter (name documentation | 305 | (cl-defmacro define-ibuffer-filter (name documentation |
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 53cf62b142b..95deb2db478 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el | |||
| @@ -372,15 +372,6 @@ directory, like `default-directory'." | |||
| 372 | (regexp :tag "From") | 372 | (regexp :tag "From") |
| 373 | (regexp :tag "To")))) | 373 | (regexp :tag "To")))) |
| 374 | 374 | ||
| 375 | ;; These declarations are here to avoid byte-compiler warnings about | ||
| 376 | ;; functions defined later via 'define-ibuffer-op'. | ||
| 377 | (declare-function ibuffer-do-toggle-lock "ibuffer.el") | ||
| 378 | (declare-function ibuffer-do-toggle-read-only "ibuffer.el") | ||
| 379 | (declare-function ibuffer-do-save "ibuffer.el") | ||
| 380 | (declare-function ibuffer-do-delete "ibuffer.el") | ||
| 381 | (declare-function ibuffer-do-toggle-modified "ibuffer.el") | ||
| 382 | (declare-function ibuffer-do-kill-on-deletion-marks "ibuffer.el") | ||
| 383 | |||
| 384 | (defvar-keymap ibuffer--filter-map | 375 | (defvar-keymap ibuffer--filter-map |
| 385 | "RET" #'ibuffer-filter-by-mode | 376 | "RET" #'ibuffer-filter-by-mode |
| 386 | "SPC" #'ibuffer-filter-chosen-by-completion | 377 | "SPC" #'ibuffer-filter-chosen-by-completion |