emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/with-editor 13397b9844 1/2: Use define-advice instead of a


From: ELPA Syncer
Subject: [nongnu] elpa/with-editor 13397b9844 1/2: Use define-advice instead of advice-add
Date: Sun, 9 Jun 2024 13:01:17 -0400 (EDT)

branch: elpa/with-editor
commit 13397b98442028b676ae8843034f90fa8622a3a0
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Use define-advice instead of advice-add
---
 lisp/with-editor.el | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/lisp/with-editor.el b/lisp/with-editor.el
index 875835b300..9d0c5732ab 100644
--- a/lisp/with-editor.el
+++ b/lisp/with-editor.el
@@ -540,8 +540,9 @@ at run-time.
                             with-editor-server-window-alist)))
       server-window))
 
-(defun server-switch-buffer--with-editor-server-window-alist
-    (fn &optional next-buffer &rest args)
+(define-advice server-switch-buffer
+    (:around (fn &optional next-buffer &rest args)
+             with-editor-server-window-alist)
   "Honor `with-editor-server-window-alist' (which see)."
   (let ((server-window (with-current-buffer
                            (or next-buffer (current-buffer))
@@ -551,11 +552,9 @@ at run-time.
                          (with-editor-server-window))))
     (apply fn next-buffer args)))
 
-(advice-add 'server-switch-buffer :around
-            #'server-switch-buffer--with-editor-server-window-alist)
-
-(defun start-file-process--with-editor-process-filter
-    (fn name buffer program &rest program-args)
+(define-advice start-file-process
+    (:around (fn name buffer program &rest program-args)
+             with-editor-process-filter)
   "When called inside a `with-editor' form and the Emacsclient
 cannot be used, then give the process the filter function
 `with-editor-process-filter'.  To avoid overriding the filter
@@ -578,10 +577,9 @@ the appropriate editor environment variable."
       (process-put process 'default-dir default-directory)
       process)))
 
-(advice-add 'start-file-process :around
-            #'start-file-process--with-editor-process-filter)
-
-(cl-defun make-process--with-editor-process-filter
+(advice-add #'make-process :around
+            #'make-process@with-editor-process-filter)
+(cl-defun make-process@with-editor-process-filter
     (fn &rest keys &key name buffer command coding noquery stop
         connection-type filter sentinel stderr file-handler
         &allow-other-keys)
@@ -621,8 +619,6 @@ to set the appropriate editor environment variable."
       (process-put process 'default-dir default-directory)
       process)))
 
-(advice-add #'make-process :around #'make-process--with-editor-process-filter)
-
 (defun with-editor-set-process-filter (process filter)
   "Like `set-process-filter' but keep `with-editor-process-filter'.
 Give PROCESS the new FILTER but keep `with-editor-process-filter'
@@ -714,11 +710,9 @@ OPEN \\([^]+?\\)\
   (unless no-default-filter
     (internal-default-process-filter process string)))
 
-(advice-add 'server-visit-files :after
-            #'server-visit-files--with-editor-file-name-history-exclude)
-
-(defun server-visit-files--with-editor-file-name-history-exclude
-    (files _proc &optional _nowait)
+(define-advice server-visit-files
+    (:after (files _proc &optional _nowait)
+            with-editor-file-name-history-exclude)
   (pcase-dolist (`(,file . ,_) files)
     (when (cl-find-if (lambda (regexp)
                         (string-match-p regexp file))
@@ -877,8 +871,9 @@ else like the former."
           shell-command-default-error-buffer
           (and async current-prefix-arg (with-editor-read-envvar)))))
 
-(defun shell-command--shell-command-with-editor-mode
-    (fn command &optional output-buffer error-buffer)
+(define-advice shell-command
+    (:around (fn command &optional output-buffer error-buffer)
+             shell-command-with-editor-mode)
   ;; `shell-mode' and its hook are intended for buffers in which an
   ;; interactive shell is running, but `shell-command' also turns on
   ;; that mode, even though it only runs the shell to run a single
@@ -909,9 +904,6 @@ else like the former."
                           (with-editor-process-filter proc str t)))
                process))))))
 
-(advice-add 'shell-command :around
-            #'shell-command--shell-command-with-editor-mode)
-
 ;;; _
 
 (defun with-editor-debug ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]