* help with a regexp
@ 2021-07-15 0:43 John Kitchin
2021-07-15 4:41 ` Timothy
2021-07-15 8:40 ` Stephen Berman
0 siblings, 2 replies; 6+ messages in thread
From: John Kitchin @ 2021-07-15 0:43 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]
Hi all, I could use a bit of help with a regexp. I am trying to fine tune
the org-ref citation regexp to make it orthogonal to org-cite.
I want to recognize these as org-ref links
[[cite:schuett-2018-schnet]]
cite:schuett-2018-schnet
but not
[cite:@schuett-2018-schnet]
so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
right now the cite: in the org-cite syntax is getting flagged as bad cite
link which I want to avoid.
is this doable?
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
[-- Attachment #2: Type: text/html, Size: 1210 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with a regexp
2021-07-15 0:43 help with a regexp John Kitchin
@ 2021-07-15 4:41 ` Timothy
2021-07-15 6:04 ` Jean-Christophe Helary
2021-07-15 8:40 ` Stephen Berman
1 sibling, 1 reply; 6+ messages in thread
From: Timothy @ 2021-07-15 4:41 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
Hi John,
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> Hi all, I could use a bit of help with a regexp. I am trying to fine tune
> the org-ref citation regexp to make it orthogonal to org-cite.
>
> I want to recognize these as org-ref links
>
> [[cite:schuett-2018-schnet]]
> cite:schuett-2018-schnet
>
> but not
>
> [cite:@schuett-2018-schnet]
>
> so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
>
> right now the cite: in the org-cite syntax is getting flagged as bad cite
> link which I want to avoid.
>
> is this doable?
I'd think so. Let me know if https://regex101.com/r/Ud6HVY/1 helps :)
--
Timothy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with a regexp
2021-07-15 4:41 ` Timothy
@ 2021-07-15 6:04 ` Jean-Christophe Helary
0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe Helary @ 2021-07-15 6:04 UTC (permalink / raw)
To: orgmode
> On Jul 15, 2021, at 13:41, Timothy <tecosaur@gmail.com> wrote:
>
>
> Hi John,
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> Hi all, I could use a bit of help with a regexp. I am trying to fine tune
>> the org-ref citation regexp to make it orthogonal to org-cite.
>>
>> I want to recognize these as org-ref links
>>
>> [[cite:schuett-2018-schnet]]
>> cite:schuett-2018-schnet
>>
>> but not
>>
>> [cite:@schuett-2018-schnet]
>>
>> so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
>>
>> right now the cite: in the org-cite syntax is getting flagged as bad cite
>> link which I want to avoid.
>>
>> is this doable?
>
> I'd think so. Let me know if https://regex101.com/r/Ud6HVY/1 helps :)
cite:[^@][A-Za-z0-9_-]+|\[\[cite:[^@][A-Za-z0-9_-]+\]\]
There are no reasons to limit the string after : to ascii.
in isearch I tried:
\[\{2\}cite.*\]\{2\}\|[^\[]cite:[^ \
]*
And it seems to do the job.
--
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with a regexp
2021-07-15 0:43 help with a regexp John Kitchin
2021-07-15 4:41 ` Timothy
@ 2021-07-15 8:40 ` Stephen Berman
2021-07-15 8:46 ` Stephen Berman
2021-07-15 12:58 ` John Kitchin
1 sibling, 2 replies; 6+ messages in thread
From: Stephen Berman @ 2021-07-15 8:40 UTC (permalink / raw)
To: John Kitchin; +Cc: org-mode-email
On Wed, 14 Jul 2021 20:43:24 -0400 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Hi all, I could use a bit of help with a regexp. I am trying to fine tune the org-ref citation regexp to
> make it orthogonal to org-cite.
>
> I want to recognize these as org-ref links
>
> [[cite:schuett-2018-schnet]]
> cite:schuett-2018-schnet
>
> but not
>
> [cite:@schuett-2018-schnet]
>
> so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
>
> right now the cite: in the org-cite syntax is getting flagged as bad cite link which I want to avoid.
>
> is this doable?
For your example this is sufficient (for real usage you probably want to
add more context to the right of 'cite'):
(re-search-forward "\\[\\[cite:\\|[^[]cite:")
Steve Berman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with a regexp
2021-07-15 8:40 ` Stephen Berman
@ 2021-07-15 8:46 ` Stephen Berman
2021-07-15 12:58 ` John Kitchin
1 sibling, 0 replies; 6+ messages in thread
From: Stephen Berman @ 2021-07-15 8:46 UTC (permalink / raw)
To: John Kitchin; +Cc: org-mode-email
On Thu, 15 Jul 2021 10:40:40 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:
> On Wed, 14 Jul 2021 20:43:24 -0400 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>
>> Hi all, I could use a bit of help with a regexp. I am trying to fine tune the org-ref citation regexp to
>> make it orthogonal to org-cite.
>>
>> I want to recognize these as org-ref links
>>
>> [[cite:schuett-2018-schnet]]
>> cite:schuett-2018-schnet
>>
>> but not
>>
>> [cite:@schuett-2018-schnet]
>>
>> so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
>>
>> right now the cite: in the org-cite syntax is getting flagged as bad cite link which I want to avoid.
>>
>> is this doable?
>
> For your example this is sufficient (for real usage you probably want to
> add more context to the right of 'cite'):
>
> (re-search-forward "\\[\\[cite:\\|[^[]cite:")
Or simply:
(re-search-forward "\\[\\[\\|[^[]cite:")
Steve Berman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: help with a regexp
2021-07-15 8:40 ` Stephen Berman
2021-07-15 8:46 ` Stephen Berman
@ 2021-07-15 12:58 ` John Kitchin
1 sibling, 0 replies; 6+ messages in thread
From: John Kitchin @ 2021-07-15 12:58 UTC (permalink / raw)
To: Stephen Berman; +Cc: org-mode-email
Thanks everyone, these are all good suggestions.
I realized though the problem is that org-mode is recognizing something
like [cite:@darby-2018-lonel-atoms] as a cite link because of the cite:
part of it. In fact org-mode seems to recognize all [link:path] as an
org link.
In general that seems ok, but it leads to overlapping syntax with
org-cite and the one org-ref link.
It seems to be a partial solution to remove the cite link from
org-link-parameters, but that isn't ideal to me because older documents
won't work with org-ref that way (most of mine use cite: very
extensively).
The best solution in my opinion would be for org-mode to not recognize
[cite:...] as a link. Other ideas?
Thanks,
Stephen Berman <stephen.berman@gmx.net> writes:
> On Wed, 14 Jul 2021 20:43:24 -0400 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>
>> Hi all, I could use a bit of help with a regexp. I am trying to fine tune the org-ref citation regexp to
>> make it orthogonal to org-cite.
>>
>> I want to recognize these as org-ref links
>>
>> [[cite:schuett-2018-schnet]]
>> cite:schuett-2018-schnet
>>
>> but not
>>
>> [cite:@schuett-2018-schnet]
>>
>> so either 0 or 2 [[ can prefix it to be a cite link in org-ref, but not 1 [.
>>
>> right now the cite: in the org-cite syntax is getting flagged as bad cite link which I want to avoid.
>>
>> is this doable?
>
> For your example this is sufficient (for real usage you probably want to
> add more context to the right of 'cite'):
>
> (re-search-forward "\\[\\[cite:\\|[^[]cite:")
>
> Steve Berman
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
Pronouns: he/him/his
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-15 12:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-15 0:43 help with a regexp John Kitchin
2021-07-15 4:41 ` Timothy
2021-07-15 6:04 ` Jean-Christophe Helary
2021-07-15 8:40 ` Stephen Berman
2021-07-15 8:46 ` Stephen Berman
2021-07-15 12:58 ` John Kitchin
Code repositories for project(s) associated with this public 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).