From 162f4854db9e4bb624606cada12151e2f3ca626e Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 19 Nov 2005 01:21:10 +0000 Subject: [PATCH] Allow bad WikiWords to be colorized, by popular request. * lisp/muse-colors.el (muse-link-face): Allow implicit links to be colored as bad links if they don't correspond with a real file. Make the code more straightforward. * lisp/muse-wiki.el (muse-wiki-ignore-bare-project-names): New option that determines whether to colorize nonexistent WikiWords. The default is nil, which means "don't colorize". (muse-wiki-resolve-project-page, muse-wiki-handle-wikiword): Adapt for the possibility of bad WikiWords. git-archimport-id: mwolson@gnu.org--2005/muse--rel--3.02--patch-13 --- lisp/muse-colors.el | 31 +++++++++++++++++-------------- lisp/muse-wiki.el | 34 +++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/lisp/muse-colors.el b/lisp/muse-colors.el index f4e2cea..b6208ac 100644 --- a/lisp/muse-colors.el +++ b/lisp/muse-colors.el @@ -583,20 +583,23 @@ ignored." (muse-handle-explicit-link link-name) (muse-handle-implicit-link link-name)))) (when link - (if (or (not explicit) - (string-match muse-file-regexp link) - (string-match muse-url-regexp link)) - 'muse-link-face - (if (not (featurep 'muse-project)) - 'muse-link-face - (if (string-match "#" link) - (setq link (substring link 0 (match-beginning 0)))) - (if (or (and (muse-project-of-file) - (muse-project-page-file link muse-current-project t)) - (file-exists-p link)) - 'muse-link-face - (when explicit - 'muse-bad-link-face)))))))) + (cond ((string-match muse-url-regexp link) + 'muse-link-face) + ((string-match muse-file-regexp link) + (if (file-exists-p link) + 'muse-link-face + 'muse-bad-link-face)) + ((not (featurep 'muse-project)) + 'muse-link-face) + (t + (if (string-match "#" link) + (setq link (substring link 0 (match-beginning 0)))) + (if (or (and (muse-project-of-file) + (muse-project-page-file + link muse-current-project t)) + (file-exists-p link)) + 'muse-link-face + 'muse-bad-link-face))))))) (defun muse-colors-explicit-link () "Color explicit links." diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index 10f74be..ec47c25 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -63,6 +63,11 @@ :type 'boolean :group 'muse-wiki) +(defcustom muse-wiki-allow-nonexistent-wikiword nil + "Whether to color bare WikiNames that don't have an existing file." + :type 'boolean + :group 'muse-wiki) + (defcustom muse-wiki-ignore-bare-project-names nil "Determine whether project names without a page specifer are links. If non-nil, project names without a page specifier will not be @@ -156,14 +161,24 @@ style and ignore the others." (local-style (car (muse-project-applicable-styles (muse-current-file) (cddr (muse-project-of-file)))))) - (if (and remote-style local-style muse-publishing-p) - (muse-publish-link-file - (file-relative-name (expand-file-name - page (muse-style-element :path remote-style)) - (expand-file-name - (muse-style-element :path local-style))) - nil remote-style) - (unless muse-publishing-p page-path)))) + (cond ((and remote-style local-style muse-publishing-p) + (muse-publish-link-file + (file-relative-name (expand-file-name + page (muse-style-element :path remote-style)) + (expand-file-name + (muse-style-element :path local-style))) + nil remote-style)) + ((not muse-publishing-p) + (if page-path + page-path + (when muse-wiki-allow-nonexistent-wikiword + ;; make a path to a nonexistent file in project + (setq page-path (expand-file-name + page (car (cadr (muse-project project))))) + (if (and muse-file-extension + (not (string= muse-file-extension ""))) + (concat page-path "." muse-file-extension) + page-path))))))) (defun muse-wiki-handle-interwiki (&optional string) "If STRING or point has an interwiki link, resolve it and @@ -190,7 +205,8 @@ Match 1 is set to the WikiWord." (if string (string-match muse-wiki-wikiword-regexp string) (looking-at muse-wiki-wikiword-regexp)) - (or (and (muse-project-of-file) + (or muse-wiki-allow-nonexistent-wikiword + (and (muse-project-of-file) (muse-project-page-file (match-string 1 string) muse-current-project t)) (file-exists-p (match-string 1 string)))) -- 2.11.4.GIT