emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] Report on emacs-wiki interwiki breakage


From: Michael Olson
Subject: [emacs-wiki-discuss] Report on emacs-wiki interwiki breakage
Date: Thu, 19 Aug 2004 10:25:58 -0500
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux)

The problems:

- At least 2 error messages appear in the *Messages* buffer when an emacs-wiki
  page with interwiki links is loaded.  The text of the error is
  `Error during redisplay: (wrong-type-argument stringp nil)'.

- Interwiki links don't highlight correctly.

Steps for replicating one bug that I found:

- Close all emacs-wiki and planner buffers.

- Make a simple page in one of your wiki directories with just one
  interwiki link, like [[ProjectsWiki#WelcomePage]] for example.

- When in the `emacs-wiki-wiki-link-target' function in emacs-wiki.el,
  do a C-u M-C-x to initialize the function with edebug.

- Switch to the temporary page we just made and start flyspell mode.

- Position the cursor over the link.  Hit <ENTER>.  The debugger
  should activate.

- Step through the first few lines and notice than the (setq name
  (match-string 1 name)) statement returns nil.  The (string-match ...
  name) line a few lines down chokes on this with a `wrong argument
  type' error since nil is not a string.

Further diagnosis:

- If you call the function manually with values like
  "[[ProjectsWiki#WelcomePage]]" (which should be a valid interwiki
  page), emacs-wiki-wiki-link-target correctly spits out
  "ProjectsWiki#WelcomePage".

- My guess is that the problem lies with the match-string function.
  string-match indicates that there is a match after hitting <ENTER>
  on the link, but string-match can't seem to find it.  Using
  string-match-no-properties did not seem to help.  Setting name to
  (substring-no-properties wiki-name) within the let statement seemed
  to do the trick, though.

I searched through `emacs-wiki.el' for every instance of match-string,
looking for those that used three arguments.  I then checked to see if
they could ever receive `raw' data from the buffer.  If so, I forced
the arguments in question to go through `substring-no-properties'
before being used by `match-string'.

I find it troubling that match-string-no-properties seemed to have no
appreciable effect on this problem.  It could be a temporary CVS Emacs
breakage, I suppose.  Does anyone know?

The included patch cuts the number of errors in half and allows one to
use `emacs-wiki-highlight-buffer' to temporarily be able to use
interwiki links.  Unfortunately, there is still one more of those
`Error during redisplay: (wrong-type-argument stringp nil)' lines in
the *Message* buffer that I can't seem to track down.

* looking for address@hidden/emacs-wiki--dev--1.0--patch-63 to compare with
* comparing to address@hidden/emacs-wiki--dev--1.0--patch-63
M  emacs-wiki.el

* modified files

--- orig/emacs-wiki.el
+++ mod/emacs-wiki.el
@@ -851,7 +851,7 @@
   "Return the visible part of a Wiki link.
 This only really means something if [[extended][links]] are involved."
   (save-match-data
-    (let ((name wiki-name))
+    (let ((name (substring-no-properties wiki-name)))
       (if (string-match emacs-wiki-extended-link-regexp name)
           (if (match-string 2 name)
               (setq name (match-string 3 name))
@@ -947,7 +947,7 @@
 (defun emacs-wiki-wiki-link-target (wiki-name)
   "Return the target of a Wiki link.  This might include anchor tags."
   (save-match-data
-    (let ((name wiki-name) lookup)
+    (let ((name (substring-no-properties wiki-name)) lookup)
       (if (string-match "^\\[\\[\\([^]]+\\)\\]" name)
           (setq name (match-string 1 name)))
       (unless (emacs-wiki-page-file name)
@@ -1090,7 +1090,8 @@
   "Visit the URL or link named by LINK-NAME.
 REFRESH-BUFFER is an optional buffer to refresh on saving the visited page.
 This makes the bad link face in the linking buffer go away."
-  (let ((link (emacs-wiki-wiki-link-target link-name))
+  (let ((link (emacs-wiki-wiki-link-target
+               (substring-no-properties link-name)))
         newbuf)
     (if (emacs-wiki-wiki-url-p link)
         (emacs-wiki-browse-url link other-window)
@@ -2111,7 +2112,8 @@
 
 (defun emacs-wiki-inline-image (beg end url &optional desc)
   "Inline locally available images."
-  (let ((filename
+  (let* ((url (substring-no-properties url))
+         (filename
          (cond
           ((string-match "\\`file:\\(.+\\)" url)
            (match-string 1 url))
