Skip to content

Commit 06b1055

Browse files
author
Jason Duncan
committed
Replaced a few ternary if statements returning nil with when statements.
1 parent bf28564 commit 06b1055

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

TODO.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*** NOTE The version using `and' is slightly more concise, but I believe the compromise I made between the two suggestions to be more readable.
2121
*** NOTE2 I'm wary of going all the way to string-blank-p as I wouldn't want to break potential compatibility with a table format which uses whitespace in a way I hadn't thought of.
2222

23-
** TODO Could the last conditional in format-table-remove-noise be written with (when ret ...) instead of (if (not ret) nil ...)?
23+
** DONE Could the last conditional in format-table-remove-noise be written with (when ret ...) instead of (if (not ret) nil ...)?
2424
** TODO Rather than
2525

2626
#+BEGIN_SRC emacs-lisp

format-table.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@
9595
(defun format-table-remove-noise (lines input-mode)
9696
"Given the set of table LINES and some extra information in INPUT-MODE, filter out any empty lines or lines which otherwise do not belong to the table of values."
9797
(let* ((row-count-format (plist-get input-mode :row-count-format))
98-
(regexp (if (not row-count-format) nil (format row-count-format "[[:digit:]]+")))
98+
(regexp (when row-count-format (format row-count-format "[[:digit:]]+")))
9999
ret)
100100
(dolist (cur-line (reverse lines) ret)
101101
(unless (or (string-empty-p cur-line)
102102
(and regexp (string-match regexp cur-line)))
103103
(push cur-line ret)))
104-
(if (not ret) nil
104+
(when ret
105105
(setq ret (if (plist-get input-mode :top-border-fn) (-slice ret 1) ret))
106106
(if (plist-get input-mode :top-border-fn)
107107
(-slice ret 0 (1- (length ret))) ret))))
@@ -247,7 +247,7 @@ otherwise values will be padded to the right with spaces."
247247
(let* ((lines (split-string str "[
248248
]+"))
249249
(lines (format-table-remove-noise lines input-mode)))
250-
(if (not lines) nil
250+
(when lines
251251
(let* ((col-widths (format-table-get-col-widths (car (cdr lines)) input-mode)))
252252
(format-table-parse-table lines col-widths input-mode))))))
253253

0 commit comments

Comments
 (0)