From: Michael Heerdegen <michael_heerdegen@web.de>
To: "Garreau\, Alexandre" <galex-713@galex-713.eu>
Cc: help-gnu-emacs@gnu.org
Subject: Re: el-search usage (doc, strings, pcase, etc.)
Date: Sat, 27 Oct 2018 17:43:11 +0200 [thread overview]
Message-ID: <875zxne6pc.fsf@web.de> (raw)
In-Reply-To: <87tvl7jvir.fsf@portable.galex-713.eu> (Alexandre Garreau's message of "Sat, 27 Oct 2018 16:48:12 +0200")
Hello Garreau",
thanks for your feedback.
> Other packages have an info file
Ok, it's on my list. I also want to record a demonstration video and
upload it somewhere, and add a live help command you can use while
searching to see the most important keys.
> Btw I really liked what I did read at some point about if you search for
> 27, it will not match for text or comments (yet I barely need to search
> for numbers usually): that makes it look pretty semantic (does it uses
> `read', `eval' or something?).
Yes, it's based on `read'.
> In my memories it was confused, so I was going to try doing the
> opposite: searching a string being or containing “was” (or “was:”) in
> gnus’ source (/usr/share/emacs/25.1/lisp/gnus/), avoiding comments and
> symbols, so to find the function removing exagerated “(was: old
> subject)” in subject lines when replying. But I found nothing relevant
> being it, and many docstring contain it :/
Yes, that's a very common use case.
> I tried “(and (pred stringp) s (guard (string-match "\<was\>:" s)))”,
> however that is long to type, so I found very very unfortunate el-search
> doesn’t seem to maintain a prompt history (why so? it is easy, just a
> symbol, so to put a list there).
Of course it has one. Doesn't M-p work for you?
BTW, the solution for your problem is the `string' pattern which exactly
does this: search for strings that match the argument(s). Like
(string "was")
The available pattern types are listed in C-h f
el-search-defined-patterns. BTW, the arguments of `string' can also be
an "extended regexp" - that's a regexp plus a list of bindings like in
(string (((case-fold-search nil)) "was"))
which would match "I was" but not "I Was", or a predicate accepting a
string.
> However it probably call for a pcase macro such as “(pcase-defmacro
> contain (match-string) `(and (pred stringp) string (guard
> (string-match ,match-string string))))”, but the problem is then it
> highlights the whole string, instead of the matched part (while this
> should be easily usable since this macro actually returns position of
> match (and match-end its end)), and el-search-defpattern doesn’t seem
> to offer a way to do so (match for a subpattern according its context,
> or maybe I’m not enough educated of pcase complex mecanics).
It doesn't have this feature (yet). I guess I could add it, but
el-search not really fits for the task. You can combine patterns
matching strings in any way. For example, you could search for
something like
(or (and (string REGEXP1) (string REGEXP2) (pred SOME-PRED))
SOMETHING-DIFFERENT))
so it's not even always well-defined what is intended to be
highlighted. Strings are atomic objects to el-search, so I decided to
make the interface reflect this. This doesn't mean that el-search can't
be used to replace words inside strings, for example - it would just
replace matching strings completely with a new string with the relevant
words replaced.
> As the search usage (keystrokes, etc.) seem to be quite different than
> from isearch (it seems to highlight it specially but doesn’t rebind
> special keystrokes (moving exit it (and scrolling commands such as SPC
> or <backspace> do exit it too) and I don’t know how to go to next
> occurence (maybe I should learn how to use occur so to know how to use
> it?))), I’m a bit lost.
The file header should tell it...? Depending on the set of key bindings
you installed, you get to the next match with C-S (i.e. control-shift-s)
or just s. Backwards with C-R or r. You need to install a set of key
bindings to make this work - loading the package doesn't define any
keys.
> I’m used to be able not to bind keystrokes for command I’m not yet a
> regular user of (otherwise I just bind the key and forget it, so I end
> loosing keybindings for thing I’d actually need), but it seems
> el-search enforces the opposite of that, since to continue a search I
> *need* to repetedly run the command (which gives a lot of “M-x <up>
> <return>”).
I see, good point. I think this is something that would not be hard to
implement. There exist transient maps to make the keys repeatable. It
should be possible to only set up the transient maps but avoid to
install any global key bindings.
Thanks,
Michael.
next prev parent reply other threads:[~2018-10-27 15:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-27 14:48 el-search usage (doc, strings, pcase, etc.) Garreau, Alexandre
2018-10-27 15:43 ` Michael Heerdegen [this message]
2018-10-27 16:37 ` Garreau, Alexandre
2018-10-27 20:19 ` Michael Heerdegen
2018-10-27 22:30 ` Garreau, Alexandre
2018-10-28 0:01 ` Michael Heerdegen
2018-10-28 1:11 ` Michael Heerdegen
2018-10-28 1:55 ` Garreau, Alexandre
2018-10-28 22:26 ` Michael Heerdegen
2018-10-28 22:59 ` Garreau, Alexandre
2018-10-28 23:39 ` Michael Heerdegen
2018-10-27 15:55 ` Michael Heerdegen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zxne6pc.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=galex-713@galex-713.eu \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).