[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Why does this font lock fun make Emacs loop?
From: |
Lennart Borgman |
Subject: |
Why does this font lock fun make Emacs loop? |
Date: |
Thu, 10 Jun 2010 18:52:33 +0200 |
This makes Emacs loops but I do not know why. The unreadable regexp is
fetched from font-lock.el.
(defconst reb-string-font-lock-defaults
(eval-when-compile
'(((reb-fontify-string-re
(1 'reb-regexp-grouping-backslash prepend)
(3 'reb-regexp-grouping-construct prepend))
(reb-mark-non-matching-parenthesis)
(reb-font-lock-background-marker)
(reb-font-lock-error-marker)
)
nil)))
;; reb-re-syntax is 'string when calling this
(defun reb-restart-font-lock ()
"Restart `font-lock-mode' to fit current regexp format."
(font-lock-mode 1) ;; fix-me
(unless (eq (current-buffer) reb-buffer) (error "Not in %S" reb-buffer))
(let ((font-lock-is-on font-lock-mode))
(font-lock-mode -1)
(kill-local-variable 'font-lock-set-defaults)
(setq font-lock-defaults
(cond
((memq reb-re-syntax '(read string))
;; Fix-me: should this be called keywords? Anyway split it up for
;; read and string.
reb-string-font-lock-defaults)
((eq reb-re-syntax 'rx)
'(reb-rx-font-lock-keywords
nil))
(t nil)))
(when font-lock-is-on (font-lock-mode 1))))
(defun reb-fontify-string-re (bound)
(when nil ;; Enabling this hangs emacs (rather badly, but can be
;; stopped if with-local-quit is used).
(with-local-quit
(catch 'found
;; The following loop is needed to continue searching after matches
;; that do not occur in strings. The associated regexp matches one
;; of `\\\\' `\\(' `\\(?:' `\\|' `\\)'. `\\\\' has been included to
;; avoid highlighting, for example, `\\(' in `\\\\('.
(when (memq reb-re-syntax '(read string))
(let ((n 0))
(while (and (> 200 (setq n (1+ n)))
(re-search-forward
(if (eq reb-re-syntax 'read)
;; Copied from font-lock.el
"\\(\\\\\\\\\\)\\(?:\\(\\\\\\\\\\)\\|\\((\\(?:\\?[0-9]*:\\)?\\|[|)]\\)\\)"
"\\(\\\\\\)\\(?:\\(\\\\\\)\\|\\((\\(?:\\?[0-9]*:\\)?\\|[|)]\\)\\)")
bound t))
(unless (match-beginning 2)
(let ((face (get-text-property (1- (point)) 'face)))
(when (or (and (listp face)
(memq 'font-lock-string-face face))
(eq 'font-lock-string-face face)
t)
(throw 'found t))))))))))
;; Tell we are ready
t)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Why does this font lock fun make Emacs loop?,
Lennart Borgman <=