emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: xristos <xristos@sdf.org>
To: emacs-orgmode@gnu.org
Subject: org-capture: Avoid inserting a new line when the template is empty
Date: Sun, 03 Jun 2018 19:13:34 -0400	[thread overview]
Message-ID: <41k1rf1n1d.fsf@sdf.org> (raw)

Hello,

An example of a capture workflow that I am using all the time
is the following:

("bbp" "Preview book" plain
 (file+function "~/org/books.org.gpg" xristos/org-capture-preview-find-location)
  "" :immediate-finish t :jump-to-captured t :empty-lines 0)

The idea is that the function I provide is fully responsible for cursor positioning
and entry manipulation. To that end, I pass an empty template ("") and
set :immediate-finish to t. This has been working fine with an older Org
version but since I recently updated to Org 9.1.13, org-capture-fill-template will
insert a new line every single time which is not what I want to happen.

The relevant code is at org-capture.el, line 1843. I think that having a way
to tell Org not to change the user-provided template at all and just use
it verbatim would be useful in the general sense.

For my own needs, I've added an extra property (:verbatim-template) which I
check for inside org-capture-fill-template:

@@ -1840,7 +1840,8 @@ The template may still contain \"%?\" for cursor positioning."
       (goto-char (point-max))
       (skip-chars-backward " \t\n")
       (delete-region (point) (point-max))
-      (insert "\n")
+      (unless (org-capture-get :verbatim-template)
+	(insert "\n"))
 
Chris

             reply	other threads:[~2018-06-03 23:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-03 23:13 xristos [this message]
2018-06-19 14:40 ` org-capture: Avoid inserting a new line when the template is empty Nicolas Goaziou

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=41k1rf1n1d.fsf@sdf.org \
    --to=xristos@sdf.org \
    --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).