all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#45606: [PATCH] Modify comint-read-input-ring to skip uninteresting text
@ 2021-01-02  3:56 Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-01-11 15:43 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-01-02  3:56 UTC (permalink / raw)
  To: 45606; +Cc: mjbauer95

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

I made the attached changes to handle zsh's history on Emacs' master branch.

This is a follow-up to Matthew Bauer's commit f7421039fb15123dbbda047e23504dd1771183b5 which sought to support zsh's extended_history. Matthew, would you confirm that these patches are OK?

Thanks,
Brian

-- 
Sent with https://mailfence.com
Secure and private email

[-- Attachment #2: File Attachment: 0001-shell-mode-use-.zsh_history-as-a-history-file.patch --]
[-- Type: text/x-diff, Size: 825 bytes --]

From 258a325eb90cc516231714fb329a0ad876ea537f Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Fri, 1 Jan 2021 18:56:41 -0800
Subject: [PATCH 1/4] shell-mode: use "~/.zsh_history" as a history file

* lisp/shell.el (shell-mode): Add "~/.zsh_history".
---
 lisp/shell.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/shell.el b/lisp/shell.el
index c179dd24d3..0f866158fe 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -603,6 +603,7 @@ shell-mode
 	     (or hfile
 		 (cond ((string-equal shell "bash") "~/.bash_history")
 		       ((string-equal shell "ksh") "~/.sh_history")
+		       ((string-equal shell "zsh") "~/.zsh_history")
 		       (t "~/.history")))))
       (if (or (equal comint-input-ring-file-name "")
 	      (equal (file-truename comint-input-ring-file-name)
-- 
2.29.2


[-- Attachment #3: File Attachment: 0002-comint-read-input-ring-Use-comint-buffer-s-ring-file.patch --]
[-- Type: text/x-diff, Size: 2204 bytes --]

From 5a6418f693bd71c3dc0cb398209b769c45e59f30 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Fri, 1 Jan 2021 18:58:26 -0800
Subject: [PATCH 2/4] comint-read-input-ring: Use comint buffer's
 ring-file-prefix

* lisp/comint.el (comint-read-input-ring): Bind
`comint-input-ring-file-prefix' in anticipation of a buffer switch.
---
 lisp/comint.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 2e683a7572..f92b7b4a7b 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -979,6 +979,7 @@ comint-read-input-ring
 		(ring (make-ring ring-size))
                 ;; Use possibly buffer-local values of these variables.
                 (ring-separator comint-input-ring-separator)
+                (ring-file-prefix comint-input-ring-file-prefix)
                 (history-ignore comint-input-history-ignore)
                 (ignoredups comint-input-ignoredups))
 	   (with-temp-buffer
@@ -993,17 +994,17 @@ comint-read-input-ring
                  (setq start
                        (if (re-search-backward ring-separator nil t)
                            (progn
-                             (when (and comint-input-ring-file-prefix
+                             (when (and ring-file-prefix
                                         (looking-at
-                                         comint-input-ring-file-prefix))
+                                         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
+                           (when (and ring-file-prefix
                                       (looking-at
-                                       comint-input-ring-file-prefix))
+                                       ring-file-prefix))
                              (goto-char (match-end 0)))
                            (point))))
                  (setq history (buffer-substring start end))
-- 
2.29.2


[-- Attachment #4: File Attachment: 0003-comint-read-input-ring-skip-over-the-comint-input-ri.patch --]
[-- Type: text/x-diff, Size: 1346 bytes --]

From 601431c612b1585cbf32f18d4de6287b83cfbdf2 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Fri, 1 Jan 2021 19:04:27 -0800
Subject: [PATCH 3/4] comint-read-input-ring: skip over the
 comint-input-ring-separator

* lisp/comint.el (comint-read-input-ring): Skip the separator.

Because re-search-backward moves point to the beginning of the match,
and since we don't want the separator appearing in the output, we skip
over it.

This is required to properly detect instances of the value that zsh
uses for `comint-input-ring-file-prefix'; if the
`comint-input-ring-file-prefix' is ':potato', the subsequent
invocation `looking-at' sees '\n:potato' for all entries after the one
at the very beginning of the history file.
---
 lisp/comint.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/comint.el b/lisp/comint.el
index f92b7b4a7b..36fcbb9465 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -994,6 +994,7 @@ comint-read-input-ring
                  (setq start
                        (if (re-search-backward ring-separator nil t)
                            (progn
+                             (goto-char (match-end 0))
                              (when (and ring-file-prefix
                                         (looking-at
                                          ring-file-prefix))
-- 
2.29.2


[-- Attachment #5: File Attachment: 0004-comint-read-input-ring-Tidy.patch --]
[-- Type: text/x-diff, Size: 2195 bytes --]

From 125025c407e6995dd9239a51997082cb898acf3b Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Fri, 1 Jan 2021 19:41:26 -0800
Subject: [PATCH 4/4] comint-read-input-ring: Tidy

* lisp/comint.el (comint-read-input-ring): Simplify.
---
 lisp/comint.el | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 36fcbb9465..3476fd146c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -991,23 +991,14 @@ comint-read-input-ring
                (while (and (< count comint-input-ring-size)
                            (re-search-backward ring-separator nil t)
                            (setq end (match-beginning 0)))
-                 (setq start
-                       (if (re-search-backward ring-separator nil t)
-                           (progn
-                             (goto-char (match-end 0))
-                             (when (and ring-file-prefix
-                                        (looking-at
-                                         ring-file-prefix))
-                               ;; Skip zsh extended_history stamps
-                               (goto-char (match-end 0)))
-                             (match-end 0))
-                         (progn
-                           (goto-char (point-min))
-                           (when (and ring-file-prefix
-                                      (looking-at
-                                       ring-file-prefix))
-                             (goto-char (match-end 0)))
-                           (point))))
+                 (goto-char (if (re-search-backward ring-separator nil t)
+                                (match-end 0)
+                              (point-min)))
+                 (when (and ring-file-prefix
+                            (looking-at ring-file-prefix))
+                   ;; Skip zsh extended_history stamps
+                   (goto-char (match-end 0)))
+                 (setq start (point))
                  (setq history (buffer-substring start end))
                  (goto-char start)
                  (when (and (not (string-match history-ignore history))
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#45606: [PATCH] Modify comint-read-input-ring to skip uninteresting text
  2021-01-02  3:56 bug#45606: [PATCH] Modify comint-read-input-ring to skip uninteresting text Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-01-11 15:43 ` Lars Ingebrigtsen
  2021-01-12  3:44   ` Matthew Bauer
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-11 15:43 UTC (permalink / raw)
  To: Brian Leung; +Cc: 45606, mjbauer95

Brian Leung <leungbk@mailfence.com> writes:

> I made the attached changes to handle zsh's history on Emacs' master branch.
>
> This is a follow-up to Matthew Bauer's commit
> f7421039fb15123dbbda047e23504dd1771183b5 which sought to support zsh's
> extended_history. Matthew, would you confirm that these patches are
> OK?

I'm not Matthew, but it looks OK to me (and didn't seem to break
anything when testing the patch), so I've pushed it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#45606: [PATCH] Modify comint-read-input-ring to skip uninteresting text
  2021-01-11 15:43 ` Lars Ingebrigtsen
@ 2021-01-12  3:44   ` Matthew Bauer
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Bauer @ 2021-01-12  3:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen, 45606, Brian Leung

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

Sorry for the delay. Looks good to me too!

On Mon, Jan 11, 2021 at 9:43 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Brian Leung <leungbk@mailfence.com> writes:
>
> > I made the attached changes to handle zsh's history on Emacs' master
> branch.
> >
> > This is a follow-up to Matthew Bauer's commit
> > f7421039fb15123dbbda047e23504dd1771183b5 which sought to support zsh's
> > extended_history. Matthew, would you confirm that these patches are
> > OK?
>
> I'm not Matthew, but it looks OK to me (and didn't seem to break
> anything when testing the patch), so I've pushed it to Emacs 28.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>

[-- Attachment #2: Type: text/html, Size: 1256 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-12  3:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-02  3:56 bug#45606: [PATCH] Modify comint-read-input-ring to skip uninteresting text Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-01-11 15:43 ` Lars Ingebrigtsen
2021-01-12  3:44   ` Matthew Bauer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.