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

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

[elpa] externals/auto-overlays 86c25df 14/93: Removed auto-overlay-funct


From: Stefan Monnier
Subject: [elpa] externals/auto-overlays 86c25df 14/93: Removed auto-overlay-functions variable, and implemented new regexp class interface
Date: Mon, 14 Dec 2020 13:00:28 -0500 (EST)

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

    Removed auto-overlay-functions variable, and implemented new regexp class 
interface
    based on symbol properties.
---
 auto-overlay-line.el  | 14 +++++-----
 auto-overlay-self.el  | 12 +++++----
 auto-overlay-stack.el | 12 +++++----
 auto-overlay-word.el  | 14 +++++-----
 auto-overlays.el      | 75 +++++++++++++++++++++++++++------------------------
 5 files changed, 70 insertions(+), 57 deletions(-)

diff --git a/auto-overlay-line.el b/auto-overlay-line.el
index 130a6c6..c2d8615 100644
--- a/auto-overlay-line.el
+++ b/auto-overlay-line.el
@@ -5,7 +5,7 @@
 ;; Copyright (C) 2005 2006 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.3.1
+;; Version: 0.3.2
 ;; Keywords: automatic, overlays, line
 ;; URL: http://www.dr-qubit.org/emacs.php
 
@@ -30,6 +30,9 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.3.2
+;; * removed `auto-overlay-functions' and changed to use new interface
+;;
 ;; Version 0.3.1
 ;; * updated to reflect changes in `auto-overlays.el'
 ;;
