[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: |
Sat, 11 May 2024 13:58:41 -0300 |
On 2024-05-10, 18:09 +0700, Max Nikulin <manikulin@gmail.com> wrote:
> Thank you for the explanation. Reading "lists all" I expected something
> like list of all info manuals in the case of M-x info RET when there are
> no info buffers yet.
I see. I replaced the term "lists all" with "shows all" to avoid this confusion.
> The following garbage in - garbage out case is a bit confusing:
> <shortdoc::*file>
> => "No such documentation group "
Fixed the error handling and the error message.
> Bruno, has you signed the copyright form? This patch is above the
> TINYCHANGE limit.
> <https://orgmode.org/worg/org-contribute.html#copyright>
I haven't yet. Will be glad to.
> It will be a bit less work for the maintainer if you attach result of
> "git format-patch" command. It adds email-like headers allowing to
> properly set commit author.
The attached patch is now in this format.
>From 57ab6be64e227fcab24ad4c5b84873ed4e946cff Mon Sep 17 00:00:00 2001
From: Bruno Cardoso <cardoso.bc@gmail.com>
Date: Sat, 11 May 2024 13:42:56 -0300
Subject: [PATCH] Add support for shortdoc link type
ol.el: 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 | 5 +++++
lisp/ol.el | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index f9d4c9a3f..8e99652b5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,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.
+ Since Emacs 28, user command ~shortdoc-display-group~ shows 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
@@ -3423,6 +3432,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 36eeddda1..9b7ba96ba 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1428,6 +1428,11 @@ 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= documentation
+groups for Emacs Lisp functions.
+
** 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 3d64b41b0..6b84957f4 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,7 +1582,47 @@ PATH is a symbol name, as a string."
:follow #'org-link--open-help
:store #'org-link--store-help)
+;;;; "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+ (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 (message "Unknown shortdoc group or malformed link: `%s'"
+ path)))))
+
+ (defun org-link--store-shortdoc (&optional _interactive?)
+ "Store \"shortdoc\" type link."
+ (when (eq major-mode 'shortdoc-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))))
+
+ (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
--
2.45.0
- Re: [PATCH] Add support for shortdoc link type, (continued)
- 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
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/08
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/08
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/10
- Re: [PATCH] Add support for shortdoc link type,
Bruno Cardoso <=
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/13
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/13
- Re: [PATCH] Add support for shortdoc link type, Max Nikulin, 2024/05/16
- Re: [PATCH] Add support for shortdoc link type, Bruno Cardoso, 2024/05/17