mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:07:52 +00:00
ol: Do not save tags when storing a link from a headline
* lisp/ol.el (org-link-heading-search-string): Assume optional argument is already valid. Remove TODO keyword, priority cookie, COMMENT keyword, and tags. (org-link-search): Remove COMMENT keyword. * testing/lisp/test-ol.el (test-ol/store-link): Add tests.
This commit is contained in:
parent
8ac1600974
commit
97e415c5df
28
lisp/ol.el
28
lisp/ol.el
|
@ -1180,17 +1180,14 @@ of matched result, which is either `dedicated' or `fuzzy'."
|
|||
org-outline-regexp-bol
|
||||
org-comment-string
|
||||
(mapconcat #'regexp-quote words ".+")))
|
||||
(cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]")
|
||||
(comment-re (format "\\`%s[ \t]+" org-comment-string)))
|
||||
(cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]"))
|
||||
(goto-char (point-min))
|
||||
(catch :found
|
||||
(while (re-search-forward title-re nil t)
|
||||
(when (equal words
|
||||
(split-string
|
||||
(replace-regexp-in-string
|
||||
cookie-re " "
|
||||
(replace-regexp-in-string
|
||||
comment-re "" (org-get-heading t t t)))))
|
||||
cookie-re " " (org-get-heading t t t t))))
|
||||
(throw :found t)))
|
||||
nil)))
|
||||
(beginning-of-line)
|
||||
|
@ -1242,18 +1239,21 @@ of matched result, which is either `dedicated' or `fuzzy'."
|
|||
|
||||
(defun org-link-heading-search-string (&optional string)
|
||||
"Make search string for the current headline or STRING.
|
||||
When optional argument STRING is non-nil, assume it a headline.
|
||||
|
||||
Search string starts with an asterisk. COMMENT keyword and
|
||||
statistics cookies are removed, and contiguous spaces are packed
|
||||
into a single one."
|
||||
(let ((context
|
||||
into a single one.
|
||||
|
||||
When optional argument STRING is non-nil, assume it a headline,
|
||||
without any TODO or COMMENT keyword, and without any priority
|
||||
cookie or tag."
|
||||
(let ((cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]")
|
||||
(context
|
||||
(if (not string)
|
||||
(concat "*" (org-trim (org-get-heading nil nil nil t)))
|
||||
(let ((s (org-trim string))
|
||||
(comment-re (format "\\`%s[ \t]+" org-comment-string)))
|
||||
(unless (string-prefix-p "*" s) (setq s (concat "*" s)))
|
||||
(replace-regexp-in-string comment-re "" s))))
|
||||
(cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]"))
|
||||
(concat "*" (org-trim (org-get-heading t t t t)))
|
||||
(let ((s (org-trim string)))
|
||||
(if (string-prefix-p "*" s) s
|
||||
(setq s (concat "*" s)))))))
|
||||
(org-link--squeeze-white-spaces
|
||||
(replace-regexp-in-string cookie-re " " context))))
|
||||
|
||||
|
|
|
@ -133,6 +133,32 @@
|
|||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
;; On a headline, remove TODO and COMMENT keywords, priority cookie,
|
||||
;; and tags.
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* TODO H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* COMMENT H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* [#A] H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* H1 :tag:"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
;; On a headline, remove any link from description.
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
|
@ -217,7 +243,7 @@
|
|||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s][file:%s]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(org-store-link nil))))))
|
||||
;; C-u prefix reverses `org-context-in-file-links' in non-Org
|
||||
;; buffer.
|
||||
(should
|
||||
|
@ -237,7 +263,7 @@
|
|||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s][file:%s]]" file file)
|
||||
(org-store-link '(16))))))))
|
||||
(org-store-link '(16))))))))
|
||||
|
||||
|
||||
;;; Radio Targets
|
||||
|
|
Loading…
Reference in a new issue