all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `font-lock-add-keywords' works... sometimes
@ 2019-03-19  7:26 Emanuel Berg
  2019-03-19 14:42 ` Michael Heerdegen
  2019-03-19 16:44 ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Emanuel Berg @ 2019-03-19  7:26 UTC (permalink / raw)
  To: help-gnu-emacs

It is pretty cool to have Emacs as
psychedelic/LSD-ish as possible. For example,
when one types the name of a color, that word
becomes that color!

Or when one types the name of a face, that name
becomes the color of the face! (This is not
only cool but also practical BTW.)
Screenshot:
  http://user.it.uu.se/~embe8573/figures/emacs/emacs-lisp-faces.png [1]

Or even better/worse, when one types the word
of a sound, that will play from a directory of
audio files, finding a file with the same name
(e.g. "wolf" triggers "wolf.mp3") - this will
*freak you out* when deep in concentration and
not expecting it in the least! Try it... if you
dare :)

But anyway...

Why does this work

    (font-lock-add-keywords 'message-mode
     '(
       ("yellow" . font-lock-function-name-face)
      )
     t) ; append [2]

but not this

    (font-lock-add-keywords 'text-mode
     '(
       ("yellow" . font-lock-function-name-face)
      )
     t) ; append [3]

?

TIA


[1] line 20 @ http://user.it.uu.se/~embe8573/emacs-init/faces.el
[2] line 99 @ http://user.it.uu.se/~embe8573/emacs-init/gnus/message-my.el
[3] line  9 @ http://user.it.uu.se/~embe8573/emacs-init/my-text.el

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




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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19  7:26 `font-lock-add-keywords' works... sometimes Emanuel Berg
@ 2019-03-19 14:42 ` Michael Heerdegen
  2019-03-19 16:51   ` Emanuel Berg
  2019-03-19 16:44 ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2019-03-19 14:42 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <moasenwood@zoho.eu> writes:

> Why does this work
>
>     (font-lock-add-keywords 'message-mode
>      '(
>        ("yellow" . font-lock-function-name-face)
>       )
>      t) ; append [2]
>
> but not this
>
>     (font-lock-add-keywords 'text-mode
>      '(
>        ("yellow" . font-lock-function-name-face)
>       )
>      t) ; append [3]
>
> ?

This works:

(progn
  (font-lock-add-keywords 'text-mode
     '(("yellow" . font-lock-function-name-face))
     t)
  (font-lock-ensure))

But I don't know much about the details.


Michael.



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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19  7:26 `font-lock-add-keywords' works... sometimes Emanuel Berg
  2019-03-19 14:42 ` Michael Heerdegen
@ 2019-03-19 16:44 ` Stefan Monnier
  2019-03-19 17:04   ` Emanuel Berg
  2019-03-19 22:09   ` Michael Heerdegen
  1 sibling, 2 replies; 10+ messages in thread
From: Stefan Monnier @ 2019-03-19 16:44 UTC (permalink / raw)
  To: help-gnu-emacs

> but not this
>
>     (font-lock-add-keywords 'text-mode
>      '(
>        ("yellow" . font-lock-function-name-face)
>       )
>      t) ; append [3]

You'd first have to clarify what you mean by "work", but my crystal ball
suggests that text-m,ode does not enable font-lock by default, contrary
to message-mode.


        Stefan




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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 14:42 ` Michael Heerdegen
@ 2019-03-19 16:51   ` Emanuel Berg
  2019-03-19 22:22     ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2019-03-19 16:51 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

> This works:
>
> (progn
>   (font-lock-add-keywords 'text-mode
>      '(("yellow" . font-lock-function-name-face))
>      t)
>   (font-lock-ensure))
>
> But I don't know much about the details.

Thank you, but I don't have `font-lock-ensure',
probably another issue with my too-old
Emacs [1].

This has happened so many times by now I feel
like I'm virtually trolling. I'm not posting
anymore before I get an update, this is
getting ridiculous.

Still, it can be interesting to understand why
my identical code works for Message mode, but
not for Text mode?

