[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
b/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))
(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"
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.
(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
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."
(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'
- [elpa] master updated (3b749e8 -> f52a5e5), Jackson Ray Hamilton, 2015/02/14
- [elpa] master 75e624c 01/26: Todo., Jackson Ray Hamilton, 2015/02/14
- [elpa] master bd11b35 03/26: Avoid using the `font-lock-string-face' color for zenburn., Jackson Ray Hamilton, 2015/02/14
- [elpa] master ebbc2f1 04/26: Fix documentation for `context-coloring-maximum-face'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 62c38d8 05/26: Fix comment., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 880ab8a 02/26: Use `maximum-face' instead of `face-count'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master e451d29 06/26: Restore original `context-coloring-maximum-face' value., Jackson Ray Hamilton, 2015/02/14
- [elpa] master a1b7f3e 08/26: Define extra faces in `context-coloring-set-colors-default'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master ca15a60 09/26: Whitespace., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 351142e 07/26: More disciplined use of `if'.,
Jackson Ray Hamilton <=
- [elpa] master e68d00b 11/26: Whitespace., Jackson Ray Hamilton, 2015/02/14
- [elpa] master c125d9f 12/26: Reorganize defvars and defcustoms., Jackson Ray Hamilton, 2015/02/14
- [elpa] master a49b024 15/26: Whitespace., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 0681e94 13/26: Remove `set-colors' and `set-colors-default'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master e5d512f 10/26: "Misfeature.", Jackson Ray Hamilton, 2015/02/14
- [elpa] master 25a8d13 16/26: Documentation., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 4c3d1da 17/26: Rename `defface-default' to `defface-neutral'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 8367e19 18/26: Rename `level-face' functions., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 3d91840 22/26: Remove `context-coloring-benchmark-colorization'., Jackson Ray Hamilton, 2015/02/14
- [elpa] master 3805110 14/26: Reorganize faces. Remove eval macroexpand., Jackson Ray Hamilton, 2015/02/14