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

Fix bug related to symbolic link followup #7

Merged
merged 3 commits into from
Feb 20, 2022
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
10 changes: 10 additions & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
* 0.5

- Stop following symbolic link as it leads to a high CPU usage. This
situation can happen frequently in a distribution like NixOS where
you can have a symbolic link inside nix's store ~/nix/store~.
- Minor cleanup in the way logging happens in the ~just-process~
buffer.
- Fix bug when process execution itself throws error.
- Migrate from the deprecated ~define-transient-command~

* 0.4

- Provides explicit details once just recipe execution is
Expand Down
21 changes: 10 additions & 11 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ NAME is the buffer name."

(defvar justl--last-command nil)

(defvar justl--list-command-exit-code t)
(defvar justl--list-command-exit-code 0)

(defconst justl--process-buffer "*just-process*"
"Just process buffer name.")
Expand Down Expand Up @@ -159,11 +159,8 @@ NAME is the buffer name."

DIR represents the directory where search will be carried
out. The search will be performed recursively."
(f-files dir (lambda (file)
(or
(cl-equalp "justfile" (f-filename file))
(cl-equalp ".justfile" (f-filename file))))
t))
(let ((case-fold-search t))
(directory-files-recursively dir "justfile")))

(defun justl--get-recipe-name (str)
"Compute the recipe name from the string STR."
Expand Down Expand Up @@ -215,20 +212,22 @@ CMD is the just command as a list."
(let ((str-cmd (if (equal 'string (type-of cmd)) cmd (mapconcat #'identity cmd " "))))
(setq justl--last-command str-cmd)
(justl--append-to-process-buffer
(format "[%s]\ncommand: %s" process-name str-cmd))))
(format "[%s] \ncommand: %s" process-name str-cmd))))

(defun justl--sentinel (process _)
"Sentinel function for PROCESS."
(let ((process-name (process-name process))
(exit-status (process-exit-status process)))
(justl--append-to-process-buffer (format "[%s]\nexit-code: %s" process-name exit-status))
(with-current-buffer (get-buffer justl--output-process-buffer)
(goto-char (point-max))
(insert (format "\nFinished execution: exit-code %s" exit-status)))
(unless (eq 0 exit-status)
(let ((err (with-current-buffer (justl--process-error-buffer process-name)
(let ((err (with-current-buffer (get-buffer-create (justl--process-error-buffer process-name))
(buffer-string))))
(justl--append-to-process-buffer (format "error: %s" err))
(justl--append-to-process-buffer
(format "[%s] error: %s"
process-name
err))
(error "Just process %s error: %s" process-name err)))))

(defun justl--xterm-color-filter (proc string)
Expand Down Expand Up @@ -422,7 +421,7 @@ tweaked further by the user."
:argument-regexp "\\(--color \\(auto\\|always\\|never\\)\\)"
:choices '("auto" "always" "never"))

(define-transient-command justl-help-popup ()
(transient-define-prefix justl-help-popup ()
"Justl Menu"
[["Arguments"
("-s" "Clear shell arguments" "--clear-shell-args")
Expand Down