From 9e2c8fe7992356c1bccd935977e1ec7363369b67 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 9 Jul 2005 08:53:33 +0000 Subject: [PATCH] Handle a few edge cases with project-page resolution gracefully. * lisp/muse-project.el (muse-project-applicable-styles): Add assertion to make sure that PAGE is specified. STYLES should be generated automatically, but it could theoretically fail. I'm managing to trigger this when messing with unsaved Muse files. Handle case where buffer has not yet been saved. (muse-project-find-file): Don't try to resolve relative links; just open them. * lisp/muse-wiki.el (muse-wiki-resolve-project-page): Fix point-of-reference bug. No need to call muse-project-page-of-file since buffer-file-name and muse-publishing-current-file both give us full paths. * lisp/muse-mode.el (muse-link-at-point): For some reason, `skip-chars-backward' only respects the newline some of the time. Damned annoying. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-118 --- ChangeLog | 29 +++++++++++++++++++++++++++++ lisp/muse-mode.el | 2 +- lisp/muse-project.el | 47 ++++++++++++++++++++++++++++------------------- lisp/muse-wiki.el | 5 ++--- 4 files changed, 60 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa632ee..ad9af8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,35 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-07-09 08:53:33 GMT Michael Olson patch-118 + + Summary: + Handle a few edge cases with project-page resolution gracefully. + Revision: + muse--main--1.0--patch-118 + + * lisp/muse-project.el (muse-project-applicable-styles): Add assertion to + make sure that PAGE is specified. STYLES should be generated + automatically, but it could theoretically fail. I'm managing to + trigger this when messing with unsaved Muse files. Handle case where + buffer has not yet been saved. + (muse-project-find-file): Don't try to resolve relative links; just + open them. + + * lisp/muse-wiki.el (muse-wiki-resolve-project-page): Fix + point-of-reference bug. No need to call muse-project-page-of-file + since buffer-file-name and muse-publishing-current-file both give us + full paths. + + * lisp/muse-mode.el (muse-link-at-point): For some reason, + `skip-chars-backward' only respects the newline some of the time. + Damned annoying. + + modified files: + ChangeLog lisp/muse-mode.el lisp/muse-project.el + lisp/muse-wiki.el + + 2005-07-09 07:41:44 GMT Michael Olson patch-117 Summary: diff --git a/lisp/muse-mode.el b/lisp/muse-mode.el index eaf032a..0e23f08 100644 --- a/lisp/muse-mode.el +++ b/lisp/muse-mode.el @@ -256,7 +256,7 @@ This is used to keep links from being improperly colorized by flyspell." (muse-handle-explicit-link)) (goto-char here) ;; Check for bare URL or other link type - (skip-chars-backward (concat "^'\"<>{}(" + (skip-chars-backward (concat "^'\"<>{}(\n" muse-regexp-space)) (and (looking-at muse-implicit-link-regexp) (muse-handle-implicit-link))))))) diff --git a/lisp/muse-project.el b/lisp/muse-project.el index 74c6187..35d3026 100644 --- a/lisp/muse-project.el +++ b/lisp/muse-project.el @@ -251,24 +251,30 @@ first directory within the project's fileset is used." (unless (interactive-p) (setq project (muse-project project) name (cons name (muse-project-page-file name project)))) - ;; At this point, name is (PAGE . FILE). - (unless (cdr name) - (let ((pats (cadr project))) - (while (and pats (null directory)) - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (if (file-directory-p (car pats)) - (setq directory (car pats) pats nil) - (setq pats (cdr pats)))))) - (when directory - (let ((filename (expand-file-name - (if muse-file-extension - (concat (car name) "." muse-file-extension) - (car name)) - directory))) - (unless (file-exists-p directory) - (make-directory directory t)) - (setcdr name filename)))) + ;; If we're given a relative name, open it as-is + (if (and (car name) + (save-match-data (string-match "\\.\\./" (car name)))) + (setcdr name (if muse-file-extension + (concat (car name) "." muse-file-extension) + (car name))) + ;; At this point, name is (PAGE . FILE). + (unless (cdr name) + (let ((pats (cadr project))) + (while (and pats (null directory)) + (if (symbolp (car pats)) + (setq pats (cddr pats)) + (if (file-directory-p (car pats)) + (setq directory (car pats) pats nil) + (setq pats (cdr pats)))))) + (when directory + (let ((filename (expand-file-name + (if muse-file-extension + (concat (car name) "." muse-file-extension) + (car name)) + directory))) + (unless (file-exists-p directory) + (make-directory directory t)) + (setcdr name filename))))) ;; Open the file (if (cdr name) (funcall (or command 'find-file) (cdr name)) @@ -280,6 +286,8 @@ first directory within the project's fileset is used." The name of a project may be used for STYLES." (when (stringp styles) (setq styles (cddr (muse-project styles)))) + (muse-assert (and file styles) t + "Incorrect arguments passed to `muse-project-applicable-styles") (let (used-styles) (dolist (style styles) (let ((include-regexp (muse-style-element :include style)) @@ -290,7 +298,8 @@ The name of a project may be used for STYLES." (if include-regexp (string-match include-regexp file) (not (string-match exclude-regexp file)))) - (not (muse-project-private-p file))) + (or (not (file-exists-p file)) + (not (muse-project-private-p file)))) (add-to-list 'used-styles style)))) used-styles)) diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index 1e40e3a..084e5c1 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -156,9 +156,8 @@ style and ignore the others." (muse-project-page-file page project) project))) (local-style (car (muse-project-applicable-styles - (muse-project-page-file page - (muse-project-of-file)) - (cddr (muse-project-of-file)))))) + (or muse-publishing-current-file buffer-file-name) + (cddr (muse-project-of-file)))))) (file-relative-name (expand-file-name page (muse-style-element :path remote-style)) (expand-file-name -- 2.11.4.GIT