From cd87cc0cc8d3089f44c214ab899649f40d503532 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 26 Jul 2021 16:20:48 -0400 Subject: [PATCH] refactor: remove redundant org code org-collect-keywords does the job here. No need to reinvent the wheel. --- core/autoload/help.el | 5 +++-- modules/lang/org/autoload/org.el | 19 ------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/core/autoload/help.el b/core/autoload/help.el index 8f01f4a01..016a5dc34 100644 --- a/core/autoload/help.el +++ b/core/autoload/help.el @@ -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 diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index f38f3782f..a1d457902 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -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."