emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bruno Cardoso <cardoso.bc@gmail.com>
To: Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add support for shortdoc link type
Date: Wed, 05 Jun 2024 19:21:59 -0300	[thread overview]
Message-ID: <87sexrvxmg.fsf@gmail.com> (raw)
In-Reply-To: <fb4ebece-e08a-4296-86dc-c412890d33d5@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]


On 2024-06-05, 22:37 +0700, Max Nikulin <manikulin@gmail.com> wrote:
>
> A couple of notes that unlikely affect real life usage.
>
>> +  (defun org-link--store-shortdoc (&optional _interactive?)
>> +    "Store \"shortdoc\" type link."
>> +    (when (eq major-mode 'shortdoc-mode)
>
> `derived-mode-p' is more reliable in general.

Fixed.

The attached patch is now rebased to new Org version.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ol-support-for-shortdoc-link-type.patch --]
[-- Type: text/x-patch, Size: 4978 bytes --]

From 43de471e577d530ea76dc48460efea12864b5675 Mon Sep 17 00:00:00 2001
From: bruno <cardoso.bc@gmail.com>
Date: Wed, 5 Jun 2024 19:14:36 -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 170eea506..e931e1cc1 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.
+  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
@@ -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 4b0b77ca8..a8f3a37f6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -40,6 +40,11 @@ all the references are resolved in the generated png.
 
 # This also includes changes in function behavior from Elisp perspective.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** Miscellaneous
 
 * Version 9.7
diff --git a/lisp/ol.el b/lisp/ol.el
index 20f1b89c0..4cda0cb60 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +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 (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))))
+
+  (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.1


  reply	other threads:[~2024-06-05 22:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01  3:29 [PATCH] Add support for shortdoc link type Bruno Cardoso
2024-05-01 11:00 ` Ihor Radchenko
2024-05-01 16:52   ` Bruno Cardoso
2024-05-01 17:55     ` Ihor Radchenko
2024-05-01 19:24       ` Bruno Cardoso
2024-05-02 10:41         ` Max Nikulin
2024-05-03 21:41           ` Bruno Cardoso
2024-05-04  7:38             ` Max Nikulin
2024-05-04 17:33               ` Bruno Cardoso
2024-05-05 11:01                 ` Max Nikulin
2024-05-05 21:35                   ` Bruno Cardoso
2024-05-06 10:55                     ` Max Nikulin
2024-05-08  1:11                       ` Bruno Cardoso
2024-05-08 11:20                         ` Max Nikulin
2024-05-08 21:26                           ` Bruno Cardoso
2024-05-10 11:09                             ` Max Nikulin
2024-05-11 16:58                               ` Bruno Cardoso
2024-05-13 11:14                                 ` Max Nikulin
2024-05-13 13:04                                   ` Bruno Cardoso
2024-05-16 10:58                                     ` Max Nikulin
2024-05-17 14:55                                       ` Bruno Cardoso
2024-06-04 23:59                                         ` Bruno Cardoso
2024-06-05 15:14                                           ` Ihor Radchenko
2024-06-05 21:15                                             ` Bastien Guerry
2024-06-05 15:37                                     ` Max Nikulin
2024-06-05 22:21                                       ` Bruno Cardoso [this message]
2024-06-06 11:53                                         ` Ihor Radchenko
2024-06-06 23:11                                           ` Bruno Cardoso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sexrvxmg.fsf@gmail.com \
    --to=cardoso.bc@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).