From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Garreau\, Alexandre" Newsgroups: gmane.emacs.help Subject: Re: el-search usage (doc, strings, pcase, etc.) Date: Sat, 27 Oct 2018 18:37:39 +0200 Message-ID: <87zhuzibvw.fsf@portable.galex-713.eu> References: <87tvl7jvir.fsf@portable.galex-713.eu> <875zxne6pc.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1540658167 14231 195.159.176.226 (27 Oct 2018 16:36:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2018 16:36:07 +0000 (UTC) User-Agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 27 18:36:02 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGRZC-0003bk-JC for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 18:36:02 +0200 Original-Received: from localhost ([::1]:37179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGRbJ-0007qj-4H for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 12:38:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGRap-0007qe-Pz for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 12:37:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGRao-00029s-Q1 for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 12:37:43 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:54202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gGRao-00029C-If for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 12:37:42 -0400 Original-Received: from localhost ([::1] helo=portable.galex-713.eu) by portable.galex-713.eu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gGRal-0003Lm-In; Sat, 27 Oct 2018 18:37:39 +0200 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: <875zxne6pc.fsf@web.de> (Michael Heerdegen's message of "Sat, 27 Oct 2018 17:43:11 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:5884:8305::1 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118443 Archived-At: Le 27/10/2018 =C3=A0 17h43, Michael Heerdegen a =C3=A9crit=C2=A0: > 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. It=E2=80=99s pretty quick=C2=A0: translate your markdown/rst (which one?) i= nto org-mode, you basically have to remove the header =E2=80=9C=3D=3D=3D=3D=E2= =80=9D underlining text, and replace that by prefixing stars =E2=80=9C*=E2=80=9D. Then you do= =E2=80=9CC-c C-e i i=E2=80=9D and you get an info file. >> In my memories it was confused, so I was going to try doing the >> opposite: searching a string being or containing =E2=80=9Cwas=E2=80=9D (= or =E2=80=9Cwas:=E2=80=9D) in >> gnus=E2=80=99 source (/usr/share/emacs/25.1/lisp/gnus/), avoiding commen= ts and >> symbols, so to find the function removing exagerated =E2=80=9C(was: old >> subject)=E2=80=9D in subject lines when replying. But I found nothing r= elevant >> being it, and many docstring contain it :/ > > Yes, that's a very common use case. it would=20 >> I tried =E2=80=9C(and (pred stringp) s (guard (string-match "\:" s= )))=E2=80=9D, >> however that is long to type, so I found very very unfortunate el-search >> doesn=E2=80=99t seem to maintain a prompt history (why so? it is easy, j= ust a >> symbol, so to put a list there). > > Of course it has one. Doesn't M-p work for you? Oh, indeed it works. I would have expected C-p/C-n and arrow keys to work too, like in M-x. I only use M-p in real buffer such as with comint-mode modes, barely with minibuffer (as I never wrote more than two lines of text in it, and with a few lines M-p is only barely useful, and C-p still work). Normally using C-p with both `read-string' (which I last used) and `read-from-minibuffer' (which el-search-pattern seems to use) support it just as M-x=E2=80=A6 > 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") Oh interesting, and it even support non-regexp patterns=E2=80=A6 but I find= it odd it use =E2=80=9Cstring=E2=80=9D. I would have expected string to destr= ucture in characters just as the `string' function does in elisp=E2=80=A6 > 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. That=E2=80=99s pretty complex=E2=80=A6 I hoped it was for pure text (so it= =E2=80=99s easier to enter =E2=80=9Cspecial=E2=80=9D characters such as =E2=80=9C\\=E2=80=9D or = =E2=80=9C(=E2=80=9D), not regexps=E2=80=A6 but strangely it seems not to support =E2=80=9C<=E2=80=9D and =E2=80=9C>=E2=80= =9D to match beginning/end of words. >> However it probably call for a pcase macro such as =E2=80=9C(pcase-defma= cro >> contain (match-string) `(and (pred stringp) string (guard >> (string-match ,match-string string))))=E2=80=9D, 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=E2=80=99t= seem >> to offer a way to do so (match for a subpattern according its context, >> or maybe I=E2=80=99m 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. I=E2=80=99d say: the return value of the last pattern, or everything if =E2= =80=9Ct=E2=80=9D. So, with a pattern written this way, it would be the whole thing (or the submatch matched by =E2=80=9CSOMETHING-DIFFERENT=E2=80=9D), while if writte= n like =E2=80=9C(or (and (pred SOME-PRED) (string REGEXP1) (string REGEXP2)) SOMETHING-DIFFERENT))=E2=80=9D it would *always* match the submatch. But I= =E2=80=99m unaware of pcase implemantation. It seems to be fairly complex, so it might be complex as well to do something alike. >> As the search usage (keystrokes, etc.) seem to be quite different than >> from isearch (it seems to highlight it specially but doesn=E2=80=99t reb= ind >> special keystrokes (moving exit it (and scrolling commands such as SPC >> or do exit it too) and I don=E2=80=99t know how to go to next >> occurence (maybe I should learn how to use occur so to know how to use >> it?))), I=E2=80=99m 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. Normally a package should be usable withut defining any key. That=E2=80=99s (part of) the whole point of package recommandation not to define keys: users should decide how they access the interface. And then it=E2=80=99s preferable it=E2=80=99s if convenient of course but I find this pushes a bi= t too much for binding keys: I=E2=80=99m bad at choices and finding myself a pref= ix key will let me unsatisfied (and above all: require me to learn them, which I don=E2=80=99t have (yet) the time or will to invest in), and the = =E2=80=9Cshift=E2=80=9D thing is specific to qwerty (=E2=80=9C%=E2=80=9D doesn=E2=80=99t use shift = on my keyboard, while others keys do (for instance =E2=80=9Cshift+%=E2=80=9D is =E2=80=9C`=E2=80= =9D here)). >> I=E2=80=99m used to be able not to bind keystrokes for command I=E2=80= =99m not yet a >> regular user of (otherwise I just bind the key and forget it, so I end >> loosing keybindings for thing I=E2=80=99d 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 =E2=80=9CM-x <= up> >> =E2=80=9D). > > 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. Why not, by default, be compatible with isearch? I=E2=80=99m not totally a= ware yet of the whole implementation of isearch, but it seems like it=E2=80=99 b= ased on a mode: maybe a clean and modular way to do that would to make derived-mode out of it? or find another way of reusing its library: this way it would stay forward-compatible with it, and benefit from further additions and improvements made to it.