emacs standard-/buffer-display-table alterations (transliteration experiment)
I adapted cyril-util.el for having transliteration of the Mkhedruli script of Georgian language. A very quick and dirty hack, but it led me to trying to learn about display-tables. The function standard-display-mkhedruli-translit flips (using a buffer-local variable) between Georgian and latin alphabet by altering the buffer-display-table, or creating a new fresh one. I posted it here: https://gist.github.com/1253614
In addition to t开发者_运维技巧his, I alter the standard-display-table in .emacs to eliminate line-wrapping eol char, and making split windows on tty use a nicer (unicode) character, like this:
(set-display-table-slot standard-display-table 'wrap ?\ )
(set-display-table-slot standard-display-table 'vertical-border ?│)
The problem now is that, though transliteration works all right, I end up losing my standard-display-table adjustments. Any ideas how to bring all this together seamlessly? I wouldn't want to have these adjustments also in my mkhedruli-function...
(There are certainly a few more flaws, such as the rough (redraw-display), which I for some reason needed to do).
You can use (set-char-table-parent <newtable> standard-display-table)
on the newly created table.
While I'm here: you can simplify your code by using define-minor-mode
.
Other kinds of simplifications:
(let ( (mkhedruli-language nil) )
(if (equal mkhedruli-active nil)
(setq mkhedruli-language "Georgian")
(setq mkhedruli-language nil))
(with-current-buffer (current-buffer)
(if (equal mkhedruli-language nil)
(setq mkhedruli-active nil)
(setq mkhedruli-active t)))
turns into
(let ( (mkhedruli-language nil) )
(setq mkhedruli-language
(if (equal mkhedruli-active nil)
"Georgian"
nil))
(if (equal mkhedruli-language nil)
(setq mkhedruli-active nil)
(setq mkhedruli-active t))
which can turn into
(let ((mkhedruli-language
(if mkhedruli-active nil "Georgian"))))
(setq mkhedruli-active
(if mkhedruli-language t nil))
tho you may prefer to just switch the two:
(setq mkhedruli-active (not mkhedruli-active))
(let ((mkhedruli-language
(if mkhedruli-active "Georgian"))))
and even get rid of mkhedruli-language
altogether since you only test if it's nil
, and you can test mkhedruli-active
instead to get the same information.
精彩评论