auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Bug with fold mode (tries to fold recursively)


From: Dominic Jänichen
Subject: Re: [AUCTeX] Bug with fold mode (tries to fold recursively)
Date: Sun, 17 Apr 2011 23:25:40 +0200

I found some time to have a look at it myself. Below is a fix.

--- tex-fold.el.org     2011-01-23 20:52:21.052579600 +0200
+++ tex-fold.el 2011-04-17 23:13:03.518289400 +0200
@@ -761,34 +761,41 @@
 (defun TeX-fold-expand-spec (spec ov-start ov-end)
   "Expand instances of {<num>}, [<num>], <<num>>, and (<num>).
 Replace them with the respective macro argument."
   (let ((spec-list (split-string spec "||"))
        (delims '((?{ . ?}) (?[ . ?]) (?< . ?>) (?\( . ?\))))
-       match-end success)
+       success)
     (catch 'success
       ;; Iterate over alternatives.
       (dolist (elt spec-list)
+       ;; everything left of start-search's character is already processed
+       ;; we start - nothing processed yet
+       (setq start-search nil)
        (setq spec elt)
        ;; Find and expand every placeholder.
        (while (and (string-match "\\([[{<]\\)\\([1-9]\\)\\([]}>]\\)" elt
-                                 match-end)
+                                 start-search)
                    ;; Does the closing delim fit to the opening one?
                    (string-equal
                     (match-string 3 elt)
                     (char-to-string
                      (cdr (assq (string-to-char (match-string 1 elt))
                                 delims)))))
-         (setq match-end (match-beginning 0))
+         ;; count the found placeholders as processed
+         (setq start-search (match-end 0))
          (let ((arg (car (save-match-data
                            ;; Get the argument.
                            (TeX-fold-macro-nth-arg
                             (string-to-number (match-string 2 elt))
                             ov-start ov-end
                             (assoc (string-to-char (match-string 1 elt))
                                    delims))))))
            (when arg (setq success t))
            ;; Replace the placeholder in the string.
            (setq elt (replace-match (or arg TeX-fold-ellipsis) nil t elt)
-                 spec elt)))
+                 spec elt)
+           ;; and adjust the start of next search accordingly
+           (setq start-search (+ start-search (+ -3 (length (or arg
TeX-fold-ellipsis)))))
+           ))
        (when success (throw 'success nil))))
     spec))


> -----Original Message-----
> >From: Dominic Jänichen
> >Sent: Monday, April 11, 2011 4:27 PM
> >To: address@hidden
> >Subject: Bug with fold mode (tries to fold recursively)
> >
> >Hello,
> >
> >I just discovered emacs  24.0.50.1 with AUCTeX 11.86 locking up as I
> >tried
> to fold code.
> >It happens if I try to fold code to an expression containing a
> >reference to
> a parameter (“{1}”), if this parameter includes the same string as one
that is
> not going to be folded.
> 
> >Minimal example:
> 
> >Add “br” to fold as “({1})” in math mode
> 
> >Try to fold
> >$\br{x_{1}}$
> 
> >AUCTeX then holds emacs (in an infinite loop?)
> 
> >Backtrace is
> >Debugger entered--Lisp error: (quit)
> >  byte-code( -- omitted here, but attached -- )
> >  TeX-fold-expand-spec("({1})" 20 30)
> >  TeX-fold-hide-item(#<overlay from 20 to 30 in test.txt.tex>)
> >  TeX-fold-region-macro-or-env(1 91 math)
> >  TeX-fold-region(1 91)
> >  TeX-fold-buffer()
> >  call-interactively(TeX-fold-buffer nil nil)
> 
> 
> >If I change $\br{x_{1}}$ to $\br{x_{1 }}$, there is no error.
> 
> 
> 
> >Sincerely,
> >Dominic





reply via email to

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