From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: org-capture file+function match [PATCH] + question Date: Mon, 5 Jul 2010 08:56:17 +0200 Message-ID: References: <20100630155357.GA19738@soloJazz.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=37872 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVfbN-0002Tg-9v for emacs-orgmode@gnu.org; Mon, 05 Jul 2010 02:56:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVfbL-0001o3-JN for emacs-orgmode@gnu.org; Mon, 05 Jul 2010 02:56:25 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:64848) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVfbL-0001nm-F8 for emacs-orgmode@gnu.org; Mon, 05 Jul 2010 02:56:23 -0400 Received: by wwi14 with SMTP id 14so4544147wwi.30 for ; Sun, 04 Jul 2010 23:56:21 -0700 (PDT) In-Reply-To: <20100630155357.GA19738@soloJazz.com> 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: Juan Cc: Emacs-orgmode 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 "<>") > (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