[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auto-overlays 2d0dbcf 04/93: Version 0.9.1 of the predi
From: |
Stefan Monnier |
Subject: |
[elpa] externals/auto-overlays 2d0dbcf 04/93: Version 0.9.1 of the predictive completion package. |
Date: |
Mon, 14 Dec 2020 13:00:26 -0500 (EST) |
branch: externals/auto-overlays
commit 2d0dbcf9845b5869f2bd9d449a97fa889bd5839d
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <tsc25@cantab.net>
Version 0.9.1 of the predictive completion package.
---
auto-overlays.el | 260 ++++++++++++++++++++++++++++---------------------------
1 file changed, 134 insertions(+), 126 deletions(-)
diff --git a/auto-overlays.el b/auto-overlays.el
index b8da00b..b5a0fa5 100644
--- a/auto-overlays.el
+++ b/auto-overlays.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2005 2006 Toby Cubitt
;; Author: Toby Cubitt
-;; Version: 0.4
+;; Version: 0.4.1
;; Keywords: automatic, overlays
;; This file is part of the Emacs Automatic Overlays package.
@@ -27,6 +27,9 @@
;;; Change Log:
;;
+;; Version 0.4.1
+;; * moved defmacros before their first use so byte-compilation works
+;;
;; Version 0.4
;; * (a lot of) bug fixes
;;
@@ -71,6 +74,136 @@
+;;;========================================================
+;;; Code-tidying macros
+
+(defmacro auto-o-entry (set type &optional sequence)
+ ;; Return regexp entry corresponding to SET, TYPE and SEQUENCE.
+ `(if ,sequence
+ (nth (1+ ,sequence) (nth ,type (nth ,set auto-overlay-regexps)))
+ (nth ,type (nth ,set auto-overlay-regexps))))
+
+
+(defmacro auto-o-class (o-match)
+ ;; Return class of match overlay O-MATCH.
+ `(car (nth (overlay-get ,o-match 'type)
+ (nth (overlay-get ,o-match 'set) auto-overlay-regexps))))
+
+
+(defmacro auto-o-seq-regexp (set type &optional sequence)
+ ;; Return regexp corresponsing to SET, TYPE and SEQUENCE.
+ `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
+ (if (atom regexp) regexp (car regexp))))
+
+
+(defmacro auto-o-regexp (o-match)
+ ;; Return match overlay O-MATCH's regexp.
+ `(auto-o-seq-regexp (overlay-get ,o-match 'set)
+ (overlay-get ,o-match 'type)
+ (overlay-get ,o-match 'sequence)))
+
+
+(defmacro auto-o-seq-regexp-group (set type &optional sequence)
+ ;; Return regexp group corresponsing to SET, TYPE and SEQUENCE, or 0 if none
+ ;; is specified.
+ `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
+ (cond
+ ((atom regexp) 0)
+ ((atom (cdr regexp)) (cdr regexp))
+ (t (cadr regexp)))))
+
+
+(defmacro auto-o-regexp-group (o-match)
+ ;; Return match overlay O-MATCH's regexp group.
+ `(auto-o-seq-regexp-group (overlay-get ,o-match 'set)
+ (overlay-get ,o-match 'type)
+ (overlay-get ,o-match 'sequence)))
+
+
+(defmacro auto-o-seq-regexp-group-nth (n set type &optional sequence)
+ ;; Return Nth regexp group entry corresponsing to SET, TYPE and SEQUENCE, or
+ ;; 0 if there is no Nth entry.
+ `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
+ (cond
+ ((atom regexp) 0)
+ ((> (1+ ,n) (length (cdr regexp))) 0)
+ (t (nth ,n (cdr regexp))))))
+
+
+(defmacro auto-o-regexp-group-nth (n o-match)
+ ;; Return match overlay O-MATCH's Nth regexp group entry, or 0 if there is
+ ;; no Nth entry.
+ `(auto-o-seq-regexp-group-nth ,n
+ (overlay-get ,o-match 'set)
+ (overlay-get ,o-match 'type)
+ (overlay-get ,o-match 'sequence)))
+
+
+(defmacro auto-o-type-props (set type &optional sequence)
+ ;; Return properties of regexp with SET, TYPE and SEQUENCE
+ `(if (auto-o-type-is-list-p ,set ,type)
+ (nthcdr 2 (auto-o-entry ,set ,type ,sequence))
+ (nthcdr 2 (auto-o-entry ,set ,type))))
+
+
+(defmacro auto-o-props (o-match)
+ ;; Return properties associated with match overlay O-MATCH.
+ `(auto-o-type-props (overlay-get ,o-match 'set)
+ (overlay-get ,o-match 'type)
+ (overlay-get ,o-match 'sequence)))
+
+
+(defmacro auto-o-seq-edge (set type sequence)
+ ;; Return edge ('start or 'end) of regexp with SET, TYPE and SEQEUNCE
+ ;; (assumes that TYPE contains a list of regexps)
+ `(car (auto-o-entry ,set ,type ,sequence)))
+
+
+(defmacro auto-o-edge (o-match)
+ ;; Return edge ('start or 'end) of match overlay O-MATCH (assumes that
+ ;; O-MATCH's type contains a list of regexps).
+ `(auto-o-seq-edge (overlay-get ,o-match 'set)
+ (overlay-get ,o-match 'type)
+ (overlay-get ,o-match 'sequence)))
+
+
+(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)))
+
+
+(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)))
+
+
+(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))))
+
+
+(defmacro auto-o-start-matched-p (overlay)
+ ;; test if OVERLAY is start-matched
+ `(overlay-get ,overlay 'start))
+
+
+(defmacro auto-o-end-matched-p (overlay)
+ ;; test if OVERLAY is end-matched
+ `(overlay-get ,overlay 'end))
+
+
+(defmacro auto-o-type-is-list-p (set type)
+ ;; Return non-nil if regexp type TYPE contains a list of regexp entries
+ ;; rather than a single entry.
+ `(let ((entry (auto-o-entry ,set ,type 0)))
+ (and (listp entry) (symbolp (car entry)))))
+
+
+
+
+;;;=========================================================
+;;; auto-overlay functions
+
(defun auto-overlay-init (regexp-list &optional buffer)
"Initialise a set of auto-overlays in BUFFER, or the current
buffer if none is specified, returning an identifier that can be
@@ -789,131 +922,6 @@ properties)."
-;; --- code-tidying macros ---
-
-(defmacro auto-o-entry (set type &optional sequence)
- ;; Return regexp entry corresponding to SET, TYPE and SEQUENCE.
- `(if ,sequence
- (nth (1+ ,sequence) (nth ,type (nth ,set auto-overlay-regexps)))
- (nth ,type (nth ,set auto-overlay-regexps))))
-
-
-(defmacro auto-o-class (o-match)
- ;; Return class of match overlay O-MATCH.
- `(car (nth (overlay-get ,o-match 'type)
- (nth (overlay-get ,o-match 'set) auto-overlay-regexps))))
-
-
-(defmacro auto-o-seq-regexp (set type &optional sequence)
- ;; Return regexp corresponsing to SET, TYPE and SEQUENCE.
- `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
- (if (atom regexp) regexp (car regexp))))
-
-
-(defmacro auto-o-regexp (o-match)
- ;; Return match overlay O-MATCH's regexp.
- `(auto-o-seq-regexp (overlay-get ,o-match 'set)
- (overlay-get ,o-match 'type)
- (overlay-get ,o-match 'sequence)))
-
-
-(defmacro auto-o-seq-regexp-group (set type &optional sequence)
- ;; Return regexp group corresponsing to SET, TYPE and SEQUENCE, or 0 if none
- ;; is specified.
- `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
- (cond
- ((atom regexp) 0)
- ((atom (cdr regexp)) (cdr regexp))
- (t (cadr regexp)))))
-
-
-(defmacro auto-o-regexp-group (o-match)
- ;; Return match overlay O-MATCH's regexp group.
- `(auto-o-seq-regexp-group (overlay-get ,o-match 'set)
- (overlay-get ,o-match 'type)
- (overlay-get ,o-match 'sequence)))
-
-
-(defmacro auto-o-seq-regexp-group-nth (n set type &optional sequence)
- ;; Return Nth regexp group entry corresponsing to SET, TYPE and SEQUENCE, or
- ;; 0 if there is no Nth entry.
- `(let ((regexp (nth 1 (auto-o-entry ,set ,type ,sequence))))
- (cond
- ((atom regexp) 0)
- ((> (1+ ,n) (length (cdr regexp))) 0)
- (t (nth ,n (cdr regexp))))))
-
-
-(defmacro auto-o-regexp-group-nth (n o-match)
- ;; Return match overlay O-MATCH's Nth regexp group entry, or 0 if there is
- ;; no Nth entry.
- `(auto-o-seq-regexp-group-nth ,n
- (overlay-get ,o-match 'set)
- (overlay-get ,o-match 'type)
- (overlay-get ,o-match 'sequence)))
-
-
-(defmacro auto-o-type-props (set type &optional sequence)
- ;; Return properties of regexp with SET, TYPE and SEQUENCE
- `(if (auto-o-type-is-list-p ,set ,type)
- (nthcdr 2 (auto-o-entry ,set ,type ,sequence))
- (nthcdr 2 (auto-o-entry ,set ,type))))
-
-
-(defmacro auto-o-props (o-match)
- ;; Return properties associated with match overlay O-MATCH.
- `(auto-o-type-props (overlay-get ,o-match 'set)
- (overlay-get ,o-match 'type)
- (overlay-get ,o-match 'sequence)))
-
-
-(defmacro auto-o-seq-edge (set type sequence)
- ;; Return edge ('start or 'end) of regexp with SET, TYPE and SEQEUNCE
- ;; (assumes that TYPE contains a list of regexps)
- `(car (auto-o-entry ,set ,type ,sequence)))
-
-
-(defmacro auto-o-edge (o-match)
- ;; Return edge ('start or 'end) of match overlay O-MATCH (assumes that
- ;; O-MATCH's type contains a list of regexps).
- `(auto-o-seq-edge (overlay-get ,o-match 'set)
- (overlay-get ,o-match 'type)
- (overlay-get ,o-match 'sequence)))
-
-
-(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)))
-
-
-(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)))
-
-
-(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))))
-
-
-(defmacro auto-o-start-matched-p (overlay)
- ;; test if OVERLAY is start-matched
- `(overlay-get ,overlay 'start))
-
-
-(defmacro auto-o-end-matched-p (overlay)
- ;; test if OVERLAY is end-matched
- `(overlay-get ,overlay 'end))
-
-
-(defmacro auto-o-type-is-list-p (set type)
- ;; Return non-nil if regexp type TYPE contains a list of regexp entries
- ;; rather than a single entry.
- `(let ((entry (auto-o-entry ,set ,type 0)))
- (and (listp entry) (symbolp (car entry)))))
-
-
-
;;; ===============================================================
;;; Compatibility Stuff
- [elpa] branch externals/auto-overlays created (now d207912), Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays f39daaa 05/93: Version 0.10 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays f41e85c 18/93: Renamed auto-overlays documentation directory., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays f435106 03/93: Version 0.9 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 2d0dbcf 04/93: Version 0.9.1 of the predictive completion package.,
Stefan Monnier <=
- [elpa] externals/auto-overlays b76de5a 06/93: Version 0.11.2 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 80e9510 01/93: Version 0.7 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 49f99f7 07/93: Version 0.12 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 8aef411 17/93: Minor modifications, Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 10bad81 31/93: Renamed "nest" regexps to "nested"., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays bf53b50 24/93: Adding free documentation license text to packaging. Bumped version numbers., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 39cb421 38/93: Save predictive mode auxiliary files to a subdirectory,, Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 6290c58 46/93: Added/modified local variables section to switch on predictive-mode automatically, Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 8859d17 35/93: Minor bug fixes., Stefan Monnier, 2020/12/14
- [elpa] externals/auto-overlays 31a4d46 48/93: Bug-fixes in auto-overlay-load-overlays and auto-overlay-save-overlays, Stefan Monnier, 2020/12/14