@@ -57,11 +60,10 @@
 (provide 'auto-overlay-line)
 
 
-;; register line overlay parsing and suicide funtions
-(assq-delete-all 'line auto-overlay-functions)
-(push (list 'line 'auto-o-parse-line-match
-           (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
-      auto-overlay-functions)
+;; set line overlay parsing and suicide funtions
+(put 'line 'auto-overlay-parse-function 'auto-o-parse-line-match)
+(put 'line 'auto-overlay-suicide-function
+     (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
 
 
 
diff --git a/auto-overlay-self.el b/auto-overlay-self.el
index 20429ef..fde62ba 100644
--- a/auto-overlay-self.el
+++ b/auto-overlay-self.el
@@ -5,7 +5,7 @@
 ;; Copyright (C) 2005 2006 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.2.4
+;; Version: 0.2.5
 ;; Keywords: automatic, overlays, self
 ;; URL: http://www.dr-qubit.org/emacs.php
 
@@ -29,6 +29,9 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.2.5
+;; * removed `auto-overlay-functions' and changed to use new interface
+;;
 ;; Version 0.2.4
 ;; * fixed(?) bug in auto-o-self-list that caused it to
 ;;   sometimes miss out the parent overlay itself from the list
@@ -60,10 +63,9 @@
 
 (defvar auto-o-pending-self-cascade nil)
 
-;; register self overlay parsing, suicide, initialisation and clear functions
-(assq-delete-all 'self auto-overlay-functions)
-(push '(self auto-o-parse-self-match auto-o-self-suicide)
-      auto-overlay-functions)
+;; set self overlay parsing and suicide functions
+(put 'self 'auto-overlay-parse-function 'auto-o-parse-self-match)
+(put 'self 'auto-overlay-suicide-function 'auto-o-self-suicide)
 
 ;; add initialisation and clear functions to hooks
 (add-hook 'auto-overlay-load-hook 'auto-o-self-load)
diff --git a/auto-overlay-stack.el b/auto-overlay-stack.el
index c21880e..75f0eb9 100644
--- a/auto-overlay-stack.el
+++ b/auto-overlay-stack.el
@@ -5,7 +5,7 @@
 ;; Copyright (C) 2005 2006 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.3
+;; Version: 0.1.4
 ;; Keywords: automatic, overlays, stack
 ;; URL: http://www.dr-qubit.org/emacs.php
 
@@ -30,6 +30,9 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.1.4
+;; * removed `auto-overlay-functions' and changed to use new interface
+;;
 ;; Version 0.1.3
 ;; * updated to reflect changes in `auto-overlays.el'
 ;;
@@ -51,10 +54,9 @@
 (provide 'auto-overlay-stack)
 
 
-;; register stack overlay parsing and suicide functions
-(assq-delete-all 'stack auto-overlay-functions)
-(push '(stack auto-o-parse-stack-match auto-o-stack-suicide)
-      auto-overlay-functions)
+;; set stack overlay parsing and suicide functions
+(put 'stack 'auto-overlay-parse-function 'auto-o-parse-stack-match)
+(put 'stack 'auto-overlay-suicide-function 'auto-o-stack-suicide)
 
 
 
diff --git a/auto-overlay-word.el b/auto-overlay-word.el
index 9c9b59b..f30b233 100644
--- a/auto-overlay-word.el
+++ b/auto-overlay-word.el
@@ -5,7 +5,7 @@
 ;; Copyright (C) 2005 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.1
+;; Version: 0.1.2
 ;; Keywords: automatic, overlays, word
 ;; URL: http://www.dr-qubit.org/emacs.php
 
@@ -30,6 +30,9 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.1.2
+;; * removed `auto-overlay-functions' and changed to use new interface
+;;
 ;; Version 0.1.1
 ;; * updated to reflect changes in `auto-overlays.el'
 ;;
@@ -45,11 +48,10 @@
 (provide 'auto-overlay-word)
 
 
-;; register word overlay parsing and suicide functions
-(assq-delete-all 'word auto-overlay-functions)
-(push (list 'word 'auto-o-parse-word-match
-           (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
-      auto-overlay-functions)
+;; set word overlay parsing and suicide functions
+(put 'word 'auto-overlay-parse-function 'auto-o-parse-word-match)
+(put 'word 'auto-overlay-suicide-function
+     (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
 
 
 
diff --git a/auto-overlays.el b/auto-overlays.el
index f0483f9..3e67d86 100644
--- a/auto-overlays.el
+++ b/auto-overlays.el
@@ -31,10 +31,12 @@
 ;;; Change Log:
 ;;
 ;; Version 0.6.2
-;; * fixed(?) bugs in `auto-o-update-exclusive' that caused it to fail if
-;;   called during a suicide when parentless overlays can exist, and that
-;;   caused it to infinitely recurse if an exclusive overlay partially
-;;   overlapped with its match overlay
+;; * fixed bugs in `auto-o-update-exclusive' that caused it to fail if called
+;;   during a suicide when parentless overlays can exist, and that caused it
+;;   to infinitely recurse if an exclusive overlay partially overlapped with
+;;   its match overlay
+;; * removed `auto-overlay-functions' variable, and implemented new interface
+;;   based on symbol properties
 ;;
 ;; Version 0.6.1
 ;; * fixed minor bug in `auto-overlay-save-overlays'
@@ -83,7 +85,6 @@
 ;;; Code:
 
 
-(defvar auto-overlay-functions nil)
 (defvar auto-overlay-regexps nil)
 (make-variable-buffer-local 'auto-overlay-regexps)
 (defvar auto-overlay-load-hook nil)
@@ -159,8 +160,8 @@
 
 
 (defmacro auto-o-entry-regexp-group (set-id entry-id &optional subentry-id)
-  ;; Return regexp group corresponsing to SET-ID, ENTRY-ID and SUBENTRY-ID, or 
0 if none
-  ;; is specified.
+  ;; Return regexp group corresponsing to SET-ID, ENTRY-ID and SUBENTRY-ID, or
+  ;; 0 if none is specified.
   `(let ((regexp (nth 1 (auto-o-entry ,set-id ,entry-id ,subentry-id))))
      (cond
       ((atom regexp) 0)
@@ -175,9 +176,10 @@
                            (overlay-get ,o-match 'subentry-id)))
 
 
-(defmacro auto-o-entry-regexp-group-nth (n set-id entry-id &optional 
subentry-id)
-  ;; Return Nth regexp group entry corresponsing to SET-ID, ENTRY-ID and 
SUBENTRY-ID, or
-  ;; 0 if there is no Nth entry.
+(defmacro auto-o-entry-regexp-group-nth (n set-id entry-id
+                                          &optional subentry-id)
+  ;; Return Nth regexp group entry corresponsing to SET-ID, ENTRY-ID and
+  ;; SUBENTRY-ID, or 0 if there is no Nth entry.
   `(let ((regexp (nth 1 (auto-o-entry ,set-id ,entry-id ,subentry-id))))
      (cond
       ((atom regexp) 0)
@@ -195,7 +197,8 @@
 
 
 (defmacro auto-o-entry-props (set-id entry-id &optional subentry-id)
-  ;; Return properties of regexp corresponding to SET-ID, ENTRY-ID and 
SUBENTRY-ID.
+  ;; Return properties of regexp corresponding to SET-ID, ENTRY-ID and
+  ;; SUBENTRY-ID.
   `(if (auto-o-entry-compound-class-p ,set-id ,entry-id)
        (nthcdr 2 (auto-o-entry ,set-id ,entry-id ,subentry-id))
      (nthcdr 2 (auto-o-entry ,set-id ,entry-id))))
@@ -209,8 +212,8 @@
 
 
 (defmacro auto-o-entry-edge (set-id entry-id subentry-id)
-  ;; Return edge ('start or 'end) of regexp with SET-ID, ENTRY-ID and 
SUBENTRY-ID
-  ;; (assumes that entry has a compound class).
+  ;; Return edge ('start or 'end) of regexp with SET-ID, ENTRY-ID and
+  ;; SUBENTRY-ID (assumes that entry has a compound class).
   `(car (auto-o-entry ,set-id ,entry-id ,subentry-id)))
 
 
@@ -224,17 +227,17 @@
 
 (defmacro auto-o-parse-function (o-match)
   ;; Return appropriate parse function for match overlay O-MATCH.
-  `(nth 1 (assq (auto-o-class ,o-match) auto-overlay-functions)))
+  `(get (auto-o-class ,o-match) 'auto-overlay-parse-function))
 
 
 (defmacro auto-o-suicide-function (o-match)
   ;; Return appropriate suicide function for match overlay O-MATCH.
-  `(nth 2 (assq (auto-o-class ,o-match) auto-overlay-functions)))
+  `(get (auto-o-class ,o-match) 'auto-overlay-suicide-function))
 
 
 (defmacro auto-o-match-function (o-match)
-  `(let ((funcs (assq (auto-o-class ,o-match) auto-overlay-functions)))
-     (when (>= (length funcs) 4) (nth 3 funcs))))
+  ;; Return match function for match overlay O-MATCH, if any.
+  `(get (auto-o-class ,o-match) 'auto-overlay-match-function))
 
 
 (defmacro auto-o-edge-matched-p (overlay edge)
@@ -405,11 +408,10 @@ supplied, delete that entire set."
     ;; call suicide function for corresponding overlays
     (mapc (lambda (o) (auto-o-suicide o 'force))
          (auto-overlays-in (point-min) (point-max)
-                           (list
-                            '(identity auto-overlay-match)
-                            (list 'eq 'set-id set-id)
-                            (list 'eq 'entry-id entry-id)
-                            (list 'eq 'subentry-id subentry-id))))
+                           `((identity auto-overlay-match)
+                             (eq set-id ,set-id)
+                             (eq entry-id ,entry-id)
+                             (eq subentry-id ,subentry-id))))
     ;; delete regexp entry
     (assq-delete-all subentry-id
                     (cdr (assq entry-id
@@ -421,10 +423,9 @@ supplied, delete that entire set."
     ;; call suicide function for corresponding overlays
     (mapc (lambda (o) (auto-o-suicide o 'force))
          (auto-overlays-in (point-min) (point-max)
-                           (list
-                            (list 'eq 'set-id set-id)
-                            (list 'eq 'entry-id entry-id)
-                            (list 'eq 'subentry-id subentry-id))))
+                           `((eq set-id ,set-id)
+                             (eq entry-id ,entry-id)
+                             (eq subentry-id ,subentry-id))))
     ;; delete regexp entry
     (assq-delete-all entry-id (cddr (assq set-id auto-overlay-regexps))))
    
@@ -766,13 +767,16 @@ The FILE should be generated by 
`auto-overlay-save-overlays'."
                  
                  ;; extract regexp properties from current entry
                  (setq regexp (auto-o-entry-regexp set-id entry-id 
subentry-id))
-                 (setq group (auto-o-entry-regexp-group set-id entry-id 
subentry-id))
+                 (setq group (auto-o-entry-regexp-group
+                              set-id entry-id subentry-id))
                  (setq priority
                        (cdr (assq 'priority
-                                  (auto-o-entry-props set-id entry-id 
subentry-id))))
+                                  (auto-o-entry-props
+                                   set-id entry-id subentry-id))))
                  
                  
-                 ;; look for matches in current line, ensuring case *is* 
significant
+                 ;; look for matches in current line, ensuring case *is*
+                 ;; significant
                  (forward-line 0)
                  (while (let ((case-fold-search nil))
                           (re-search-forward regexp (line-end-position) t))
@@ -854,8 +858,7 @@ The FILE should be generated by 
`auto-overlay-save-overlays'."
 
 (defun auto-o-suicide (o-self &optional force)
   ;; This function is assigned to all match overlay modification hooks, and
-  ;; calls the appropriate suicide function for match overlay O-SELF as
-  ;; specified in `auto-overlay-functions'.
+  ;; calls the appropriate suicide function for match overlay O-SELF.
   ;; If FORCE is non-nil, O-SELF is deleted irrespective of whether its
   ;; overlay still matches.
   
@@ -1172,10 +1175,12 @@ properties)."
 
 
 (defun auto-o-delete-overlay (overlay &optional no-parse protect-match)
-  ;; Delete OVERLAY from buffer and `auto-overlay-list'. If PROTECT-MATCH is
-  ;; non-nil, don't modify any match overlays associated with OVERLAY
-  ;; (i.e. leave their 'parent properties alone). If NO-PARSE is non-nil,
-  ;; block re-parsing due to exclusive overlay changes.
+  "Delete OVERLAY from buffer.
+
+If PROTECT-MATCH is non-nil, don't modify any match overlays
+associated with OVERLAY (i.e. leave their 'parent properties
+alone). If NO-PARSE is non-nil, block re-parsing due to exclusive
+overlay changes."
   
   (let ((start (overlay-start overlay))
        (end (overlay-end overlay))



reply via email to

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