From c5d7ad94ec2b8aefabbe5cd7f482bf96dab583ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20A=2E=20Gomes?= Date: Sat, 9 Oct 2021 16:23:37 +0300 Subject: [PATCH 52/76] Deprecate org-link-search-must-match-exact-headline. --- lisp/ol.el | 8 +++---- lisp/org-compat.el | 2 ++ lisp/org-lint.el | 2 +- lisp/org-macro.el | 4 ++-- lisp/ox-publish.el | 2 +- lisp/ox.el | 2 +- testing/lisp/test-org.el | 46 ++++++++++++++++++++-------------------- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 4a26efc2d..1e3eab6f2 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -336,7 +336,7 @@ another window." (const wl) (const wl-other-frame))))) -(defcustom org-link-search-must-match-exact-headline 'query-to-create +(defcustom org-link-search-must-match-exact-heading 'query-to-create "Non-nil means internal fuzzy links can only match headings. When nil, the a fuzzy link may point to a target or a named @@ -1216,9 +1216,9 @@ of matched result, which is either `dedicated' or `fuzzy'." (beginning-of-line) (setq type 'dedicated)) ;; Offer to create non-existent heading depending on - ;; `org-link-search-must-match-exact-headline'. + ;; `org-link-search-must-match-exact-heading'. ((and (derived-mode-p 'org-mode) - (eq org-link-search-must-match-exact-headline 'query-to-create) + (eq org-link-search-must-match-exact-heading 'query-to-create) (yes-or-no-p "No match - create this as a new heading? ")) (goto-char (point-max)) (unless (bolp) (newline)) @@ -1228,7 +1228,7 @@ of matched result, which is either `dedicated' or `fuzzy'." ;; Only headings are looked after. No need to process ;; further: throw an error. ((and (derived-mode-p 'org-mode) - (or starred org-link-search-must-match-exact-headline)) + (or starred org-link-search-must-match-exact-heading)) (goto-char origin) (error "No match for fuzzy expression: %s" normalized)) ;; Regular text search. diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 51d13791e..e7e057a56 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -402,6 +402,8 @@ Counting starts at 1." 'org-latex-format-heading-function "9.5") (define-obsolete-function-alias 'org-latex-headline 'org-latex-heading "9.5") +(define-obsolete-variable-alias 'org-link-search-must-match-exact-headline + 'org-link-search-must-match-exact-heading "9.5") (define-obsolete-face-alias 'org-headline-done 'org-heading-done "9.5") (define-obsolete-face-alias 'org-headline-todo 'org-heading-todo "9.5") diff --git a/lisp/org-lint.el b/lisp/org-lint.el index ec5859a92..619efbc7b 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -625,7 +625,7 @@ in description" (let* ((visiting (if file (find-buffer-visiting file) (current-buffer))) (buffer (or visiting (find-file-noselect file))) - (org-link-search-must-match-exact-headline t)) + (org-link-search-must-match-exact-heading t)) (unwind-protect (with-current-buffer buffer (when (and search diff --git a/lisp/org-macro.el b/lisp/org-macro.el index b8d337341..28ffc23af 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -68,7 +68,7 @@ (declare-function vc-call "vc-hooks" (fun file &rest args) t) (declare-function vc-exec-after "vc-dispatcher" (code)) -(defvar org-link-search-must-match-exact-headline) +(defvar org-link-search-must-match-exact-heading) ;;; Variables @@ -320,7 +320,7 @@ by `org-link-search', or the empty string." (save-excursion (when (org-string-nw-p location) (condition-case _ - (let ((org-link-search-must-match-exact-headline t)) + (let ((org-link-search-must-match-exact-heading t)) (org-link-search location nil t)) (error (error "Macro property failed: cannot find location %s" location)))) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 08052a96b..235b41485 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -1172,7 +1172,7 @@ references with `org-export-get-reference'." (substring search 1) (with-current-buffer (find-file-noselect file) (org-with-point-at 1 - (let ((org-link-search-must-match-exact-headline t)) + (let ((org-link-search-must-match-exact-heading t)) (condition-case err (org-link-search search nil t) (error diff --git a/lisp/ox.el b/lisp/ox.el index 60f9527dc..2672650da 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3340,7 +3340,7 @@ Return a string of lines to be included in the format expected by (let ((org-inhibit-startup t)) (org-mode))) (condition-case err ;; Enforce consistent search. - (let ((org-link-search-must-match-exact-headline nil)) + (let ((org-link-search-must-match-exact-heading nil)) (org-link-search location)) (error (error "%s for %s::%s" (error-message-string err) file location))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 202e5cb16..04d92314d 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1247,7 +1247,7 @@ (should (org-test-with-temp-text "Link [[target]] <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) (should-not @@ -1261,13 +1261,13 @@ (should (org-test-with-temp-text "Link [[target][/desciption/]] <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) (should-not (org-test-with-temp-text "Link [[target]] <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) ;; When `org-return-follows-link' is non-nil, tolerate links and @@ -1275,7 +1275,7 @@ (should (org-test-with-temp-text "# Comment [[target]]\n <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) (should-not @@ -1285,7 +1285,7 @@ (should-not (org-test-with-temp-text "# Comment [[target]]\n <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) ;; Non-nil `org-return-follows-link' ignores read-only state of @@ -1293,7 +1293,7 @@ (should (org-test-with-temp-text "Link [[target]] <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (setq buffer-read-only t) (call-interactively #'org-return)) (looking-at-p "<>"))) @@ -1302,14 +1302,14 @@ (org-test-with-temp-text "[[target][This is a very\n long description]]\n <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) (should-not (org-test-with-temp-text "[[target][This is a very\n long description]]\n <>" (let ((org-return-follows-link t) - (org-link-search-must-match-exact-headline nil)) + (org-link-search-must-match-exact-heading nil)) (org-return)) (looking-at-p "<>"))) ;; However, do not open link when point is in a table. @@ -2703,37 +2703,37 @@ SCHEDULED: <2014-03-04 tue.>" (should (org-test-with-temp-text "#+NAME: Test\n|a|b|\n<>\n* Test\n[[Test]]" - (let ((org-link-search-must-match-exact-headline nil)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point)) (looking-at "<>"))) ;; Then fuzzy link points to an element with a given name. (should (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]" - (let ((org-link-search-must-match-exact-headline nil)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point)) (looking-at "#\\+NAME: Test"))) ;; A target still lead to a matching heading otherwise. (should (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]" - (let ((org-link-search-must-match-exact-headline nil)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point)) (looking-at "\\* Head2"))) ;; With a leading star in link, enforce heading match. (should (org-test-with-temp-text "* Test\n<>\n[[*Test]]" - (let ((org-link-search-must-match-exact-headline nil)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point)) (looking-at "\\* Test"))) ;; With a leading star in link, enforce exact heading match, even - ;; with `org-link-search-must-match-exact-headline' set to nil. + ;; with `org-link-search-must-match-exact-heading' set to nil. (should-error (org-test-with-temp-text "* Test 1\nFoo Bar\n[[*Test]]" - (let ((org-link-search-must-match-exact-headline nil)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point)))) - ;; Handle non-nil `org-link-search-must-match-exact-headline'. + ;; Handle non-nil `org-link-search-must-match-exact-heading'. (should (org-test-with-temp-text "* Test\nFoo Bar\n[[Test]]" - (let ((org-link-search-must-match-exact-headline t)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading t)) (org-open-at-point)) (looking-at "\\* Test"))) (should (org-test-with-temp-text "* Test\nFoo Bar\n[[*Test]]" - (let ((org-link-search-must-match-exact-headline t)) (org-open-at-point)) + (let ((org-link-search-must-match-exact-heading t)) (org-open-at-point)) (looking-at "\\* Test"))) ;; Heading match should not care about spaces, cookies, TODO ;; keywords, priorities, and tags. However, TODO keywords are @@ -2743,13 +2743,13 @@ SCHEDULED: <2014-03-04 tue.>" "** TODO [#A] [/] Test [1/2] [33%] 1 \t 2 [%] :work:urgent: ")) (org-test-with-temp-text (concat first-line "\nFoo Bar\n[[*Test 1 2]]") - (let ((org-link-search-must-match-exact-headline nil) + (let ((org-link-search-must-match-exact-heading nil) (org-todo-regexp "TODO")) (org-open-at-point)) (looking-at (regexp-quote first-line))))) (should-error (org-test-with-temp-text "** todo Test 1 2\nFoo Bar\n[[*Test 1 2]]" - (let ((org-link-search-must-match-exact-headline nil) + (let ((org-link-search-must-match-exact-heading nil) (org-todo-regexp "TODO")) (org-open-at-point)))) ;; Heading match should still be exact. @@ -2758,12 +2758,12 @@ SCHEDULED: <2014-03-04 tue.>" ** TODO [#A] [/] Test [1/2] [33%] 1 \t 2 [%] :work:urgent: Foo Bar [[*Test 1]]" - (let ((org-link-search-must-match-exact-headline nil) + (let ((org-link-search-must-match-exact-heading nil) (org-todo-regexp "TODO")) (org-open-at-point)))) (should (org-test-with-temp-text "* Test 1 2 3\n** Test 1 2\n[[*Test 1 2]]" - (let ((org-link-search-must-match-exact-headline nil) + (let ((org-link-search-must-match-exact-heading nil) (org-todo-regexp "TODO")) (org-open-at-point)) (looking-at-p (regexp-quote "** Test 1 2")))) @@ -2789,7 +2789,7 @@ Foo Bar (goto-char (point-max)) (insert (format "[[file:%s::line1 line2]]" file)) (beginning-of-line) - (let ((org-link-search-must-match-exact-headline nil)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point 0)) (looking-at-p "line1")))) (should @@ -2798,7 +2798,7 @@ Foo Bar (goto-char (point-max)) (insert (format "[[file:%s::line1 line2]]" file)) (beginning-of-line) - (let ((org-link-search-must-match-exact-headline nil)) + (let ((org-link-search-must-match-exact-heading nil)) (org-open-at-point 0)) (looking-at-p "line1"))))) -- 2.33.0