From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Subject: org-capture file+function match [PATCH] + question Date: Wed, 30 Jun 2010 12:53:57 -0300 Message-ID: <20100630155357.GA19738@soloJazz.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=54307 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTzbz-0002v6-SF for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 11:54:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTzbu-0002Hn-DG for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 11:54:07 -0400 Received: from cpoproxy2-pub.bluehost.com ([67.222.39.38]:37961) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OTzbu-0002HW-7l for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 11:54:02 -0400 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: carsten.dominik@gmail.com 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 "<>") (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)