Skip to content

Conversation

@edrex
Copy link
Contributor

@edrex edrex commented Oct 20, 2021

motivation: spacemacs and others bind <RET> to
markdown-do in evil normal mode.

with this change links can also be followed with enter.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have updated the documentation in the README.md file if necessary.
  • I have added an entry to CHANGES.md.
  • I have added tests to cover my changes.
  • All new and existing tests passed (using make test).

@syohex
Copy link
Collaborator

syohex commented Oct 20, 2021

@edrex Your patch breaks tests and existed behaviors. How about following patch ?

diff --git a/markdown-mode.el b/markdown-mode.el
index 321a284..f999cfe 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -8221,9 +8221,6 @@ Jumps between reference links and definitions; between footnote
 markers and footnote text."
   (interactive)
   (cond
-   ;; Link
-   ((or (markdown-link-p) (markdown-wiki-link-p))
-    (markdown-follow-thing-at-point nil))
    ;; Footnote definition
    ((markdown-footnote-text-positions)
     (markdown-footnote-return))
@@ -8242,6 +8239,9 @@ markers and footnote text."
    ;; Align table
    ((markdown-table-at-point-p)
     (call-interactively #'markdown-table-align))
+   ;; Link
+   ((or (markdown-link-p) (markdown-wiki-link-p))
+    (markdown-follow-thing-at-point nil))
    ;; Otherwise
    (t
     (markdown-insert-gfm-checkbox))))

edrex added 2 commits October 20, 2021 10:19
motivation: spacemacs and others bind <RET> to
markdown-do in evil normal mode. with this change links
can also be followed with enter.
@edrex
Copy link
Contributor Author

edrex commented Oct 20, 2021

thanks for the quick feedback @syohex! I hadn't worked with the emacs testing tools yet, good time to start :)

I updated the change so the footnote jump test passes, putting the link branch between the footnote and table branches, since table cells can have inlines so links should take precedence there.

I added 3 failing tests that I don't yet know how to make asserts for, LMK if you have any ideas:

  • check that a new buffer Foo.md is opened
  • check that an external URL is launched in browser

Guessing some mock is needed at least for the URL

@edrex edrex force-pushed the markdown-do-follow-links branch from ea512df to fc729ea Compare October 20, 2021 18:32
@syohex syohex mentioned this pull request Oct 21, 2021
7 tasks
@syohex
Copy link
Collaborator

syohex commented Oct 21, 2021

I fix your tests at #667. How about this ?

@syohex syohex merged commit fc729ea into jrblevin:master Oct 22, 2021
@edrex edrex deleted the markdown-do-follow-links branch October 22, 2021 01:04
edrex added a commit to edrex/doom-emacs that referenced this pull request Oct 22, 2021
Improves markdown-do to follow markdown links and [[WikiLinks]]

jrblevin/markdown-mode#666
edrex added a commit to edrex/doom-emacs that referenced this pull request Oct 22, 2021
Improves markdown-do to follow markdown links and [[WikiLinks]]

jrblevin/markdown-mode#666
edrex added a commit to edrex/doom-emacs that referenced this pull request Oct 22, 2021
Improves markdown-do to follow markdown links and [[WikiLinks]]

jrblevin/markdown-mode#666
edrex added a commit to edrex/doom-emacs that referenced this pull request Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants