In Emacs;
Is there a way for both window-display-table
and buffer-display-table
to have effect at the same time?
The reason is, I'm using Pretty-Control-L (from Emacs Goodies El script package) and whitespace (of whitespace.el
, I think it is in the base Emacs distribution, but I’m not sure).
- Pretty-Control-L visualizes form-feeds (
^L
) in a customized manner, by setting the entry forC-l
in the window-localwindow-display-table
. - Whitespace visualizes spaces, tabs and newlines by setting entries in the buffer-local
buffer-display-table
. (and also by usingfont-lock
functionality).
These uses clashes (or rather, the use of a window-display-table
and buffer-display-table
clashes) since, if the window-display-table
is non-nil
it completely overrides any buffer-display-table
for any buffer displayed in that window.
Quote from the Emacs Lisp manual:
38.21.2 Active Display Table
Each window can specify a display table, and so can each buffer. When a buffer B is displayed in window W, display uses the display table for window W if it has one; otherwise, the display table for buffer B if it has one; otherwise, the standard display table if any. The display table chosen is called the "active" display table.
[...]
(emphasis by me)
So, Is there any easy way to consolidate this? Or is the only way to re-code one of them to use the same mechanism as the other?
I've been considering writing a small (i.e. even smaller) crude variant of the form-feed visualization compatible with the white-space visualization that just uses some buffer-loading hook (or other) to put a hard-coded entry for ^L
in the buffer-display-table
. But I’d like to know if there’s any simpler alternative.
EDIT: To clarify the problem, here's a excerpt of an annotated "Interactive Lisp" session (i.e. from the *scratch*
-buffer). This shows the commands and their output, and annotated with the effects:
;; Emacs is started with `-q', to not load my init-file(s).
;; First, write some sample text with tabs and line-feeds:
"A tab: and some text
A line-feed:and some text"
;; Make sure that it is a tab on the first line (input by `C-q TAB')
;; and a line-feed on the second line (input by `C-q C-l').
;; These probably won't copy properly into Stack Exchange.
;; This shows the spaces as center-dots, tabs as `>>'-glyphs and
;; new-lines as $'s (or perhaps other glyphs, depending on system
;; setup...). All of them fontified to be dimmed out on yellow/beige/white
;; background.
(whitespace-mode t)
t
;; This turns on pretty-control-l mode. The `^L' above will be
;; prettified... Since this sets the window display table, the glyphs
;; for the spaces/tabs/new-lines will disappear, but the background of
;; spaces/tabs will still be yellow/beige (since that's done with
;; fontification, not display tables).
(pretty-control-l-mode t)
t
;; This turns pretty-control-l mode OFF again. The form-feed will
;; revert to displaying as `^L'. However, the glyphs for the
;; spaces/tabs/new-lines will not re-appear, since this only removes
;; the `C-l'-entry in the window-display-list, not the entire list.
(pretty-control-l-mode 0)
nil
;; Nil the window-display-table, to verify that is the culprit. This
;; will re-enable the glyphs defined by whitespace-mode (since they
;; are still in the buffer display-table).
(set-window-display-table nil nil)
nil
;; To round of; this is my Emacs-version:
(emacs-version)
"GNU Emacs 23.4.1 (i686-pc-linux-gnu, GTK+ Version 2.24.12)
of 2012-09-22 on akateko, modified by Debian"
;;End.