Function: org-update-radio-target-regexp
org-update-radio-target-regexp is an autoloaded, interactive and
byte-compiled function defined in ol.el.gz.
Signature
(org-update-radio-target-regexp)
Documentation
Find all radio targets in this file and update the regular expression.
Also refresh fontification if needed.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/ol.el.gz
;;;###autoload
(defun org-update-radio-target-regexp ()
"Find all radio targets in this file and update the regular expression.
Also refresh fontification if needed."
(interactive)
(let ((old-regexp org-target-link-regexp)
;; Some languages, e.g., Chinese, do not use spaces to
;; separate words. Also allow to surround radio targets with
;; line-breakable characters.
(before-re "\\(?:^\\|[^[:alnum:]]\\|\\c|\\)\\(")
(after-re "\\)\\(?:$\\|[^[:alnum:]]\\|\\c|\\)")
(targets
(org-with-wide-buffer
(goto-char (point-min))
(let (rtn)
(while (re-search-forward org-radio-target-regexp nil t)
;; Make sure point is really within the object.
(backward-char)
(let ((obj (org-element-context)))
(when (eq (org-element-type obj) 'radio-target)
(cl-pushnew (org-element-property :value obj) rtn
:test #'equal))))
rtn))))
(setq targets
(sort targets
(lambda (a b)
(> (length a) (length b)))))
(setq org-target-link-regexp
(and targets
(concat before-re
(mapconcat
(lambda (x)
(replace-regexp-in-string
" +" "\\s-+" (regexp-quote x) t t))
targets
"\\|")
after-re)))
(unless (equal old-regexp org-target-link-regexp)
;; Clean-up cache.
(let ((regexp (cond ((not old-regexp) org-target-link-regexp)
((not org-target-link-regexp) old-regexp)
(t
(concat before-re
(mapconcat
(lambda (re)
(substring re (length before-re)
(- (length after-re))))
(list old-regexp org-target-link-regexp)
"\\|")
after-re)))))
(when (and (featurep 'org-element)
(not (bound-and-true-p org-mode-loading)))
(org-with-point-at 1
(while (re-search-forward regexp nil t)
(org-element-cache-refresh (match-beginning 1))))))
;; Re fontify buffer.
(when (memq 'radio org-highlight-links)
(org-restart-font-lock)))))