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.
This commit is contained in:
parent
7ae069b676
commit
5d75c6e44d
2 changed files with 51 additions and 60 deletions
|
@ -218,12 +218,10 @@ buffer object.
|
|||
(let ((opstring-sym (make-symbol "opstring"))
|
||||
(active-opstring-sym (make-symbol "active-opstring")))
|
||||
`(progn
|
||||
(let ((,opstring-sym ,opstring)
|
||||
(,active-opstring-sym ,active-opstring))
|
||||
(defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op))
|
||||
"" "ibuffer-do-")
|
||||
(symbol-name op)))
|
||||
,args
|
||||
(defalias ',(intern (concat (if (string-match "^ibuffer-do" (symbol-name op))
|
||||
"" "ibuffer-do-")
|
||||
(symbol-name op)))
|
||||
(lambda ,args
|
||||
,(if (stringp documentation)
|
||||
documentation
|
||||
(format "%s marked buffers." (if (functionp active-opstring)
|
||||
|
@ -234,45 +232,47 @@ buffer object.
|
|||
'(interactive))
|
||||
(cl-assert (derived-mode-p 'ibuffer-mode))
|
||||
(setq ibuffer-did-modification nil)
|
||||
(let ((marked-names (,(pcase mark
|
||||
(:deletion
|
||||
'ibuffer-deletion-marked-buffer-names)
|
||||
(_
|
||||
'ibuffer-marked-buffer-names)))))
|
||||
(when (null marked-names)
|
||||
(cl-assert (get-text-property (line-beginning-position)
|
||||
'ibuffer-properties)
|
||||
nil "No buffer on this line")
|
||||
(setq marked-names (list (buffer-name (ibuffer-current-buffer))))
|
||||
(ibuffer-set-mark ,(pcase mark
|
||||
(:deletion
|
||||
'ibuffer-deletion-char)
|
||||
(_
|
||||
'ibuffer-marked-char))))
|
||||
,(let* ((finish (append
|
||||
'(progn)
|
||||
(if (eq modifier-p t)
|
||||
'((setq ibuffer-did-modification t))
|
||||
())
|
||||
(and after `(,after)) ; post-operation form.
|
||||
`((ibuffer-redisplay t)
|
||||
(message (concat "Operation finished; "
|
||||
(if (functionp ,opstring-sym)
|
||||
(funcall ,opstring-sym)
|
||||
,opstring-sym)
|
||||
" %s %s")
|
||||
count (ngettext "buffer" "buffers"
|
||||
count)))))
|
||||
(inner-body (if complex
|
||||
`(progn ,@body)
|
||||
`(progn
|
||||
(let ((,opstring-sym ,opstring)
|
||||
(,active-opstring-sym ,active-opstring))
|
||||
(let ((marked-names (,(pcase mark
|
||||
(:deletion
|
||||
'ibuffer-deletion-marked-buffer-names)
|
||||
(_
|
||||
'ibuffer-marked-buffer-names)))))
|
||||
(when (null marked-names)
|
||||
(cl-assert (get-text-property (line-beginning-position)
|
||||
'ibuffer-properties)
|
||||
nil "No buffer on this line")
|
||||
(setq marked-names (list (buffer-name (ibuffer-current-buffer))))
|
||||
(ibuffer-set-mark ,(pcase mark
|
||||
(:deletion
|
||||
'ibuffer-deletion-char)
|
||||
(_
|
||||
'ibuffer-marked-char))))
|
||||
,(let* ((finish (append
|
||||
'(progn)
|
||||
(if (eq modifier-p t)
|
||||
'((setq ibuffer-did-modification t))
|
||||
())
|
||||
(and after `(,after)) ; post-operation form.
|
||||
`((ibuffer-redisplay t)
|
||||
(message (concat "Operation finished; "
|
||||
(if (functionp ,opstring-sym)
|
||||
(funcall ,opstring-sym)
|
||||
,opstring-sym)
|
||||
" %s %s")
|
||||
count (ngettext "buffer" "buffers"
|
||||
count)))))
|
||||
(inner-body (if complex
|
||||
`(progn ,@body)
|
||||
`(progn
|
||||
(with-current-buffer buf
|
||||
(save-excursion
|
||||
,@body))
|
||||
t)))
|
||||
(body `(let ((_ ,before) ; pre-operation form.
|
||||
(count
|
||||
(,(pcase mark
|
||||
(body `(let ((_ ,before) ; pre-operation form.
|
||||
(count
|
||||
(,(pcase mark
|
||||
(:deletion
|
||||
'ibuffer-map-deletion-lines)
|
||||
(_
|
||||
|
@ -290,16 +290,16 @@ buffer object.
|
|||
(setq
|
||||
ibuffer-did-modification t))))
|
||||
inner-body)))))
|
||||
,finish)))
|
||||
(if dangerous
|
||||
`(when (ibuffer-confirm-operation-on
|
||||
(if (functionp ,active-opstring-sym)
|
||||
(funcall ,active-opstring-sym)
|
||||
,active-opstring-sym)
|
||||
marked-names)
|
||||
,body)
|
||||
body))))
|
||||
:autoload-end))))
|
||||
,finish)))
|
||||
(if dangerous
|
||||
`(when (ibuffer-confirm-operation-on
|
||||
(if (functionp ,active-opstring-sym)
|
||||
(funcall ,active-opstring-sym)
|
||||
,active-opstring-sym)
|
||||
marked-names)
|
||||
,body)
|
||||
body))))
|
||||
:autoload-end)))))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defmacro define-ibuffer-filter (name documentation
|
||||
|
|
|
@ -372,15 +372,6 @@ directory, like `default-directory'."
|
|||
(regexp :tag "From")
|
||||
(regexp :tag "To"))))
|
||||
|
||||
;; These declarations are here to avoid byte-compiler warnings about
|
||||
;; functions defined later via 'define-ibuffer-op'.
|
||||
(declare-function ibuffer-do-toggle-lock "ibuffer.el")
|
||||
(declare-function ibuffer-do-toggle-read-only "ibuffer.el")
|
||||
(declare-function ibuffer-do-save "ibuffer.el")
|
||||
(declare-function ibuffer-do-delete "ibuffer.el")
|
||||
(declare-function ibuffer-do-toggle-modified "ibuffer.el")
|
||||
(declare-function ibuffer-do-kill-on-deletion-marks "ibuffer.el")
|
||||
|
||||
(defvar-keymap ibuffer--filter-map
|
||||
"RET" #'ibuffer-filter-by-mode
|
||||
"SPC" #'ibuffer-filter-chosen-by-completion
|
||||
|
|
Loading…
Add table
Reference in a new issue