Subject: bug#43117: [PATCH] Add .git-blame-ignore-revs file

From: Brian Leung <[email-masked]>
Date: Sun, 13 Sep 2020 02:42:23 +0200 (CEST)

OK, please see attached. Right now there are no extraneous whitespace changes, and the only changes I've made change if -> when in the eshell files.

> Pure re-indentation patches I thought were not acceptable unless
> accompanied by an actual code change near the re-indented lines.

With a .git-blame-ignore file of some sort, shouldn't this not be a hindrance?

> ----------------------------------------
> From: Dmitry Gutov <[email-masked]>
> Sent: Mon Aug 31 23:03:23 CEST 2020
> To: Robert Pluim <[email-masked]>
> Cc: Brian Leung <[email-masked]>, <[email-masked]>
> Subject: Re: bug#43117: [PATCH] Add .git-blame-ignore-revs file
> 
> 
> On 31.08.2020 23:57, Robert Pluim wrote:
> 
> >      Dmitry> Do we accept reindentation patches, though? Ones where the effective
> >      Dmitry> indentation does change.
> > 
> > Didnʼt we just have this thread? :-)
> 
> I might have missed it. :-(
> 
> > Pure re-indentation patches I thought were not acceptable unless
> > accompanied by an actual code change near the re-indented lines.
> 
> Okay.
> 
> Brian, could you re-submit patches without extra re-indentation?

-- 
Sent with https://mailfence.com
Secure and private email

>From b535e0b426c2cc7b32c98304de76fbc9df0b17cf Mon Sep 17 00:00:00 2001
From: Brian Leung <[email-masked]>
Date: Mon, 31 Aug 2020 20:31:58 -0700
Subject: [PATCH 1/2] eshell: Replace single-clause if statements with whens

* lisp/eshell/em-alias.el: if -> when where appropriate.
* lisp/eshell/em-basic.el: Same.
* lisp/eshell/em-cmpl.el: Same.
* lisp/eshell/em-dirs.el: Same.
* lisp/eshell/em-glob.el: Same.
* lisp/eshell/em-hist.el: Same.
* lisp/eshell/em-ls.el: Same.
* lisp/eshell/em-pred.el: Same.
* lisp/eshell/em-prompt.el: Same.
* lisp/eshell/em-rebind.el: Same.
* lisp/eshell/em-script.el: Same.
* lisp/eshell/em-smart.el: Same.
* lisp/eshell/em-term.el: Same.
* lisp/eshell/em-tramp.el: Same.
* lisp/eshell/em-unix.el: Same.
* lisp/eshell/esh-arg.el: Same.
* lisp/eshell/esh-cmd.el: Same.
* lisp/eshell/eshell.el: Same.
* lisp/eshell/esh-ext.el: Same.
* lisp/eshell/esh-io.el: Same.
* lisp/eshell/esh-mode.el: Same.
* lisp/eshell/esh-module.el: Same.
* lisp/eshell/esh-opt.el: Same.
* lisp/eshell/esh-proc.el: Same.
* lisp/eshell/esh-util.el: Same.
* lisp/eshell/esh-var.el: Same.
---
 lisp/eshell/em-alias.el   |  46 ++---
 lisp/eshell/em-basic.el   |   4 +-
 lisp/eshell/em-cmpl.el    |  78 ++++-----
 lisp/eshell/em-dirs.el    |  82 ++++-----
 lisp/eshell/em-glob.el    |  52 +++---
 lisp/eshell/em-hist.el    | 120 ++++++-------
 lisp/eshell/em-ls.el      | 214 +++++++++++------------
 lisp/eshell/em-pred.el    |  80 ++++-----
 lisp/eshell/em-prompt.el  |  14 +-
 lisp/eshell/em-rebind.el  |   6 +-
 lisp/eshell/em-script.el  |   4 +-
 lisp/eshell/em-smart.el   |  42 ++---
 lisp/eshell/em-term.el    |  18 +-
 lisp/eshell/em-tramp.el   |   4 +-
 lisp/eshell/em-unix.el    | 194 ++++++++++-----------
 lisp/eshell/esh-arg.el    |  66 +++----
 lisp/eshell/esh-cmd.el    | 350 +++++++++++++++++++-------------------
 lisp/eshell/esh-ext.el    |  56 +++---
 lisp/eshell/esh-io.el     |  82 ++++-----
 lisp/eshell/esh-mode.el   | 175 ++++++++++---------
 lisp/eshell/esh-module.el |  10 +-
 lisp/eshell/esh-opt.el    |  14 +-
 lisp/eshell/esh-proc.el   |  76 ++++-----
 lisp/eshell/esh-util.el   | 170 +++++++++---------
 lisp/eshell/esh-var.el    |  86 +++++-----
 lisp/eshell/eshell.el     |  40 ++---
 26 files changed, 1041 insertions(+), 1042 deletions(-)

diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el
index 67e0c3fc08..09669477d8 100644
--- a/lisp/eshell/em-alias.el
+++ b/lisp/eshell/em-alias.el
@@ -167,9 +167,9 @@ eshell/alias
       (let ((def (assoc alias eshell-command-aliases-list))
 	    (alias-def (list alias
 			     (eshell-flatten-and-stringify definition))))
-	(if def
-	    (setq eshell-command-aliases-list
-		  (delq def eshell-command-aliases-list)))
+	(when def
+	  (setq eshell-command-aliases-list
+		(delq def eshell-command-aliases-list)))
 	(setq eshell-command-aliases-list
 	      (cons alias-def eshell-command-aliases-list))))
     (eshell-write-aliases-list))
