Skip to content

Commit

Permalink
Backwards compatibility for missing url-parse
Browse files Browse the repository at this point in the history
url-parse was added in Emacs 24.3.
  • Loading branch information
jrblevin committed May 6, 2016
1 parent 8e708bc commit 27067e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@
(require 'outline)
(require 'thingatpt)
(require 'cl-lib)
(require 'url-parse)
(require 'url-parse nil t)

(defvar jit-lock-start)
(defvar jit-lock-end)
Expand Down Expand Up @@ -6198,8 +6198,8 @@ Otherwise, open with `find-file' after stripping anchor and/or query string."
(interactive)
(if (markdown-link-p)
(let* ((link (markdown-link-link))
(struct (url-generic-parse-url link)))
(if (url-fullness struct)
(struct (and (featurep 'url-parse) (url-generic-parse-url link))))
(if (or (null struct) (url-fullness struct))
;; Open full URLs in browser
(browse-url link)
;; Strip query string and open partial URLs in Emacs
Expand Down
9 changes: 5 additions & 4 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3359,10 +3359,11 @@ like statement. Detail: https://github.com/jrblevin/markdown-mode/issues/75"
(lambda (url &rest args) (setq opened-url url))))
(markdown-follow-thing-at-point nil)
(should (equal opened-url "http://path?query=foo#id"))))
(markdown-test-string "[text](path?query=foo#id)"
(markdown-follow-thing-at-point nil)
(should (equal (file-name-nondirectory (buffer-file-name)) "path"))
(kill-buffer)))
(when (featurep 'url-parse)
(markdown-test-string "[text](path?query=foo#id)"
(markdown-follow-thing-at-point nil)
(should (equal (file-name-nondirectory (buffer-file-name)) "path"))
(kill-buffer))))

;;; Wiki link tests:

Expand Down

0 comments on commit 27067e2

Please sign in to comment.