我想在文档本地的 Emacs 中定义一个缩写,即:
- 它不会被写入 abbrev 文件
- 它会否决 abbrev 文件中具有相同键的任何缩写,但仅适用于当前文档。
到目前为止,我所拥有的是:
%%% eval: (define-abbrev-table 'latex-mode-abbrev-table '(("tc" "triangular clique" nil 0)))
但这不能满足我的要求......,
我想在文档本地的 Emacs 中定义一个缩写,即:
到目前为止,我所拥有的是:
%%% eval: (define-abbrev-table 'latex-mode-abbrev-table '(("tc" "triangular clique" nil 0)))
但这不能满足我的要求......,
这个怎么样:
(defun set-local-abbrevs (abbrevs)
"Add ABBREVS to `local-abbrev-table' and make it buffer local.
ABBREVS should be a list of abbrevs as passed to `define-abbrev-table'.
The `local-abbrev-table' will be replaced by a copy with the new
abbrevs added, so that it is not the same as the abbrev table used
in other buffers with the same `major-mode'."
(let* ((bufname (buffer-name))
(prefix (substring (md5 bufname) 0 (length bufname)))
(tblsym (intern (concat prefix "-abbrev-table"))))
(set tblsym (copy-abbrev-table local-abbrev-table))
(dolist (abbrev abbrevs)
(define-abbrev (eval tblsym)
(car abbrev)
(cadr abbrev)
(caddr abbrev)))
(setq-local local-abbrev-table (eval tblsym))))
接着:
(set-local-abbrevs '(("tc" "triangular clique" nil)))