From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] org-protocol: fixes open-source and extends rewriting of URLs Date: Wed, 28 Jun 2017 11:32:50 +0200 Message-ID: <87injgh2yl.fsf@nicolasgoaziou.fr> References: <68E12968-9AF5-440A-B22C-AC55B70BA910@schnuddelhuddel.de> <87k248b6p8.fsf@nicolasgoaziou.fr> <7C76EDC3-CC7E-4AFE-B45B-867752C1B33A@schnuddelhuddel.de> <87a8519rlg.fsf@nicolasgoaziou.fr> <8760fp9mui.fsf@nicolasgoaziou.fr> <2FAD7DF2-2A0C-4703-A383-BA8D3346C691@schnuddelhuddel.de> <18D83D3C-C472-4614-988F-1F1DA5EB5CEC@schnuddelhuddel.de> <87efub7psj.fsf@nicolasgoaziou.fr> <8CE2CFE3-2911-4369-8E93-E80CD25FD7E4@schnuddelhuddel.de> <5442AC7A-D45E-46FE-A3A7-3AB25679B3FE@schnuddelhuddel.de> <4427263B-5534-4FFD-AFA0-211EDA489001@schnuddelhuddel.de> <8760fk4jur.fsf@nicolasgoaziou.fr> <87mv8uv5ns.fsf@nicolasgoaziou.fr> <92533F36-7529-496B-BA7B-8ED49FBFB3D2@schnuddelhuddel.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQ9LH-0007ET-Fn for emacs-orgmode@gnu.org; Wed, 28 Jun 2017 05:33:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQ9LD-0006fj-29 for emacs-orgmode@gnu.org; Wed, 28 Jun 2017 05:32:59 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:53473) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQ9LC-0006ek-Ob for emacs-orgmode@gnu.org; Wed, 28 Jun 2017 05:32:54 -0400 In-Reply-To: <92533F36-7529-496B-BA7B-8ED49FBFB3D2@schnuddelhuddel.de> (Mario Martelli's message of "Tue, 27 Jun 2017 08:54:08 +0200") 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: Mario Martelli Cc: emacs-orgmode@gnu.org Hello, Mario Martelli writes: > Sorry for producing noise. Just read the contribution guidelines once again ;) > Hope everything is now according to the guidelines. Thank you. Comments follow. > Subject: [PATCH 1/4] org-protocol.el: Fix for failing open-source subprotocol > > * (org-protocol-open-source): make sure url is > sanitised before processing Applied. > Subject: [PATCH 2/4] org-protocol.el: Fix for silently failing open-source > subprotocol > > * (org-protocol-open-source): tests URL against > base-url and not the filename Applied. > Subject: [PATCH 3/4] org-protocol.el sources with date URL are supported > > * (org-protocol-project-alist): date-URL is added as example > * (org-protocol-open-source): first match is processed in rewrite Not applied. See below. > + :rewrites ((\"org/?$\" . \"index.php\"))) > + (\"Hugo based blog\" > + :base-url \"https://themes.gohugo.io/theme/hugo-icarus/\" > + :working-directory \"~/Documents/MyBlog/themes/hugo-icarus-theme/exampleSite/content/post/\" > + :online-suffix \".html\" > + :working-suffix \".md\" > + :rewrites ((\"\\(https://themes.gohugo.io/theme/hugo-icarus/[0-9]+/[0-9]+/[0-9]+/\\)\" . \".md\"))))) Would it be possible to make the path involved smaller so that the example can fit in 80 columns? > The last line tells `org-protocol-open-source' to open > /home/user/org/index.php, if the URL cannot be mapped to an existing > @@ -554,8 +561,13 @@ The location for a browser's bookmark should look like this: > ;; Try to match a rewritten URL and map it to > ;; a real file. Compare redirects without > ;; suffix. > - (when (string-match-p (car rewrite) f1) > - (throw 'result (concat wdir (cdr rewrite)))))))) > + (when (string-match (car rewrite) f1) > + (setq replacement (cdr rewrite)) Here, `replacement' isn't lexically bound, so compiling "org-protocol.el" should return an error. `replacement' should be let-bound instead. > + (if (match-string 0 f1) AFAIU, (match-string 0 f1) is necessarily true, per the (string-match (car rewrite) f1) above, so the test can be removed. > + (setq replacement (concat > + (directory-file-name (replace-match "" nil nil f1 1)) > + replacement ))))) Spurious white space character before the parenthesis. > + (throw 'result (concat wdir replacement))))) Shouldn't the (throw ...) be within the (when (string-match ...)) as it was before? I may be wrong. I didn't check the high level logic of the patch since I don't know "org-protocol.el". > Applied for it just now. Have marked the changes as tiny. Great. Let me know when the process is complete. Regards, -- Nicolas Goaziou 0x80A93738