Skip to content

Commit

Permalink
Merge pull request #68 from bbbscarter/master
Browse files Browse the repository at this point in the history
Added option justl-pop-to-buffer-on-display
  • Loading branch information
psibi authored Nov 23, 2024
2 parents 8292554 + f64cd9c commit e04f656
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
with no-cd recipe attribute.
- Justl buffer names are changed to include filename too. This is made
in preparation for supporting just modules.
- Add ~justl-pop-to-buffer-on-display~. When on, input focus moves to the justl
buffer when it is displayed (the previous behavior). Otherwise the buffer is
displayed without selecting it. (defaults to on).

* 0.14

Expand Down
20 changes: 17 additions & 3 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ package to be installed."
(const vterm))
:group 'justl)

(defcustom justl-pop-to-buffer-on-display t
"If non-nil, selects the justl buffer when it is displayed.
If nil, displays the buffer without selecting it."
:type 'boolean
:group 'justl
:safe 'booleanp)

(defun justl--recipe-output-buffer (recipe-name)
"Return the buffer name for the RECIPE-NAME."
(if justl-per-recipe-buffer
Expand All @@ -146,7 +153,10 @@ package to be installed."
"Utility function to pop to buffer or create it.
NAME is the buffer name."
(pop-to-buffer-same-window (get-buffer-create name)))
(let ((buf (get-buffer-create name)))
(if justl-pop-to-buffer-on-display
(pop-to-buffer-same-window buf)
(display-buffer buf display-buffer--same-window-action))))

(defconst justl--process-buffer "*just-process*"
"Just process buffer name.")
Expand Down Expand Up @@ -281,7 +291,9 @@ ARGS is a plist that affects how the process is run.
(set-process-filter process 'justl--process-filter)
(set-process-sentinel process (lambda (proc _) (justl--sentinel proc buf)))
(set-process-coding-system process 'utf-8-emacs-unix 'utf-8-emacs-unix)
(pop-to-buffer buf)))))
(if justl-pop-to-buffer-on-display
(pop-to-buffer buf)
(display-buffer buf))))))

(defvar justl-compile-mode-map
(let ((map (make-sparse-keymap)))
Expand Down Expand Up @@ -388,7 +400,9 @@ ARGS is a ist of arguments."
:process process-name
:directory default-directory
:mode mode)))
(pop-to-buffer justl--output-process-buffer))
(if justl-pop-to-buffer-on-display
(pop-to-buffer justl--output-process-buffer)
(display-buffer justl--output-process-buffer)))

(defun justl--exec-to-string-with-exit-code (executable &rest args)
"Run EXECUTABLE with ARGS, throwing an error if the command fails.
Expand Down

0 comments on commit e04f656

Please sign in to comment.