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

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

[nongnu] elpa/zig-mode 909e263 096/104: Merge pull request #53 from bbuc


From: ELPA Syncer
Subject: [nongnu] elpa/zig-mode 909e263 096/104: Merge pull request #53 from bbuccianti/master
Date: Sun, 29 Aug 2021 11:37:10 -0400 (EDT)

branch: elpa/zig-mode
commit 909e26365e0f63ee6d5d20f2c0c27ca16d59868b
Merge: 07efab0 b6abeb4
Author: Andrea Orru <andrea@orru.io>
Commit: GitHub <noreply@github.com>

    Merge pull request #53 from bbuccianti/master
    
    Add a defvar to define if user wants to return to buffer after fmt.
---
 zig-mode.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/zig-mode.el b/zig-mode.el
index f529e5c..5b8503b 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -105,11 +105,15 @@ If given a SOURCE, execute the CMD on it."
   (interactive)
   (zig--run-cmd "run" (buffer-file-name)))
 
+(defvar zig-return-to-buffer-after-format nil
+  "Enable zig-format-buffer to return to file buffer after fmt is done.")
+
 ;;;###autoload
 (defun zig-format-buffer ()
   "Format the current buffer using the zig fmt."
   (interactive)
-  (let ((fmt-buffer-name "*zig-fmt*"))
+  (let ((fmt-buffer-name "*zig-fmt*")
+        (file-buffer (current-buffer)))
     ;; If we have an old *zig-fmt* buffer, we want to kill
     ;; it and start a new one to show the new errors
     (when (get-buffer fmt-buffer-name)
@@ -126,8 +130,10 @@ If given a SOURCE, execute the CMD on it."
        (lambda (process _e)
          (if (> (process-exit-status process) 0)
              (progn
-               (switch-to-buffer-other-window fmt-buffer)
-               (compilation-mode))
+               (pop-to-buffer fmt-buffer)
+               (compilation-mode)
+               (when zig-return-to-buffer-after-format
+                 (pop-to-buffer file-buffer)))
            (revert-buffer :ignore-auto :noconfirm)))))))
 
 (defun zig-re-word (inner)



reply via email to

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