emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 60/352: Lisätään ikuisen silmukan tarkistus funktioon wcheck-pai


From: Stefan Monnier
Subject: [elpa] 60/352: Lisätään ikuisen silmukan tarkistus funktioon wcheck-paint-words
Date: Mon, 07 Jul 2014 14:02:02 +0000

monnier pushed a commit to branch master
in repository elpa.

commit c23e2ad0609d9ce3ea9fe3ebbafc39f8e51cf0db
Author: Teemu Likonen <address@hidden>
Date:   Fri May 22 11:21:14 2009 +0000

    Lisätään ikuisen silmukan tarkistus funktioon wcheck-paint-words
---
 wcheck-mode.el |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/wcheck-mode.el b/wcheck-mode.el
index 91aa83e..128fcae 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -733,25 +733,34 @@ syntax table settings defined in LANGUAGE (see
               (r-end (wcheck-query-language-data language 'regexp-end t))
               (syntax (eval (wcheck-query-language-data language 'syntax t)))
               (case-fold-search nil)
-              regexp)
+              regexp old-point)
 
           (with-syntax-table syntax
             (dolist (word wordlist)
               (setq regexp (concat r-start "\\("
                                    (regexp-quote word) "\\)"
-                                   r-end))
+                                   r-end)
+                    old-point 0)
               (goto-char w-start)
 
-              (while (re-search-forward regexp w-end t)
-                ;; If the point is invisible jump forward to the next
-                ;; change of "invisible" text property, else make the
-                ;; overlay.
-                (if (get-char-property (match-beginning 1) 'invisible buffer)
-                    (goto-char (next-single-char-property-change
-                                (match-beginning 1) 'invisible buffer w-end))
-                  (wcheck-make-overlay language buffer
-                                       (match-beginning 1)
-                                       (match-end 1)))))))))))
+              (catch 'infinite
+                (while (re-search-forward regexp w-end t)
+                  (cond ((= (point) old-point)
+                         ;; We didn't move forward so break the loop.
+                         (throw 'infinite t))
+                        ((get-char-property (match-beginning 1)
+                                            'invisible buffer)
+                         ;; The point is invisible so jump forward to
+                         ;; the next change of "invisible" text property
+                         (goto-char (next-single-char-property-change
+                                     (match-beginning 1) 'invisible buffer
+                                     w-end)))
+                        (t
+                         ;; Make an overlay
+                         (wcheck-make-overlay language buffer
+                                              (match-beginning 1)
+                                              (match-end 1))))
+                  (setq old-point (point)))))))))))
 
 
 (defun wcheck-query-language-data (language key &optional default)



reply via email to

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