emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] tempo: Support inserting an absolute file name for 'include'
Date: Tue, 22 Dec 2020 19:14:08 GMT	[thread overview]
Message-ID: <87y2hphcw5.fsf@kyleam.com> (raw)
In-Reply-To: <87k0tkwd3p.fsf@mat.ucm.es>

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



      reply	other threads:[~2020-12-22 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 16:45 insert file, relative or absolute path when using <I Uwe Brauer
2020-12-22 19:14 ` Kyle Meyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2hphcw5.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).