all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* patch for org-capture.el  to allow for no file extension on open-source, protocol
@ 2020-05-09 20:55 Stacey Marshall
  2020-05-10 12:57 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Stacey Marshall @ 2020-05-09 20:55 UTC (permalink / raw)
  To: emacs-orgmode

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

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.


```
 From 213b7968199bebcf11d0bcf0bbc44d0843f19ecc Mon Sep 17 00:00:00 2001
 From: Stacey Marshall <stacey.marshall@gmail.com>
Date: Sat, 9 May 2020 21:31:04 +0100
Subject: [PATCH] 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 
valid contents."
@@ -545,11 +550,12 @@ The location for a browser's bookmark should look 
like 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 
browsers
  	      ;; tend to encode `&auml;' in URLs to `%25C3' - `%25' being 
`%'.
-- 
2.21.1 (Apple Git-122.3)

```


--
[Stacey](https://staceymarshall.wordpress.com/)

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

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

end of thread, other threads:[~2020-08-01 13:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-09 20:55 patch for org-capture.el to allow for no file extension on open-source, protocol Stacey Marshall
2020-05-10 12:57 ` Nicolas Goaziou
2020-05-11  0:05   ` Stacey Marshall
2020-05-12 14:46     ` Nicolas Goaziou
2020-05-12 15:05       ` Nicolas Goaziou
2020-05-12 17:02         ` Stacey Marshall
2020-05-13  8:02           ` Nicolas Goaziou
2020-08-01 13:18             ` Stacey Marshall

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.