emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: sexp in org remember templates


From: Richard Riley
Subject: [Orgmode] Re: sexp in org remember templates
Date: Tue, 27 Oct 2009 00:04:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Nick Dokos <address@hidden> writes:

> Richard Riley <address@hidden> wrote:
>
>> 
>> Not being much of an elisp programmer and just returning to try and
>> integrate with org-learn a little :-
>> 
>> This 
>> 
>>            ("vocab"?v "* Learn TODO %(format '%s' rgr/orig-word)
>>            :VOCAB:\n:PROPERTIES:\n:orig:\t%(format '%s'
>>            rgr/orig-word)\n:trans:\t%(format '%s'
>>            rgr/trans-word)\n:END:%!" nil bottom nil)
>> 
>> fails me by outputting:
>> 
>
> At the very least, you need to avoid single quotes for quoting strings -
> a single quote has a very special meaning to lisp in general: it inhibits
> evaluation of the following sexp.
>
> Try something like this instead:
>
> ("vocab"?v "* Learn TODO %(format \"%s\" rgr/orig-word)
>             :VOCAB:\n:PROPERTIES:\n:orig:\t%(format \"%s\"
>             rgr/orig-word)\n:trans:\t%(format \"%s\"
>             rgr/trans-word)\n:END:%!" nil bottom nil)
>
> However, no guarantees: when (or even whether) the format calls will be 
> executed
> (let alone whether they'll produce the correct result) depends on the
> code that handles this construct. There have been a couple of questions
> on the mailing list about such evaluations in the context of
> org-remember-templates, and IIRC, Carsten had added an evaluation
> mechanism there - see e.g. the thread at
>
>    http://thread.gmane.org/gmane.emacs.orgmode/14521
>
> and another thread referenced therein for some details. But I don't know
> if this will do what you need it to do.
>
> HTH,
> Nick

Thanks for the info. In the meantime I had just created two functions
with no parameters to return the values and this worked. 

Trying now to auto remember. I have some code like this:-

,----
| (defun rgr/context-babel()
|   (interactive)
|   (save-window-excursion(unwind-protect
|                           (let* ((default (region-or-word-at-point)))
|                             (setq default (read-string (format "Translate 
\"%s\" :" default) nil nil default))
|                             (when (length default) (setq
|   rgr/trans-word (babel default nil t))(setq rgr/orig-word
|   default)(org-remember nil ?v)(message "%s" rgr/trans-word))))))
`----

Thanks. I had already create two funcs to call so my template is now:-

,----
|             ("vocab"?v "* TODO Learn %(rgr/orig-word)
|             
:VOCAB:\n:PROPERTIES:\n:orig:\t%(rgr/orig-word)\n:trans:\t%(rgr/trans-word)\n:END:%!"
|             nil bottom nil)
`----

and the translate code I call does this:

,----
| ;;;###autoload
| (defun rgr/context-babel()
|   (interactive)
|   (save-window-excursion(unwind-protect
|                           (let* ((default (region-or-word-at-point)))
|                             (setq default (read-string (format "Translate 
\"%s\" :" default) nil nil default))
|                             (when (length default) (setq rgr/trans-word 
(babel default nil t))(setq rgr/orig-word default)(org-remember nil ?v)(message 
"%s" rgr/trans-word))))))
`----

and now I have my translate hot key auto creating VOCAB TODOs. The only
thing I need to know now is how to auto schedule them.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]