all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font-lock-keywords: matcher function not working
@ 2013-06-27 12:39 Raffaele Ricciardi
  2013-06-27 12:40 ` Raffaele Ricciardi
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Raffaele Ricciardi @ 2013-06-27 12:39 UTC (permalink / raw)
  To: help-gnu-emacs

Hello everybody,

I'm trying to highlight the first parenthesis of each line in Lisp code.

After having read the documentation of `font-lock-keywords', I've
written a matcher function which behaves as required (I've tested it
with `eval-expression').  However, first parentheses are not
highlighted.


Here is my code, tested on GNU Emacs 24.3

;; Tested in the *scratch* buffer after "emacs -Q".

(require 'cl)

(defun* rr-first-non-blank? (&optional (point (point)))
   "Return non-NIL if POINT is on the first non-blank character of the
current line."
   (= point
      (save-excursion
        (back-to-indentation)
        (point))))

(defun rr-match-indented-paren (^end)
   "Matcher for `font-lock-keywords' that matches a parenthesis made
  redundant by indentation."
   (if (and (eql (char-after) ?\()
            (rr-first-non-blank?))
       (re-search-forward "(" ^end)
       nil))

(font-lock-add-keywords 'lisp-interaction-mode
                         '(
                           (rr-match-indented-paren . 
'font-lock-warning-face)
                           ))

(font-lock-fontify-buffer)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-06-29 13:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-27 12:39 font-lock-keywords: matcher function not working Raffaele Ricciardi
2013-06-27 12:40 ` Raffaele Ricciardi
2013-06-27 17:32 ` Stefan Monnier
     [not found] ` <mailman.2602.1372354403.22516.help-gnu-emacs@gnu.org>
2013-06-28 10:43   ` rfflrccrd
2013-06-28 19:30     ` Stefan Monnier
     [not found]     ` <mailman.2731.1372447819.22516.help-gnu-emacs@gnu.org>
2013-06-28 20:50       ` Raffaele Ricciardi
2013-06-29  2:35         ` Stefan Monnier
     [not found]         ` <mailman.2762.1372473348.22516.help-gnu-emacs@gnu.org>
2013-06-29  8:53           ` Raffaele Ricciardi
2013-06-29 13:32             ` Raffaele Ricciardi

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.