branch: elpa/idris-mode
commit f38456aeb063a33019bccc2d11960633c6f99320
Author: Marek L <[email protected]>
Commit: Marek L <[email protected]>
Hide notes buffer whe no notes available.
This revisits https://github.com/idris-hackers/idris-mode/pull/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.
---
idris-warnings-tree.el | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/idris-warnings-tree.el b/idris-warnings-tree.el
index 853e4c784d3..aeb886bf59a 100644
--- a/idris-warnings-tree.el
+++ b/idris-warnings-tree.el
@@ -38,18 +38,19 @@
(defvar idris-tree-printer 'idris-tree-default-printer)
(defun idris-compiler-notes-list-show (notes)
- (if (null notes)
- nil ;; See https://github.com/idris-hackers/idris-mode/pull/148 TODO:
revisit
- (with-current-buffer (get-buffer-create idris-notes-buffer-name)
- (idris-compiler-notes-mode)
- (let ((buffer-read-only nil)
- (root (idris-compiler-notes-to-tree notes)))
- (erase-buffer)
+ (with-current-buffer (get-buffer-create idris-notes-buffer-name)
+ (idris-compiler-notes-mode)
+ (let ((inhibit-read-only t)
+ (window (get-buffer-window))
+ (root (idris-compiler-notes-to-tree notes)))
+ (erase-buffer)
+ (if (null notes)
+ (when window (quit-window nil window))
(idris-tree-insert root "")
(insert "\n\n")
(message "Press q to close, return or mouse on error to navigate to
source")
- (goto-char (point-min))))
- (display-buffer idris-notes-buffer-name)))
+ (goto-char (point-min))
+ (display-buffer idris-notes-buffer-name)))))
(defun idris-tree-for-note (note)
(let* ((buttonp (> (length (nth 0 note)) 0)) ;; if empty source location