emacs-diffs
[Top][All Lists]
Advanced

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

master f742103: Add zsh extended_history handling for comint.el input ri


From: Lars Ingebrigtsen
Subject: master f742103: Add zsh extended_history handling for comint.el input ring
Date: Mon, 10 Aug 2020 07:10:18 -0400 (EDT)

branch: master
commit f7421039fb15123dbbda047e23504dd1771183b5
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add zsh extended_history handling for comint.el input ring
    
    * lisp/comint.el (comint-input-ring-file-prefix): New variable
    (bug#36034).
    (comint-read-input-ring): Use it.
    
    * lisp/shell.el (shell-mode): Set it.
---
 lisp/comint.el | 20 ++++++++++++++++++--
 lisp/shell.el  |  7 ++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 4b3b583..df947b9 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -249,6 +249,10 @@ to set this in a mode hook, rather than customize the 
default value."
                 file)
   :group 'comint)
 
+(defvar comint-input-ring-file-prefix nil
+  "The prefix to skip when parsing the input ring file.
+This is useful in Zsh when the extended_history option is on.")
+
 (defcustom comint-scroll-to-bottom-on-input nil
   "Controls whether input to interpreter causes window to scroll.
 If nil, then do not scroll.  If t or `all', scroll all windows showing buffer.
@@ -987,8 +991,20 @@ See also `comint-input-ignoredups' and 
`comint-write-input-ring'."
                            (setq end (match-beginning 0)))
                  (setq start
                        (if (re-search-backward ring-separator nil t)
-                           (match-end 0)
-                         (point-min)))
+                           (progn
+                             (when (and comint-input-ring-file-prefix
+                                        (looking-at
+                                         comint-input-ring-file-prefix))
+                               ;; Skip zsh extended_history stamps
+                               (goto-char (match-end 0)))
+                             (match-end 0))
+                         (progn
+                           (goto-char (point-min))
+                           (when (and comint-input-ring-file-prefix
+                                      (looking-at
+                                       comint-input-ring-file-prefix))
+                             (goto-char (match-end 0)))
+                           (point))))
                  (setq history (buffer-substring start end))
                  (goto-char start)
                  (when (and (not (string-match history-ignore history))
diff --git a/lisp/shell.el b/lisp/shell.el
index dc52841..f5e18bb 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -619,7 +619,12 @@ buffer."
       ;; Bypass a bug in certain versions of bash.
       (when (string-equal shell "bash")
         (add-hook 'comint-preoutput-filter-functions
-                  #'shell-filter-ctrl-a-ctrl-b nil t)))
+                  #'shell-filter-ctrl-a-ctrl-b nil t))
+
+      ;; Skip extended history for zsh.
+      (when (string-equal shell "zsh")
+        (setq-local comint-input-ring-file-prefix
+                    ": [[:digit:]]+:[[:digit:]]+;")))
     (comint-read-input-ring t)))
 
 (defun shell-apply-ansi-color (beg end face)



reply via email to

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