changeset 85659:be317780de60

2007-10-26 John Wiegley <johnw@newartisans.com> * eshell/em-unix.el (eshell/diff): Before calling the `diff' function, ensure that the third argument is turned into a NIL if the string is otherwise completely empty (either no characters, or all tabs/spaces). This fixes a bug from a user who found himself unable to customize `diff-switches' and still use Eshell's diff command.
author John Wiegley <johnw@newartisans.com>
date Fri, 26 Oct 2007 08:07:17 +0000
parents 3b737e455071
children 7dd9ef0af1e0
files lisp/ChangeLog lisp/eshell/em-unix.el
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Oct 26 07:35:31 2007 +0000
+++ b/lisp/ChangeLog	Fri Oct 26 08:07:17 2007 +0000
@@ -1,3 +1,12 @@
+2007-10-26  John Wiegley  <johnw@newartisans.com>
+
+	* eshell/em-unix.el (eshell/diff): Before calling the `diff'
+	function, ensure that the third argument is turned into a NIL if
+	the string is otherwise completely empty (either no characters, or
+	all tabs/spaces).  This fixes a bug from a user who found himself
+	unable to customize `diff-switches' and still use Eshell's diff
+	command.
+
 2007-10-26  Glenn Morris  <rgm@gnu.org>
 
 	* emacs-lisp/bytecomp.el (byte-compile-warnings): Autoload the
--- a/lisp/eshell/em-unix.el	Fri Oct 26 07:35:31 2007 +0000
+++ b/lisp/eshell/em-unix.el	Fri Oct 26 08:07:17 2007 +0000
@@ -974,6 +974,13 @@
   (if eshell-diff-window-config
       (set-window-configuration eshell-diff-window-config)))
 
+(defun nil-blank-string ( string )
+  "if a string is all blanks return nil, if there are non-blank characters
+return the string"
+  (cond
+   ((string-match "[^[:blank:]]" string ) string)
+   (nil)))
+
 (defun eshell/diff (&rest args)
   "Alias \"diff\" to call Emacs `diff' function."
   (let ((orig-args (eshell-stringify-list (eshell-flatten-list args))))
@@ -995,7 +1002,8 @@
 	  (setcdr (last args 3) nil))
 	(with-current-buffer
 	    (condition-case err
-		(diff old new (eshell-flatten-and-stringify args))
+		(diff old new
+		      (nil-blank-string (eshell-flatten-and-stringify args)))
 	      (error
 	       (throw 'eshell-replace-command
 		      (eshell-parse-command "*diff" orig-args))))