[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, 04 May 2024 14:33:05 -0300 |
On 2024-05-04, 14:38 +0700, Max Nikulin <manikulin@gmail.com> wrote:
> It is necessary to maintain backward compatibility for `ol-info'. I do
> not know what kind of separator was added earlier: "::" or "#". I
> suppose, for new link type, rules more close to file: links may be used, see
> (info "(org) Search Options")
> https://orgmode.org/manual/Search-Options.html
>
> That is why I suggested shortdoc:GROUP::#FUNCTION. This way
> shrotdoc:GROUP::SEARCH_STRING is possible as well.
I see, thanks for pointing it out. I modified the regexp to match this pattern.
> Notice that `shortdoc-display-group' has optional FUNCTION argument.
Yes, I completely missed that. I updated the patch to use the optional function
argument instead.
diff --git a/doc/org-manual.org b/doc/org-manual.org
index d66d95a22..61ee0c63d 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 more
information, see [[info:emacs#Name Help][Help by Command or Variable Name]].
+
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,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 87ebed751..f90c59ed3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1369,6 +1369,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 bc9682e4a..19ec7a32a 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,41 @@ 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 (path _)
+ "Open a \"shortdoc\" type link.
+PATH is a group name or \"group::#function\"."
+ (string-match "\\`\\([^#:]*\\)\\(::#?\\(.*\\)\\)?\\'" path)
+ (let ((group (match-string 1 path))
+ (fn (match-string 3 path)))
+ (condition-case nil
+ (shortdoc-display-group group (intern-soft fn))
+ (error (message "Unknown shortdoc group: %s" group)))))
+
+ (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
- 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, 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 <=
- 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, 2024/05/11
- 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