Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option justl-pop-to-buffer-on-display #68

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add :group here ? You can see other defcustom for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh! Yes, of course.

: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
Loading