From mboxrd@z Thu Jan 1 00:00:00 1970 From: Allen Li Subject: Re: Bug: protocol capture without url corrupts org-stored-links [9.1.14 (9.1.14-1059-gadec50-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20181211/)] Date: Tue, 11 Dec 2018 19:38:06 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000c8bc03057ccaed27" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWvLo-00036c-Il for emacs-orgmode@gnu.org; Tue, 11 Dec 2018 22:38:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWvLn-0002Md-MI for emacs-orgmode@gnu.org; Tue, 11 Dec 2018 22:38:20 -0500 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]:39644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWvLn-0002MA-EO for emacs-orgmode@gnu.org; Tue, 11 Dec 2018 22:38:19 -0500 Received: by mail-io1-xd29.google.com with SMTP id k7so13695772iob.6 for ; Tue, 11 Dec 2018 19:38:19 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode List --000000000000c8bc03057ccaed27 Content-Type: text/plain; charset="UTF-8" Attached patch I didn't realize that org-protocol-capture is documented for URLs, since the concept of capturing through org-protocol is useful for non-web browser contexts. Anyway, I'm not interested in updating the documentation for org-protocol-capture at the moment, but even if org-protocol-capture is documented to need a URL, it seems wrong for it to corrupt org-stored-links but otherwise function correctly if a URL was not provided. On Tue, Dec 11, 2018 at 7:18 PM Allen Li wrote: > > Using Org protocol capture without supplying a URL inserts a corrupt > entry into org-stored-links (nil ""). The nil causes a type error later > in org-insert-link. > > (defun org-protocol-do-capture (info) > "Perform the actual capture based on INFO." > (let* ((temp-parts (org-protocol-parse-parameters info)) > (parts > (cond > ((and (listp info) (symbolp (car info))) info) > ((= (length (car temp-parts)) 1) ;; First parameter is exactly one > character long > (org-protocol-assign-parameters temp-parts '(:template :url :title :body))) > (t > (org-protocol-assign-parameters temp-parts '(:url :title :body))))) > (template (or (plist-get parts :template) > org-protocol-default-template-key)) > (url (and (plist-get parts :url) (org-protocol-sanitize-uri (plist-get > parts :url)))) > (type (and url (string-match "^\\([a-z]+\\):" url) (match-string 1 url))) > (title (or (plist-get parts :title) "")) > (region (or (plist-get parts :body) "")) > (orglink (if url > (org-make-link-string > url (if (string-match "[^[:space:]]" title) title url)) > title)) > (org-capture-link-is-already-stored t)) ;; avoid call to org-store-link > (setq org-stored-links > (cons (list url title) org-stored-links)) > > > Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) > of 2018-07-05 > Package: Org mode version 9.1.14 (9.1.14-1059-gadec50-elpaplus @ > /home/ionasal/.emacs.d/elpa/org-plus-contrib-20181211/) --000000000000c8bc03057ccaed27 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-org-protocol-Don-t-corrupt-org-stored-link-if-url-is.patch" Content-Disposition: attachment; filename="0001-org-protocol-Don-t-corrupt-org-stored-link-if-url-is.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jpkmf0d80 RnJvbSAxMTJlZjE3ZGVjOGFhN2RmYWJhNWQ2ZWUwMDE4ZDhmZTNiNjYzOWU2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbGxlbiBMaSA8ZGFya2ZlbGluZUBmZWxlc2F0cmEubW9lPgpE YXRlOiBUdWUsIDExIERlYyAyMDE4IDE5OjMyOjU2IC0wODAwClN1YmplY3Q6IFtQQVRDSF0gb3Jn LXByb3RvY29sOiBEb24ndCBjb3JydXB0IG9y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