refactor: remove redundant org code

org-collect-keywords does the job here. No need to reinvent the wheel.
This commit is contained in:
Henrik Lissner 2021-07-26 16:20:48 -04:00
parent fd844ea18d
commit cd87cc0cc8
2 changed files with 3 additions and 21 deletions

View file

@ -126,11 +126,12 @@ selection of all minor-modes, active or not."
(<= level depth))
(or (null tags)
(not (string-match-p ":TOC" tags))))
(let ((path (org-get-outline-path)))
(let ((path (org-get-outline-path))
(title (org-collect-keywords '("TITLE") '("TITLE"))))
(list (string-join
(list (string-join
(append (when include-files
(list (or (+org-get-global-property "TITLE")
(list (or (cdr (assoc "TITLE" title))
(file-relative-name (buffer-file-name)))))
path
(when text

View file

@ -86,25 +86,6 @@
(not (evil-emacs-state-p)))
(evil-insert 1))))
(defun +org--get-property (name &optional bound)
(save-excursion
(let ((re (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name))))
(goto-char (point-min))
(when (re-search-forward re bound t)
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))))
;;;###autoload
(defun +org-get-global-property (name &optional file bound)
"Get a document property named NAME (string) from an org FILE (defaults to
current file). Only scans first 2048 bytes of the document."
(unless bound
(setq bound 256))
(if file
(with-temp-buffer
(insert-file-contents-literally file nil 0 bound)
(+org--get-property name))
(+org--get-property name bound)))
;;;###autoload
(defun +org-get-todo-keywords-for (&optional keyword)
"Returns the list of todo keywords that KEYWORD belongs to."