From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id aLvbKOiWuF4pbgAA0tVLHw (envelope-from ) for ; Mon, 11 May 2020 00:06:00 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4DRpGPaWuF4PfAAAB5/wlQ (envelope-from ) for ; Mon, 11 May 2020 00:06:14 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F3C67941159 for ; Mon, 11 May 2020 00:06:10 +0000 (UTC) Received: from localhost ([::1]:59330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXvxS-0000b6-JM for larch@yhetil.org; Sun, 10 May 2020 20:06:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXvwg-0000aw-8g for emacs-orgmode@gnu.org; Sun, 10 May 2020 20:05:22 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42270) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jXvwe-00057D-Hi for emacs-orgmode@gnu.org; Sun, 10 May 2020 20:05:21 -0400 Received: by mail-wr1-x442.google.com with SMTP id s8so8743576wrt.9 for ; Sun, 10 May 2020 17:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=PdZks5BpotvyQksS/VCXV57rYzpnKeIxfSwlg7KWemw=; b=eUMRpNn80/koIIoz/3q0REQY2UVaJ0SlbvKqvb64WHSd+Yt8DzKTbMzYdwEvyqmdoE bdEFMa3hr9fPfnoV0x8roncu62lkWgE7Sg6OoMyO/NvQ58a4g4KVk/pb0Yew0VYOO+ka S9lckh4JG7IfLvULzuGSQAdp5haJfbqSrydYsbg0p9q3h4dJhJbnlBqzL4W8m+7H+kRD WduRm4PY27V4ZLKwa+t4DvrZxh4qs5G0L8sdlxxPbrcKiSi53NBAsCD8UyTOqfn0PF7o biuMMRKS3DC9PJVDYSPW506Qz3CxHVzUEEAKVzm9iy2t2RdOZspmLGnqNSAMIFcqtwqA T84Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=PdZks5BpotvyQksS/VCXV57rYzpnKeIxfSwlg7KWemw=; b=nr6xyMjv+kIo3TLcC00tiq3WHovcg+hBgecLp7nc1G0Se0Hm3llOM+LI8GWaOKBkCn VcOU/6I09ZDhPVnHf18qrLFST+2EVckPTuTnUUsfQyF2zxqtjuNocg1ASwYVImJEUi3Z aH97b78+qkFCm+wAykGAjAa7U6n7uCYPu5eOW9pbMrvC06cOjl+qYkSqKTFhZhJMhNBp j3vLosD5sWaqDtLmWmb4micSMKnn4SR+YAq8OlEsRHGwI7LG2k4/KPiqWG2CEj4vI9HA 97L0JeRagB8Hg+SEL/jlwEg7vvj2ejuVOYVlHpLzZ/2bHCVc5fVf9t40b3N1su+QH0Lt iDsg== X-Gm-Message-State: AGi0PuZzRGWyTK39cPWnsUFsU7GS47WrYNRbC2rz+JCCS1X/j1VNrUM1 7NC+9ASDY8SuoqQmRTVZui8= X-Google-Smtp-Source: APiQypLV+tvbHcyOR4fYnYRtn+DgC3jUigS8MqMGVbIlFscMIJFJS5+jXZQ5gdw/ud6Fprq2x+yJoA== X-Received: by 2002:adf:f684:: with SMTP id v4mr15407062wrp.218.1589155518491; Sun, 10 May 2020 17:05:18 -0700 (PDT) Received: from [192.168.0.38] (cpc81195-farn9-2-0-cust897.6-2.cable.virginm.net. [82.6.59.130]) by smtp.gmail.com with ESMTPSA id j2sm15275884wrp.47.2020.05.10.17.05.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2020 17:05:17 -0700 (PDT) From: "Stacey Marshall" To: "Nicolas Goaziou" Subject: Re: patch for org-capture.el to allow for no file extension on open-source, protocol Date: Mon, 11 May 2020 01:05:14 +0100 X-Mailer: MailMate (1.13.1r5671) Message-ID: <8882FF49-05B4-4ADD-8180-F14E9DB70138@gmail.com> In-Reply-To: <87lfm0ymkr.fsf@nicolasgoaziou.fr> References: <87lfm0ymkr.fsf@nicolasgoaziou.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_MailMate_0DC55EE9-8870-451D-8596-EEA86DB6CA5E_=" Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=stacey.marshall@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -0.71 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=eUMRpNn8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-0.71 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.53918578218302]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[gmail.com]; HAS_ATTACHMENT(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.08), country: US(-0.00), ip: 209.51.188.17(-0.54)]; DWL_DNSWL_BLOCKED(0.00)[gmail.com:dkim,209.51.188.17:from]; DKIM_TRACE(0.00)[gmail.com:+]; CTYPE_MIXED_BOGUS(1.00)[]; RCPT_COUNT_TWO(0.00)[2]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:~,4:+,5:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[housegordon.com:url,blog-example.com:url,orgmode.org:url,site.com:url]; FROM_NEQ_ENVFROM(0.00)[staceymarshall@gmail.com,emacs-orgmode-bounces@gnu.org]; MIME_GOOD(-0.10)[multipart/mixed,multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[82.6.59.130:received]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 0oEsgSRST1h2 --=_MailMate_0DC55EE9-8870-451D-8596-EEA86DB6CA5E_= Content-Type: multipart/alternative; boundary="=_MailMate_6128D387-6FEB-439C-8981-F52B2A8FFD36_=" --=_MailMate_6128D387-6FEB-439C-8981-F52B2A8FFD36_= Content-Type: text/plain; format=flowed; markup=markdown On 10 May 2020, at 13:57, Nicolas Goaziou wrote: > Hello, > > "Stacey Marshall" writes: > >> The issue was that the URL I was opening had the full filename as-is. >> No extension needed to be added or removed. If no suffix is provided >> in the alist then the function failed. The patch allows both >> online-suffix and working-suffix to not be required. > > Thank you. Could you add a test in "test-org-protocol.el" ? > > Regards, > > -- > Nicolas Goaziou Hi Nicolas, Test patch below. I've attached both patch files too. ``` From 9263002dc97753e297f8571511839eea0b39252e Mon Sep 17 00:00:00 2001 From: Stacey Marshall Date: Mon, 11 May 2020 00:58:40 +0100 Subject: [PATCH 2/2] test-org-protocol.el: Fix tests and add new test for as-is filename. * testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-parse-parameters): Fix issue of missing flag to indicate new paramenter testing. * testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-open-source): Fix test3 which was not working. Add test4, for opening file name as-is without suffix modification. Tested using ert. TINYCHANGE --- testing/lisp/test-org-protocol.el | 37 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-protocol.el index 6ee368dcf..42ad5e1a3 100644 --- a/testing/lisp/test-org-protocol.el +++ b/testing/lisp/test-org-protocol.el @@ -40,7 +40,7 @@ "url=https%3A%2F%2Forgmode.org%2Forg.html%23capture-protocol&" "title=The%20Org%20Manual&" "body=9.4.2%20capture%20protocol")) - (data (org-protocol-parse-parameters url))) + (data (org-protocol-parse-parameters url t))) (should (string= (plist-get data :template) "p")) (should (string= (plist-get data :url) "https://orgmode.org/org.html#capture-protocol")) (should (string= (plist-get data :title) "The Org Manual")) @@ -138,6 +138,8 @@ "Test org-protocol://open-source links." (let* ((temp-file-name1 (make-temp-file "org-protocol-test1")) (temp-file-name2 (make-temp-file "org-protocol-test2")) + (temp-file-name3 (make-temp-file "org-protocol-test3" nil ".md")) + (temp-file-name4 (make-temp-file "org-protocol-test4" nil ".c")) (org-protocol-project-alist `((test1 :base-url "http://example.com/" @@ -149,10 +151,13 @@ :working-directory ,(file-name-directory temp-file-name2)) (test3 :base-url "https://blog-example.com/" - :working-directory ,(file-name-directory temp-file-name2) + :working-directory ,(file-name-directory temp-file-name3) :online-suffix ".html" :working-suffix ".md" - :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\\)" . ".md"))))) + :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\\)" . ".md"))) + (test4 + :base-url "http://as-is.example.com/" + :working-directory ,(file-name-directory temp-file-name4)))) (test-cases (list ;; Old-style URLs @@ -166,6 +171,16 @@ (url-hexify-string (concat "http://another.example.com/" (file-name-nondirectory temp-file-name2) ".js"))) temp-file-name2) + (cons + (concat "/some/directory/org-protocol:/open-source:/" + (url-hexify-string + (concat "https://blog-example.com/" (file-name-nondirectory (file-name-sans-extension temp-file-name3)) ".html"))) + temp-file-name3) + (cons + (concat "/some/directory/org-protocol:/open-source:/" + (url-hexify-string + (concat "http://as-is.example.com/" (file-name-nondirectory temp-file-name4)))) + temp-file-name4) ;; New-style URLs (cons (concat "/some/directory/org-protocol:/open-source?url=" @@ -176,7 +191,17 @@ (concat "/some/directory/org-protocol:/open-source?url=" (url-hexify-string (concat "http://another.example.com/" (file-name-nondirectory temp-file-name2) ".js"))) - temp-file-name2)))) + temp-file-name2) + (cons + (concat "/some/directory/org-protocol:/open-source?url=" + (url-hexify-string + (concat "https://blog-example.com/" (file-name-nondirectory (file-name-sans-extension temp-file-name3)) ".html"))) + temp-file-name3) + (cons + (concat "/some/directory/org-protocol:/open-source?url=" + (url-hexify-string + (concat "http://as-is.example.com/" (file-name-nondirectory temp-file-name4)))) + temp-file-name4)))) (mapc (lambda (test-case) (should (string= (org-protocol-check-filename-for-protocol @@ -185,7 +210,9 @@ (cdr test-case)))) test-cases) (delete-file temp-file-name1) - (delete-file temp-file-name2))) + (delete-file temp-file-name2) + (delete-file temp-file-name3) + (delete-file temp-file-name4))) (defun test-org-protocol/org-protocol-greedy-handler (fname) ;; fname should be a list of parsed items -- 2.21.1 (Apple Git-122.3) ``` -- [Stacey](https://staceymarshall.wordpress.com/) --=_MailMate_6128D387-6FEB-439C-8981-F52B2A8FFD36_= Content-Type: text/html Content-Transfer-Encoding: quoted-printable

