怎样设置默认保存为utf-8-unix格式?

希望在保存时,默认就使用此格式。现在的做法是每次都手动设置一下比较麻烦

;; Prefer utf-8
(set-charset-priority 'unicode)
(prefer-coding-system 'utf-8-unix)

如果在Windows下,那么可能有些用到的命令行程序会有编解码问题,那就再单独设置:

(when (memq system-type '(windows-nt ms-dos))
  ;; NOTE: (decoding output . encoding input)
  (add-to-list 'process-coding-system-alist '("rg" utf-8 . gbk))
  ;; NOTE: not needed if is native GBK locale(ex, no `(prefer-coding-system 'utf-8-unix)')
  (add-to-list 'process-coding-system-alist '("mutool" gbk . gbk))
  (add-to-list 'process-coding-system-alist '("es" gbk . gbk)))

用到那些程序就添加规则,不用就不用管这个。

1 个赞