unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why does this font lock fun make Emacs loop?
@ 2010-06-10 16:52 Lennart Borgman
  0 siblings, 0 replies; only message in thread
From: Lennart Borgman @ 2010-06-10 16:52 UTC (permalink / raw)
  To: Emacs-Devel devel

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)



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-10 16:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-10 16:52 Why does this font lock fun make Emacs loop? Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).