Skip to content

Commit e924176

Browse files
committed
Hide notes buffer whe no notes available.
This revisits #148 and improves the user experience when Idris does not report any errors. Previously in such case the user is left with empty buffer in some of the windows. After this change if there is nothing to display the window the notes either display previous buffer or it is closed completely if notes buffer was the only buffer displayed in it.
1 parent b45ddda commit e924176

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

idris-warnings-tree.el

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@
3838
(defvar idris-tree-printer 'idris-tree-default-printer)
3939

4040
(defun idris-compiler-notes-list-show (notes)
41-
(if (null notes)
42-
nil ;; See https://github.com/idris-hackers/idris-mode/pull/148 TODO: revisit
43-
(with-current-buffer (get-buffer-create idris-notes-buffer-name)
44-
(idris-compiler-notes-mode)
45-
(let ((buffer-read-only nil)
46-
(root (idris-compiler-notes-to-tree notes)))
47-
(erase-buffer)
41+
(with-current-buffer (get-buffer-create idris-notes-buffer-name)
42+
(idris-compiler-notes-mode)
43+
(let ((inhibit-read-only t)
44+
(window (get-buffer-window))
45+
(root (idris-compiler-notes-to-tree notes)))
46+
(erase-buffer)
47+
(if (null notes)
48+
(when window (quit-window nil window))
4849
(idris-tree-insert root "")
4950
(insert "\n\n")
5051
(message "Press q to close, return or mouse on error to navigate to source")
51-
(goto-char (point-min))))
52-
(display-buffer idris-notes-buffer-name)))
52+
(goto-char (point-min))
53+
(display-buffer idris-notes-buffer-name)))))
5354

5455
(defun idris-tree-for-note (note)
5556
(let* ((buttonp (> (length (nth 0 note)) 0)) ;; if empty source location

0 commit comments

Comments
 (0)