emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
@ 2012-12-31  1:23 Ryo TAKAISHI
  2012-12-31 10:11 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Ryo TAKAISHI @ 2012-12-31  1:23 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: 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)

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

* Re: [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
  2012-12-31  1:23 [PATCH] org-protocol: Pass optional value using query in url to capture from protocol Ryo TAKAISHI
@ 2012-12-31 10:11 ` Bastien
  2013-01-01  9:10   ` Ryo TAKAISHI
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bastien @ 2012-12-31 10:11 UTC (permalink / raw)
  To: Ryo TAKAISHI; +Cc: emacs-orgmode

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

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

* Re: [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
  2012-12-31 10:11 ` Bastien
@ 2013-01-01  9:10   ` Ryo TAKAISHI
  2013-03-03  1:06   ` Ryo Takaishi
  2013-03-04  0:13   ` Ryo TAKAISHI
  2 siblings, 0 replies; 6+ messages in thread
From: Ryo TAKAISHI @ 2013-01-01  9:10 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hello,
Bastien

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

Regards,
Ryo

Bastien <bzg@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!

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

* Re: [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
  2012-12-31 10:11 ` Bastien
  2013-01-01  9:10   ` Ryo TAKAISHI
@ 2013-03-03  1:06   ` Ryo Takaishi
  2013-03-04  0:13   ` Ryo TAKAISHI
  2 siblings, 0 replies; 6+ messages in thread
From: Ryo Takaishi @ 2013-03-03  1:06 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]

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 <bzg@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

[-- Attachment #2: Type: text/html, Size: 4129 bytes --]

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

* Re: [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
  2012-12-31 10:11 ` Bastien
  2013-01-01  9:10   ` Ryo TAKAISHI
  2013-03-03  1:06   ` Ryo Takaishi
@ 2013-03-04  0:13   ` Ryo TAKAISHI
  2013-03-04  0:16     ` Bastien
  2 siblings, 1 reply; 6+ messages in thread
From: Ryo TAKAISHI @ 2013-03-04  0:13 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

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

* Re: [PATCH] org-protocol: Pass optional value using query in url to capture from protocol.
  2013-03-04  0:13   ` Ryo TAKAISHI
@ 2013-03-04  0:16     ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2013-03-04  0:16 UTC (permalink / raw)
  To: Ryo TAKAISHI; +Cc: emacs-orgmode

Hi Ryo,

Ryo TAKAISHI <ryo.takaishi.0@gmail.com> writes:

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

Applied, thanks a lot!

-- 
 Bastien

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

end of thread, other threads:[~2013-03-04  0:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-31  1:23 [PATCH] org-protocol: Pass optional value using query in url to capture from protocol Ryo TAKAISHI
2012-12-31 10:11 ` Bastien
2013-01-01  9:10   ` Ryo TAKAISHI
2013-03-03  1:06   ` Ryo Takaishi
2013-03-04  0:13   ` Ryo TAKAISHI
2013-03-04  0:16     ` Bastien

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