emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Auto-activate new <<<radio targets>>>
@ 2021-02-06 22:36 Adam Sneller
  2021-02-08  1:47 ` Kyle Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Sneller @ 2021-02-06 22:36 UTC (permalink / raw)
  To: emacs-orgmode

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

I want to call org-update-radio-target-regexp as soon as org-mode recognises a new <<<radio target>>> has been created (which seems to happen as soon as the third ">" is typed).

What hook can I use to get this done?

Adam Sneller – CCO
MS2 Digital
20 Old Bailey, St Paul's, ​London EC4M 7AN
​adam.sneller@ms2.digital
office: 020 3988 6800
direct: 020 3988 6809
The information in this e-mail and any documents and files transmitted with it are confidential and for the use of the intended recipient only. If you are not the intended recipient, please delete the message and any attachments immediately and notify the sender. Although MS2 Group Limited believes this e-mail and any attachments are free of any virus or other defect which may affect a computer, it is the responsibility of the recipient to ensure that it is virus free and MS2 Group Limited does not accept any responsibility for any loss or damage arising from its use. MS2 Group Limited is registered in England and Wales, company number 10410414. Registered office: 27 Old Gloucester Street, London WC1N 3AX. 'MS2 Digital' is the trading name of MS2 Group Limited.
​
​© 2020 MS2 Group Limited

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

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

* Re: Auto-activate new <<<radio targets>>>
  2021-02-06 22:36 Auto-activate new <<<radio targets>>> Adam Sneller
@ 2021-02-08  1:47 ` Kyle Meyer
  2021-02-08 13:44   ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Kyle Meyer @ 2021-02-08  1:47 UTC (permalink / raw)
  To: Adam Sneller; +Cc: emacs-orgmode

Adam Sneller writes:

> I want to call org-update-radio-target-regexp as soon as org-mode
> recognises a new <<<radio target>>> has been created (which seems to
> happen as soon as the third ">" is typed).
>
> What hook can I use to get this done?

I'm not spotting any hook that could be used for this.  The <<<target>>>
fontification happens through a simple 'regular expression => face'
mapping in org-font-lock-keywords.

You're probably aware of this and it's just not as automatic as you'd
like, but just in case: pressing `C-c C-c' with point on <<<target>>
will call org-update-radio-target-regexp.


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

* Re: Auto-activate new <<<radio targets>>>
  2021-02-08  1:47 ` Kyle Meyer
@ 2021-02-08 13:44   ` John Kitchin
  2021-02-08 17:43     ` Adam Sneller
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2021-02-08 13:44 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Adam Sneller, emacs-orgmode

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

I guess the place to do it is with an advice on org-activate-links. Maybe a
simple after advice would do.

John

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



On Sun, Feb 7, 2021 at 8:48 PM Kyle Meyer <kyle@kyleam.com> wrote:

> Adam Sneller writes:
>
> > I want to call org-update-radio-target-regexp as soon as org-mode
> > recognises a new <<<radio target>>> has been created (which seems to
> > happen as soon as the third ">" is typed).
> >
> > What hook can I use to get this done?
>
> I'm not spotting any hook that could be used for this.  The <<<target>>>
> fontification happens through a simple 'regular expression => face'
> mapping in org-font-lock-keywords.
>
> You're probably aware of this and it's just not as automatic as you'd
> like, but just in case: pressing `C-c C-c' with point on <<<target>>
> will call org-update-radio-target-regexp.
>
>

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

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

* Re: Auto-activate new <<<radio targets>>>
  2021-02-08 13:44   ` John Kitchin
@ 2021-02-08 17:43     ` Adam Sneller
  2021-02-09  5:06       ` Kyle Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Sneller @ 2021-02-08 17:43 UTC (permalink / raw)
  To: John Kitchin; +Cc: Kyle Meyer, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1807 bytes --]

Thanks John! It looks like there is also an org-activate-target-links which may narrow the field a bit. Here is what I have so far:

(defadvice org-activate-target-links (after ad-update-target-links ())
  "Activate radio target links as soon as a new target is created."
  (lambda ()
    (interactive)
    (when (and (org-in-regexp org-target-regexp)
	       (not (org-in-regexp org-target-regexp nil t)))
      (org-update-radio-target-regexp))))
(ad-activate 'org-activate-target-links)

Unfortunately, this is not working for me...

Any ideas?

> On 8 Feb 2021, at 13:44, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>
> I guess the place to do it is with an advice on org-activate-links. Maybe a simple after advice would do.
>
> John
>
> -----------------------------------
> 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 <http://kitchingroup.cheme.cmu.edu/>
>
>
>
> On Sun, Feb 7, 2021 at 8:48 PM Kyle Meyer <kyle@kyleam.com <mailto:kyle@kyleam.com>> wrote:
> Adam Sneller writes:
>
> > I want to call org-update-radio-target-regexp as soon as org-mode
> > recognises a new <<<radio target>>> has been created (which seems to
> > happen as soon as the third ">" is typed).
> >
> > What hook can I use to get this done?
>
> I'm not spotting any hook that could be used for this.  The <<<target>>>
> fontification happens through a simple 'regular expression => face'
> mapping in org-font-lock-keywords.
>
> You're probably aware of this and it's just not as automatic as you'd
> like, but just in case: pressing `C-c C-c' with point on <<<target>>
> will call org-update-radio-target-regexp.
>


[-- Attachment #1.2: Type: text/html, Size: 3712 bytes --]

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

* Re: Auto-activate new <<<radio targets>>>
  2021-02-08 17:43     ` Adam Sneller
@ 2021-02-09  5:06       ` Kyle Meyer
  0 siblings, 0 replies; 5+ messages in thread
From: Kyle Meyer @ 2021-02-09  5:06 UTC (permalink / raw)
  To: Adam Sneller, John Kitchin; +Cc: emacs-orgmode

Adam Sneller writes:

> Thanks John! It looks like there is also an org-activate-target-links
> which may narrow the field a bit. Here is what I have so far:
>
> (defadvice org-activate-target-links (after ad-update-target-links ())
>   "Activate radio target links as soon as a new target is created."
>   (lambda ()
>     (interactive)
>     (when (and (org-in-regexp org-target-regexp)
> 	       (not (org-in-regexp org-target-regexp nil t)))
>       (org-update-radio-target-regexp))))
> (ad-activate 'org-activate-target-links)
>
> Unfortunately, this is not working for me...
>
> Any ideas?

org-activate-target-links _depends_ on org-update-radio-target-regexp
being called to update org-target-link-regexp, so I don't think it's a
candidate for a place to hook into if you want
org-update-radio-target-regexp to be triggered on typing <<<target>>>.


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

end of thread, other threads:[~2021-02-09  5:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 22:36 Auto-activate new <<<radio targets>>> Adam Sneller
2021-02-08  1:47 ` Kyle Meyer
2021-02-08 13:44   ` John Kitchin
2021-02-08 17:43     ` Adam Sneller
2021-02-09  5:06       ` Kyle Meyer

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