emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add support for shortdoc link type


From: Bruno Cardoso
Subject: [PATCH] Add support for shortdoc link type
Date: Wed, 01 May 2024 00:29:08 -0300

Hi all,

This patch adds support for "shortdoc:" links.

Best,

Bruno.

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]