diff options
author | Nick Dokos <ndokos@redhat.com> | 2020-07-06 21:49:41 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-07-07 23:37:54 -0400 |
commit | bc4fa8a008aeb718c3d2788d70db935a917af1e7 (patch) | |
tree | 778422624728c7a002b46029cf886225175110e6 | |
parent | 353e8cc2b721c720d283a5dae0078fc27893d349 (diff) | |
download | org-mode-bc4fa8a008aeb718c3d2788d70db935a917af1e7.tar.gz |
org: add property names from #+PROPERTY keywords to completion list
* lisp/org.el (org-buffer-property-keys): Enhance the completion list
with property names from #+PROPERTY keywords, not just property
drawers. Also, for each xxx_ALL property, make sure that the bare xxx
property is added too.
* testing/lisp/test-org.el (test-org/buffer-property-keys): Add test
cases for #+PROPERTY keywords and also for xxx_ALL --> xxx properties.
See https://emacs.stackexchange.com/questions/59448/ for details.
Modified-by: Kyle Meyer <kyle@kyleam.com>
Cosmetic tweaks to _ALL stripping.
-rw-r--r-- | lisp/org.el | 15 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 21 |
2 files changed, 34 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el index 4a1a83d..8bc2478 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13084,7 +13084,10 @@ COLUMN formats in the current buffer." (props (append (and specials org-special-properties) (and defaults (cons org-effort-property org-default-properties)) - nil))) + ;; Get property names from #+PROPERTY keywords as well + (mapcar (lambda (s) + (nth 0 (split-string s))) + (cdar (org-collect-keywords '("PROPERTY"))))))) (org-with-wide-buffer (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) @@ -13132,7 +13135,15 @@ COLUMN formats in the current buffer." (let ((p (match-string-no-properties 1 value))) (unless (member-ignore-case p org-special-properties) (push p props)))))))))) - (sort (delete-dups props) (lambda (a b) (string< (upcase a) (upcase b)))))) + (sort (delete-dups + (append props + ;; for each xxx_ALL property, make sure the bare + ;; xxx property is also included + (delq nil (mapcar (lambda (p) + (and (string-match-p "._ALL\\'" p) + (substring p 0 -4))) + props)))) + (lambda (a b) (string< (upcase a) (upcase b)))))) (defun org-property-values (key) "List all non-nil values of property KEY in current buffer." diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 30a8067..61e642d 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -5409,6 +5409,27 @@ Paragraph<point>" (equal '("A") (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:A+: 2\n:END:" (org-buffer-property-keys)))) + ;; Add bare property if xxx_ALL property is there + (should + (equal '("A" "B" "B_ALL") + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:A+: 2\n:B_ALL: foo bar\n:END:" + (org-buffer-property-keys)))) + ;; Add bare property if xxx_ALL property is there - check dupes + (should + (equal '("A" "B" "B_ALL") + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:B: 2\n:B_ALL: foo bar\n:END:" + (org-buffer-property-keys)))) + ;; Retrieve properties from #+PROPERTY keyword lines + (should + (equal '("A" "C") + (org-test-with-temp-text "#+PROPERTY: C foo\n* H\n:PROPERTIES:\n:A: 1\n:A+: 2\n:END:" + (org-buffer-property-keys)))) + ;; Retrieve properties from #+PROPERTY keyword lines - make sure an _ALL property also + ;; adds the bare property + (should + (equal '("A" "C" "C_ALL") + (org-test-with-temp-text "#+PROPERTY: C_ALL foo bar\n* H\n:PROPERTIES:\n:A: 1\n:A+: 2\n:END:" + (org-buffer-property-keys)))) ;; With non-nil COLUMNS, extract property names from columns. (should (equal '("A" "B") |