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

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

[elpa] master 4eacc29 07/10: Update eval-expression recommendation for 2


From: Jackson Ray Hamilton
Subject: [elpa] master 4eacc29 07/10: Update eval-expression recommendation for 24.3.
Date: Thu, 18 Jun 2015 08:33:57 +0000

branch: master
commit 4eacc29a5dd6a725f4885709f9f352d810a36e94
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Update eval-expression recommendation for 24.3.
---
 README.md                     |    4 ++--
 context-coloring.el           |   11 +++++++++--
 test/context-coloring-test.el |   35 +++++++++++++++--------------------
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index 568be45..0ced14c 100644
--- a/README.md
+++ b/README.md
@@ -78,8 +78,8 @@ Add the following to your init file:
 ;; emacs-lisp-mode:
 (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode)
 
-;; Minibuffer:
-(add-hook 'eval-expression-minibuffer-setup-hook #'context-coloring-mode)
+;; eval-expression:
+(add-hook 'minibuffer-setup-hook #'context-coloring-mode)
 ```
 
 ## Customizing
diff --git a/context-coloring.el b/context-coloring.el
index 6ebf924..69c6eb8 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -5,7 +5,7 @@
 ;; Author: Jackson Ray Hamilton <address@hidden>
 ;; Version: 6.4.1
 ;; Keywords: convenience faces tools
-;; Package-Requires: ((emacs "24") (js2-mode "20150126"))
+;; Package-Requires: ((emacs "24.3") (js2-mode "20150126"))
 ;; URL: https://github.com/jacksonrayhamilton/context-coloring
 
 ;; This file is part of GNU Emacs.
@@ -1760,9 +1760,16 @@ precedence, i.e. the car of `custom-enabled-themes'."
  :setup #'context-coloring-setup-idle-change-detection
  :teardown #'context-coloring-teardown-idle-change-detection)
 
+;; `eval-expression-minibuffer-setup-hook' is not available in Emacs 24.3, so
+;; the backwards-compatible recommendation is to use `minibuffer-setup-hook' 
and
+;; rely on this predicate instead.
+(defun context-coloring-eval-expression-predicate ()
+  "Non-nil if the minibuffer is for `eval-expression'."
+  (eq this-command 'eval-expression))
+
 (context-coloring-define-dispatch
  'eval-expression
- :predicate #'window-minibuffer-p
+ :predicate #'context-coloring-eval-expression-predicate
  :colorizer #'context-coloring-eval-expression-colorize
  :delay 0.016
  :setup #'context-coloring-setup-idle-change-detection
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index f7c7a20..39f2f80 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1272,28 +1272,23 @@ nnnnn n nnn nnnnnnnn")))
 1111 111
 nnnn nn")))
 
-(defun context-coloring-test-eval-expression-let ()
-  "Test that coloring works inside `eval-expression.'"
-  (let ((input "(ignore-errors (let (a) (message a free)))"))
-    (insert input)
-    (context-coloring-colorize)
-    (context-coloring-test-assert-coloring "
-xxxx: 0000000-000000 1111 111 11111111 1 0000110")))
-
 (context-coloring-test-deftest-eval-expression let
   (lambda ()
-    (add-hook
-     'eval-expression-minibuffer-setup-hook
-     #'context-coloring-test-eval-expression-let)
-    (execute-kbd-macro
-     (vconcat
-      [?\C-u] ;; Don't output to stdout.
-      [?\M-x]
-      (vconcat "eval-expression"))))
-  :after (lambda ()
-           (remove-hook
-            'eval-expression-minibuffer-setup-hook
-            #'context-coloring-test-eval-expression-let)))
+    (minibuffer-with-setup-hook
+        (lambda ()
+          ;; Perform the test in a hook as it's the only way I know of 
examining
+          ;; the minibuffer's contents.  The contents are implicitly submitted,
+          ;; so we have to ignore the errors in the arbitrary test subject 
code.
+          (insert "(ignore-errors (let (a) (message a free)))")
+          (context-coloring-colorize)
+          (context-coloring-test-assert-coloring "
+xxxx: 0000000-000000 1111 111 11111111 1 0000110"))
+      ;; Simulate user input because `call-interactively' is blocking and
+      ;; doesn't seem to run the hook.
+      (execute-kbd-macro
+       (vconcat
+        [?\C-u] ;; Don't output the result of the arbitrary test subject code.
+        [?\M-:])))))
 
 (provide 'context-coloring-test)
 



reply via email to

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