emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* insert file, relative or absolute path when using <I
@ 2020-12-14 16:45 Uwe Brauer
  2020-12-22 19:14 ` [PATCH] tempo: Support inserting an absolute file name for 'include' Kyle Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Brauer @ 2020-12-14 16:45 UTC (permalink / raw)
  To: emacs-orgmode


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?

Thanks 

Uwe Brauer 



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] tempo: Support inserting an absolute file name for 'include'
  2020-12-14 16:45 insert file, relative or absolute path when using <I Uwe Brauer
@ 2020-12-22 19:14 ` Kyle Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2020-12-22 19:14 UTC (permalink / raw)
  To: emacs-orgmode

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: 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)
 
 \f
 ;;; 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-22 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 16:45 insert file, relative or absolute path when using <I Uwe Brauer
2020-12-22 19:14 ` [PATCH] tempo: Support inserting an absolute file name for 'include' Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).