Skip to content

Commit

Permalink
Merge pull request #7 from psibi/infinite-recursion
Browse files Browse the repository at this point in the history
Fix bug related to symbolic link followup
  • Loading branch information
psibi authored Feb 20, 2022
2 parents f60f57a + 144999e commit dcc49c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
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

0 comments on commit dcc49c9

Please sign in to comment.