From 02b8873060200af6bfa2a2e4fff3930435b9a686 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 8 Jan 2016 11:49:46 +0000 Subject: [PATCH 1/2] fix for highly confusing tramp error If you put something like [[/!foo website="http://bar.baz"]] in a markdown file, the conversion to filename will start failing with tramp-related errors. This is particularly bad because fontification happens on window configuration change, so killing the buffer and/or switching away from it also fail. Fix: for the normal case, escape without testing the filesystem. Wrap a condition-case around for when the user has specified search-parent-directories. --- markdown-mode.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 8485df2b..d6386afb 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -5489,14 +5489,16 @@ and [[test test]] both map to Test-test.ext." (file-name-extension (buffer-file-name)))))) (current default)) (catch 'done - (cl-loop - (if (or (file-exists-p current) - (not markdown-wiki-link-search-parent-directories)) - (throw 'done current)) - (if (string-equal (expand-file-name current) - (concat "/" default)) - (throw 'done default)) - (setq current (concat "../" current))))))) + (condition-case nil + (cl-loop + (if (or (not markdown-wiki-link-search-parent-directories) + (file-exists-p current)) + (throw 'done current)) + (if (string-equal (expand-file-name current) + (concat "/" default)) + (throw 'done default)) + (setq current (concat "../" current))) + (error default)))))) (defun markdown-follow-wiki-link (name &optional other) "Follow the wiki link NAME. From bdc065b6a383da1073762e9086f44c4266164a43 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 8 Jan 2016 11:57:02 +0000 Subject: [PATCH 2/2] another file-exists-p It's all very well fixing the filename finding, but we also need to prevent the fontification engine itself asking about invalid tramp files. --- markdown-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown-mode.el b/markdown-mode.el index d6386afb..d9c4fae8 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -5545,7 +5545,7 @@ and highlight accordingly." (file-name (markdown-convert-wiki-link-to-filename (markdown-wiki-link-link)))) - (if (file-exists-p file-name) + (if (condition-case nil (file-exists-p file-name) (error nil)) (markdown-highlight-wiki-link highlight-beginning highlight-end markdown-link-face) (markdown-highlight-wiki-link