]> code.delx.au - gnu-emacs-elpa/commitdiff
More disciplined use of `if'.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Wed, 11 Feb 2015 09:57:41 +0000 (01:57 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Wed, 11 Feb 2015 09:57:41 +0000 (01:57 -0800)
benchmark/context-coloring-benchmark.el
context-coloring.el
test/context-coloring-test.el

index 004b66fbe13fa3b79b6936da4c8176c3d50f38d6..887cdc830d9c56e619091bcaf6830461fc8f06d1 100644 (file)
@@ -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))
     (context-coloring-benchmark-next-tick
      (lambda ()
        (funcall
@@ -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
   '("./fixtures/jquery-2.1.1.js"
index fbc49b8de219f62d6322ac4c85f18ded9c556b78..076575cc72054de024d954a4ed2a3fbc294a8c71 100644 (file)
@@ -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.
   (process-send-region
@@ -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
           scopifier
           command
@@ -437,15 +437,16 @@ elisp tracks, and asynchronously for shell command tracks."
       (cond
        ((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 `context-coloring-dispatch'."
      (lambda ()
        (when context-coloring-benchmark-colorization
          (message "Colorization took %.3f seconds" (- (float-time) start-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
index 87568fe903c3c2940c687f18bced5abf34375d07..7c23d89db6bf20fddbca81b34adb62767a11fc51 100644 (file)
@@ -80,7 +80,7 @@ to run arbitrary code before the mode is invoked."
   (context-coloring-test-with-temp-buffer-async
    (lambda (done-with-temp-buffer)
      (context-coloring-test-setup)
-     (if setup (funcall setup))
+     (when setup (funcall setup))
      (insert (context-coloring-test-read-file fixture))
      (funcall
       callback
@@ -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'