[Top][All Lists]

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

[elpa] master 351142e 07/26: More disciplined use of `if'.

From: Jackson Ray Hamilton
Subject: [elpa] master 351142e 07/26: More disciplined use of `if'.
Date: Sat, 14 Feb 2015 08:19:33 +0000

branch: master
commit 351142efaf9b520d610780a34de810f14a74d1b1
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    More disciplined use of `if'.
 benchmark/context-coloring-benchmark.el |    5 +++--
 context-coloring.el                     |   18 ++++++++++--------
 test/context-coloring-test.el           |    4 ++--
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/benchmark/context-coloring-benchmark.el 
index 004b66f..887cdc8 100644
--- a/benchmark/context-coloring-benchmark.el
+++ b/benchmark/context-coloring-benchmark.el
@@ -49,7 +49,8 @@ asynchrony."
   "Run the next test in LIST by calling CONTINUE.  When LIST is
 exhausted, call STOP instead."
   (if (null list)
-      (context-coloring-benchmark-next-tick stop)
+      (progn
+        (context-coloring-benchmark-next-tick stop))
      (lambda ()
@@ -92,7 +93,7 @@ all are done."
          (find-file fixture)))
      (lambda ()
        (funcall teardown)
-       (if callback (funcall callback))))))
+       (when callback (funcall callback))))))
 (defconst context-coloring-benchmark-js-fixtures
diff --git a/context-coloring.el b/context-coloring.el
index fbc49b8..076575c 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -339,7 +339,7 @@ Invokes CALLBACK when complete."
            (with-current-buffer buffer
              (context-coloring-apply-tokens tokens))
            (setq context-coloring-scopifier-process nil)
-           (if callback (funcall callback)))))))
+           (when callback (funcall callback)))))))
   ;; Give the process its input so it can begin.
@@ -428,8 +428,8 @@ of the current buffer, then executes it.
 Invokes CALLBACK when complete.  It is invoked synchronously for
 elisp tracks, and asynchronously for shell command tracks."
   (let ((dispatch (gethash major-mode context-coloring-mode-hash-table)))
-    (if (null dispatch)
-        (message "%s" "Context coloring is not available for this major mode"))
+    (when (null dispatch)
+      (message "%s" "Context coloring is not available for this major mode"))
     (let (colorizer
@@ -437,15 +437,16 @@ elisp tracks, and asynchronously for shell command 
        ((setq colorizer (plist-get dispatch :colorizer))
         (funcall colorizer)
-        (if callback (funcall callback)))
+        (when callback (funcall callback)))
        ((setq scopifier (plist-get dispatch :scopifier))
         (context-coloring-apply-tokens (funcall scopifier))
-        (if callback (funcall callback)))
+        (when callback (funcall callback)))
        ((setq command (plist-get dispatch :command))
         (setq executable (plist-get dispatch :executable))
         (if (and executable
                  (null (executable-find executable)))
-            (message "Executable \"%s\" not found" executable)
+            (progn
+              (message "Executable \"%s\" not found" executable))
           (context-coloring-scopify-shell-command command callback)))))))
@@ -461,7 +462,7 @@ Invokes CALLBACK when complete; see 
      (lambda ()
        (when context-coloring-benchmark-colorization
          (message "Colorization took %.3f seconds" (- (float-time) 
-       (if callback (funcall callback))))))
+       (when callback (funcall callback))))))
 (defun context-coloring-change-function (_start _end _length)
   "Registers a change so that a buffer can be colorized soon."
@@ -685,7 +686,8 @@ faces for custom themes that might not exist yet."
   (when (custom-theme-p theme) ; Guard against non-existent themes.
     (let ((enabled-theme (car custom-enabled-themes)))
       (if (context-coloring-theme-p enabled-theme)
-          (context-coloring-enable-theme enabled-theme)
+          (progn
+            (context-coloring-enable-theme enabled-theme))
         ;; Assume we are back to no theme; act as if nothing ever happened.
         ;; This is still prone to intervention, but rather extraordinarily.
         (setq context-coloring-maximum-face
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 87568fe..7c23d89 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -80,7 +80,7 @@ to run arbitrary code before the mode is invoked."
    (lambda (done-with-temp-buffer)
-     (if setup (funcall setup))
+     (when setup (funcall setup))
      (insert (context-coloring-test-read-file fixture))
@@ -247,7 +247,7 @@ EXPECTED-FACE."
 (defun context-coloring-test-kill-buffer (buffer)
   "Kill BUFFER if it exists."
-  (if (get-buffer buffer) (kill-buffer buffer)))
+  (when (get-buffer buffer) (kill-buffer buffer)))
 (defun context-coloring-test-assert-face (level foreground &optional negate)
   "Assert that a face for LEVEL exists and that its `:foreground'

reply via email to

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