2011-09-30 51 views
1

我修改了cyril-util.el用於音譯格魯吉亞語Mkhedruli腳本。一個非常快速和骯髒的黑客,但它導致我試圖瞭解顯示錶。通過修改緩衝區顯示錶或者創建一個新的函數,standard-display-mkhedruli-translit可以在格魯吉亞語和拉丁字母之間翻轉(使用緩衝區局部變量)。我發佈在這裏:https://gist.github.com/1253614emacs標準/緩衝區顯示錶更改(音譯實驗)

除此之外,我改變.emacs中的標準顯示錶以消除換行符的eol字符,並使tty上的拆分窗口使用更好的(unicode)字符,像這樣:

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

現在的問題是,雖然音譯工作的很好,我結束了 失去我的標準顯示錶的調整。任何想法如何將所有這些無縫地結合在一起?我不希望這些調整也在我的mkhedruli函數中...

(當然還有更多的缺陷,比如粗糙(重繪顯示),我出於某種原因需要做) 。

回答

1

您可以在新創建的表上使用(set-char-table-parent <newtable> standard-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")))) 

一個d甚至完全擺脫mkhedruli-language,因爲您只測試它是否爲nil,而您可以測試mkhedruli-active而不是獲取相同的信息。