all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Display of "narrow no-break space" character
@ 2023-06-17  9:31 PierGianLuca
  2023-06-17 10:39 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: PierGianLuca @ 2023-06-17  9:31 UTC (permalink / raw)
  To: help-gnu-emacs

Hi everyone.

I use Emacs with a GUI and monospaced font (DejaVu Sans Mono). Lately I've had to use "no-break space" (U+00A0) and "narrow no-break space" (U+202F) very often.

Emacs does a great job distinguishing space from no-break space: the latter is shown as an underlined space. However, no-break space and narrow no-break space are represented in exactly the same way (underlined space).

Does anyone know of a method to make Emacs use a different glyph for narrow no-break space?

I know of whitespace-mode, but that is a bit overkill for my needs, and would require a lot of customization because I don't need highlighting newlines, EOLs, and so on.

In case the theme used has something to do with this, I use modus-operandi. But other themes seem to have the same issue.

Cheers!



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

* Re: Display of "narrow no-break space" character
  2023-06-17  9:31 Display of "narrow no-break space" character PierGianLuca
@ 2023-06-17 10:39 ` Eli Zaretskii
  2023-06-17 12:09   ` PierGianLuca
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-17 10:39 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 17 Jun 2023 11:31:39 +0200
> From: PierGianLuca <luca@magnaspesmeretrix.org>
> 
> I use Emacs with a GUI and monospaced font (DejaVu Sans Mono). Lately I've had to use "no-break space" (U+00A0) and "narrow no-break space" (U+202F) very often.
> 
> Emacs does a great job distinguishing space from no-break space: the latter is shown as an underlined space. However, no-break space and narrow no-break space are represented in exactly the same way (underlined space).
> 
> Does anyone know of a method to make Emacs use a different glyph for narrow no-break space?

You should be able to use the display table to change how a character
is displayed.  See the node "Display Tables" in the ELisp manual for
more details about this feature.



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

* Re: Display of "narrow no-break space" character
  2023-06-17 10:39 ` Eli Zaretskii
@ 2023-06-17 12:09   ` PierGianLuca
  2023-06-17 13:15     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: PierGianLuca @ 2023-06-17 12:09 UTC (permalink / raw)
  To: help-gnu-emacs

Thank you for the reference, Eli.

I've read the whole "Character Display" section, but it's really above my head; at least the parts that are probably relevant.

I tried to follow the example that starts with

(setq disptab (make-display-table))
...
[incidentally, there are spurious parentheses at the end of that code]

modifying the "(aset disptab ...)", but no success.


On 230617 12:39, Eli Zaretskii wrote:
>> Date: Sat, 17 Jun 2023 11:31:39 +0200
>> From: PierGianLuca <luca@magnaspesmeretrix.org>
>>
>> I use Emacs with a GUI and monospaced font (DejaVu Sans Mono). Lately I've had to use "no-break space" (U+00A0) and "narrow no-break space" (U+202F) very often.
>>
>> Emacs does a great job distinguishing space from no-break space: the latter is shown as an underlined space. However, no-break space and narrow no-break space are represented in exactly the same way (underlined space).
>>
>> Does anyone know of a method to make Emacs use a different glyph for narrow no-break space?
> 
> You should be able to use the display table to change how a character
> is displayed.  See the node "Display Tables" in the ELisp manual for
> more details about this feature.
> 



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

* Re: Display of "narrow no-break space" character
  2023-06-17 12:09   ` PierGianLuca
@ 2023-06-17 13:15     ` Eli Zaretskii
  2023-06-17 14:04       ` PierGianLuca
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-17 13:15 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 17 Jun 2023 14:09:24 +0200
> From: PierGianLuca <luca@magnaspesmeretrix.org>
> 
> Thank you for the reference, Eli.
> 
> I've read the whole "Character Display" section, but it's really above my head; at least the parts that are probably relevant.
> 
> I tried to follow the example that starts with
> 
> (setq disptab (make-display-table))
> ...
> [incidentally, there are spurious parentheses at the end of that code]

Thanks, fixed.

> modifying the "(aset disptab ...)", but no success.

Crystal ball says you didn't assign the display table you created to
the buffer display table or standard-display-table.  Without that, all
you have is a display table that nothing in Emacs uses.

If the above is not what you tried, how about showing what you tried?



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

* Re: Display of "narrow no-break space" character
  2023-06-17 13:15     ` Eli Zaretskii
