From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petro Subject: template, position search Date: Fri, 12 Oct 2012 15:44:55 +0200 Message-ID: <87zk3rhkiw.fsf@cica.cica> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMfYG-0006vY-1t for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 09:45:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMfY8-0003zo-Ms for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 09:45:19 -0400 Received: from plane.gmane.org ([80.91.229.3]:45081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMfY8-0003yR-FH for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 09:45:12 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TMfYB-0006il-8Q for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 15:45:15 +0200 Received: from 0x4dd745cf.adsl.cybercity.dk ([77.215.69.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Oct 2012 15:45:15 +0200 Received: from x.piter by 0x4dd745cf.adsl.cybercity.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Oct 2012 15:45:15 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi list, I am developing a template, which will enable me to group notes about one article together. It is my first attempt of elisp programming and I have some difficulties. In the first version my plan if to bind notes to a file name. (Later when I make it working I plan to combine it with ebib but there is a long way to go.) * Articles ** /home/article1.pdf *** note1 *** note2 ** /home/article2.pdf *** note1 *** note2 I open a article1.pdf file in emacs, run org-capture command and choose the following template: ------------------------------------------------------------------------ ("a" "article note" entry (file+function "~/org/scientific_notes.org" find-create-article-note-location) "*** test %?\nEntered on %U\n" ) ------------------------------------------------------------------------ The find-create-article-note-location function scans the org file for an entry "** /home/article1.pdf" and moves cursor below it. If there is no such entry then it is created. Bellow is my attempt to implement it. I do not know how to send an article filename to the find-create-article-note-location function. Once executed it creates this headline and places the note bellow it. ** /home/petro/org/scientific_notes.org *** note1 I would appreciate a hint how to make this function aware of the pdf file name. Thanks Petro ----------------- code------------------------------------------------------- ;; templates (setq org-capture-templates '(("t" "Todo" entry (file+headline "~/org/tasks.org" "Tasks") "* TODO %?\n %i\n %a") ("n" "Note" entry (file+datetree "~/org/notes.org") "* %?\nEntered on %U\n %i\n %a") ("a" "article note" entry (file+function "~/org/scientific_notes.org" find-create-article-note-location) "*** test %?\nEntered on %U\n" ) )) ;; org-mode functions (defun find-create-article-note-location () "Find a place to put an annotation note from pdf file" (defvar article-to-note buffer-file-name) (goto-char (point-min)) ;; go to the top of the file (if (search-forward (concat "** " article-to-note) nil t) (go-to-note-place) (create-place-for-note) ) ) (defun go-to-note-place() "Move cursor to the top of an article notes " (goto-char (point-min)) (re-search-forward (concat "** " article-to-note) nil t) (newline 2)) (defun create-place-for-note() "Create place for notes" (goto-char (point-min)) (re-search-forward (concat "* Articles") nil t) (newline 2) (insert (concat "** " article-to-note)) (newline 2) )