[O] [PATCH] fix bug: org-ascii--unique-links don't call org-element-map with correct number of arguments

2013-10-14 Thread Ryo TAKAISHI
* lisp/ox-ascii.el: org-ascii--unique-links call org-element-map with correct 
number of arguments.

---
 lisp/ox-ascii.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e0a3fa9..7ad0ee1 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -812,7 +812,7 @@ is a plist used as a communication channel.
(or (org-export-get-parent-headline element) element
 ;; Get all links in HEADLINE.
 (org-element-map headline 'link
-  (lambda (l) (funcall unique-link-p l)) info nil nil t)))
+  (lambda (l) (funcall unique-link-p l)) info nil t)))
 
 (defun org-ascii--describe-links (links width info)
   Return a string describing a list of links.
-- 
1.7.9.6 (Apple Git-31.1)




[O] [PATCH] fix bug: org-babel-tangle-file can't limit collected source code block by argument.

2013-03-04 Thread Ryo TAKAISHI
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): Change argument name 
collid org-babel-map-src-blocks's variable 'lang'.
---
 lisp/ob-tangle.el |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index ef14f22..95433ee 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -352,7 +352,7 @@ that the appropriate major-mode is set.  SPEC has the form:
(org-fill-template org-babel-tangle-comment-format-end link-data)
 
 (defvar org-comment-string) ;; Defined in org.el
