branch: elpa/markdown-mode commit c89377ad588c064e124079673a639b2838451068 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Fix: (markdown-follow-link-at-point) Don't save-excursion Using `save-excursion' here means that after `markdown-follow-link-functions' or `markdown--browse-url' may change the buffer, the buffer gets changed back to the Markdown buffer. Besides seeming to be undesirable behavior, it breaks the `test-markdown-link/follow' test. It was likely added because of the call to `posn-set-point', but it's unclear why that would make it necessary, because clicking with the mouse generally moves the point. If clicking with the mouse really should not move point, this could be worked around, but `save-excursion' seems generally incompatible with calling functions which may leave the buffer changed according to the user's action. --- markdown-mode.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index fadf6dc4c9..82901b1443 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -7930,12 +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) - (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")))) + (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."