branch: externals/org
commit 55e8068d6910f2457eb9369171ec8aa91930d270
Author: bruno <[email protected]>
Commit: Ihor Radchenko <[email protected]>
ol: Add support for shortdoc link type
* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.
---
doc/org-manual.org | 11 +++++++++++
etc/ORG-NEWS | 6 ++++++
lisp/ol.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 170eea506a..9121631759 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3393,6 +3393,15 @@ Here is the full set of built-in link types:
Execute a shell command upon activation.
+- =shortdoc= ::
+
+ Link to short documentation summary for an Emacs Lisp function group.
+ [fn::You can run =M-x shortdoc-display-group= to list all known
+ documentation groups.]
+
+ For more information, see [[info:emacs#Name Help][Name Help]]
+ and [[info:elisp#Documentation Groups][Documentation Groups]].
+
For =file:= and =id:= links, you can additionally specify a line
number, or a text search string, separated by =::=. In Org files, you
@@ -3434,6 +3443,8 @@ options:
| irc | =irc:/irc.com/#emacs/bob=
|
| help | =help:org-store-link=
|
| info | =info:org#External links=
|
+| shortdoc | =shortdoc:text-properties=
|
+| | =shortdoc:text-properties::#get-pos-property=
|
| shell | =shell:ls *.org=
|
| elisp | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)
|
| | =elisp:org-agenda= (interactive Elisp command)
|
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4b0b77ca89..95e5ec5699 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -23,6 +23,12 @@ Please send Org bug reports to mailto:[email protected].
# We list the most important features, and the features that may
# require user action to be used.
+** =ol.el=: New =shortdoc= link type
+
+You can now create links to =shortdoc= documentation groups for Emacs
+Lisp functions (see =M-x shortdoc-display-group=). Requires Emacs 28
+or newer.
+
** New and changed options
# Chanes deadling with changing default values of customizations,
diff --git a/lisp/ol.el b/lisp/ol.el
index 20f1b89c06..6e6bc74dcb 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,52 @@ PATH is a symbol name, as a string."
:follow #'org-link--open-help
:store #'org-link--store-help)
+(defvar shortdoc--groups)
+(declare-function shortdoc-display-group "shortdoc"
+ (group &optional function same-window))
+(defun org-link--open-shortdoc (path _)
+ "Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search
+string\"."
+ (string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+ (let* ((group (match-string 1 path))
+ (str (match-string 2 path))
+ (fn (and str
+ (eq ?# (string-to-char str))
+ (intern-soft (substring str 1)))))
+ (condition-case nil
+ (progn
+ (shortdoc-display-group group fn)
+ (and str (not fn) (search-forward str nil t)))
+ (error (user-error "Unknown shortdoc group or malformed link: `%s'"
+ path)))))
+
+(defun org-link--store-shortdoc (&optional _interactive?)
+ "Store \"shortdoc\" type link."
+ (when (derived-mode-p 'org-mode)
+ (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+ (match-string 1 buffer))))
+ (if (and group (assoc (intern-soft group) shortdoc--groups))
+ (org-link-store-props :type "shortdoc"
+ :link (format "shortdoc:%s" group)
+ :description nil)
+ (user-error "Unknown shortdoc group: %s" group)))))
+
+(defun org-link--complete-shortdoc ()
+ "Create a \"shortdoc\" link using completion."
+ (concat "shortdoc:"
+ (completing-read "Shortdoc summary for functions in: "
+ (mapcar #'car shortdoc--groups))))
+
+;; FIXME: Remove the condition when we drop Emacs 27 support.
+;;;; "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+ (org-link-set-parameters "shortdoc"
+ :follow #'org-link--open-shortdoc
+ :store #'org-link--store-shortdoc
+ :complete #'org-link--complete-shortdoc))
+
;;;; "http", "https", "mailto", "ftp", and "news" link types
(dolist (scheme '("ftp" "http" "https" "mailto" "news"))
(org-link-set-parameters scheme