-(defun org-babel-tangle-collect-blocks (optional lang tangle-file)
+(defun org-babel-tangle-collect-blocks (optional language tangle-file)
   Collect source blocks in the current Org-mode file.
 Return an association list of source-code block specifications of
 the form used by `org-babel-spec-to-string' grouped by language.
@@ -378,7 +378,7 @@ used to limit the collected code blocks by target file.
 (unless (or (string-match (concat ^ org-comment-string) 
current-heading)
(string= (cdr (assoc :tangle (nth 2 info))) no)
(and tangle-file (not (equal tangle-file src-tfile
-  (unless (and lang (not (string= lang src-lang)))
+  (unless (and language (not (string= language src-lang)))
;; Add the spec for this block to blocks under it's language
(setq by-lang (cdr (assoc src-lang blocks)))
(setq blocks (delq (assoc src-lang blocks) blocks))
-- 
1.7.9.6 (Apple Git-31.1)




Re: [O] [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.

2013-03-03 Thread Ryo TAKAISHI
* lisp/org-protocol.el: (org-protocol-convert-query-to-plist): New function.
(org-protocol-do-capture): Use new function.
(org-protocol-data-separator): Change default separator.

When org-protocol's url has query, org-capture get query using plist-get from 
store-link.
For example:
Url is org-protocol:/capture:/URL/TITLE/BODY?key=value
org-capture can get (:key value) with (plist-get org-store-link-plist :query).
---

Hello,
Bastien

I fixed and resend a patch.

Thanks,
Ryo

 lisp/org-protocol.el |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 2a804ad..d676c39 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -267,10 +267,12 @@ string with two characters.
   :group 'org-protocol
   :type 'string)
 
-(defcustom org-protocol-data-separator /+
+(defcustom org-protocol-data-separator /+\\|\\?
   The default data separator to use.
This should be a single regexp string.
   :group 'org-protocol
+  :version 24.4
+  :package-version '(Org . 8.0)
   :type 'string)
 
 ;;; Helper functions:
@@ -291,7 +293,7 @@ nil, assume \/+\.  The results of that splitting are 
returned
 as a list.  If UNHEXIFY is non-nil, hex-decode each split part.
 If UNHEXIFY is a function, use that function to decode each split
 part.
-  (let* ((sep (or separator /+))
+  (let* ((sep (or separator /+\\|\\?))
  (split-parts (split-string data sep)))
 (if unhexify
(if (fboundp unhexify)
@@ -411,6 +413,14 @@ Now template ?b will be used.
   (message Item captured.))
   nil)
 
+(defun org-protocol-convert-query-to-plist (query)
+  Convert query string that is part of url to property list.
+  (if query
+  (apply 'append (mapcar (lambda (x)
+  (let ((c (split-string x =)))
+(list (intern (concat : (car c))) (cadr c
+(split-string query )
+
 (defun org-protocol-do-capture (info)
   Support `org-capture'.
   (let* ((parts (org-protocol-split-data info t org-protocol-data-separator))
@@ -423,6 +433,7 @@ Now template ?b will be used.
 (region (or (caddr parts) ))
 (orglink (org-make-link-string
   url (if (string-match [^[:space:]] title) title url)))
+(query (or (org-protocol-convert-query-to-plist (cadddr parts)) ))
 (org-capture-link-is-already-stored t)) ;; avoid call to org-store-link
 (setq org-stored-links
  (cons (list url title) org-stored-links))
@@ -431,7 +442,8 @@ Now template ?b will be used.
  :link url
  :description title
  :annotation orglink
- :initial region)
+ :initial region
+ :query query)
 (raise-frame)
 (funcall 'org-capture nil template)))
 
-- 
1.7.9.6 (Apple Git-31.1)




Re: [O] [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.

2013-03-02 Thread Ryo Takaishi
Hello,
Bastien

I resend a patch for HEAD of master branch.

Thanks,
Ryo.
---

* lisp/org-protocol.el: (org-protocol-convert-query-to-plist): New function.
(org-protocol-do-capture): Use new function.

When org-protocol's url has query, org-capture get query using plist-get
from store-link.
For example:
Url is org-protocol:/capture:/URL/TITLE/BODY?key=value
org-capture can get (:key value) with (plist-get org-store-link-plist
:query).
---
 lisp/org-protocol.el |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 2a804ad..1f76e85 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -267,7 +267,7 @@ string with two characters.
   :group 'org-protocol
   :type 'string)

-(defcustom org-protocol-data-separator /+
+(defcustom org-protocol-data-separator /+\\|\\?
   The default data separator to use.
This should be a single regexp string.
   :group 'org-protocol
@@ -291,7 +291,7 @@ nil, assume \/+\.  The results of that splitting are
returned
 as a list.  If UNHEXIFY is non-nil, hex-decode each split part.
 If UNHEXIFY is a function, use that function to decode each split
 part.
-  (let* ((sep (or separator /+))
+  (let* ((sep (or separator /+\\|\\?))
  (split-parts (split-string data sep)))
 (if unhexify
 (if (fboundp unhexify)
@@ -411,6 +411,14 @@ Now template ?b will be used.
   (message Item captured.))
   nil)

+(defun org-protocol-convert-query-to-plist (query)
+  Convert query string that is part of url to property list.
+  (if query
+  (apply 'append (mapcar (lambda (x)
+   (let ((c (split-string x =)))
+ (list (intern (concat : (car c))) (cadr c
+ (split-string query )
+
 (defun org-protocol-do-capture (info)
   Support `org-capture'.
   (let* ((parts (org-protocol-split-data info t
org-protocol-data-separator))
@@ -423,6 +431,7 @@ Now template ?b will be used.
  (region (or (caddr parts) ))
  (orglink (org-make-link-string
url (if (string-match [^[:space:]] title) title url)))
+ (query (or (org-protocol-convert-query-to-plist (cadddr parts)) ))
  (org-capture-link-is-already-stored t)) ;; avoid call to
org-store-link
 (setq org-stored-links
   (cons (list url title) org-stored-links))
@@ -431,7 +440,8 @@ Now template ?b will be used.
   :link url
   :description title
   :annotation orglink
-  :initial region)
+  :initial region
+  :query query)
 (raise-frame)
 (funcall 'org-capture nil template)))

-- 
1.7.9.6 (Apple Git-31.1)




2012/12/31 Bastien b...@altern.org

 Hi Ryo,

 I'm willing to apply this patch but since you already submitted tiny
 changes we would need to have you sign the FSF copyright assignment.

 See
 http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt

 Let me know if you are willing to assign your copyright to the FSF.

 Thanks!

 --
  Bastien




-- 
Ryo Takaishi


Re: [O] [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.

2013-01-01 Thread Ryo TAKAISHI
Hello,
Bastien

I will to assign my copyright to the FSF.
I sent request-assign-future.txt to ass...@gnu.org now.

Regards,
Ryo

Bastien b...@altern.org writes:

 Hi Ryo,

 I'm willing to apply this patch but since you already submitted tiny
 changes we would need to have you sign the FSF copyright assignment.

 See http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt

 Let me know if you are willing to assign your copyright to the FSF.

 Thanks!



[O] [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.

2012-12-30 Thread Ryo TAKAISHI
* lisp/org-protocol.el: (org-protocol-convert-query-to-plist): New function.
(org-protocol-do-capture): Use new function.

When org-protocol's url has query, org-capture get query using plist-get from 
store-link.
For example:
Url is org-protocol:/capture:/URL/TITLE/BODY?key=value
org-capture can get (:key value) with (plist-get org-store-link-plist :query).

---
 lisp/org-protocol.el |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 31f6fb2..2fa7c76 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -273,7 +273,7 @@ string with two characters.
   :group 'org-protocol
   :type 'string)
 
-(defcustom org-protocol-data-separator /+
+(defcustom org-protocol-data-separator /+\\|\\?
   The default data separator to use.
This should be a single regexp string.
   :group 'org-protocol
@@ -297,7 +297,7 @@ nil, assume \/+\.  The results of that splitting are 
returned
 as a list.  If UNHEXIFY is non-nil, hex-decode each split part.
 If UNHEXIFY is a function, use that function to decode each split
 part.
-  (let* ((sep (or separator /+))
+  (let* ((sep (or separator /+\\|\\?))
  (split-parts (split-string data sep)))
 (if unhexify
(if (fboundp unhexify)
@@ -436,6 +436,14 @@ Now template ?b will be used.
   (message Item captured.))
   nil)
 
+(defun org-protocol-convert-query-to-plist (query)
+  Convert query string that is part of url to property list.
+  (if query
+  (apply 'append (mapcar (lambda (x)
+  (let ((c (split-string x =)))
+(list (intern (concat : (car c))) (cadr c
+(split-string query )
+
 (defun org-protocol-do-capture (info capture-func)
   Support `org-capture' and `org-remember' alike.
 CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'.
@@ -449,6 +457,7 @@ CAPTURE-FUNC is either the symbol `org-remember' or 
`org-capture'.
 (region (or (caddr parts) ))
 (orglink (org-make-link-string
   url (if (string-match [^[:space:]] title) title url)))
+(query (or (org-protocol-convert-query-to-plist (cadddr parts)) ))
 (org-capture-link-is-already-stored t) ;; avoid call to org-store-link
 remember-annotation-functions)
 (setq org-stored-links
@@ -458,7 +467,8 @@ CAPTURE-FUNC is either the symbol `org-remember' or 
`org-capture'.
  :link url
  :description title
  :annotation orglink
- :initial region)
+ :initial region
+ :query query)
 (raise-frame)
 (funcall capture-func nil template)))
 
-- 
1.7.9.6 (Apple Git-31.1)




Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-05 Thread Ryo TAKAISHI
Hello,

Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Ryo TAKAISHI ryo.takaish...@gmail.com writes:

 I create a complete patch for current commit.

 I've pushed your patch on master (with some documentation tweaks). Thank
 you for your work.

Thank you very much.
But, I had forgot to escape double quote in docstring, so attach patch
fixing it.

 Also, please consider signing FSF papers if you want to make other
 contributions to Org.

OK, I want to consider when I send a patch next time.

Regards,
Ryo

From dacf4ef0677f80cfc589bf5014ca71dfdd2dc3d4 Mon Sep 17 00:00:00 2001
From: Ryo TAKAISHI ryo.takaish...@gmail.com
Date: Mon, 5 Nov 2012 21:20:14 +0900
Subject: [PATCH] org-capture: Fix a docstring

* lisp/org-capture.el: Fix a docstring.

TINYCHANGE
---
 lisp/org-capture.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 695c5eb..ccdb0c1 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1631,7 +1631,7 @@ The template may still contain \%?\ for cursor positioning.
 
 (defun org-capture--expand-keyword-in-embedded-elisp (attr)
   Recursively replace capture link keywords in ATTR sexp.
-Such keywords are prefixed with %:.  See `org-capture-template'
+Such keywords are prefixed with '%:'.  See `org-capture-template'
 for more information.
   (cond ((consp attr)
 	 (mapcar 'org-capture--expand-keyword-in-embedded-elisp attr))
-- 
1.7.9.5



Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-04 Thread Ryo TAKAISHI
Nicolas Goaziou n.goaz...@gmail.com writes:

 The code looks good, although I would have moved the external `mapcar'
 within the worker function in order to make its purpose clearer.

 Also, would you mind to provide a docstring for the function? Something
 along the lines of:

 Recursively replace capture link keywords in ATTR sexp. 
   Such keywords are prefixed with %:.  See `org-capture-template' for
   more information.

 You may also want to rename it
 `org-capture--expand-keyword-in-embedded-elisp' to insist on the fact it
 is an internal function. That's not mandatory, though.

 Finally, this feature must be documented in `org-capture-templates'
 docstring and org.texi.

Hello,

I fixed and added document in docstring  org.texi.
Is my additional document fully?

Regards,
Ryo

 doc/org.texi|2 ++
 lisp/org-capture.el |   20 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/doc/org.texi b/doc/org.texi
index b23f492..b661dac 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6853,6 +6853,8 @@ dynamic insertion of content.  The templates are expanded 
in the order given her
 @smallexample
 %[@var{file}] @r{Insert the contents of the file given by @var{file}.}
 %(@var{sexp}) @r{Evaluate Elisp @var{sexp} and replace with the result.}
+  @r{If sexp's attr is link keyword (@code{%:keyword}),}
+  @r{it will be expanded using @code{org-store-link-plist}.}
 @r{The sexp must return a string.}
 %...  @r{The result of format-time-string on the ... format 
specification.}
 %t  @r{Timestamp, date only.}
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 1dfffc6..fcaa4f9 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -224,6 +224,8 @@ be replaced with content and expanded in this order:
 
   %[pathname] Insert the contents of the file given by `pathname'.
   %(sexp) Evaluate elisp `(sexp)' and replace with the result.
+  If sexp's attr is link keyword (%:keyword), it will
+  be expanded using `org-store-link-plist`.
   %...  The result of format-time-string on the ... format specification.
   %t  Time stamp, date only.
   %T  Time stamp with date and time.
@@ -1621,10 +1623,26 @@ The template may still contain \%?\ for cursor 
positioning.
   (goto-char (match-beginning 0))
   (let ((template-start (point)))
(forward-char 1)
-   (let ((result (org-eval (read (current-buffer)
+   (let* ((sexp (org-capture-expand-keyword-in-embedded-elisp
+ (read (current-buffer
+  (result (org-eval sexp)))
  (delete-region template-start (point))
  (insert result))
 
+(defun org-capture--expand-keyword-in-embedded-elisp (attr)
+  Recursively replace capture link keywords in ATTR sexp.
+Such keywords are prefixed with %:. See `org-capture-template`
+for more information.
+  (cond ((consp attr)
+(mapcar 'org-capture--expand-keyword-in-embedded-elisp attr))
+   ((symbolp attr)
+(let* ((attr-symbol (symbol-name attr))
+   (key (and (string-match %\\(:.*\\) attr-symbol)
+ (intern (match-string 1 attr-symbol)
+  (or (plist-get org-store-link-plist key)
+  attr)))
+   (t attr)))
+
 (defun org-capture-inside-embedded-elisp-p ()
   Return non-nil if point is inside of embedded elisp %(sexp).
   (let (beg end)
-- 
1.7.9.5




Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-04 Thread Ryo TAKAISHI
Nicolas Goaziou n.goaz...@gmail.com writes:

 Otherwise the code is fine. Would you provide a complete patch, i.e.
 with `git format-patch'? The changelog entry may be:

I create a complete patch for current commit.

Regards,
Ryo

From d82c99bb643e2c61e1f5b598a687160340a1558f Mon Sep 17 00:00:00 2001
From: Ryo TAKAISHI ryo.takaish...@gmail.com
Date: Mon, 5 Nov 2012 00:01:08 +0900
Subject: [PATCH] org-capture: Expand keywords within %(sexp) placeholder in
 template

* lisp/org-capture.el: (org-capture--expand-keyword-in-embedded-elisp): New function.
(org-capture-expand-embedded-elisp): Use new function.
---
 doc/org.texi|4 +++-
 lisp/org-capture.el |   22 --
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index b23f492..dd1d9b9 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6852,7 +6852,9 @@ dynamic insertion of content.  The templates are expanded in the order given her
 
 @smallexample
 %[@var{file}] @r{Insert the contents of the file given by @var{file}.}
-%(@var{sexp}) @r{Evaluate Elisp @var{sexp} and replace with the result.}
+%(@var{sexp}) @r{Evaluate Elisp @var{sexp} and replace with the result@footnote{For }
+  @r{convenience, %:keyword (see above) placeholders within the expression}
+  @r{will be expanded.}.}
 @r{The sexp must return a string.}
 %...  @r{The result of format-time-string on the ... format specification.}
 %t  @r{Timestamp, date only.}
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 1dfffc6..d0f7297 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -223,7 +223,9 @@ freely formatted text.  Furthermore, the following %-escapes will
 be replaced with content and expanded in this order:
 
   %[pathname] Insert the contents of the file given by `pathname'.
-  %(sexp) Evaluate elisp `(sexp)' and replace with the result.
+  %(sexp) Evaluate elisp `(sexp)' and replace with the result@(For
+  convenience, %:keyword (see above) placeholders within the expression
+  will be expanded.).
   %...  The result of format-time-string on the ... format specification.
   %t  Time stamp, date only.
   %T  Time stamp with date and time.
@@ -1621,10 +1623,26 @@ The template may still contain \%?\ for cursor positioning.
   (goto-char (match-beginning 0))
   (let ((template-start (point)))
 	(forward-char 1)
-	(let ((result (org-eval (read (current-buffer)
+	(let* ((sexp (org-capture-expand-keyword-in-embedded-elisp
+		  (read (current-buffer
+	   (result (org-eval sexp)))
 	  (delete-region template-start (point))
 	  (insert result))
 
+(defun org-capture--expand-keyword-in-embedded-elisp (attr)
+  Recursively replace capture link keywords in ATTR sexp.
+Such keywords are prefixed with %:. See `org-capture-template`
+for more information.
+  (cond ((consp attr)
+	 (mapcar 'org-capture--expand-keyword-in-embedded-elisp attr))
+	((symbolp attr)
+	 (let* ((attr-symbol (symbol-name attr))
+		(key (and (string-match %\\(:.*\\) attr-symbol)
+			  (intern (match-string 1 attr-symbol)
+	   (or (plist-get org-store-link-plist key)
+	   attr)))
+	(t attr)))
+
 (defun org-capture-inside-embedded-elisp-p ()
   Return non-nil if point is inside of embedded elisp %(sexp).
   (let (beg end)
-- 
1.7.9.5



[O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-02 Thread Ryo TAKAISHI
* lisp/org-capture.el: If %(SEXP) has %:keyword, expand it using 
org-store-link-plist.

I want to expand %:description keyword in sexp %(func %:description).
But if org-capture template is %(function %:keyword), function take a symbol 
%:keyword, it does'nt expand.
This patch expand %:keyword within %(SEXP), so funcsion is taken %:keyword's 
value.
For example, when capture template is %(func %:description) and a keyword 
:description is foobar, func is taken string foobar.

Modified from a patch proposal by Ryo TAKAISHI.

TINYCHANGE
---
 lisp/org-capture.el |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index be973b0..a8e49d6 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1620,7 +1620,15 @@ The template may still contain \%?\ for cursor 
positioning.
   (goto-char (match-beginning 0))
   (let ((template-start (point)))
(forward-char 1)
-   (let ((result (org-eval (read (current-buffer)
+   (let* ((sexp (mapcar '(lambda (attr)
+   (let* ((attr-symbol (symbol-name attr))
+  (key (if (string-match %\\(:.*\\) 
attr-symbol)
+   (intern (match-string 1 
attr-symbol))
+ nil)))
+ (or (plist-get org-store-link-plist key)
+ attr)))
+(read (current-buffer
+  (result (org-eval sexp)))
  (delete-region template-start (point))
  (insert result))
 
-- 
1.7.9.5




Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-02 Thread Ryo TAKAISHI


Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Thanks for your patch. Here are a few comments about it.

 Ryo TAKAISHI ryo.takaish...@gmail.com writes:

 * lisp/org-capture.el: If %(SEXP) has %:keyword, expand it using 
 org-store-link-plist.

 I want to expand %:description keyword in sexp %(func %:description).
 But if org-capture template is %(function %:keyword), function
 take a symbol %:keyword, it does'nt expand.
 This patch expand %:keyword within %(SEXP), so funcsion is taken %:keyword's 
 value.
 For example, when capture template is %(func %:description) and
 a keyword :description is foobar, func is taken string foobar.

 I'm not sure to understand why this patch is necessary. Can't you use
 (plist-get org-store-link-plist :description) from your sexp instead?


I did'nt come up with to use it.
But %(func %:description) or %(func (plist-get org-store-link-plist 
:description)), I think the former is readble template than the latter.

 +(let* ((sexp (mapcar '(lambda (attr)

 lambdas are self-quoting: do not explicitly quote them.

 +   (key (if (string-match %\\(:.*\\) 
 attr-symbol)
 +(intern (match-string 1 
 attr-symbol))
 +  nil)))

 (key (and (string-match %\\(:.*\\) attr-symbol)
   (intern (match-string 1 attr-symbol

 is better.


 Regards,

Thank you for your comment, I'll refine my code.

Regards,
Ryo



Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template

2012-11-02 Thread Ryo TAKAISHI
Nicolas Goaziou n.goaz...@gmail.com writes:

 Ryo TAKAISHI ryo.takaish...@gmail.com writes:

 I did'nt come up with to use it.
 But %(func %:description) or %(func (plist-get
 org-store-link-plist :description)), I think the former is readble
 template than the latter.

 Probably, but it's also more error-prone.

 For example, your code operates only at top-level, i.e. it won't handle
 something like:

 %(fun arg1 (sub-fun %:description))

 It will also error out if any atom isn't a symbol, i.e.:

 %(format %d 1)

 It's all about pro and cons.


 Regards,

I fix these problem. A new patch expand keyword recursively, and only symbol.

Regards,

---
 lisp/org-capture.el |   15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 1dfffc6..b8c9844 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1621,10 +1621,23 @@ The template may still contain \%?\ for cursor 
positioning.
   (goto-char (match-beginning 0))
   (let ((template-start (point)))
(forward-char 1)
-   (let ((result (org-eval (read (current-buffer)
+   (let* ((sexp (mapcar 'org-capture-expand-keyword-in-embedded-elisp
+(read (current-buffer
+  (result (org-eval sexp)))
  (delete-region template-start (point))
  (insert result))
 
+(defun org-capture-expand-keyword-in-embedded-elisp (attr)
+  (cond ((consp attr)
+(mapcar 'org-capture-expand-keyword-in-embedded-elisp attr))
+   ((symbolp attr)
+(let* ((attr-symbol (symbol-name attr))
+   (key (and (string-match %\\(:.*\\) attr-symbol)
+ (intern (match-string 1 attr-symbol)
+  (or (plist-get org-store-link-plist key)
+  attr)))
+   (t attr)))
+
 (defun org-capture-inside-embedded-elisp-p ()
   Return non-nil if point is inside of embedded elisp %(sexp).
   (let (beg end)
-- 
1.7.9.5