[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode 1cf1c1b270 6/6: Merge pull request #808 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode 1cf1c1b270 6/6: Merge pull request #808 from alphapapa/wip/extensible-follow-links |
Date: |
Fri, 27 Oct 2023 01:01:13 -0400 (EDT) |
branch: elpa/markdown-mode
commit 1cf1c1b270b4683cb35a082f168790f69c35bddc
Merge: 2a0556c5b7 c89377ad58
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #808 from alphapapa/wip/extensible-follow-links
Add extensible link-opening system
---
CHANGES.md | 7 +++++++
markdown-mode.el | 19 +++++++++++++------
tests/markdown-test.el | 20 +++++++++-----------
3 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 0604a9a398..648bb6298b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,12 +2,19 @@
*Under development*
+* New Features:
+ - Variable `markdown-follow-link-functions` extends
+ `markdown-follow-link-at-point` similarly to Org's
+ `org-open-at-point-functions`, allowing other libraries to
+ handle links specially. [GH-780][]
+
* Bug fixes:
- Don't highlight superscript/subscript in math inline/block [GH-802][]
* Improvements:
- Apply url-unescape against URL in an inline link [GH-805][]
+ [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780
[gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
[gh-805]: https://github.com/jrblevin/markdown-mode/issues/805
diff --git a/markdown-mode.el b/markdown-mode.el
index 3abecce927..82901b1443 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -73,6 +73,13 @@
(defvar markdown-gfm-language-history nil
"History list of languages used in the current buffer in GFM code blocks.")
+(defvar markdown-follow-link-functions nil
+ "Functions used to follow a link.
+Each function is called with one argument, the link's URL. It
+should return non-nil if it followed the link, or nil if not.
+Functions are called in order until one of them returns non-nil;
+otherwise the default link-following function is used.")
+
;;; Customizable Variables ====================================================
@@ -7923,11 +7930,11 @@ If the link is a complete URL, open in browser with
`browse-url'.
Otherwise, open with `find-file' after stripping anchor and/or query string.
Translate filenames using `markdown-filename-translate-function'."
(interactive (list last-command-event))
- (save-excursion
- (if event (posn-set-point (event-start event)))
- (if (markdown-link-p)
- (markdown--browse-url (markdown-link-url))
- (user-error "Point is not at a Markdown link or URL"))))
+ (if event (posn-set-point (event-start event)))
+ (if (markdown-link-p)
+ (or (run-hook-with-args-until-success 'markdown-follow-link-functions
(markdown-link-url))
+ (markdown--browse-url (markdown-link-url)))
+ (user-error "Point is not at a Markdown link or URL")))
(defun markdown-fontify-inline-links (last)
"Add text properties to next inline link from point to LAST."
@@ -8337,7 +8344,7 @@ See `markdown-follow-link-at-point' and
`markdown-follow-wiki-link-at-point'."
(interactive "P")
(cond ((markdown-link-p)
- (markdown--browse-url (markdown-link-url)))
+ (markdown-follow-link-at-point))
((markdown-wiki-link-p)
(markdown-follow-wiki-link-at-point arg))
(t
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 22b7c9ea9e..0abcbc9423 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -51,17 +51,15 @@
"Run BODY in a temporary buffer containing STRING in MODE."
(declare (indent 2))
`(let ((win (selected-window)))
- (unwind-protect
- (with-temp-buffer
- (set-window-buffer win (current-buffer) t)
- (erase-buffer)
- (insert ,string)
- (funcall ,mode)
- (setq-default indent-tabs-mode nil)
- (goto-char (point-min))
- (font-lock-ensure)
- (prog1 ,@body (kill-buffer)))
- (ignore))))
+ (with-temp-buffer
+ (set-window-buffer win (current-buffer) t)
+ (erase-buffer)
+ (insert ,string)
+ (funcall ,mode)
+ (setq-default indent-tabs-mode nil)
+ (goto-char (point-min))
+ (font-lock-ensure)
+ ,@body)))
(defmacro markdown-test-file-mode (mode file &rest body)
"Open FILE from `markdown-test-dir' in MODE and execute BODY."
- [nongnu] elpa/markdown-mode updated (2a0556c5b7 -> 1cf1c1b270), ELPA Syncer, 2023/10/27
- [nongnu] elpa/markdown-mode 6c39b72f6f 2/6: Add: (markdown-follow-link-functions), ELPA Syncer, 2023/10/27
- [nongnu] elpa/markdown-mode 1cf1c1b270 6/6: Merge pull request #808 from alphapapa/wip/extensible-follow-links,
ELPA Syncer <=
- [nongnu] elpa/markdown-mode c89377ad58 5/6: Fix: (markdown-follow-link-at-point) Don't save-excursion, ELPA Syncer, 2023/10/27
- [nongnu] elpa/markdown-mode 37a7b9a26b 1/6: Change/Fix: (-follow-thing-at-point) Use markdown-follow-link-at-point, ELPA Syncer, 2023/10/27
- [nongnu] elpa/markdown-mode 8077373665 4/6: Tidy: (markdown-test-string-mode), ELPA Syncer, 2023/10/27
- [nongnu] elpa/markdown-mode f290586c61 3/6: Docs: Update CHANGES.md, ELPA Syncer, 2023/10/27