From 624866ea43b3aefaa71f58f33a90205df47906f9 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 4 Nov 2006 06:03:41 +0000 Subject: [PATCH] Fix bug with recognizing wiki project names too loosely * lisp/muse-wiki.el (muse-wiki-handle-explicit-interwiki): Fix a bug with recognizing project names too loosely. git-archimport-id: mwolson@gnu.org--2006/muse--main--1.0--patch-241 --- ChangeLog | 3 ++- lisp/muse-wiki.el | 33 +++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 459f3bd..aed9f93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,8 @@ smarter about where an explicit link ends in a buffer. This allows you to refer to page names with invalid Wiki characters, such as underscores and dashes, merely by enclosing them in double - brackets. + brackets. Also, a bug with recognizing project names too loosely + has been fixed. 2006-11-03 Michael Olson diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index a617b56..c6c98b2 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -284,25 +284,30 @@ return the first match. Match 1 is set to the link. Match 2 is set to the description." - (let ((right-pos (unless string (match-end 1)))) + (let ((right-pos (if string (length string) (match-end 1)))) (when (if string (string-match muse-wiki-interwiki-regexp string) (looking-at muse-wiki-interwiki-regexp)) (let* ((project (match-string 1 string)) (subst (cdr (assoc project muse-wiki-interwiki-alist))) - (word (if right-pos - (and (match-end 2) - (buffer-substring (match-end 2) right-pos)) + (word (when (match-end 2) (if string - (and (match-beginning 3) - (substring string (match-beginning 3))) - (match-string 3 string))))) - (if subst - (if (functionp subst) - (funcall subst word) - (concat subst word)) - (and (assoc project muse-project-alist) - (or word (not muse-wiki-ignore-bare-project-names)) - (muse-wiki-resolve-project-page project word))))))) + (substring string (match-end 2)) + (if right-pos + (buffer-substring (match-end 2) + right-pos)))))) + (if (and (null word) + right-pos + (not (= right-pos (match-end 1)))) + ;; if only a project name was found, it must take up the + ;; entire string or link + nil + (if subst + (if (functionp subst) + (funcall subst word) + (concat subst word)) + (and (assoc project muse-project-alist) + (or word (not muse-wiki-ignore-bare-project-names)) + (muse-wiki-resolve-project-page project word)))))))) (defun muse-wiki-handle-wikiword (&optional string) "If STRING or point has a WikiWord, return it. -- 2.11.4.GIT