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

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

[elpa] externals/auto-overlays db9036a 92/93: * packages/auto-overlays/:


From: Stefan Monnier
Subject: [elpa] externals/auto-overlays db9036a 92/93: * packages/auto-overlays/: Activate lexical-binding.
Date: Mon, 14 Dec 2020 13:00:45 -0500 (EST)

branch: externals/auto-overlays
commit db9036a8174e328a7b7c963aee68c939586a86fc
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * packages/auto-overlays/: Activate lexical-binding.
    
    * packages/auto-overlays/auto-overlays.el: Don't require `cl`.
    Prefer `defsubst` over `defmacro` when possible.
    (auto-o-adjoin): Use `setq` rather than `setf`.
    (auto-o-entry): Hoist the common `cdr` outside the `if`.
    (auto-o-sublist): Remove redundant test (we know it's nil).
    (auto-overlay-load-regexp): Simplify adding to the end.
    (auto-overlay-update): Simplify with DeMorgan.
    (auto-o-match-overlay): Hoist common code out of `if`.
    
    * packages/auto-overlays/auto-overlay-common.el (auto-overlays-in): 
Simplify.
    
    * packages/auto-overlays/auto-overlay-flat.el (auto-o-flat-suicide):
    Remove unused var `o-start`.
---
 auto-overlay-flat.el   |  7 +++----
 auto-overlay-line.el   |  5 ++---
 auto-overlay-nested.el |  9 ++++-----
 auto-overlay-self.el   | 15 +++++++--------
 auto-overlay-word.el   |  7 +++----
 auto-overlays.el       | 42 ++++++++++++++++++++----------------------
 6 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/auto-overlay-flat.el b/auto-overlay-flat.el
index e50ceac..1167e3b 100644
--- a/auto-overlay-flat.el
+++ b/auto-overlay-flat.el
@@ -1,7 +1,6 @@
 ;;; auto-overlay-flat.el --- flat start/end-delimited automatic overlays    
-*- lexical-binding: t; -*-
 
-
-;; Copyright (C) 2005-2015  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
 ;; Maintainer: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -32,8 +31,8 @@
 
 ;; set flat overlay parsing and suicide functions, and indicate class requires
 ;; separate start and end regexps
-(put 'flat 'auto-overlay-parse-function 'auto-o-parse-flat-match)
-(put 'flat 'auto-overlay-suicide-function 'auto-o-flat-suicide)
+(put 'flat 'auto-overlay-parse-function #'auto-o-parse-flat-match)
+(put 'flat 'auto-overlay-suicide-function #'auto-o-flat-suicide)
 (put 'flat 'auto-overlay-complex-class t)
 
 
diff --git a/auto-overlay-line.el b/auto-overlay-line.el
index 8afbb4e..231d563 100644
--- a/auto-overlay-line.el
+++ b/auto-overlay-line.el
@@ -1,7 +1,6 @@
 ;;; auto-overlay-line.el --- automatic overlays for single lines    -*- 
lexical-binding: t; -*-
 
-
-;; Copyright (C) 2005-2015  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
 ;; Maintainer: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -31,7 +30,7 @@
 
 
 ;; set line overlay parsing and suicide funtions
-(put 'line 'auto-overlay-parse-function 'auto-o-parse-line-match)
+(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-nested.el b/auto-overlay-nested.el
index af23c25..cc06a3a 100644
--- a/auto-overlay-nested.el
+++ b/auto-overlay-nested.el
@@ -1,7 +1,6 @@
 ;;; auto-overlay-nested.el --- nested start/end-delimited automatic overlays   
 -*- lexical-binding: t; -*-
 
-
-;; Copyright (C) 2005-2015  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
 ;; Maintainer: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -32,8 +31,8 @@
 
 ;; set nested overlay parsing and suicide functions, and indicate class
 ;; requires separate start and end regexps
-(put 'nested 'auto-overlay-parse-function 'auto-o-parse-nested-match)
-(put 'nested 'auto-overlay-suicide-function 'auto-o-nested-suicide)
+(put 'nested 'auto-overlay-parse-function #'auto-o-parse-nested-match)
+(put 'nested 'auto-overlay-suicide-function #'auto-o-nested-suicide)
 (put 'nested 'auto-overlay-complex-class t)
 
 
@@ -103,7 +102,7 @@
 
 
 
-(defun auto-o-make-nested (o-match &optional unmatched)
+(defun auto-o-make-nested (o-match &optional _unmatched)
   ;; Create a nested overlay for match overlay O-MATCH.
   ;; If UNMATCHED is nil, overlay will start and end at O-MATCH.
   ;; If non-nil, overlay will start or end from O-MATCH (depending on whether
diff --git a/auto-overlay-self.el b/auto-overlay-self.el
index 5e72566..864c24f 100644
--- a/auto-overlay-self.el
+++ b/auto-overlay-self.el
@@ -1,7 +1,6 @@
 ;;; auto-overlay-self.el --- self-delimited automatic overlays    -*- 
lexical-binding: t; -*-
 
-
-;; Copyright (C) 2005-2017  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
 ;; Maintainer: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -34,12 +33,12 @@
 (make-variable-buffer-local 'auto-o-pending-self-cascade)
 
 ;; 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)
+(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)
-(add-hook 'auto-overlay-unload-hook 'auto-o-self-unload)
+(add-hook 'auto-overlay-load-hook #'auto-o-self-load)
+(add-hook 'auto-overlay-unload-hook #'auto-o-self-unload)
 
 
 
@@ -47,13 +46,13 @@
   ;; Make sure `auto-o-perform-self-cascades' is in `before-change-functions',
   ;; so that any cascading that is required is performed before anything else
   ;; happens.
-  (add-hook 'before-change-functions 'auto-o-perform-self-cascades
+  (add-hook 'before-change-functions #'auto-o-perform-self-cascades
            nil t))
 
 
 (defun auto-o-self-unload ()
   ;; Remove `auto-o-perform-self-cascades' from `before-change-functions'.
-  (remove-hook 'before-change-functions 'auto-o-perform-self-cascades t)
+  (remove-hook 'before-change-functions #'auto-o-perform-self-cascades t)
   (setq auto-o-pending-self-cascade nil))
 
 
diff --git a/auto-overlay-word.el b/auto-overlay-word.el
index 15637c7..cc984c9 100644
--- a/auto-overlay-word.el
+++ b/auto-overlay-word.el
@@ -1,7 +1,6 @@
 ;;; auto-overlay-word.el --- automatic overlays for single "words"    -*- 
lexical-binding: t; -*-
 
-
-;; Copyright (C) 2005-2015  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
 ;; Maintainer: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -31,7 +30,7 @@
 
 
 ;; set word overlay parsing and suicide functions
-(put 'word 'auto-overlay-parse-function 'auto-o-parse-word-match)
+(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))))
 
@@ -67,4 +66,4 @@
 )
 
 
-;; auto-overlay-word.el ends here
+;;; auto-overlay-word.el ends here
diff --git a/auto-overlays.el b/auto-overlays.el
index 69604c7..83a17ee 100644
--- a/auto-overlays.el
+++ b/auto-overlays.el
@@ -1,6 +1,6 @@
 ;;; auto-overlays.el --- Automatic regexp-delimited overlays    -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2005-2017  Free Software Foundation, Inc
+;; Copyright (C) 2005-2020  Free Software Foundation, Inc
 
 ;; Version: 0.10.9
 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
@@ -859,7 +859,7 @@ identifies REGEXP within DEFINITION (see
          ;; if DEFINITION-ID is not specified, create a unique numeric
          ;; DEFINITION-ID
          (setq definition-id
-               (1+ (apply 'max -1
+               (1+ (apply #'max -1
                           (mapcar (lambda (elt)
                                     (if (integerp (car elt))
                                         (car elt) -1))
@@ -937,7 +937,7 @@ uniquely identify REGEXP (see 
`auto-overlay-unload-regexp')."
          (setq regexp (auto-o--plist-delete regexp :id)))
       ;; if no id is specified, create a unique numeric ID
       (setq regexp-id
-           (1+ (apply 'max -1
+           (1+ (apply #'max -1
                       (mapcar (lambda (elt)
                                 (if (integerp (car elt)) (car elt) -1))
                               (cddr defs))))))
@@ -947,9 +947,7 @@ uniquely identify REGEXP (see 
`auto-overlay-unload-regexp')."
     (cond
      ;; adding at end
      ((or (null pos) (and (integerp pos) (>= pos (length (cddr defs)))))
-      (if (= (length (cddr defs)) 0)
-         (setcdr (cdr defs) (list regexp))
-       (nconc (cddr defs) (list regexp))))
+      (nconc defs (list regexp)))
      ;; adding at start
      ((or (eq pos t) (and (integerp pos) (<= pos 0)))
       (setcdr (cdr defs) (nconc (list regexp) (cddr defs))))
@@ -1106,14 +1104,14 @@ definitions are the same as when the overlays were 
saved."
     (run-hooks 'auto-overlay-load-hook)
     ;; add hook to run all the various functions scheduled be run after a
     ;; buffer modification
-    (add-hook 'after-change-functions 'auto-o-run-after-change-functions
+    (add-hook 'after-change-functions #'auto-o-run-after-change-functions
              nil t)
     ;; add hook to schedule an update after a buffer modification
-    (add-hook 'after-change-functions 'auto-o-schedule-update nil t)
+    (add-hook 'after-change-functions #'auto-o-schedule-update nil t)
     ;; add hook to simulate missing `delete-in-front-hooks' and
     ;; `delete-behind-hooks' overlay properties
     (add-hook 'after-change-functions
-             'auto-o-schedule-delete-in-front-or-behind-suicide
+             #'auto-o-schedule-delete-in-front-or-behind-suicide
              nil t)
 
     (unless (auto-o-enabled-p set-id)
@@ -1159,7 +1157,7 @@ is about to be killed in which case it speeds things up a 
bit\)."
 
     ;; delete overlays unless told not to bother
     (unless leave-overlays
-      (mapc 'delete-overlay
+      (mapc #'delete-overlay
            (auto-overlays-in
             (point-min) (point-max) :all-overlays t :inactive t
             (list (lambda (overlay match) (or overlay match))
@@ -1175,9 +1173,9 @@ is about to be killed in which case it speeds things up a 
bit\)."
       ;; run clear hooks
       (run-hooks 'auto-overlay-unload-hook)
       ;; reset variables
-      (remove-hook 'after-change-functions 'auto-o-schedule-update t)
+      (remove-hook 'after-change-functions #'auto-o-schedule-update t)
       (remove-hook 'after-change-functions
-                  'auto-o-run-after-change-functions t)
+                  #'auto-o-run-after-change-functions t)
       (setq auto-o-pending-suicides nil
            auto-o-pending-updates nil
            auto-o-pending-post-suicide nil))))
@@ -1353,7 +1351,7 @@ overlays were saved."
 ;;;               Update and change-hook functions
 
 (defun auto-o-run-after-change-functions (beg end len)
-  ;; Assigned to the `after-change-functions' hook. Run all the various
+  ;; Assigned to the `after-change-functions' hook.  Run all the various
   ;; functions that should run after a change to the buffer, in the correct
   ;; order.
 
@@ -1369,7 +1367,7 @@ overlays were saved."
               auto-o-pending-post-update)
       ;; run pending pre-suicide functions
       (when auto-o-pending-pre-suicide
-       (mapc (lambda (f) (apply (car f) (cdr f)))
+       (mapc (lambda (f) (apply (car f) (cdr f))) ;Just #'apply in Emacs≥24.3
              auto-o-pending-pre-suicide)
        (setq auto-o-pending-pre-suicide nil))
       ;; run pending suicides
@@ -1378,7 +1376,7 @@ overlays were saved."
        (setq auto-o-pending-suicides nil))
       ;; run pending post-suicide functions
       (when auto-o-pending-post-suicide
-       (mapc (lambda (f) (apply (car f) (cdr f)))
+       (mapc (lambda (f) (apply (car f) (cdr f))) ;Just #'apply in Emacs≥24.3
              auto-o-pending-post-suicide)
        (setq auto-o-pending-post-suicide nil))
       ;; run updates
@@ -1388,7 +1386,7 @@ overlays were saved."
        (setq auto-o-pending-updates nil))
       ;; run pending post-update functions
       (when auto-o-pending-post-update
-       (mapc (lambda (f) (apply (car f) (cdr f)))
+       (mapc (lambda (f) (apply (car f) (cdr f))) ;Just #'apply in Emacs≥24.3
              auto-o-pending-post-update)
        (setq auto-o-pending-post-update nil))
       ))
@@ -1547,8 +1545,8 @@ overlays were saved."
                      (while (let ((case-fold-search nil))
                               (re-search-forward regexp (line-end-position) t))
                        ;; sanity check regexp definition against match
-                       (when (or (null (setq beg (match-beginning group)))
-                                 (null (setq end (match-end group))))
+                       (unless (and (setq beg (match-beginning group))
+                                    (setq end (match-end group)))
                          (error "Match for regexp \"%s\" has no group %d"
                                 regexp group))
 
@@ -1939,10 +1937,10 @@ properties)."
         (t  ;; otherwise, use properties of whichever match takes precedence
          (let ((o-start (overlay-get overlay 'start))
                (o-end (overlay-get overlay 'end)))
-           (if (<= (auto-o-rank o-start)
-                   (auto-o-rank o-end))
-               (setq props (auto-o-props o-start))
-             (setq props (auto-o-props o-end))))))
+           (setq props (auto-o-props (if (<= (auto-o-rank o-start)
+                                             (auto-o-rank o-end))
+                                         o-start
+                                       o-end))))))
        ;; bundle properties inside a list if not already, then update them
        (when (symbolp (car props)) (setq props (list props)))
        (dolist (p props) (overlay-put overlay (car p) (cdr p)))))



reply via email to

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