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

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

[elpa] master 8d54c2e 08/12: Suppress unavailable messages in minibuffer


From: Jackson Ray Hamilton
Subject: [elpa] master 8d54c2e 08/12: Suppress unavailable messages in minibuffer.
Date: Sun, 21 Jun 2015 21:16:14 +0000

branch: master
commit 8d54c2e2b78eef8a785d20f557072ddfe6345770
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Suppress unavailable messages in minibuffer.
---
 context-coloring.el           |   20 ++++++++++++++++++--
 test/context-coloring-test.el |   17 +++++++++++++++--
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 1967cdf..5b5eb28 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -1186,6 +1186,22 @@ override `context-coloring-default-delay'.
  :setup #'context-coloring-setup-idle-change-detection
  :teardown #'context-coloring-teardown-idle-change-detection)
 
+(defvar context-coloring-ignore-unavailable-predicates
+  (list
+   #'minibufferp)
+  "Cases when \"unavailable\" messages are silenced.
+Necessary in editing states where coloring is only sometimes
+permissible.")
+
+(defun context-coloring-ignore-unavailable-message-p ()
+  "Determine if the unavailable message should be silenced."
+  (let ((predicates context-coloring-ignore-unavailable-predicates)
+        (ignore-p nil))
+    (while (and predicates
+                (not ignore-p))
+      (setq ignore-p (funcall (pop predicates))))
+    ignore-p))
+
 
 ;;; Minor mode
 
@@ -1233,8 +1249,8 @@ Feature inspired by Douglas Crockford."
           ;; Colorize once initially.
           (let ((context-coloring-parse-interruptable-p nil))
             (context-coloring-colorize))))
-       (t
-        (message "Context coloring is not available for this major mode")))))
+       ((not (context-coloring-ignore-unavailable-message-p))
+        (message "Context coloring is unavailable here")))))
    (t
     (let ((dispatch (context-coloring-get-current-dispatch)))
       (when dispatch
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index afacbec..f5633b8 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -259,7 +259,7 @@ signaled."
   (lambda ()
     (context-coloring-mode)
     (context-coloring-test-assert-message
-     "Context coloring is not available for this major mode"
+     "Context coloring is unavailable here"
      "*Messages*")))
 
 (context-coloring-test-deftest derived-mode
@@ -267,9 +267,22 @@ signaled."
     (lisp-interaction-mode)
     (context-coloring-mode)
     (context-coloring-test-assert-not-message
-     "Context coloring is not available for this major mode"
+     "Context coloring is unavailable here"
      "*Messages*")))
 
+(context-coloring-test-deftest unavailable-message-ignored
+  (lambda ()
+    (minibuffer-with-setup-hook
+        (lambda ()
+          (context-coloring-mode)
+          (context-coloring-test-assert-not-message
+           "Context coloring is unavailable here"
+           "*Messages*"))
+      (execute-kbd-macro
+       (vconcat
+        [?\C-u]
+        [?\M-!])))))
+
 (context-coloring-test-define-derived-mode define-dispatch-error)
 
 (context-coloring-test-deftest define-dispatch-error



reply via email to

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