all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* set face for added font lock keywords
@ 2011-01-09 15:27 extronom
  2011-01-10  5:31 ` Suvayu Ali
  2011-01-10  6:43 ` Teemu Likonen
  0 siblings, 2 replies; 4+ messages in thread
From: extronom @ 2011-01-09 15:27 UTC (permalink / raw)
  To: help-gnu-emacs

I'm trying to add some new keywords by doing  font-lock-add-keywords
so that a FIXME keyword gets highlighted, which works quite well. When
I try to change the color of the used face it doesn't work and
probably somebody could give me a hint what the problem is here (I'm
still a newbie regarding elisp programming).

Here is a function which is suppose to create a new buffer and add the
appropriated keyword regexp to be highlighted then but the color can't
be changed here it seems why? Maybe I'm missing some basic stuff here?

(defun my-new-buffer-color ()
  (interactive)
  (setq myBuffer (generate-new-buffer "myTemp"))
  (switch-to-buffer myBuffer)

  (lisp-interaction-mode)

  (font-lock-mode 0);; does not seem to help here???

  ;; this is supposed to work but doesn't???
  (set-face-foreground 'font-lock-comment-face "green" )
  (set-variable font-lock-comment-face 'font-lock-comment-face)

  ;; highlight FIXME
  (font-lock-add-keywords nil
    '("\\<FIXME\\>" 1 font-lock-comment-face prepend))

  (insert "this is a FIXME test \n")
)

Thanks for any help / hint.

Br


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

* Re: set face for added font lock keywords
  2011-01-09 15:27 set face for added font lock keywords extronom
@ 2011-01-10  5:31 ` Suvayu Ali
  2011-01-10  5:34   ` Suvayu Ali
  2011-01-10  6:43 ` Teemu Likonen
  1 sibling, 1 reply; 4+ messages in thread
From: Suvayu Ali @ 2011-01-10  5:31 UTC (permalink / raw)
  To: extronom; +Cc: help-gnu-emacs

On Sun, 9 Jan 2011 07:27:30 -0800 (PST)
extronom <extronom@googlemail.com> wrote:

> I'm trying to add some new keywords by doing  font-lock-add-keywords
> so that a FIXME keyword gets highlighted, which works quite well. When
> I try to change the color of the used face it doesn't work and
> probably somebody could give me a hint what the problem is here

Why don't you use `M-x customize-face' to customise the face you want
to?

That apart, I have a similar setup but all I do is add this hook:

(add-hook 'find-file-hook
	  (lambda ()
	    (font-lock-add-keywords
	     nil '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)))
	    (if (vc-working-revision (buffer-file-name))
		(auto-revert-mode t))
	    ))

Hope this helps.

-- 
Suvayu

Open source is the future. It sets us free.



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

* Re: set face for added font lock keywords
  2011-01-10  5:31 ` Suvayu Ali
@ 2011-01-10  5:34   ` Suvayu Ali
  0 siblings, 0 replies; 4+ messages in thread
From: Suvayu Ali @ 2011-01-10  5:34 UTC (permalink / raw)
  To: extronom; +Cc: help-gnu-emacs

On Sun, 9 Jan 2011 21:31:22 -0800
Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> 
> That apart, I have a similar setup but all I do is add this hook:
> 
> (add-hook 'find-file-hook
> 	  (lambda ()
> 	    (font-lock-add-keywords
> 	     nil '(("\\<\\(FIXME\\):" 1 font-lock-warning-face
> prepend))) (if (vc-working-revision (buffer-file-name))
> 		(auto-revert-mode t))
> 	    ))
> 

Sorry, that should have been this:

(add-hook 'find-file-hook
	  (lambda ()
	    (font-lock-add-keywords
	     nil '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)))
	    ))

> Hope this helps.
> 

-- 
Suvayu

Open source is the future. It sets us free.



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

* Re: set face for added font lock keywords
  2011-01-09 15:27 set face for added font lock keywords extronom
  2011-01-10  5:31 ` Suvayu Ali
@ 2011-01-10  6:43 ` Teemu Likonen
  1 sibling, 0 replies; 4+ messages in thread
From: Teemu Likonen @ 2011-01-10  6:43 UTC (permalink / raw)
  To: extronom; +Cc: help-gnu-emacs

* 2011-01-09 07:27 (-0800), extronom@googlemail.com wrote:

> I'm trying to add some new keywords by doing font-lock-add-keywords so
> that a FIXME keyword gets highlighted, which works quite well. When I
> try to change the color of the used face it doesn't work and probably
> somebody could give me a hint what the problem is here (I'm still a
> newbie regarding elisp programming).

I'm the author of wcheck-mode [1], so perhaps quite naturally I would
use it for this task too. Let's create a new language called "fixme" and
choose some face for highlighting:


    ;; Make sure the variable exists.
    (defvar wcheck-language-data nil)

    (push '("fixme"
            (program . (lambda (strings)
                         (when (member "FIXME" strings)
                           (list "FIXME"))))
            (face . highlight))
          wcheck-language-data)


This configuration uses face "highlight" but you can use any face you
want. Change languages with command wcheck-change-language and switch
the mode on and off with command wcheck-mode. See the Emacs wiki page
[1] for more information about wcheck-mode.

---------------
 1. http://www.emacswiki.org/emacs/WcheckMode



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

end of thread, other threads:[~2011-01-10  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-09 15:27 set face for added font lock keywords extronom
2011-01-10  5:31 ` Suvayu Ali
2011-01-10  5:34   ` Suvayu Ali
2011-01-10  6:43 ` Teemu Likonen

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.