emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* %( in capture template
@ 2017-01-10 19:16 Samuel Wales
  2017-01-10 23:38 ` Nick Dokos
  2017-01-11  0:00 ` Nicolas Goaziou
  0 siblings, 2 replies; 14+ messages in thread
From: Samuel Wales @ 2017-01-10 19:16 UTC (permalink / raw)
  To: emacs-orgmode

i have "%(my-function \"%:link\" \"%:description\" \"%i\")" in a
capture template, which now does not run the function but treats it as
text.  i get that this is for security.  what do i do?

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.
  UPDATE 2016-10: home, but not fully free

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

* Re: %( in capture template
  2017-01-10 19:16 %( in capture template Samuel Wales
@ 2017-01-10 23:38 ` Nick Dokos
  2017-01-11  0:20   ` Samuel Wales
  2017-01-11  0:00 ` Nicolas Goaziou
  1 sibling, 1 reply; 14+ messages in thread
From: Nick Dokos @ 2017-01-10 23:38 UTC (permalink / raw)
  To: emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> i have "%(my-function \"%:link\" \"%:description\" \"%i\")" in a
> capture template, which now does not run the function but treats it as
> text.  i get that this is for security.  what do i do?

IIUC, if the function call is part of the template that is inserted as a
result of the capture, the function should still be executed: I see
calls to `org-capture-expand-embedded-elisp' still in
`org-capture'. Can you post the full entry?

-- 
Nick

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

* Re: %( in capture template
  2017-01-10 19:16 %( in capture template Samuel Wales
  2017-01-10 23:38 ` Nick Dokos
@ 2017-01-11  0:00 ` Nicolas Goaziou
  2017-03-13  1:45   ` Samuel Wales
  1 sibling, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2017-01-11  0:00 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> i have "%(my-function \"%:link\" \"%:description\" \"%i\")" in a
> capture template, which now does not run the function but treats it as
> text.

It should. Do you have an ECM?

Regards,

-- 
Nicolas Goaziou

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

* Re: %( in capture template
  2017-01-10 23:38 ` Nick Dokos
@ 2017-01-11  0:20   ` Samuel Wales
  2017-01-11  8:56     ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2017-01-11  0:20 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

On 1/10/17, Nick Dokos <ndokos@gmail.com> wrote:
> IIUC, if the function call is part of the template that is inserted as a
> result of the capture, the function should still be executed: I see
> calls to `org-capture-expand-embedded-elisp' still in
> `org-capture'. Can you post the full entry?

here are the entries:

("p" "Protocol p" entry
      (file+headline "/home/org/executive--a.org" "xyzzy-remember")
      "%(alpha-org-protocol-string \"%:link\" \"%:description\"
\"%i\")" :prepend t :immediate-finish t :jump-to-captured t)
 ("L" "Protocol L" entry
      (file+headline "/home/org/executive--a.org" "xyzzy-remember")
      "%(alpha-org-protocol-string \"%:link\" \"%:description\"
\"%i\")" :prepend t :immediate-finish t :jump-to-captured t)

background: this is part of my years-long effort to try to
get protocol to work from firefox.  i never got org-protocol to work
reliably in org 8, despite trying probably at least 4 separate sets of
instructions.

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.
  UPDATE 2016-10: home, but not fully free

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

* Re: %( in capture template
  2017-01-11  0:20   ` Samuel Wales
@ 2017-01-11  8:56     ` Nicolas Goaziou
  2017-01-12  2:19       ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2017-01-11  8:56 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Nick Dokos, emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> here are the entries:
>
> ("p" "Protocol p" entry
>       (file+headline "/home/org/executive--a.org" "xyzzy-remember")
>       "%(alpha-org-protocol-string \"%:link\" \"%:description\"
> \"%i\")" :prepend t :immediate-finish t :jump-to-captured t)
>  ("L" "Protocol L" entry
>       (file+headline "/home/org/executive--a.org" "xyzzy-remember")
>       "%(alpha-org-protocol-string \"%:link\" \"%:description\"
> \"%i\")" :prepend t :immediate-finish t :jump-to-captured t)

I fixed an issue with :jump-to-captured in conjunction with a nil
`org-capture-bookmark'.

Now, I can use the following template without issue

 ("B" "BUG!" entry
  (file+headline "/tmp/bug-capture.org" "test")
  "%(concat \"* headline\" \"%:link\" \"%:description\" \"%i\")"
  :prepend t :immediate-finish t :jump-to-captured t)

Note that `alpha-org-protocol-string' is expected to create a valid Org
tree (or headline).

Could you confirm it is now working as expected? Thank you.

Regards,

-- 
Nicolas Goaziou

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

* Re: %( in capture template
  2017-01-11  8:56     ` Nicolas Goaziou
@ 2017-01-12  2:19       ` Samuel Wales
       [not found]         ` <CAJcAo8u3=OqneKTpKWxBYwJW1Z-N9tQOe1-RZDD2-3OLgZkbxw@mail.gmail.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2017-01-12  2:19 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

hi nicolas,


thank you for the fix.  quick testing seems to show that it works much
better.  will keep evaluating it.

i had thought it was my own lack of understanding.

there is one problem.  when i select a few paragraphs in firefox using
org-capture extension, they get captured as one long line.  but i'm
guessing that's protocol, not capture.


samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.
  UPDATE 2016-10: home, but not fully free

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

* %( in capture template
       [not found]         ` <CAJcAo8u3=OqneKTpKWxBYwJW1Z-N9tQOe1-RZDD2-3OLgZkbxw@mail.gmail.com>
@ 2017-02-09  4:41           ` Samuel Wales
  2017-02-19  9:07             ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2017-02-09  4:41 UTC (permalink / raw)
  To: emacs-orgmode

with the new org maint code, i still occasionally get the literal string.

it occurs when the region spans a blank line.

like

  %(concat
"http://whatever.whatever/building-a-mold-free-house/whatever"
"Building a mold free house" "

these remplates [don't know if first does anything]

  (add-to-list 'org-capture-templates
               `("L" "Protocol L for link" entry
                 (file+headline ,org-default-notes-file "xyzzy-remember")
                 ;; fixme perhaps i do not need the %i, if it is for no text
                 "%(concat \"%:link\"
\"%:description\" \"%i\") L"
                 :prepend t :immediate-finish t :jump-to-captured t))
  ;; this seems to get called by org capture whether selection or not
  (add-to-list 'org-capture-templates
               `("p" "Protocol p" entry
                 (file+headline ,org-default-notes-file "xyzzy-remember")
                 "%(concat \"%:link\"
\"%:description\" \"%i\")"
                 :prepend t :immediate-finish t :jump-to-captured t))

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it -- at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." --- very true words by Johanna Kaiser spoken to US NIH in
conference call with Walter Koroshetz, NINDS director
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>

Denmark: free Karina Hansen NOW.
  UPDATE 2016-10: home, but not fully free

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

* Re: %( in capture template
  2017-02-09  4:41           ` Samuel Wales
@ 2017-02-19  9:07             ` Nicolas Goaziou
  2017-02-19 23:34               ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2017-02-19  9:07 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> with the new org maint code, i still occasionally get the literal string.
>
> it occurs when the region spans a blank line.

I cannot reproduce your issue.

> like
>
>   %(concat
> "http://whatever.whatever/building-a-mold-free-house/whatever"
> "Building a mold free house" "

I have trouble understanding the double quote above. Do you mean the
text below is inserted within the %(concat ...) or are these your
templates? In this case, which one produces the error?

> these remplates [don't know if first does anything]
>
>   (add-to-list 'org-capture-templates
>                `("L" "Protocol L for link" entry
>                  (file+headline ,org-default-notes-file "xyzzy-remember")
>                  ;; fixme perhaps i do not need the %i, if it is for no text
>                  "%(concat \"%:link\"
> \"%:description\" \"%i\") L"
>                  :prepend t :immediate-finish t :jump-to-captured t))
>   ;; this seems to get called by org capture whether selection or not
>   (add-to-list 'org-capture-templates
>                `("p" "Protocol p" entry
>                  (file+headline ,org-default-notes-file "xyzzy-remember")
>                  "%(concat \"%:link\"
> \"%:description\" \"%i\")"
>                  :prepend t :immediate-finish t :jump-to-captured t))

Regards,

-- 
Nicolas Goaziou

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

* Re: %( in capture template
  2017-02-19  9:07             ` Nicolas Goaziou
@ 2017-02-19 23:34               ` Samuel Wales
  2017-02-19 23:34                 ` Samuel Wales
  2017-03-07  3:45                 ` Samuel Wales
  0 siblings, 2 replies; 14+ messages in thread
From: Samuel Wales @ 2017-02-19 23:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 2/19/17, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> I have trouble understanding the double quote above. Do you mean the
> text below is inserted within the %(concat ...) or are these your
> templates? In this case, which one produces the error?

thanks for asking about this.

for clarity, let's do it from the beginning.

[first please note that i am experiencing random results.  sometimes
it works fine but:

  1] sometimes nothing shows up
  2] sometimes as i will describe below
  3] sometimes nothing shows up, but "Warning (emacs): Please update
your org protocol handler to deal with new-style links." buffer pops
up

what i will describe is 2, which is the topic of this thread.]

just now i selected the first two paragraphs of the quote of your
email, and clicked the org-capture extension unicorn.

i use this function:

(defun alpha-org-protocol-string (link description region)
  (format "* x
           link %s
           description %s
           region %s
           " link description region))

the result of clicking on the unicorn:

===
***** x
           link
https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c
           description Gmail - %( in capture template
           region
%(alpha-org-protocol-string
"https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
"Gmail - %( in capture template" "> with the new org maint code, i
still occasionally get the literal string.
%(alpha-org-protocol-string
"https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
"Gmail - %( in capture template" ">
%(alpha-org-protocol-string
"https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
"Gmail - %( in capture template" "> it occurs when the region spans a
blank line.
===

region should be what i selected.  instead it is a garbled version of
what i selected with the literal function call text.  is this user
error?

the double quotes are as you see them.  i did not add any.

below are my templates.

  (add-to-list 'org-capture-templates
               `("L" "Protocol L for link" entry
                 (file+headline ,org-default-notes-file "xyzzy-remember")
                 ;; fixme perhaps i do not need the %i, if it is for no text
                 "%(alpha-org-protocol-string \"%:link\"
\"%:description\" \"%i\") L"
                 :prepend t :immediate-finish t :jump-to-captured t))
  ;; this seems to get called by org capture whether selection or not
  (add-to-list 'org-capture-templates
               `("p" "Protocol p" entry
                 (file+headline ,org-default-notes-file "xyzzy-remember")
                 "%(alpha-org-protocol-string \"%:link\"
\"%:description\" \"%i\")"
                 :prepend t :immediate-finish t :jump-to-captured t))

the org capture extension is set to p, so the second one should be the
operative one.  but what do i know?

so perhaps %i is being set to some crazy value.

i definitely do not understand any of this stuff.

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

* Re: %( in capture template
  2017-02-19 23:34               ` Samuel Wales
@ 2017-02-19 23:34                 ` Samuel Wales
  2017-03-07  3:45                 ` Samuel Wales
  1 sibling, 0 replies; 14+ messages in thread
From: Samuel Wales @ 2017-02-19 23:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

the above bug description pertains to recent org maint.

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

* Re: %( in capture template
  2017-02-19 23:34               ` Samuel Wales
  2017-02-19 23:34                 ` Samuel Wales
@ 2017-03-07  3:45                 ` Samuel Wales
  1 sibling, 0 replies; 14+ messages in thread
From: Samuel Wales @ 2017-03-07  3:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 2/19/17, Samuel Wales <samologist@gmail.com> wrote:
> ***** x
>            link
> https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c
>            description Gmail - %( in capture template
>            region
> %(alpha-org-protocol-string
> "https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
> "Gmail - %( in capture template" "> with the new org maint code, i
> still occasionally get the literal string.
> %(alpha-org-protocol-string
> "https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
> "Gmail - %( in capture template" ">
> %(alpha-org-protocol-string
> "https://mail.google.com/mail/u/0/h/rfjkj7op114w/?&th=15a580ccf5cb9d34&v=c"
> "Gmail - %( in capture template" "> it occurs when the region spans a
> blank line.

intuitively, does this sound like user error, or a bug?

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

* Re: %( in capture template
  2017-01-11  0:00 ` Nicolas Goaziou
@ 2017-03-13  1:45   ` Samuel Wales
  2017-03-14  8:13     ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: Samuel Wales @ 2017-03-13  1:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

===
* ecm
capture literally inserts.  i was told this is not normal,
but a bug.

recent maint

to reproduce, evaluate the following code, select the lines
in the scratch buffer, and run m-x org-capture RET p.

set the notes file to whatever works for you.

*** code
  (require 'org-capture)
  (setq org-default-notes-file (substitute-in-file-name
"$dorg/alpha-org-testcase.org"))
  ;; (find-file org-default-notes-file)
  (defun alpha-org-testcase--create-capture-bug ()
    (add-to-list 'org-capture-templates
                 `("p" "Protocol p" entry
                   (file+headline ,org-default-notes-file "xyzzy-remember")
                   "%(alpha-org-protocol-string \"%:link\"
\"%:description\" \"%i\")"
                   :prepend t :immediate-finish t :jump-to-captured t))
    (defun alpha-org-protocol-string (link description region)
      (format "* debug org-capture
           - link %s
           - description %s
           - region %s \
           "
              link description region)))
*** the bug is below
***** debug org-capture
             - link
             - description
             - region ;; This buffer is for notes you don't want to
save, and for Lisp evaluation.
  %(alpha-org-protocol-string "" "" ";; If you want to create a file,
visit that file with C-x C-f,
  %(alpha-org-protocol-string "" "" ";; then enter the text in that
file's own buffer.
  %(alpha-org-protocol-string "" "" "
  %(alpha-org-protocol-string "" "" "
===

On 1/10/17, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> i have "%(my-function \"%:link\" \"%:description\" \"%i\")" in a
>> capture template, which now does not run the function but treats it as
>> text.
>
> It should. Do you have an ECM?
>
> Regards,
>
> --
> Nicolas Goaziou
>


-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

The NIH, FDA, and CDC are not there for you.  Not without activism.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

* Re: %( in capture template
  2017-03-13  1:45   ` Samuel Wales
@ 2017-03-14  8:13     ` Nicolas Goaziou
  2017-03-17  3:22       ` Samuel Wales
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Goaziou @ 2017-03-14  8:13 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> ===
> * ecm
> capture literally inserts.  i was told this is not normal,
> but a bug.
>
> recent maint
>
> to reproduce, evaluate the following code, select the lines
> in the scratch buffer, and run m-x org-capture RET p.
>
> set the notes file to whatever works for you.
>
> *** code
>   (require 'org-capture)
>   (setq org-default-notes-file (substitute-in-file-name
> "$dorg/alpha-org-testcase.org"))
>   ;; (find-file org-default-notes-file)
>   (defun alpha-org-testcase--create-capture-bug ()
>     (add-to-list 'org-capture-templates
>                  `("p" "Protocol p" entry
>                    (file+headline ,org-default-notes-file "xyzzy-remember")
>                    "%(alpha-org-protocol-string \"%:link\"
> \"%:description\" \"%i\")"
>                    :prepend t :immediate-finish t :jump-to-captured t))
>     (defun alpha-org-protocol-string (link description region)
>       (format "* debug org-capture
>            - link %s
>            - description %s
>            - region %s \
>            "
>               link description region)))
> *** the bug is below
> ***** debug org-capture
>              - link
>              - description
>              - region ;; This buffer is for notes you don't want to
> save, and for Lisp evaluation.
>   %(alpha-org-protocol-string "" "" ";; If you want to create a file,
> visit that file with C-x C-f,
>   %(alpha-org-protocol-string "" "" ";; then enter the text in that
> file's own buffer.
>   %(alpha-org-protocol-string "" "" "
>   %(alpha-org-protocol-string "" "" "
> ===

Thank you. I think it is fixed, now. Could you test maint branch and
report your result?

Regards,

-- 
Nicolas Goaziou

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

* Re: %( in capture template
  2017-03-14  8:13     ` Nicolas Goaziou
@ 2017-03-17  3:22       ` Samuel Wales
  0 siblings, 0 replies; 14+ messages in thread
From: Samuel Wales @ 2017-03-17  3:22 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 3/14/17, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Thank you. I think it is fixed, now. Could you test maint branch and
> report your result?

it seems to work so far.  thank you.

btw, the org-capture firefox extension is behaving more reliably also,
with recent firefox-esr.  it has been many years since i tried to get
protocol to work.

this matters because i very often only use the mouse.

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

The NIH, FDA, and CDC are not there for you.  Not without activism.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

end of thread, other threads:[~2017-03-17  3:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10 19:16 %( in capture template Samuel Wales
2017-01-10 23:38 ` Nick Dokos
2017-01-11  0:20   ` Samuel Wales
2017-01-11  8:56     ` Nicolas Goaziou
2017-01-12  2:19       ` Samuel Wales
     [not found]         ` <CAJcAo8u3=OqneKTpKWxBYwJW1Z-N9tQOe1-RZDD2-3OLgZkbxw@mail.gmail.com>
2017-02-09  4:41           ` Samuel Wales
2017-02-19  9:07             ` Nicolas Goaziou
2017-02-19 23:34               ` Samuel Wales
2017-02-19 23:34                 ` Samuel Wales
2017-03-07  3:45                 ` Samuel Wales
2017-01-11  0:00 ` Nicolas Goaziou
2017-03-13  1:45   ` Samuel Wales
2017-03-14  8:13     ` Nicolas Goaziou
2017-03-17  3:22       ` Samuel Wales

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