emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Patch org-capure-fill-template
@ 2014-10-29 17:46 Roberto Huelga
  2014-10-30 15:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Roberto Huelga @ 2014-10-29 17:46 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 72 bytes --]

Patch proposal fro org-capture-fill-template

Hope it's useful.
Thanks.

[-- Attachment #1.2: Type: text/html, Size: 140 bytes --]

[-- Attachment #2: 0001-org-capture.el-Fix-expand-template-order.patch --]
[-- Type: application/octet-stream, Size: 1503 bytes --]

From 3298e255aa8cc0c0bb5367a469d578fc8ed45600 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roberto=20Huelga=20D=C3=ADaz?= <rhuelga@gmail.com>
Date: Wed, 29 Oct 2014 18:29:11 +0100
Subject: [PATCH] org-capture.el: Fix expand template order

* lisp/org-capture.el (org-capture-fill-template): expand %(sexp) after
  %:keywords

When a template is expanded first the simple %-escapes, %:keywords and
after that the %(sexp).

Patch proposal by Roberto Huelga Díaz.

TINYCHANGE
---
 lisp/org-capture.el |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9f8107e..65de098 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1608,8 +1608,6 @@ The template may still contain \"%?\" for cursor positioning."
 		(insert-file-contents filename)
 	      (error (insert (format "%%![Couldn't insert %s: %s]"
 				     filename error)))))))
-      ;; %() embedded elisp
-      (org-capture-expand-embedded-elisp)

       ;; The current time
       (goto-char (point-min))
@@ -1639,6 +1637,10 @@ The template may still contain \"%?\" for cursor positioning."
 					(intern (match-string 1))) ""))
 		 (replace-match x t t)))))

+      ;; %() embedded elisp
+      (goto-char (point-min))
+      (org-capture-expand-embedded-elisp)
+
       ;; Turn on org-mode in temp buffer, set local variables
       ;; This is to support completion in interactive prompts
       (let ((org-inhibit-startup t)) (org-mode))
--
1.7.10.2 (Apple Git-33)

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

* Re: Patch org-capure-fill-template
  2014-10-29 17:46 Patch org-capure-fill-template Roberto Huelga
@ 2014-10-30 15:48 ` Nicolas Goaziou
  2014-10-30 16:21   ` Roberto Huelga
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-10-30 15:48 UTC (permalink / raw)
  To: Roberto Huelga; +Cc: emacs-orgmode

Hello,

Roberto Huelga <rhuelga@gmail.com> writes:

> Patch proposal fro org-capture-fill-template

Thanks for your patch. However, I'd like to know your motivation for it
as I fail to see how it is superior to the current design.


Regards,

-- 
Nicolas Goaziou

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

* Re: Patch org-capure-fill-template
  2014-10-30 15:48 ` Nicolas Goaziou
@ 2014-10-30 16:21   ` Roberto Huelga
  2014-11-02  9:44     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Roberto Huelga @ 2014-10-30 16:21 UTC (permalink / raw)
  To: Roberto Huelga, emacs-orgmode

Suppose you want to write the parent directory name in your capture so write a
template like

"* %(file-name-nondirectory (directory-file-name (file-name-directory \"%F\")))"

Without the patch, file-name-directory get the useless string "%F"
instead of a string
with the full path name of the file.

The orgmode manual template expansion page describe

     %(sexp)     Evaluate Elisp sexp and replace with the result.
                       For convenience, %:keyword (see below) placeholders
                       within the expression will be expanded prior to this.
                       The sexp must return a string.

But without the patch is not true, first is expanded %(sexp) and after
that the %OneLetter and later the %:keyword

Thanks for your work at the awesome orgmode.


2014-10-30 16:48 GMT+01:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:
> Hello,
>
> Roberto Huelga <rhuelga@gmail.com> writes:
>
>> Patch proposal fro org-capture-fill-template
>
> Thanks for your patch. However, I'd like to know your motivation for it
> as I fail to see how it is superior to the current design.
>
>
> Regards,
>
> --
> Nicolas Goaziou

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

* Re: Patch org-capure-fill-template
  2014-10-30 16:21   ` Roberto Huelga
@ 2014-11-02  9:44     ` Nicolas Goaziou
  2014-11-02 19:59       ` Roberto Huelga
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-11-02  9:44 UTC (permalink / raw)
  To: Roberto Huelga; +Cc: emacs-orgmode

Roberto Huelga <rhuelga@gmail.com> writes:

> Suppose you want to write the parent directory name in your capture so write a
> template like
>
> "* %(file-name-nondirectory (directory-file-name (file-name-directory \"%F\")))"
>
> Without the patch, file-name-directory get the useless string "%F"
> instead of a string
> with the full path name of the file.
>
> The orgmode manual template expansion page describe
>
>      %(sexp)     Evaluate Elisp sexp and replace with the result.
>                        For convenience, %:keyword (see below) placeholders
>                        within the expression will be expanded prior to this.
>                        The sexp must return a string.
>
> But without the patch is not true, first is expanded %(sexp) and after
> that the %OneLetter and later the %:keyword

Understood. Applied, thank you.

Regards,

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

* Re: Patch org-capure-fill-template
  2014-11-02  9:44     ` Nicolas Goaziou
@ 2014-11-02 19:59       ` Roberto Huelga
  2014-11-02 21:41         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Roberto Huelga @ 2014-11-02 19:59 UTC (permalink / raw)
  To: Roberto Huelga, emacs-orgmode

I founded a section in the org-contribute.html with the names of the
tiny change contributors,
Do you know how could I get my name there? This is my second
tinychange patch. And
get my name in the list will make my day.

Thanks

2014-11-02 10:44 GMT+01:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:
> Roberto Huelga <rhuelga@gmail.com> writes:
>
>> Suppose you want to write the parent directory name in your capture so write a
>> template like
>>
>> "* %(file-name-nondirectory (directory-file-name (file-name-directory \"%F\")))"
>>
>> Without the patch, file-name-directory get the useless string "%F"
>> instead of a string
>> with the full path name of the file.
>>
>> The orgmode manual template expansion page describe
>>
>>      %(sexp)     Evaluate Elisp sexp and replace with the result.
>>                        For convenience, %:keyword (see below) placeholders
>>                        within the expression will be expanded prior to this.
>>                        The sexp must return a string.
>>
>> But without the patch is not true, first is expanded %(sexp) and after
>> that the %OneLetter and later the %:keyword
>
> Understood. Applied, thank you.
>
> Regards,

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

* Re: Patch org-capure-fill-template
  2014-11-02 19:59       ` Roberto Huelga
@ 2014-11-02 21:41         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2014-11-02 21:41 UTC (permalink / raw)
  To: Roberto Huelga; +Cc: emacs-orgmode

Roberto Huelga <rhuelga@gmail.com> writes:

> I founded a section in the org-contribute.html with the names of the
> tiny change contributors,
> Do you know how could I get my name there? This is my second
> tinychange patch. And
> get my name in the list will make my day.

Your name is already in that list. You may need to refresh your
browser's cache.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2014-11-02 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 17:46 Patch org-capure-fill-template Roberto Huelga
2014-10-30 15:48 ` Nicolas Goaziou
2014-10-30 16:21   ` Roberto Huelga
2014-11-02  9:44     ` Nicolas Goaziou
2014-11-02 19:59       ` Roberto Huelga
2014-11-02 21:41         ` Nicolas Goaziou

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