From 1f7f7148f54ea1db53b68291caefe7aceaed14cd Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 20 Feb 2022 18:12:57 +0530 Subject: [PATCH 1/3] Fix bug related to symbolic link followup This causes high CPU usage on situation where a symbolic link leads to a nix store. --- Changelog.org | 8 ++++++++ justl.el | 17 ++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Changelog.org b/Changelog.org index 9d6ba46..f2e7aac 100644 --- a/Changelog.org +++ b/Changelog.org @@ -1,3 +1,11 @@ +* 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. + * 0.4 - Provides explicit details once just recipe execution is diff --git a/justl.el b/justl.el index 0fbfc9c..4dee350 100644 --- a/justl.el +++ b/justl.el @@ -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.") @@ -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" nil nil nil))) (defun justl--get-recipe-name (str) "Compute the recipe name from the string STR." @@ -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) (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) From 9182649292839762f36168ad8312138ffc909a3b Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 20 Feb 2022 18:20:20 +0530 Subject: [PATCH 2/3] Make it compatible with older version of emacs --- justl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justl.el b/justl.el index 4dee350..d2c2309 100644 --- a/justl.el +++ b/justl.el @@ -160,7 +160,7 @@ NAME is the buffer name." DIR represents the directory where search will be carried out. The search will be performed recursively." (let ((case-fold-search t)) - (directory-files-recursively dir "justfile" nil nil nil))) + (directory-files-recursively dir "justfile"))) (defun justl--get-recipe-name (str) "Compute the recipe name from the string STR." From 144999e34d26a870faf60a9567442fab3cef9c9c Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 20 Feb 2022 18:27:25 +0530 Subject: [PATCH 3/3] Fix minor bugs --- Changelog.org | 2 ++ justl.el | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.org b/Changelog.org index f2e7aac..13112a4 100644 --- a/Changelog.org +++ b/Changelog.org @@ -5,6 +5,8 @@ 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 diff --git a/justl.el b/justl.el index d2c2309..86860d5 100644 --- a/justl.el +++ b/justl.el @@ -222,7 +222,7 @@ CMD is the just command as a list." (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 "[%s] error: %s" @@ -421,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")