bug fix: show source function in minor errors

This commit is contained in:
Miranda Marquez 2024-10-20 08:57:23 -08:00
parent af1b8e5d57
commit fbe13a46b1

View File

@ -133,7 +133,8 @@ If STACKDEPTH is non-nil and nonzero, return a position that far down."
(defun notibox--hide (frame) (defun notibox--hide (frame)
"Stop showing FRAME." "Stop showing FRAME."
(posframe-hide (window-buffer (frame-selected-window frame)))) (if (frame-live-p frame)
(posframe-hide (window-buffer (frame-selected-window frame)))))
(defun notibox-delete (frame) (defun notibox-delete (frame)
"Delete the notibox FRAME. "Delete the notibox FRAME.
@ -157,32 +158,44 @@ If the source is not obvious, use `current-buffer'."
contents contents
(splooted (split-string msg ": "))) (splooted (split-string msg ": ")))
(pcase (length splooted) (pcase (length splooted)
(2 (progn ;; problem: the echo area shows only cdr, whereas messages buffer shows the source fn we want..
(setq source (car splooted))
(setq contents (cadr splooted))))
(1 (progn (1 (progn
(setq source (setq source
(format "%s" (format "%s"
(current-buffer))) (current-buffer)))
(setq contents (setq contents
(car splooted)))) (car splooted))))
(2 (progn
(setq source (car splooted))
(setq contents (cadr splooted))))
) )
;; (message "[debug] message: %s" msg)
(cons source contents))) (cons source contents)))
;; (split-string "evil-forward-character: End of line" ": ") ;; (split-string "evil-forward-character: End of line" ": ")
;; (length '("evil-forward-character" "end of line"))
;; (split-string "this is a valid message" ": ") ;; (split-string "this is a valid message" ": ")
;; (notibox--parse-message "evil-forward-char: End of line") ;; (notibox--parse-message "evil-forward-char: End of line")
;; (notibox--parse-message "this is a badly formed message") ;; (notibox--parse-message "this is a badly formed message")
(defun buflast (buffer)
"Return the last line of BUFFER as a string, without linebreaks."
(with-current-buffer buffer
(save-excursion
(goto-char (- (point-max) 1)) ; there is a \n at the end of every buffer
(buffer-substring-no-properties (point-at-bol) (point-max)))))
;; (buflast (get-buffer "*Messages*"))
(defun notibox--tail-echoarea () (defun notibox--tail-echoarea ()
"Show `current-message' in the notibox. If that does not exist, probably hide it." "Show `current-message' in the notibox. If that does not exist, probably hide it."
(if (current-message) (if (current-message)
(let* ((notibox-border-color "#0faa0f") (let* ((notibox-border-color "#0faa0f") ; hacky, can we set it elsewhere?
(parsed-msg (parsed-msg
(notibox--parse-message (current-message))) (notibox--parse-message
;; (current-message)
(buflast (get-buffer "*Messages*")) ; workaround for abbreviated stuff
))
(title (car parsed-msg)) (title (car parsed-msg))
(contents (cdr parsed-msg))) (contents (cdr parsed-msg)))
(notibox-alert `( (notibox-alert `( :title ,title
:title ,title
:message ,contents :message ,contents
:depth 0))) :depth 0)))
(if notibox-current-posframes (if notibox-current-posframes