* Trying to disable the fontification of strings in fundamental-mode
@ 2008-09-12 4:30 Davin Pearson
2008-09-12 8:57 ` Nikolaj Schumacher
[not found] ` <mailman.19100.1221209839.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 5+ messages in thread
From: Davin Pearson @ 2008-09-12 4:30 UTC (permalink / raw
To: help-gnu-emacs
I am trying to turn off the fonfication of strings in
fundamental
mode. The following code appears to turn it off in *all* modes,
not
just fundamental mode. What do I need to do to restrict
the
suppressing of the fontification of strings to just fundamental
mode?
(defadvice fundamental-mode (before my-remove-strings
activate)
(if (eq major-mode 'fundamental-
mode)
(setq font-lock-string-face
nil)))
(defadvice fundamental-mode (after my-remove-strings
activate)
(if (eq major-mode 'fundamental-
mode)
(setq font-lock-string-face
nil)))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trying to disable the fontification of strings in fundamental-mode
2008-09-12 4:30 Trying to disable the fontification of strings in fundamental-mode Davin Pearson
@ 2008-09-12 8:57 ` Nikolaj Schumacher
[not found] ` <mailman.19100.1221209839.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 5+ messages in thread
From: Nikolaj Schumacher @ 2008-09-12 8:57 UTC (permalink / raw
To: Davin Pearson; +Cc: help-gnu-emacs
Davin Pearson <davin.pearson@gmail.com> wrote:
> What do I need to do to restrict the suppressing of the fontification
> of strings to just fundamental mode?
First of all, don't use advice for this! Use hooks, which are cleaner
and safer.
Second of all, setq changes the variable globally, so naturally it is
disabled everywhere. You need to make the variable buffer-local.
(defun my-fundamental-mode-hook ()
(set (make-variable-buffer-local 'font-lock-string-face) nil))
(add-hook 'fundamental-mode-hook 'my-fundamental-mode-hook)
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trying to disable the fontification of strings in fundamental-mode
[not found] ` <mailman.19100.1221209839.18990.help-gnu-emacs@gnu.org>
@ 2008-09-13 2:48 ` Davin Pearson
2008-09-13 2:57 ` Davin Pearson
0 siblings, 1 reply; 5+ messages in thread
From: Davin Pearson @ 2008-09-13 2:48 UTC (permalink / raw
To: help-gnu-emacs
On Sep 12, 8:57 pm, Nikolaj Schumacher <m...@nschum.de> wrote:
> Davin Pearson <davin.pear...@gmail.com> wrote:
> > What do I need to do to restrict the suppressing of the fontification
> > of strings to just fundamental mode?
>
> First of all, don't use advice for this! Use hooks, which are cleaner
> and safer.
>
> Second of all, setq changes the variable globally, so naturally it is
> disabled everywhere. You need to make the variable buffer-local.
>
> (defun my-fundamental-mode-hook ()
> (set (make-variable-buffer-local 'font-lock-string-face) nil))
>
> (add-hook 'fundamental-mode-hook 'my-fundamental-mode-hook)
The above code doesn't work as there is no Emacs hook called
fundamental-mode-hook
Following your advice about local variables I also tried the
following:
(defadvice fundamental-mode (before my-remove-strings
activate)
(if (eq major-mode 'fundamental-
mode)
(set (make-variable-buffer-local 'font-lock-string-face)
nil)))
(defadvice fundamental-mode (after my-remove-strings
activate)
(if (eq major-mode 'fundamental-
mode)
(set (make-variable-buffer-local 'font-lock-string-face) nil)))
and both of these don't work either.
What gives?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trying to disable the fontification of strings in fundamental-mode
2008-09-13 2:48 ` Davin Pearson
@ 2008-09-13 2:57 ` Davin Pearson
2008-09-14 22:54 ` Nikolaj Schumacher
0 siblings, 1 reply; 5+ messages in thread
From: Davin Pearson @ 2008-09-13 2:57 UTC (permalink / raw
To: help-gnu-emacs
I managed to get the following code to work:
> (defadvice fundamental-mode (after my-remove-strings
> activate)
> (if (eq major-mode 'fundamental-
> mode)
> (set (make-variable-buffer-local 'font-lock-string-face) nil)))
I don't see the problem about using advice. I use advice all of the
time in Emacs.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trying to disable the fontification of strings in fundamental-mode
2008-09-13 2:57 ` Davin Pearson
@ 2008-09-14 22:54 ` Nikolaj Schumacher
0 siblings, 0 replies; 5+ messages in thread
From: Nikolaj Schumacher @ 2008-09-14 22:54 UTC (permalink / raw
To: Davin Pearson; +Cc: help-gnu-emacs
Davin Pearson <davin.pearson@gmail.com> wrote:
> I managed to get the following code to work:
>
>> (defadvice fundamental-mode (after my-remove-strings
>> activate)
>> (if (eq major-mode 'fundamental-
>> mode)
>> (set (make-variable-buffer-local 'font-lock-string-face) nil)))
Sorry that I missed that there's no `fundamental-mode-hook'. You can
use `after-change-major-mode-hook' instead. You'll still need to test
the major-mode variable the way you did.
Also the right function is `make-local-variable', not
`make-variable-buffer-local'. Sorry, I always mix those up.
> I don't see the problem about using advice. I use advice all of the
> time in Emacs.
Advice can certainly do the job. But they are a very powerful tool that
can break a lot of stuff, unless you're careful. Hooks are made for
this very purpose, however.
Some discussion about this is here:
http://www.emacswiki.org/cgi-bin/wiki/AdviceVsHooks
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-09-14 22:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 4:30 Trying to disable the fontification of strings in fundamental-mode Davin Pearson
2008-09-12 8:57 ` Nikolaj Schumacher
[not found] ` <mailman.19100.1221209839.18990.help-gnu-emacs@gnu.org>
2008-09-13 2:48 ` Davin Pearson
2008-09-13 2:57 ` Davin Pearson
2008-09-14 22:54 ` Nikolaj Schumacher
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.