From 24f98d49ecd64d853d59e16e8783be5d393701eb Mon Sep 17 00:00:00 2001 From: TEC Date: Mon, 26 Sep 2022 02:39:26 +0800 Subject: [PATCH] tweak(org): have doom links use path for info --- modules/lang/org/autoload/org-link.el | 26 ++++++++++++-------------- modules/lang/org/config.el | 9 ++++----- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/modules/lang/org/autoload/org-link.el b/modules/lang/org/autoload/org-link.el index e91338108..eed9a6914 100644 --- a/modules/lang/org/autoload/org-link.el +++ b/modules/lang/org/autoload/org-link.el @@ -77,36 +77,36 @@ exist, and `org-link' otherwise." keystr t t))) keystr) -(defun +org-link--read-module-link (link) +(defun +org-link--read-module-spec (module-spec-str) (cl-destructuring-bind (category &optional module flag) - (let ((desc (+org-link-read-desc-at-point link))) - (if (string-prefix-p "+" (string-trim-left desc)) - (list nil nil (intern desc)) - (mapcar #'intern (split-string desc " " nil)))) + (if (string-prefix-p "+" (string-trim-left module-spec-str)) + (list nil nil (intern module-spec-str)) + (mapcar #'intern (split-string module-spec-str " " nil))) (list :category category :module module :flag flag))) ;;;###autoload -(defun +org-link--doom-module-link-face-fn (link) +(defun +org-link--doom-module-link-face-fn (module-path) (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-link link) + (+org-link--read-module-spec module-path) (if (doom-module-locate-path category module) `(:inherit org-priority :weight bold) 'error))) + ;;;###autoload -(defun +org-link-follow-doom-module-fn (link) +(defun +org-link-follow-doom-module-fn (module-path _prefixarg) "TODO" (cl-destructuring-bind (&key category module flag) - (+org-link--read-module-link link) + (+org-link--read-module-spec module-path) (when category (let ((doom-modules-dirs (list doom-modules-dir))) (if-let* ((path (doom-module-locate-path category module)) (path (or (car (doom-glob path "README.org")) path))) (find-file path) - (user-error "Can't find Doom module '%s'" link)))) + (user-error "Can't find Doom module '%s'" module-path)))) (when flag (goto-char (point-min)) (when (and (re-search-forward "^\\*+ \\(?:TODO \\)?Module flags") @@ -118,11 +118,9 @@ exist, and `org-link' otherwise." (recenter))))) ;;;###autoload -(defun +org-link-follow-doom-package-fn (link) +(defun +org-link-follow-doom-package-fn (pkg _prefixarg) "TODO" - (doom/describe-package - (intern-soft - (+org-link-read-desc-at-point link)))) + (doom/describe-package (intern-soft pkg))) ;; diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 0ee7b81e7..2d94813fd 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -542,11 +542,10 @@ relative to `org-directory', unless it is an absolute path." ;; Add "lookup" links for packages and keystrings; useful for Emacs ;; documentation -- especially Doom's! (letf! ((defun -call-interactively (fn) - (lambda (link) - (let ((desc (+org-link-read-desc-at-point link))) - (funcall - fn (or (intern-soft desc) - (user-error "Can't find documentation for %S" desc)))))) + (lambda (path _prefixarg) + (funcall + fn (or (intern-soft path) + (user-error "Can't find documentation for %S" path))))) (defun -eldoc-fn (label face) (lambda (context) (format "%s %s"