From mboxrd@z Thu Jan 1 00:00:00 1970 From: xristos Subject: org-capture: Avoid inserting a new line when the template is empty Date: Sun, 03 Jun 2018 19:13:34 -0400 Message-ID: <41k1rf1n1d.fsf@sdf.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPcLX-0003eX-KI for emacs-orgmode@gnu.org; Sun, 03 Jun 2018 19:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPcLU-0005a5-GO for emacs-orgmode@gnu.org; Sun, 03 Jun 2018 19:23:35 -0400 Received: from mail.suspicious.org ([104.131.63.74]:34519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPcLU-0005Zu-CI for emacs-orgmode@gnu.org; Sun, 03 Jun 2018 19:23:32 -0400 Received: from samadhi.lan (unknown [204.11.85.76]) (Authenticated sender: night) by mail.suspicious.org (Postfix) with ESMTPSA id AB8B91400E3 for ; Sun, 3 Jun 2018 19:13:35 -0400 (EDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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