On 10 May 2020, at 13:57, Nicolas Goaziou wrote:

Hello,

"Stacey Marshall" stacey.marshall@gmail.com writes:

The issue was that the URL I was opening had the full fil= ename as-is.
No extension needed to be added or removed. If no suffix is provided
= in the alist then the function failed. The patch allows both
online-suffix and working-suffix to not be required.

Thank you. Could you add a test in "test-org-protocol.el"= ?

Regards,

--
Nicolas Goaziou

Hi Nicolas,

Test patch below. I've attached both patch files too.

From 9263002dc97753e297f8571511839eea0b39252e Mon Sep 17 00:00=
:00 2001
From: Stacey Marshall <stacey.marshall@gmail.com>
Date: Mon, 11 May 2020 00:58:40 +0100
Subject: [PATCH 2/2] test-org-protocol.el: Fix tests and add new test for=

 as-is filename.

* testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-parse=
-parameters):
Fix issue of missing flag to indicate new paramenter testing.

* testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-open-=
source):
Fix test3 which was not working.  Add test4, for opening file name
as-is without suffix modification.

Tested using ert.

TINYCHANGE
---
 testing/lisp/test-org-protocol.el | 37 ++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-pr=
otocol.el
index 6ee368dcf..42ad5e1a3 100644
--- a/testing/lisp/test-org-protocol.el
+++ b/testing/lisp/test-org-protocol.el
@@ -40,7 +40,7 @@
               "url=3Dhttps%3A%2F%2Forgmode.org%2Forg.html%23capture-prot=
