unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: steve-humphreys@gmx.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: Including tex commands in a list
Date: Fri, 29 Jan 2021 23:24:02 +0100	[thread overview]
Message-ID: <20210129222402.GB4451@tuxteam.de> (raw)
In-Reply-To: <trinity-90aa2b9b-0410-432b-8279-15b6c20d72aa-1611957159263@3c-app-mailcom-bs16>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On Fri, Jan 29, 2021 at 10:52:39PM +0100, steve-humphreys@gmx.com wrote:
> I wantt to make the equivalent to the following, but still find
> difficulty doing it.
> 
> (,(concat "\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>")

There's something missing up there. I'll try with just

  "\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>"

The first four backslashes translate to one escaped backslash:

  (rx "\\" ...)

(two backslashes, because of Lisp string literal syntax)

Now comes a word start ("word-start" or "bow"; I'll go with the
more readable "word-start"):

  (rx "\\" word-start ...)

Next is a group, followed by a word-end:

  (rx "\\" word-start (group ...) word-end)

Within the group, there is an alternative:

  (rx "\\"
    word-start
      (group
        (or ...))
    word-end)

Now the alternative's content:
   
  (rx "\\"
    word-start
      (group
        (or "alpha" "beta" "gamma"))
    word-end)

You can check that by evaluating it in a Emacs Lisp buffer (e.g.
this *scratch* buffer Emacs comes up at start): put point after
the whole expression and hit C-x e. You get:

  "\\\\\\<\\(\\(?:\\(?:alph\\|bet\\|gamm\\)a\\)\\)\\>"

There are some spurious non-capturing groups (?: ...), and it
even factored out the trailing -a from "alpha"... etc., but
should be equivalent.

Does it help?

Cheers
 - t


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      reply	other threads:[~2021-01-29 22:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 23:27 Including tex commands in a list steve-humphreys
2021-01-27 23:01 ` Michael Heerdegen
2021-01-28 13:29   ` steve-humphreys
2021-01-28 14:24     ` Michael Heerdegen
2021-01-28 21:05       ` steve-humphreys
2021-01-28 21:19         ` Michael Heerdegen
2021-01-28 21:50           ` steve-humphreys
2021-01-28 22:12           ` steve-humphreys
2021-01-28 22:17             ` Christopher Dimech
2021-01-28 22:26               ` steve-humphreys
2021-01-28 22:35                 ` steve-humphreys
2021-01-29 12:05                   ` Michael Heerdegen
2021-01-29 12:57                     ` steve-humphreys
2021-01-29 14:00                       ` Michael Heerdegen
2021-01-29 20:46                         ` steve-humphreys
2021-01-29 20:56                           ` Michael Heerdegen
2021-01-29 21:01                             ` steve-humphreys
2021-01-29 21:10                             ` steve-humphreys
2021-01-30 13:36                               ` Michael Heerdegen
2021-01-29 21:45                           ` tomas
2021-01-29 21:52                             ` steve-humphreys
2021-01-29 22:24                               ` tomas [this message]

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=20210129222402.GB4451@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=steve-humphreys@gmx.com \
    /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).