[O] Bug: Inconsistent usage of org-capture-get [9.2 (release_9.2 @ /Users/xristos/code/elisp/third-party/org-mode/lisp/)]

2019-01-03 Thread xristos


At some point, the optional argument LOCAL was added to org-capture-get:

(org-capture-get PROP  LOCAL)

"When LOCAL is set, use the local variable ‘org-capture-current-plist’,
this is necessary after initialization of the capture process,
to avoid conflicts with other active capture processes."

A lot of the org-capture-get calls in org-capture.el do not set LOCAL
and suffer from aforementioned conflicts. The calls inside function org-capture
are exempt from this, but the calls inside org-capture-finalize that do not
set LOCAL are obviously erroneous. There are more org-capture-get calls in
other functions that have to be reviewed.

Emacs  : GNU Emacs 25.3.2 (x86_64-apple-darwin17.4.0, Carbon Version 158 AppKit 
1561.2)
 of 2018-02-19
Package: Org mode version 9.2 (release_9.2 @ 
/Users/xristos/code/elisp/third-party/org-mode/lisp/)



[O] org-capture: Avoid inserting a new line when the template is empty

2018-06-06 Thread xristos
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