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

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

[nongnu] elpa/eat 35df1bc2a4 2/7: Refactor 'eat--eshell-adjust-make-proc


From: ELPA Syncer
Subject: [nongnu] elpa/eat 35df1bc2a4 2/7: Refactor 'eat--eshell-adjust-make-process-args'
Date: Thu, 15 Dec 2022 10:58:37 -0500 (EST)

branch: elpa/eat
commit 35df1bc2a4ce2d36701f812eea9432406fd12b5b
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Refactor 'eat--eshell-adjust-make-process-args'
    
    * eat.el (eat--eshell-adjust-make-process-args): Avoid
    unnecessary function overrides.  Overriding functions with
    'cl-letf*' is not well documented, and self-overriding a
    function (override a function with its own definition) may not
    a nop.
---
 eat.el | 95 +++++++++++++++++++++++++++++++++---------------------------------
 1 file changed, 48 insertions(+), 47 deletions(-)

diff --git a/eat.el b/eat.el
index 8063979e24..3b636edf2b 100644
--- a/eat.el
+++ b/eat.el
@@ -5527,53 +5527,54 @@ Disable terminal emulation?")))
                  ((and (pred functionp) function)
                   (apply function command args)))))
       (funcall fn command args)
-    (cl-letf*
-        (;; For Emacs 29 and above.
-         (make-process (symbol-function #'make-process))
-         ((symbol-function #'make-process)
-          (if (< emacs-major-version 29)
-              make-process
-            (lambda (&rest plist)
-              ;; Make sure we don't attack wrong process.
-              (if (not (equal (plist-get plist :command)
-                              (cons (file-local-name
-                                     (expand-file-name command))
-                                    args)))
-                  (apply make-process plist)
-                (setf (plist-get plist :command)
-                      `("/usr/bin/env" "sh" "-c"
-                        ,(format "stty -nl echo rows %d columns %d \
-sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
-                                 (floor (window-screen-lines))
-                                 (window-max-chars-per-line)
-                                 null-device)
-                        ".." ,@(plist-get plist :command)))
-                (apply make-process plist)))))
-         ;; For Emacs 28.
-         (start-file-process (symbol-function #'start-file-process))
-         ((symbol-function #'start-file-process)
-          (if (< emacs-major-version 29)
-              (lambda (name buffer &rest command)
-                (apply start-file-process name buffer
-                       `("/usr/bin/env" "sh" "-c"
-                         ,(format "stty -nl echo rows %d columns %d \
-sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
-                                  (floor (window-screen-lines))
-                                  (window-max-chars-per-line)
-                                  null-device)
-                         ".." ,@command)))
-            ;; Don't override on Emacs 28.
-            start-file-process)))
-      (let ((hook
-             (lambda (proc)
-               (set-process-filter proc #'eat--eshell-filter)
-               (set-process-sentinel proc #'eat--eshell-sentinel)
-               (eat--eshell-setup-proc-and-term proc))))
-        (unwind-protect
-            (progn
-              (add-hook 'eshell-exec-hook hook 99)
-              (funcall fn command args))
-          (remove-hook 'eshell-exec-hook hook))))))
+    (let ((hook (lambda (proc)
+                  (set-process-filter proc #'eat--eshell-filter)
+                  (set-process-sentinel proc #'eat--eshell-sentinel)
+                  (eat--eshell-setup-proc-and-term proc))))
+      (unwind-protect
+          (progn
+            (add-hook 'eshell-exec-hook hook 99)
+            (cond
+             ;; Emacs 29 and above.
+             ((>= emacs-major-version 29)
+              (cl-letf*
+                  ((make-process (symbol-function #'make-process))
+                   ((symbol-function #'make-process)
+                    (lambda (&rest plist)
+                      ;; Make sure we don't attack wrong process.
+                      (if (not (equal
+                                (plist-get plist :command)
+                                (cons (file-local-name
+                                       (expand-file-name command))
+                                      args)))
+                          (apply make-process plist)
+                        (setf (plist-get plist :command)
+                              `("/usr/bin/env" "sh" "-c"
+                                ,(format "stty -nl echo rows %d \
+columns %d sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
+                                         (floor (window-screen-lines))
+                                         (window-max-chars-per-line)
+                                         null-device)
+                                ".." ,@(plist-get plist :command)))
+                        (apply make-process plist)))))
+                (funcall fn command args)))
+             ;; Emacs 28.
+             (t
+              (cl-letf*
+                  ((start-file-process
+                    (symbol-function #'start-file-process))
+                   ((symbol-function #'start-file-process)
+                    (lambda (name buffer &rest command)
+                      (apply start-file-process name buffer
+                             "/usr/bin/env" "sh" "-c"
+                             (format "stty -nl echo rows %d columns \
+%d sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
+                                     (floor (window-screen-lines))
+                                     (window-max-chars-per-line)
+                                     null-device)
+                             ".." command))))
+                (funcall fn command args)))))
+        (remove-hook 'eshell-exec-hook hook)))))
 
 
 ;;;;; Minor Modes.



reply via email to

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