* Including tex commands in a list
@ 2021-01-26 23:27 steve-humphreys
2021-01-27 23:01 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-26 23:27 UTC (permalink / raw)
To: Help Gnu Emacs
I am including a long list of greek characters (\alpha \beta \gamma) when
using texinfo, and want to inquire how to list them in a multiline expression.
Here I am using one line.
(defconst supinf-greek-keywords
'(("\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>"
(1 'typeface-greek-keywords)))
"Rules to apply font-lock highlighting.")
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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
0 siblings, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-27 23:01 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys@gmx.com writes:
> I am including a long list of greek characters (\alpha \beta \gamma)
> when using texinfo, and want to inquire how to list them in a
> multiline expression. Here I am using one line.
>
> (defconst supinf-greek-keywords
> '(("\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>"
> (1 'typeface-greek-keywords)))
> "Rules to apply font-lock highlighting.")
You mean, in the expression? Like
#+begin_src emacs-lisp
(defconst supinf-greek-keywords
`((,(concat "\\\\\\<\\("
(mapconcat #'identity (list "alpha" "beta" "gamma") "\\|")
"\\)\\>")
(1 'typeface-greek-keywords)))
"Rules to apply font-lock highlighting.")
#+end_src
?
It would be best to use an appropriate `rx' expression instead of
`concat' as above if you know `rx' or want to get used to it. Would
make the result even more readable.
Regards,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-27 23:01 ` Michael Heerdegen
@ 2021-01-28 13:29 ` steve-humphreys
2021-01-28 14:24 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 13:29 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Never came across rx before.
Have used
(defconst crucible-mtksy-keywords
`(;; Greek
(,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
"Delta\\|epsilon\\|varepsilon\\|eta\\|"
"gamma\\|Gamma\\|iota\\|kappa \\|"
"lambda\\|Lambda\\|mu\\|nu\\|"
"omega\\|Omega\\|phi\\|varphi\\|"
"Phi\\|pi\\|varpi\\|Pi\\|"
"psi\\|Psi\\|rho\\|varrho\\|"
"sigma\\|varsigma\\|Sigma\\|tau\\|"
"theta\\|vartheta\\|Theta\\|upsilon\\|"
"Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
(0 'crucible-mtksy-tfc)) ;
It would help if I had an example of using "rx" for this.
> Sent: Thursday, January 28, 2021 at 11:01 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > I am including a long list of greek characters (\alpha \beta \gamma)
> > when using texinfo, and want to inquire how to list them in a
> > multiline expression. Here I am using one line.
> >
> > (defconst supinf-greek-keywords
> > '(("\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>"
> > (1 'typeface-greek-keywords)))
> > "Rules to apply font-lock highlighting.")
>
> You mean, in the expression? Like
>
> #+begin_src emacs-lisp
> (defconst supinf-greek-keywords
> `((,(concat "\\\\\\<\\("
> (mapconcat #'identity (list "alpha" "beta" "gamma") "\\|")
> "\\)\\>")
> (1 'typeface-greek-keywords)))
> "Rules to apply font-lock highlighting.")
> #+end_src
>
> ?
>
> It would be best to use an appropriate `rx' expression instead of
> `concat' as above if you know `rx' or want to get used to it. Would
> make the result even more readable.
>
> Regards,
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 13:29 ` steve-humphreys
@ 2021-01-28 14:24 ` Michael Heerdegen
2021-01-28 21:05 ` steve-humphreys
0 siblings, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-28 14:24 UTC (permalink / raw)
To: steve-humphreys; +Cc: help-gnu-emacs
steve-humphreys@gmx.com writes:
> (defconst crucible-mtksy-keywords
> `(;; Greek
> (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> "gamma\\|Gamma\\|iota\\|kappa \\|"
> "lambda\\|Lambda\\|mu\\|nu\\|"
> "omega\\|Omega\\|phi\\|varphi\\|"
> "Phi\\|pi\\|varpi\\|Pi\\|"
> "psi\\|Psi\\|rho\\|varrho\\|"
> "sigma\\|varsigma\\|Sigma\\|tau\\|"
> "theta\\|vartheta\\|Theta\\|upsilon\\|"
> "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> (0 'crucible-mtksy-tfc)) ;
>
> It would help if I had an example of using "rx" for this.
That would look like this (you want to add the missing greek letter
names):
(defconst crucible-mtksy-keywords
`(;; Greek
(,(rx "\\" word-start
(or "alpha" "beta") ;add the other letters here
word-end)
(0 'crucible-mtksy-tfc))))
The result will be a slightly optimized regexp (equivalent to yours of
course).
If you want to go that way, I think it would also be possible to avoid
the repetition of uncapitalized followed by a capitalized letter name.
HTH,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 14:24 ` Michael Heerdegen
@ 2021-01-28 21:05 ` steve-humphreys
2021-01-28 21:19 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 21:05 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
I am using font lock to highlight keywords in a minor mode.
Have changed from using "concat" to using "rx" as you suggested.
However it does not seem equivalent.
(defconst crucible-mtksy-keywords
`(;; Greek
(,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
"Delta\\|epsilon\\|varepsilon\\|eta\\|"
"gamma\\|Gamma\\|iota\\|kappa \\|"
"lambda\\|Lambda\\|mu\\|nu\\|"
"omega\\|Omega\\|phi\\|varphi\\|"
"Phi\\|pi\\|varpi\\|Pi\\|"
"psi\\|Psi\\|rho\\|varrho\\|"
"sigma\\|varsigma\\|Sigma\\|tau\\|"
"theta\\|vartheta\\|Theta\\|upsilon\\|"
"Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
(0 'crucible-mtksy-tfc)))
"Fontification for letters and symbols.")
(defun crucible-mtksy-tfc ()
"Font-lock setup for mathematical symbols."
(font-lock-flush (point-min) (point-max))
(if crucible-mode
(progn
(font-lock-add-keywords nil crucible-mtksy-keywords t)
(font-lock-add-keywords nil crucible-supinf-font-lock t))
(font-lock-remove-keywords nil crucible-mtksy-keywords)
(crucible-supinf-disable (point-min) (point-max)))
(font-lock-flush (point-min) (point-max)))
> Sent: Friday, January 29, 2021 at 2:24 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: steve-humphreys@gmx.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > (defconst crucible-mtksy-keywords
> > `(;; Greek
> > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > "lambda\\|Lambda\\|mu\\|nu\\|"
> > "omega\\|Omega\\|phi\\|varphi\\|"
> > "Phi\\|pi\\|varpi\\|Pi\\|"
> > "psi\\|Psi\\|rho\\|varrho\\|"
> > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > (0 'crucible-mtksy-tfc)) ;
> >
> > It would help if I had an example of using "rx" for this.
>
> That would look like this (you want to add the missing greek letter
> names):
>
> (defconst crucible-mtksy-keywords
> `(;; Greek
> (,(rx "\\" word-start
> (or "alpha" "beta") ;add the other letters here
> word-end)
> (0 'crucible-mtksy-tfc))))
>
> The result will be a slightly optimized regexp (equivalent to yours of
> course).
>
> If you want to go that way, I think it would also be possible to avoid
> the repetition of uncapitalized followed by a capitalized letter name.
>
> HTH,
>
> Michael.
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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
0 siblings, 2 replies; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-28 21:19 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys@gmx.com writes:
> I am using font lock to highlight keywords in a minor mode.
> Have changed from using "concat" to using "rx" as you suggested.
> However it does not seem equivalent.
>
> (defconst crucible-mtksy-keywords
> `(;; Greek
> (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> "gamma\\|Gamma\\|iota\\|kappa \\|"
> "lambda\\|Lambda\\|mu\\|nu\\|"
> "omega\\|Omega\\|phi\\|varphi\\|"
> "Phi\\|pi\\|varpi\\|Pi\\|"
> "psi\\|Psi\\|rho\\|varrho\\|"
> "sigma\\|varsigma\\|Sigma\\|tau\\|"
> "theta\\|vartheta\\|Theta\\|upsilon\\|"
> "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> (0 'crucible-mtksy-tfc)))
> "Fontification for letters and symbols.")
How does your rx version look like?
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 21:19 ` Michael Heerdegen
@ 2021-01-28 21:50 ` steve-humphreys
2021-01-28 22:12 ` steve-humphreys
1 sibling, 0 replies; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 21:50 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Had made it as you suggested, but I think there has to be some changes
that have to be done in the regexp.
Have used
(defconst crucible-mtksy-keywords
`(;; Greek
(,(rx "\\" word-start
(or "alpha" "beta") ;add the other letters here
word-end)
(0 'crucible-mtksy-tfc))) )
In the expression (1 'crucible-mtksy-tfc), the "1" is an option to not
highlight the starting "\".
> Sent: Friday, January 29, 2021 at 9:19 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > I am using font lock to highlight keywords in a minor mode.
> > Have changed from using "concat" to using "rx" as you suggested.
> > However it does not seem equivalent.
> >
> > (defconst crucible-mtksy-keywords
> > `(;; Greek
> > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > "lambda\\|Lambda\\|mu\\|nu\\|"
> > "omega\\|Omega\\|phi\\|varphi\\|"
> > "Phi\\|pi\\|varpi\\|Pi\\|"
> > "psi\\|Psi\\|rho\\|varrho\\|"
> > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > (0 'crucible-mtksy-tfc)))
> > "Fontification for letters and symbols.")
>
> How does your rx version look like?
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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
1 sibling, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 22:12 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
I know that the command
(rx (or "alpha" "beta"))
produces the generated pattern
"\\(?:alpha\\|beta\\)"
> Sent: Friday, January 29, 2021 at 9:19 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > I am using font lock to highlight keywords in a minor mode.
> > Have changed from using "concat" to using "rx" as you suggested.
> > However it does not seem equivalent.
> >
> > (defconst crucible-mtksy-keywords
> > `(;; Greek
> > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > "lambda\\|Lambda\\|mu\\|nu\\|"
> > "omega\\|Omega\\|phi\\|varphi\\|"
> > "Phi\\|pi\\|varpi\\|Pi\\|"
> > "psi\\|Psi\\|rho\\|varrho\\|"
> > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > (0 'crucible-mtksy-tfc)))
> > "Fontification for letters and symbols.")
>
> How does your rx version look like?
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 22:12 ` steve-humphreys
@ 2021-01-28 22:17 ` Christopher Dimech
2021-01-28 22:26 ` steve-humphreys
0 siblings, 1 reply; 22+ messages in thread
From: Christopher Dimech @ 2021-01-28 22:17 UTC (permalink / raw)
To: steve-humphreys; +Cc: Michael Heerdegen, help-gnu-emacs
You can try to use
(require 'rx)
(rx "\\" "alpha" (or "beta" "gamma") "theta")
> Sent: Friday, January 29, 2021 at 10:12 AM
> From: steve-humphreys@gmx.com
> To: "Michael Heerdegen" <michael_heerdegen@web.de>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> I know that the command
>
> (rx (or "alpha" "beta"))
>
> produces the generated pattern
>
> "\\(?:alpha\\|beta\\)"
>
>
>
>
>
> > Sent: Friday, January 29, 2021 at 9:19 AM
> > From: "Michael Heerdegen" <michael_heerdegen@web.de>
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: Including tex commands in a list
> >
> > steve-humphreys@gmx.com writes:
> >
> > > I am using font lock to highlight keywords in a minor mode.
> > > Have changed from using "concat" to using "rx" as you suggested.
> > > However it does not seem equivalent.
> > >
> > > (defconst crucible-mtksy-keywords
> > > `(;; Greek
> > > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > > "lambda\\|Lambda\\|mu\\|nu\\|"
> > > "omega\\|Omega\\|phi\\|varphi\\|"
> > > "Phi\\|pi\\|varpi\\|Pi\\|"
> > > "psi\\|Psi\\|rho\\|varrho\\|"
> > > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > > (0 'crucible-mtksy-tfc)))
> > > "Fontification for letters and symbols.")
> >
> > How does your rx version look like?
> >
> > Michael.
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 22:17 ` Christopher Dimech
@ 2021-01-28 22:26 ` steve-humphreys
2021-01-28 22:35 ` steve-humphreys
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 22:26 UTC (permalink / raw)
To: Christopher Dimech; +Cc: Michael Heerdegen, help-gnu-emacs
As you pointed out, I misunderstood how to use rx.
However when I applied the change, the keywords are not being
highlighted at all.
`(;; Greek
(, (rx "\\" "alpha" (or "beta" "chi") "delta")
(1 'crucible-mtksy-tfc))
(,(concat "\\\\\\<\\(Delta\\|epsilon\\|varepsilon\\|eta\\|"
"gamma\\|Gamma\\|iota\\|kappa \\|"
"lambda\\|Lambda\\|mu\\|nu\\|"
"omega\\|Omega\\|phi\\|varphi\\|"
"Phi\\|pi\\|varpi\\|Pi\\|"
"psi\\|Psi\\|rho\\|varrho\\|"
"sigma\\|varsigma\\|Sigma\\|tau\\|"
"theta\\|vartheta\\|Theta\\|upsilon\\|"
"Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
(0 'crucible-mtksy-tfc))
> Sent: Friday, January 29, 2021 at 10:17 AM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: steve-humphreys@gmx.com
> Cc: "Michael Heerdegen" <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> You can try to use
>
> (require 'rx)
> (rx "\\" "alpha" (or "beta" "gamma") "theta")
>
>
>
>
> > Sent: Friday, January 29, 2021 at 10:12 AM
> > From: steve-humphreys@gmx.com
> > To: "Michael Heerdegen" <michael_heerdegen@web.de>
> > Cc: help-gnu-emacs@gnu.org
> > Subject: Re: Including tex commands in a list
> >
> > I know that the command
> >
> > (rx (or "alpha" "beta"))
> >
> > produces the generated pattern
> >
> > "\\(?:alpha\\|beta\\)"
> >
> >
> >
> >
> >
> > > Sent: Friday, January 29, 2021 at 9:19 AM
> > > From: "Michael Heerdegen" <michael_heerdegen@web.de>
> > > To: help-gnu-emacs@gnu.org
> > > Subject: Re: Including tex commands in a list
> > >
> > > steve-humphreys@gmx.com writes:
> > >
> > > > I am using font lock to highlight keywords in a minor mode.
> > > > Have changed from using "concat" to using "rx" as you suggested.
> > > > However it does not seem equivalent.
> > > >
> > > > (defconst crucible-mtksy-keywords
> > > > `(;; Greek
> > > > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > > > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > > > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > > > "lambda\\|Lambda\\|mu\\|nu\\|"
> > > > "omega\\|Omega\\|phi\\|varphi\\|"
> > > > "Phi\\|pi\\|varpi\\|Pi\\|"
> > > > "psi\\|Psi\\|rho\\|varrho\\|"
> > > > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > > > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > > > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > > > (0 'crucible-mtksy-tfc)))
> > > > "Fontification for letters and symbols.")
> > >
> > > How does your rx version look like?
> > >
> > > Michael.
> > >
> > >
> > >
> >
> >
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 22:26 ` steve-humphreys
@ 2021-01-28 22:35 ` steve-humphreys
2021-01-29 12:05 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-28 22:35 UTC (permalink / raw)
To: steve-humphreys; +Cc: Michael Heerdegen, help-gnu-emacs
Have also tried to do the following, but it still has remained a problem.
(defconst crucible-mtksy-keywords
`(;; Greek
(,(concat "\\\\\\<"
(rx "\\" "alpha" (or "beta" "chi") "delta")
"\\>")
(0 'crucible-mtksy-tfc)) ; NOTE: Use 0 instead of 1 to also highlight the \
(,(concat "\\\\\\<\\(Delta\\|epsilon\\|varepsilon\\|eta\\|"
"gamma\\|Gamma\\|iota\\|kappa \\|"
"lambda\\|Lambda\\|mu\\|nu\\|"
"omega\\|Omega\\|phi\\|varphi\\|"
"Phi\\|pi\\|varpi\\|Pi\\|"
"psi\\|Psi\\|rho\\|varrho\\|"
"sigma\\|varsigma\\|Sigma\\|tau\\|"
"theta\\|vartheta\\|Theta\\|upsilon\\|"
"Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
(0 'crucible-mtksy-tfc))
> Sent: Friday, January 29, 2021 at 10:26 AM
> From: steve-humphreys@gmx.com
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Michael Heerdegen" <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> As you pointed out, I misunderstood how to use rx.
>
> However when I applied the change, the keywords are not being
> highlighted at all.
>
> `(;; Greek
> (, (rx "\\" "alpha" (or "beta" "chi") "delta")
> (1 'crucible-mtksy-tfc))
> (,(concat "\\\\\\<\\(Delta\\|epsilon\\|varepsilon\\|eta\\|"
> "gamma\\|Gamma\\|iota\\|kappa \\|"
> "lambda\\|Lambda\\|mu\\|nu\\|"
> "omega\\|Omega\\|phi\\|varphi\\|"
> "Phi\\|pi\\|varpi\\|Pi\\|"
> "psi\\|Psi\\|rho\\|varrho\\|"
> "sigma\\|varsigma\\|Sigma\\|tau\\|"
> "theta\\|vartheta\\|Theta\\|upsilon\\|"
> "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> (0 'crucible-mtksy-tfc))
>
>
> > Sent: Friday, January 29, 2021 at 10:17 AM
> > From: "Christopher Dimech" <dimech@gmx.com>
> > To: steve-humphreys@gmx.com
> > Cc: "Michael Heerdegen" <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
> > Subject: Re: Including tex commands in a list
> >
> > You can try to use
> >
> > (require 'rx)
> > (rx "\\" "alpha" (or "beta" "gamma") "theta")
> >
> >
> >
> >
> > > Sent: Friday, January 29, 2021 at 10:12 AM
> > > From: steve-humphreys@gmx.com
> > > To: "Michael Heerdegen" <michael_heerdegen@web.de>
> > > Cc: help-gnu-emacs@gnu.org
> > > Subject: Re: Including tex commands in a list
> > >
> > > I know that the command
> > >
> > > (rx (or "alpha" "beta"))
> > >
> > > produces the generated pattern
> > >
> > > "\\(?:alpha\\|beta\\)"
> > >
> > >
> > >
> > >
> > >
> > > > Sent: Friday, January 29, 2021 at 9:19 AM
> > > > From: "Michael Heerdegen" <michael_heerdegen@web.de>
> > > > To: help-gnu-emacs@gnu.org
> > > > Subject: Re: Including tex commands in a list
> > > >
> > > > steve-humphreys@gmx.com writes:
> > > >
> > > > > I am using font lock to highlight keywords in a minor mode.
> > > > > Have changed from using "concat" to using "rx" as you suggested.
> > > > > However it does not seem equivalent.
> > > > >
> > > > > (defconst crucible-mtksy-keywords
> > > > > `(;; Greek
> > > > > (,(concat "\\\\\\<\\(alpha\\|beta\\|chi\\|delta\\|"
> > > > > "Delta\\|epsilon\\|varepsilon\\|eta\\|"
> > > > > "gamma\\|Gamma\\|iota\\|kappa \\|"
> > > > > "lambda\\|Lambda\\|mu\\|nu\\|"
> > > > > "omega\\|Omega\\|phi\\|varphi\\|"
> > > > > "Phi\\|pi\\|varpi\\|Pi\\|"
> > > > > "psi\\|Psi\\|rho\\|varrho\\|"
> > > > > "sigma\\|varsigma\\|Sigma\\|tau\\|"
> > > > > "theta\\|vartheta\\|Theta\\|upsilon\\|"
> > > > > "Upsilon\\|xi\\|Xi\\|zeta\\)\\>")
> > > > > (0 'crucible-mtksy-tfc)))
> > > > > "Fontification for letters and symbols.")
> > > >
> > > > How does your rx version look like?
> > > >
> > > > Michael.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-28 22:35 ` steve-humphreys
@ 2021-01-29 12:05 ` Michael Heerdegen
2021-01-29 12:57 ` steve-humphreys
0 siblings, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-29 12:05 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys@gmx.com writes:
> Have also tried to do the following, but it still has remained a problem.
>
> (defconst crucible-mtksy-keywords
> `(;; Greek
> (,(concat "\\\\\\<"
> (rx "\\" "alpha" (or "beta" "chi") "delta")
That would match something like \alphabetadelta. I guess that's not
what you want.
If you want to refer to a submatch, e.g. to what is matched by the `or'
subexpression, use an explicit `group'.
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 12:05 ` Michael Heerdegen
@ 2021-01-29 12:57 ` steve-humphreys
2021-01-29 14:00 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-29 12:57 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
> Sent: Saturday, January 30, 2021 at 12:05 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > Have also tried to do the following, but it still has remained a problem.
> >
> > (defconst crucible-mtksy-keywords
> > `(;; Greek
> > (,(concat "\\\\\\<"
> > (rx "\\" "alpha" (or "beta" "chi") "delta")
>
> That would match something like \alphabetadelta. I guess that's not
> what you want.
>
> If you want to refer to a submatch, e.g. to what is matched by the `or'
> subexpression, use an explicit `group'.
Should I still try to use "rx" for my situation?
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 12:57 ` steve-humphreys
@ 2021-01-29 14:00 ` Michael Heerdegen
2021-01-29 20:46 ` steve-humphreys
0 siblings, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-29 14:00 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys@gmx.com writes:
> Should I still try to use "rx" for my situation?
I would do it, it makes the regexp better readable. That's why I
mentioned it. Of course it takes a bit of extra time to learn the
syntax. It's totally ok to go without `rx'.
Regards,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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:45 ` tomas
0 siblings, 2 replies; 22+ messages in thread
From: steve-humphreys @ 2021-01-29 20:46 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
I have not found enough information on how to use "rx".
> Sent: Saturday, January 30, 2021 at 2:00 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > Should I still try to use "rx" for my situation?
>
> I would do it, it makes the regexp better readable. That's why I
> mentioned it. Of course it takes a bit of extra time to learn the
> syntax. It's totally ok to go without `rx'.
>
> Regards,
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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-29 21:45 ` tomas
1 sibling, 2 replies; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-29 20:56 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys@gmx.com writes:
> I have not found enough information on how to use "rx".
In my Emacs version it's described in the manual:
(info "(elisp) Rx Notation")
Do you have that? AFAIR that chapter had been added to Emacs not that
long ago.
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 20:56 ` Michael Heerdegen
@ 2021-01-29 21:01 ` steve-humphreys
2021-01-29 21:10 ` steve-humphreys
1 sibling, 0 replies; 22+ messages in thread
From: steve-humphreys @ 2021-01-29 21:01 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
I am using GNU Emacs 25.2.2 and would not give me any information.
> Sent: Saturday, January 30, 2021 at 8:56 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > I have not found enough information on how to use "rx".
>
> In my Emacs version it's described in the manual:
>
> (info "(elisp) Rx Notation")
>
> Do you have that? AFAIR that chapter had been added to Emacs not that
> long ago.
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
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
1 sibling, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-29 21:10 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Have looked at the Emacs Lisp Manual from the Online Emacs Documentation.
I now understand why you used word-start and word-end, but still need
some serious help to get an equivalent expression for my regexp.
> Sent: Saturday, January 30, 2021 at 8:56 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> steve-humphreys@gmx.com writes:
>
> > I have not found enough information on how to use "rx".
>
> In my Emacs version it's described in the manual:
>
> (info "(elisp) Rx Notation")
>
> Do you have that? AFAIR that chapter had been added to Emacs not that
> long ago.
>
> Michael.
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 20:46 ` steve-humphreys
2021-01-29 20:56 ` Michael Heerdegen
@ 2021-01-29 21:45 ` tomas
2021-01-29 21:52 ` steve-humphreys
1 sibling, 1 reply; 22+ messages in thread
From: tomas @ 2021-01-29 21:45 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
On Fri, Jan 29, 2021 at 09:46:57PM +0100, steve-humphreys@gmx.com wrote:
>
> I have not found enough information on how to use "rx".
The Emacs Lisp manual has a pretty extensive documentation
on it:
34.3.3 The ‘rx’ Structured Regexp Notation
Alternatively, in the Interwebs here [1].
Cheers
[1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 21:45 ` tomas
@ 2021-01-29 21:52 ` steve-humphreys
2021-01-29 22:24 ` tomas
0 siblings, 1 reply; 22+ messages in thread
From: steve-humphreys @ 2021-01-29 21:52 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
I wantt to make the equivalent to the following, but still find
difficulty doing it.
(,(concat "\\\\\\<\\(alpha\\|beta\\|gamma\\)\\>")
> Sent: Saturday, January 30, 2021 at 9:45 AM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Including tex commands in a list
>
> On Fri, Jan 29, 2021 at 09:46:57PM +0100, steve-humphreys@gmx.com wrote:
> >
> > I have not found enough information on how to use "rx".
>
> The Emacs Lisp manual has a pretty extensive documentation
> on it:
>
> 34.3.3 The ‘rx’ Structured Regexp Notation
>
> Alternatively, in the Interwebs here [1].
>
> Cheers
>
> [1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 21:52 ` steve-humphreys
@ 2021-01-29 22:24 ` tomas
0 siblings, 0 replies; 22+ messages in thread
From: tomas @ 2021-01-29 22:24 UTC (permalink / raw)
To: steve-humphreys; +Cc: help-gnu-emacs
[-- 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 --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Including tex commands in a list
2021-01-29 21:10 ` steve-humphreys
@ 2021-01-30 13:36 ` Michael Heerdegen
0 siblings, 0 replies; 22+ messages in thread
From: Michael Heerdegen @ 2021-01-30 13:36 UTC (permalink / raw)
To: steve-humphreys; +Cc: help-gnu-emacs
steve-humphreys@gmx.com writes:
> I now understand why you used word-start and word-end, but still need
> some serious help to get an equivalent expression for my regexp.
And what are your questions?
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2021-01-30 13:36 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).