help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Error-Free Navigation in Trees of Sub-Expressions (sexp) in Font-Lo


From: Nordlöw
Subject: Re: Error-Free Navigation in Trees of Sub-Expressions (sexp) in Font-Locking Function Matchers
Date: Wed, 8 Oct 2008 05:31:18 -0700 (PDT)
User-agent: G2/1.0

Ooops...

My initial posting contained two errors.
Here is the correct test code that works in Vanilla Emacs:

(defun pnw-fancy/setq-args-matcher (limit)
  (let ((start (point)))    ; remember beginning
    (if (looking-at (concat "[[:blank:]\n]*" "'?\\(\\w+\\)"))
        (progn (goto-char (match-end 1))
               (forward-sexp); skip VAL
               t)); signal hit
    ))
(defun pnw-fancy/emacs-lisp-variables-font-locking ()
  (font-lock-add-keywords
   nil
   (list
    ;; setq-statements: (setq SYM VAL ...)
    `(;; MATCHER: (SETQ
      ,(concat "(" (regexp-opt '("set"
                                 "setq"
                                 "setq-default"
                                 "setq-mode-local") t)
               "[[:blank:]\n]*")
      ;; SUBEXP-HIGHLIGHTER
      (1 'font-lock-function-name-face keep)
      ;; ANCHORED-HIGHLIGHTER: (setq SYM VAL ...)
      (;; ANCHORED-MATCHER
       pnw-fancy/setq-args-matcher
       nil ; PRE-FORM
       nil ; POST-FORM
       (1 'font-lock-variable-name-face prepend) ; SUBEXP-HIGHLIGHTERS
       ))
    ) t))
(add-hook 'emacs-lisp-mode-hook 'pnw-fancy/emacs-lisp-variables-font-
locking)

/Nordlöw


reply via email to

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