emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture file+function match [PATCH] + question
@ 2010-06-30 15:53 Juan
  2010-07-05  6:56 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Juan @ 2010-06-30 15:53 UTC (permalink / raw)
  To: carsten.dominik; +Cc: Emacs-orgmode

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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-05  6:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 15:53 org-capture file+function match [PATCH] + question Juan
2010-07-05  6:56 ` Carsten Dominik

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).