1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-03 08:30:03 +00:00

Fix radio target update

* lisp/org.el (org-update-radio-target-regexp): Properly update cache
  when refreshing regexp.

* testing/lisp/test-org.el (test-org/update-radio-target-regexp): Fix
  test.
This commit is contained in:
Nicolas Goaziou 2014-05-17 11:03:29 +02:00
parent 716bc48744
commit f8b7eb4e20
2 changed files with 20 additions and 13 deletions

View File

@ -6130,11 +6130,15 @@ Also refresh fontification if needed."
"\\)\\(?:$\\|[^[:alnum:]]\\)")))
(unless (equal old-regexp org-target-link-regexp)
;; Clean-up cache.
(when old-regexp
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward old-regexp nil t)
(org-element-cache-refresh (match-beginning 1)))))
(let ((regexp (cond
((not old-regexp) org-target-link-regexp)
((not org-target-link-regexp) old-regexp)
(t (concat old-regexp "\\|" org-target-link-regexp)))))
(when regexp
(org-with-wide-buffer
(goto-char (point-min))
(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)))))

View File

@ -1742,14 +1742,17 @@ Text.
(ert-deftest test-org/update-radio-target-regexp ()
"Test `org-update-radio-target-regexp' specifications."
(org-test-with-temp-text "radio\n\nParagraph\n\nradio"
(save-excursion (goto-char (point-max)) (org-element-context))
(insert "<<<")
(search-forward "o")
(insert ">>>")
(org-update-radio-target-regexp)
(goto-char (point-max))
(org-element-type (org-element-context))))
;; Properly update cache.
(should
(eq 'link
(org-test-with-temp-text "radio\n\nParagraph\n\nradio"
(save-excursion (goto-char (point-max)) (org-element-context))
(insert "<<<")
(search-forward "o")
(insert ">>>")
(org-update-radio-target-regexp)
(goto-char (point-max))
(org-element-type (org-element-context))))))