aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEivind Fonn <evfonn@gmail.com>2020-01-29 09:12:07 +0100
committerEivind Fonn <evfonn@gmail.com>2020-01-29 09:15:41 +0100
commit21e504a8b961d0131e4a712bd711125a86a2a703 (patch)
treee757a67523b67d67f28097336ed71f50870b94e3
parente9391ae769bee189ef6144b8861b117d5c948a80 (diff)
Re-enable lexical binding
This reverts commit e9391ae769bee189ef6144b8861b117d5c948a80, and removes spurious debug messages.
-rw-r--r--evil-command-window.el2
-rw-r--r--evil-commands.el2
-rw-r--r--evil-common.el2
-rw-r--r--evil-core.el2
-rw-r--r--evil-development.el2
-rw-r--r--evil-digraphs.el2
-rw-r--r--evil-ex.el104
-rw-r--r--evil-integration.el2
-rw-r--r--evil-jumps.el2
-rw-r--r--evil-keybindings.el2
-rw-r--r--evil-macros.el2
-rw-r--r--evil-maps.el2
-rw-r--r--evil-repeat.el2
-rw-r--r--evil-search.el2
-rw-r--r--evil-states.el2
-rw-r--r--evil-test-helpers.el2
-rw-r--r--evil-types.el2
-rw-r--r--evil-vars.el2
18 files changed, 72 insertions, 66 deletions
diff --git a/evil-command-window.el b/evil-command-window.el
index 5201d7b..379e556 100644
--- a/evil-command-window.el
+++ b/evil-command-window.el
@@ -1,4 +1,4 @@
-;;; evil-command-window.el --- Evil command line window implementation
+;;; evil-command-window.el --- Evil command line window implementation -*- lexical-binding: t -*-
;; Author: Emanuel Evans <emanuel.evans at gmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-commands.el b/evil-commands.el
index e1749ac..f7180ff 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1,4 +1,4 @@
-;;; evil-commands.el --- Evil commands and operators
+;;; evil-commands.el --- Evil commands and operators -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-common.el b/evil-common.el
index f10a6d2..92447c5 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -1,4 +1,4 @@
-;;; evil-common.el --- Common functions and utilities
+;;; evil-common.el --- Common functions and utilities -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-core.el b/evil-core.el
index 8b74fa7..09101e4 100644
--- a/evil-core.el
+++ b/evil-core.el
@@ -1,4 +1,4 @@
-;;; evil-core.el --- Core functionality
+;;; evil-core.el --- Core functionality -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-development.el b/evil-development.el
index 203b5de..7cebf5b 100644
--- a/evil-development.el
+++ b/evil-development.el
@@ -1,4 +1,4 @@
-;;; evil-development.el --- Useful features for Evil developers
+;;; evil-development.el --- Useful features for Evil developers -*- lexical-binding: t -*-
;; Author: Justin Burkett <justin at burkett dot cc>
diff --git a/evil-digraphs.el b/evil-digraphs.el
index f0d89a3..e2d533a 100644
--- a/evil-digraphs.el
+++ b/evil-digraphs.el
@@ -1,4 +1,4 @@
-;;; evil-digraphs.el --- Digraphs
+;;; evil-digraphs.el --- Digraphs -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-ex.el b/evil-ex.el
index f257f4e..e35e5b6 100644
--- a/evil-ex.el
+++ b/evil-ex.el
@@ -1,4 +1,4 @@
-;;; evil-ex.el --- Ex-mode
+;;; evil-ex.el --- Ex-mode -*- lexical-binding: nil -*-
;; Author: Frank Fischer <frank fischer at mathematik.tu-chemnitz.de>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
@@ -923,6 +923,33 @@ POS defaults to the current position of point."
(when contexts
(nth pos contexts))))
+(defun evil-parser--dexp (obj)
+ "Parse a numerical dollar-sign symbol.
+Given e.g. $4, return 4."
+ (when (symbolp obj)
+ (let ((str (symbol-name obj)))
+ (save-match-data
+ (when (string-match "\\$\\([0-9]+\\)" str)
+ (string-to-number (match-string 1 str)))))))
+
+(defun evil-parser--dval (obj result)
+ "Substitute all dollar-sign symbols in OBJ.
+Each dollar-sign symbol is replaced with the corresponding
+element in RESULT, so that $1 becomes the first element, etc.
+The special value $0 is substituted with the whole list RESULT.
+If RESULT is not a list, all dollar-sign symbols are substituted with
+RESULT."
+ (if (listp obj)
+ (mapcar (lambda (obj) (evil-parser--dval obj result)) obj)
+ (let ((num (evil-parser--dexp obj)))
+ (if num
+ (if (not (listp result))
+ result
+ (if (eq num 0)
+ `(list ,@result)
+ (nth (1- num) result)))
+ obj))))
+
(defun evil-parser (string symbol grammar &optional greedy syntax)
"Parse STRING as a SYMBOL in GRAMMAR.
If GREEDY is non-nil, the whole of STRING must match.
@@ -1120,54 +1147,33 @@ The following symbols have reserved meanings within a grammar:
;; semantic action
(when (and pair func (not syntax))
(setq result (car pair))
- (let* ((dexp
- #'(lambda (obj)
- (when (symbolp obj)
- (let ((str (symbol-name obj)))
- (save-match-data
- (when (string-match "\\$\\([0-9]+\\)" str)
- (string-to-number (match-string 1 str))))))))
- ;; traverse a tree for dollar expressions
- (dval nil)
- (dval
- #'(lambda (obj)
- (if (listp obj)
- (mapcar dval obj)
- (let ((num (funcall dexp obj)))
- (if num
- (if (not (listp result))
- result
- (if (eq num 0)
- `(list ,@result)
- (nth (1- num) result)))
- obj))))))
- (cond
- ((null func)
- (setq result nil))
- ;; lambda function
- ((eq (car-safe func) 'lambda)
- (if (memq symbol '(+ seq))
- (setq result `(funcall ,func ,@result))
- (setq result `(funcall ,func ,result))))
- ;; string replacement
- ((or (stringp func) (stringp (car-safe func)))
- (let* ((symbol (or (car-safe (cdr-safe func))
- (and (boundp 'context) context)
- (car-safe (car-safe grammar))))
- (string (if (stringp func) func (car-safe func))))
- (setq result (car-safe (evil-parser string symbol grammar
- greedy syntax)))))
- ;; dollar expression
- ((funcall dexp func)
- (setq result (funcall dval func)))
- ;; function call
- ((listp func)
- (setq result (funcall dval func)))
- ;; symbol
- (t
- (if (memq symbol '(+ seq))
- (setq result `(,func ,@result))
- (setq result `(,func ,result))))))
+ (cond
+ ((null func)
+ (setq result nil))
+ ;; lambda function
+ ((eq (car-safe func) 'lambda)
+ (if (memq symbol '(+ seq))
+ (setq result `(funcall ,func ,@result))
+ (setq result `(funcall ,func ,result))))
+ ;; string replacement
+ ((or (stringp func) (stringp (car-safe func)))
+ (let* ((symbol (or (car-safe (cdr-safe func))
+ (and (boundp 'context) context)
+ (car-safe (car-safe grammar))))
+ (string (if (stringp func) func (car-safe func))))
+ (setq result (car-safe (evil-parser string symbol grammar
+ greedy syntax)))))
+ ;; dollar expression
+ ((evil-parser--dexp func)
+ (setq result (evil-parser--dval func result)))
+ ;; function call
+ ((listp func)
+ (setq result (evil-parser--dval func result)))
+ ;; symbol
+ (t
+ (if (memq symbol '(+ seq))
+ (setq result `(,func ,@result))
+ (setq result `(,func ,result)))))
(setcar pair result))))
;; weed out incomplete matches
(when pair
diff --git a/evil-integration.el b/evil-integration.el
index 284f9d4..3eac3c5 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -1,4 +1,4 @@
-;;; evil-integration.el --- Integrate Evil with other modules
+;;; evil-integration.el --- Integrate Evil with other modules -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-jumps.el b/evil-jumps.el
index 4afb2bd..c02de01 100644
--- a/evil-jumps.el
+++ b/evil-jumps.el
@@ -1,4 +1,4 @@
-;;; evil-jumps.el --- Jump list implementation
+;;; evil-jumps.el --- Jump list implementation -*- lexical-binding: t -*-
;; Author: Bailey Ling <bling at live.ca>
diff --git a/evil-keybindings.el b/evil-keybindings.el
index 8311187..3df4f98 100644
--- a/evil-keybindings.el
+++ b/evil-keybindings.el
@@ -1,4 +1,4 @@
-;;; evil-keybindings.el --- Add some Evil keybindings to other modules
+;;; evil-keybindings.el --- Add some Evil keybindings to other modules -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-macros.el b/evil-macros.el
index 5142649..42e18df 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -1,4 +1,4 @@
-;;; evil-macros.el --- Macros
+;;; evil-macros.el --- Macros -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-maps.el b/evil-maps.el
index c57a33f..214d8a6 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -1,4 +1,4 @@
-;;; evil-maps.el --- Default keymaps
+;;; evil-maps.el --- Default keymaps -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-repeat.el b/evil-repeat.el
index d9f1f90..01168c9 100644
--- a/evil-repeat.el
+++ b/evil-repeat.el
@@ -1,4 +1,4 @@
-;;; evil-repeat.el --- Repeat system
+;;; evil-repeat.el --- Repeat system -*- lexical-binding: t -*-
;; Author: Frank Fischer <frank.fischer at mathematik.tu-chemnitz.de>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-search.el b/evil-search.el
index d77034e..1989cab 100644
--- a/evil-search.el
+++ b/evil-search.el
@@ -1,4 +1,4 @@
-;;; evil-search.el --- Search and substitute
+;;; evil-search.el --- Search and substitute -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-states.el b/evil-states.el
index ee136a3..9365678 100644
--- a/evil-states.el
+++ b/evil-states.el
@@ -1,4 +1,4 @@
-;;; evil-states.el --- States
+;;; evil-states.el --- States -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-test-helpers.el b/evil-test-helpers.el
index 6f8d02f..1461c8a 100644
--- a/evil-test-helpers.el
+++ b/evil-test-helpers.el
@@ -1,4 +1,4 @@
-;;; evil-test-helpers.el --- unit test helpers for Evil -*- coding: utf-8 -*-
+;;; evil-test-helpers.el --- unit test helpers for Evil -*- coding: utf-8; lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-types.el b/evil-types.el
index 3cf9f2d..be894af 100644
--- a/evil-types.el
+++ b/evil-types.el
@@ -1,4 +1,4 @@
-;;; evil-types.el --- Type system
+;;; evil-types.el --- Type system -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
diff --git a/evil-vars.el b/evil-vars.el
index e42a087..d5bb097 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -1,4 +1,4 @@
-;;; evil-vars.el --- Settings and variables
+;;; evil-vars.el --- Settings and variables -*- lexical-binding: t -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>