emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to handle strings with commas in macros?
@ 2022-04-07 16:29 William Denton
  2022-04-07 16:42 ` Kaushal Modi
  2022-04-07 16:55 ` Eric S Fraga
  0 siblings, 2 replies; 4+ messages in thread
From: William Denton @ 2022-04-07 16:29 UTC (permalink / raw)
  To: emacs-orgmode

I'm using macros to format names in a LaTeX export, like so:

#+latex_header: \newcommand\m[1]{\textsc{#1}}
#+macro: m \m{$1}

Thus

{{{m(William Denton)}}}

becomes

\m{William Denton}

on export and LaTeX will format it.  That works fine.  But in an index of names, 
if I want

{{{m(Denton, William)}}}

then Org takes that as two arguments to the macro, and outputs

\m{Denton}

Is there a way to get around this?

Thanks,

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to handle strings with commas in macros?
  2022-04-07 16:29 How to handle strings with commas in macros? William Denton
@ 2022-04-07 16:42 ` Kaushal Modi
  2022-04-07 19:46   ` William Denton
  2022-04-07 16:55 ` Eric S Fraga
  1 sibling, 1 reply; 4+ messages in thread
From: Kaushal Modi @ 2022-04-07 16:42 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-org list

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

On Thu, Apr 7, 2022 at 12:30 PM William Denton <wtd@pobox.com> wrote:

> I'm using macros to format names in a LaTeX export, like so:
>
> on export and LaTeX will format it.  That works fine.  But in an index of
> names,
> if I want
>
> {{{m(Denton, William)}}}
>
> then Org takes that as two arguments to the macro, and outputs
>
> \m{Denton}
>
> Is there a way to get around this?
>

The comma needs to be backslash escaped.

{{{m(Denton\, William)}}}

Ref: (org) Macro Replacement

> (1) Since commas separate the arguments, commas within arguments have
to be escaped with the backslash character.  So only those backslash
characters before a comma need escaping with another backslash
character.

[-- Attachment #2: Type: text/html, Size: 1127 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to handle strings with commas in macros?
  2022-04-07 16:29 How to handle strings with commas in macros? William Denton
  2022-04-07 16:42 ` Kaushal Modi
@ 2022-04-07 16:55 ` Eric S Fraga
  1 sibling, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2022-04-07 16:55 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-orgmode

On Thursday,  7 Apr 2022 at 12:29, William Denton wrote:
> on export and LaTeX will format it.  That works fine.  But in an index of names,
> if I want
>
> {{{m(Denton, William)}}}

You have to escape the , unfortunately:

{{{m(Denton\, William)}}}

-- 
: Eric S Fraga, with org release_9.5.2-427-g40a348 in Emacs 29.0.50


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to handle strings with commas in macros?
  2022-04-07 16:42 ` Kaushal Modi
@ 2022-04-07 19:46   ` William Denton
  0 siblings, 0 replies; 4+ messages in thread
From: William Denton @ 2022-04-07 19:46 UTC (permalink / raw)
  To: emacs-org list

On 7 April 2022, Kaushal Modi wrote:

> The comma needs to be backslash escaped.
>
> {{{m(Denton\, William)}}}
>
> Ref: (org) Macro Replacement

Aha!  Thanks to you and Eric for pointing this out.  I missed that footnote (and 
I should have tried escaping with a backslash anyway, since that's the solution 
to so many things).

I'd been looking at the documentation on the web site, as I usually do, but the 
pointer to the info page got me looking at that.  I'm going to start referring 
to it first and see how that goes.

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-07 19:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 16:29 How to handle strings with commas in macros? William Denton
2022-04-07 16:42 ` Kaushal Modi
2022-04-07 19:46   ` William Denton
2022-04-07 16:55 ` Eric S Fraga

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).