unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Leo Butler <leo.butler@umanitoba.ca>
To: Jean-Christophe Helary <lists@traduction-libre.org>
Cc: help-gnu-emacs@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: non word abbrevs
Date: Mon, 01 Nov 2021 08:49:34 -0500	[thread overview]
Message-ID: <87fssgyoi9.fsf@t14.reltub.ca> (raw)
In-Reply-To: <D862580E-8E5B-4F14-9C0A-BF98A8749931@traduction-libre.org> (Jean-Christophe Helary's message of "Mon, 1 Nov 2021 22:17:28 +0900")

Jean-Christophe Helary <lists@traduction-libre.org> writes:

>> On Nov 1, 2021, at 21:43, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>> 
>>>>>   :regexp "\(<?[-=]>?\)")
>>>>> I must be missing something.
>>>> Hmmm... backslashes?  ;-)
>>>> The above string is the same as "(<?[-=]>?)" (in recentish Emacsen the
>>>> above backslashes should presumably be highlighted in
>>>> a font-lock-warning color for that reason).
>>> 
>>> I'm trying in *scratch* with lisp-mode on a recent "master" and I don't get that...
>> 
>> I just tried it on my end with both `master` and Emacs-27.1
>> 
>>    emacs -Q
>>    :regexp "\(<?[-=]>?\)")
>> 
>> and the two backslashes got the `font-lock-warning-face` (the strings
>> are colored a kind of brick red and the warning is in red so it doesn't
>> stand out as much as I'd like but it's visible).
>
> Ok, I just rebuilt the latest master and emacs -Q shows them... And I am *not* going to dive into my init.el at this time of the day...
>
>>> :regexp "\\([<>=-]+\\)"
>> 
>> And since Emacs will only use the shortest match, it will only use
>> one-char-long matches :-(
>> 
>> Try something like: "[^<>=-]\\([<>=-]+\\)"
>> [ Yes, this shortest match business is a PITA.  ]
>
> My abbrevs are arrows composed of < or > at the tips and - or = with a minimum of 2 characters and a max of 3:
>
> → ⇒
> ← ⇐
> ↔ ⇔
>
> In a different world, I'd try [<>=-]{2,3}
>
> Is that what you mean ?

Try M-x regexp-builder RET

This is a fast way to check your regexps are matching the way you
intend.

Btw, it might be easier to do something like

(regexp-opt '("=>" "==>") "[^>=<]\\(?:")
===> "[^>=<]\\(?:=\\(?:=?>\\)\\)"

Btw, I just checked that regexp with regexp-builder and it matched only
2 strings in this buffer.

FWIW,
Leo



  reply	other threads:[~2021-11-01 13:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31  5:45 non word abbrevs Jean-Christophe Helary
2021-10-31 19:04 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-01  7:57   ` Jean-Christophe Helary
2021-11-01 10:54     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-11-01 12:03     ` Stefan Monnier
2021-11-01 12:13       ` Jean-Christophe Helary
2021-11-01 12:43         ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-01 13:17           ` Jean-Christophe Helary
2021-11-01 13:49             ` Leo Butler [this message]
2021-11-01 14:03             ` tomas
2021-11-01 17:58             ` Stefan Monnier
2021-11-06  8:20         ` Jean-Christophe Helary
2021-11-06 22:32           ` Stefan Monnier
2021-11-07  0:01             ` Jean-Christophe Helary
2021-11-07  3:15               ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-07  3:24                 ` Jean-Christophe Helary
2021-11-07  4:11                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-11-08  5:36                   ` Kevin Vigouroux via Users list for the GNU Emacs text editor
2021-11-08  7:18                     ` Jean-Christophe Helary
2021-11-08 23:29                       ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-07  4:06                 ` Emanuel Berg via Users list for the GNU Emacs text editor

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=87fssgyoi9.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=help-gnu-emacs@gnu.org \
    --cc=lists@traduction-libre.org \
    --cc=monnier@iro.umontreal.ca \
    /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).