From: Petro <x.piter@gmail.com>
To: emacs-orgmode@gnu.org
Subject: template, position search
Date: Fri, 12 Oct 2012 15:44:55 +0200 [thread overview]
Message-ID: <87zk3rhkiw.fsf@cica.cica> (raw)
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)
)
next reply other threads:[~2012-10-12 13:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 13:44 Petro [this message]
2012-12-18 14:01 ` template, position search Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zk3rhkiw.fsf@cica.cica \
--to=x.piter@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).