mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-24 07:20:29 +00:00
Move custom links to new tooling
* contrib/lisp/ol-bookmark.el (org-bookmark-open): * contrib/lisp/ol-elisp-symbol.el (elisp-symbol-open): * contrib/lisp/ol-git-link.el (org-gitbare-open): (org-git-open): * contrib/lisp/ol-man.el (org-man-open): * contrib/lisp/ol-mew.el (org-mew-open): * contrib/lisp/ol-notmuch.el (org-notmuch-open): (org-notmuch-search-open): (org-notmuch-tree-open): * contrib/lisp/ol-vm.el (org-vm-open): (org-vm-imap-open): * contrib/lisp/ol-wl.el (org-wl-open): * contrib/lisp/org-mac-link.el (org-mac-together-item-open): (org-mac-addressbook-item-open): (org-mac-skim-open): (org-mac-acrobat-open): (org-mac-outlook-message-open): (org-mac-evernote-note-open): (org-devonthink-item-open): (org-mac-message-open): * contrib/lisp/org-mairix.el (org-mairix-open): * lisp/ol-bbdb.el (org-bbdb-export): (org-bbdb-open): * lisp/ol-bibtex.el (org-bibtex-open): * lisp/ol-docview.el (org-docview-open): * lisp/ol-eshell.el (org-eshell-open): * lisp/ol-eww.el ("eww"): * lisp/ol-gnus.el (org-gnus-open): * lisp/ol-info.el (org-info-open): * lisp/ol-irc.el (org-irc-visit): * lisp/ol-mhe.el (org-mhe-open): * lisp/ol-rmail.el ("rmail"): (org-rmail-open): * lisp/ol.el (org-link--open-doi): (org-link--open-elisp): (org-link--open-help): (org-link--open-shell): * lisp/org-id.el (org-id-open): * testing/lisp/test-ox.el (test-org-export/custom-protocol-maybe): Use new tooling. * doc/org-manual.org (Adding Hyperlink Types): Adapt example.
This commit is contained in:
parent
afd3b04ecc
commit
f4bed78a19
@ -52,7 +52,7 @@ Otherwise prompt the user for the right bookmark to use."
|
||||
:follow #'org-bookmark-open
|
||||
:store #'org-bookmark-store-link)
|
||||
|
||||
(defun org-bookmark-open (bookmark)
|
||||
(defun org-bookmark-open (bookmark _)
|
||||
"Visit the bookmark BOOKMARK."
|
||||
(bookmark-jump bookmark))
|
||||
|
||||
|
@ -82,12 +82,8 @@
|
||||
:follow #'org-elisp-symbol-open
|
||||
:store #'org-elisp-symbol-store-link)
|
||||
|
||||
(defun org-elisp-symbol-open (path)
|
||||
"Visit the emacs-lisp elisp-symbol at PATH."
|
||||
(let* ((search (when (string-match "::\\(.+\\)\\'" path)
|
||||
(match-string 1 path)))
|
||||
(path (substring path 0 (match-beginning 0))))
|
||||
(org-open-file path t nil search)))
|
||||
(defun org-elisp-symbol-open (symbol arg)
|
||||
(org-link-open-as-file symbol arg))
|
||||
|
||||
(defun org-elisp-symbol-store-link ()
|
||||
"Store a link to an emacs-lisp elisp-symbol."
|
||||
|
@ -73,7 +73,7 @@
|
||||
;; bare git link
|
||||
(org-link-set-parameters "gitbare" :follow #'org-gitbare-open)
|
||||
|
||||
(defun org-gitbare-open (str)
|
||||
(defun org-gitbare-open (str _)
|
||||
(let* ((strlist (org-git-split-string str))
|
||||
(gitdir (nth 0 strlist))
|
||||
(object (nth 1 strlist)))
|
||||
@ -96,7 +96,7 @@
|
||||
;; user friendly link
|
||||
(org-link-set-parameters "git" :follow #'org-git-open :store #'org-git-store-link)
|
||||
|
||||
(defun org-git-open (str)
|
||||
(defun org-git-open (str _)
|
||||
(let* ((strlist (org-git-split-string str))
|
||||
(filepath (nth 0 strlist))
|
||||
(commit (nth 1 strlist))
|
||||
|
@ -35,7 +35,7 @@
|
||||
:group 'org-link
|
||||
:type '(choice (const man) (const woman)))
|
||||
|
||||
(defun org-man-open (path)
|
||||
(defun org-man-open (path _)
|
||||
"Visit the manpage on PATH.
|
||||
PATH should be a topic that can be thrown at the man command."
|
||||
(funcall org-man-command path))
|
||||
|
@ -191,7 +191,7 @@ with \"t\" key."
|
||||
(let ((folder-or-path (mew-summary-folder-name)))
|
||||
(mew-folder-path-to-folder folder-or-path t))))))
|
||||
|
||||
(defun org-mew-open (path)
|
||||
(defun org-mew-open (path _)
|
||||
"Follow the Mew message link specified by PATH."
|
||||
(let (folder message-id)
|
||||
(cond ((string-match "\\`\\(+.*\\)+\\+\\([0-9]+\\)\\'" path) ; for Bastien's
|
||||
|
@ -86,7 +86,7 @@ Should accept a notmuch search string as the sole argument."
|
||||
(org-link-add-props :link link :description desc)
|
||||
link)))
|
||||
|
||||
(defun org-notmuch-open (path)
|
||||
(defun org-notmuch-open (path _)
|
||||
"Follow a notmuch message link specified by PATH."
|
||||
(funcall org-notmuch-open-function path))
|
||||
|
||||
@ -113,7 +113,7 @@ Can link to more than one message, if so all matching messages are shown."
|
||||
:description desc)
|
||||
link)))
|
||||
|
||||
(defun org-notmuch-search-open (path)
|
||||
(defun org-notmuch-search-open (path _)
|
||||
"Follow a notmuch message link specified by PATH."
|
||||
(message "%s" path)
|
||||
(org-notmuch-search-follow-link path))
|
||||
@ -139,7 +139,7 @@ Can link to more than one message, if so all matching messages are shown."
|
||||
:description desc)
|
||||
link)))
|
||||
|
||||
(defun org-notmuch-tree-open (path)
|
||||
(defun org-notmuch-tree-open (path _)
|
||||
"Follow a notmuch message link specified by PATH."
|
||||
(message "%s" path)
|
||||
(org-notmuch-tree-follow-link path))
|
||||
|
@ -95,7 +95,7 @@
|
||||
(org-add-link-props :link link :description desc)
|
||||
link))))
|
||||
|
||||
(defun org-vm-open (path)
|
||||
(defun org-vm-open (path _)
|
||||
"Follow a VM message link specified by PATH."
|
||||
(let (folder article)
|
||||
(if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
|
||||
@ -127,7 +127,7 @@
|
||||
(when article
|
||||
(org-vm-select-message (org-link-add-angle-brackets article)))))
|
||||
|
||||
(defun org-vm-imap-open (path)
|
||||
(defun org-vm-imap-open (path _)
|
||||
"Follow a VM link to an IMAP folder."
|
||||
(require 'vm-imap)
|
||||
(when (string-match "\\([^:]+\\):\\([^#]+\\)#?\\(.+\\)?" path)
|
||||
|
@ -255,7 +255,7 @@ ENTITY is a message entity."
|
||||
(concat "@" (or (cdr server) (car server))))
|
||||
(if article (concat "#" article) "")))))
|
||||
|
||||
(defun org-wl-open (path)
|
||||
(defun org-wl-open (path &rest _)
|
||||
"Follow the WL message link specified by PATH.
|
||||
When called with one prefix, open message in namazu search folder
|
||||
with `org-wl-namazu-default-index' as search index. When called
|
||||
|
@ -494,7 +494,7 @@ The links are of the form <link>::split::<name>."
|
||||
;; Handle links from together.app
|
||||
(org-link-set-parameters "x-together-item" :follow #'org-mac-together-item-open)
|
||||
|
||||
(defun org-mac-together-item-open (uid)
|
||||
(defun org-mac-together-item-open (uid _)
|
||||
"Open UID, which is a reference to an item in Together."
|
||||
(shell-command (concat "open -a Together \"x-together-item:" uid "\"")))
|
||||
|
||||
@ -553,7 +553,7 @@ The links are of the form <link>::split::<name>."
|
||||
;; Handle links from AddressBook.app
|
||||
(org-link-set-parameters "addressbook" :follow #'org-mac-addressbook-item-open)
|
||||
|
||||
(defun org-mac-addressbook-item-open (uid)
|
||||
(defun org-mac-addressbook-item-open (uid _)
|
||||
"Open UID, which is a reference to an item in the addressbook."
|
||||
(shell-command (concat "open \"addressbook:" uid "\"")))
|
||||
|
||||
@ -588,7 +588,7 @@ The links are of the form <link>::split::<name>."
|
||||
|
||||
(org-link-set-parameters "skim" :follow #'org-mac-skim-open)
|
||||
|
||||
(defun org-mac-skim-open (uri)
|
||||
(defun org-mac-skim-open (uri _)
|
||||
"Visit page of pdf in Skim"
|
||||
(let* ((page (when (string-match "::\\(.+\\)\\'" uri)
|
||||
(match-string 1 uri)))
|
||||
@ -647,7 +647,7 @@ The links are of the form <link>::split::<name>."
|
||||
|
||||
(org-link-set-parameters "acrobat" :follow #'org-mac-acrobat-open)
|
||||
|
||||
(defun org-mac-acrobat-open (uri)
|
||||
(defun org-mac-acrobat-open (uri _)
|
||||
"Visit page of pdf in Acrobat"
|
||||
(let* ((page (when (string-match "::\\(.+\\)\\'" uri)
|
||||
(match-string 1 uri)))
|
||||
@ -697,7 +697,7 @@ The links are of the form <link>::split::<name>."
|
||||
|
||||
(org-link-set-parameters "mac-outlook" :follow #'org-mac-outlook-message-open)
|
||||
|
||||
(defun org-mac-outlook-message-open (msgid)
|
||||
(defun org-mac-outlook-message-open (msgid _)
|
||||
"Open a message in Outlook"
|
||||
(do-applescript
|
||||
(concat
|
||||
@ -809,7 +809,7 @@ after heading."
|
||||
|
||||
(org-link-set-parameters "mac-evernote" :follow #'org-mac-evernote-note-open)
|
||||
|
||||
(defun org-mac-evernote-note-open (noteid)
|
||||
(defun org-mac-evernote-note-open (noteid _)
|
||||
"Open a note in Evernote"
|
||||
(do-applescript
|
||||
(concat
|
||||
@ -860,7 +860,7 @@ note(s) in Evernote.app and make a link out of it/them."
|
||||
|
||||
(org-link-set-parameters "x-devonthink-item" :follow #'org-devonthink-item-open)
|
||||
|
||||
(defun org-devonthink-item-open (uid)
|
||||
(defun org-devonthink-item-open (uid _)
|
||||
"Open UID, which is a reference to an item in DEVONthink Pro Office."
|
||||
(shell-command (concat "open \"x-devonthink-item:" uid "\"")))
|
||||
|
||||
@ -908,7 +908,7 @@ selected items in DEVONthink Pro Office and make link(s) out of it/them."
|
||||
|
||||
(org-link-set-parameters "message" :follow #'org-mac-message-open)
|
||||
|
||||
(defun org-mac-message-open (message-id)
|
||||
(defun org-mac-message-open (message-id _)
|
||||
"Visit the message with MESSAGE-ID.
|
||||
This will use the command `open' with the message URL."
|
||||
(start-process (concat "open message:" message-id) nil
|
||||
|
@ -139,7 +139,7 @@ the buffer just like 'message-send-and-exit' does."
|
||||
(cons (list link desc) org-stored-links)))
|
||||
(message-bury (current-buffer)))
|
||||
|
||||
(defun org-mairix-open (search)
|
||||
(defun org-mairix-open (search _)
|
||||
"Function to open mairix link.
|
||||
|
||||
We first need to split it into its individual parts, and then
|
||||
|
@ -19835,7 +19835,7 @@ The following =ol-man.el= file implements it
|
||||
(require 'ol)
|
||||
|
||||
(org-link-set-parameters "man"
|
||||
:follow org-man-command
|
||||
:follow #'org-man-open
|
||||
:export #'org-man-export
|
||||
:store #'org-man-store-link)
|
||||
|
||||
@ -19844,6 +19844,11 @@ The following =ol-man.el= file implements it
|
||||
:group 'org-link
|
||||
:type '(choice (const man) (const woman)))
|
||||
|
||||
(defun org-man-open (path _)
|
||||
"Visit the manpage on PATH.
|
||||
PATH should be a topic that can be thrown at the man command."
|
||||
(funcall org-man-command path))
|
||||
|
||||
(defun org-man-store-link ()
|
||||
"Store a link to a man page."
|
||||
(when (memq major-mode '(Man-mode woman-mode))
|
||||
@ -19863,7 +19868,7 @@ The following =ol-man.el= file implements it
|
||||
(match-string 1 (buffer-name))
|
||||
(error "Cannot create link to this man page")))
|
||||
|
||||
(defun org-man-export (link description format)
|
||||
(defun org-man-export (link description format _)
|
||||
"Export a man page link from Org files."
|
||||
(let ((path (format "http://man.he.net/?topic=%s§ion=all" link))
|
||||
(desc (or description link)))
|
||||
|
@ -236,7 +236,7 @@ date year)."
|
||||
:link link :description name)
|
||||
link)))
|
||||
|
||||
(defun org-bbdb-export (path desc format)
|
||||
(defun org-bbdb-export (path desc format _)
|
||||
"Create the export version of a BBDB link specified by PATH or DESC.
|
||||
If exporting to either HTML or LaTeX FORMAT the link will be
|
||||
italicized, in all other cases it is left unchanged."
|
||||
@ -249,7 +249,7 @@ italicized, in all other cases it is left unchanged."
|
||||
(format "<text:span text:style-name=\"Emphasis\">%s</text:span>" desc))
|
||||
(t desc)))
|
||||
|
||||
(defun org-bbdb-open (name)
|
||||
(defun org-bbdb-open (name _)
|
||||
"Follow a BBDB link to NAME."
|
||||
(require 'bbdb-com)
|
||||
(let ((inhibit-redisplay (not debug-on-error)))
|
||||
|
@ -134,7 +134,6 @@
|
||||
(declare-function org-insert-heading "org" (&optional arg invisible-ok top))
|
||||
(declare-function org-map-entries "org" (func &optional match scope &rest skip))
|
||||
(declare-function org-narrow-to-subtree "org" ())
|
||||
(declare-function org-open-file "org" (path &optional in-emacs line search))
|
||||
(declare-function org-set-property "org" (property value))
|
||||
(declare-function org-toggle-tag "org" (tag &optional onoff))
|
||||
|
||||
@ -483,12 +482,11 @@ With optional argument OPTIONAL, also prompt for optional fields."
|
||||
:follow #'org-bibtex-open
|
||||
:store #'org-bibtex-store-link)
|
||||
|
||||
(defun org-bibtex-open (path)
|
||||
"Visit the bibliography entry on PATH."
|
||||
(let* ((search (when (string-match "::\\(.+\\)\\'" path)
|
||||
(match-string 1 path)))
|
||||
(path (substring path 0 (match-beginning 0))))
|
||||
(org-open-file path t nil search)))
|
||||
(defun org-bibtex-open (path arg)
|
||||
"Visit the bibliography entry on PATH.
|
||||
ARG, when non-nil, is a universal prefix argument. See
|
||||
`org-open-file' for details."
|
||||
(org-link-open-as-file path arg))
|
||||
|
||||
(defun org-bibtex-store-link ()
|
||||
"Store a link to a BibTeX entry."
|
||||
|
@ -68,7 +68,7 @@
|
||||
((eq format 'ascii) (format "%s (%s)" desc path))
|
||||
(t path)))))
|
||||
|
||||
(defun org-docview-open (link)
|
||||
(defun org-docview-open (link _)
|
||||
(string-match "\\(.*?\\)\\(?:::\\([0-9]+\\)\\)?$" link)
|
||||
(let ((path (match-string 1 link))
|
||||
(page (and (match-beginning 2)
|
||||
|
@ -33,7 +33,7 @@
|
||||
:follow #'org-eshell-open
|
||||
:store #'org-eshell-store-link)
|
||||
|
||||
(defun org-eshell-open (link)
|
||||
(defun org-eshell-open (link _)
|
||||
"Switch to an eshell buffer and execute a command line.
|
||||
The link can be just a command line (executed in the default
|
||||
eshell buffer) or a command line prefixed by a buffer name
|
||||
|
@ -46,17 +46,22 @@
|
||||
;;; Code:
|
||||
(require 'ol)
|
||||
(require 'cl-lib)
|
||||
(require 'eww)
|
||||
|
||||
;; For Emacsen < 25.
|
||||
(defvar eww-current-title)
|
||||
(defvar eww-current-url)
|
||||
(defvar eww-data)
|
||||
(defvar eww-mode-map)
|
||||
|
||||
(declare-function eww-current-url "eww")
|
||||
|
||||
|
||||
;; Store Org link in Eww mode buffer
|
||||
(org-link-set-parameters "eww" :follow #'eww :store #'org-eww-store-link)
|
||||
(org-link-set-parameters "eww"
|
||||
:follow #'org-eww-open
|
||||
:store #'org-eww-store-link)
|
||||
|
||||
(defun org-eww-open (url _)
|
||||
"Open URL with Eww in the current buffer."
|
||||
(eww url))
|
||||
|
||||
(defun org-eww-store-link ()
|
||||
"Store a link to the url of an EWW buffer."
|
||||
(when (eq major-mode 'eww-mode)
|
||||
|
@ -210,7 +210,7 @@ If `org-store-link' was called with a prefix arg the meaning of
|
||||
(format "nntp+%s:%s" (or (cdr server) (car server)) group)
|
||||
article)))
|
||||
|
||||
(defun org-gnus-open (path)
|
||||
(defun org-gnus-open (path _)
|
||||
"Follow the Gnus message or folder link specified by PATH."
|
||||
(unless (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)
|
||||
(error "Error in Gnus link %S" path))
|
||||
|
@ -59,7 +59,7 @@
|
||||
:link link :desc desc)
|
||||
link)))
|
||||
|
||||
(defun org-info-open (path)
|
||||
(defun org-info-open (path _)
|
||||
"Follow an Info file and node link specified by PATH."
|
||||
(org-info-follow-link path))
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
:store #'org-irc-store-link
|
||||
:export #'org-irc-export)
|
||||
|
||||
(defun org-irc-visit (link)
|
||||
(defun org-irc-visit (link _)
|
||||
"Parse LINK and dispatch to the correct function based on the client found."
|
||||
(let ((link (org-irc-parse-link link)))
|
||||
(cond
|
||||
|
@ -96,7 +96,7 @@ supported by MH-E."
|
||||
(org-link-add-props :link link :description desc)
|
||||
link))))
|
||||
|
||||
(defun org-mhe-open (path)
|
||||
(defun org-mhe-open (path _)
|
||||
"Follow an MH-E message link specified by PATH."
|
||||
(let (folder article)
|
||||
(if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
|
||||
|
@ -43,7 +43,9 @@
|
||||
(defvar rmail-file-name) ; From rmail.el
|
||||
|
||||
;; Install the link type
|
||||
(org-link-set-parameters "rmail" :follow #'org-rmail-open :store #'org-rmail-store-link)
|
||||
(org-link-set-parameters "rmail"
|
||||
:follow #'org-rmail-open
|
||||
:store #'org-rmail-store-link)
|
||||
|
||||
;; Implementation
|
||||
(defun org-rmail-store-link ()
|
||||
@ -75,7 +77,7 @@
|
||||
(rmail-show-message rmail-current-message)
|
||||
link)))))
|
||||
|
||||
(defun org-rmail-open (path)
|
||||
(defun org-rmail-open (path _)
|
||||
"Follow an Rmail message link to the specified PATH."
|
||||
(let (folder article)
|
||||
(if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
|
||||
|
10
lisp/ol.el
10
lisp/ol.el
@ -1279,15 +1279,15 @@ If there is no description, use the link target."
|
||||
;;; Built-in link types
|
||||
|
||||
;;;; "doi" link type
|
||||
(defun org-link--open-doi (path)
|
||||
(defun org-link--open-doi (path arg)
|
||||
"Open a \"doi\" type link.
|
||||
PATH is a the path to search for, as a string."
|
||||
(browse-url (url-encode-url (concat org-link-doi-server-url path))))
|
||||
(browse-url (url-encode-url (concat org-link-doi-server-url path)) arg))
|
||||
|
||||
(org-link-set-parameters "doi" :follow #'org-link--open-doi)
|
||||
|
||||
;;;; "elisp" link type
|
||||
(defun org-link--open-elisp (path)
|
||||
(defun org-link--open-elisp (path _)
|
||||
"Open a \"elisp\" type link.
|
||||
PATH is the sexp to evaluate, as a string."
|
||||
(if (or (and (org-string-nw-p org-link-elisp-skip-confirm-regexp)
|
||||
@ -1308,7 +1308,7 @@ PATH is the sexp to evaluate, as a string."
|
||||
(org-link-set-parameters "file" :complete #'org-link-complete-file)
|
||||
|
||||
;;;; "help" link type
|
||||
(defun org-link--open-help (path)
|
||||
(defun org-link--open-help (path _)
|
||||
"Open a \"help\" type link.
|
||||
PATH is a symbol name, as a string."
|
||||
(pcase (intern path)
|
||||
@ -1326,7 +1326,7 @@ PATH is a symbol name, as a string."
|
||||
(browse-url (concat scheme ":" url) arg))))
|
||||
|
||||
;;;; "shell" link type
|
||||
(defun org-link--open-shell (path)
|
||||
(defun org-link--open-shell (path _)
|
||||
"Open a \"shell\" type link.
|
||||
PATH is the command to execute, as a string."
|
||||
(if (or (and (org-string-nw-p org-link-shell-skip-confirm-regexp)
|
||||
|
@ -75,7 +75,6 @@
|
||||
|
||||
(declare-function message-make-fqdn "message" ())
|
||||
(declare-function org-goto-location "org-goto" (&optional _buf help))
|
||||
(declare-function org-link-set-parameters "ol" (type &rest rest))
|
||||
|
||||
;;; Customization
|
||||
|
||||
@ -674,7 +673,7 @@ optional argument MARKERP, return the position as a new marker."
|
||||
(org-link-store-props :link link :description desc :type "id")
|
||||
link)))
|
||||
|
||||
(defun org-id-open (id)
|
||||
(defun org-id-open (id _)
|
||||
"Go to the entry with id ID."
|
||||
(org-mark-ring-push)
|
||||
(let ((m (org-id-find id 'marker))
|
||||
|
@ -2997,7 +2997,7 @@ Para2"
|
||||
(string-match
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters "foo" :export (lambda (p d f) "success"))
|
||||
(org-link-set-parameters "foo" :export (lambda (p d f i) "success"))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
@ -3013,7 +3013,7 @@ Para2"
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters
|
||||
"foo" :export (lambda (p d f) (and (eq f 'test) "success")))
|
||||
"foo" :export (lambda (p d f i) (and (eq f 'test) "success")))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
@ -3030,7 +3030,7 @@ Para2"
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters
|
||||
"foo" :export (lambda (p d f) (and (eq f 'test) "success")))
|
||||
"foo" :export (lambda (p d f i) (and (eq f 'test) "success")))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
|
Loading…
Reference in New Issue
Block a user