branch: elpa/idris-mode
commit 06158d7adc645827a050dfbebd6f1af2137686aa
Merge: d32b2396a8 ffe4bed686
Author: Jan de Muijnck-Hughes <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #664 from keram/minor-code-improvements
    
    Minor code improvements
---
 idris-commands.el  | 19 +++++++------------
 idris-events.el    |  8 +++-----
 idris-ipkg-mode.el |  2 +-
 idris-warnings.el  |  3 +--
 inferior-idris.el  | 12 ++++++------
 5 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/idris-commands.el b/idris-commands.el
index 417c827880..e20d74e88e 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -232,10 +232,9 @@ A prefix argument SET-LINE forces loading but only up to 
the current line."
 (defun idris-view-compiler-log ()
   "Jump to the log buffer, if it is open."
   (interactive)
-  (let ((buffer (get-buffer idris-log-buffer-name)))
-    (if buffer
-        (pop-to-buffer buffer)
-      (message "No Idris compiler log is currently open"))))
+  (if-let* ((buffer (get-buffer idris-log-buffer-name)))
+      (pop-to-buffer buffer)
+    (message "No Idris compiler log is currently open")))
 
 (defun idris-next-error ()
   "Jump to the next error overlay in the buffer."
@@ -737,7 +736,7 @@ If no indentation is found, return the empty string."
 (defun idris-replace-hole-with (expr)
   "Replace the hole under the cursor by some EXPR."
   (save-excursion
-    (let ((start (progn (search-backward "?") (point)))
+    (let ((start (search-backward "?"))
           (end (progn (forward-char) (search-forward-regexp "[^a-zA-Z0-9_']")
                       (backward-char) (point))))
       (delete-region start end))
@@ -915,8 +914,7 @@ type-correct, so loading will fail."
 (defun idris-list-compiler-notes ()
   "Show the compiler notes in tree view."
   (interactive)
-  (with-temp-message "Preparing compiler note tree..."
-    (idris-compiler-notes-list-show (reverse idris-raw-warnings))))
+  (idris-compiler-notes-list-show (reverse idris-raw-warnings)))
 
 (defun idris-kill-buffers ()
   ;; not killing :events since it it tremendously useful for debuging
@@ -1210,11 +1208,8 @@ of the term to replace."
   ;; The timer is necessary because of the async nature of starting the prover
   (run-with-timer 0.25 nil
                   #'(lambda ()
-                      (let ((buffer (get-buffer 
idris-prover-script-buffer-name)))
-                        (when buffer
-                          (let ((window (get-buffer-window buffer)))
-                            (when window
-                              (select-window window))))))))
+                      (if-let* ((window (get-buffer-window 
idris-prover-script-buffer-name)))
+                          (select-window window)))))
 
 (defun idris-fill-paragraph (justify)
   "In literate Idris files, allow filling non-code paragraphs."
diff --git a/idris-events.el b/idris-events.el
index cd4e319ec1..f6040c2ef9 100644
--- a/idris-events.el
+++ b/idris-events.el
@@ -51,12 +51,10 @@ The event is only logged if `idris-log-events' is non-nil."
   (when idris-log-events
     (with-current-buffer (idris-events-buffer)
       (goto-char (point-max))
-      (let ((buffer-read-only nil)
-            (time (format-time-string "%H:%M:%S")))
+      (let ((buffer-read-only nil))
         (save-excursion
-          (if sending
-              (insert (concat time " -> "))
-            (insert (concat time " <- ")))
+          (insert (concat (format-time-string "%H:%M:%S")
+                          (if sending " -> " " <- ")))
           (idris-pprint-event event (current-buffer))))
       (goto-char (point-max)))))
 
diff --git a/idris-ipkg-mode.el b/idris-ipkg-mode.el
index 851b35f0ca..a3d5f6fe58 100644
--- a/idris-ipkg-mode.el
+++ b/idris-ipkg-mode.el
@@ -141,7 +141,7 @@
   "Make all modules with existing files clickable, where clicking opens them."
   (interactive)
   (idris-clear-file-link-overlays 'idris-ipkg-mode)
-  (let ((src-dir (idris-ipkg-buffer-src-dir (file-name-directory 
(buffer-file-name)))))
+  (let ((src-dir (idris-ipkg-buffer-src-dir (buffer-file-name))))
     ;; Make the sourcedir clickable
     (save-excursion
       (goto-char (point-min))
diff --git a/idris-warnings.el b/idris-warnings.el
index d5d709d52c..45143af57e 100644
--- a/idris-warnings.el
+++ b/idris-warnings.el
@@ -125,8 +125,7 @@ is mostly the same as (startline startcolumn)"
     (overlay-put overlay 'face 'idris-warning-face)
     (overlay-put overlay 'mouse-face 'highlight)
     (push overlay idris-warnings)
-    (unless (memq (current-buffer) idris-warnings-buffers)
-      (push (current-buffer) idris-warnings-buffers))
+    (cl-pushnew (current-buffer) idris-warnings-buffers)
     overlay))
 
 (provide 'idris-warnings)
diff --git a/inferior-idris.el b/inferior-idris.el
index adf3341112..efae6b1bf5 100644
--- a/inferior-idris.el
+++ b/inferior-idris.el
@@ -112,7 +112,7 @@ This is maintained to restart Idris when the arguments 
change.")
     (delete-process idris-process)
     (setq idris-process nil)))
 
-(defvar idris-process-port-output-regexp (rx (? (group (+ any (not num)))) 
(group (+ (any num))))
+(defvar idris-process-port-output-regexp (rx (? (group (+ anychar (not num)))) 
(group (+ (any num))))
   "Regexp used to match the port of an Idris process.")
 (defvar idris-process-exact-port-output-regexp (rx bol (group (+ (any num))) 
eol)
   "Regexp to match port number.")
@@ -120,11 +120,11 @@ This is maintained to restart Idris when the arguments 
change.")
   "Port number matcher.")
 
 (defvar idris-process-port-with-warning-output-regexp
-  (rx (? (group (+ any (not num)))) (group (** 3 4 (any num)))))
-;;      ^^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^
-;;           ^                          ^
-;;           |                          |
-;;           |                          +---- port number
+  (rx (? (group (+ anychar (not num)))) (group (** 3 4 (any num)))))
+;;        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^
+;;           ^                              ^
+;;           |                              |
+;;           |                              +---- port number
 ;;           +------------------------------- warning message
 (defvar idris-warning-matcher 1
   "Warning from Idris.")

Reply via email to