* how to display a character with a specific glyph and face ?
@ 2014-10-23 12:57 Boiteux Frederic
2014-10-23 15:44 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Boiteux Frederic @ 2014-10-23 12:57 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
When I was using Emacs23, I had a piece of config to display « no-break space » character with another glyph (centered dot) an a specific face (with a blue background) :
(make-face 'nbsp-face)
(set-face-background 'nbsp-face "LightBlue")
(require 'disp-table)
(aset standard-display-table
(make-char 'latin-iso8859-1 (- ?\240 128))
(vector (+ ?\267 (* 524288 (face-id 'nbsp-face)))))
It was very helpful when editing text mixing standard and no-break spaces.
Now, I use Emacs24 and mainly UTF-8 encoded files/buffers, and I tried to do the same, without success. I tried :
(aset standard-display-table
#xA0 ;; NO-BREAK SPACE
(vector (+ #xB7 ;; MIDDLE DOT
(* 524288 (face-id 'nbsp-face)))))
But it doesn't work as expected : I get an Unicode character not mapped to a glyph (giving a number written in a square), with a red background (!).
Do you know how I could do this display with Emacs24 ?
With regards,
Fred.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to display a character with a specific glyph and face ?
[not found] <mailman.11860.1414070397.1147.help-gnu-emacs@gnu.org>
@ 2014-10-23 13:30 ` Stefan Monnier
2014-10-24 6:14 ` Boiteux Frederic
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-10-23 13:30 UTC (permalink / raw)
To: help-gnu-emacs
> When I was using Emacs23, I had a piece of config to display
> « no-break space » character with another glyph (centered dot) an
> a specific face (with a blue background) :
I don't know the answer to your question, but I wonder why you need
this customization. By default the NBSP char is highlighted with
`escape-glyph' face already, so the only difference is that additionally
to having a special color you replace the "whitespace" with
a centered dot.
Is there a strong reason why you need this extra behavior, or is it just
something you've gotten used to?
Stefan "just curious"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to display a character with a specific glyph and face ?
2014-10-23 12:57 Boiteux Frederic
@ 2014-10-23 15:44 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2014-10-23 15:44 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 23 Oct 2014 14:57:43 +0200
> From: "Boiteux Frederic" <fboiteux@prosodie.com>
>
> (make-face 'nbsp-face)
> (set-face-background 'nbsp-face "LightBlue")
>
> (require 'disp-table)
> (aset standard-display-table
> (make-char 'latin-iso8859-1 (- ?\240 128))
> (vector (+ ?\267 (* 524288 (face-id 'nbsp-face)))))
>
> It was very helpful when editing text mixing standard and no-break spaces.
> Now, I use Emacs24 and mainly UTF-8 encoded files/buffers, and I tried to do the same, without success. I tried :
>
> (aset standard-display-table
> #xA0 ;; NO-BREAK SPACE
> (vector (+ #xB7 ;; MIDDLE DOT
> (* 524288 (face-id 'nbsp-face)))))
>
> But it doesn't work as expected : I get an Unicode character not mapped to a glyph (giving a number written in a square), with a red background (!).
>
> Do you know how I could do this display with Emacs24 ?
Like this:
(aset standard-display-table
#xA0 ;; NO-BREAK SPACE
(vector (make-glyph-code #xb7 'nbsp-face)))
I'm with Stefan wondering why you'd need that. In addition to what
Stefan points out, I can suggest to take a look at whitespace-mode.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: how to display a character with a specific glyph and face ?
2014-10-23 13:30 ` how to display a character with a specific glyph and face ? Stefan Monnier
@ 2014-10-24 6:14 ` Boiteux Frederic
2014-10-24 7:02 ` Eli Zaretskii
[not found] ` <<837fzq6jbw.fsf@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Boiteux Frederic @ 2014-10-24 6:14 UTC (permalink / raw)
To: help-gnu-emacs
Hello Stefan, Eli,
Thanks for you quick replies.
Yes, I've done this since a long time to distinguish non-break space from standard ones (I think in emacs22 ou 23), and tried to report this on emacs24, as I didn't understood that in this version, the non-break space is already shown with a special face ! I got a small brown « underscore », not very different from standard underscore, and as on my keyboard, these two characters are on the same key, it wasn't sufficient for me.
Instead of modifying the standard-display-table, I should modify the escape-glyph face, isn't it ?
Thanks for your suggestions and solutions,
Fred.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to display a character with a specific glyph and face ?
2014-10-24 6:14 ` Boiteux Frederic
@ 2014-10-24 7:02 ` Eli Zaretskii
[not found] ` <<837fzq6jbw.fsf@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2014-10-24 7:02 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 24 Oct 2014 08:14:52 +0200
> From: "Boiteux Frederic" <fboiteux@prosodie.com>
>
> Instead of modifying the standard-display-table, I should modify the escape-glyph face, isn't it ?
Either the escape-glyph face, or, if you are only interested in the
no-break space character, the nobreak-space face.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: how to display a character with a specific glyph and face ?
[not found] ` <<837fzq6jbw.fsf@gnu.org>
@ 2014-10-24 14:01 ` Drew Adams
2014-10-24 14:49 ` Boiteux Frederic
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-10-24 14:01 UTC (permalink / raw)
To: help-gnu-emacs
> > Instead of modifying the standard-display-table, I should modify
> > the escape-glyph face, isn't it ?
>
> Either the escape-glyph face, or, if you are only interested in the
> no-break space character, the nobreak-space face.
If you want to highlight only hard (i.e., no-break) spaces, and
not also hard hyphens, or if you want font-lock to control the
highlighting, then you can use library `highlight-chars.el'.
http://www.emacswiki.org/emacs/ShowWhiteSpace#HighlightChars
http://www.emacswiki.org/emacs-en/download/highlight-chars.el
You can turn on/off such highlighting:
* in the current buffer only (i.e., locally),
* globally whenever FontLockMode is turned on, or
* automatically whenever a buffer is in a given major mode
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: how to display a character with a specific glyph and face ?
2014-10-24 14:01 ` Drew Adams
@ 2014-10-24 14:49 ` Boiteux Frederic
0 siblings, 0 replies; 7+ messages in thread
From: Boiteux Frederic @ 2014-10-24 14:49 UTC (permalink / raw)
To: help-gnu-emacs
Thanks for all your replies :-) As usual with Emacs, there isn't a
single way nor a unique possible solution for a problem...
Fred.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-24 14:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.11860.1414070397.1147.help-gnu-emacs@gnu.org>
2014-10-23 13:30 ` how to display a character with a specific glyph and face ? Stefan Monnier
2014-10-24 6:14 ` Boiteux Frederic
2014-10-24 7:02 ` Eli Zaretskii
[not found] ` <<837fzq6jbw.fsf@gnu.org>
2014-10-24 14:01 ` Drew Adams
2014-10-24 14:49 ` Boiteux Frederic
2014-10-23 12:57 Boiteux Frederic
2014-10-23 15:44 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).