[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: Report on emacs-wiki interwiki breakage
From: |
Michael Olson |
Subject: |
[emacs-wiki-discuss] Re: Report on emacs-wiki interwiki breakage |
Date: |
Thu, 26 Aug 2004 01:27:01 -0500 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) |
I believe I've finally fixed the problem!
There was a slight typo in `emacs-wiki-project-interwiki-link' in my
pre-3 patch:
(let ((page-publishing-directory
(file-name-directory
(concat emacs-wiki-project-server-prefix
(emacs-wiki-link-url (emacs-wiki-page-name)))))
((url (emacs-wiki-link-url (or tag emacs-wiki-home-page)))))
which should be:
(let ((page-publishing-directory
(file-name-directory
(concat emacs-wiki-project-server-prefix
(emacs-wiki-link-url (emacs-wiki-page-name tag)))))
(url (emacs-wiki-link-url (or tag emacs-wiki-home-page))))
Another change you'll see in the above chunk of code is that I passed
`tag' to `emacs-wiki-page-name' since there were times when
`emacs-wiki-page-name' would return null. As best I can tell, this
happened because these routines create two temp buffers: one in this
routine to switch the project (implied by the use of
`with-emacs-wiki-project', and once for each file to publish, so you
actually have two current temp buffers.
I suspect that the `buffer-file-name' function did not know what to do
when called from a temp buffer, so it returned nil. Later on, a
string-match call choked on that. Since we know definitively the name
of the buffer once we reach that point in
`emacs-wiki-project-interwiki-link', I thought it best to pass that
information (which is contained by the variable `tag') as an argument
to `emacs-wiki-page-name'.
Since I feel this patch to be ready for the -dev (and possibly -main)
branch(es), I have enclosed a "full patch" (i.e. with no `-b' or `-w'
args passed to diff) against patch-63, as well as a ChangeLog entry.
BTW: I merged in several of Gary Vaughan's patches. Thanks again to
Mark Triggs for the initial patch to fix this problem.
Mike Olson
2004-08-26 Michael Olson <address@hidden>
* emacs-wiki.el (emacs-wiki-extended-link-regexp): Merged from
Gary's branch; it allows the first part of an extended link to
have whitespace in it. I'm not completely sure this is the
correct behavior, since I couldn't find mention of it in any
changelogs.
(emacs-wiki-set-sym-and-url-regexp): replace multiple consecutive
spaces in regexp with space and tab, since this is probably what
was meant. Also define emacs-wiki-url-server-regexp here.
(emacs-wiki-url-server-regexp): New variable that matches server
URLs from `emacs-wiki-project-server-prefix'. We need this
variable because it is used in `emacs-wiki-relative-link-maybe'
and has been left unbound for some time.
(emacs-wiki-publish-current): Don't replace markup in image files.
From Gary's patch-16.
(emacs-wiki-publish-files): Set the project before calling
`emacs-wiki-publish-function'. From Gary's patch-18.
(emacs-wiki-relative-link-maybe): Only proceed with the
calculation for non-nil arguments. From Gary's patch-19.
(emacs-wiki-project-interwiki-link): Reordering of
`with-emacs-wiki-project' and combination of let statements. From
a patch sent by Mark Triggs, which was slightly modified to remove
an extra set of parentheses.
--- emacs-wiki-test/emacs-wiki.el 2004-08-26 01:13:32.000000000 -0500
+++ emacs-wiki-dev/emacs-wiki.el 2004-08-26 00:54:54.000000000 -0500
@@ -304,7 +304,7 @@
"Matches either a Wiki link or a URL. This variable is auto-generated.")
(defcustom emacs-wiki-extended-link-regexp
- "\\[\\[\\([^][\n]+\\)\\]\\(\\[\\([^][\n]+\\)\\]\\)?\\]"
+ "\\[\\[\\([^][ \t\n]+\\)\\]\\(\\[\\([^][\n]+\\)\\]\\)?\\]"
"Regexp used to match [[extended][links]]."
:type 'regexp
:group 'emacs-wiki)
@@ -326,7 +326,14 @@
(concat "\\<\\("
(mapconcat 'car emacs-wiki-url-protocols "\\|")
"\\):"
- "[^] \n \"'()<>[^`{}]*[^] \n \"'()<>[^`{}.,;]+")))
+ "[^] \n \"'()<>[^`{}]*[^] \n \"'()<>[^`{}.,;]+")
+ emacs-wiki-url-server-regexp
+ (concat "\\<\\("
+ (mapconcat 'car emacs-wiki-url-protocols "\\|")
+ "\\):"
+ "\\([^:@address@hidden:]+\\)?"
+ "\\([^] \n \"'()<>[^`{},;/]+\\)"
+ "\\(/.*\\|$\\)")))
(setq emacs-wiki-url-or-name-regexp
(concat "\\("
(if (eq sym 'emacs-wiki-name-regexp)
@@ -380,6 +387,11 @@
"A regexp used to match URLs within a Wiki buffer.
Dynamically calculated from `emacs-wiki-url-protocols'.")
+(defvar emacs-wiki-url-server-regexp
+ nil
+ "A regexp used to match server URLs from `emacs-wiki-project-server-prefix'.
+Dynamically calculated from `emacs-wiki-url-protocols'.")
+
(defcustom emacs-wiki-grep-command
"find %D -type f ! -name '*~' | xargs egrep -n -e \"\\<%W\\>\""
"The name of the program to use when grepping for backlinks.
@@ -3013,7 +3025,8 @@
(insert-file-contents file t)
(cd (file-name-directory file))
(emacs-wiki-maybe)
- (emacs-wiki-replace-markup)
+ (unless (string-match emacs-wiki-image-regexp (emacs-wiki-page-name))
+ (emacs-wiki-replace-markup))
(emacs-wiki-write-buffer output-path)))
(defun emacs-wiki-publish-files (files force)
@@ -3034,7 +3047,8 @@
(make-directory publishing-directory 'parents)))
(when (and (not (emacs-wiki-private-p page))
(or force (file-newer-than-file-p file published)))
- (funcall emacs-wiki-publish-function file published)
+ (with-emacs-wiki-project emacs-wiki-current-project
+ (funcall emacs-wiki-publish-function file published))
(run-hook-with-args 'emacs-wiki-after-file-publish-hook file)
(setq published-some t)))
published-some))
@@ -4057,40 +4071,41 @@
(defun emacs-wiki-relative-link-maybe (dest src)
"Return the relative link for DEST based on SRC."
- (let ((dest-host
- (and (string-match emacs-wiki-url-server-regexp dest)
- (match-string 3 dest)))
- (src-host
- (and (string-match emacs-wiki-url-server-regexp src)
- (match-string 3 src))))
- (and dest-host src-host (string= dest-host src-host)
- (file-relative-name dest src))))
+ (when (and dest src)
+ (let ((dest-host
+ (and (string-match emacs-wiki-url-server-regexp dest)
+ (match-string 3 dest)))
+ (src-host
+ (and (string-match emacs-wiki-url-server-regexp src)
+ (match-string 3 src))))
+ (and dest-host src-host (string= dest-host src-host)
+ (file-relative-name dest src)))))
(defun emacs-wiki-project-interwiki-link (project tag)
- (let ((page-publishing-directory
- (file-name-directory
- (concat emacs-wiki-project-server-prefix
- (emacs-wiki-link-url (emacs-wiki-page-name))))))
- (with-emacs-wiki-project project
- (if emacs-wiki-publishing-p
- (let ((url (emacs-wiki-link-url (or tag emacs-wiki-home-page))))
- (cond
- ;; bad link, no prefix will be added
- ((null url) "")
- ;; try and convert to a relative link
- ((and emacs-wiki-relative-links
- ;; without catching extended links by mistake
- (not (string-match "\\[\\[[^][]+\\(\\]\\[[^][]+\\)?\\]\\]"
- url))
- (emacs-wiki-relative-link-maybe
- (concat emacs-wiki-project-server-prefix url)
- page-publishing-directory)))
- ;; use the server prefix
- ((concat emacs-wiki-project-server-prefix url))))
- (or (emacs-wiki-page-file (or tag emacs-wiki-home-page))
- ;; doesn't yet exist, so we don't qualify the name, causing it
- ;; to be rendered as a bad link
- tag)))))
+ (with-emacs-wiki-project project
+ (if emacs-wiki-publishing-p
+ (let ((page-publishing-directory
+ (file-name-directory
+ (concat emacs-wiki-project-server-prefix
+ (emacs-wiki-link-url (emacs-wiki-page-name tag)))))
+ (url (emacs-wiki-link-url (or tag emacs-wiki-home-page))))
+ (cond
+ ;; bad link, no prefix will be added
+ ((null url) "")
+ ;; try and convert to a relative link
+ ((and emacs-wiki-relative-links
+ ;; without catching extended links by mistake
+ (not (string-match "\\[\\[[^][]+\\(\\]\\[[^][]+\\)?\\]\\]"
+ url))
+ (emacs-wiki-relative-link-maybe
+ (concat emacs-wiki-project-server-prefix url)
+ page-publishing-directory)))
+ ;; use the server prefix
+ ((concat emacs-wiki-project-server-prefix url))))
+ (or (emacs-wiki-page-file (or tag emacs-wiki-home-page))
+ ;; doesn't yet exist, so we don't qualify the name, causing it
+ ;; to be rendered as a bad link
+ tag))))
;; URLs