emacs 标准/缓冲区显示表更改(音译实验)

发布于 2024-12-07 16:21:43 字数 634 浏览 0 评论 0原文

我改编了 cyril-util.el 来音译格鲁吉亚语的 Mkhedruli 文字。一个非常快速和肮脏的黑客,但它引导我尝试了解显示表。函数 standard-display-mkhedruli-translit 通过更改缓冲区显示表或创建一个新的表来在格鲁吉亚语和拉丁字母之间翻转(使用缓冲区本地变量)。我将其发布在这里: https://gist.github.com/1253614

除此之外,我还更改了.emacs 中的标准显示表可以消除换行 eol 字符,并使 tty 上的分割窗口使用更好的(unicode)字符,如下所示:

(set-display-table-slot standard-display-table 'wrap ?\ )
(set-display-table-slot standard-display-table 'vertical-border ?│)

现在的问题是,尽管音译工作正常,我最终 失去我的标准显示表调整。有什么想法如何将所有这些无缝地结合在一起吗?我不想在我的 mkhedruli 函数中也进行这些调整...

(当然还有一些缺陷,例如粗糙(重绘显示),出于某种原因我需要这样做)。

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 this, 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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掌心的温暖 2024-12-14 16:21:43

您可以在新创建的表上使用 (set-char-table-parentstandard-display-table)

当我在这里时:您可以使用 define-minor-mode 来简化代码。
其他类型的简化:

(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)))

变成

(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))

哪个可以变成

(let ((mkhedruli-language
       (if mkhedruli-active nil "Georgian"))))
  (setq mkhedruli-active 
        (if mkhedruli-language t nil))

你可能更喜欢切换两者:

(setq mkhedruli-active (not mkhedruli-active))
(let ((mkhedruli-language
       (if mkhedruli-active "Georgian"))))

甚至完全摆脱mkhedruli-language,因为你只测试它是否nil,您可以测试 mkhedruli-active 来获取相同的信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文