Hacker News new | ask | show | jobs
by phforms 589 days ago
I couldn’t find the command you mentioned “org-insert-radio-target-brackets” in my Emacs and it doesn’t appear to be in the manual[1] either. But of course it is very trivial to write, in case anyone else needs this:

  (defun org-insert-radio-target-brackets (start end)
    "Wraps a region with angular brackets to create a radio target."
    (interactive "r")
    (save-excursion
      (goto-char end)
      (insert ">>>")
      (goto-char start)
      (insert "<<<")))

  (keymap-set org-mode-map "C-c n r" #'org-insert-radio-target-brackets)

[1]: https://orgmode.org/manual/Radio-Targets.html
1 comments

Apologies, you're right - this was a function I'd forgotten that I'd defined myself! The main thing I would add to your definition is to finish with org-update-radio-target-regexp which does what C-c C-c would otherwise do in this context.

Here's how I defined it.

  (defun org-insert-radio-target-brackets (&optional arg)
    "Surround selected text with Org Radio Target angle brackets (eg. <<<arg>>>) and then find and update all radio targets"
    (interactive)
    (progn
      (insert-pair arg "<<<" ">>>")
      (org-update-radio-target-regexp)))
Good idea to update the radio targets along with the wrapping. Also, I didn’t know `insert-pair` exists, could have saved me some typing. :)