3939(defcustom zig-indent-offset 4
4040 " Indent Zig code by this number of spaces."
4141 :type 'integer
42- :group 'zig-mode
4342 :safe #'integerp )
4443
4544(defcustom zig-format-on-save t
4645 " Format buffers before saving using zig fmt."
4746 :type 'boolean
48- :safe #'booleanp
49- :group 'zig-mode )
50-
51- (defcustom zig-format-show-buffer t
52- " Show a *zig-fmt* buffer after zig fmt completes with errors"
53- :type 'boolean
54- :safe #'booleanp
55- :group 'zig-mode )
47+ :safe #'booleanp )
5648
5749(defcustom zig-zig-bin " zig"
5850 " Path to zig executable."
5951 :type 'file
60- :safe #'stringp
61- :group 'zig-mode )
52+ :safe #'stringp )
6253
6354(defcustom zig-run-optimization-mode " Debug"
6455 " Optimization mode to run code with."
6556 :type 'string
66- :safe #'stringp
67- :group 'zig-mode )
57+ :safe #'stringp )
6858
6959(defcustom zig-test-optimization-mode " Debug"
7060 " Optimization mode to run tests with."
7161 :type 'string
72- :safe #'stringp
73- :group 'zig-mode )
62+ :safe #'stringp )
7463
7564; ; zig CLI commands
7665
7766(defun zig--run-cmd (cmd &optional source &rest args )
7867 " Use compile command to execute a zig CMD with ARGS if given.
7968If given a SOURCE, execute the CMD on it."
80- (let ((cmd-args
81- (if source
82- (mapconcat 'shell-quote-argument (cons source args) " " )
83- args)))
84- (compilation-start (concat zig-zig-bin " " cmd " " cmd-args))))
69+ (let ((cmd-args (if source (cons source args) args)))
70+ (compilation-start (mapconcat 'shell-quote-argument
71+ `(, zig-zig-bin , cmd ,@cmd-args ) " " ))))
8572
8673;;;### autoload
8774(defun zig-compile ()
@@ -229,8 +216,7 @@ If given a SOURCE, execute the CMD on it."
229216
230217(defface zig-multiline-string-face
231218 '((t :inherit font-lock-string-face ))
232- " Face for multiline string literals."
233- :group 'zig-mode )
219+ " Face for multiline string literals." )
234220
235221(defvar zig-font-lock-keywords
236222 (append
@@ -441,14 +427,12 @@ This is written mainly to be used as `end-of-defun-function' for Zig."
441427 (point ) end))
442428
443429(defun zig-mode-syntactic-face-function (state )
444- (if ( nth 3 state)
445- ( save-excursion
446- ( goto-char (nth 8 state) )
430+ (save-excursion
431+ ( goto-char ( nth 8 state))
432+ ( if (nth 3 state)
447433 (if (looking-at " \\\\\\\\ " )
448434 'zig-multiline-string-face
449- 'font-lock-string-face ))
450- (save-excursion
451- (goto-char (nth 8 state))
435+ 'font-lock-string-face )
452436 (if (looking-at " //[/|!][^/]" )
453437 'font-lock-doc-face
454438 'font-lock-comment-face ))))
@@ -467,16 +451,6 @@ This is written mainly to be used as `end-of-defun-function' for Zig."
467451 '(" enum" " struct" " union" ))
468452 `((" Fn" ,(zig-re-definition " fn" ) 1 ))))
469453
470- (defun zig-file-coding-system ()
471- " Guarantee filesystem unix line endings."
472- (with-current-buffer (current-buffer )
473- (if (buffer-file-name )
474- (if (string-match " \\ .d?zig\\ '" buffer-file-name)
475- (setq buffer-file-coding-system 'utf-8-unix )
476- nil ))))
477-
478- (add-hook 'zig-mode-hook 'zig-file-coding-system )
479-
480454(defvar zig-mode-map
481455 (let ((map (make-sparse-keymap )))
482456 (define-key map (kbd " C-c C-b" ) #'zig-compile )
@@ -488,10 +462,7 @@ This is written mainly to be used as `end-of-defun-function' for Zig."
488462
489463;;;### autoload
490464(define-derived-mode zig-mode prog-mode " Zig"
491- " A major mode for the Zig programming language.
492-
493- \\ {zig-mode-map}"
494- :group 'zig-mode
465+ " A major mode for the Zig programming language."
495466 (setq-local comment-start " // " )
496467 (setq-local comment-start-skip " //+ *" )
497468 (setq-local comment-end " " )
@@ -505,6 +476,7 @@ This is written mainly to be used as `end-of-defun-function' for Zig."
505476 (setq-local indent-tabs-mode nil ) ; Zig forbids tab characters.
506477 (setq-local syntax-propertize-function 'zig-syntax-propertize )
507478 (setq-local imenu-generic-expression zig-imenu-generic-expression)
479+ (setq buffer-file-coding-system 'utf-8-unix ) ; zig source is always utf-8
508480 (setq font-lock-defaults '(zig-font-lock-keywords
509481 nil nil nil nil
510482 (font-lock-syntactic-face-function . zig-mode-syntactic-face-function)))
0 commit comments