|
From: | Stacey Marshall |
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 |
On 10 May 2020, at 13:57, Nicolas Goaziou wrote:
Hello,
"Stacey Marshall" address@hidden 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 <address@hidden>
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=""
"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=""/some/directory/org-protocol:/open-source?url=""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=""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=""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
0001-org-capture.el-Allow-for-no-file-extension-on-open-s.patch
Description: Text document
0002-test-org-protocol.el-Fix-tests-and-add-new-test-for-.patch
Description: Text document
[Prev in Thread] | Current Thread | [Next in Thread] |