From 8b07119d1724318b0c85794bdfd59c0763f715f6 Mon Sep 17 00:00:00 2001 From: "Michael W. Olson" Date: Sun, 5 Aug 2007 17:33:47 -0400 Subject: [PATCH] Fix bug involving visiting Muse files in nested directories * .gitignore: Add the DVC log edit file. * lisp/muse-project.el (muse-project-of-file): Simplify by using catch, throw, and dolist. Look for exact matches before considering any subdirectories. If no exact matches are found, then pick the longest match. * lisp/muse.el (muse-sort-by-rating): Mention default test in documentation. --- .gitignore | 1 + ChangeLog | 10 +++++++++- lisp/muse-project.el | 34 +++++++++++++++++++--------------- lisp/muse.el | 2 +- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 7824e96..b70794e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Files that we ignore when using git. *~ +/++xgit-log-edit *.elc /Makefile.defs /lisp/muse-autoloads.el diff --git a/ChangeLog b/ChangeLog index f989861..03bf0d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,20 @@ 2007-08-05 Michael Olson - * .gitignore: Add texi/muse.html. + * .gitignore: Add texi/muse.html and the DVC log edit file. * Makefile.defs.default (install_info): Rename from INSTALLINFO. Turn this into something that can be called like a command, due to needing to deal with XEmacs, which has different argument order. Thanks to Terrence Brannon for the report. + * lisp/muse-project.el (muse-project-of-file): Simplify by using + catch, throw, and dolist. Look for exact matches before + considering any subdirectories. If no exact matches are found, + then pick the longest match. + + * lisp/muse.el (muse-sort-by-rating): Mention default test in + documentation. + * scripts/muse-build.el: Avoid interference from VC.el in the build process. diff --git a/lisp/muse-project.el b/lisp/muse-project.el index c238d8b..ca1ddb6 100644 --- a/lisp/muse-project.el +++ b/lisp/muse-project.el @@ -508,21 +508,25 @@ If PATHNAME is nil, the current buffer's filename is used." pathname)))))) (let* ((file (file-truename pathname)) (dir (file-name-directory file)) - (project-entry muse-project-alist) - found) - (while (and project-entry (not found)) - (let ((pats (car (cdar project-entry)))) - (while (and pats (not found)) - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (let ((truename (file-truename (car pats)))) - (if (or (string= truename file) - (string= truename dir) - (string-match (regexp-quote truename) file)) - (setq found (car project-entry)))) - (setq pats (cdr pats)))) - (setq project-entry (cdr project-entry)))) - found))))) + found rating matches) + (catch 'found + (dolist (project-entry muse-project-alist) + (let ((pats (cadr project-entry))) + (while pats + (if (symbolp (car pats)) + (setq pats (cddr pats)) + (let ((tname (file-truename (car pats)))) + (cond ((or (string= tname file) + (string= tname dir)) + (throw 'found project-entry)) + ((string-match (concat "\\`" (regexp-quote tname)) + file) + (setq matches (cons (cons (match-end 0) + project-entry) + matches))))) + (setq pats (cdr pats)))))) + ;; if we haven't found an exact match, pick a candidate + (car (muse-sort-by-rating matches)))))))) (defun muse-project-after-save-hook () "Update Muse's file-alist if we are saving a Muse file." diff --git a/lisp/muse.el b/lisp/muse.el index 69153e5..bb0a54b 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -345,7 +345,7 @@ before the second." The rating is stripped out in the returned list. Default sorting is highest-first. -If TEST if specified, use it to sort the list." +If TEST if specified, use it to sort the list. The default test is '>." (unless test (setq test '>)) (mapcar (function cdr) (muse-sort-with-closure -- 2.11.4.GIT