From: Lennart Borgman <lennart.borgman@gmail.com>
To: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Why does this font lock fun make Emacs loop?
Date: Thu, 10 Jun 2010 18:52:33 +0200 [thread overview]
Message-ID: <AANLkTimPUNrFwqH4Lbv5DCx7zwVs46qHZn8BBw0avu2k@mail.gmail.com> (raw)
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)
reply other threads:[~2010-06-10 16:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTimPUNrFwqH4Lbv5DCx7zwVs46qHZn8BBw0avu2k@mail.gmail.com \
--to=lennart.borgman@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.