I am trying to write a menu which changes `buffer-display-table' in
the current buffer. The buffer may be visible through several
windows. I keep fighting with a problem in emacs-19.34 (GNU Emacs
19.34.1, sparc-sun-sunos4.1.4, X toolkit) whose origin I do not
completely understand. The piece of code below illustrates the
(setq test-table (make-display-table))
(aset test-table ?a [?b])
(defun test-b () "Display all \"a\" as \"b\" in the current buffer."
(setq buffer-display-table test-table))
(defun test-a () "Restore the usual display conventions." (interactive)
(setq buffer-display-table nil))
(define-key global-map [menu-bar test]
(cons "Test" (make-sparse-keymap "Test")))
(define-key global-map [menu-bar test test-a] '("default". test-a))
(define-key global-map [menu-bar test test-b] '("\"a\" as \"b\"". test-b))
When I select the menu 'Test' with `tmm-menubar' and then choose the
entry '"a" as "b"' then all letters "a" in the current buffer are
displayed as "b". However when I select the same entry using the
mouse, the display table is set to the right value but the buffer is
not redisplayed until I press some key on the keyboard (and what if
the buffer is read-only?). I'd like to have emacs redisplay the buffer
automatically whenever the buffer-display-table is changed. It seems
from info pages (even though it is not obvious) that setting of
`buffer-display-table' must result in immediate redisplaying of the
buffer, or does one need `redraw-display'? May be something is
missing in my function definitions? The function `redraw-frame' does
not solve the problem since buffer may be displayed in several frames,
and `redraw-display' seems to be an overkill for my purposes.
Does anyone has a cure (or perhaps a reasonable explanation) for this?
Many thanks, Denis Kosygin.