emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] tempo: Support inserting an absolute file name for 'include'


From: Kyle Meyer
Subject: [PATCH] tempo: Support inserting an absolute file name for 'include'
Date: Tue, 22 Dec 2020 19:14:08 GMT

Uwe Brauer writes:

> Hi
>
> I use tempo template and writing 
>
> <I pressing tab allows me to add a file I want to be inserted.
> Although the minibuffer presents me with the absolute path, only the
> relative path is inserted.
>
> Where can I change this behaviour?

It's hard coded at the moment.  I'd be okay adding a defcustom that
controls this behavior, though perhaps those familiar with tempo.el can
suggest a better approach.

Thoughts?

-- >8 --
Subject: [PATCH] tempo: Support inserting an absolute file name for 'include'

* lisp/org-tempo.el (org-tempo-include-use-relative): New option.
(org-tempo--include-file): Insert file name according to
org-tempo-include-use-relative.

Suggested-by: Uwe Brauer <oub@mat.ucm.es>
Ref: 87k0tkwd3p.fsf@mat.ucm.es">https://orgmode.org/list/87k0tkwd3p.fsf@mat.ucm.es
---
 etc/ORG-NEWS      |  7 +++++++
 lisp/org-tempo.el | 12 +++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 65098d85d..d486eb4a5 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -12,6 +12,13 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.5 (not yet released)
 ** New options and settings
+
+*** New option ~org-tempo-include-use-relative~
+
+By default, inserting an =include= keyword via =<I= inserts the file
+name read from the user as a relative one.  When this option is to
+nil, the file name is instead inserted as an absolute file name.
+
 *** Option ~org-hidden-keywords~ now also applies to #+SUBTITLE:
 
 The option ~org-hidden-keywords~ previously applied
diff --git a/lisp/org-tempo.el b/lisp/org-tempo.el
index eac6b35fd..b7b8185dc 100644
--- a/lisp/org-tempo.el
+++ b/lisp/org-tempo.el
@@ -72,6 +72,12 @@ (defcustom org-tempo-keywords-alist
                       (string :tag "Keyword")))
   :package-version '(Org . "9.2"))
 
+(defcustom org-tempo-include-use-relative t
+  "Whether to insert a relative file name for \"#+include\"."
+  :group 'org-tempo
+  :package-version '(Org . "9.5")
+  :safe 'booleanp
+  :type 'boolean)
 
 
 ;;; Org Tempo functions and setup.
@@ -159,7 +165,11 @@ (defun org-tempo--include-file ()
              (prog1 t
                (insert
                 (format "#+include: %S "
-                        (file-relative-name
+                        (funcall
+                         (if org-tempo-include-use-relative
+                             #'file-relative-name
+                           (lambda (f)
+                             (abbreviate-file-name (expand-file-name f))))
                          (read-file-name "Include file: "))))))
       (insert "<I")
       (setq quit-flag nil))))

base-commit: 9140a712fb1546ecb52ddda6e607f0bcecd436d8
-- 
2.29.2




reply via email to

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