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

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

[elpa] externals/gnorb 894b96c 334/449: Additional guard for non-existen


From: Stefan Monnier
Subject: [elpa] externals/gnorb 894b96c 334/449: Additional guard for non-existent headings
Date: Fri, 27 Nov 2020 23:16:06 -0500 (EST)

branch: externals/gnorb
commit 894b96cf04f20f09c26985c3971d19d48e7f9f56
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Additional guard for non-existent headings
    
    * gnorb-utils.el (gnorb-pretty-outline): The heading may have been
      deleted; at the very least don't raise an error.
---
 gnorb-utils.el | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/gnorb-utils.el b/gnorb-utils.el
index d7f5e86..4d473f1 100644
--- a/gnorb-utils.el
+++ b/gnorb-utils.el
@@ -334,24 +334,27 @@ agenda. Then let the user choose an action from the value 
of
   "Return pretty outline path of the Org heading indicated by ID.
 
 If the KW argument is true, add the TODO keyword into the path."
-  (org-with-point-at (org-id-find id t)
-    (let ((el (org-element-at-point)))
-      (concat
-       (if kw
-          (format "(%s): "
-                  (org-element-property :todo-keyword el))
-        "")
-       (org-format-outline-path
-       (append
-        (list
-         (file-name-nondirectory
-          (buffer-file-name
-           (org-base-buffer (current-buffer)))))
-        (org-get-outline-path)
-        (list
-         (replace-regexp-in-string
-          org-bracket-link-regexp
-          "\\3" (org-element-property :raw-value el)))))))))
+  (let ((pt (org-id-find id t)))
+    (if pt
+       (org-with-point-at pt
+         (let ((el (org-element-at-point)))
+           (concat
+            (if kw
+                (format "(%s): "
+                        (org-element-property :todo-keyword el))
+              "")
+            (org-format-outline-path
+             (append
+              (list
+               (file-name-nondirectory
+                (buffer-file-name
+                 (org-base-buffer (current-buffer)))))
+              (org-get-outline-path)
+              (list
+               (replace-regexp-in-string
+                org-bracket-link-regexp
+                "\\3" (org-element-property :raw-value el))))))))
+      "[none]")))
 
 (defun gnorb-scan-links (bound &rest types)
   "Scan from point to BOUND looking for links of type in TYPES.



reply via email to

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