branch: elpa/idris-mode
commit 7ebd8e721b0b4abb0b9ff2e86738d02ca6906a99
Merge: ee551230ed 71ab6a35e3
Author: Jan de Muijnck-Hughes <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #581 from keram/highlight-partial
[semantic-highlight] Remove and rebuild overlays in file on reload only in
changed area
---
idris-commands.el | 2 --
idris-highlight-input.el | 53 ++++++++++++++++++++++++++++++------------------
2 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/idris-commands.el b/idris-commands.el
index 9b8eb7ee32..54f558b19a 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -209,8 +209,6 @@ A prefix argument forces loading but only up to the current
line."
(when (get-buffer idris-notes-buffer-name)
(with-current-buffer idris-notes-buffer-name
(let ((inhibit-read-only t)) (erase-buffer))))
- ;; Remove stale semantic highlighting
- (idris-highlight-remove-overlays (current-buffer))
;; Actually do the loading
(let* ((dir-and-fn (idris-filename-to-load))
(fn (cdr dir-and-fn))
diff --git a/idris-highlight-input.el b/idris-highlight-input.el
index 521e4b0399..ec9aaaab67 100644
--- a/idris-highlight-input.el
+++ b/idris-highlight-input.el
@@ -57,32 +57,45 @@ See Info node `(elisp)Overlay Properties' to understand how
ARGS are used."
(defun idris-highlight-input-region (buffer start-line start-col end-line
end-col highlight)
"Highlight in BUFFER using an overlay from START-LINE and START-COL to
END-LINE and END-COL and the semantic properties specified in HIGHLIGHT."
- (when idris-semantic-source-highlighting
- (save-restriction
- (widen)
- (if (or (> end-line start-line)
- (and (= end-line start-line)
- (> end-col start-col)))
- (with-current-buffer buffer
+ (if (or (> end-line start-line)
+ (and (= end-line start-line)
+ (> end-col start-col)))
+ (when idris-semantic-source-highlighting
+ (with-current-buffer buffer
+ (save-restriction
+ (widen)
(save-excursion
(goto-char (point-min))
(let* ((start-pos (+ (line-beginning-position start-line)
(idris-highlight-column start-col)))
(end-pos (+ (line-beginning-position end-line)
(idris-highlight-column end-col)))
- (highlight-overlay (make-overlay start-pos end-pos
- (get-buffer buffer))))
- (overlay-put highlight-overlay 'idris-source-highlight t)
- (idris-add-overlay-properties highlight-overlay
- (idris-semantic-properties
highlight))
- (overlay-put highlight-overlay
- 'modification-hooks
- '(idris-highlight--overlay-modification-hook)))))
- (when (eq idris-semantic-source-highlighting 'debug)
- (message "Not highlighting absurd span %s:%s-%s:%s with %s"
- start-line start-col
- end-line end-col
- highlight ))))))
+ (existing-idris-overlays-in-range (seq-filter
+ (lambda (overlay)
+ (overlay-get overlay
'idris-source-highlight))
+ (overlays-in start-pos
end-pos)))
+ (existing-idris-overlay (seq-find (lambda (overlay)
+ (and
+ (eql start-pos
(overlay-start overlay))
+ (eql end-pos
(overlay-end overlay))
+ ;; TODO: overlay
properties match
+ ))
+
existing-idris-overlays-in-range)))
+ (when (null existing-idris-overlay)
+ (dolist (old-overlay existing-idris-overlays-in-range)
+ (delete-overlay old-overlay))
+ (let ((highlight-overlay (make-overlay start-pos end-pos)))
+ (overlay-put highlight-overlay 'idris-source-highlight t)
+ (idris-add-overlay-properties highlight-overlay
+ (idris-semantic-properties
highlight))
+ (overlay-put highlight-overlay
+ 'modification-hooks
+
'(idris-highlight--overlay-modification-hook)))))))))
+ (when (eq idris-semantic-source-highlighting 'debug)
+ (message "Not highlighting absurd span %s:%s-%s:%s with %s"
+ start-line start-col
+ end-line end-col
+ highlight))))
(defun idris-highlight-source-file (hs)
(cl-loop