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

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

[elpa] externals/org-transclusion 20ac54f54a 1/3: (WIP) add filter to co


From: ELPA Syncer
Subject: [elpa] externals/org-transclusion 20ac54f54a 1/3: (WIP) add filter to convert filenames in links from rel to abs #145
Date: Fri, 27 May 2022 09:57:45 -0400 (EDT)

branch: externals/org-transclusion
commit 20ac54f54a3a40e1ffd433569c064fb7c3acfa21
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    (WIP) add filter to convert filenames in links from rel to abs #145
    
    It is still WIP. In this commit, a new function in the content filter
    has been added. It will iterate every link Org element and covernt
    relative filename into absolute. It does nothing if the link is already
    an absolute.
---
 org-transclusion.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/org-transclusion.el b/org-transclusion.el
index 0934630b84..8668b89a1c 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -17,7 +17,7 @@
 
 ;; Author:        Noboru Ota <me@nobiot.com>
 ;; Created:       10 October 2020
-;; Last modified: 29 January 2022
+;; Last modified: 27 May 2022
 
 ;; URL: https://github.com/nobiot/org-transclusion
 ;; Keywords: org-mode, transclusion, writing
@@ -1162,11 +1162,25 @@ etc.)."
           (setq obj (org-element-map obj org-element-all-elements
                       #'org-transclusion-content-filter-org-only-contents
                       nil nil '(section) nil)))
+        ;; Convert relative filename in links to absolute (abbreviated)
+        (org-element-map obj 'link #'org-transclusion-content-absolute-links)
+
         (list :src-content (org-element-interpret-data obj)
               :src-buf (current-buffer)
               :src-beg (point-min)
               :src-end (point-max))))))
 
+(defun org-transclusion-content-absolute-links (link)
+  "."
+  (when (string-equal "file" (org-element-property :type link))
+    (let ((raw-link (org-element-property :raw-link link)))
+      (unless (file-name-absolute-p raw-link)
+        (org-element-put-property
+         link :path
+         (expand-file-name
+          raw-link
+          (file-name-directory (buffer-file-name (current-buffer)))))))))
+
 (defun org-transclusion-content-filter-org-exclude-elements (data)
   "Exclude specific elements from DATA.
 The elements to be excluded are defined by customizing variable



reply via email to

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