我寫了一個很簡單的Emacs模式標準ML:Emacs的增加是一致的縮進規則,通用-X模式
;; sml syntax
(require 'generic-x)
(define-generic-mode
'sml-mode ;; name of the mode
'(("(*" . "*)")) ;; comments delimiter
'("fun" "fn" "let" "val" "datatype" "type" "case" "of" "end" "structure" "struct" "signature" "sig")
'(("=" . 'font-lock-builtin-face)
("|" . 'font-lock-builtin-face)
(">" . 'font-lock-builtin-face)
("<" . 'font-lock-builtin-face)
("-" . 'font-lock-builtin-face)
("+" . 'font-lock-builtin-face)
(";" . 'font-lock-builtin-face)
("," . 'font-lock-builtin-face)
("{" . 'font-lock-builtin-face)
("}" . 'font-lock-builtin-face)
("(" . 'font-lock-builtin-face)
(")" . 'font-lock-builtin-face)
(":" . 'font-lock-builtin-face)
("[" . 'font-lock-builtin-face)
("]" . 'font-lock-builtin-face)) ;; a built-in
'("\\.sml$") ;; files that trigger this mode
nil ;; any other functions to call
"SML highlighting mode" ;; doc string
)
但是,它不會持續縮進。我無法準確描述它如何縮進,但它在製表符和空格以及空格的長度之間切換不一致。我能想到的最簡單的規則是始終在同一列上開始一個新行,並且標籤總是將您帶到下一個爲4的倍數的列。標籤應該是空格。我如何使用通用模式來做到這一點?
由於在模式定義一個音符,我使用的是內置的臉,因爲不正確的操作面沒有着色。現在看起來很醜陋。
爲了得到您想要的縮進行爲,您嘗試過了些什麼? – Thomas