From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: el-search usage (doc, strings, pcase, etc.) Date: Sat, 27 Oct 2018 22:19:52 +0200 Message-ID: <87zhuzkuqf.fsf@web.de> References: <87tvl7jvir.fsf@portable.galex-713.eu> <875zxne6pc.fsf@web.de> <87zhuzibvw.fsf@portable.galex-713.eu> 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 1540671515 20036 195.159.176.226 (27 Oct 2018 20:18:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2018 20:18:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: "Garreau\, Alexandre" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 27 22:18:31 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 1gGV2U-00058E-NV for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 22:18:30 +0200 Original-Received: from localhost ([::1]:37676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGV4a-0006Xg-Vs for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 16:20:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGV41-0006XY-I4 for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:20:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGV3w-0005uy-14 for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:20:04 -0400 Original-Received: from mout.web.de ([212.227.17.11]:57579) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gGV3t-0005sC-SI for help-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:19:59 -0400 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MF3jD-1gNyEs3i6l-00GLkm; Sat, 27 Oct 2018 22:19:54 +0200 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MF3jD-1gNyEs3i6l-00GLkm; Sat, 27 Oct 2018 22:19:54 +0200 In-Reply-To: <87zhuzibvw.fsf@portable.galex-713.eu> (Alexandre Garreau's message of "Sat, 27 Oct 2018 18:37:39 +0200") X-Provags-ID: V03:K1:AcVgJLfAxTssRFOHcQLnO5ndNiK7BTpAX+5/1RoJwj4HRwqnB1y 3VEooZcOUrwRRAGKCTs4G37iHyrlI7ysA3qqiEKL8Q4pXzTfgRO3urt/ArfMkeMhRH3MZEJ gmEE0uGrj2Kwn8Tqr6Yj4jNrZJ1aSJ5Fi2s/oYUxjguUw97uEOg0BxrzIIxI2uz1P0+67ET L/mGQ/a5OwD8lFjNSDwLA== X-UI-Out-Filterresults: notjunk:1;V01:K0:H8z9hy3gLhM=:HDN0Hgi8+T6sqjEIK3LiSD gTjP+Uy2cZbbt5Y3v1C8k+Gx0UCpaO+Dj286rUsIxFbCNDFrbkYZok7QLa9RF7Y2Lj2Oa9I3I gxb9/RUkgnX/CQmhbrPv+FDMyJlIZLRvjz+JGmYSChFRGbzqZ994ZmzgLjfUDd/YPf6yMZzvF puNZuk1N8CAWd1SMAus5dZDtIWO3Bu7ujPxnez4eamho5mAs7MG6cuikrdBwzn35SC3RG67yC ioG/gX8pt2/IfoccT/25I+MvrIf2kYcIZwgsV3T3AgHMo41rBIoPCl8q1JTze9R9HSz6rcFaS O72cQyIZOpKMRGJcnhONgxKtH8W/Ribg/0Vc6Cxri1q/n6ahQuDHJ2R+Zi08T37vwpviHHd5M 0a/Ip2jyHOVCAoOn1jyZszjMMA+EmFTR7wChP+OQ2pgRMvQP3kU3hTzso3ne9Qor+ZVm3nM/Q TvHDmdarqjRMyx9+aiXecEYR16Rav7CGOTkZwAcB+bAw2wxNDl5MQpM9IydSSahfzi5Oi/y52 2J0zQoWd4wX6zH4X0uABU8gOHHFhjTAIptoBSePvkRyI2Og+JlA4z6BN1IqG3U0M2UWGYkg0q HFbi8oVdCIxbJpvb8JqmqNvTJZtbcy3NmLNXrh2PhYobxIlfMtahM0uJRJtrZ0xjDQDLPiYhq WrZLUEDJ5WuRldIJDYUr0MoV3rJOn9m8B3yLCthyU8m/rmv04dsJFlTvvkeA/h4MhBbtsv0LU lc0Z+douCJALGyTOX+6KYg0VtGffE+b4X4fsF0wXjLbuqi8+zSaLJwD0Ah98CVETrj9MW/zK X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 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:118450 Archived-At: "Garreau, Alexandre" writes: > It=E2=80=99s pretty quick=C2=A0: translate your markdown/rst (which one?) Currently I only have the comment in the file header. > 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 In emacs -Q, C-p and C-n don't browse the history for M-x. Also, in el-search, the pattern input buffer is in elisp-mode and often contains multiline input, so I decided that up and down move by lines. That's beneficial when you write more complex patterns. > Oh interesting, and it even support non-regexp patterns=E2=80=A6 but I fi= nd it > odd it use =E2=80=9Cstring=E2=80=9D. I would have expected string to des= tructure in > characters just as the `string' function does in elisp=E2=80=A6 First of all I wanted a name that is short, because it is one of the most often used pattern types. Any better idea? > > 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 o= r =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. A literal string match pattern is easy to implement: (el-search-defpattern string-literal (s) `(string ,(regexp-quote s))) Then you can e.g. search for (string-literal "**") to search for string containing two subsequent star chars. Matching beginning and end of words works with `string': (string "\\") In isearch, it's possible to enter only one backslash, but el-search patterns are sexps, so you must escape the escape character to get one escape character as in any Lisp expression. > > 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 writ= ten 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. Yeah, it's not that simple: patterns do not have return values, and side effects (like changing match data) for matching are tricky. > Normally a package should be usable withut defining any key. Well, it's usable without keys, but then you have no ... keys ... for going to the next match, etc, as you wanted. > 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 f= ind this > pushes a bit too much for binding keys: I=E2=80=99m bad at choices and fi= nding > myself a prefix 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), Then I suggest to simply follow the suggestion in the commentary and use M-s e as prefix. > 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)). Well, I can only predefine bindings, then you have to use these, or you have to make choices... Do you use neo or something like that? Of course you can define bindings on your own, but there are quite a few in different maps needed, so I predefined the commands that can do this for the user for convenience. I thought this would especially help people to try the package quickly. > Why not, by default, be compatible with isearch? I=E2=80=99m not totally= aware > yet of the whole implementation of isearch, but it seems like it=E2=80=99= based > 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. When I wrote el-search, I considered compatibility with isearch, but there are too many requirements for el-search that where incompatible or impossible to do with isearch (matches completely inside matches; interruptible (multi-buffer) search and query-replace, concurrent match count in the background, and many more things). So incompatibility with Isearch is intentional, sorry. Michael.