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

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

Re: Problem with CC mode hooks and font-locking


From: Francis Belliveau
Subject: Re: Problem with CC mode hooks and font-locking
Date: Sat, 1 Dec 2018 09:33:39 -0500

Thank you Eli, I found found the problem hidden elsewhere that was toggling 
things.  Understanding is everything.
By the way "Starting from the dock" is the same a clicking an icon on the 
desktop.  It just starts the application without any arguments.

I am now at the point of not liking what this is doing because, as Eli said, 
all coloring has been disabled.  I did like seeing the colors in buffers like 
the output of "grep".

So I removed the statement from my .emacs file and placed (font-lock-mode -1) 
in my  'c-initialization-hook' with the intention of only disabling colors in 
my coding modes.
That seems to disable it for only the first file loaded, but not the others.  
As Eli suggested, this does not have any effect on Lisp mode; that buffer is 
always colored.  My guess here is that placing it there does not step on the 
defaults for all future mode initializations like I would have expected.

So I moved if to my 'c-mode-common-hook' and that did the trick.

Thanks to all who read through my details.  I hope that it will help others to 
understand these things.

Fran


> On Dec 1, 2018, at 02:55, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Francis Belliveau <f.belliveau@comcast.net>
>> Date: Fri, 30 Nov 2018 16:50:23 -0500
>> 
>> To be clear, what I am trying to do is eliminate the colors being applied to 
>> text in all my files.  My understanding from the documentation is that if I 
>> add (global-font-lock-mode -1) to my .emacs file before I load any modes, 
>> the effects should be globally disabled.  Therefore, "failure" in this case 
>> is when various portions of my text is being shown in different colors.
>> 
>> I am not sure that it matters, but for clarity, my .emacs setup opens up 
>> with the window split vertically so that I can see two buffers 
>> simultaneously.
>> For the experiments below, I always open the application from my dock so 
>> that no file is loaded.  Then I usually open my .emacs file first, in the 
>> left half, then the code files in order on the right.  Where I open another 
>> file first, it is done in the left side and the others on the right.
> 
> Maybe the above does matters, as I'm not on macOS, so maybe there's
> something macOS specific involved here; in particular, I have no idea
> what does "opening application from my dock" mean.
> 
>> 1. Placing this in my .emacs file does not seem to have any effect.  Lisp, 
>> C++ and Java modes all show text in lots of colors.
> 
> Just doing this one thing, i.e. having a .emacs that says only
> 
>  (global-font-lock-mode -1)
> 
> disables colors in both Lisp (including *scratch* buffer and any Lisp
> file I visit) and C/Java files I visited.
> 
> Do you have anything else in your .emacs in addition to that single
> line?  If so, perhaps those other things are the culprit.  What
> happens if you leave just the above single line in your .emacs, and
> then restart Emacs?
> 
>> 2. Removed it from main .emacs and placed it in my 'c-initialization-hook' 
>> produces the following curious effects:
> 
> This is definitely not the right thing to do, so let's disregard what
> you get when you do this.  (c-initialization-hook is only relevant to
> C-like languages, which is not what you want.  And if you do anything
> from that hook, you should only change local values,
> i.e. font-lock-mode and not global-font-lock-mode; the latter is a
> global mode, so it is inappropriate to turn it on or off from a mode
> hook.)
> 
>> I do not understand why there is any "file load order" dependency
> 
> Because you are changing a global setting from a hook that is called
> when the first C-like file is visited.
> 




reply via email to

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