all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* case-insensitive regexp in derived-mode
@ 2014-04-27 23:14 jfjfcli
  2014-04-27 23:38 ` Emanuel Berg
  2014-04-27 23:46 ` Jacob Gerlach
  0 siblings, 2 replies; 4+ messages in thread
From: jfjfcli @ 2014-04-27 23:14 UTC (permalink / raw)
  To: help-gnu-emacs

Following this tutorial
http://ergoemacs.org/emacs/elisp_syntax_coloring.html

Now my keywords are working, but the regexp to colour keyword is case insensitive.

I was able to get it to work by evaluating
(setq font-lock-keywords-case-fold-search t) 
after loading the custom mode into that buffer.

However no matter where I put it in the .el file of the custom mode, I cannot to work automatically.

The documentation also says "You can use case-fold in font-lock-defaults to specify the value of font-lock-keywords-case-fold-search which says whether search-based fontification should be case-insensitive."

any help would be great, thanks. 


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

* Re: case-insensitive regexp in derived-mode
  2014-04-27 23:14 case-insensitive regexp in derived-mode jfjfcli
@ 2014-04-27 23:38 ` Emanuel Berg
  2014-04-28  3:04   ` jfjfcli
  2014-04-27 23:46 ` Jacob Gerlach
  1 sibling, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2014-04-27 23:38 UTC (permalink / raw)
  To: help-gnu-emacs

jfjfcli@gmail.com writes:

> I was able to get it to work by evaluating (setq
> font-lock-keywords-case-fold-search t) after loading
> the custom mode into that buffer.
>
> However no matter where I put it in the .el file of
> the custom mode, I cannot to work automatically.

The documentation also says: "Automatically becomes
buffer-local when set." So perhaps your setting got
overruled along the way.

Try:

(set-default 'font-lock-keywords-case-fold-search t)

I don't know if you want that, but if it works, you
know where the first attempt failed.

-- 
underground experts united:
http://user.it.uu.se/~embe8573


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

* Re: case-insensitive regexp in derived-mode
  2014-04-27 23:14 case-insensitive regexp in derived-mode jfjfcli
  2014-04-27 23:38 ` Emanuel Berg
@ 2014-04-27 23:46 ` Jacob Gerlach
  1 sibling, 0 replies; 4+ messages in thread
From: Jacob Gerlach @ 2014-04-27 23:46 UTC (permalink / raw)
  To: help-gnu-emacs

> Now my keywords are working, but the regexp to colour keyword is case insensitive.

The tutorial shows:
(define-derived-mode math-lang-mode fundamental-mode
  (setq font-lock-defaults '(myKeywords))
  (setq mode-name "math lang")
)

If you look at the documentation for font-lock-defaults (C-h v font-lock-defaults <RET>), you will see an option for case-fold-search when specifying font-lock-defaults, so you instead want to use something like:

(setq font-lock-defaults '(myKeywords nil t))

The tutorials I read led me to use setq-local, but perhaps this is unnecessary, since as Emmanuel pointed out, it automatically becomes buffer local when set.



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

* Re: case-insensitive regexp in derived-mode
  2014-04-27 23:38 ` Emanuel Berg
@ 2014-04-28  3:04   ` jfjfcli
  0 siblings, 0 replies; 4+ messages in thread
From: jfjfcli @ 2014-04-28  3:04 UTC (permalink / raw)
  To: help-gnu-emacs

Le dimanche 27 avril 2014 19:38:11 UTC-4, Emanuel Berg a écrit :

> 
> Try:
> 
> 
> 
> (set-default 'font-lock-keywords-case-fold-search t)
> 
> 

That fixed my issue Thanks a lot!


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

end of thread, other threads:[~2014-04-28  3:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-27 23:14 case-insensitive regexp in derived-mode jfjfcli
2014-04-27 23:38 ` Emanuel Berg
2014-04-28  3:04   ` jfjfcli
2014-04-27 23:46 ` Jacob Gerlach

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.