[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add support for shortdoc link type
From: |
Bruno Cardoso |
Subject: |
Re: [PATCH] Add support for shortdoc link type |
Date: |
Wed, 01 May 2024 13:52:46 -0300 |
Hi Ihor,
Thanks for your comments. See attached the updated patch.
diff --git a/doc/org-manual.org b/doc/org-manual.org
index d66d95a22..c9e307c94 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3372,6 +3372,10 @@ Here is the full set of built-in link types:
Execute a shell command upon activation.
+- =shortdoc= ::
+
+ Link to short documentation summary for a function group.
+
For =file:= and =id:= links, you can additionally specify a line
number, or a text search string, separated by =::=. In Org files, you
@@ -3413,6 +3417,7 @@ options:
| irc | =irc:/irc.com/#emacs/bob=
|
| help | =help:org-store-link=
|
| info | =info:org#External links=
|
+| shortdoc | =shortdoc:text-properties=
|
| 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 8dbc3292d..cfe894448 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1357,6 +1357,10 @@ place the entry in the ~Misc~ category if
~TEXINFO_DIR_CATEGORY~ is missing.
=TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
The old name is obsolete.
+*** =ol.el=: Support for ~shortdoc~ link type
+
+Add support for storing and inserting links to ~shortdoc~ groups.
+
** New functions and changes in function arguments
*** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
diff --git a/lisp/ol.el b/lisp/ol.el
index f6d656982..b7b988581 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1598,6 +1598,30 @@ PATH is a symbol name, as a string."
:follow #'org-link--open-help
:store #'org-link--store-help)
+;;;; "shortdoc" link type
+
+(when (version< "27" emacs-version)
+ (defun org-link--open-shortdoc (group _)
+ "Open a \"shortdoc\" type link.
+GROUP is a symbol name."
+ (if (assoc (intern group) shortdoc--groups)
+ (shortdoc-display-group group)
+ (user-error "Unknown shortdoc group: %s" group)))
+
+ (defun org-link--store-shortdoc (&optional _interactive?)
+ (when (eq major-mode 'shortdoc-mode)
+ (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+ (match-string 1 buffer))))
+ (when (assoc (intern group) shortdoc--groups)
+ (org-link-store-props :type "shortdoc"
+ :link (format "shortdoc:%s" group)
+ :description nil)))))
+
+ (org-link-set-parameters "shortdoc"
+ :follow #'org-link--open-shortdoc
+ :store #'org-link--store-shortdoc))
+
;;;; "http", "https", "mailto", "ftp", and "news" link types
(dolist (scheme '("ftp" "http" "https" "mailto" "news"))
(org-link-set-parameters scheme
On 2024-05-01, 11:00 +0000, Ihor Radchenko <yantar92@posteo.net> wrote:
> Bruno Cardoso <cardoso.bc@gmail.com> writes:
>
>> This patch adds support for "shortdoc:" links.
>
> Thanks!
>
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>
> You also need to document the new built-in link type in the manual.
>
>> +(defun org-link--open-shortdoc (group _)
>> + "Open a \"shortdoc\" type link.
>> +GROUP is a symbol name."
>> + (if (assoc (intern group) shortdoc--groups)
>> + (shortdoc group)
>> + (user-error "Unknown shortdoc group: %s" group)))
>
> `shortdoc' function was only introduced in Emacs 29.
> In Emacs 28, there is only `shortdoc-display-group'.
> Please use the latter function, when `shortdoc' is not available.
>
> In Emacs 27, shortdoc library is not yet present. So, please avoid
> defining shortdoc: link type in Emacs <28.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
- Re: [PATCH] Add support for shortdoc link type, Ihor Radchenko, 2024/05/01
- Re: [PATCH] Add support for shortdoc link type,
Bruno Cardoso <=
- Re: [PATCH] Add support for shortdoc link type, Ihor Radchenko, 2024/05/01
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/01
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/02
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/03
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/04
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/04
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/05
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/05
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/06
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/07