[Top][All Lists]

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

Re: RFC: [PATCH] isearch enhancements: symbol mode; syntactic filtering

From: Juri Linkov
Subject: Re: RFC: [PATCH] isearch enhancements: symbol mode; syntactic filtering
Date: Fri, 08 Jul 2011 22:27:47 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

>>> - Syntactic filtering: control whether to match in comments, strings, and
>>> normal text.
>> This is easier to implement using `isearch-filter-predicate' as shown in
>> http://thread.gmane.org/gmane.emacs.devel/34742
> It may be easier to implement that way, but the results aren't as
> good. Integrating the filtering mode into isearch allows it to be saved
> along with all other isearch state.  Also, my approach doesn't conflict
> with other uses of isearch-filter-predicate.

It would be bad design to implement all particular filter types
in isearch.el.  `isearch-filter-predicate' was intended to provide
modular approach where additional filters can be defined only by
changing the value of `isearch-filter-predicate'.

But I agree with you that in its current state `isearch-filter-predicate'
can cause conflicts with other uses of `isearch-filter-predicate'.
It should be improved to allow adding more filters.  This can be
implemented by supporting a list of filters.

`isearch-filter-predicate' also makes it easier to be saved along with
all other isearch state - you can just save its value.

>> Unfortunately, I failed to find a good keybinding for this feature,
>> so it sunk into obscurity.
> The ones I proposed should be reasonably accessible, and they don't
> conflict with anything useful directly from isearch.

When choosing a keybinding we need to anticipate the possibility of
adding more keybindings in the future.  Adding a key prefix will help, e.g.

`M-s f c' isearch-toggle-filter-comments
`M-s f s' isearch-toggle-filter-strings
`M-s f t' isearch-toggle-filter-text

where `f' is short for "filter".

>>> - Symbol search: like word search, but looks only at symbol boundaries
>> This is much needed.  But I think it should have a keybinding separate
>> from word search.  Currently, `M-s w' toggles word search,
>> so a new keybinding `M-s _' could toggle symbol search.
> Adding symbol search as a new kind of word search makes sense because the
> new search mode is conceptually similar to, and mutually exclusive with,
> classic word search; having accepted this idea, it naturally follows to
> allow users to cycle through normal, word, and symbol searches makes sense.
> I have no objection to providing a way to go directly to symbol search,
> however: being able to cycle backwards with a prefix argument to M-s
> w would be sufficient, I think.

I remember seeing exactly the same arguments in support for cycling
through normal, word, and regexp searches with the same key because they
are conceptually similar (word search is implemented by regexp search)
and mutually exclusive.

If it was decided to put them on one key, then now adding symbol search
to the same key would make cycling longer.  This suggests that it's
better to activate all different search types with separate keys.

> I like the idea of using M-_ to refer to something having to do with
> symbols; in my patch, I bind this key to a function that both sets
> symbol-search mode _and_ filters out matches in comments and strings;
> I call it identifier-mode.  I find myself wanting exactly this behavior
> fairly frequently.  We can certainly bikeshed a bit about the
> actual keybindings.

`identifier-mode' is another search type that suggests that using
a separate key to enable it (e.g. `M-s i') is better than cycling.

reply via email to

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