mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
feat(org): new "cmd" link type
This commit is contained in:
@ -142,6 +142,25 @@ exist, and `org-link' otherwise."
|
|||||||
#(" " 0 1 (face (:underline nil)))
|
#(" " 0 1 (face (:underline nil)))
|
||||||
face)))))
|
face)))))
|
||||||
|
|
||||||
|
(defun +org-link--command-keys (command)
|
||||||
|
"Convert command reference TEXT to key binding representation."
|
||||||
|
(let* ((cmd-prefix (mapcar #'reverse
|
||||||
|
(split-string (reverse command) " ")))
|
||||||
|
(cmd (intern-soft (car cmd-prefix)))
|
||||||
|
(prefix (and (cdr cmd-prefix)
|
||||||
|
(string-join (reverse (cdr cmd-prefix)) " ")))
|
||||||
|
(key-binding (where-is-internal cmd nil t))
|
||||||
|
(key-text (if key-binding
|
||||||
|
(key-description key-binding)
|
||||||
|
(format "M-x %s" cmd))))
|
||||||
|
(concat prefix (and prefix " ") key-text)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +org-link--command-link-activate-command (start end command _bracketed-p)
|
||||||
|
(when buffer-read-only
|
||||||
|
(add-text-properties
|
||||||
|
start end (list 'display (+org-link--command-keys command)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +org-link--doom-module-link-follow-fn (module-path _arg)
|
(defun +org-link--doom-module-link-follow-fn (module-path _arg)
|
||||||
(cl-destructuring-bind (&key category module flag)
|
(cl-destructuring-bind (&key category module flag)
|
||||||
@ -282,6 +301,13 @@ exist, and `org-link' otherwise."
|
|||||||
"The key sequence "
|
"The key sequence "
|
||||||
(propertize (+org-link--describe-kbd (org-element-property :path link))
|
(propertize (+org-link--describe-kbd (org-element-property :path link))
|
||||||
'face 'help-key-binding)))
|
'face 'help-key-binding)))
|
||||||
|
("cmd"
|
||||||
|
(concat
|
||||||
|
"The command "
|
||||||
|
(propertize (org-element-property :path link) 'face 'font-lock-function-name-face)
|
||||||
|
" can be invoked with the key sequence "
|
||||||
|
(propertize (+org-link--command-keys (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)
|
||||||
|
@ -559,6 +559,12 @@ relative to `org-directory', unless it is an absolute path."
|
|||||||
:follow (-call-interactively #'describe-face)
|
:follow (-call-interactively #'describe-face)
|
||||||
:activate-func #'+org-link--face-link-activate-face
|
:activate-func #'+org-link--face-link-activate-face
|
||||||
:face '(font-lock-type-face underline))
|
:face '(font-lock-type-face underline))
|
||||||
|
(org-link-set-parameters
|
||||||
|
"cmd"
|
||||||
|
:follow (-call-interactively #'describe-command)
|
||||||
|
:activate-func #'+org-link--command-link-activate-command
|
||||||
|
:face 'help-key-binding
|
||||||
|
:help-echo #'+org-link-doom--help-echo-from-textprop)
|
||||||
(org-link-set-parameters
|
(org-link-set-parameters
|
||||||
"doom-package"
|
"doom-package"
|
||||||
:follow #'+org-link-follow-doom-package-fn
|
:follow #'+org-link-follow-doom-package-fn
|
||||||
|
Reference in New Issue
Block a user