emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/nix-mode 207e5c0a92 455/500: nix-format.el: Add nix-format


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode 207e5c0a92 455/500: nix-format.el: Add nix-format-before-save
Date: Sat, 29 Jan 2022 08:27:55 -0500 (EST)

branch: elpa/nix-mode
commit 207e5c0a92536a271b18354745e58abd3553336a
Author: Aaron L. Zeng <me@bcc32.com>
Commit: Aaron L. Zeng <me@bcc32.com>

    nix-format.el: Add nix-format-before-save
    
    This is an autoloaded function suitable for adding to
    the global `before-save-hook`.
---
 nix-format.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nix-format.el b/nix-format.el
index 1f97e8a086..151c16bdd2 100644
--- a/nix-format.el
+++ b/nix-format.el
@@ -38,5 +38,11 @@
   (nix--format-call (current-buffer) (nix--find-nixfmt))
   (message "Formatted buffer with nixfmt."))
 
+;;;###autoload
+(defun nix-format-before-save ()
+  "Add this to `before-save-hook' to run nixfmt when saving."
+  (when (derived-mode-p 'nix-mode)
+    (nix-format-buffer)))
+
 (provide 'nix-format)
 ;;; nix-format.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]