* elmo-localdir.el (elmo-folder-rename-internal): Referctoring;
authorkaoru <kaoru>
Sat, 1 Feb 2003 00:48:12 +0000 (00:48 +0000)
committerkaoru <kaoru>
Sat, 1 Feb 2003 00:48:12 +0000 (00:48 +0000)
Replace nested conditional with guard clauses.
* elmo-archive.el (elmo-folder-rename-internal): Ditto.

elmo/ChangeLog
elmo/elmo-archive.el
elmo/elmo-localdir.el

index 79aadea..98d3ff1 100644 (file)
@@ -1,5 +1,9 @@
 2003-02-01  TAKAHASHI Kaoru  <kaoru@kaisei.org>
 
+       * elmo-localdir.el (elmo-folder-rename-internal): Referctoring;
+       Replace nested conditional with guard clauses.
+       * elmo-archive.el (elmo-folder-rename-internal): Ditto.
+
        * elmo-imap4.el: Remove Nemacs hack, replace `elmo-read' with `read'.
        * elmo-util.el: Ditto.
 
index ce97bb6..c903302 100644 (file)
@@ -465,12 +465,14 @@ TYPE specifies the archiver's symbol."
                        (elmo-archive-folder-archive-prefix-internal
                         new-folder)))
       (error "Not same archive type and prefix"))
-    (if (not (file-exists-p old-arc))
-       (error "No such file: %s" old-arc)
-      (if (file-exists-p new-arc)
-         (error "Already exists: %s" new-arc)
-       (rename-file old-arc new-arc)
-       t))))
+    (unless (file-exists-p old-arc)
+      (error "No such file: %s" old-arc))
+    (when (file-exists-p new-arc)
+      (error "Already exists: %s" new-arc))
+    (unless (file-directory-p new-dir)
+      (elmo-make-directory new-dir))
+    (rename-file old-arc new-arc)
+    t))
 
 (defun elmo-archive-folder-list-subfolders (folder one-level)
   (if elmo-archive-treat-file
index 7b7f114..3ab93a0 100644 (file)
   (let* ((old (elmo-localdir-folder-directory-internal folder))
         (new (elmo-localdir-folder-directory-internal new-folder))
         (new-dir (directory-file-name (file-name-directory new))))
-    (if (not (file-directory-p old))
-       (error "No such directory: %s" old)
-      (if (file-exists-p new)
-         (error "Already exists directory: %s" new)
-       (if (not (file-exists-p new-dir))
-           (elmo-make-directory new-dir))
-       (rename-file old new)
-       t))))
+    (unless (file-directory-p old)
+      (error "No such directory: %s" old))
+    (when (file-exists-p new)
+      (error "Already exists directory: %s" new))
+    (unless (file-directory-p new-dir)
+      (elmo-make-directory new-dir))
+    (rename-file old new)
+    t))
 
 (defsubst elmo-localdir-field-condition-match (folder condition
                                                      number number-list)