[Top][All Lists]

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

Re: PATCH: isearch-yank-until-char

From: Karl Fogel
Subject: Re: PATCH: isearch-yank-until-char
Date: Thu, 15 Aug 2019 23:53:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On 14 Aug 2019, Juri Linkov wrote:
>Globally 'C-M-c' is bound to 'exit-recursive-edit', so the question is
>does anyone want 'C-M-c' to quit isearch and execute 'exit-recursive-edit'?
>I never used 'C-M-c' to quit isearch.

Neither have I.

>One problem is that typing 'C-s C-M-c <SPC>' at the end of the buffer
>raises the error:
>  Debugger entered--Lisp error: (search-failed " ")
>    search-forward(" ")
>    isearch-yank-until-char(32)
>    funcall-interactively(isearch-yank-until-char 32)
>    call-interactively(isearch-yank-until-char nil nil)
>    command-execute(isearch-yank-until-char)
>and leaves isearch in a broken state.  Should your new command
>catch this error?

It could.  I'm not sure exacly what to do with the error, though.  The new 
version below displays a brief message and then returns to the isearch prompt:

(defun isearch-yank-until-char (char)
  "Pull everything until next instance of CHAR from buffer into search string.
Interactively, prompt for CHAR."
  (interactive "cYank until character: ")
   (lambda () (let ((inhibit-field-text-motion t))
                (condition-case nil
                      (search-forward (char-to-string char))
                      (forward-char -1))
                   (message "`%c' not found" char)
                   (sit-for 2)))

This feels klugey, but I'm not sure what a better way is.  Do you have any 

I also tried raising an error -- i.e., substitute `message' above with `error' 
and get rid of the `(sit-for 2)' -- but the problem with that is that it 
*never* returns to the isearch prompt, even though in either case isearch is 
still active and one could continue adding to the search string.

Best regards,

reply via email to

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