Skip to content

Commit

Permalink
More fixes and font lock feature
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Jun 25, 2022
1 parent 623d317 commit 01e1a1f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Don't output at the bottom of the screen if the just target
execution fails. Instead, it's displayed in the compilation mode
now.
- Use font locking to hightlight the execution status of just target.
- Update CI to test for 28.1 Emacs. Remove other old version from the
check matrix.

Expand Down
39 changes: 33 additions & 6 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
(require 'f)

(defgroup justl nil
"Justfile customization group"
"Justfile customization group."
:group 'languages
:prefix "justl-"
:link '(url-link :tag "Site" "https://github.com/psibi/justl.el")
Expand Down Expand Up @@ -166,7 +166,7 @@ NAME is the buffer name."
(defvar-local justl--justfile nil
"Buffer local variable which points to the justfile.
If this is NIL, it means that no justfiles was found. In any
If this is NIL, it means that no justfiles was found. In any
other cases, it's a known path.")

(defun justl--traverse-upwards (fn &optional path)
Expand Down Expand Up @@ -297,7 +297,11 @@ STRING is the data returned by the PROC"
(if moving (goto-char (process-mark proc)))))))

(defun justl-compilation-setup-buffer (buf dir mode &optional no-mode-line)
"Prepare BUF for compilation process."
"Setup the compilation buffer for just-compile-mode.
Prepare BUF for compilation process. DIR is set as default
directory and MODE is name of the Emacs mode. NO-MODE-LINE
controls if we are going to display the process status on mode line."
(let ((inhibit-read-only t))
(with-current-buffer buf
(erase-buffer)
Expand Down Expand Up @@ -359,18 +363,41 @@ ARGS is a plist that affects how the process is run.
"Keymap for justl compilation log buffers.")

(defun justl-recompile ()
"Execute the same just target again."
(interactive)
(justl--make-process justl--compile-command (list :buffer justl--output-process-buffer
:process "just"
:mode 'justl-compile-mode)))
;;; todo: fix just hardcode above

(defconst justl-mode-compilation-finished "^Target execution \\(finished\\).*")

(defvar sibi-test
'(justl-mode-compilation-finished (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
()) )

(defvar justl-mode-font-lock-keywords
'(
("^Target execution \\(finished\\).*"
(0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
(1 compilation-info-face))
("^Target execution \\(exited abnormally\\)\\(?:.*with code \\([0-9]+\\)\\)?.*"
(0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
(1 compilation-error-face)
(2 compilation-error-face nil t)))
"Things to highlight in justl-compile mode.")

(define-compilation-mode justl-compile-mode "just-compile"
"Just compilation mode.
Error matching regexes from compile.el are removed."
(setq-local compilation-error-regexp-alist-alist nil)
(setq-local compilation-error-regexp-alist nil))
(setq-local compilation-error-regexp-alist nil)
(setq font-lock-defaults '(justl-mode-font-lock-keywords t))
(setq-local compilation-num-errors-found 0)
(setq-local compilation-num-warnings-found 0)
(setq-local compilation-num-infos-found 0)
(setq-local overlay-arrow-string "")
(setq next-error-overlay-arrow-position nil))

(defun justl--exec (process-name args)
"Utility function to run commands in the proper context and namespace.
Expand Down Expand Up @@ -446,7 +473,7 @@ and output of process."
(format "--justfile=%s" justl--justfile))

(defun justl--justfile-from-arg (arg)
"Return justfile filepatch from ARG"
"Return justfile filepath from ARG."
(car (cdr (s-split "--justfile=" arg))))

(defun justl--get-recipies-with-desc (justfile)
Expand Down

0 comments on commit 01e1a1f

Please sign in to comment.