emacs-pretest-bug
[Top][All Lists]
Advanced

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

RE: re-search-forward ... nil t) results in error instead of returning n


From: Drew Adams
Subject: RE: re-search-forward ... nil t) results in error instead of returning nil
Date: Sat, 20 Nov 2004 16:55:56 -0800

    BTW this regexp can't be right (i.e. it does not do what you want).


The regexp is correct (for Emacs 21); it does what I want. The following
regexp is correct for Emacs 20:
"\"\\([^\\\"]\\|\\\\\\(.\\|[\n]\\)\\)*\"\\|`[^']+'"

The regexp works fine, and it was tested by several others (including
yourself, I thought) back in early October (emacs-devel thread "info faces
for strings and quotations"). And it works even in the bug case, on node Key
Index. Usually, I get a stack overflow when I search with it at that Info
node, but occasionally (as Luc noticed also) there is no overflow and no
problem.

BTW - That is the regexp as it appears in Lisp code - not what you would
enter at C-M-s. Try the Lisp expression I sent originally in the bug report:

(re-search-forward "\"\\(?:[^\\\"]\\|\\\\\\(?:.\\|[\n]\\)\\)*\"\\|`[^']+'"
nil t)

FYI, here is the code (Emacs 21 version) that uses the regexp:

(defun info-fontify-quotations ()
    "Fontify text between double-quotes (\"...\") and single-quotes (`...')
For single-quotes, use face `info-quoted-name'.
For double-quotes, use face `info-string'."
    (while (re-search-forward           ; Match `...' or "..."
            "\"\\(?:[^\\\"]\\|\\\\\\(?:.\\|[\n]\\)\\)*\"\\|`[^']+'"
            nil t)
      (cond ((eq ?` (aref (match-string 0) 0)) ; `...'
             (put-text-property (1+ (match-beginning 0)) (1- (match-end 0))
                                'face 'info-quoted-name))
            ((and (goto-char (match-beginning 0)) ; "...": If preceded by \,
skip it
                  (= 1 (mod (save-excursion (skip-chars-backward "\\\\"))
2)))
             (forward-char 1))
            ((goto-char (match-end 0))  ; "..." not preceded by \
             (put-text-property (match-beginning 0) (match-end 0)
                                'face 'info-string)))))

 - Drew





reply via email to

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