emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org be2966a: org-id: Add title to description when stor


From: ELPA Syncer
Subject: [elpa] externals/org be2966a: org-id: Add title to description when storing id links
Date: Sat, 6 Feb 2021 14:57:08 -0500 (EST)

branch: externals/org
commit be2966abb5a97f3503cf7c26a83d9e111fc0b8aa
Author: Gustav Wikström <gustav@whil.se>
Commit: Gustav Wikström <gustav@whil.se>

    org-id: Add title to description when storing id links
    
    * lisp/org-id.el (org-id-store-link): Store title as link description
    if it is available.
---
 etc/ORG-NEWS   |  7 +++++++
 lisp/org-id.el | 24 +++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index ba76922..ef100ed 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -197,6 +197,13 @@ changed to
                                 :height 0.75)))
 #+end_src
 
+*** Storing ID-links before first heading uses title as description
+
+Storing links to files using ~org-store-link~ (=<C-c l>=) when
+~org-id-link-to-org-use-id~ is not nil will now store the title as
+description of the link, if available.  If no title exists it falls
+back to the filename as before.
+
 * Version 9.4
 ** Incompatible changes
 *** Possibly broken internal file links: please check and fix
diff --git a/lisp/org-id.el b/lisp/org-id.el
index d1e9aa9..76077b7 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -693,21 +693,27 @@ optional argument MARKERP, return the position as a new 
marker."
 
 ;;;###autoload
 (defun org-id-store-link ()
-  "Store a link to the current entry, using its ID."
+  "Store a link to the current entry, using its ID.
+
+If before first heading store first title-keyword as description
+or filename if no title."
   (interactive)
   (when (and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 
'org-mode))
     (let* ((link (concat "id:" (org-id-get-create)))
           (case-fold-search nil)
           (desc (save-excursion
                   (org-back-to-heading-or-point-min t)
-                  (or (and (org-before-first-heading-p)
-                           (file-name-nondirectory
-                            (buffer-file-name (buffer-base-buffer))))
-                      (and (looking-at org-complex-heading-regexp)
-                           (if (match-end 4)
-                               (match-string 4)
-                             (match-string 0)))
-                      link))))
+                   (cond ((org-before-first-heading-p)
+                          (let ((keywords (org-collect-keywords '("TITLE"))))
+                            (if keywords
+                                (car (alist-get "TITLE" keywords nil nil 
'equal))
+                              (file-name-nondirectory
+                              (buffer-file-name (buffer-base-buffer))))))
+                        ((looking-at org-complex-heading-regexp)
+                         (if (match-end 4)
+                             (match-string 4)
+                           (match-string 0)))
+                         (t link)))))
       (org-link-store-props :link link :description desc :type "id")
       link)))
 



reply via email to

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