From 0f1341565310bffb475ac660825781a17c4d393b Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 9 Jul 2005 00:10:01 +0000 Subject: [PATCH] Make natural interwiki links between projects mostly work. * lisp/muse-wiki.el (muse-wiki-resolve-project-page): Uncomment this function and flesh it out. This seems to work properly, though for some reason, interwiki links using projects are a bit flakey. (muse-wiki-handle-interwiki): Deal with case where we have a project name in an interwiki link. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-111 --- ChangeLog | 17 +++++++++++++++++ lisp/muse-wiki.el | 54 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index c82d691..bbc26fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,23 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-07-09 00:10:01 GMT Michael Olson patch-111 + + Summary: + Make natural interwiki links between projects mostly work. + Revision: + muse--main--1.0--patch-111 + + * lisp/muse-wiki.el (muse-wiki-resolve-project-page): Uncomment this + function and flesh it out. This seems to work properly, though for + some reason, interwiki links using projects are a bit flakey. + (muse-wiki-handle-interwiki): Deal with case where we have a project + name in an interwiki link. + + modified files: + ChangeLog lisp/muse-wiki.el + + 2005-07-08 22:57:55 GMT Michael Olson patch-110 Summary: diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index 4cef9ad..8fe37ef 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -136,23 +136,25 @@ Read-only properties are added to the string." (setq url nil))) (when url (muse-publish-read-only url))) -;; (defun muse-wiki-resolve-project-page (project page) -;; "Return the published path from the current page to PAGE of PROJECT. -;; If PAGE is not specified, use the value of :default in PROJECT. -;; If PROJECT is not specified, default to first project of -;; `muse-projects-alist'. - -;; Note that PAGE can have several output directories. If this is -;; the case, we will use the first one that matches our current -;; style and ignore the others." -;; (setq project (or project (caar muse-project-alist)) -;; page (or page (muse-get-keyword :default -;; (cadr (muse-project project))))) -;; (let* ((styles (muse-project-applicable-styles project)) -;; (dirs (search-styles-for-:base-that-matches-ours))) -;; (file-relative-name (file-plus-extensions (car dirs) current-file) -;; (our-current-publishing-dir) -;; ))) +(defun muse-wiki-resolve-project-page (&optional project page) + "Return the published path from the current page to PAGE of PROJECT. +If PAGE is not specified, use the value of :default in PROJECT. +If PROJECT is not specified, default to first project of +`muse-projects-alist'. + +Note that PAGE can have several output directories. If this is +the case, we will use the first one that matches our current +style and ignore the others." + (setq project (or project (caar muse-project-alist)) + page (or page (muse-get-keyword :default + (cadr (muse-project project))))) + (let ((remote-style (car (muse-project-applicable-styles page project))) + (local-style (car (muse-project-applicable-styles + (muse-page-name) (muse-project-of-file))))) + (file-relative-name (expand-file-name + page (muse-style-element :path remote-style)) + (expand-file-name + (muse-style-element :path local-style))))) (defun muse-wiki-handle-interwiki (&optional string) "If STRING or point has an interwiki link, resolve it and @@ -161,15 +163,15 @@ Match 1 is set to the link. Match 2 is set to the description." (when (if string (string-match muse-wiki-interwiki-regexp string) (looking-at muse-wiki-interwiki-regexp)) - (let ((subst (or (cdr (assoc (match-string 1 string) - muse-wiki-interwiki-alist)) - (and (assoc (match-string 1 string) muse-project-alist) - 'muse-wiki-resolve-project-page))) - (word (match-string 2 string))) - (when subst - (if (functionp subst) - (funcall subst word) - (concat subst word)))))) + (let* ((project (match-string 1 string)) + (subst (cdr (assoc project muse-wiki-interwiki-alist))) + (word (match-string 2 string))) + (if subst + (if (functionp subst) + (funcall subst word) + (concat subst word)) + (and (assoc project muse-project-alist) + (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