emacs-devel
[Top][All Lists]
Advanced

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

Re: isearch region or thing at point.


From: Basil L. Contovounesios
Subject: Re: isearch region or thing at point.
Date: Fri, 03 May 2019 17:28:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Ergus <address@hidden> writes:

> Here is attached a patch with all my proposed changes to isearch.

Thanks, just some minor comments from me:

> @@ -267,6 +267,14 @@ of the current line to the search string.  If point is 
> already at the
>  end of a line, it appends the next line.  With a prefix argument
>  @var{n}, it appends the next @var{n} lines.
>  
> address@hidden M-w @r{(Incremental search)}
> address@hidden isearch-yank-region
> +  @kbd{M-w} (@code{isearch-yank-region}) appends the text in the
> +active region if @code{transient-mark-mode} is @code{non-nil}. This is

I think it is more common to talk about transient-mark-mode the mode,
not the variable. 

Emacs convention is to end all sentences with two spaces, see the
sentence-end-double-space setting in the repository's dir-locals-file.

> +an easy way to insert the text in the region without needing to exit
> address@hidden The region is deactivated during the search, but
> +it is reactivated if the @code{isearch-cancel} is called.
> +
>  @kindex C-y @r{(Incremental search)}
>  @kindex M-y @r{(Incremental search)}
>  @kindex mouse-2 @r{in the minibuffer (Incremental search)}
> diff --git a/lisp/isearch.el b/lisp/isearch.el
> index 6280afebdc..78414dbfcd 100644
> --- a/lisp/isearch.el
> +++ b/lisp/isearch.el
> @@ -937,6 +940,8 @@ Each element is an `isearch--state' struct where the 
> slots are
>  
>  (defvar isearch--saved-overriding-local-map nil)
>  
> +(defvar isearch--deactivated-mark nil)
> +

It's always nice to have docstrings.

>  ;; Minor-mode-alist changes - kind of redundant with the
>  ;; echo area, but if isearching in multiple windows, it can be useful.
>  ;; Also, clicking the mode-line indicator pops up
> @@ -1133,6 +1140,22 @@ positive, or search for ARGth symbol backward if ARG 
> is negative."
>        (isearch-push-state)
>        (isearch-update)))))
>  
> +(defun isearch-forward-region (&optional arg)
> +  "Do incremental search forward for text in active region.
> +Like ordinary incremental search except that the text in the
> +active region is added to the search string initially
> +if`transient-mark-mode' is enabled.  See the command
    ^^^

Missing space.

> +`isearch-forward' for more information.
> +With a prefix argument, search for ARGth occurrence forward if
> +ARG is positive, or ARGth occurrence backward if ARG is
> +negative."
> +  (interactive "P")
> +  (isearch-forward nil 1)
> +  (isearch-yank-region)
> +  (when (and isearch--deactivated-mark
> +             arg)
> +    (isearch-repeat-forward (prefix-numeric-value arg))))
> +
>  
>  ;; isearch-mode only sets up incremental search for the minor mode.
>  ;; All the work is done by the isearch-mode commands.
> @@ -2446,6 +2473,27 @@ If search string is empty, just beep."
>    ;; then it "used" the mark which we should hence deactivate.
>    (when select-active-regions (deactivate-mark)))
>  
> +(defun isearch-yank-region ()
> +  "Pull current active region text into search string.
> +The text in the active region is added to the search string if
> +variable `transient-mark-mode' is non nil."

Ditto re: transient-mark-mode the mode, not variable.

Thanks,

-- 
Basil



reply via email to

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