[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/idris-mode 0379683173 1/3: Simplify `idris-warning-overlay
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/idris-mode 0379683173 1/3: Simplify `idris-warning-overlay` by |
Date: |
Wed, 21 Dec 2022 05:59:35 -0500 (EST) |
branch: elpa/idris-mode
commit 037968317300f4702a360559265562371bcc1bc8
Author: Marek L <nospam.keram@gmail.com>
Commit: Marek L <nospam.keram@gmail.com>
Simplify `idris-warning-overlay` by
- inline idris-get-line-region and remove cl-multiple-value-bind
- remove extra goto-char
- flatten body
---
idris-warnings.el | 44 ++++++++++++++++++--------------------------
1 file changed, 18 insertions(+), 26 deletions(-)
diff --git a/idris-warnings.el b/idris-warnings.el
index 1d98971e92..cc9ae10ce0 100644
--- a/idris-warnings.el
+++ b/idris-warnings.el
@@ -60,18 +60,12 @@
(setq idris-warnings '())
(delq (current-buffer) idris-warnings-buffers))
-(defun idris-get-line-region (line)
- (goto-char (point-min))
- (cl-values
- (line-beginning-position line)
- (line-end-position line)))
-
(defun idris-warning-overlay-p (overlay)
(overlay-get overlay 'idris-warning))
-(defun idris-warning-overlay-at-point ()
- "Return the overlay for a note starting at point, otherwise nil."
- (cl-find (point) (cl-remove-if-not 'idris-warning-overlay-p (overlays-at
(point)))
+(defun idris-warning-overlay-at-point (point)
+ "Return the overlay for a note starting at POINT, otherwise nil."
+ (cl-find point (cl-remove-if-not 'idris-warning-overlay-p (overlays-at
point))
:key 'overlay-start))
(defun idris-warning-overlay (warning)
@@ -103,23 +97,21 @@ is mostly the same as (startline startcolumn)"
(save-restriction
(widen) ;; Show errors at the proper location in narrowed buffers
(goto-char (point-min))
- (cl-multiple-value-bind (startp endp) (idris-get-line-region
startline)
- (goto-char startp)
- (let ((start (+ startp startcol))
- (end (if (and (= startline endline) (= startcol endcol))
- ;; this is a hack to have warnings reported
which point to empty lines
- (if (= startp endp)
- (progn (insert " ")
- (1+ endp))
- endp)
- (+ (save-excursion
- (goto-char (point-min))
- (line-beginning-position endline))
- endcol)))
- (overlay (idris-warning-overlay-at-point)))
- (if overlay
- (idris-warning-merge-overlays overlay message)
- (idris-warning-create-overlay start end message)))))))))))
+ (let* ((startp (line-beginning-position startline))
+ (endp (line-end-position startline))
+ (start (+ startp startcol))
+ (end (if (and (= startline endline) (= startcol endcol))
+ ;; this is a hack to have warnings reported
which point to empty lines
+ (if (= startp endp)
+ (progn (goto-char startp)
+ (insert " ")
+ (1+ endp))
+ endp)
+ (+ (line-beginning-position endline) endcol)))
+ (overlay (idris-warning-overlay-at-point startp)))
+ (if overlay
+ (idris-warning-merge-overlays overlay message)
+ (idris-warning-create-overlay start end message))))))))))
(defun idris-warning-merge-overlays (overlay message)
(overlay-put overlay 'help-echo