emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add support for shortdoc link type
@ 2024-05-01  3:29 Bruno Cardoso
  2024-05-01 11:00 ` Ihor Radchenko
  0 siblings, 1 reply; 28+ messages in thread
From: Bruno Cardoso @ 2024-05-01  3:29 UTC (permalink / raw)
  To: emacs-orgmode

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


Hi all,

This patch adds support for "shortdoc:" links.

Best,

Bruno.


[-- 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: 1865 bytes --]

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..f0088ae5f 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1598,6 +1598,29 @@ PATH is a symbol name, as a string."
                          :follow #'org-link--open-help
                          :store #'org-link--store-help)
 
+;;;; "shortdoc" link type
+
+(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)))
+
+(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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2024-06-06 23:12 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-06-06 11:53                                         ` Ihor Radchenko
2024-06-06 23:11                                           ` Bruno Cardoso

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).