refactor(org): use new :help-echo for kbd link
This commit is contained in:
parent
14bf870025
commit
825458e039
2 changed files with 12 additions and 22 deletions
|
@ -277,6 +277,11 @@ exist, and `org-link' otherwise."
|
||||||
(if (not buffer-read-only)
|
(if (not buffer-read-only)
|
||||||
(format "LINK: %s" (org-element-property :raw-link link))
|
(format "LINK: %s" (org-element-property :raw-link link))
|
||||||
(pcase (org-element-property :type 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"
|
("doom-package"
|
||||||
(concat
|
(concat
|
||||||
(propertize "Emacs package " 'face 'bold)
|
(propertize "Emacs package " 'face 'bold)
|
||||||
|
|
|
@ -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-docs" 'doom-docs-dir)
|
||||||
(+org-define-basic-link "doom-modules" 'doom-modules-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
|
;; Add "lookup" links for packages and keystrings; useful for Emacs
|
||||||
;; documentation -- especially Doom's!
|
;; documentation -- especially Doom's!
|
||||||
(letf! ((defun -call-interactively (fn)
|
(letf! ((defun -call-interactively (fn)
|
||||||
(lambda (path _prefixarg)
|
(lambda (path _prefixarg)
|
||||||
(funcall
|
(funcall
|
||||||
fn (or (intern-soft path)
|
fn (or (intern-soft path)
|
||||||
(user-error "Can't find documentation for %S" 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)))))
|
|
||||||
(org-link-set-parameters
|
(org-link-set-parameters
|
||||||
"kbd"
|
"kbd"
|
||||||
:follow (lambda (_) (minibuffer-message "%s" (+org-display-link-in-eldoc-a)))
|
:follow (lambda (ev)
|
||||||
:help-echo #'+org-link-read-kbd-at-point
|
(interactive "e")
|
||||||
:face 'help-key-binding
|
(minibuffer-message "%s" (+org-link-doom--help-echo-from-textprop
|
||||||
:eldoc (-eldoc-fn "Key sequence" 'help-key-binding))
|
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
|
(org-link-set-parameters
|
||||||
"var"
|
"var"
|
||||||
:follow (-call-interactively #'helpful-variable)
|
:follow (-call-interactively #'helpful-variable)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue