From 825458e03950455d6aa4ab6ff76aa0966487d0a4 Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 19 Feb 2023 00:22:52 +0800 Subject: [PATCH] refactor(org): use new :help-echo for kbd link --- modules/lang/org/autoload/org-link.el | 5 +++++ modules/lang/org/config.el | 29 +++++++-------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/modules/lang/org/autoload/org-link.el b/modules/lang/org/autoload/org-link.el index 83953d0b1..5cd6f3a51 100644 --- a/modules/lang/org/autoload/org-link.el +++ b/modules/lang/org/autoload/org-link.el @@ -277,6 +277,11 @@ exist, and `org-link' otherwise." (if (not buffer-read-only) (format "LINK: %s" (org-element-property :raw-link link)) (pcase (org-element-property :type link) + ("kbd" + (concat + "The key sequence " + (propertize (+org-link--describe-kbd (org-element-property :path link)) + 'face 'help-key-binding))) ("doom-package" (concat (propertize "Emacs package " 'face 'bold) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index e81db7175..27f6fff2e 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -529,36 +529,21 @@ relative to `org-directory', unless it is an absolute path." (+org-define-basic-link "doom-docs" 'doom-docs-dir) (+org-define-basic-link "doom-modules" 'doom-modules-dir) - (defadvice! +org-display-link-in-eldoc-a (&rest _) - "Display full link in minibuffer when cursor/mouse is over it." - :before-until #'org-eldoc-documentation-function - (when-let (context (org-element-context)) - (if-let ((type (org-element-property :type context)) - (eldocfn (org-link-get-parameter type :eldoc))) - (funcall eldocfn context) - (when-let (raw-link (org-element-property :raw-link context)) - (format "Link: %s" raw-link))))) - ;; Add "lookup" links for packages and keystrings; useful for Emacs ;; documentation -- especially Doom's! (letf! ((defun -call-interactively (fn) (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" - (propertize (format "%s:" label) 'face 'bold) - (propertize (+org-link-read-desc-at-point - (org-element-property :path context) context) - 'face face))))) + (user-error "Can't find documentation for %S" path)))))) (org-link-set-parameters "kbd" - :follow (lambda (_) (minibuffer-message "%s" (+org-display-link-in-eldoc-a))) - :help-echo #'+org-link-read-kbd-at-point - :face 'help-key-binding - :eldoc (-eldoc-fn "Key sequence" 'help-key-binding)) + :follow (lambda (ev) + (interactive "e") + (minibuffer-message "%s" (+org-link-doom--help-echo-from-textprop + nil (current-buffer) (posn-point (event-start ev))))) + :help-echo #'+org-link-doom--help-echo-from-textprop + :face 'help-key-binding) (org-link-set-parameters "var" :follow (-call-interactively #'helpful-variable)