From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Riley Subject: Re: sexp in org remember templates Date: Tue, 27 Oct 2009 00:04:02 +0100 Message-ID: References: <10440.1256596261@gamaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2Yd2-0003ku-Mi for emacs-orgmode@gnu.org; Mon, 26 Oct 2009 19:05:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2Ycx-0003e9-59 for emacs-orgmode@gnu.org; Mon, 26 Oct 2009 19:05:31 -0400 Received: from [199.232.76.173] (port=45132 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2Ycw-0003dr-Tf for emacs-orgmode@gnu.org; Mon, 26 Oct 2009 19:05:26 -0400 Received: from lo.gmane.org ([80.91.229.12]:46247) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N2Ycw-0008Bv-4u for emacs-orgmode@gnu.org; Mon, 26 Oct 2009 19:05:26 -0400 Received: from list by lo.gmane.org with local (Exim 4.50) id 1N2Ycl-0002hJ-Nz for emacs-orgmode@gnu.org; Tue, 27 Oct 2009 00:05:15 +0100 Received: from 85.183.18.158 ([85.183.18.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Oct 2009 00:05:15 +0100 Received: from rileyrgdev by 85.183.18.158 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Oct 2009 00:05:15 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Nick Dokos writes: > Richard Riley 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.