@@ -191,22 +191,22 @@ eshell-read-aliases-list
 	      (let (eshell-command-aliases-list)
 		(insert-file-contents file)
 		(while (not (eobp))
-		  (if (re-search-forward
-		       "^alias\\s-+\\(\\S-+\\)\\s-+\\(.+\\)")
-		      (setq eshell-command-aliases-list
-			    (cons (list (match-string 1)
-					(match-string 2))
-				  eshell-command-aliases-list)))
+		  (when (re-search-forward
+		         "^alias\\s-+\\(\\S-+\\)\\s-+\\(.+\\)")
+		    (setq eshell-command-aliases-list
+			  (cons (list (match-string 1)
+				      (match-string 2))
+				eshell-command-aliases-list)))
 		  (forward-line 1))
 		eshell-command-aliases-list))))))
 
 (defun eshell-write-aliases-list ()
   "Write out the current aliases into `eshell-aliases-file'."
-  (if (file-writable-p (file-name-directory eshell-aliases-file))
-      (let ((eshell-current-handles
-	     (eshell-create-handles eshell-aliases-file 'overwrite)))
-	(eshell/alias)
-	(eshell-close-handles 0))))
+  (when (file-writable-p (file-name-directory eshell-aliases-file))
+    (let ((eshell-current-handles
+	   (eshell-create-handles eshell-aliases-file 'overwrite)))
+      (eshell/alias)
+      (eshell-close-handles 0))))
 
 (defsubst eshell-lookup-alias (name)
   "Check whether NAME is aliased.  Return the alias if there is one."
@@ -219,21 +219,21 @@ eshell-maybe-replace-by-alias
   (unless (and eshell-prevent-alias-expansion
 	       (member command eshell-prevent-alias-expansion))
     (let ((alias (eshell-lookup-alias command)))
-      (if alias
-	  (throw 'eshell-replace-command
-		 `(let ((eshell-command-name ',eshell-last-command-name)
-                        (eshell-command-arguments ',eshell-last-arguments)
-                        (eshell-prevent-alias-expansion
-                         ',(cons command eshell-prevent-alias-expansion)))
-                    ,(eshell-parse-command (nth 1 alias))))))))
+      (when alias
+	(throw 'eshell-replace-command
+	       `(let ((eshell-command-name ',eshell-last-command-name)
+                      (eshell-command-arguments ',eshell-last-arguments)
+                      (eshell-prevent-alias-expansion
+                       ',(cons command eshell-prevent-alias-expansion)))
+                  ,(eshell-parse-command (nth 1 alias))))))))
 
 (defun eshell-alias-completions (name)
   "Find all possible completions for NAME.
 These are all the command aliases which begin with NAME."
   (let (completions)
     (dolist (alias eshell-command-aliases-list)
-      (if (string-match (concat "^" name) (car alias))
-	  (setq completions (cons (car alias) completions))))
+      (when (string-match (concat "^" name) (car alias))
+	(setq completions (cons (car alias) completions))))
     completions))
 
 (defun eshell-fix-bad-commands (name)
diff --git a/lisp/eshell/em-basic.el b/lisp/eshell/em-basic.el
index 6cfc89cce6..d3cbcb183f 100644
--- a/lisp/eshell/em-basic.el
+++ b/lisp/eshell/em-basic.el
@@ -92,8 +92,8 @@ eshell-echo
 	     (mapcar
 	      (function
 	       (lambda (arg)
-		 (if (stringp arg)
-		     (set-text-properties 0 (length arg) nil arg))
+		 (when (stringp arg)
+		   (set-text-properties 0 (length arg) nil arg))
 		 arg))
 	      args)))))
       (if output-newline
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index 8a444c9100..69cefdda3a 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -285,9 +285,9 @@ eshell-cmpl-initialize
        eshell-cmpl-ignore-case)
   (set (make-local-variable 'pcomplete-autolist)
        eshell-cmpl-autolist)
-  (if (boundp 'pcomplete-suffix-list)
-      (set (make-local-variable 'pcomplete-suffix-list)
-           eshell-cmpl-suffix-list))
+  (when (boundp 'pcomplete-suffix-list)
+    (set (make-local-variable 'pcomplete-suffix-list)
+         eshell-cmpl-suffix-list))
   (set (make-local-variable 'pcomplete-recexact)
        eshell-cmpl-recexact)
   (set (make-local-variable 'pcomplete-man-function)
@@ -348,29 +348,29 @@ eshell-complete-parse-arguments
     (when (memq this-command '(pcomplete-expand
 			       pcomplete-expand-and-complete))
       (run-hook-with-args 'eshell-expand-input-functions begin end)
-      (if (= begin end)
-	  (end-of-line))
+      (when (= begin end)
+	(end-of-line))
       (setq end (point-marker)))
-    (if (setq delim
-	      (catch 'eshell-incomplete
-		(ignore
-		 (setq args (eshell-parse-arguments begin end)))))
-	(cond ((memq (car delim) '(?\{ ?\<))
-	       (setq begin (1+ (cadr delim))
-		     args (eshell-parse-arguments begin end)))
-	      ((eq (car delim) ?\()
-	       (eshell-complete-lisp-symbol)
-	       (throw 'pcompleted t))
-	      (t
-	       (insert-and-inherit "\t")
-	       (throw 'pcompleted t))))
+    (when (setq delim
+	        (catch 'eshell-incomplete
+		  (ignore
+		   (setq args (eshell-parse-arguments begin end)))))
+      (cond ((memq (car delim) '(?\{ ?\<))
+	     (setq begin (1+ (cadr delim))
+		   args (eshell-parse-arguments begin end)))
+	    ((eq (car delim) ?\()
+	     (eshell-complete-lisp-symbol)
+	     (throw 'pcompleted t))
+	    (t
+	     (insert-and-inherit "\t")
+	     (throw 'pcompleted t))))
     (when (get-text-property (1- end) 'comment)
       (insert-and-inherit "\t")
       (throw 'pcompleted t))
     (let ((pos begin))
       (while (< pos end)
-	(if (get-text-property pos 'arg-begin)
-	    (nconc posns (list pos)))
+	(when (get-text-property pos 'arg-begin)
+	  (nconc posns (list pos)))
 	(setq pos (1+ pos))))
     (setq posns (cdr posns))
     (cl-assert (= (length args) (length posns)))
@@ -378,9 +378,9 @@ eshell-complete-parse-arguments
 	  (i 0)
 	  l)
       (while a
-	(if (and (consp (car a))
-		 (eq (caar a) 'eshell-operator))
-	    (setq l i))
+	(when (and (consp (car a))
+		   (eq (caar a) 'eshell-operator))
+	  (setq l i))
 	(setq a (cdr a) i (1+ i)))
       (and l
 	   (setq args (nthcdr (1+ l) args)
@@ -401,8 +401,8 @@ eshell-complete-parse-arguments
 			   (cl-assert (eq (car result) 'quote))
 			   (cadr result))
 		       arg)))
-		(if (numberp val)
-		    (setq val (number-to-string val)))
+		(when (numberp val)
+		  (setq val (number-to-string val)))
 		(or val ""))))
 	   args)
 	  posns)))
@@ -414,11 +414,11 @@ eshell-complete-commands-list
         (if eshell-force-execution
             (pcomplete-dirs-or-entries nil #'file-readable-p)
           (pcomplete-executables))
-      (if (and (> (length filename) 0)
-	       (eq (aref filename 0) eshell-explicit-command-char))
-	  (setq filename (substring filename 1)
-		pcomplete-stub filename
-		glob-name t))
+      (when (and (> (length filename) 0)
+	         (eq (aref filename 0) eshell-explicit-command-char))
+	(setq filename (substring filename 1)
+	      pcomplete-stub filename
+	      glob-name t))
       (let* ((paths (eshell-get-path))
 	     (cwd (file-name-as-directory
 		   (expand-file-name default-directory)))
@@ -436,13 +436,13 @@ eshell-complete-commands-list
 	  (while comps-in-path
 	    (setq file (car comps-in-path)
 		  filepath (concat path file))
-	    (if (and (not (member file completions)) ;
-		     (or (string-equal path cwd)
-			 (not (file-directory-p filepath)))
-                     (if eshell-force-execution
-                         (file-readable-p filepath)
-                       (file-executable-p filepath)))
-		(setq completions (cons file completions)))
+	    (when (and (not (member file completions)) ;
+		       (or (string-equal path cwd)
+			   (not (file-directory-p filepath)))
+                       (if eshell-force-execution
+                           (file-readable-p filepath)
+                         (file-executable-p filepath)))
+	      (setq completions (cons file completions)))
 	    (setq comps-in-path (cdr comps-in-path)))
 	  (setq paths (cdr paths)))
 	;; Add aliases which are currently visible, and Lisp functions.
@@ -450,8 +450,8 @@ eshell-complete-commands-list
 	 (if glob-name
 	     completions
 	   (setq completions
-		 (append (if (fboundp 'eshell-alias-completions)
-			      (eshell-alias-completions filename))
+		 (append (when (fboundp 'eshell-alias-completions)
+			   (eshell-alias-completions filename))
 			 (eshell-winnow-list
 			  (mapcar
 			   (function
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 51df6fa1d5..d6a964c881 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -208,9 +208,9 @@ eshell-dirs-initialize
 
   (add-hook 'eshell-parse-argument-hook
 	    #'eshell-parse-user-reference nil t)
-  (if (eshell-under-windows-p)
-      (add-hook 'eshell-parse-argument-hook
-		#'eshell-parse-drive-letter nil t))
+  (when (eshell-under-windows-p)
+    (add-hook 'eshell-parse-argument-hook
+	      #'eshell-parse-drive-letter nil t))
 
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
@@ -219,8 +219,8 @@ eshell-dirs-initialize
   (make-local-variable 'eshell-dirstack)
   (make-local-variable 'eshell-last-dir-ring)
 
-  (if eshell-last-dir-ring-file-name
-      (eshell-read-last-dir-ring))
+  (when eshell-last-dir-ring-file-name
+    (eshell-read-last-dir-ring))
   (unless eshell-last-dir-ring
     (setq eshell-last-dir-ring (make-ring eshell-last-dir-ring-size)))
 
@@ -231,16 +231,16 @@ eshell-dirs-initialize
 (defun eshell-save-some-last-dir ()
   "Save the list-dir-ring for any open Eshell buffers."
   (dolist (buf (buffer-list))
-    (if (buffer-live-p buf)
-	(with-current-buffer buf
-	  (if (and eshell-mode
+    (when (buffer-live-p buf)
+      (with-current-buffer buf
+	(when (and eshell-mode
 		   eshell-ask-to-save-last-dir
 		   (or (eq eshell-ask-to-save-last-dir 'always)
 		       (y-or-n-p
-			(format-message
-			 "Save last dir ring for Eshell buffer `%s'? "
-			 (buffer-name buf)))))
-	      (eshell-write-last-dir-ring))))))
+		        (format-message
+		         "Save last dir ring for Eshell buffer `%s'? "
+		         (buffer-name buf)))))
+	  (eshell-write-last-dir-ring))))))
 
 (defun eshell-lone-directory-p (file)
   "Test whether FILE is just a directory name, and not a command name."
@@ -298,11 +298,11 @@ eshell/pwd
   "Change output from `pwd' to be cleaner."
   (let* ((path default-directory)
 	 (len (length path)))
-    (if (and (> len 1)
-	     (eq (aref path (1- len)) ?/)
-	     (not (and (eshell-under-windows-p)
-		       (string-match "\\`[A-Za-z]:[\\/]\\'" path))))
-	(setq path (substring path 0 (1- (length path)))))
+    (when (and (> len 1)
+	       (eq (aref path (1- len)) ?/)
+	       (not (and (eshell-under-windows-p)
+		         (string-match "\\`[A-Za-z]:[\\/]\\'" path))))
+      (setq path (substring path 0 (1- (length path)))))
     (funcall (or eshell-pwd-convert-function #'identity) path)))
 
 (defun eshell-expand-multiple-dots (filename)
@@ -335,13 +335,13 @@ eshell-find-previous-directory
   (let ((index 0)
 	(len (ring-length eshell-last-dir-ring))
 	oldpath)
-    (if (> (length regexp) 0)
-	(while (< index len)
-	  (setq oldpath (ring-ref eshell-last-dir-ring index))
-	  (if (string-match regexp oldpath)
-	      (setq index len)
-	    (setq oldpath nil
-		  index (1+ index)))))
+    (when (> (length regexp) 0)
+      (while (< index len)
+	(setq oldpath (ring-ref eshell-last-dir-ring index))
+	(if (string-match regexp oldpath)
+	    (setq index len)
+	  (setq oldpath nil
+		index (1+ index)))))
     oldpath))
 
 (defun eshell/cd (&rest args)           ; all but first ignored
@@ -351,10 +351,10 @@ eshell/cd
 	(subpath (car (cdr args)))
 	(case-fold-search (eshell-under-windows-p))
 	handled)
-    (if (numberp path)
-	(setq path (number-to-string path)))
-    (if (numberp subpath)
-	(setq subpath (number-to-string subpath)))
+    (when (numberp path)
+      (setq path (number-to-string path)))
+    (when (numberp subpath)
+      (setq subpath (number-to-string subpath)))
     (cond
      (subpath
       (let ((curdir (eshell/pwd)))
@@ -375,8 +375,8 @@ eshell/cd
 	    (setq path oldpath)
 	  (let ((len (ring-length eshell-last-dir-ring))
 		(index 0))
-	    (if (= len 0)
-		(error "Directory ring empty"))
+	    (when (= len 0)
+	      (error "Directory ring empty"))
 	    (eshell-init-print-buffer)
 	    (while (< index len)
 	      (eshell-buffered-print
@@ -408,13 +408,13 @@ eshell-add-to-dir-ring
   "Add PATH to the last-dir-ring, if applicable."
   (unless (and (not (ring-empty-p eshell-last-dir-ring))
 	       (equal path (ring-ref eshell-last-dir-ring 0)))
-    (if eshell-last-dir-unique
-	(let ((index 0)
-	      (len (ring-length eshell-last-dir-ring)))
-	  (while (< index len)
-	    (if (equal (ring-ref eshell-last-dir-ring index) path)
-		(ring-remove eshell-last-dir-ring index)
-	      (setq index (1+ index))))))
+    (when eshell-last-dir-unique
+      (let ((index 0)
+	    (len (ring-length eshell-last-dir-ring)))
+	(while (< index len)
+	  (if (equal (ring-ref eshell-last-dir-ring index) path)
+	      (ring-remove eshell-last-dir-ring index)
+	    (setq index (1+ index))))))
     (ring-insert eshell-last-dir-ring path)))
 
 ;;; pushd [+n | dir]
@@ -459,9 +459,9 @@ eshell/pushd
       ;; pushd <dir>
       (let ((old-wd (eshell/pwd)))
 	(eshell/cd path)
-	(if (or (null eshell-pushd-dunique)
-		(not (member old-wd eshell-dirstack)))
-	    (setq eshell-dirstack (cons old-wd eshell-dirstack)))
+	(when (or (null eshell-pushd-dunique)
+		  (not (member old-wd eshell-dirstack)))
+	  (setq eshell-dirstack (cons old-wd eshell-dirstack)))
 	(eshell/dirs t)))))
   nil)
 
@@ -546,7 +546,7 @@ eshell-read-last-dir-ring
 (defun eshell-write-last-dir-ring ()
   "Write the buffer's `eshell-last-dir-ring' to a history file."
   (let* ((file eshell-last-dir-ring-file-name)
-	 (resolved-file (if (stringp file) (file-truename file))))
+	 (resolved-file (when (stringp file) (file-truename file))))
     (cond
      ((or (null file)
 	  (equal file "")
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index a32a6abe29..7d534d85f7 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -257,8 +257,8 @@ eshell-extended-glob
 	    (eshell-glob-entries (file-name-as-directory (car paths))
 				 (cdr paths))
 	  (eshell-glob-entries (file-name-as-directory ".") paths))
-      (if message-shown
-	  (message nil)))
+      (when message-shown
+	(message nil)))
     (or (and eshell-glob-matches (sort eshell-glob-matches #'string<))
 	(if eshell-error-if-no-glob
 	    (error "No matches found: %s" glob)
@@ -286,8 +286,8 @@ eshell-glob-entries
 		   globs (cdr globs)
 		   glob (car globs)
 		   len (length glob)))))
-    (if (and recurse-p (not glob))
-	(error "`**' cannot end a globbing pattern"))
+    (when (and recurse-p (not glob))
+      (error "`**' cannot end a globbing pattern"))
     (let ((index 1))
       (setq incl glob)
       (while (and (eq incl glob)
@@ -300,12 +300,12 @@ eshell-glob-entries
     ;; can't use `directory-file-name' because it strips away text
     ;; properties in the string
     (let ((len (1- (length incl))))
-      (if (eq (aref incl len) ?/)
-	  (setq incl (substring incl 0 len)))
+      (when (eq (aref incl len) ?/)
+	(setq incl (substring incl 0 len)))
       (when excl
 	(setq len (1- (length excl)))
-	(if (eq (aref excl len) ?/)
-	    (setq excl (substring excl 0 len)))))
+	(when (eq (aref excl len) ?/)
+	  (setq excl (substring excl 0 len)))))
     (setq incl (eshell-glob-regexp incl)
 	  excl (and excl (eshell-glob-regexp excl)))
     (if (or eshell-glob-include-dot-files
@@ -322,28 +322,28 @@ eshell-glob-entries
       (message "Building file list...%d so far: %s"
 	       (length eshell-glob-matches) path)
       (setq message-shown t))
-    (if (equal path "./") (setq path ""))
+    (when (equal path "./") (setq path ""))
     (while entries
       (setq name (car entries)
 	    len (length name)
 	    isdir (eq (aref name (1- len)) ?/))
-      (if (let ((fname (directory-file-name name)))
-	    (and (not (and excl (string-match excl fname)))
-		 (string-match incl fname)))
-	  (if (cdr globs)
-	      (if isdir
-		  (setq dirs (cons (concat path name) dirs)))
-	    (setq eshell-glob-matches
-		  (cons (concat path name) eshell-glob-matches))))
-      (if (and recurse-p isdir
-	       (or (> len 3)
-		   (not (or (and (= len 2) (equal name "./"))
-			    (and (= len 3) (equal name "../")))))
-	       (setq pathname (concat path name))
-	       (not (and (= recurse-p 2)
-			 (file-symlink-p
-			  (directory-file-name pathname)))))
-	  (setq rdirs (cons pathname rdirs)))
+      (when (let ((fname (directory-file-name name)))
+	      (and (not (and excl (string-match excl fname)))
+		   (string-match incl fname)))
+	(if (cdr globs)
+	    (when isdir
+	      (setq dirs (cons (concat path name) dirs)))
+	  (setq eshell-glob-matches
+		(cons (concat path name) eshell-glob-matches))))
+      (when (and recurse-p isdir
+	         (or (> len 3)
+		     (not (or (and (= len 2) (equal name "./"))
+			      (and (= len 3) (equal name "../")))))
+	         (setq pathname (concat path name))
+	         (not (and (= recurse-p 2)
+			   (file-symlink-p
+			    (directory-file-name pathname)))))
+	(setq rdirs (cons pathname rdirs)))
       (setq entries (cdr entries)))
     (setq dirs (nreverse dirs)
 	  rdirs (nreverse rdirs))
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 5cee1bad36..d089498f33 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -265,9 +265,9 @@ eshell-hist-initialize
 	(add-hook 'isearch-mode-hook
 		  (function
 		   (lambda ()
-		     (if (>= (point) eshell-last-output-end)
-			 (setq overriding-terminal-local-map
-			       eshell-isearch-map))))
+		     (when (>= (point) eshell-last-output-end)
+		       (setq overriding-terminal-local-map
+			     eshell-isearch-map))))
                   nil t)
 	(add-hook 'isearch-mode-end-hook
 		  (function
@@ -296,8 +296,8 @@ eshell-hist-initialize
   (if (minibuffer-window-active-p (selected-window))
       (set (make-local-variable 'eshell-save-history-on-exit) nil)
     (set (make-local-variable 'eshell-history-ring) nil)
-    (if eshell-history-file-name
-	(eshell-read-history nil t))
+    (when eshell-history-file-name
+      (eshell-read-history nil t))
 
     (add-hook 'eshell-exit-hook #'eshell-write-history nil t))
 
@@ -314,17 +314,17 @@ eshell-hist-initialize
 (defun eshell-save-some-history ()
   "Save the history for any open Eshell buffers."
   (dolist (buf (buffer-list))
-    (if (buffer-live-p buf)
-	(with-current-buffer buf
-	  (if (and eshell-mode
+    (when (buffer-live-p buf)
+      (with-current-buffer buf
+	(when (and eshell-mode
 		   eshell-history-file-name
 		   eshell-save-history-on-exit
 		   (or (eq eshell-save-history-on-exit t)
 		       (y-or-n-p
-			(format-message
-			 "Save input history for Eshell buffer `%s'? "
-			 (buffer-name buf)))))
-	      (eshell-write-history))))))
+		        (format-message
+		         "Save input history for Eshell buffer `%s'? "
+		         (buffer-name buf)))))
+	  (eshell-write-history))))))
 
 (defun eshell/history (&rest args)
   "List in help buffer the buffer's input history."
@@ -389,12 +389,12 @@ eshell-add-input-to-history
 Input is entered into the input history ring, if the value of
 variable `eshell-input-filter' returns non-nil when called on the
 input."
-  (if (and (funcall eshell-input-filter input)
-	   (or (null eshell-hist-ignoredups)
-	       (not (ring-p eshell-history-ring))
-	       (ring-empty-p eshell-history-ring)
-	       (not (string-equal (eshell-get-history 0) input))))
-      (eshell-put-history input))
+  (when (and (funcall eshell-input-filter input)
+	     (or (null eshell-hist-ignoredups)
+	         (not (ring-p eshell-history-ring))
+	         (ring-empty-p eshell-history-ring)
+	         (not (string-equal (eshell-get-history 0) input))))
+    (eshell-put-history input))
   (setq eshell-save-history-index eshell-history-index)
   (setq eshell-history-index nil))
 
@@ -455,11 +455,11 @@ eshell-read-history
 		      (re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
 					  nil t))
 	    (let ((history (match-string 1)))
-	      (if (or (null ignore-dups)
-		      (ring-empty-p ring)
-		      (not (string-equal (ring-ref ring 0) history)))
-		  (ring-insert-at-beginning
-		   ring (subst-char-in-string ?\177 ?\n history))))
+	      (when (or (null ignore-dups)
+		        (ring-empty-p ring)
+		        (not (string-equal (ring-ref ring 0) history)))
+		(ring-insert-at-beginning
+		 ring (subst-char-in-string ?\177 ?\n history))))
 	    (setq count (1+ count))))
 	(setq eshell-history-ring ring
 	      eshell-history-index nil))))))
@@ -475,7 +475,7 @@ eshell-write-history
 
 See also `eshell-read-history'."
   (let* ((file (or filename eshell-history-file-name))
-	 (resolved-file (if (stringp file) (file-truename file))))
+	 (resolved-file (when (stringp file) (file-truename file))))
     (cond
      ((or (null file)
 	  (equal file "")
@@ -506,9 +506,9 @@ eshell-list-history
   (interactive)
   (let (prefix prelen)
     (save-excursion
-      (if (re-search-backward "!\\(.+\\)" (line-beginning-position) t)
-	  (setq prefix (match-string 1)
-		prelen (length prefix))))
+      (when (re-search-backward "!\\(.+\\)" (line-beginning-position) t)
+	(setq prefix (match-string 1)
+	      prelen (length prefix))))
     (if (or (not (ring-p eshell-history-ring))
 	    (ring-empty-p eshell-history-ring))
 	(message "No history")
@@ -519,10 +519,10 @@ eshell-list-history
 	;; We have to build up a list ourselves from the ring vector.
 	(while (>= index 0)
 	  (let ((hist (eshell-get-history index)))
-	    (if (or (not prefix)
-		    (and (>= (length hist) prelen)
-			 (string= (substring hist 0 prelen) prefix)))
-		(setq history (cons hist history))))
+	    (when (or (not prefix)
+		      (and (>= (length hist) prelen)
+			   (string= (substring hist 0 prelen) prefix)))
+	      (setq history (cons hist history))))
 	  (setq index (1- index)))
 	;; Change "completion" to "history reference"
 	;; to make the display accurate.
@@ -564,13 +564,13 @@ eshell-hist-parse-arguments
       (save-excursion
 	(goto-char begin)
 	(while (< (point) end)
-	  (if (get-text-property (point) 'arg-begin)
-	      (nconc posb (list (point))))
-	  (if (get-text-property (point) 'arg-end)
-	      (nconc pose
-		     (list (if (= (1+ (point)) end)
-			       (1+ (point))
-			     (point)))))
+	  (when (get-text-property (point) 'arg-begin)
+	    (nconc posb (list (point))))
+	  (when (get-text-property (point) 'arg-end)
+	    (nconc pose
+		   (list (if (= (1+ (point)) end)
+			     (1+ (point))
+			   (point)))))
 	  (forward-char))
 	(setq posb (cdr posb)
 	      pose (cdr pose))
@@ -633,12 +633,12 @@ eshell-complete-history-reference
 	       ;; vector.
 	       (while (>= index 0)
 		 (let ((hist (eshell-get-history index)))
-		   (if (and (>= (length hist) stublen)
-			    (string= (substring hist 0 stublen)
-				     pcomplete-stub)
-			    (string-match "^\\([^:^$*% \t\n]+\\)" hist))
-		       (setq history (cons (match-string 1 hist)
-					   history))))
+		   (when (and (>= (length hist) stublen)
+			      (string= (substring hist 0 stublen)
+				       pcomplete-stub)
+			      (string-match "^\\([^:^$*% \t\n]+\\)" hist))
+		     (setq history (cons (match-string 1 hist)
+					 history))))
 		 (setq index (1- index)))
 	       (let ((fhist (list t)))
 		 ;; uniquify the list, but preserve the order
@@ -740,11 +740,11 @@ eshell-hist-parse-word-designator
       (insert hist)
       (setq textargs (car (eshell-hist-parse-arguments here (point))))
       (delete-region here (point))
-      (if (string= nth "*")
-	  (if mth
-	      (error "Invalid history word designator `%s'"
-		     reference)
-	    (setq nth 1 mth "-$")))
+      (when (string= nth "*")
+	(if mth
+	    (error "Invalid history word designator `%s'"
+		   reference)
+	  (setq nth 1 mth "-$")))
       (if (not mth)
 	  (if nth
 	      (setq mth nth)
@@ -793,9 +793,9 @@ eshell-get-next-from-history
 (defun eshell-search-arg (arg)
   ;; First make sure there is a ring and that we are after the process
   ;; mark
-  (if (and eshell-hist-move-to-end
-	   (< (point) eshell-last-output-end))
-      (goto-char eshell-last-output-end))
+  (when (and eshell-hist-move-to-end
+	     (< (point) eshell-last-output-end))
+    (goto-char eshell-last-output-end))
   (cond ((or (null eshell-history-ring)
 	     (ring-empty-p eshell-history-ring))
 	 (error "Empty input ring"))
@@ -841,15 +841,15 @@ eshell-previous-matching-input-string
   "Return the string matching REGEXP ARG places along the input ring.
 Moves relative to `eshell-history-index'."
   (let* ((pos (eshell-previous-matching-input-string-position regexp arg)))
-    (if pos (eshell-get-history pos))))
+    (when pos (eshell-get-history pos))))
 
 (defun eshell-previous-matching-input-string-position
   (regexp arg &optional start)
   "Return the index matching REGEXP ARG places along the input ring.
 Moves relative to START, or `eshell-history-index'."
-  (if (or (not (ring-p eshell-history-ring))
-	  (ring-empty-p eshell-history-ring))
-      (error "No history"))
+  (when (or (not (ring-p eshell-history-ring))
+	    (ring-empty-p eshell-history-ring))
+    (error "No history"))
   (let* ((len (ring-length eshell-history-ring))
 	 (motion (if (> arg 0) 1 -1))
 	 (n (mod (- (or start (eshell-search-start arg)) motion) len))
@@ -870,8 +870,8 @@ eshell-previous-matching-input-string-position
       (setq arg (if (> arg 0) (1- arg) (1+ arg))))
     ;; Now that we know which ring element to use, if we found it,
     ;; return that.
-    (if (string-match regexp (eshell-get-history n))
-	n)))
+    (when (string-match regexp (eshell-get-history n))
+      n)))
 
 (defun eshell-previous-matching-input (regexp arg)
   "Search backwards through input history for match for REGEXP.
@@ -880,8 +880,8 @@ eshell-previous-matching-input
 If N is negative, find the next or Nth next match."
   (interactive (eshell-regexp-arg "Previous input matching (regexp): "))
   (setq arg (eshell-search-arg arg))
-  (if (> eshell-last-output-end (point))
-      (error "Point not located after prompt"))
+  (when (> eshell-last-output-end (point))
+    (error "Point not located after prompt"))
   (let ((pos (eshell-previous-matching-input-string-position regexp arg)))
     ;; Has a match been found?
     (if (null pos)
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index c1a022ee52..f9d4e91ca1 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -185,8 +185,8 @@ eshell-ls-clutter
 
 (defsubst eshell-ls-filetype-p (attrs type)
   "Test whether ATTRS specifies a file of type TYPE."
-  (if (file-attribute-modes attrs)
-      (eq (aref (file-attribute-modes attrs) 0) type)))
+  (when (file-attribute-modes attrs)
+    (eq (aref (file-attribute-modes attrs) 0) type)))
 
 (defmacro eshell-ls-applicable (attrs index func file)
   "Test whether, for ATTRS, the user can do what corresponds to INDEX.
@@ -264,8 +264,8 @@ eshell-ls--insert-directory
       (if handler
           (funcall handler 'insert-directory file switches
                    wildcard full-directory-p)
-        (if (stringp switches)
-            (setq switches (split-string switches)))
+        (when (stringp switches)
+          (setq switches (split-string switches)))
         (let (eshell-current-handles
               eshell-current-subjob-p
               font-lock-mode)
@@ -274,10 +274,10 @@ eshell-ls--insert-directory
                      (featurep 'font-lock))
             (font-lock-mode -1)
             (setq font-lock-defaults nil)
-            (if (boundp 'font-lock-buffers)
-                (set 'font-lock-buffers
-                     (delq (current-buffer)
-                           (symbol-value 'font-lock-buffers)))))
+            (when (boundp 'font-lock-buffers)
+              (set 'font-lock-buffers
+                   (delq (current-buffer)
+                         (symbol-value 'font-lock-buffers)))))
           (require 'em-glob)
           (let* ((insert-func 'insert)
                  (error-func 'insert)
@@ -497,8 +497,8 @@ eshell-ls-file
 	    (funcall insert-func file "\n"))
 	(let ((line
 	       (concat
-		(if show-size
-		    (concat (eshell-ls-size-string attrs size-width) " "))
+		(when show-size
+		  (concat (eshell-ls-size-string attrs size-width) " "))
 		(format
 		 (if numeric-uid-gid
 		     "%s%4d %-8s %-8s "
@@ -549,14 +549,14 @@ eshell-ls-dir
 	(funcall error-func (format "%s: No such file or directory\n" dir))
       (if dir-literal
 	  (eshell-ls-file dirinfo size-width)
-	(if insert-name
-	    (funcall insert-func
-		     (eshell-ls-decorated-name
-		      (cons (concat
-			     (if root-dir
-				 (file-relative-name dir root-dir)
-			       (expand-file-name dir)))
-			    (cdr dirinfo))) ":\n"))
+	(when insert-name
+	  (funcall insert-func
+		   (eshell-ls-decorated-name
+		    (cons (concat
+			   (if root-dir
+			       (file-relative-name dir root-dir)
+			     (expand-file-name dir)))
+			  (cdr dirinfo))) ":\n"))
 	(let ((entries (eshell-directory-files-and-attributes
 			dir nil (and (not (or show-all show-almost-all))
 				     eshell-ls-exclude-hidden
@@ -587,16 +587,16 @@ eshell-ls-dir
 	    (let ((total 0.0))
 	      (setq size-width 0)
 	      (dolist (e entries)
-		(if (file-attribute-size (cdr e))
-		    (setq total (+ total (file-attribute-size (cdr e)))
-			  size-width
-			  (max size-width
-			       (length (eshell-ls-printable-size
-					(file-attribute-size (cdr e))
-					(not
-					 ;; If we are under -l, count length
-					 ;; of sizes in bytes, not in blocks.
-					 (eq listing-style 'long-listing))))))))
+		(when (file-attribute-size (cdr e))
+		  (setq total (+ total (file-attribute-size (cdr e)))
+			size-width
+			(max size-width
+			     (length (eshell-ls-printable-size
+				      (file-attribute-size (cdr e))
+				      (not
+				       ;; If we are under -l, count length
+				       ;; of sizes in bytes, not in blocks.
+				       (eq listing-style 'long-listing))))))))
 	      (funcall insert-func "total "
 		       (eshell-ls-printable-size total t) "\n")))
 	  (let ((default-directory (expand-file-name dir)))
@@ -677,8 +677,8 @@ eshell-ls-files
 	       (not (eq listing-style 'by-lines)))
 	  (memq listing-style '(long-listing single-column)))
       (dolist (file files)
-	(if file
-	    (eshell-ls-file file size-width copy-fileinfo)))
+	(when file
+	  (eshell-ls-file file size-width copy-fileinfo)))
     (let ((f files)
 	  last-f
 	  display-files
@@ -704,8 +704,8 @@ eshell-ls-files
 	(dolist (file files)
 	  (let* ((str (eshell-ls-printable-size (file-attribute-size (cdr file)) t))
 		 (len (length str)))
-	    (if (< len size-width)
-		(setq str (concat (make-string (- size-width len) ? ) str)))
+	    (when (< len size-width)
+	      (setq str (concat (make-string (- size-width len) ? ) str)))
 	    (setq file (eshell-ls-annotate file)
 		  display-files (cons (cons (concat str " " (car file))
 					    (cdr file))
@@ -741,8 +741,8 @@ eshell-ls-files
 		      col-index (1+ col-index))
 	      (funcall insert-func need-return name "\n")
 	      (setq col-index 1 need-return nil))))
-	(if need-return
-	    (funcall insert-func need-return "\n"))))))
+	(when need-return
+	  (funcall insert-func need-return "\n"))))))
 
 (defun eshell-ls-entries (entries &optional separate root-dir)
   "Output PATH's directory ENTRIES.
@@ -765,17 +765,17 @@ eshell-ls-entries
 	    (unless separate
 	      (setq files (cons entry files)
 		    size-width
-		    (if show-size
-			(max size-width
-			     (length (eshell-ls-printable-size
-				      (file-attribute-size (cdr entry)) t))))))
+		    (when show-size
+		      (max size-width
+			   (length (eshell-ls-printable-size
+				    (file-attribute-size (cdr entry)) t))))))
 	    (setq dirs (cons entry dirs)))
 	(setq files (cons entry files)
 	      size-width
-	      (if show-size
-		  (max size-width
-		       (length (eshell-ls-printable-size
-				(file-attribute-size (cdr entry)) t)))))))
+	      (when show-size
+		(max size-width
+		     (length (eshell-ls-printable-size
+			      (file-attribute-size (cdr entry)) t)))))))
     (when files
       (eshell-ls-files (eshell-ls-sort-entries files)
 		       size-width show-recursive)
@@ -783,8 +783,8 @@ eshell-ls-entries
     (setq show-names (or show-recursive
 			 (> (+ (length files) (length dirs)) 1)))
     (dolist (dir (eshell-ls-sort-entries dirs))
-      (if (and need-return (not dir-literal))
-	  (funcall insert-func "\n"))
+      (when (and need-return (not dir-literal))
+	(funcall insert-func "\n"))
       (eshell-ls-dir dir show-names
 		     (unless (file-name-absolute-p (car dir)) root-dir)
 		     size-width)
@@ -821,18 +821,18 @@ eshell-ls-find-column-widths
 	    (colw (make-vector numcols 0))
 	    (w widths))
 	(while w
-	  (if (= i numcols)
-	      (setq i 0))
+	  (when (= i numcols)
+	    (setq i 0))
 	  (aset colw i (max (aref colw i) (car w)))
 	  (setq w (cdr w) i (1+ i)))
 	(setq i 0 width 0)
 	(while (< i numcols)
 	  (setq width (+ width (aref colw i))
 		i (1+ i)))
-	(if (and (< width max-width)
-		 (> width best-width))
-	    (setq col-widths colw
-		  best-width width)))
+	(when (and (< width max-width)
+		   (> width best-width))
+	  (setq col-widths colw
+		best-width width)))
       (setq numcols (1- numcols)))
 
     (cons (or col-widths (vector max-width)) files)))
@@ -868,8 +868,8 @@ eshell-ls-find-column-lengths
 			(float (1- numcols))))
 	  (setq colw (make-vector numcols 0))
 	  (while (> len 0)
-	    (if (= i numcols)
-		(setq i 0 index (1+ index)))
+	    (when (= i numcols)
+	      (setq i 0 index (1+ index)))
 	    (aset colw i
 		  (max (aref colw i)
 		       (or (nth (+ (* i rows) index) w) 0)))
@@ -880,8 +880,8 @@ eshell-ls-find-column-lengths
 		  i (1+ i))))
 	(if (>= width max-width)
 	    (setq numcols nil)
-	  (if colw
-	      (setq col-widths colw))
+	  (when colw
+	    (setq col-widths colw))
 	  (if (>= numcols (length widths))
 	      (setq numcols nil)
 	    (setq numcols (1+ numcols))))))
@@ -897,8 +897,8 @@ eshell-ls-find-column-lengths
 	     (i 0)
 	     (j 0))
 	(while (< j len)
-	  (if (= i numcols)
-	      (setq i 0 index (1+ index)))
+	  (when (= i numcols)
+	    (setq i 0 index (1+ index)))
 	  (setcar (nthcdr j newfiles)
 		  (nth (+ (* i rows) index) files))
 	  (setq j (1+ j) i (1+ i)))
@@ -906,57 +906,57 @@ eshell-ls-find-column-lengths
 
 (defun eshell-ls-decorated-name (file)
   "Return FILE, possibly decorated."
-  (if eshell-ls-use-colors
-      (let ((face
-	     (cond
-	      ((not (cdr file))
-	       'eshell-ls-missing)
-
-	      ((stringp (cadr file))
-	       'eshell-ls-symlink)
-
-	      ((eq (cadr file) t)
-	       'eshell-ls-directory)
-
-	      ((not (eshell-ls-filetype-p (cdr file) ?-))
-	       'eshell-ls-special)
-
-	      ((and (/= (user-uid) 0) ; root can execute anything
-		    (eshell-ls-applicable (cdr file) 3
-					  'file-executable-p (car file)))
-	       'eshell-ls-executable)
-
-	      ((not (eshell-ls-applicable (cdr file) 1
-					  'file-readable-p (car file)))
-	       'eshell-ls-unreadable)
-
-	      ((string-match eshell-ls-archive-regexp (car file))
-	       'eshell-ls-archive)
-
-	      ((string-match eshell-ls-backup-regexp (car file))
-	       'eshell-ls-backup)
-
-	      ((string-match eshell-ls-product-regexp (car file))
-	       'eshell-ls-product)
-
-	      ((string-match eshell-ls-clutter-regexp (car file))
-	       'eshell-ls-clutter)
-
-	      ((not (eshell-ls-applicable (cdr file) 2
-					  'file-writable-p (car file)))
-	       'eshell-ls-readonly)
-	      (eshell-ls-highlight-alist
-	       (let ((tests eshell-ls-highlight-alist)
-		     value)
-		 (while tests
-		   (if (funcall (caar tests) (car file) (cdr file))
-		       (setq value (cdar tests) tests nil)
-		     (setq tests (cdr tests))))
-		 value)))))
-	(if face
-	    (add-text-properties 0 (length (car file))
-				 (list 'font-lock-face face)
-				 (car file)))))
+  (when eshell-ls-use-colors
+    (let ((face
+	   (cond
+	    ((not (cdr file))
+	     'eshell-ls-missing)
+
+	    ((stringp (cadr file))
+	     'eshell-ls-symlink)
+
+	    ((eq (cadr file) t)
+	     'eshell-ls-directory)
+
+	    ((not (eshell-ls-filetype-p (cdr file) ?-))
+	     'eshell-ls-special)
+
+	    ((and (/= (user-uid) 0)     ; root can execute anything
+		  (eshell-ls-applicable (cdr file) 3
+					'file-executable-p (car file)))
+	     'eshell-ls-executable)
+
+	    ((not (eshell-ls-applicable (cdr file) 1
+					'file-readable-p (car file)))
+	     'eshell-ls-unreadable)
+
+	    ((string-match eshell-ls-archive-regexp (car file))
+	     'eshell-ls-archive)
+
+	    ((string-match eshell-ls-backup-regexp (car file))
+	     'eshell-ls-backup)
+
+	    ((string-match eshell-ls-product-regexp (car file))
+	     'eshell-ls-product)
+
+	    ((string-match eshell-ls-clutter-regexp (car file))
+	     'eshell-ls-clutter)
+
+	    ((not (eshell-ls-applicable (cdr file) 2
+					'file-writable-p (car file)))
+	     'eshell-ls-readonly)
+	    (eshell-ls-highlight-alist
+	     (let ((tests eshell-ls-highlight-alist)
+		   value)
+	       (while tests
+		 (if (funcall (caar tests) (car file) (cdr file))
+		     (setq value (cdar tests) tests nil)
+		   (setq tests (cdr tests))))
+	       value)))))
+      (when face
+	(add-text-properties 0 (length (car file))
+			     (list 'font-lock-face face)
+			     (car file)))))
   (car file))
 
 (defun eshell-ls-unload-function ()
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index c26f654e27..6746c68c99 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -86,9 +86,9 @@ eshell-predicate-alist
     (?S . (eshell-pred-file-mode 2000)) ; setgid
     (?t . (eshell-pred-file-mode 1000)) ; sticky bit
     (?U . #'(lambda (file)                   ; owned by effective uid
-              (if (file-exists-p file)
-                  (= (file-attribute-user-id (file-attributes file))
-		     (user-uid)))))
+              (when (file-exists-p file)
+                (= (file-attribute-user-id (file-attributes file))
+		   (user-uid)))))
     ;; (?G . #'(lambda (file)               ; owned by effective gid
     ;;          (if (file-exists-p file)
     ;;              (= (file-attribute-user-id (file-attributes file))
@@ -266,9 +266,9 @@ eshell-pred-initialize
 (defun eshell-apply-modifiers (lst predicates modifiers)
   "Apply to LIST a series of PREDICATES and MODIFIERS."
   (let (stringified)
-    (if (stringp lst)
-	(setq lst (list lst)
-	      stringified t))
+    (when (stringp lst)
+      (setq lst (list lst)
+	    stringified t))
     (when (listp lst)
       (setq lst (eshell-winnow-list lst nil predicates))
       (while modifiers
@@ -371,12 +371,12 @@ eshell-parse-modifiers
 
 (defun eshell-add-pred-func (pred funcs negate follow)
   "Add the predicate function PRED to FUNCS."
-  (if negate
-      (setq pred `(lambda (file)
-		    (not (funcall ,pred file)))))
-  (if follow
-      (setq pred `(lambda (file)
-		    (funcall ,pred (file-truename file)))))
+  (when negate
+    (setq pred `(lambda (file)
+		  (not (funcall ,pred file)))))
+  (when follow
+    (setq pred `(lambda (file)
+		  (funcall ,pred (file-truename file)))))
   (cons pred funcs))
 
 (defun eshell-pred-user-or-group (mod-char mod-type attr-index get-id-func)
@@ -404,8 +404,8 @@ eshell-pred-user-or-group
 	     mod-type mod-char))
     `(lambda (file)
        (let ((attrs (file-attributes file)))
-	 (if attrs
-	     (= (nth ,attr-index attrs) ,ugid))))))
+	 (when attrs
+	   (= (nth ,attr-index attrs) ,ugid))))))
 
 (defun eshell-pred-file-time (mod-char mod-type attr-index)
   "Return a predicate to test whether a file matches a certain time."
@@ -450,11 +450,11 @@ eshell-pred-file-time
       (goto-char (1+ end)))
     `(lambda (file)
        (let ((attrs (file-attributes file)))
-	 (if attrs
-             (,(cond ((eq qual ?-) #'time-less-p)
-                     ((eq qual ?+) (lambda (a b) (time-less-p b a)))
-                     (#'time-equal-p))
-	      ,when (nth ,attr-index attrs)))))))
+	 (when attrs
+           (,(cond ((eq qual ?-) #'time-less-p)
+                   ((eq qual ?+) (lambda (a b) (time-less-p b a)))
+                   (#'time-equal-p))
+	    ,when (nth ,attr-index attrs)))))))
 
 (defun eshell-pred-file-type (type)
   "Return a test which tests that the file is of a certain TYPE.
@@ -467,18 +467,18 @@ eshell-pred-file-type
       (setq type ?%)))
   `(lambda (file)
      (let ((attrs (eshell-file-attributes (directory-file-name file))))
-       (if attrs
-	   (memq (aref (file-attribute-modes attrs) 0)
-		 ,(if (eq type ?%)
-		      '(?b ?c)
-		    (list 'quote (list type))))))))
+       (when attrs
+	 (memq (aref (file-attribute-modes attrs) 0)
+	       ,(if (eq type ?%)
+		    '(?b ?c)
+		  (list 'quote (list type))))))))
 
 (defsubst eshell-pred-file-mode (mode)
   "Return a test which tests that MODE pertains to the file."
   `(lambda (file)
      (let ((modes (file-modes file 'nofollow)))
-       (if modes
-	   (logand ,mode modes)))))
+       (when modes
+	 (logand ,mode modes)))))
 
 (defun eshell-pred-file-links ()
   "Return a predicate to test whether a file has a given number of links."
@@ -492,13 +492,13 @@ eshell-pred-file-links
     (goto-char (match-end 0))
     `(lambda (file)
        (let ((attrs (eshell-file-attributes file)))
-	 (if attrs
-	     (,(if (eq qual ?-)
-		   '<
-		 (if (eq qual ?+)
-		     '>
-		   '=))
-	      (file-attribute-link-number attrs) ,amount))))))
+	 (when attrs
+	   (,(if (eq qual ?-)
+		 '<
+	       (if (eq qual ?+)
+		   '>
+		 '=))
+	    (file-attribute-link-number attrs) ,amount))))))
 
 (defun eshell-pred-file-size ()
   "Return a predicate to test whether a file is of a given size."
@@ -522,13 +522,13 @@ eshell-pred-file-size
     (goto-char (match-end 0))
     `(lambda (file)
        (let ((attrs (eshell-file-attributes file)))
-	 (if attrs
-	     (,(if (eq qual ?-)
-		   '<
-		 (if (eq qual ?+)
-		     '>
-		   '=))
-	      (file-attribute-size attrs) ,amount))))))
+	 (when attrs
+	   (,(if (eq qual ?-)
+		 '<
+	       (if (eq qual ?+)
+		   '>
+		 '=))
+	    (file-attribute-size attrs) ,amount))))))
 
 (defun eshell-pred-substitute (&optional repeat)
   "Return a modifier function that will substitute matches."
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 9ae5ae1281..37873cefc9 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -117,8 +117,8 @@ eshell-prompt-initialize
     (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t)
 
     (make-local-variable 'eshell-prompt-regexp)
-    (if eshell-prompt-regexp
-	(set (make-local-variable 'paragraph-start) eshell-prompt-regexp))
+    (when eshell-prompt-regexp
+      (set (make-local-variable 'paragraph-start) eshell-prompt-regexp))
 
     (set (make-local-variable 'eshell-skip-prompt-function)
 	 'eshell-skip-prompt)
@@ -150,8 +150,8 @@ eshell-backward-matching-input
   (interactive (eshell-regexp-arg "Backward input matching (regexp): "))
   (let* ((re (concat eshell-prompt-regexp ".*" regexp))
 	 (pos (save-excursion (end-of-line (if (> arg 0) 0 1))
-			      (if (re-search-backward re nil t arg)
-				  (point)))))
+			      (when (re-search-backward re nil t arg)
+				(point)))))
     (if (null pos)
 	(progn (message "Not found")
 	       (ding))
@@ -194,9 +194,9 @@ eshell-skip-prompt
   "Skip past the text matching regexp `eshell-prompt-regexp'.
 If this takes us past the end of the current line, don't skip at all."
   (let ((eol (line-end-position)))
-    (if (and (looking-at eshell-prompt-regexp)
-	     (<= (match-end 0) eol))
-	(goto-char (match-end 0)))))
+    (when (and (looking-at eshell-prompt-regexp)
+	       (<= (match-end 0) eol))
+      (goto-char (match-end 0)))))
 
 (provide 'em-prompt)
 
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el
index 7991c63177..3b5604f3d7 100644
--- a/lisp/eshell/em-rebind.el
+++ b/lisp/eshell/em-rebind.el
@@ -212,9 +212,9 @@ eshell-rebind-input-map
 	      (progn
 		(use-local-map eshell-input-keymap)
 		(goto-char begin)
-		(if (and eshell-error-if-move-away
-			 (not (eq this-command 'kill-region)))
-		    (beep)))
+		(when (and eshell-error-if-move-away
+			   (not (eq this-command 'kill-region)))
+		  (beep)))
 	    (use-local-map eshell-mode-map)))))))
 
 (defun eshell-setup-input-keymap ()
diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el
index 5c2f145f59..113c15971a 100644
--- a/lisp/eshell/em-script.el
+++ b/lisp/eshell/em-script.el
@@ -106,8 +106,8 @@ eshell-source-file
                              (list 'eshell-command-arguments
                                    (list 'quote args)))
                        (let ((cmd (eshell-parse-command (cons here (point)))))
-                         (if subcommand-p
-                             (setq cmd (list 'eshell-as-subcommand cmd)))
+                         (when subcommand-p
+                           (setq cmd (list 'eshell-as-subcommand cmd)))
                          cmd))
                (delete-region here (point))
                (goto-char orig))))))
diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el
index f173c8db9c..226de22204 100644
--- a/lisp/eshell/em-smart.el
+++ b/lisp/eshell/em-smart.el
@@ -211,14 +211,14 @@ eshell-refresh-windows
      (function
       (lambda (wind)
 	(with-current-buffer (window-buffer wind)
-	  (if eshell-mode
-	      (let (window-scroll-functions) ;;FIXME: Why?
-		(eshell-smart-scroll-window wind (window-start))
-		(setq affected t))))))
+	  (when eshell-mode
+	    (let (window-scroll-functions) ;;FIXME: Why?
+	      (eshell-smart-scroll-window wind (window-start))
+	      (setq affected t))))))
      0 frame)
-    (if affected
-	(let (window-scroll-functions) ;;FIXME: Why?
-	  (eshell-redisplay)))))
+    (when affected
+      (let (window-scroll-functions) ;;FIXME: Why?
+	(eshell-redisplay)))))
 
 (defun eshell-smart-display-setup ()
   "Set the point to somewhere in the beginning of the last command."
@@ -228,8 +228,8 @@ eshell-smart-display-setup
    ((eq eshell-where-to-jump 'after)
     (goto-char (next-single-property-change
 		eshell-last-input-start 'arg-end))
-    (if (= (point) (- eshell-last-input-end 2))
-	(forward-char)))
+    (when (= (point) (- eshell-last-input-end 2))
+      (forward-char)))
    ((eq eshell-where-to-jump 'end)
     (goto-char (1- eshell-last-input-end)))
    (t
@@ -272,14 +272,14 @@ eshell-smart-redisplay
 	   (< (point) eshell-last-input-end)
 	   (set-window-start (selected-window)
 			     (line-beginning-position) t))
-      (if (pos-visible-in-window-p (point-max))
-	  (save-excursion
-	    (goto-char (point-max))
-	    (recenter -1)
-	    (unless (pos-visible-in-window-p top-point)
-	      (goto-char top-point)
-	      (set-window-start (selected-window)
-				(line-beginning-position) t)))))))
+      (when (pos-visible-in-window-p (point-max))
+	(save-excursion
+	  (goto-char (point-max))
+	  (recenter -1)
+	  (unless (pos-visible-in-window-p top-point)
+	    (goto-char top-point)
+	    (set-window-start (selected-window)
+			      (line-beginning-position) t)))))))
 
 (defun eshell-smart-goto-end ()
   "Like `end-of-buffer', but do not push a mark."
@@ -315,16 +315,16 @@ eshell-smart-display-move
 		  (scroll-down))
 		(eshell-show-output))
 	    (scroll-down)
-	    (if (pos-visible-in-window-p eshell-last-input-end)
-		(eshell-show-output)))))
+	    (when (pos-visible-in-window-p eshell-last-input-end)
+	      (eshell-show-output)))))
        ((or (memq this-command eshell-smart-display-navigate-list)
 	    (and (eq this-command 'eshell-send-input)
 		 (not (and (>= (point) eshell-last-input-start)
 			   (< (point) eshell-last-input-end)))))
 	(setq clear t)
 	(goto-char (point-max)))))
-    (if clear
-	(remove-hook 'pre-command-hook 'eshell-smart-display-move t))))
+    (when clear
+      (remove-hook 'pre-command-hook 'eshell-smart-display-move t))))
 
 (provide 'em-smart)
 
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el
index f52b3cda73..d1c4e1af6b 100644
--- a/lisp/eshell/em-term.el
+++ b/lisp/eshell/em-term.el
@@ -188,8 +188,8 @@ eshell-exec-visual
 	    (set-process-sentinel proc #'eshell-term-sentinel)
 	  (error "Failed to invoke visual command")))
       (term-char-mode)
-      (if eshell-escape-control-x
-	  (term-set-escape-char ?\C-x))))
+      (when eshell-escape-control-x
+	(term-set-escape-char ?\C-x))))
   nil)
 
 ;; Process sentinels receive two arguments.
@@ -203,13 +203,13 @@ eshell-term-sentinel
       (when (and proc-buf (buffer-live-p proc-buf)
                  (not (eq 'run (process-status proc)))
                  (= (process-exit-status proc) 0))
-        (if (eq (current-buffer) proc-buf)
-            (let ((buf (and (boundp 'eshell-parent-buffer)
-                            eshell-parent-buffer
-                            (buffer-live-p eshell-parent-buffer)
-                            eshell-parent-buffer)))
-              (if buf
-                  (switch-to-buffer buf))))
+        (when (eq (current-buffer) proc-buf)
+          (let ((buf (and (boundp 'eshell-parent-buffer)
+                          eshell-parent-buffer
+                          (buffer-live-p eshell-parent-buffer)
+                          eshell-parent-buffer)))
+            (when buf
+              (switch-to-buffer buf))))
         (kill-buffer proc-buf)))))
 
 ;; jww (1999-09-17): The code below will allow Eshell to send input
diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el
index 01f7038e46..a2201ce86c 100644
--- a/lisp/eshell/em-tramp.el
+++ b/lisp/eshell/em-tramp.el
@@ -80,8 +80,8 @@ eshell/su
 	      (dolist (arg args)
 		(if (string-equal arg "-") (setq login t) (setq user arg)))
 	      ;; `eshell-eval-using-options' does not handle "-".
-	      (if (member "-" orig-args) (setq login t))
-	      (if login (setq dir "~/"))
+	      (when (member "-" orig-args) (setq login t))
+	      (when login (setq dir "~/"))
 	      (if (and prefix
 		       (or
 			(not (string-equal
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index fbd3cfbb6f..567ce097d8 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -199,14 +199,14 @@ eshell-remove-entries
   (while files
     (if (string-match "\\`\\.\\.?\\'"
 		      (file-name-nondirectory (car files)))
-	(if toplevel
-	    (eshell-error "rm: cannot remove `.' or `..'\n"))
+	(when toplevel
+	  (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
 	       (not (file-symlink-p (car files))))
 	  (progn
-	    (if em-verbose
-		(eshell-printn (format-message "rm: removing directory `%s'"
-					       (car files))))
+	    (when em-verbose
+	      (eshell-printn (format-message "rm: removing directory `%s'"
+					     (car files))))
 	    (unless
 		(or em-preview
 		    (and em-interactive
@@ -214,9 +214,9 @@ eshell-remove-entries
 			       (format-message "rm: remove directory `%s'? "
 					       (car files))))))
 	      (eshell-funcalln 'delete-directory (car files) t t)))
-	(if em-verbose
-	    (eshell-printn (format-message "rm: removing file `%s'"
-					   (car files))))
+	(when em-verbose
+	  (eshell-printn (format-message "rm: removing file `%s'"
+					 (car files))))
 	(unless (or em-preview
 		    (and em-interactive
 			 (not (y-or-n-p
@@ -248,8 +248,8 @@ eshell/rm
 Remove (unlink) the FILE(s).")
    (unless em-interactive
      (setq em-interactive eshell-rm-interactive-query))
-   (if (and force-removal em-interactive)
-       (setq em-interactive nil))
+   (when (and force-removal em-interactive)
+     (setq em-interactive nil))
    (while args
      (let ((entry (if (stringp (car args))
 		      (directory-file-name (car args))
@@ -258,8 +258,8 @@ eshell/rm
 		      (car args)))))
        (cond
 	((bufferp entry)
-	 (if em-verbose
-	     (eshell-printn (format-message "rm: removing buffer `%s'" entry)))
+	 (when em-verbose
+	   (eshell-printn (format-message "rm: removing buffer `%s'" entry)))
 	 (unless (or em-preview
 		     (and em-interactive
 			  (not (y-or-n-p (format-message
@@ -267,8 +267,8 @@ eshell/rm
 					  entry)))))
 	   (eshell-funcalln 'kill-buffer entry)))
 	((eshell-processp entry)
-	 (if em-verbose
-	     (eshell-printn (format-message "rm: killing process `%s'" entry)))
+	 (when em-verbose
+	   (eshell-printn (format-message "rm: killing process `%s'" entry)))
 	 (unless (or em-preview
 		     (and em-interactive
 			  (not (y-or-n-p (format-message
@@ -276,9 +276,9 @@ eshell/rm
 					  entry)))))
 	   (eshell-funcalln 'kill-process entry)))
 	((symbolp entry)
-	 (if em-verbose
-	     (eshell-printn (format-message
-			     "rm: uninterning symbol `%s'" entry)))
+	 (when em-verbose
+	   (eshell-printn (format-message
+			   "rm: uninterning symbol `%s'" entry)))
 	 (unless
 	     (or em-preview
 		 (and em-interactive
@@ -294,11 +294,11 @@ eshell/rm
 		    (not (file-symlink-p entry)))
 	       (if (or em-recursive
 		       eshell-rm-removes-directories)
-		   (if (or em-preview
-			   (not em-interactive)
-			   (y-or-n-p
-			    (format-message "rm: descend into directory `%s'? "
-					    entry)))
+		   (when (or em-preview
+			     (not em-interactive)
+			     (y-or-n-p
+			      (format-message "rm: descend into directory `%s'? "
+					      entry)))
 		     (eshell-remove-entries (list entry) t))
 		 (eshell-error (format "rm: %s: is a directory\n" entry)))
 	     (eshell-remove-entries (list entry) t))))))
@@ -353,18 +353,18 @@ eshell-shuffle-files
 	(is-dir (or (file-directory-p target)
 		    (and em-preview (not eshell-warn-dot-directories))))
 	attr)
-    (if (and (not em-preview) (not is-dir)
-	     (> (length files) 1))
-	(error "%s: when %s multiple files, last argument must be a directory"
-	       command action))
+    (when (and (not em-preview) (not is-dir)
+	       (> (length files) 1))
+      (error "%s: when %s multiple files, last argument must be a directory"
+	     command action))
     (while files
       (setcar files (directory-file-name (car files)))
       (cond
        ((string-match "\\`\\.\\.?\\'"
 		      (file-name-nondirectory (car files)))
-	(if eshell-warn-dot-directories
-	    (eshell-error (format "%s: %s: omitting directory\n"
-				  command (car files)))))
+	(when eshell-warn-dot-directories
+	  (eshell-error (format "%s: %s: omitting directory\n"
+				command (car files)))))
        ((and attr-target
 	     (or (not (eshell-under-windows-p))
 		 (eq system-type 'ms-dos))
@@ -410,10 +410,10 @@ eshell-shuffle-files
 				      (expand-file-name target)))))))
 		      (apply 'eshell-funcalln func source target args)
 		  (unless (file-directory-p target)
-		    (if em-verbose
-			(eshell-printn
-			 (format "%s: making directory %s"
-				 command target)))
+		    (when em-verbose
+		      (eshell-printn
+		       (format "%s: making directory %s"
+			       command target)))
 		    (unless em-preview
 		      (eshell-funcalln 'make-directory target)))
 		  (apply 'eshell-shuffle-files
@@ -425,15 +425,15 @@ eshell-shuffle-files
 			  (directory-files source))
 			 target func t args)
 		  (when (eq func 'rename-file)
-		    (if em-verbose
-			(eshell-printn
-			 (format "%s: deleting directory %s"
-				 command source)))
+		    (when em-verbose
+		      (eshell-printn
+		       (format "%s: deleting directory %s"
+			       command source)))
 		    (unless em-preview
 		      (eshell-funcalln 'delete-directory source))))))
-	    (if em-verbose
-		(eshell-printn (format "%s: %s -> %s" command
-				       source target)))
+	    (when em-verbose
+	      (eshell-printn (format "%s: %s -> %s" command
+				     source target)))
 	    (unless em-preview
 	      (if (and no-dereference
 		       (setq link (file-symlink-p source)))
@@ -459,10 +459,10 @@ eshell-shorthand-tar-command
     (if (file-exists-p archive)
 	(setq tar-args (concat "u" tar-args))
       (setq tar-args (concat "c" tar-args)))
-    (if em-verbose
-	(setq tar-args (concat "v" tar-args)))
-    (if (equal command "mv")
-	(setq tar-args (concat "--remove-files -" tar-args)))
+    (when em-verbose
+      (setq tar-args (concat "v" tar-args)))
+    (when (equal command "mv")
+      (setq tar-args (concat "--remove-files -" tar-args)))
     ;; truncate the archive name from the arguments
     (setcdr (last args 2) nil)
     (throw 'eshell-replace-command
@@ -473,11 +473,11 @@ eshell-shorthand-tar-command
 (defmacro eshell-mvcpln-template (command action func query-var
 					  force-var &optional preserve)
   `(let ((len (length args)))
-     (if (or (= len 0)
-	     (and (= len 1) (null eshell-default-target-is-dot)))
-	 (error "%s: missing destination file or directory" ,command))
-     (if (= len 1)
-	 (nconc args '(".")))
+     (when (or (= len 0)
+	       (and (= len 1) (null eshell-default-target-is-dot)))
+       (error "%s: missing destination file or directory" ,command))
+     (when (= len 1)
+       (nconc args '(".")))
      (setq args (eshell-stringify-list (flatten-tree args)))
      (if (and ,(not (equal command "ln"))
 	      (string-match eshell-tar-regexp (car (last args)))
@@ -495,8 +495,8 @@ eshell-mvcpln-template
 			    ,query-var)
 			(not force))
 		   1 (or force ,force-var)))
-	     (if preserve
-		 (list preserve)))))
+	     (when preserve
+	       (list preserve)))))
        nil)))
 
 (defun eshell/mv (&rest args)
@@ -556,8 +556,8 @@ eshell/cp
      :usage "[OPTION]... SOURCE DEST
    or:  cp [OPTION]... SOURCE... DIRECTORY
 Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.")
-   (if archive
-       (setq preserve t no-dereference t em-recursive t))
+   (when archive
+     (setq preserve t no-dereference t em-recursive t))
    (eshell-mvcpln-template "cp" "copying" 'copy-file
 			   eshell-cp-interactive-query
 			   eshell-cp-overwrite-files preserve)))
@@ -630,9 +630,9 @@ eshell/cat
        :usage "[OPTION] FILE...
 Concatenate FILE(s), or standard input, to standard output.")
      (dolist (file args)
-       (if (string= file "-")
-	   (throw 'eshell-external
-		  (eshell-external-command "cat" args))))
+       (when (string= file "-")
+	 (throw 'eshell-external
+		(eshell-external-command "cat" args))))
      (let ((curbuf (current-buffer)))
        (dolist (file args)
 	 (with-temp-buffer
@@ -705,19 +705,19 @@ eshell-poor-mans-grep
 		(inhibit-redisplay t)
 		string)
 	    (when (car args)
-	      (if (get-buffer "*Occur*")
-		  (kill-buffer (get-buffer "*Occur*")))
+	      (when (get-buffer "*Occur*")
+		(kill-buffer (get-buffer "*Occur*")))
 	      (setq string nil)
 	      (while files
 		(with-current-buffer (find-file-noselect (car files))
 		  (save-excursion
 		    (ignore-errors
 		      (occur (car args))))
-		  (if (get-buffer "*Occur*")
-		      (with-current-buffer (get-buffer "*Occur*")
-			(setq string (buffer-string))
-			(kill-buffer (current-buffer)))))
-		(if string (insert string))
+		  (when (get-buffer "*Occur*")
+		    (with-current-buffer (get-buffer "*Occur*")
+		      (setq string (buffer-string))
+		      (kill-buffer (current-buffer)))))
+		(when string (insert string))
 		(setq string nil
 		      files (cdr files)))))
 	  (local-set-key [mouse-2] 'eshell-occur-mode-mouse-goto)
@@ -831,8 +831,8 @@ show-all
 (defsubst eshell-du-size-string (size)
   (let* ((str (eshell-printable-size size human-readable block-size t))
 	 (len (length str)))
-    (concat str (if (< len 8)
-		    (make-string (- 8 len) ? )))))
+    (concat str (when (< len 8)
+		  (make-string (- 8 len) ? )))))
 
 (defun eshell-du-sum-directory (path depth)
   "Summarize PATH, and its member directories."
@@ -848,8 +848,8 @@ eshell-du-sum-directory
 		      (and only-one-filesystem
 			   (/= only-one-filesystem
 			       (file-attribute-device-number (cdar entries)))))
-	    (if symlink
-		(setq entry symlink))
+	    (when symlink
+	      (setq entry symlink))
 	    (setq size
 		  (+ size
 		     (if (eq t (car (cdar entries)))
@@ -857,16 +857,16 @@ eshell-du-sum-directory
 		       (let ((file-size (file-attribute-size (cdar entries))))
 			 (prog1
 			     file-size
-			   (if show-all
-			       (eshell-print
-				(concat (eshell-du-size-string file-size)
-					entry "\n")))))))))))
+			   (when show-all
+			     (eshell-print
+			      (concat (eshell-du-size-string file-size)
+				      entry "\n")))))))))))
       (setq entries (cdr entries)))
-    (if (or (not max-depth)
-	    (= depth max-depth)
-	    (= depth 0))
-	(eshell-print (concat (eshell-du-size-string size)
-			      (directory-file-name path) "\n")))
+    (when (or (not max-depth)
+	      (= depth max-depth)
+	      (= depth 0))
+      (eshell-print (concat (eshell-du-size-string size)
+			    (directory-file-name path) "\n")))
     size))
 
 (defun eshell/du (&rest args)
@@ -878,9 +878,9 @@ eshell/du
     (if (and ext-du
 	     (not (catch 'have-ange-path
 		    (dolist (arg args)
-		      (if (string-equal
-			   (file-remote-p (expand-file-name arg) 'method) "ftp")
-			  (throw 'have-ange-path t))))))
+		      (when (string-equal
+			     (file-remote-p (expand-file-name arg) 'method) "ftp")
+			(throw 'have-ange-path t))))))
 	(throw 'eshell-replace-command
 	       (eshell-parse-command (eshell-quote-argument ext-du) args))
       (eshell-eval-using-options
@@ -916,23 +916,23 @@ eshell/du
 Summarize disk usage of each FILE, recursively for directories.")
        (unless by-bytes
 	 (setq block-size (or block-size 1024)))
-       (if (and max-depth (stringp max-depth))
-	   (setq max-depth (string-to-number max-depth)))
+       (when (and max-depth (stringp max-depth))
+	 (setq max-depth (string-to-number max-depth)))
        ;; filesystem support means nothing under Windows
-       (if (eshell-under-windows-p)
-	   (setq only-one-filesystem nil))
+       (when (eshell-under-windows-p)
+	 (setq only-one-filesystem nil))
        (let ((size 0.0))
 	 (while args
-	   (if only-one-filesystem
-	       (setq only-one-filesystem
-		     (file-attribute-device-number (eshell-file-attributes
-			      (file-name-as-directory (car args))))))
+	   (when only-one-filesystem
+	     (setq only-one-filesystem
+		   (file-attribute-device-number (eshell-file-attributes
+			                          (file-name-as-directory (car args))))))
 	   (setq size (+ size (eshell-du-sum-directory
 			       (directory-file-name (car args)) 0)))
 	   (setq args (cdr args)))
-	 (if grand-total
-	     (eshell-print (concat (eshell-du-size-string size)
-				   "total\n"))))))))
+	 (when grand-total
+	   (eshell-print (concat (eshell-du-size-string size)
+				 "total\n"))))))))
 
 (put 'eshell/du 'eshell-filename-arguments t)
 
@@ -984,8 +984,8 @@ eshell-diff-window-config
 (defun eshell-diff-quit ()
   "Restore the window configuration previous to diff'ing."
   (interactive)
-  (if eshell-diff-window-config
-      (set-window-configuration eshell-diff-window-config)))
+  (when eshell-diff-window-config
+    (set-window-configuration eshell-diff-window-config)))
 
 (defun nil-blank-string (string)
   "Return STRING, or nil if STRING contains only non-blank characters."
@@ -1005,9 +1005,9 @@ eshell/diff
 	(throw 'eshell-replace-command
 	       (eshell-parse-command "*diff" orig-args))
       (setq args (copy-sequence orig-args))
-      (if (< (length args) 2)
-	  (throw 'eshell-replace-command
-		 (eshell-parse-command "*diff" orig-args)))
+      (when (< (length args) 2)
+	(throw 'eshell-replace-command
+	       (eshell-parse-command "*diff" orig-args)))
       (let ((old (car (last args 2)))
 	    (new (car (last args)))
 	    (config (current-window-configuration)))
@@ -1032,8 +1032,8 @@ eshell/diff
 		  (set (make-local-variable 'eshell-diff-window-config)
 		       ,config)
 		  (local-set-key [?q] 'eshell-diff-quit)
-		  (if (fboundp 'turn-on-font-lock-if-enabled)
-		      (turn-on-font-lock-if-enabled))
+		  (when (fboundp 'turn-on-font-lock-if-enabled)
+		    (turn-on-font-lock-if-enabled))
 		  (goto-char (point-min))))))
 	  (pop-to-buffer (current-buffer))))))
   nil)
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index e7b07b4208..190ffd3a31 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -93,8 +93,8 @@ eshell-parse-argument-hook
 		 (eshell-arg-delimiter (match-end 0)))
 	(goto-char (match-end 0))
 	(let ((str (match-string 0)))
-	  (if (> (length str) 0)
-	      (add-text-properties 0 (length str) '(number t) str))
+	  (when (> (length str) 0)
+	    (add-text-properties 0 (length str) '(number t) str))
 	  str))))
 
    ;; parse any non-special characters, based on the current context
@@ -113,8 +113,8 @@ eshell-parse-argument-hook
 			  eshell-outside-quote-regexp))
 	(goto-char (match-end 0))
 	(let ((str (match-string 0)))
-	  (if str
-	      (set-text-properties 0 (length str) nil str))
+	  (when str
+	    (set-text-properties 0 (length str) nil str))
 	  str))))
 
    ;; whitespace or a comment is an argument delimiter
@@ -125,9 +125,9 @@ eshell-parse-argument-hook
 		  (and (not eshell-current-argument)
 		       (looking-at "#\\([^<'].*\\|$\\)")
 		       (setq comment-p t)))
-	  (if comment-p
-	      (add-text-properties (match-beginning 0) (match-end 0)
-				   '(comment t)))
+	  (when comment-p
+	    (add-text-properties (match-beginning 0) (match-end 0)
+				 '(comment t)))
 	  (goto-char (match-end 0))
 	  (eshell-finish-arg)))))
 
@@ -181,8 +181,8 @@ eshell-insert-buffer-name
 
 (defsubst eshell-escape-arg (string)
   "Return STRING with the `escaped' property on it."
-  (if (stringp string)
-      (add-text-properties 0 (length string) '(escaped t) string))
+  (when (stringp string)
+    (add-text-properties 0 (length string) '(escaped t) string))
   string)
 
 (defun eshell-resolve-current-argument ()
@@ -207,8 +207,8 @@ eshell-resolve-current-argument
 
 (defun eshell-finish-arg (&optional argument)
   "Finish the current argument being processed."
-  (if argument
-      (setq eshell-current-argument argument))
+  (when argument
+    (setq eshell-current-argument argument))
   (throw 'eshell-arg-done t))
 
 (defun eshell-quote-argument (string)
@@ -239,19 +239,19 @@ eshell-parse-arguments
         (with-silent-modifications
           (remove-text-properties (point-min) (point-max)
                                   '(arg-begin nil arg-end nil))
-          (if (setq
-               delim
-               (catch 'eshell-incomplete
-                 (while (not (eobp))
-                   (let* ((here (point))
-                          (arg (eshell-parse-argument)))
-                     (if (= (point) here)
+          (when (setq
+                 delim
+                 (catch 'eshell-incomplete
+                   (while (not (eobp))
+                     (let* ((here (point))
+                            (arg (eshell-parse-argument)))
+                       (when (= (point) here)
                          (error "Failed to parse argument `%s'"
                                 (buffer-substring here (point-max))))
-                     (and arg (nconc args (list arg)))))))
-              (throw 'eshell-incomplete (if (listp delim)
-                                            delim
-                                          (list delim (point) (cdr args)))))
+                       (and arg (nconc args (list arg)))))))
+            (throw 'eshell-incomplete (if (listp delim)
+                                          delim
+                                        (list delim (point) (cdr args)))))
           (cdr args))))))
 
 (defun eshell-parse-argument ()
@@ -304,8 +304,8 @@ eshell-quote-backslash
   (let ((char (aref string index)))
     (if (eq char ?\\)
 	(char-to-string char)
-      (if (memq char eshell-special-chars-outside-quoting)
-	  (string ?\\ char)))))
+      (when (memq char eshell-special-chars-outside-quoting)
+	(string ?\\ char)))))
 
 (defun eshell-parse-backslash ()
   "Parse a single backslash (\\) character and the character after.
@@ -332,15 +332,15 @@ eshell-parse-backslash
 
 (defun eshell-parse-literal-quote ()
   "Parse a literally quoted string.  Nothing has special meaning!"
-  (if (eq (char-after) ?\')
-      (let ((end (eshell-find-delimiter ?\' ?\')))
-	(if (not end)
-	    (throw 'eshell-incomplete ?\')
-	  (let ((string (buffer-substring-no-properties (1+ (point)) end)))
-	    (goto-char (1+ end))
-	    (while (string-match "''" string)
-	      (setq string (replace-match "'" t t string)))
-	    (list 'eshell-escape-arg string))))))
+  (when (eq (char-after) ?\')
+    (let ((end (eshell-find-delimiter ?\' ?\')))
+      (if (not end)
+	  (throw 'eshell-incomplete ?\')
+	(let ((string (buffer-substring-no-properties (1+ (point)) end)))
+	  (goto-char (1+ end))
+	  (while (string-match "''" string)
+	    (setq string (replace-match "'" t t string)))
+	  (list 'eshell-escape-arg string))))))
 
 (defun eshell-parse-double-quote ()
   "Parse a double quoted string, which allows for variable interpolation."
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index e0348ba501..88dd6d768a 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -370,8 +370,8 @@ eshell-parse-command
 	   (eshell-separate-commands terms "[&;]" nil 'eshell--sep-terms))))
     (let ((cmd commands))
       (while cmd
-	(if (cdr cmd)
-	    (setcar cmd `(eshell-commands ,(car cmd))))
+	(when (cdr cmd)
+	  (setcar cmd `(eshell-commands ,(car cmd))))
 	(setq cmd (cdr cmd))))
     (if toplevel
 	`(eshell-commands (progn
@@ -394,38 +394,38 @@ eshell-debug-command
 (defun eshell-debug-show-parsed-args (terms)
   "Display parsed arguments in the debug buffer."
   (ignore
-   (if eshell-debug-command
-       (eshell-debug-command "parsed arguments" terms))))
+   (when eshell-debug-command
+     (eshell-debug-command "parsed arguments" terms))))
 
 (defun eshell-no-command-conversion (terms)
   "Don't convert the command argument."
   (ignore
-   (if (and (listp (car terms))
-	    (eq (caar terms) 'eshell-convert))
-       (setcar terms (cadr (car terms))))))
+   (when (and (listp (car terms))
+	      (eq (caar terms) 'eshell-convert))
+     (setcar terms (cadr (car terms))))))
 
 (defun eshell-subcommand-arg-values (terms)
   "Convert subcommand arguments {x} to ${x}, in order to take their values."
   (setq terms (cdr terms))		; skip command argument
   (while terms
-    (if (and (listp (car terms))
-	     (eq (caar terms) 'eshell-as-subcommand))
-	(setcar terms `(eshell-convert
-                        (eshell-command-to-value ,(car terms)))))
+    (when (and (listp (car terms))
+	       (eq (caar terms) 'eshell-as-subcommand))
+      (setcar terms `(eshell-convert
+                      (eshell-command-to-value ,(car terms)))))
     (setq terms (cdr terms))))
 
 (defun eshell-rewrite-sexp-command (terms)
   "Rewrite a sexp in initial position, such as `(+ 1 2)'."
   ;; this occurs when a Lisp expression is in first position
-  (if (and (listp (car terms))
-	   (eq (caar terms) 'eshell-command-to-value))
-      (car (cdar terms))))
+  (when (and (listp (car terms))
+	     (eq (caar terms) 'eshell-command-to-value))
+    (car (cdar terms))))
 
 (defun eshell-rewrite-initial-subcommand (terms)
   "Rewrite a subcommand in initial position, such as `{+ 1 2}'."
-  (if (and (listp (car terms))
-	   (eq (caar terms) 'eshell-as-subcommand))
-      (car terms)))
+  (when (and (listp (car terms))
+	     (eq (caar terms) 'eshell-as-subcommand))
+    (car terms)))
 
 (defun eshell-rewrite-named-command (terms)
   "If no other rewriting rule transforms TERMS, assume a named command."
@@ -473,32 +473,32 @@ eshell-rewrite-for-command
 Because the implementation of `for' relies upon conditional evaluation
 of its argument (i.e., use of a Lisp special form), it must be
 implemented via rewriting, rather than as a function."
-  (if (and (equal (car terms) "for")
-	   (equal (nth 2 terms) "in"))
-      (let ((body (car (last terms))))
-	(setcdr (last terms 2) nil)
-	`(let ((for-items
-		(copy-tree
-		 (append
-		  ,@(mapcar
-		     (lambda (elem)
-		       (if (listp elem)
-			   elem
-			 `(list ,elem)))
-		     (cdr (cddr terms))))))
-	       (eshell-command-body '(nil))
-               (eshell-test-body '(nil)))
-	   (while (car for-items)
-	     (let ((,(intern (cadr terms)) (car for-items))
-		   (eshell--local-vars (cons ',(intern (cadr terms))
-					    eshell--local-vars)))
-	       (eshell-protect
-	   	,(eshell-invokify-arg body t)))
-	     (setcar for-items (cadr for-items))
-	     (setcdr for-items (cddr for-items)))
-           (eshell-close-handles
-            eshell-last-command-status
-            (list 'quote eshell-last-command-result))))))
+  (when (and (equal (car terms) "for")
+	     (equal (nth 2 terms) "in"))
+    (let ((body (car (last terms))))
+      (setcdr (last terms 2) nil)
+      `(let ((for-items
+	      (copy-tree
+	       (append
+		,@(mapcar
+		   (lambda (elem)
+		     (if (listp elem)
+			 elem
+		       `(list ,elem)))
+		   (cdr (cddr terms))))))
+	     (eshell-command-body '(nil))
+             (eshell-test-body '(nil)))
+	 (while (car for-items)
+	   (let ((,(intern (cadr terms)) (car for-items))
+		 (eshell--local-vars (cons ',(intern (cadr terms))
+					   eshell--local-vars)))
+	     (eshell-protect
+	      ,(eshell-invokify-arg body t)))
+	   (setcar for-items (cadr for-items))
+	   (setcdr for-items (cddr for-items)))
+         (eshell-close-handles
+          eshell-last-command-status
+          (list 'quote eshell-last-command-result))))))
 
 (defun eshell-structure-basic-command (func names keyword test body
 					    &optional else)
@@ -519,10 +519,10 @@ eshell-structure-basic-command
   ;; Otherwise, it can be a pair of strings; if the keyword
   ;; we're using matches the second member of that pair (a
   ;; list), we should reverse it.
-  (if (or (eq names nil)
-	  (and (listp names)
-	       (string= keyword (cadr names))))
-      (setq test `(not ,test)))
+  (when (or (eq names nil)
+	    (and (listp names)
+	         (string= keyword (cadr names))))
+    (setq test `(not ,test)))
 
   ;; finally, create the form that represents this structured
   ;; command
@@ -538,30 +538,30 @@ eshell-rewrite-while-command
 Because the implementation of `while' relies upon conditional
 evaluation of its argument (i.e., use of a Lisp special form), it
 must be implemented via rewriting, rather than as a function."
-  (if (and (stringp (car terms))
-	   (member (car terms) '("while" "until")))
-      (eshell-structure-basic-command
-       'while '("while" "until") (car terms)
-       (eshell-invokify-arg (cadr terms) nil t)
-       `(eshell-protect
-         ,(eshell-invokify-arg (car (last terms)) t)))))
+  (when (and (stringp (car terms))
+	     (member (car terms) '("while" "until")))
+    (eshell-structure-basic-command
+     'while '("while" "until") (car terms)
+     (eshell-invokify-arg (cadr terms) nil t)
+     `(eshell-protect
+       ,(eshell-invokify-arg (car (last terms)) t)))))
 
 (defun eshell-rewrite-if-command (terms)
   "Rewrite an `if' command into its equivalent Eshell command form.
 Because the implementation of `if' relies upon conditional
 evaluation of its argument (i.e., use of a Lisp special form), it
 must be implemented via rewriting, rather than as a function."
-  (if (and (stringp (car terms))
-	   (member (car terms) '("if" "unless")))
-      (eshell-structure-basic-command
-       'if '("if" "unless") (car terms)
-       (eshell-invokify-arg (cadr terms) nil t)
-       `(eshell-protect
-         ,(eshell-invokify-arg (car (last terms (if (= (length terms) 4) 2)))
-                               t))
-       (if (= (length terms) 4)
-	   `(eshell-protect
-             ,(eshell-invokify-arg (car (last terms)))) t))))
+  (when (and (stringp (car terms))
+	     (member (car terms) '("if" "unless")))
+    (eshell-structure-basic-command
+     'if '("if" "unless") (car terms)
+     (eshell-invokify-arg (cadr terms) nil t)
+     `(eshell-protect
+       ,(eshell-invokify-arg (car (last terms (when (= (length terms) 4) 2)))
+                             t))
+     (if (= (length terms) 4)
+	 `(eshell-protect
+           ,(eshell-invokify-arg (car (last terms)))) t))))
 
 (defvar eshell-last-command-result)     ;Defined in esh-io.el.
 
@@ -621,35 +621,35 @@ eshell-parse-pipeline
 
 (defun eshell-parse-subcommand-argument ()
   "Parse a subcommand argument of the form `{command}'."
-  (if (and (not eshell-current-argument)
-	   (not eshell-current-quoted)
-	   (eq (char-after) ?\{)
-	   (or (= (point-max) (1+ (point)))
-	       (not (eq (char-after (1+ (point))) ?\}))))
-      (let ((end (eshell-find-delimiter ?\{ ?\})))
-	(if (not end)
-	    (throw 'eshell-incomplete ?\{)
-	  (when (eshell-arg-delimiter (1+ end))
-	    (prog1
-		`(eshell-as-subcommand
-                  ,(eshell-parse-command (cons (1+ (point)) end)))
-	      (goto-char (1+ end))))))))
+  (when (and (not eshell-current-argument)
+	     (not eshell-current-quoted)
+	     (eq (char-after) ?\{)
+	     (or (= (point-max) (1+ (point)))
+	         (not (eq (char-after (1+ (point))) ?\}))))
+    (let ((end (eshell-find-delimiter ?\{ ?\})))
+      (if (not end)
+	  (throw 'eshell-incomplete ?\{)
+	(when (eshell-arg-delimiter (1+ end))
+	  (prog1
+	      `(eshell-as-subcommand
+                ,(eshell-parse-command (cons (1+ (point)) end)))
+	    (goto-char (1+ end))))))))
 
 (defun eshell-parse-lisp-argument ()
   "Parse a Lisp expression which is specified as an argument."
-  (if (and (not eshell-current-argument)
-	   (not eshell-current-quoted)
-	   (looking-at eshell-lisp-regexp))
-      (let* ((here (point))
-	     (obj
-	      (condition-case nil
-		  (read (current-buffer))
-		(end-of-file
-		 (throw 'eshell-incomplete ?\()))))
-	(if (eshell-arg-delimiter)
-	    `(eshell-command-to-value
-              (eshell-lisp-command (quote ,obj)))
-	  (ignore (goto-char here))))))
+  (when (and (not eshell-current-argument)
+	     (not eshell-current-quoted)
+	     (looking-at eshell-lisp-regexp))
+    (let* ((here (point))
+	   (obj
+	    (condition-case nil
+		(read (current-buffer))
+	      (end-of-file
+	       (throw 'eshell-incomplete ?\()))))
+      (if (eshell-arg-delimiter)
+	  `(eshell-command-to-value
+            (eshell-lisp-command (quote ,obj)))
+	(ignore (goto-char here))))))
 
 (defun eshell-separate-commands (terms separator &optional
 				       reversed last-terms-sym)
@@ -672,15 +672,15 @@ eshell-separate-commands
 		  sub-terms (list t)))
 	(nconc sub-terms (list (car terms))))
       (setq terms (cdr terms)))
-    (if (> (length sub-terms) 1)
-	(setq subchains (cons (cdr sub-terms) subchains)))
+    (when (> (length sub-terms) 1)
+      (setq subchains (cons (cdr sub-terms) subchains)))
     (if reversed
 	(progn
-	  (if last-terms-sym
-	      (set last-terms-sym (reverse (cdr eshell-sep-terms))))
+	  (when last-terms-sym
+	    (set last-terms-sym (reverse (cdr eshell-sep-terms))))
 	  subchains)                    ; already reversed
-      (if last-terms-sym
-	  (set last-terms-sym (cdr eshell-sep-terms)))
+      (when last-terms-sym
+	(set last-terms-sym (cdr eshell-sep-terms)))
       (nreverse subchains))))
 
 ;;_* Command evaluation macros
@@ -769,8 +769,8 @@ eshell-do-pipelines
                                         'append nextproc)
               (setq tailproc (or tailproc nextproc))))
 	,(let ((head (car pipeline)))
-	   (if (memq (car head) '(let progn))
-	       (setq head (car (last head))))
+	   (when (memq (car head) '(let progn))
+	     (setq head (car (last head))))
 	   (when (memq (car head) eshell-deferrable-commands)
 	     (ignore
 	      (setcar head
@@ -798,8 +798,8 @@ eshell-do-pipelines-synchronously
              (eshell-set-output-handle ,eshell-error-handle
                                        'append output-marker)))
        ,(let ((head (car pipeline)))
-          (if (memq (car head) '(let progn))
-              (setq head (car (last head))))
+          (when (memq (car head) '(let progn))
+            (setq head (car (last head))))
           ;; FIXME: is deferrable significant here?
           (when (memq (car head) eshell-deferrable-commands)
             (ignore
@@ -879,10 +879,10 @@ eshell/eshell-debug
   (ignore
    (cond
     ((not args)
-     (if eshell-handle-errors
-	 (eshell-print "errors\n"))
-     (if eshell-debug-command
-	 (eshell-print "commands\n")))
+     (when eshell-handle-errors
+       (eshell-print "errors\n"))
+     (when eshell-debug-command
+       (eshell-print "commands\n")))
     ((member (car args) '("-h" "--help"))
      (eshell-print "usage: eshell-debug [kinds]
 
@@ -908,17 +908,17 @@ pcomplete/eshell-mode/eshell-debug
 
 (defun eshell-invoke-directly (command)
   (let ((base (cadr (nth 2 (nth 2 (cadr command))))) name)
-    (if (and (eq (car base) 'eshell-trap-errors)
-	     (eq (car (cadr base)) 'eshell-named-command))
-	(setq name (cadr (cadr base))))
+    (when (and (eq (car base) 'eshell-trap-errors)
+	       (eq (car (cadr base)) 'eshell-named-command))
+      (setq name (cadr (cadr base))))
     (and name (stringp name)
 	 (not (member name eshell-complex-commands))
 	 (catch 'simple
 	   (progn
 	    (dolist (pred eshell-complex-commands)
-	      (if (and (functionp pred)
-		       (funcall pred name))
-		  (throw 'simple nil)))
+	      (when (and (functionp pred)
+		         (funcall pred name))
+		(throw 'simple nil)))
 	    t))
 	 (fboundp (intern-soft (concat "eshell/" name))))))
 
@@ -931,8 +931,8 @@ eshell-eval-command
 	      (list `(let ((here (and (eobp) (point))))
                        ,(and input
                              `(insert-and-inherit ,(concat input "\n")))
-                       (if here
-                           (eshell-update-markers here))
+                       (when here
+                         (eshell-update-markers here))
                        (eshell-do-eval ',command))))
     (and eshell-debug-command
          (with-current-buffer (get-buffer-create "*eshell last cmd*")
@@ -943,10 +943,10 @@ eshell-eval-command
 		   (eshell-resume-eval))))
       ;; On systems that don't support async subprocesses, eshell-resume
       ;; can return t.  Don't treat that as an error.
-      (if (listp delim)
-	  (setq delim (car delim)))
-      (if (and delim (not (eq delim t)))
-	  (error "Unmatched delimiter: %c" delim)))))
+      (when (listp delim)
+	(setq delim (car delim)))
+      (when (and delim (not (eq delim t)))
+	(error "Unmatched delimiter: %c" delim)))))
 
 (defun eshell-resume-command (proc status)
   "Resume the current command when a process ends."
@@ -954,8 +954,8 @@ eshell-resume-command
     (unless (or (not (stringp status))
 		(string= "stopped" status)
 		(string-match eshell-reset-signals status))
-      (if (eq proc (eshell-interactive-process))
-	  (eshell-resume-eval)))))
+      (when (eq proc (eshell-interactive-process))
+	(eshell-resume-eval)))))
 
 (defun eshell-resume-eval ()
   "Destructively evaluate a form which may need to be deferred."
@@ -1002,12 +1002,12 @@ eshell-do-eval
       (setq form (cadr (cadr form))))
     ;; expand any macros directly into the form.  This is done so that
     ;; we can modify any `let' forms to evaluate only once.
-    (if (macrop (car form))
-	(let ((exp (eshell-copy-tree (macroexpand form))))
-	  (eshell-manipulate (format-message "expanding macro `%s'"
-					     (symbol-name (car form)))
-	    (setcar form (car exp))
-	    (setcdr form (cdr exp)))))
+    (when (macrop (car form))
+      (let ((exp (eshell-copy-tree (macroexpand form))))
+	(eshell-manipulate (format-message "expanding macro `%s'"
+					   (symbol-name (car form)))
+	  (setcar form (car exp))
+	  (setcdr form (cdr exp)))))
     (let ((args (cdr form)))
       (cond
        ((eq (car form) 'while)
@@ -1053,19 +1053,19 @@ eshell-do-eval
 	(setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p))
 	(eval form))
        ((eq (car form) 'let)
-	(if (not (eq (car (cadr args)) 'eshell-do-eval))
-	    (eshell-manipulate "evaluating let args"
-	      (dolist (letarg (car args))
-		(if (and (listp letarg)
-			 (not (eq (cadr letarg) 'quote)))
-		    (setcdr letarg
-			    (list (eshell-do-eval
-				   (cadr letarg) synchronous-p)))))))
+	(when (not (eq (car (cadr args)) 'eshell-do-eval))
+	  (eshell-manipulate "evaluating let args"
+	    (dolist (letarg (car args))
+	      (when (and (listp letarg)
+		         (not (eq (cadr letarg) 'quote)))
+		(setcdr letarg
+			(list (eshell-do-eval
+			       (cadr letarg) synchronous-p)))))))
         (cl-progv
             (mapcar (lambda (binding) (if (consp binding) (car binding) binding))
                     (car args))
             ;; These expressions should all be constants now.
-            (mapcar (lambda (binding) (if (consp binding) (eval (cadr binding))))
+            (mapcar (lambda (binding) (when (consp binding) (eval (cadr binding))))
                     (car args))
 	  (eshell-do-eval (macroexp-progn (cdr args)) synchronous-p)))
        ((memq (car form) '(catch condition-case unwind-protect))
@@ -1083,18 +1083,18 @@ eshell-do-eval
 	    (setcar args `(eshell-do-eval ',(car args) ,synchronous-p))))
 	(eval form))
        ((eq (car form) 'setq)
-	(if (cddr args) (error "Unsupported form (setq X1 E1 X2 E2..)"))
+	(when (cddr args) (error "Unsupported form (setq X1 E1 X2 E2..)"))
         (eshell-manipulate "evaluating arguments to setq"
           (setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p)))
 	(list 'quote (eval form)))
        (t
-	(if (and args (not (memq (car form) '(run-hooks))))
-	    (eshell-manipulate
-		(format-message "evaluating arguments to `%s'"
-				(symbol-name (car form)))
-	      (while args
-		(setcar args (eshell-do-eval (car args) synchronous-p))
-		(setq args (cdr args)))))
+	(when (and args (not (memq (car form) '(run-hooks))))
+	  (eshell-manipulate
+	      (format-message "evaluating arguments to `%s'"
+			      (symbol-name (car form)))
+	    (while args
+	      (setcar args (eshell-do-eval (car args) synchronous-p))
+	      (setq args (cdr args)))))
 	(cond
 	 ((eq (car form) 'progn)
 	  (car (last form)))
@@ -1154,16 +1154,16 @@ eshell/which
   "Identify the COMMAND, and where it is located."
   (dolist (name (cons command names))
     (let (program alias direct)
-      (if (eq (aref name 0) eshell-explicit-command-char)
-	  (setq name (substring name 1)
-		direct t))
-      (if (and (not direct)
-	       (fboundp 'eshell-lookup-alias)
-	       (setq alias
-		     (eshell-lookup-alias name)))
-	  (setq program
-		(concat name " is an alias, defined as \""
-			(cadr alias) "\"")))
+      (when (eq (aref name 0) eshell-explicit-command-char)
+	(setq name (substring name 1)
+	      direct t))
+      (when (and (not direct)
+	         (fboundp 'eshell-lookup-alias)
+	         (setq alias
+		       (eshell-lookup-alias name)))
+	(setq program
+	      (concat name " is an alias, defined as \""
+		      (cadr alias) "\"")))
       (unless program
         (setq program
               (let* ((esym (eshell-find-alias-function name))
@@ -1190,12 +1190,12 @@ eshell-named-command
 	eshell-last-command-name (eshell-stringify command))
   (run-hook-with-args 'eshell-prepare-command-hook)
   (cl-assert (stringp eshell-last-command-name))
-  (if eshell-last-command-name
-      (or (run-hook-with-args-until-success
-	   'eshell-named-command-hook eshell-last-command-name
-	   eshell-last-arguments)
-	  (eshell-plain-command eshell-last-command-name
-				eshell-last-arguments))))
+  (when eshell-last-command-name
+    (or (run-hook-with-args-until-success
+	 'eshell-named-command-hook eshell-last-command-name
+	 eshell-last-arguments)
+	(eshell-plain-command eshell-last-command-name
+			      eshell-last-arguments))))
 
 (defalias 'eshell-named-command* 'eshell-named-command)
 
@@ -1210,14 +1210,14 @@ eshell-find-alias-function
 	     (string-match "\\`\\(em\\|esh\\)-\\([[:alnum:]]+\\)\\'" file))
 	(let ((module-sym
 	       (intern (concat "eshell-" (match-string 2 file)))))
-	  (if (and (functionp sym)
-		   (or (null module-sym)
-		       (eshell-using-module module-sym)
-		       (memq module-sym (eshell-subgroups 'eshell))))
-	      sym))
+	  (when (and (functionp sym)
+		     (or (null module-sym)
+		         (eshell-using-module module-sym)
+		         (memq module-sym (eshell-subgroups 'eshell))))
+	    sym))
       ;; Otherwise, if it's bound, return it.
-      (if (functionp sym)
-	  sym))))
+      (when (functionp sym)
+	sym))))
 
 (defun eshell-plain-command (command args)
   "Insert output from a plain COMMAND, using ARGS.
@@ -1247,11 +1247,11 @@ eshell-exec-lisp
     (error
      (setq eshell-last-command-status 1)
      (let ((msg (error-message-string err)))
-       (if (and (not form-p)
-                (string-match "^Wrong number of arguments" msg)
-                (fboundp 'eldoc-get-fnsym-args-string))
-           (let ((func-doc (eldoc-get-fnsym-args-string func-or-form)))
-             (setq msg (format "usage: %s" func-doc))))
+       (when (and (not form-p)
+                  (string-match "^Wrong number of arguments" msg)
+                  (fboundp 'eldoc-get-fnsym-args-string))
+         (let ((func-doc (eldoc-get-fnsym-args-string func-or-form)))
+           (setq msg (format "usage: %s" func-doc))))
        (funcall errprint msg))
      nil)))
 
@@ -1333,11 +1333,11 @@ eshell-lisp-command
               (setq eshell-last-arguments args
                     eshell-last-command-name "#<Lisp object>")
               (eshell-eval object))))
-      (if (and eshell-ensure-newline-p
-	       (save-excursion
-		 (goto-char eshell-last-output-end)
-		 (not (bolp))))
-	  (eshell-print "\n"))
+      (when (and eshell-ensure-newline-p
+	         (save-excursion
+		   (goto-char eshell-last-output-end)
+		   (not (bolp))))
+	(eshell-print "\n"))
       (eshell-close-handles 0 (list 'quote result)))))
 
 (defalias 'eshell-lisp-command* #'eshell-lisp-command)
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index c88d3c9f59..7fbdefbb23 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -81,11 +81,11 @@ eshell-search-path
 	(setq suffixes eshell-binary-suffixes)
 	(while suffixes
 	  (setq n2 (concat n1 (car suffixes)))
-	  (if (and (or (file-executable-p n2)
-		       (and eshell-force-execution
-			    (file-readable-p n2)))
-		   (not (file-directory-p n2)))
-	      (setq file n2 suffixes nil list nil))
+	  (when (and (or (file-executable-p n2)
+		         (and eshell-force-execution
+			      (file-readable-p n2)))
+		     (not (file-directory-p n2)))
+	    (setq file n2 suffixes nil list nil))
 	  (setq suffixes (cdr suffixes)))
 	(setq list (cdr list)))
       file)))
@@ -260,17 +260,17 @@ eshell-script-interpreter
 
   (INTERPRETER [ARGS] FILE)"
   (let ((maxlen eshell-command-interpreter-max-length))
-    (if (and (file-readable-p file)
-	     (file-regular-p file))
-	(with-temp-buffer
-	  (insert-file-contents-literally file nil 0 maxlen)
-	  (if (looking-at "#![ \t]*\\([^ \r\t\n]+\\)\\([ \t]+\\(.+\\)\\)?")
-	      (if (match-string 3)
-		  (list (match-string 1)
-			(match-string 3)
-			file)
+    (when (and (file-readable-p file)
+	       (file-regular-p file))
+      (with-temp-buffer
+	(insert-file-contents-literally file nil 0 maxlen)
+	(if (looking-at "#![ \t]*\\([^ \r\t\n]+\\)\\([ \t]+\\(.+\\)\\)?")
+	    (if (match-string 3)
 		(list (match-string 1)
-		      file)))))))
+		      (match-string 3)
+		      file)
+	      (list (match-string 1)
+		    file)))))))
 
 (defun eshell-find-interpreter (file args &optional no-examine-p)
   "Find the command interpreter with which to execute FILE.
@@ -302,15 +302,15 @@ eshell-find-interpreter
                 (if (file-name-absolute-p fullname)
                     (concat (file-remote-p default-directory) fullname)
                   (expand-file-name fullname default-directory))))
-	(if (and fullname (not (or eshell-force-execution
-				   (file-executable-p fullname))))
-	    (while suffixes
-	      (let ((try (concat fullname (car suffixes))))
-		(if (or (file-executable-p try)
-			(and eshell-force-execution
-			     (file-readable-p try)))
-		    (setq fullname try suffixes nil)
-		  (setq suffixes (cdr suffixes))))))
+	(when (and fullname (not (or eshell-force-execution
+				     (file-executable-p fullname))))
+	  (while suffixes
+	    (let ((try (concat fullname (car suffixes))))
+	      (if (or (file-executable-p try)
+		      (and eshell-force-execution
+			   (file-readable-p try)))
+		  (setq fullname try suffixes nil)
+		(setq suffixes (cdr suffixes))))))
 	(cond ((not (and fullname (file-exists-p fullname)))
 	       (let ((name (or fullname file)))
 		 (unless (setq fullname
@@ -323,10 +323,10 @@ eshell-find-interpreter
 	(let (interp)
 	  (unless no-examine-p
 	    (setq interp (eshell-script-interpreter fullname))
-	    (if interp
-		(setq interp
-		      (cons (car (eshell-find-interpreter (car interp) args t))
-			    (cdr interp)))))
+	    (when interp
+	      (setq interp
+		    (cons (car (eshell-find-interpreter (car interp) args t))
+			  (cdr interp)))))
 	  (or interp (list fullname)))))))
 
 (provide 'esh-ext)
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index b415486190..8aaf4edf04 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -118,13 +118,13 @@ eshell-print-queue-size
 (defcustom eshell-virtual-targets
   '(("/dev/eshell" eshell-interactive-print nil)
     ("/dev/kill" (lambda (mode)
-		   (if (eq mode 'overwrite)
-		       (kill-new ""))
+		   (when (eq mode 'overwrite)
+		     (kill-new ""))
 		   'eshell-kill-append) t)
     ("/dev/clip" (lambda (mode)
-		   (if (eq mode 'overwrite)
-		       (let ((select-enable-clipboard t))
-			 (kill-new "")))
+		   (when (eq mode 'overwrite)
+		     (let ((select-enable-clipboard t))
+		       (kill-new "")))
 		   'eshell-clipboard-append) t))
   "Map virtual devices name to Emacs Lisp functions.
 If the user specifies any of the filenames above as a redirection
@@ -189,8 +189,8 @@ eshell-parse-redirection
 	      (oper (match-string 2))
 ;	      (th (match-string 3))
 	      )
-	  (if (string= oper "<")
-	      (error "Eshell does not support input redirection"))
+	  (when (string= oper "<")
+	    (error "Eshell does not support input redirection"))
 	  (eshell-finish-arg
 	   (prog1
 	       (list 'eshell-set-output-handle
@@ -247,9 +247,9 @@ eshell-protect-handles
   "Protect the handles in HANDLES from a being closed."
   (let ((idx 0))
     (while (< idx eshell-number-of-handles)
-      (if (aref handles idx)
-	  (setcdr (aref handles idx)
-		  (1+ (cdr (aref handles idx)))))
+      (when (aref handles idx)
+	(setcdr (aref handles idx)
+		(1+ (cdr (aref handles idx)))))
       (setq idx (1+ idx))))
   handles)
 
@@ -275,8 +275,8 @@ eshell-close-target
    ;; If we're redirecting to a process (via a pipe, or process
    ;; redirection), send it EOF so that it knows we're finished.
    ((eshell-processp target)
-    (if (eq (process-status target) 'run)
-	(process-send-eof target)))
+    (when (eq (process-status target) 'run)
+      (process-send-eof target)))
 
    ;; A plain function redirection needs no additional arguments
    ;; passed.
@@ -317,14 +317,14 @@ eshell-close-handles
 
 (defun eshell-kill-append (string)
   "Call `kill-append' with STRING, if it is indeed a string."
-  (if (stringp string)
-      (kill-append string nil)))
+  (when (stringp string)
+    (kill-append string nil)))
 
 (defun eshell-clipboard-append (string)
   "Call `kill-append' with STRING, if it is indeed a string."
-  (if (stringp string)
-      (let ((select-enable-clipboard t))
-	(kill-append string nil))))
+  (when (stringp string)
+    (let ((select-enable-clipboard t))
+      (kill-append string nil))))
 
 (defun eshell-get-target (target &optional mode)
   "Convert TARGET, which is a raw argument, into a valid output target.
@@ -341,8 +341,8 @@ eshell-get-target
 	(let* ((exists (get-file-buffer target))
 	       (buf (find-file-noselect target t)))
 	  (with-current-buffer buf
-	    (if buffer-file-read-only
-		(error "Cannot write to read-only file `%s'" target))
+	    (when buffer-file-read-only
+	      (error "Cannot write to read-only file `%s'" target))
 	    (setq buffer-read-only nil)
 	    (set (make-local-variable 'eshell-output-file-buffer)
 		 (if (eq exists buf) 0 t))
@@ -364,8 +364,8 @@ eshell-get-target
    ((functionp target) nil)
 
    ((symbolp target)
-    (if (eq mode 'overwrite)
-	(set target nil))
+    (when (eq mode 'overwrite)
+      (set target nil))
     target)
 
    ((or (eshell-processp target)
@@ -391,8 +391,8 @@ eshell-set-output-handle
 		 (not (member where current)))
 	    (setq current (append current (list where)))
 	  (setq current (list where)))
-	(if (not (aref eshell-current-handles index))
-	    (aset eshell-current-handles index (cons nil 1)))
+	(when (not (aref eshell-current-handles index))
+	  (aset eshell-current-handles index (cons nil 1)))
 	(setcar (aref eshell-current-handles index) current)))))
 
 (defun eshell-interactive-output-p ()
@@ -417,8 +417,8 @@ eshell-flush
    (if reset-p
        (setq eshell-print-queue nil
 	     eshell-print-queue-count reset-p)
-     (if eshell-print-queue
-	 (eshell-print eshell-print-queue))
+     (when eshell-print-queue
+       (eshell-print eshell-print-queue))
      (eshell-flush 0))))
 
 (defun eshell-init-print-buffer ()
@@ -431,8 +431,8 @@ eshell-buffered-print
       (progn
 	(eshell-print (apply 'concat strings))
 	(setq eshell-print-queue-count 0))
-    (if (= eshell-print-queue-count eshell-print-queue-size)
-	(eshell-flush))
+    (when (= eshell-print-queue-count eshell-print-queue-size)
+      (eshell-flush))
     (setq eshell-print-queue
 	  (concat eshell-print-queue (apply 'concat strings))
 	  eshell-print-queue-count (1+ eshell-print-queue-count))))
@@ -466,23 +466,23 @@ eshell-output-object-to-target
       (if (not (symbol-value target))
 	  (set target object)
 	(setq object (eshell-stringify object))
-	(if (not (stringp (symbol-value target)))
-	    (set target (eshell-stringify
-			 (symbol-value target))))
+	(when (not (stringp (symbol-value target)))
+	  (set target (eshell-stringify
+		       (symbol-value target))))
 	(set target (concat (symbol-value target) object)))))
 
    ((markerp target)
-    (if (buffer-live-p (marker-buffer target))
-	(with-current-buffer (marker-buffer target)
-	  (let ((moving (= (point) target)))
-	    (save-excursion
-	      (goto-char target)
-	      (unless (stringp object)
-		(setq object (eshell-stringify object)))
-	      (insert-and-inherit object)
-	      (set-marker target (point-marker)))
-	    (if moving
-		(goto-char target))))))
+    (when (buffer-live-p (marker-buffer target))
+      (with-current-buffer (marker-buffer target)
+	(let ((moving (= (point) target)))
+	  (save-excursion
+	    (goto-char target)
+	    (unless (stringp object)
+	      (setq object (eshell-stringify object)))
+	    (insert-and-inherit object)
+	    (set-marker target (point-marker)))
+	  (when moving
+	    (goto-char target))))))
 
    ((eshell-processp target)
     (when (eq (process-status target) 'run)
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index e0e86348bd..e6dc311ced 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -309,8 +309,8 @@ eshell-mode
     (let ((fmt (copy-sequence mode-line-format)))
       (setq-local mode-line-format fmt))
     (let ((mode-line-elt (memq 'mode-line-modified mode-line-format)))
-      (if mode-line-elt
-	  (setcar mode-line-elt 'eshell-command-running-string))))
+      (when mode-line-elt
+	(setcar mode-line-elt 'eshell-command-running-string))))
 
   (set (make-local-variable 'bookmark-make-record-function)
        'eshell-bookmark-make-record)
@@ -327,10 +327,10 @@ eshell-mode
   (setq auto-fill-function nil)
 
   ;; always display everything from a return value
-  (if (boundp 'print-length)
-      (set (make-local-variable 'print-length) nil))
-  (if (boundp 'print-level)
-      (set (make-local-variable 'print-level) nil))
+  (when (boundp 'print-length)
+    (set (make-local-variable 'print-length) nil))
+  (when (boundp 'print-level)
+    (set (make-local-variable 'print-level) nil))
 
   ;; set require-final-newline to nil; otherwise, all redirected
   ;; output will end with a newline, whether or not the source
@@ -363,9 +363,9 @@ eshell-mode
   (dolist (module eshell-modules-list)
     (let ((module-fullname (symbol-name module))
 	  module-shortname)
-      (if (string-match "^eshell-\\(.*\\)" module-fullname)
-	  (setq module-shortname
-		(concat "em-" (match-string 1 module-fullname))))
+      (when (string-match "^eshell-\\(.*\\)" module-fullname)
+	(setq module-shortname
+	      (concat "em-" (match-string 1 module-fullname))))
       (unless module-shortname
 	(error "Invalid Eshell module name: %s" module-fullname))
       (unless (featurep (intern module-shortname))
@@ -379,16 +379,16 @@ eshell-mode
     (let ((load-hook (intern-soft (format "%s-load-hook" module)))
           (initfunc (intern-soft (format "%s-initialize" module))))
       (when (and load-hook (boundp load-hook))
-        (if (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
+        (when (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
         (run-hooks load-hook))
       ;; So we don't need the -initialize functions on the hooks (bug#5375).
       (and initfunc (fboundp initfunc) (funcall initfunc))))
 
-  (if eshell-send-direct-to-subprocesses
-      (add-hook 'pre-command-hook #'eshell-intercept-commands t t))
+  (when eshell-send-direct-to-subprocesses
+    (add-hook 'pre-command-hook #'eshell-intercept-commands t t))
 
-  (if eshell-scroll-to-bottom-on-input
-      (add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
+  (when eshell-scroll-to-bottom-on-input
+    (add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
 
   (when eshell-scroll-show-maximum-output
     (set (make-local-variable 'scroll-conservatively) 1000))
@@ -399,8 +399,8 @@ eshell-mode
 
   (add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t)
 
-  (if eshell-first-time-p
-      (run-hooks 'eshell-first-time-mode-hook))
+  (when eshell-first-time-p
+    (run-hooks 'eshell-first-time-mode-hook))
   (run-hooks 'eshell-post-command-hook))
 
 (put 'eshell-mode 'mode-class 'special)
@@ -452,8 +452,8 @@ eshell-intercept-commands
 	  (if (> (length (car possible-events)) 1)
 	      (setq intercept nil possible-events nil)
 	    (setq possible-events (cdr possible-events)))))
-      (if intercept
-	  (setq this-command 'eshell-self-insert-command)))))
+      (when intercept
+	(setq this-command 'eshell-self-insert-command)))))
 
 (declare-function find-tag-interactive "etags" (prompt &optional no-default))
 
@@ -477,15 +477,15 @@ eshell-move-argument
   (let ((pos (save-excursion
 	       (funcall func 1)
 	       (while (and (> arg 0) (/= (point) limit))
-		 (if (get-text-property (point) property)
-		     (setq arg (1- arg)))
-		 (if (> arg 0)
-		     (funcall func 1)))
+		 (when (get-text-property (point) property)
+		   (setq arg (1- arg)))
+		 (when (> arg 0)
+		   (funcall func 1)))
 	       (point))))
     (goto-char pos)
-    (if (and (eq func 'forward-char)
-	     (= (1+ pos) limit))
-	(forward-char 1))))
+    (when (and (eq func 'forward-char)
+	       (= (1+ pos) limit))
+      (forward-char 1))))
 
 (defun eshell-forward-argument (&optional arg)
   "Move forward ARG arguments."
@@ -695,21 +695,21 @@ eshell-output-filter
               (widen)
               (goto-char eshell-last-output-end)
               (setq ostart (point))
-              (if (<= (point) opoint)
-                  (setq opoint (+ opoint nchars)))
-              (if (< (point) obeg)
-                  (setq obeg (+ obeg nchars)))
-              (if (<= (point) oend)
-                  (setq oend (+ oend nchars)))
+              (when (<= (point) opoint)
+                (setq opoint (+ opoint nchars)))
+              (when (< (point) obeg)
+                (setq obeg (+ obeg nchars)))
+              (when (<= (point) oend)
+                (setq oend (+ oend nchars)))
               ;; Let the ansi-color overlay hooks run.
               (let ((inhibit-modification-hooks nil))
                 (insert-before-markers string))
-              (if (= (window-start) (point))
-                  (set-window-start (selected-window)
-                                    (- (point) nchars)))
-              (if (= (point) eshell-last-input-end)
-                  (set-marker eshell-last-input-end
-                              (- eshell-last-input-end nchars)))
+              (when (= (window-start) (point))
+                (set-window-start (selected-window)
+                                  (- (point) nchars)))
+              (when (= (point) eshell-last-input-end)
+                (set-marker eshell-last-input-end
+                            (- eshell-last-input-end nchars)))
               (set-marker eshell-last-output-start ostart)
               (set-marker eshell-last-output-end (point))
               (force-mode-line-update))
@@ -734,22 +734,22 @@ eshell-preinput-scroll-to-bottom
 `eshell-scroll-to-bottom-on-input'.
 
 This function should be a pre-command hook."
-  (if (memq this-command '(self-insert-command yank hilit-yank))
-      (let* ((selected (selected-window))
-	     (current (current-buffer))
-	     (scroll eshell-scroll-to-bottom-on-input))
-	(if (< (point) eshell-last-output-end)
-	    (if (eq scroll 'this)
-		(goto-char (point-max))
-	      (walk-windows
-	       (function
-		(lambda (window)
-		  (when (and (eq (window-buffer window) current)
-			     (or (eq scroll t) (eq scroll 'all)))
-		    (select-window window)
-		    (goto-char (point-max))
-		    (select-window selected))))
-	       nil t))))))
+  (when (memq this-command '(self-insert-command yank hilit-yank))
+    (let* ((selected (selected-window))
+	   (current (current-buffer))
+	   (scroll eshell-scroll-to-bottom-on-input))
+      (if (< (point) eshell-last-output-end)
+	  (if (eq scroll 'this)
+	      (goto-char (point-max))
+	    (walk-windows
+	     (function
+	      (lambda (window)
+		(when (and (eq (window-buffer window) current)
+			   (or (eq scroll t) (eq scroll 'all)))
+		  (select-window window)
+		  (goto-char (point-max))
+		  (select-window selected))))
+	     nil t))))))
 
 ;;; jww (1999-10-23): this needs testing
 (defun eshell-postoutput-scroll-to-bottom ()
@@ -766,27 +766,26 @@ eshell-postoutput-scroll-to-bottom
 	(walk-windows
 	 (function
 	  (lambda (window)
-	    (if (eq (window-buffer window) current)
-		(progn
-		  (select-window window)
-		  (if (and (< (point) eshell-last-output-end)
-			   (or (eq scroll t) (eq scroll 'all)
-			       ;; Maybe user wants point to jump to end.
-			       (and (eq scroll 'this)
-				    (eq selected window))
-			       (and (eq scroll 'others)
-				    (not (eq selected window)))
-			       ;; If point was at the end, keep it at end.
-			       (>= (point) eshell-last-output-start)))
-		      (goto-char eshell-last-output-end))
-		  ;; Optionally scroll so that the text
-		  ;; ends at the bottom of the window.
-		  (if (and eshell-scroll-show-maximum-output
-			   (>= (point) eshell-last-output-end))
-		      (save-excursion
-			(goto-char (point-max))
-			(recenter -1)))
-		  (select-window selected)))))
+	    (when (eq (window-buffer window) current)
+              (select-window window)
+	      (when (and (< (point) eshell-last-output-end)
+			 (or (eq scroll t) (eq scroll 'all)
+			     ;; Maybe user wants point to jump to end.
+			     (and (eq scroll 'this)
+				  (eq selected window))
+			     (and (eq scroll 'others)
+				  (not (eq selected window)))
+			     ;; If point was at the end, keep it at end.
+			     (>= (point) eshell-last-output-start)))
+		(goto-char eshell-last-output-end))
+	      ;; Optionally scroll so that the text
+	      ;; ends at the bottom of the window.
+	      (when (and eshell-scroll-show-maximum-output
+			 (>= (point) eshell-last-output-end))
+		(save-excursion
+		  (goto-char (point-max))
+		  (recenter -1)))
+	      (select-window selected))))
 	 nil t)
       (set-buffer current))))
 
@@ -823,9 +822,9 @@ eshell-show-output
 		    (save-excursion
 		      (goto-char (eshell-beginning-of-input))
 		      (line-beginning-position)))
-  (if arg
-      (narrow-to-region (eshell-beginning-of-output)
-			(eshell-end-of-output)))
+  (when arg
+    (narrow-to-region (eshell-beginning-of-output)
+		      (eshell-end-of-output)))
   (eshell-end-of-output))
 
 (defun eshell-mark-output (&optional arg)
@@ -848,8 +847,8 @@ eshell-show-maximum-output
   "Put the end of the buffer at the bottom of the window.
 When run interactively, widen the buffer first."
   (interactive "p")
-  (if interactive
-      (widen))
+  (when interactive
+    (widen))
   (goto-char (point-max))
   (recenter -1))
 
@@ -912,13 +911,13 @@ eshell-truncate-buffer
       (beginning-of-line)
       (let ((pos (point)))
 	(if (bobp)
-	    (if (called-interactively-p 'interactive)
-		(message "Buffer too short to truncate"))
+	    (when (called-interactively-p 'interactive)
+	      (message "Buffer too short to truncate"))
 	  (delete-region (point-min) (point))
-	  (if (called-interactively-p 'interactive)
-	      (message "Truncated buffer from %d to %d lines (%.1fk freed)"
-		       lines eshell-buffer-maximum-lines
-		       (/ pos 1024.0))))))))
+	  (when (called-interactively-p 'interactive)
+	    (message "Truncated buffer from %d to %d lines (%.1fk freed)"
+		     lines eshell-buffer-maximum-lines
+		     (/ pos 1024.0))))))))
 
 (custom-add-option 'eshell-output-filter-functions
 		   'eshell-truncate-buffer)
@@ -947,9 +946,9 @@ eshell-watch-for-password-prompt
       (let ((case-fold-search t))
 	(goto-char eshell-last-output-block-begin)
 	(beginning-of-line)
-	(if (re-search-forward eshell-password-prompt-regexp
-			       eshell-last-output-end t)
-	    (eshell-send-invisible))))))
+	(when (re-search-forward eshell-password-prompt-regexp
+			         eshell-last-output-end t)
+	  (eshell-send-invisible))))))
 
 (custom-add-option 'eshell-output-filter-functions
 		   'eshell-watch-for-password-prompt)
diff --git a/lisp/eshell/esh-module.el b/lisp/eshell/esh-module.el
index 45c4c9e13c..59b874933e 100644
--- a/lisp/eshell/esh-module.el
+++ b/lisp/eshell/esh-module.el
@@ -92,11 +92,11 @@ eshell-using-module
 (defun eshell-unload-extension-modules ()
   "Unload any memory resident extension modules."
   (dolist (module (eshell-subgroups 'eshell-module))
-    (if (featurep module)
-	(ignore-errors
-	  (message "Unloading %s..." (symbol-name module))
-	  (unload-feature module)
-	  (message "Unloading %s...done" (symbol-name module))))))
+    (when (featurep module)
+      (ignore-errors
+	(message "Unloading %s..." (symbol-name module))
+	(unload-feature module)
+	(message "Unloading %s...done" (symbol-name module))))))
 
 (provide 'esh-module)
 ;;; esh-module.el ends here
diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el
index dc8918891b..990ca4daba 100644
--- a/lisp/eshell/esh-opt.el
+++ b/lisp/eshell/esh-opt.el
@@ -181,15 +181,15 @@ eshell-show-usage
 				       (nth 4 opt)))))
 		(t (setq had-option nil)))))
       (setq options (cdr options)))
-    (if post-usage
-	(setq usage (concat usage (and had-option "\n")
-			    (cadr post-usage))))
+    (when post-usage
+      (setq usage (concat usage (and had-option "\n")
+			  (cadr post-usage))))
     (when extcmd
       (setq extcmd (eshell-search-path (cadr extcmd)))
-      (if extcmd
-	  (setq usage
-		(concat usage
-			(format-message "
+      (when extcmd
+	(setq usage
+	      (concat usage
+		      (format-message "
 This command is implemented in Lisp.  If an unrecognized option is
 passed to this command, the external version `%s'
 will be called instead." extcmd)))))
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index db1b258c8f..5d68930f28 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -126,8 +126,8 @@ eshell-kill-process-function
 Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments
 PROC and STATUS to functions on the latter."
   ;; Was there till 24.1, but it is not optional.
-  (if (memq #'eshell-reset-after-proc eshell-kill-hook)
-      (setq eshell-kill-hook (delq #'eshell-reset-after-proc eshell-kill-hook)))
+  (when (memq #'eshell-reset-after-proc eshell-kill-hook)
+    (setq eshell-kill-hook (delq #'eshell-reset-after-proc eshell-kill-hook)))
   (eshell-reset-after-proc status)
   (run-hook-with-args 'eshell-kill-hook proc status))
 
@@ -159,8 +159,8 @@ eshell-wait-for-process
       (when (eshell-processp proc)
 	;; NYI: If the process gets stopped here, that's bad.
 	(while (assq proc eshell-process-list)
-	  (if (input-pending-p)
-	      (discard-input))
+	  (when (input-pending-p)
+	    (discard-input))
 	  (sit-for eshell-process-wait-seconds
 		   eshell-process-wait-milliseconds))))
     (setq procs (cdr procs))))
@@ -243,11 +243,11 @@ eshell-record-process-object
 
 (defun eshell-remove-process-entry (entry)
   "Record the process ENTRY as fully completed."
-  (if (and (eshell-processp (car entry))
-	   (nth 2 entry)
-	   eshell-done-messages-in-minibuffer)
-      (message "[%s]+ Done %s" (process-name (car entry))
-	       (process-command (car entry))))
+  (when (and (eshell-processp (car entry))
+	     (nth 2 entry)
+	     eshell-done-messages-in-minibuffer)
+    (message "[%s]+ Done %s" (process-name (car entry))
+	     (process-command (car entry))))
   (setq eshell-process-list
 	(delq entry eshell-process-list)))
 
@@ -276,10 +276,10 @@ eshell-needs-pipe-p
        ;; neither 'first nor 'last?  See bug#1388 discussion.
        (catch 'found
 	 (dolist (exe eshell-needs-pipe)
-	   (if (string-equal exe (if (string-match "/" exe)
-				     command
-				   (file-name-nondirectory command)))
-	       (throw 'found t))))))
+	   (when (string-equal exe (if (string-match "/" exe)
+				       command
+				     (file-name-nondirectory command)))
+	     (throw 'found t))))))
 
 (defun eshell-gather-process-output (command args)
   "Gather the output from COMMAND + ARGS."
@@ -318,18 +318,18 @@ eshell-gather-process-output
 	;; decoding data sent from the process and the coding system
 	;; doesn't specify EOL conversion, we had better convert CRLF
 	;; to LF.
-	(if (vectorp (coding-system-eol-type decoding))
-	    (setq decoding (coding-system-change-eol-conversion decoding 'dos)
-		  changed t))
+	(when (vectorp (coding-system-eol-type decoding))
+	  (setq decoding (coding-system-change-eol-conversion decoding 'dos)
+		changed t))
 	;; Even if start-process left the coding system for encoding
 	;; data sent from the process undecided, we had better use the
 	;; same one as what we use for decoding.  But, we should
 	;; suppress EOL conversion.
-	(if (and decoding (not encoding))
-	    (setq encoding (coding-system-change-eol-conversion decoding 'unix)
-		  changed t))
-	(if changed
-	    (set-process-coding-system proc decoding encoding))))
+	(when (and decoding (not encoding))
+	  (setq encoding (coding-system-change-eol-conversion decoding 'unix)
+		changed t))
+	(when changed
+	  (set-process-coding-system proc decoding encoding))))
      (t
       ;; No async subprocesses...
       (let ((oldbuf (current-buffer))
@@ -376,7 +376,7 @@ eshell-gather-process-output
 	(eshell-kill-process-function command exit-status)
 	(or (bound-and-true-p eshell-in-pipeline-p)
 	    (setq eshell-last-sync-output-start nil))
-	(if (not (numberp exit-status))
+	(when (not (numberp exit-status))
 	  (error "%s: external command failed: %s" command exit-status))
 	(setq proc t))))
     proc))
@@ -438,14 +438,14 @@ eshell-process-interact
 If QUERY is non-nil, query the user with QUERY before calling FUNC."
   (let (defunct result)
     (dolist (entry eshell-process-list)
-      (if (and (memq (process-status (car entry))
-		    '(run stop open closed))
-	       (or all
-		   (not (nth 2 entry)))
-	       (or (not query)
-		   (y-or-n-p (format-message query
-					     (process-name (car entry))))))
-	  (setq result (funcall func (car entry))))
+      (when (and (memq (process-status (car entry))
+		       '(run stop open closed))
+	         (or all
+		     (not (nth 2 entry)))
+	         (or (not query)
+		     (y-or-n-p (format-message query
+					       (process-name (car entry))))))
+	(setq result (funcall func (car entry))))
       (unless (memq (process-status (car entry))
 		    '(run stop open closed))
 	(setq defunct (cons entry defunct))))
@@ -514,15 +514,15 @@ eshell-query-kill-processes
 	     eshell-process-list)
     (save-window-excursion
       (list-processes)
-      (if (or (not (eq eshell-kill-processes-on-exit 'ask))
-	      (y-or-n-p (format-message "Kill processes owned by `%s'? "
-					(buffer-name))))
-	  (eshell-round-robin-kill
-	   (if (eq eshell-kill-processes-on-exit 'every)
-	       "Kill Eshell child process `%s'? ")))
+      (when (or (not (eq eshell-kill-processes-on-exit 'ask))
+	        (y-or-n-p (format-message "Kill processes owned by `%s'? "
+					  (buffer-name))))
+	(eshell-round-robin-kill
+	 (if (eq eshell-kill-processes-on-exit 'every)
+	     "Kill Eshell child process `%s'? ")))
       (let ((buf (get-buffer "*Process List*")))
-	(if (and buf (buffer-live-p buf))
-	    (kill-buffer buf)))
+	(when (and buf (buffer-live-p buf))
+	  (kill-buffer buf)))
       (message nil))))
 
 (defun eshell-interrupt-process ()
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index ab030ede05..f0affe1381 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -203,8 +203,8 @@ eshell-convert
     (let ((len (length string)))
       (if (= len 0)
 	  string
-	(if (eq (aref string (1- len)) ?\n)
-	    (setq string (substring string 0 (1- len))))
+	(when (eq (aref string (1- len)) ?\n)
+	  (setq string (substring string 0 (1- len))))
 	(if (string-match "\n" string)
 	    (split-string string "\n")
 	  (if (and eshell-convert-numeric-arguments
@@ -218,8 +218,8 @@ eshell-sublist
   "Return from LIST the N to M elements.
 If N or M is nil, it means the end of the list."
   (let ((a (copy-sequence l)))
-    (if (and m (consp (nthcdr m a)))
-	(setcdr (nthcdr m a) nil))
+    (when (and m (consp (nthcdr m a)))
+      (setcdr (nthcdr m a) nil))
     (if n
 	(setq a (nthcdr n a))
       (setq n (1- (length a))
@@ -255,30 +255,30 @@ eshell-split-path
   (let ((len (length path))
 	(i 0) (li 0)
 	parts)
-    (if (and (eshell-under-windows-p)
-	     (> len 2)
-	     (eq (aref path 0) ?/)
-	     (eq (aref path 1) ?/))
-	(setq i 2))
+    (when (and (eshell-under-windows-p)
+	       (> len 2)
+	       (eq (aref path 0) ?/)
+	       (eq (aref path 1) ?/))
+      (setq i 2))
     (while (< i len)
-      (if (and (eq (aref path i) ?/)
-	       (not (get-text-property i 'escaped path)))
-	  (setq parts (cons (if (= li i) "/"
-			      (substring path li (1+ i))) parts)
-		li (1+ i)))
+      (when (and (eq (aref path i) ?/)
+	         (not (get-text-property i 'escaped path)))
+	(setq parts (cons (if (= li i) "/"
+			    (substring path li (1+ i))) parts)
+	      li (1+ i)))
       (setq i (1+ i)))
-    (if (< li i)
-	(setq parts (cons (substring path li i) parts)))
-    (if (and (eshell-under-windows-p)
-	     (string-match "\\`[A-Za-z]:\\'" (car (last parts))))
-	(setcar (last parts) (concat (car (last parts)) "/")))
+    (when (< li i)
+      (setq parts (cons (substring path li i) parts)))
+    (when (and (eshell-under-windows-p)
+	       (string-match "\\`[A-Za-z]:\\'" (car (last parts))))
+      (setcar (last parts) (concat (car (last parts)) "/")))
     (nreverse parts)))
 
 (defun eshell-to-flat-string (value)
   "Make value a string.  If separated by newlines change them to spaces."
   (let ((text (eshell-stringify value)))
-    (if (string-match "\n+\\'" text)
-	(setq text (replace-match "" t t text)))
+    (when (string-match "\n+\\'" text)
+      (setq text (replace-match "" t t text)))
     (while (string-match "\n+" text)
       (setq text (replace-match " " t t text)))
     text))
@@ -370,21 +370,21 @@ eshell-printable-size
 		(let ((str (if (<= size 9.94)
 			       (format "%.1fM" size)
 			     (format "%.0fM" size))))
-		  (if use-colors
-		      (put-text-property 0 (length str)
-					 'face 'bold str))
+		  (when use-colors
+		    (put-text-property 0 (length str)
+				       'face 'bold str))
 		  str)
 	      (setq size (/ size human-readable))
-	      (if (< size human-readable)
-		  (let ((str (if (<= size 9.94)
-				 (format "%.1fG" size)
-			       (format "%.0fG" size))))
-		    (if use-colors
-			(put-text-property 0 (length str)
-					   'face 'bold-italic str))
-		    str)))))
-      (if block-size
-	  (setq size (/ size block-size)))
+	      (when (< size human-readable)
+		(let ((str (if (<= size 9.94)
+			       (format "%.1fG" size)
+			     (format "%.0fG" size))))
+		  (when use-colors
+		    (put-text-property 0 (length str)
+				       'face 'bold-italic str))
+		  str)))))
+      (when block-size
+	(setq size (/ size block-size)))
       (format "%.0f" size))))
 
 (defun eshell-winnow-list (entries exclude &optional predicates)
@@ -433,31 +433,31 @@ eshell-read-passwd-file
 		  (split-string (buffer-substring
 				 (point) (progn (end-of-line)
 						(point))) ":")))
-	    (if (and (and fields (nth 0 fields) (nth 2 fields))
-		     (not (assq (string-to-number (nth 2 fields)) names)))
-		(setq names (cons (cons (string-to-number (nth 2 fields))
-					(nth 0 fields))
-				  names))))
+	    (when (and (and fields (nth 0 fields) (nth 2 fields))
+		       (not (assq (string-to-number (nth 2 fields)) names)))
+	      (setq names (cons (cons (string-to-number (nth 2 fields))
+				      (nth 0 fields))
+				names))))
 	  (forward-line))))
     names))
 
 (defun eshell-read-passwd (file result-var timestamp-var)
   "Read the contents of /etc/passwd for user names."
-  (if (or (not (symbol-value result-var))
-	  (not (symbol-value timestamp-var))
-	  (time-less-p
-	   (symbol-value timestamp-var)
-	   (file-attribute-modification-time (file-attributes file))))
-      (progn
-	(set result-var (eshell-read-passwd-file file))
-	(set timestamp-var (current-time))))
+  (when (or (not (symbol-value result-var))
+	    (not (symbol-value timestamp-var))
+	    (time-less-p
+	     (symbol-value timestamp-var)
+	     (file-attribute-modification-time (file-attributes file))))
+    (progn
+      (set result-var (eshell-read-passwd-file file))
+      (set timestamp-var (current-time))))
   (symbol-value result-var))
 
 (defun eshell-read-group-names ()
   "Read the contents of /etc/group for group names."
-  (if eshell-group-file
-      (eshell-read-passwd eshell-group-file 'eshell-group-names
-			  'eshell-group-timestamp)))
+  (when eshell-group-file
+    (eshell-read-passwd eshell-group-file 'eshell-group-names
+			'eshell-group-timestamp)))
 
 (defsubst eshell-group-id (name)
   "Return the user id for user NAME."
@@ -469,9 +469,9 @@ eshell-group-name
 
 (defun eshell-read-user-names ()
   "Read the contents of /etc/passwd for user names."
-  (if eshell-passwd-file
-      (eshell-read-passwd eshell-passwd-file 'eshell-user-names
-			  'eshell-user-timestamp)))
+  (when eshell-passwd-file
+    (eshell-read-passwd eshell-passwd-file 'eshell-user-names
+			'eshell-user-timestamp)))
 
 (defsubst eshell-user-id (name)
   "Return the user id for user NAME."
@@ -495,21 +495,21 @@ eshell-read-hosts-file
 
 (defun eshell-read-hosts (file result-var timestamp-var)
   "Read the contents of /etc/hosts for host names."
-  (if (or (not (symbol-value result-var))
-	  (not (symbol-value timestamp-var))
-	  (time-less-p
-	   (symbol-value timestamp-var)
-	   (file-attribute-modification-time (file-attributes file))))
-      (progn
-	(set result-var (apply #'nconc (eshell-read-hosts-file file)))
-	(set timestamp-var (current-time))))
+  (when (or (not (symbol-value result-var))
+	    (not (symbol-value timestamp-var))
+	    (time-less-p
+	     (symbol-value timestamp-var)
+	     (file-attribute-modification-time (file-attributes file))))
+    (progn
+      (set result-var (apply #'nconc (eshell-read-hosts-file file)))
+      (set timestamp-var (current-time))))
   (symbol-value result-var))
 
 (defun eshell-read-host-names ()
   "Read the contents of /etc/hosts for host names."
-  (if eshell-hosts-file
-      (eshell-read-hosts eshell-hosts-file 'eshell-host-names
-			 'eshell-host-timestamp)))
+  (when eshell-hosts-file
+    (eshell-read-hosts eshell-hosts-file 'eshell-host-names
+		       'eshell-host-timestamp)))
 
 (defsubst eshell-copy-environment ()
   "Return an unrelated copy of `process-environment'."
@@ -520,8 +520,8 @@ eshell-subgroups
   (let ((subgroups (get groupsym 'custom-group))
 	(subg (list t)))
     (while subgroups
-      (if (eq (cadr (car subgroups)) 'custom-group)
-	  (nconc subg (list (caar subgroups))))
+      (when (eq (cadr (car subgroups)) 'custom-group)
+	(nconc subg (list (caar subgroups))))
       (setq subgroups (cdr subgroups)))
     (cdr subg)))
 
@@ -558,13 +558,13 @@ eshell-directory-files-and-attributes
       (directory-files-and-attributes dir full match nosort id-format))))
 
 (defun eshell-current-ange-uids ()
-  (if (string-match "/\\([^@]+\\)@\\([^:]+\\):" default-directory)
-      (let* ((host (match-string 2 default-directory))
-	     (user (match-string 1 default-directory))
-	     (host-users (assoc host eshell-ange-ls-uids)))
-	(when host-users
-	  (setq host-users (cdr host-users))
-	  (cdr (assoc user host-users))))))
+  (when (string-match "/\\([^@]+\\)@\\([^:]+\\):" default-directory)
+    (let* ((host (match-string 2 default-directory))
+	   (user (match-string 1 default-directory))
+	   (host-users (assoc host eshell-ange-ls-uids)))
+      (when host-users
+	(setq host-users (cdr host-users))
+	(cdr (assoc user host-users))))))
 
 (autoload 'parse-time-string "parse-time")
 
@@ -595,10 +595,10 @@ eshell-parse-ange-ls
     (with-temp-buffer
       (insert (ange-ftp-ls dir "-la" nil))
       (goto-char (point-min))
-      (if (looking-at "^total [0-9]+$")
-	  (forward-line 1))
+      (when (looking-at "^total [0-9]+$")
+	(forward-line 1))
       ;; Some systems put in a blank line here.
-      (if (eolp) (forward-line 1))
+      (when (eolp) (forward-line 1))
       (while (looking-at
 	      `,(concat "\\([dlscb-][rwxst-]+\\)"
 			"\\s-*" "\\([0-9]+\\)" "\\s-+"
@@ -621,9 +621,9 @@ eshell-parse-ange-ls
                     (setf (decoded-time-hour moment) 0))
 		  (encode-time moment)))
 	       symlink)
-	  (if (string-match "\\(.+\\) -> \\(.+\\)" name)
-	      (setq symlink (match-string 2 name)
-		    name (match-string 1 name)))
+	  (when (string-match "\\(.+\\) -> \\(.+\\)" name)
+	    (setq symlink (match-string 2 name)
+		  name (match-string 1 name)))
 	  (setq entry
 		(cons
 		 (cons name
@@ -646,14 +646,14 @@ eshell-file-attributes
     (if (string-equal (file-remote-p file 'method) "ftp")
 	(let ((base (file-name-nondirectory file))
 	      (dir (file-name-directory file)))
-	  (if (string-equal "" base) (setq base "."))
+	  (when (string-equal "" base) (setq base "."))
 	  (unless entry
 	    (setq entry (eshell-parse-ange-ls dir))
-	    (if entry
-		(let ((fentry (assoc base (cdr entry))))
-		  (if fentry
-		      (setq entry (cdr fentry))
-		    (setq entry nil)))))
+	    (when entry
+	      (let ((fentry (assoc base (cdr entry))))
+		(if fentry
+		    (setq entry (cdr fentry))
+		  (setq entry nil)))))
 	  entry)
       (file-attributes file id-format))))
 
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 96838d4132..a32861f34f 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -267,25 +267,25 @@ eshell-handle-local-variables
     ;; setenv immediately before the command is invoked.  This means
     ;; that 'BLAH=x cd blah' won't work exactly as expected, but that
     ;; is by no means a typical use of local environment variables.
-    (if (and command (string-match setvar command))
-	(throw
-	 'eshell-replace-command
-	 (list
-	  'eshell-as-subcommand
-	  (append
-	   (list 'progn)
-	   (let ((l (list t)))
-	     (while (string-match setvar command)
-	       (nconc
-		l (list
-		   (list 'setenv (match-string 1 command)
-			 (match-string 2 command)
-			 (= (length (match-string 2 command)) 0))))
-	       (setq command (eshell-stringify (car args))
-		     args (cdr args)))
-	     (cdr l))
-	   (list (list 'eshell-named-command
-		       command (list 'quote args)))))))))
+    (when (and command (string-match setvar command))
+      (throw
+       'eshell-replace-command
+       (list
+	'eshell-as-subcommand
+	(append
+	 (list 'progn)
+	 (let ((l (list t)))
+	   (while (string-match setvar command)
+	     (nconc
+	      l (list
+		 (list 'setenv (match-string 1 command)
+		       (match-string 2 command)
+		       (= (length (match-string 2 command)) 0))))
+	     (setq command (eshell-stringify (car args))
+		   args (cdr args)))
+	   (cdr l))
+	 (list (list 'eshell-named-command
+		     command (list 'quote args)))))))))
 
 (defun eshell-interpolate-variable ()
   "Parse a variable interpolation.
@@ -308,10 +308,10 @@ eshell/define
 		 (list 'quote (if (= (length definition) 1)
 				  (car definition)
 				definition)))))
-      (if def
-	  (setq eshell-variable-aliases-list
-		(delq (assoc var-alias eshell-variable-aliases-list)
-		      eshell-variable-aliases-list)))
+      (when def
+	(setq eshell-variable-aliases-list
+	      (delq (assoc var-alias eshell-variable-aliases-list)
+		    eshell-variable-aliases-list)))
       (setq eshell-variable-aliases-list
 	    (cons alias-def
 		  eshell-variable-aliases-list))))
@@ -320,10 +320,10 @@ eshell/define
 (defun eshell/export (&rest sets)
   "This alias allows the `export' command to act as bash users expect."
   (while sets
-    (if (and (stringp (car sets))
-	     (string-match "^\\([^=]+\\)=\\(.*\\)" (car sets)))
-	(setenv (match-string 1 (car sets))
-		(match-string 2 (car sets))))
+    (when (and (stringp (car sets))
+	       (string-match "^\\([^=]+\\)=\\(.*\\)" (car sets)))
+      (setenv (match-string 1 (car sets))
+	      (match-string 2 (car sets))))
     (setq sets (cdr sets))))
 
 (defun pcomplete/eshell-mode/export ()
@@ -336,8 +336,8 @@ pcomplete/eshell-mode/export
 (defun eshell/unset (&rest args)
   "Unset an environment variable."
   (while args
-    (if (stringp (car args))
-	(setenv (car args) nil t))
+    (when (stringp (car args))
+      (setenv (car args) nil t))
     (setq args (cdr args))))
 
 (defun pcomplete/eshell-mode/unset ()
@@ -393,10 +393,10 @@ eshell-environment-variables
 environment, as specified in `eshell-variable-aliases-list'."
   (let ((process-environment (eshell-copy-environment)))
     (dolist (var-alias eshell-variable-aliases-list)
-      (if (nth 2 var-alias)
-	  (setenv (car var-alias)
-		  (eshell-stringify
-		   (or (eshell-get-variable (car var-alias)) "")))))
+      (when (nth 2 var-alias)
+	(setenv (car var-alias)
+		(eshell-stringify
+		 (or (eshell-get-variable (car var-alias)) "")))))
     process-environment))
 
 (defun eshell-parse-variable ()
@@ -548,12 +548,12 @@ eshell-apply-indices
     (let ((refs (car indices)))
       (when (stringp value)
 	(let (separator)
-	  (if (not (or (not (stringp (caar indices)))
-		       (string-match
-			(concat "^" eshell-variable-name-regexp "$")
-			(caar indices))))
-	      (setq separator (caar indices)
-		    refs (cdr refs)))
+	  (when (not (or (not (stringp (caar indices)))
+		         (string-match
+			  (concat "^" eshell-variable-name-regexp "$")
+			  (caar indices))))
+	    (setq separator (caar indices)
+		  refs (cdr refs)))
 	  (setq value
 		(mapcar #'eshell-convert
 			(split-string value separator)))))
@@ -613,8 +613,8 @@ eshell-variables-list
   (let ((argname pcomplete-stub)
 	completions)
     (dolist (alias eshell-variable-aliases-list)
-      (if (string-match (concat "^" argname) (car alias))
-	  (setq completions (cons (car alias) completions))))
+      (when (string-match (concat "^" argname) (car alias))
+	(setq completions (cons (car alias) completions))))
     (sort
      (append
       (mapcar
@@ -636,8 +636,8 @@ eshell-complete-variable-assignment
   (let ((arg (pcomplete-actual-arg)) pos)
     (when (string-match (concat "\\`" eshell-variable-name-regexp "=") arg)
       (setq pos (match-end 0))
-      (if (string-match "\\(:\\)[^:]*\\'" arg)
-	  (setq pos (match-end 1)))
+      (when (string-match "\\(:\\)[^:]*\\'" arg)
+	(setq pos (match-end 1)))
       (setq pcomplete-stub (substring arg pos))
       (throw 'pcomplete-completions (pcomplete-entries)))))
 
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index 6698ca45de..b5433f25a1 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -299,8 +299,8 @@ eshell-command
                                     (eshell-command-mode +1))
       (unless command
         (setq command (read-from-minibuffer "Emacs shell command: "))
-	(if (eshell-using-module 'eshell-hist)
-	    (eshell-add-input-to-history command)))))
+	(when (eshell-using-module 'eshell-hist)
+	  (eshell-add-input-to-history command)))))
   (unless command
     (error "No command specified!"))
   ;; redirection into the current buffer is achieved by adding an
@@ -308,11 +308,11 @@ eshell-command
   ;; 'COMMAND >>> #<buffer BUFFER>'.  This will not interfere with
   ;; other redirections, since multiple redirections merely cause the
   ;; output to be copied to multiple target locations
-  (if arg
-      (setq command
-	    (concat command
-		    (format " >>> #<buffer %s>"
-			    (buffer-name (current-buffer))))))
+  (when arg
+    (setq command
+	  (concat command
+		  (format " >>> #<buffer %s>"
+			  (buffer-name (current-buffer))))))
   (save-excursion
     (let ((buf (set-buffer (generate-new-buffer " *eshell cmd*")))
 	  (eshell-non-interactive-p t))
@@ -325,15 +325,15 @@ eshell-command
 			  "*Eshell Async Command Output*"
 			(setq intr t)
 			"*Eshell Command Output*")))
-	(if (buffer-live-p (get-buffer bufname))
-	    (kill-buffer bufname))
+	(when (buffer-live-p (get-buffer bufname))
+	  (kill-buffer bufname))
 	(rename-buffer bufname)
 	;; things get a little coarse here, since the desire is to
 	;; make the output as attractive as possible, with no
 	;; extraneous newlines
 	(when intr
-	  (if (eshell-interactive-process)
-	      (eshell-wait-for-process (eshell-interactive-process)))
+	  (when (eshell-interactive-process)
+	    (eshell-wait-for-process (eshell-interactive-process)))
 	  (cl-assert (not (eshell-interactive-process)))
 	  (goto-char (point-max))
 	  (while (and (bolp) (not (bobp)))
@@ -369,8 +369,8 @@ eshell-command-result
   ;; a null command produces a null, successful result
   (if (not command)
       (ignore
-       (if (and status-var (symbolp status-var))
-	   (set status-var 0)))
+       (when (and status-var (symbolp status-var))
+	 (set status-var 0)))
     (with-temp-buffer
       (let ((eshell-non-interactive-p t))
 	(eshell-mode)
@@ -380,8 +380,8 @@ eshell-command-result
 				   (eshell-parse-command command)))
                        t)))
 	  (cl-assert (eq (car result) 'quote))
-	  (if (and status-var (symbolp status-var))
-	      (set status-var eshell-last-command-status))
+	  (when (and status-var (symbolp status-var))
+	    (set status-var eshell-last-command-status))
 	  (cadr result))))))
 
 ;;; Code:
@@ -400,11 +400,11 @@ eshell-unload-all-modules
       ;; since other `require' references (such as by customizing
       ;; `eshell-prefer-to-shell' to a non-nil value) might make it
       ;; impossible to unload Eshell completely
-      (if (featurep module)
-	  (ignore-errors
-	    (message "Unloading %s..." (symbol-name module))
-	    (unload-feature module)
-	    (message "Unloading %s...done" (symbol-name module)))))
+      (when (featurep module)
+	(ignore-errors
+	  (message "Unloading %s..." (symbol-name module))
+	  (unload-feature module)
+	  (message "Unloading %s...done" (symbol-name module)))))
     (message "Unloading eshell...done")))
 
 (run-hooks 'eshell-load-hook)
-- 
2.28.0

>From 55caa714c1774e57c3b9716e2b632c4158a7135f Mon Sep 17 00:00:00 2001
From: Brian Leung <[email-masked]>
Date: Mon, 31 Aug 2020 21:30:24 -0700
Subject: [PATCH 2/2] Add .git-blame-ignore-revs

Git 2.23 introduced the ability to use an ignore file for git blame,
allowing specified commits to be ignored during git-blame sessions.
---
 .git-blame-ignore-revs | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 .git-blame-ignore-revs

diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000000..60d0b5c9a6
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,30 @@
+# Configure git to ignore commits listed in this file with:
+#
+#   git config blame.ignoreRevsFile .git-blame-ignore-revs
+
+# eshell: Replace single-clause if statements with whens
+b535e0b426c2cc7b32c98304de76fbc9df0b17cf
+
+# ; tiny indentation fix to lisp/progmodes/elisp-mode.el
+bf018eefa2a9c33f9f80e977ee085e89df526992
+
+# ; Fix typos
+a3ca5318760b350309e50adf38fabc259c48ba06
+
+# ; Fix typos in etc/NEWS
+a6b45145824043eb0c049270ef37e64f1a677b4e
+
+# ; * lisp/textmodes/flyspell.el (flyspell-mode-on): Fix typo.
+f8082a5ccae11508c7eb80ca4d9fabb341985419
+
+# ; * lisp/info.el (Info-up): Fix a typo in a comment.
+478c2e23620eeda65030458762a843231f7e9b35
+
+# ; Fix typos; change "Emacs-Lisp" to "Emacs Lisp"
+abca75d2e9b2a406157383dfb7fe3f185e0b5741
+
+# ; * lisp/man.el (Man-mode): Fix formatting.
+9b35b0c99ceaeca74a16bea86a665ae5f44430a1
+
+# ; Fix typo in last change
+60cb56e9999050740f4b987ccb806ee6e8227c07
-- 
2.28.0