Re: org-capture config broken

2021-08-26 Thread Maxim Nikulin

On 26/08/2021 16:48, Orm Finnendahl wrote:


Am Mittwoch, den 25. August 2021 um 18:16:15 Uhr (+0200) schrieb Maxim
Nikulin:


Unfortunately you did not specify version of Org you are currently using.


Sorry, it's 9.4.4.


The changes, I were writing about, landed in 9.4.6. If you were using 
the latest version, perhaps you would not experience a problem with 
old-style URI.



$ emacsclient org-protocol:/capture?template=m?url=URL&title=TITLE&body=BODY
Waiting for Emacs...
*ERROR*: No capture template referred to by "m?url" keys

Thanks for the hint! If this example is still in the master branch
maybe that should get fixed (or the code if it should work with a
question mark).


I just took the example from the manual at the web site. Then I realized 
that it looked strange and fixed it. Unfortunately I missed one question 
mark. The example in master and maint branches is correct. Thank you for 
drawing attention to this issue.






Re: org-capture config broken

2021-08-26 Thread Orm Finnendahl
Hi,

Am Mittwoch, den 25. August 2021 um 18:16:15 Uhr (+0200) schrieb Maxim
Nikulin:
> 
> Unfortunately you did not specify version of Org you are currently using.

Sorry, it's 9.4.4.

> This the old style of Org protocol URI. See
> https://orgmode.org/manual/The-capture-protocol.html for an example
> of modern variant (it has typos fixed in master branch, some "?"
> should be "&"). I am unsure concerning order of parameters in
> old-style URLs.

Thanks, that helped! In my version the following (which I had tried
before following the org manual page you mention) throws an error, as
it seems to expect an ampersand after the template name:

$ emacsclient org-protocol:/capture?template=m?url=URL&title=TITLE&body=BODY
Waiting for Emacs...
*ERROR*: No capture template referred to by "m?url" keys

This works:

emacsclient org-protocol:/capture?template=m&url=URL&title=TITLE&body=BODY

Thanks for the hint! If this example is still in the master branch
maybe that should get fixed (or the code if it should work with a
question mark).

Best,
Orm



Re: org-capture config broken (org-protocol URI syntax)

2021-08-25 Thread Maxim Nikulin

On 25/08/2021 19:05, Orm Finnendahl wrote:


  I use a custom script (dating back to a post from 2013) to capture my
mutt Emails using org-capture. It worked flawlessly but stopped
working some time ago (I don't exactly know, when, probably last
year).


Unfortunately you did not specify version of Org you are currently using.


I assume the code has changed and doesn't accept the syntax of the
org-protocol line any more.

emacsclient 
org-protocol:/capture:/m/mutt:ysyuf6skfsbwt...@example.com/mail/%20%20Subject%3A%20test%0A%20%20%20%20From%3A%20Unknown%20%3Cdummy%40example.com%3E


This the old style of Org protocol URI. See 
https://orgmode.org/manual/The-capture-protocol.html for an example of 
modern variant (it has typos fixed in master branch, some "?" should be 
"&"). I am unsure concerning order of parameters in old-style URLs. 
Older syntax should still be supported (a warning requesting update may 
be issued however), unfortunately there were some issues, see e.g. 
https://orgmode.org/list/s4cjck$156g$2...@ciao.gmane.io


Some details: https://orgmode.org/Changes_old.html#org3da1425 (news for 
version 9.0)



The emacsclient commmand above is generated with a perl script using
uri_escape for everything after /mail/. The single slashes in the
protocol line of the emacsclient command seem strange, but I couldn't
find any hint in the internet how the syntax is supposed to be for a
certain org-capture-template.


I suggest you to update perl script to generate URI with key-value 
parameters in query part.


Concerning number of slashes, I suppose, the following should minimize 
issues with desktop integration and intermediate bugs in various 
versions of Org


org-protocol:/capture?template=X?url=URL&title=TITLE&body=BODY

namely no double slash after org-protocol otherwise in some cases slash 
might be inserted before question mark or second colon might be dropped 
in old-style URI. With double slash subprotocol might be interpreted as 
host name causing further normalization as dropping colon that is not 
followed by port number or adding path "/" before query part. Such 
considerations however are not applied for direct invocation of emacsclient.


Emacsclient considers org-protocol URI as relative path, so it prepends 
argument with current working directory and squashes multiple slashes 
into single ones. That is why it does not matter how much consequent 
slashes are used in emacsclient command, however desktop-wide handlers 
may modify URI depending on number of slashes.


Latest releases should tolerate URIs with slash before question mark like

org-protocol://capture/?template=X?url=URL&title=TITLE&body=BODY




org-capture config broken

2021-08-25 Thread Orm Finnendahl
Hi,

 I use a custom script (dating back to a post from 2013) to capture my
mutt Emails using org-capture. It worked flawlessly but stopped
working some time ago (I don't exactly know, when, probably last
year).

I assume the code has changed and doesn't accept the syntax of the
org-protocol line any more.

I'm calling emacsclient with the following command:

emacsclient 
org-protocol:/capture:/m/mutt:ysyuf6skfsbwt...@example.com/mail/%20%20Subject%3A%20test%0A%20%20%20%20From%3A%20Unknown%20%3Cdummy%40example.com%3E

It fails printing "*ERROR*: Wrong type argument: arrayp, nil" in the terminal 
and posts

"Greedy org protocol handler. Killing client"

in the minibuffer.

The emacsclient commmand above is generated with a perl script using
uri_escape for everything after /mail/. The single slashes in the
protocol line of the emacsclient command seem strange, but I couldn't
find any hint in the internet how the syntax is supposed to be for a
certain org-capture-template.

Maybe someone can help to debug it? Below is my init.el configuration.

Best,
Orm

(setq org-capture-templates
  (quote
   (("m"
 "Mail"
 entry
 (file+headline "~/work/gtd.org" "Incoming")
 "* %^{Title}\n  Source: %u, %:link\n  %i"
 :empty-lines 1)
;; ... more templates here ...
)))
;; ensure that emacsclient will show just the note to be edited when invoked
;; from Mutt, and that it will shut down emacsclient once finished;
;; fallback to legacy behavior when not invoked via org-protocol.
(add-hook 'org-capture-mode-hook 'delete-other-windows)
(setq my-org-protocol-flag nil)
(defadvice org-capture-finalize (after delete-frame-at-end activate)
  "Delete frame at remember finalization"
  (progn (if my-org-protocol-flag (delete-frame))
 (setq my-org-protocol-flag nil)))
(defadvice org-capture-kill (after delete-frame-at-end activate)
  "Delete frame at remember abort"
  (progn (if my-org-protocol-flag (delete-frame))
 (setq my-org-protocol-flag nil)))
(defadvice org-protocol-capture (before set-org-protocol-flag activate)
  (setq my-org-protocol-flag t))