@ 2023-06-17 14:04       ` PierGianLuca
  2023-06-17 14:18         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: PierGianLuca @ 2023-06-17 14:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Eli, thank you, actually I think I've managed now:

(setq disptab (make-display-table))
(aset disptab 8239 [729]) ;; upper dot for narrow no-break space
(setq buffer-display-table disptab)

The question now is how to make this the standard display table on all future Emacs sessions. I tried adding

(aset standard-display-table 8239 [729])

to my .init.el, but it yields a "wrong type argument" error. Still, it works if I call it after Emacs is started instead.



On 230617 15:15, Eli Zaretskii wrote:
>> Date: Sat, 17 Jun 2023 14:09:24 +0200
>> From: PierGianLuca <luca@magnaspesmeretrix.org>
>>
>> Thank you for the reference, Eli.
>>
>> I've read the whole "Character Display" section, but it's really above my head; at least the parts that are probably relevant.
>>
>> I tried to follow the example that starts with
>>
>> (setq disptab (make-display-table))
>> ...
>> [incidentally, there are spurious parentheses at the end of that code]
> 
> Thanks, fixed.
> 
>> modifying the "(aset disptab ...)", but no success.
> 
> Crystal ball says you didn't assign the display table you created to
> the buffer display table or standard-display-table.  Without that, all
> you have is a display table that nothing in Emacs uses.
> 
> If the above is not what you tried, how about showing what you tried?
> 



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

* Re: Display of "narrow no-break space" character
  2023-06-17 14:04       ` PierGianLuca
@ 2023-06-17 14:18         ` Eli Zaretskii
  2023-06-17 14:34           ` PierGianLuca
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-17 14:18 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 17 Jun 2023 16:04:49 +0200
> From: PierGianLuca <luca@magnaspesmeretrix.org>
> 
> Hi Eli, thank you, actually I think I've managed now:
> 
> (setq disptab (make-display-table))
> (aset disptab 8239 [729]) ;; upper dot for narrow no-break space
> (setq buffer-display-table disptab)
> 
> The question now is how to make this the standard display table on all future Emacs sessions. I tried adding
> 
> (aset standard-display-table 8239 [729])
> 
> to my .init.el, but it yields a "wrong type argument" error. Still, it works if I call it after Emacs is started instead.

standard-display-table is not guaranteed to be set, so you need to
make sure it is first.  Like this:

  (or standard-display-table
      (setq standard-display-table (make-display-table)))
  (aset standard-display-table 8239 [729])

Note that you can also specify a face for the glyphs in the display
table, which could come in handy if you want them to stand out on
display.



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

* Re: Display of "narrow no-break space" character
  2023-06-17 14:18         ` Eli Zaretskii
@ 2023-06-17 14:34           ` PierGianLuca
  0 siblings, 0 replies; 7+ messages in thread
From: PierGianLuca @ 2023-06-17 14:34 UTC (permalink / raw)
  To: help-gnu-emacs

Fantastic, thank you so much, Eli! Also for the additional suggestion about faces; that will come in very handy indeed.

Cheers,
Luca

On 230617 16:18, Eli Zaretskii wrote:

> standard-display-table is not guaranteed to be set, so you need to
> make sure it is first.  Like this:
> 
>    (or standard-display-table
>        (setq standard-display-table (make-display-table)))
>    (aset standard-display-table 8239 [729])
> 
> Note that you can also specify a face for the glyphs in the display
> table, which could come in handy if you want them to stand out on
> display.
> 



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

end of thread, other threads:[~2023-06-17 14:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-17  9:31 Display of "narrow no-break space" character PierGianLuca
2023-06-17 10:39 ` Eli Zaretskii
2023-06-17 12:09   ` PierGianLuca
2023-06-17 13:15     ` Eli Zaretskii
2023-06-17 14:04       ` PierGianLuca
2023-06-17 14:18         ` Eli Zaretskii
2023-06-17 14:34           ` PierGianLuca

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.