From: Juri Linkov <juri@linkov.net>
To: 30187@debbugs.gnu.org
Subject: bug#30187: M-e should restore isearch correctly in special modes
Date: Mon, 29 Jan 2018 23:57:17 +0200 [thread overview]
Message-ID: <87a7wwz5tu.fsf@mail.linkov.net> (raw)
In-Reply-To: <87607wnsnb.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 20 Jan 2018 23:10:16 +0200")
> There was an old problem that ‘isearch-edit-string’ incorrectly
> restored a previous isearch mode in such commands as
> ‘comint-history-isearch-backward’ and ‘dired-isearch-filenames’
> because they let-bind variables that affects the search parameters,
> e.g. ‘(let ((dired-isearch-filenames t)))’ only at the starting
> isearch, but when ‘M-e’ (isearch-edit-string) exits isearch,
> and later starts again, these let-binding are not in effect
> and thus restore the wrong search state.
There is another problem with ‘comint-history-isearch-backward’:
when it is called at the end of an “*Async Shell Command*” buffer
it should not activate comint-history isearch, only a normal isearch
should be started. I tried different approaches, but only workable
solution is to check whether the shell prompt is empty as it is
in all “*Async Shell Command*” buffers:
diff --git a/lisp/comint.el b/lisp/comint.el
index 8dba317..b7179e2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1448,10 +1448,17 @@ comint-history-isearch-message-overlay
(defun comint-history-isearch-setup ()
"Set up a comint for using Isearch to search the input history.
Intended to be added to `isearch-mode-hook' in `comint-mode'."
- (when (or (eq comint-history-isearch t)
- (and (eq comint-history-isearch 'dwim)
- ;; Point is at command line.
- (comint-after-pmark-p)))
+ (when (and (get-buffer-process (current-buffer))
+ (or (eq comint-history-isearch t)
+ (and (eq comint-history-isearch 'dwim)
+ ;; Point is at command line.
+ (comint-after-pmark-p)
+ ;; Prompt is not empty like in Async Shell Command buffers
+ (not (eq (save-excursion
+ (goto-char (comint-line-beginning-position))
+ (forward-line 0)
+ (point))
+ (comint-line-beginning-position))))))
(setq isearch-message-prefix-add "history ")
(setq-local isearch-search-fun-function
#'comint-history-isearch-search)
prev parent reply other threads:[~2018-01-29 21:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-20 21:10 bug#30187: M-e should restore isearch correctly in special modes Juri Linkov
2018-01-21 16:00 ` Eli Zaretskii
2018-01-21 21:23 ` Juri Linkov
2018-01-22 22:14 ` Juri Linkov
2018-01-29 21:57 ` Juri Linkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a7wwz5tu.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=30187@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.