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: Ergus
Subject: Re: isearch region or thing at point.
Date: Wed, 1 May 2019 13:20:25 +0200
User-agent: NeoMutt/20180716

Hi all:

Here is attached a patch with all my proposed changes to isearch. I
added documentation in the manual for one of the two functions, but for
the other I don't find the right place.

There is still a pending agreement about the questions I made in the
last email, but, meanwhile you can check the rest of the patch and make
all the corrections you think are needed.

Thanks in advance for your comments,
Ergus

On Wed, May 01, 2019 at 12:33:12AM +0100, Basil L. Contovounesios wrote:
Ergus <address@hidden> writes:

On Tue, Apr 30, 2019 at 11:39:11PM +0100, Basil L. Contovounesios wrote:
Ergus <address@hidden> writes:

                         (region-bounds)))
            (contiguous (= (length bounds) 1)) ;; Region is contiguous

Better to use the function region-noncontiguous-p.

I already had the bounds.. I didn't want to do the funcall again... but
I know it is probably not important.. I am just an obsessed.

The higher-level and more flexible region-extract-function will handle
this for you in any case.

            (region-string (and (= (count-lines region-beg region-end) 1)
                                (buffer-substring-no-properties
                                 region-beg region-end)))

Why can't the region span multiple lines?  Better to use
region-extract-function for this, as it is more flexible.

I don't thing that searching multiple lines will be very useful in
practice and could potentially produce some corner cases. But I
will think about that a bit more.

AFAIK, isearch is designed to work perfectly fine with multiple lines,
and I use this feature a lot, especially in the context of lax
whitespace matches in Info manuals, for example.

Providing a dedicated region isearch command which is limited to a
single line sounds hardly better than using isearch-yank-word-or-char or
similar.

        (isearch-yank-string region-string)

        (when-let (count (and arg (prefix-numeric-value arg)))
          (isearch-repeat-forward count)))

This can be simplified as per Noam's suggestion.
Yes, sorry, I was concerned if somehow the prefix could be non-nil, but
(prefix-numeric-value arg) could return nil... I don't really know the
fancy valued that prefix could potentially have. But probably there is
not any danger there.

All potential prefix values are listed under (info "(elisp) Prefix
Command Arguments"), and prefix-numeric-value is guaranteed to return an
integer.

Thanks,

--
Basil

Attachment: isearch_yank_region.patch
Description: Text document


reply via email to

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