@@ -3170,13 +3172,13 @@
             (start (match-beginning 0))
             (beg (point)) end attrs)
         (when (nth 2 tag-info)
-          (let ((attrstr (match-string 2)))
+          (let ((attrstr (match-string-no-properties 2)))
             (while (and attrstr
                         (string-match
                          "\\([^ \t\n=]+\\)\\(=\"\\([^\"]+\\)\"\\)?" attrstr))
               (let ((attr (cons (downcase
-                                 (match-string-no-properties 1 attrstr))
-                                (match-string-no-properties 3 attrstr))))
+                                 (match-string 1 attrstr))
+                                (match-string 3 attrstr))))
                 (setq attrstr (replace-match "" t t attrstr))
                 (if attrs
                     (nconc attrs (list attr))
@@ -3613,7 +3615,7 @@
     (when (and (not (eq (char-after (point)) ?\"))
                (not (eq (char-after (point)) ?\>)))
       (let* (string
-             (wiki-link (match-string 0))
+             (wiki-link (match-string-no-properties 0))
              (url (emacs-wiki-link-url wiki-link))
              (text (emacs-wiki-wiki-visible-name wiki-link))
              (name text))
@@ -4059,10 +4061,10 @@
   "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)))
+              (match-string 3 (substring-no-properties dest))))
         (src-host
          (and (string-match emacs-wiki-url-server-regexp src)
-              (match-string 3 src))))
+              (match-string 3 (substring-no-properties src)))))
     (and dest-host src-host (string= dest-host src-host)
          (file-relative-name dest src))))
 
@@ -4098,7 +4100,7 @@
   "Return the correct Google search string."
   (when (string-match "^google:/?/?\\(.+\\)" url)
     (concat "http://www.google.com/search?q=";
-            (match-string 1 url))))
+            (match-string 1 (substring-no-properties url)))))
 
 (defun emacs-wiki-browse-url-google (url)
   "If this is a Google URL, jump to it."
@@ -4109,25 +4111,27 @@
 (defun emacs-wiki-browse-url-info (url)
   "If this in an Info URL, jump to it."
   (require 'info)
-  (cond
-   ((string-match "^info://\\([^#]+\\)#\\(.+\\)" url)
-    (Info-find-node (match-string 1 url)
-                    (match-string 2 url)))
-   ((string-match "^info://\\([^#]+\\)" url)
-    (Info-find-node (match-string 1 url)
-                    "Top"))
-   ((string-match "^info://(\\([^)]+\\))\\(.+\\)" url)
-    (Info-find-node (match-string 1 url) (match-string 2 url)))
-   ((string-match "^info://\\(.+\\)" url)
-    (Info-find-node (match-string 1 url) "Top"))))
+  (let ((url (substring-no-properties url)))
+    (cond
+     ((string-match "^info://\\([^#]+\\)#\\(.+\\)" url)
+      (Info-find-node (match-string 1 url)
+                      (match-string 2 url)))
+     ((string-match "^info://\\([^#]+\\)" url)
+      (Info-find-node (match-string 1 url)
+                      "Top"))
+     ((string-match "^info://(\\([^)]+\\))\\(.+\\)" url)
+      (Info-find-node (match-string 1 url) (match-string 2 url)))
+     ((string-match "^info://\\(.+\\)" url)
+      (Info-find-node (match-string 1 url) "Top")))))
 
 (defun emacs-wiki-browse-url-man (url)
   "If this in a manpage URL, jump to it."
-  (cond ((string-match "^man://\\(.+\\):\\(.+\\)" url)
-         (manual-entry (concat (match-string 1 url)
-                               "(" (match-string 2 url) ")")))
-        ((string-match "^man://\\(.+\\)" url)
-         (manual-entry (concat (match-string 1 url))))))
+  (let ((url (substring-no-properties url)))
+    (cond ((string-match "^man://\\(.+\\):\\(.+\\)" url)
+           (manual-entry (concat (match-string 1 url)
+                                 "(" (match-string 2 url) ")")))
+          ((string-match "^man://\\(.+\\)" url)
+           (manual-entry (concat (match-string 1 url)))))))
 
 
 (provide 'emacs-wiki)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]