rustic icon indicating copy to clipboard operation
rustic copied to clipboard

rustic-compile results in error

Open hexmode opened this issue 2 years ago • 4 comments

emacs 30.0.50 (a180f700cbf)

I have the following result after running M-x toggle-debug-on-error RET and eval-buffer in compile.el:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  -(1694087269.2730725 nil)
  (let ((elapsed (- (float-time) compilation--start-time))) (cond ((< elapsed 10) (format "%.2f s" elapsed)) ((< elapsed 60) (format "%.1f s" elapsed)) (t (format-seconds "%h:%02m:%02s" elapsed))))
  (compilation-insert-annotation " at " (substring (current-time-string) 0 19) ", duration " (let ((elapsed (- (float-time) compilation--start-time))) (cond ((< elapsed 10) (format "%.2f s" elapsed)) ((< elapsed 60) (format "%.1f s" elapsed)) (t (format-seconds "%h:%02m:%02s" elapsed)))))
  (let ((inhibit-read-only t) (status (if compilation-exit-message-function (funcall compilation-exit-message-function process-status exit-status msg) (cons msg exit-status))) (omax (point-max)) (opoint (point)) (cur-buffer (current-buffer))) (goto-char omax) (compilation-insert-annotation 10 mode-name " " (car status)) (if (and (numberp compilation-window-height) (= 0 compilation-window-height)) (message "%s" (cdr status))) (if (bolp) (forward-char -1)) (compilation-insert-annotation " at " (substring (current-time-string) 0 19) ", duration " (let ((elapsed (- (float-time) compilation--start-time))) (cond ((< elapsed 10) (format "%.2f s" elapsed)) ((< elapsed 60) (format "%.1f s" elapsed)) (t (format-seconds "%h:%02m:%02s" elapsed))))) (goto-char (point-max)) (add-text-properties omax (point) (append '(compilation-handle-exit t) nil)) (setq mode-line-process (list (let ((out-string (format ":%s [%s]" process-status (cdr status))) (msg (format "%s %s" mode-name (replace-regexp-in-string "\n?$" "" ...)))) (message "%s" msg) (propertize out-string 'help-echo msg 'face (if (> exit-status 0) 'compilation-mode-line-fail 'compilation-mode-line-exit))) compilation-mode-line-errors)) (force-mode-line-update) (if (and opoint (< opoint omax)) (goto-char opoint)) (run-hook-with-args 'compilation-finish-functions cur-buffer msg))
  compilation-handle-exit(exit 0 "finished\n")
  (save-current-buffer (set-buffer buffer) (compilation-handle-exit (process-status proc) (process-exit-status proc) msg) (delete-process proc))
  (if (null (buffer-name buffer)) (set-process-buffer proc nil) (save-current-buffer (set-buffer buffer) (compilation-handle-exit (process-status proc) (process-exit-status proc) msg) (delete-process proc)))
  (if (memq (process-status proc) '(exit signal)) (if (null (buffer-name buffer)) (set-process-buffer proc nil) (save-current-buffer (set-buffer buffer) (compilation-handle-exit (process-status proc) (process-exit-status proc) msg) (delete-process proc))) (setq compilation-in-progress (delq proc compilation-in-progress)) (compilation--update-in-progress-mode-line))
  (let ((buffer (process-buffer proc))) (save-current-buffer (set-buffer buffer) (setq default-directory (process-get proc 'workspace))) (if (memq (process-status proc) '(exit signal)) (if (null (buffer-name buffer)) (set-process-buffer proc nil) (save-current-buffer (set-buffer buffer) (compilation-handle-exit (process-status proc) (process-exit-status proc) msg) (delete-process proc))) (setq compilation-in-progress (delq proc compilation-in-progress)) (compilation--update-in-progress-mode-line)))
  rustic-compilation-sentinel(#<process rustic-compilation-process> "finished\n")

I've found that this is because the buffer-local variable compilation--start-time is set tonil by the time it gets to this point, even if I set it before running rustic-compile but haven't found why that is.

hexmode avatar Sep 07 '23 12:09 hexmode

I think I've just encountered the same error. I've only just set up rustic to start learning Rust, and I was trying out a few commands. rustic-cargo-check brought up the same error.

I've "fixed" it by adding (setq compilation--start-time (float-time)) to rustic-compilation immediately after (with-current-buffer buf. As this was after only a couple of minutes looking at the code, I'd be surprised if this is the correct place to put it, but it seemed sensible at first glance.

gajama avatar Sep 16 '23 19:09 gajama

It looks like you mean here.

If this works for me, I'll make a PR so others can review or use.

hexmode avatar Sep 18 '23 13:09 hexmode

Hi,

No - I meant here, but if it also works in the other location, it maybe makes no difference.

gajama avatar Sep 18 '23 14:09 gajama

Yeah, I realized that later and updated my comment (for anyone who wonders, my original comment was pointing to line 250). The PR uses your location.

hexmode avatar Sep 18 '23 16:09 hexmode