emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* template, position search
@ 2012-10-12 13:44 Petro
  2012-12-18 14:01 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Petro @ 2012-10-12 13:44 UTC (permalink / raw)
  To: emacs-orgmode

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)
  )

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: template, position search
  2012-10-12 13:44 template, position search Petro
@ 2012-12-18 14:01 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2012-12-18 14:01 UTC (permalink / raw)
  To: Petro; +Cc: emacs-orgmode

Hi Petro,

Petro <x.piter@gmail.com> writes:

> (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" )
>       ))

Instead of 

  (file+function "~/org/scientific_notes.org"
    find-create-article-note-location) 

I'd use (function find-file-create-article-note-location)
then tell `find-file-create-article-note-location' to retrieve
(buffer-file-name) when on the pdf.

HTH,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-18 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-12 13:44 template, position search Petro
2012-12-18 14:01 ` Bastien

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).