From 3202d5080f3a6999add1aa88e1f36c868776c0d9 Mon Sep 17 00:00:00 2001 From: Adrian Daerr Date: Sun, 18 Apr 2021 18:45:41 +0200 Subject: [PATCH] Make markdown-mouse-follow-link work when nil This commit 1. corrects the variable type so it can be toggled in customize-mode 2. defines markdown-mode-mouse-map to an empty map instead of just breaking it 3. deactivates the mouse-face property attribution when no link following wanted. This provides the (presumably) intended behaviour when set to nil. --- markdown-mode.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index c93d0513..fab09251 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -617,7 +617,7 @@ requires Emacs to be built with ImageMagick support." "Non-nil means mouse on a link will follow the link. This variable must be set before loading markdown-mode." :group 'markdown - :type 'bool + :type 'boolean :safe 'booleanp :package-version '(markdown-mode . "2.5")) @@ -5396,11 +5396,11 @@ Assumes match data is available for `markdown-regex-italic'." "Keymap for Markdown major mode.") (defvar markdown-mode-mouse-map - (when markdown-mouse-follow-link - (let ((map (make-sparse-keymap))) + (let ((map (make-sparse-keymap))) + (when markdown-mouse-follow-link (define-key map [follow-link] 'mouse-face) - (define-key map [mouse-2] #'markdown-follow-thing-at-point) - map)) + (define-key map [mouse-2] #'markdown-follow-thing-at-point)) + map) "Keymap for following links with mouse.") (defvar gfm-mode-map @@ -7730,6 +7730,7 @@ Translate filenames using `markdown-filename-translate-function'." (defun markdown-fontify-inline-links (last) "Add text properties to next inline link from point to LAST." + (when markdown-mouse-follow-link (when (markdown-match-generic-links last nil) (let* ((link-start (match-beginning 3)) (link-end (match-end 3)) @@ -7773,7 +7774,7 @@ Translate filenames using `markdown-filename-translate-function'." (when title-start (add-text-properties url-end title-end tp)) (when (and markdown-hide-urls url-start) (compose-region url-start (or title-end url-end) url-char)) - t))) + t)))) (defun markdown-fontify-reference-links (last) "Add text properties to next reference link from point to LAST."