emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: org-capture file+function match [PATCH] + question


From: Carsten Dominik
Subject: [Orgmode] Re: org-capture file+function match [PATCH] + question
Date: Mon, 5 Jul 2010 08:56:17 +0200

Hi Juan,

I have now taken a look at the file+regexp, file+function,
and function targets in capture.  They should work now, including
using :prepend to position at the beginning of the regexp
in the file+regexp target specification.  For file+function and
for function, :prepend has no effect.

If you still feel like testing them, this would be much appreciated.

- Carsten

On Jun 30, 2010, at 5:53 PM, Juan wrote:

Hi Carsten,

Below is a patch for file+function matching (nth 1 instead of nth 2
when calling the match function).


Question:

I'm having trouble with both file+function and file+regexp capture
targets.

My actual capture text ends up at the end of the file (or top of file
if :prepend is set), instead of at the point of match.

I think it has something to do with org-capture-place-entry, after the
suspicious comment:

   (cond
    ((not target-entry-p)
;; Insert as top-level entry, either at beginning or at end of file

I would expect the cursor to stay at the point of match (match-end or
match-beginning depending on :prepend).

An example template and match function goes below.

Am I missing something?

Saludos,
.j.


8<---- example template & function ------------------------------

Example template:

'(("h" "New clock-in" plain
  (file+function "~/shared/everything.org" match-function)
"*** %u %^{Task}\n " :prepend t :immediate-finish t :clock-in t))

Example matching function:

(defun match-function ()
 (goto-char (point-min))
 (search-forward "<<insert-here>>")
 (goto-char (match-beginning 0))
)


8<----- PATCH -------------------------------------------------------

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index fb3c06a..f12826a 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -586,7 +586,7 @@ already gone."

       ((eq (car target) 'file+function)
       (set-buffer (org-capture-target-buffer (nth 1 target)))
-       (funcall (nth 1 target))
+       (funcall (nth 2 target))
       (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))

       ((eq (car target) 'clock)

- Carsten






reply via email to

[Prev in Thread] Current Thread [Next in Thread]