[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] template, position search
From: |
Petro |
Subject: |
[O] template, position search |
Date: |
Fri, 12 Oct 2012 15:44:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
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)
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [O] template, position search,
Petro <=