   (dolist (dir (darcsum-selected-changeset))
     (dolist (file (cdr dir))
       (let ((item (darcsum-change-item (cadr file))))
-	(if (and (symbolp item) (eq item 'newfile))
-	    (progn
-	      (setcar (cadr file) 'addfile)
-	      (with-temp-buffer
-		(cd (expand-file-name (car dir)))
-		(if (/= 0 (call-process darcsum-program nil t nil
-					"add" (car file)))
-		    (error "Error running `darcsum add' for `%s' in dir `%s'"
-			   (car file) (car dir)))))
-	  (error "Can only add New entries for `%s' in dir `%s'"
-		 (car file) (car dir))))))
+        (if (and (symbolp item) (eq item 'newfile))
+            (progn
+              (setcar (cadr file) 'addfile)
+              (with-temp-buffer
+                (cd (expand-file-name (car dir)))
+                (if (/= 0 (call-process darcsum-program nil t nil
+                                        "add" (car file)))
+                    (error "Error running `darcsum add' for `%s' in dir `%s'"
+                           (car file) (car dir)))))
+          (error "Can only add New entries for `%s' in dir `%s'"
+                 (car file) (car dir))))))
   (darcsum-refresh))
 
 (defun darcsum-add-to-boring (path)


;;;###autoload
(defun darcsum-whatsnew (directory
			 &optional look-for-adds no-display show-context)
  "Run `darcs whatsnew' in DIRECTORY, displaying the output in `darcsum-mode'.

When invoked interactively, prompt for the directory to display changes for."
  (interactive
   ; fancy "DDirectory: \nP"
   (let ((root
	  (if darcsum-whatsnew-at-toplevel
	      (darcsum-repository-root)
	    default-directory)))
     (list (funcall (if (fboundp 'read-directory-name)
			'read-directory-name
		      'read-file-name)
		    "Directory: " root root)
	   (or darcsum-look-for-adds current-prefix-arg))))
  (with-temp-buffer
    (cd directory)
    (let ((repo (darcsum-repository-root)))
      (unless repo
	(error "Directory `%s' is not under darcs version control"
	       directory))
      (cd repo))
    (let* ((process-environment (append 
				 (list "DARCS_DONT_ESCAPE_TRAILING_SPACES=1"
				       "DARCS_DONT_COLOR=1"
				       "DARCS_DONT_ESCAPE_TRAILING_CR=1")
				 process-environment))
	   (args (append
		  ;; Build a list of arguments for call-process
		  (list darcsum-program nil t nil)
		  (list "whatsnew" "--no-summary")
		  (darcsum-fix-switches darcsum-whatsnew-switches)
		  ; Arguments override user preferences
		  (unless (null look-for-adds) (list "--look-for-adds"))
		  (unless (null show-context) (list "--unified"))
		  (unless (string= directory default-directory)
		    (list (file-relative-name
			   directory default-directory)))
		  nil))
	   (result (apply 'call-process args)))
      (if (/= result 0)
	  (if (= result 1)
	      (progn (and (interactive-p) (message "No changes!"))
		     nil)
	    (progn (if (member "*darcs-output*"
			       (mapcar (lambda (&rest x)
					 (apply 'buffer-name x))
				       (buffer-list)) )
		       (kill-buffer "*darcs-output*"))
		   (if (fboundp 'clone-buffer)
		       (clone-buffer "*darcs-output*" t))
		   (error "Error running darcsum whatsnew")))
	(let ((changes (darcsum-read-changeset darcsum-default-expanded)))
	  (if (and changes (not no-display))
	      (darcsum-display changes look-for-adds))
	  changes)))))

; lifted from diff.el
(defun darcsum-fix-switches (switch-spec)

VIEW non-nil means open in View mode."
  (interactive (list last-input-event current-prefix-arg))
  (let* ((type (get-text-property (point) 'darcsum-line-type))
         (file (if (eq 'type 'dir)
                   (get-text-property (point) 'darcsum-dir)
                 (darcsum-path (point)))))
    (cond
     ((eq type 'dir)
      (find-file (get-text-property (point) 'darcsum-dir)))
     ((eq type 'file)
      (cond ((eq other 'dont-select)
             (display-buffer (find-file-noselect file)))
            ((and other view)
             (view-file-other-window file))
            (view (view-file file))
            (other (find-file-other-window file))
            (t (find-file file))))
     ((eq type 'change)
      (let ((change-line (car (get-text-property (point) 'darcsum-change))))
        (with-current-buffer (cond ((eq other 'dont-select)
                                    (display-buffer (find-file-noselect file)))
                                   ((and other view)
                                    (view-file-other-window file))
                                   (view (view-file file))
                                   (other (find-file-other-window file))
                                   (t (find-file file)))
          (if (listp change-line)
              (setq change-line (car change-line)))
          (goto-line (abs change-line))))))))

(defun darcsum-find-file-other-window (e)
  "Select a buffer containing the file in another window."
