From fd78e459024bb84d56f4849086ffea9a3030c9d5 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 30 Oct 2006 00:56:57 +0000 Subject: [PATCH] Implement publish-time detection of whether a link needs link-suffix * lisp/muse-project.el (muse-publish-link-file): Check to see whether the given link points at a valid file. If so, return it. Otherwise, apply other transforms like prefix and link suffix. git-archimport-id: mwolson@gnu.org--2006/muse--main--1.0--patch-233 --- ChangeLog | 3 +++ lisp/muse-publish.el | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc81a83..3eb5efd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,9 @@ to serve as a description for a URL, as long as it differs from the destination URL. This fixes the description of WikPage links in PDF output. + (muse-publish-link-file): Check to see whether the given link + points at a valid file. If so, return it. Otherwise, apply other + transforms like prefix and link suffix. * lisp/muse-regexps.el (muse-file-regexp): If something ends in "/", it is a file or directory, not a Muse page. Thanks to diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index e459b9c..5e0d11f 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -624,12 +624,17 @@ TITLE is used when indicating the publishing progress; it may be nil." (or (muse-style-element :link-suffix style) (muse-style-element :suffix style)))) -(defsubst muse-publish-link-file (file &optional output-dir style) +(defun muse-publish-link-file (file &optional output-dir style) (setq style (muse-style style)) (if output-dir - (expand-file-name (muse-publish-link-name file style) output-dir) - (concat (file-name-directory file) - (muse-publish-link-name file style)))) + (let ((link-name (expand-file-name file output-dir))) + (if (file-exists-p link-name) + link-name + (expand-file-name (muse-publish-link-name file style) output-dir))) + (if (file-exists-p file) + file + (concat (file-name-directory file) + (muse-publish-link-name file style))))) (defsubst muse-publish-link-page (page) (if (fboundp 'muse-project-link-page) -- 2.11.4.GIT