emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auto-overlays f268d75 42/93: Fixed bug in auto-overlay-


From: Stefan Monnier
Subject: [elpa] externals/auto-overlays f268d75 42/93: Fixed bug in auto-overlay-unload-definition.
Date: Mon, 14 Dec 2020 13:00:34 -0500 (EST)

branch: externals/auto-overlays
commit f268d75c3a01021bcd9d0f3ceb8869da108eb4bb
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>

    Fixed bug in auto-overlay-unload-definition.
---
 auto-overlays.el | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/auto-overlays.el b/auto-overlays.el
index 4e7204d..6da2969 100644
--- a/auto-overlays.el
+++ b/auto-overlays.el
@@ -5,7 +5,7 @@
 ;; Copyright (C) 2005-2008 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.9.2
+;; Version: 0.9.3
 ;; Keywords: automatic, overlays
 ;; URL: http://www.dr-qubit.org/emacs.php
 
@@ -30,7 +30,10 @@
 
 ;;; Change Log:
 ;;
-;; Version 0.9,2
+;; Version 0.9.3
+;; * fixed bug in `auto-overlay-unload-definition'
+;;
+;; Version 0.9.2
 ;; * allow SAVE-FILE argument of `auto-overlay-start/stop' to specify a
 ;;   location to save to
 ;; * made corresponding modifications to `auto-overlay-save/load-overlays'
@@ -188,6 +191,11 @@
   `(cddr (assq ,set-id auto-overlay-regexps)))
 
 
+;; (defmacro auto-o-set-regexps (set-id regexps)
+;;   ;; Set the list of regexp definitions for regexp set SET-ID.
+;;   `(setcdr (cdr (assq ,set-id auto-overlay-regexps)) ,regexps))
+
+
 
 
 ;; (defmacro auto-o-set-buffer-list (set-id list)
@@ -687,10 +695,13 @@ from the current buffer. Returns the deleted definition."
                                `((eq set-id ,set-id)
                                  (eq definition-id ,definition-id))))))
     ;; delete definition
-    (let* ((defs (auto-o-get-regexps set-id))
-          (olddef (assq definition-id defs))
+    (let ((olddef (assq definition-id (auto-o-get-regexps set-id)))
           def-id class regexps regexp edge regexp-id props)
-      (assq-delete-all definition-id defs)
+      ;; safe to delete by side effect here because definition is guaranteed
+      ;; not to be the first element of the list (the first two elements of a
+      ;; regexp set are always the set-id and the buffer list)
+      (assq-delete-all definition-id (assq set-id auto-overlay-regexps))
+
 
       ;; massage deleted definition into form suitable for
       ;; `auto-overlay-load-definition'
@@ -733,6 +744,9 @@ Returns the deleted regexp."
     (let* ((def (cdr (assq definition-id (auto-o-get-regexps set-id))))
           (oldregexp (assq regexp-id def))
           id edge regexp props)
+      ;; can safely delete by side effect here because the regexp definition
+      ;; is guaranteed not to be the first element of the list (the first two
+      ;; elements of a definition are always the :id and class)
       (assq-delete-all regexp-id def)
 
       ;; massage deleted definition into form suitable for
@@ -1229,6 +1243,12 @@ overlays were saved."
                    (forward-line 0)
                    (while (let ((case-fold-search nil))
                             (re-search-forward regexp (line-end-position) t))
+                     ;; sanity check regexp definition against match
+                     (when (or (null (match-beginning group))
+                               (null (match-end group)))
+                       (error "Match for regexp \"%s\" has no group %d"
+                              regexp group))
+
                      (cond
                       ;; ignore match if it already has a match overlay
                       ((auto-o-matched-p (match-beginning 0) (match-end 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]