BTW what is the proper "notation" for an
Emacs major mode? Personally, I'm all ascii
with lowercase and dashes, I even do that with
my file system, e.g. ~/tools/torque-wrench or
~/fighters/juan-manuel-marquez, so I'd like to
denote them (the major modes) for ex
"message-mode" and "text-mode". But in the help
(.e.g., `C-h M' when I type this) it is
"Message mode", not message-mode, so I suppose
I'm technically incorrect.



PS.Too little sleep guys. I hope this makes
   sense in the sense that you at least
   understand it :) DS.

[1] GNU Emacs 24.4.1
    (arm-unknown-linux-gnueabihf, GTK+ Version
    3.14.5) of 2017-09-13 on mb-lxc-01,
    modified by Debian

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




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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 16:44 ` Stefan Monnier
@ 2019-03-19 17:04   ` Emanuel Berg
  2019-03-19 22:09   ` Michael Heerdegen
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2019-03-19 17:04 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

> You'd first have to clarify what you mean by
> "work", but my crystal ball suggests that
> text-m,ode does not enable font-lock by
> default, contrary to message-mode.

Of course. In message-mode, I can toggle the
"yellow" back and forth (including all other
colors, of course) with `font-lock-mode', as
you say - but in text-mode I can only toggle
`font-lock-mode', not the actual colors -
because there are none no matter what.

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




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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 16:44 ` Stefan Monnier
  2019-03-19 17:04   ` Emanuel Berg
@ 2019-03-19 22:09   ` Michael Heerdegen
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2019-03-19 22:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> > but not this
> >
> >     (font-lock-add-keywords 'text-mode
> >      '(
> >        ("yellow" . font-lock-function-name-face)
> >       )
> >      t) ; append [3]
>
> You'd first have to clarify what you mean by "work", but my crystal ball
> suggests that text-m,ode does not enable font-lock by default, contrary
> to message-mode.

But it should be covered by global-font-lock-mode by default.

I see that font-lock-mode is indeed enabled but `font-lock-specified-p'
fails for a text-mode buffer, so you get a buffer with font-lock-mode on
but no fontification.  Maybe using font-lock-add-keywords without
setting any other font-lock variables confuses font-lock?  An explicit
`font-lock-set-defaults' call helps btw.


Michael.



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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 16:51   ` Emanuel Berg
@ 2019-03-19 22:22     ` Michael Heerdegen
  2019-03-19 23:37       ` Emanuel Berg
  2019-03-20  6:22       ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Michael Heerdegen @ 2019-03-19 22:22 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <moasenwood@zoho.eu> writes:

> Still, it can be interesting to understand why my identical code works
> for Message mode, but not for Text mode?

I tried to figure it out, but after reading the code, I got the
impression that it is intended to work.

> BTW what is the proper "notation" for an Emacs major mode? Personally,
> I'm all ascii with lowercase and dashes, I even do that with my file
> system, e.g. ~/tools/torque-wrench or ~/fighters/juan-manuel-marquez,
> so I'd like to denote them (the major modes) for ex "message-mode" and
> "text-mode". But in the help (.e.g., `C-h M' when I type this) it is
> "Message mode", not message-mode, so I suppose I'm technically
> incorrect.

I guess both are ok and no one cares.  Most people seem to prefer the
lowercase version.  C-h M just tries to be cool.

Some background: we have `major-mode', which is bound to a symbol naming
the mode, and the pretty version `mode-name' which specifies a string
(most of the time) to be displayed in the mode-line.  See the macro
`define-derived-mode' for example, where you specify both kinds of
names.


Michael.



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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 22:22     ` Michael Heerdegen
@ 2019-03-19 23:37       ` Emanuel Berg
  2019-03-20  6:22       ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2019-03-19 23:37 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

> Some background: we have `major-mode', which
> is bound to a symbol naming the mode, and the
> pretty version `mode-name' which specifies
> a string (most of the time) to be displayed
> in the mode-line. See the macro
> `define-derived-mode' for example, where you
> specify both kinds of names.

Aha, some nice "facts for fans".

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




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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-19 22:22     ` Michael Heerdegen
  2019-03-19 23:37       ` Emanuel Berg
@ 2019-03-20  6:22       ` Eli Zaretskii
  2019-03-21 14:25         ` Emanuel Berg
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2019-03-20  6:22 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Tue, 19 Mar 2019 23:22:14 +0100
> 
> > BTW what is the proper "notation" for an Emacs major mode? Personally,
> > I'm all ascii with lowercase and dashes, I even do that with my file
> > system, e.g. ~/tools/torque-wrench or ~/fighters/juan-manuel-marquez,
> > so I'd like to denote them (the major modes) for ex "message-mode" and
> > "text-mode". But in the help (.e.g., `C-h M' when I type this) it is
> > "Message mode", not message-mode, so I suppose I'm technically
> > incorrect.
> 
> I guess both are ok and no one cares.  Most people seem to prefer the
> lowercase version.  C-h M just tries to be cool.

The convention is to use lower case when referencing the mode as a
Lisp symbol, and capitalized words without hyphens when talking about
the mode in the documentation.



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

* Re: `font-lock-add-keywords' works... sometimes
  2019-03-20  6:22       ` Eli Zaretskii
@ 2019-03-21 14:25         ` Emanuel Berg
  0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2019-03-21 14:25 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:

> The convention is to use lower case when
> referencing the mode as a Lisp symbol, and
> capitalized words without hyphens when
> talking about the mode in the documentation.

Great, thanks.

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




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

end of thread, other threads:[~2019-03-21 14:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-19  7:26 `font-lock-add-keywords' works... sometimes Emanuel Berg
2019-03-19 14:42 ` Michael Heerdegen
2019-03-19 16:51   ` Emanuel Berg
2019-03-19 22:22     ` Michael Heerdegen
2019-03-19 23:37       ` Emanuel Berg
2019-03-20  6:22       ` Eli Zaretskii
2019-03-21 14:25         ` Emanuel Berg
2019-03-19 16:44 ` Stefan Monnier
2019-03-19 17:04   ` Emanuel Berg
2019-03-19 22:09   ` Michael Heerdegen

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.