ocol&"
               "title=3DThe%20Org%20Manual&"
               "body=3D9.4.2%20capture%20protocol"))
-     (data (org-protocol-parse-parameters url)))
+     (data (org-protocol-parse-parameters url t)))
     (should (string=3D (plist-get data :template) "p"))
     (should (string=3D (plist-get data :url) "https://orgmode.org/org.ht=
ml#capture-protocol"))
     (should (string=3D (plist-get data :title) "The Org Manual"))
@@ -138,6 +138,8 @@
   "Test org-protocol://open-source links."
   (let* ((temp-file-name1 (make-temp-file "org-protocol-test1"))
      (temp-file-name2 (make-temp-file "org-protocol-test2"))
+     (temp-file-name3 (make-temp-file "org-protocol-test3" nil ".md"))
+     (temp-file-name4 (make-temp-file "org-protocol-test4" nil ".c"))
      (org-protocol-project-alist
       `((test1
          :base-url "http://example.com/"
@@ -149,10 +151,13 @@
          :working-directory ,(file-name-directory temp-file-name2))
         (test3
          :base-url "https://blog-example.com/"
-         :working-directory ,(file-name-directory temp-file-name2)
+         :working-directory ,(file-name-directory temp-file-name3)
          :online-suffix ".html"
          :working-suffix ".md"
-         :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\=
\)" . ".md")))))
+         :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\=
\)" . ".md")))
+        (test4
+         :base-url "http://as-is.example.com/"
+         :working-directory ,(file-name-directory temp-file-name4))))
      (test-cases
       (list
        ;; Old-style URLs
@@ -166,6 +171,16 @@
             (url-hexify-string
              (concat "http://another.example.com/" (file-name-nondirecto=
ry temp-file-name2) ".js")))
         temp-file-name2)
+       (cons
+        (concat "/some/directory/org-protocol:/open-source:/"
+               (url-hexify-string
+                (concat "https://blog-example.com/" (file-name-nondirect=
ory (file-name-sans-extension temp-file-name3)) ".html")))
+        temp-file-name3)
+       (cons
+        (concat "/some/directory/org-protocol:/open-source:/"
+               (url-hexify-string
+                (concat "http://as-is.example.com/" (file-name-nondirect=
ory temp-file-name4))))
+        temp-file-name4)
        ;; New-style URLs
        (cons
         (concat "/some/directory/org-protocol:/open-source?url=3D"
@@ -176,7 +191,17 @@
         (concat "/some/directory/org-protocol:/open-source?url=3D"
             (url-hexify-string
              (concat "http://another.example.com/" (file-name-nondirecto=
ry temp-file-name2) ".js")))
-        temp-file-name2))))
+        temp-file-name2)
+       (cons
+        (concat "/some/directory/org-protocol:/open-source?url=3D"
+               (url-hexify-string
+                (concat "https://blog-example.com/" (file-name-nondirect=
ory (file-name-sans-extension temp-file-name3)) ".html")))
+        temp-file-name3)
+       (cons
+        (concat "/some/directory/org-protocol:/open-source?url=3D"
+            (url-hexify-string
+             (concat "http://as-is.example.com/" (file-name-nondirectory=
 temp-file-name4))))
+        temp-file-name4))))
     (mapc (lambda (test-case)
         (should (string=3D
              (org-protocol-check-filename-for-protocol
@@ -185,7 +210,9 @@
              (cdr test-case))))
       test-cases)
     (delete-file temp-file-name1)
-    (delete-file temp-file-name2)))
+    (delete-file temp-file-name2)
+    (delete-file temp-file-name3)
+    (delete-file temp-file-name4)))

 (defun test-org-protocol/org-protocol-greedy-handler (fname)
   ;; fname should be a list of parsed items
-- =

2.21.1 (Apple Git-122.3)


--
Stacey

--=_MailMate_6128D387-6FEB-439C-8981-F52B2A8FFD36_=-- --=_MailMate_0DC55EE9-8870-451D-8596-EEA86DB6CA5E_= Content-Disposition: attachment; filename=0001-org-capture.el-Allow-for-no-file-extension-on-open-s.patch Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =46rom 213b7968199bebcf11d0bcf0bbc44d0843f19ecc Mon Sep 17 00:00:00 2001 From: Stacey Marshall Date: Sat, 9 May 2020 21:31:04 +0100 Subject: [PATCH 1/2] org-capture.el: Allow for no file extension on open-source protocol * lisp/org-capture.el (org-protocol-open-source): Remove requirement to have :online-suffix and :working-suffix. The problem here was that two assignments expected suffix's to be provided in org-protocol-project-alist. When they were missing an error occurred. With the changes source URLs that include the file name as-is, such as those presented by openGrok, may be opened. TINYCHANGE --- lisp/org-protocol.el | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index 55a534d0d..35f58f490 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -191,7 +191,7 @@ Example: :working-suffix \".org\" :base-url \"https://orgmode.org/worg/\" :working-directory \"/home/user/org/Worg/\") - (\"http://localhost/org-notes/\" + (\"localhost org-notes/\" :online-suffix \".html\" :working-suffix \".org\" :base-url \"http://localhost/org/\" @@ -202,12 +202,17 @@ Example: :working-directory \"~/site/content/post/\" :online-suffix \".html\" :working-suffix \".md\" - :rewrites ((\"\\(https://site.com/[0-9]+/[0-9]+/[0-9]+/\\)\" .= \".md\"))))) - - - The last line tells `org-protocol-open-source' to open - /home/user/org/index.php, if the URL cannot be mapped to an existing - file, and ends with either \"org\" or \"org/\". + :rewrites ((\"\\(https://site.com/[0-9]+/[0-9]+/[0-9]+/\\)\" .= \".md\"))) + (\"GNU emacs OpenGrok\" + :base-url \"https://opengrok.housegordon.com/source/xref/emacs= /\" + :working-directory \"~/dev/gnu-emacs/\"))) + + The :rewrites line of \"localhost org-notes\" entry tells + `org-protocol-open-source' to open /home/user/org/index.php, + if the URL cannot be mapped to an existing file, and ends with + either \"org\" or \"org/\". The \"GNU emacs OpenGrok\" entry + does not include any suffix properties, allowing local source + file to be opened as found by OpenGrok. = Consider using the interactive functions `org-protocol-create' and `org-protocol-create-for-org' to help you filling this variable with val= id contents." @@ -545,11 +550,12 @@ The location for a browser's bookmark should look l= ike this: ;; ending than strip-suffix here: (f1 (substring f 0 (string-match "\\([\\?#].*\\)?$" f))) (start-pos (+ (string-match wsearch f1) (length base-= url))) - (end-pos (string-match - (regexp-quote strip-suffix) f1)) + (end-pos (if strip-suffix + (string-match (regexp-quote strip-suffix) f1) + (length f1))) ;; We have to compare redirects without suffix below: (f2 (concat wdir (substring f1 start-pos end-pos))) - (the-file (concat f2 add-suffix))) + (the-file (if add-suffix (concat f2 add-suffix) f2)))= = ;; Note: the-file may still contain `%C3' et al here because brow= sers ;; tend to encode `ä' in URLs to `%25C3' - `%25' being `%'. -- = 2.21.1 (Apple Git-122.3) --=_MailMate_0DC55EE9-8870-451D-8596-EEA86DB6CA5E_= Content-Disposition: attachment; filename=0002-test-org-protocol.el-Fix-tests-and-add-new-test-for-.patch Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =46rom 9263002dc97753e297f8571511839eea0b39252e Mon Sep 17 00:00:00 2001 From: Stacey Marshall Date: Mon, 11 May 2020 00:58:40 +0100 Subject: [PATCH 2/2] test-org-protocol.el: Fix tests and add new test for= as-is filename. * testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-parse= -parameters): Fix issue of missing flag to indicate new paramenter testing. * testing/lisp/test-org-protocol.el (test-org-protocol/org-protocol-open-= source): Fix test3 which was not working. Add test4, for opening file name as-is without suffix modification. Tested using ert. TINYCHANGE --- testing/lisp/test-org-protocol.el | 37 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-pr= otocol.el index 6ee368dcf..42ad5e1a3 100644 --- a/testing/lisp/test-org-protocol.el +++ b/testing/lisp/test-org-protocol.el @@ -40,7 +40,7 @@ "url=3Dhttps%3A%2F%2Forgmode.org%2Forg.html%23capture-protocol&"= "title=3DThe%20Org%20Manual&" "body=3D9.4.2%20capture%20protocol")) - (data (org-protocol-parse-parameters url))) + (data (org-protocol-parse-parameters url t))) (should (string=3D (plist-get data :template) "p")) (should (string=3D (plist-get data :url) "https://orgmode.org/org.ht= ml#capture-protocol")) (should (string=3D (plist-get data :title) "The Org Manual")) @@ -138,6 +138,8 @@ "Test org-protocol://open-source links." (let* ((temp-file-name1 (make-temp-file "org-protocol-test1")) (temp-file-name2 (make-temp-file "org-protocol-test2")) + (temp-file-name3 (make-temp-file "org-protocol-test3" nil ".md")) + (temp-file-name4 (make-temp-file "org-protocol-test4" nil ".c")) (org-protocol-project-alist `((test1 :base-url "http://example.com/" @@ -149,10 +151,13 @@ :working-directory ,(file-name-directory temp-file-name2)) (test3 :base-url "https://blog-example.com/" - :working-directory ,(file-name-directory temp-file-name2) + :working-directory ,(file-name-directory temp-file-name3) :online-suffix ".html" :working-suffix ".md" - :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\\)"= . ".md"))))) + :rewrites (("\\(https://blog-example.com/[0-9]+/[0-9]+/[0-9]+/\\)"= . ".md"))) + (test4 + :base-url "http://as-is.example.com/" + :working-directory ,(file-name-directory temp-file-name4)))) (test-cases (list ;; Old-style URLs @@ -166,6 +171,16 @@ (url-hexify-string (concat "http://another.example.com/" (file-name-nondirectory tem= p-file-name2) ".js"))) temp-file-name2) + (cons + (concat "/some/directory/org-protocol:/open-source:/" + (url-hexify-string + (concat "https://blog-example.com/" (file-name-nondirectory (f= ile-name-sans-extension temp-file-name3)) ".html"))) + temp-file-name3) + (cons + (concat "/some/directory/org-protocol:/open-source:/" + (url-hexify-string + (concat "http://as-is.example.com/" (file-name-nondirectory te= mp-file-name4)))) + temp-file-name4) ;; New-style URLs (cons (concat "/some/directory/org-protocol:/open-source?url=3D" @@ -176,7 +191,17 @@ (concat "/some/directory/org-protocol:/open-source?url=3D" (url-hexify-string (concat "http://another.example.com/" (file-name-nondirectory tem= p-file-name2) ".js"))) - temp-file-name2)))) + temp-file-name2) + (cons + (concat "/some/directory/org-protocol:/open-source?url=3D" + (url-hexify-string + (concat "https://blog-example.com/" (file-name-nondirectory (f= ile-name-sans-extension temp-file-name3)) ".html"))) + temp-file-name3) + (cons + (concat "/some/directory/org-protocol:/open-source?url=3D" + (url-hexify-string + (concat "http://as-is.example.com/" (file-name-nondirectory temp-= file-name4)))) + temp-file-name4)))) (mapc (lambda (test-case) (should (string=3D (org-protocol-check-filename-for-protocol @@ -185,7 +210,9 @@ (cdr test-case)))) test-cases) (delete-file temp-file-name1) - (delete-file temp-file-name2))) + (delete-file temp-file-name2) + (delete-file temp-file-name3) + (delete-file temp-file-name4))) = (defun test-org-protocol/org-protocol-greedy-handler (fname) ;; fname should be a list of parsed items -- = 2.21.1 (Apple Git-122.3) --=_MailMate_0DC55EE9-8870-451D-8596-EEA86DB6CA5E_=--