Browse Source

org-publish.el: Small code clean-up

* org-publish.el (org-publish-write-cache-file)
(org-publish-initialize-cache)
(org-publish-cache-file-needs-publishing)
(org-publish-cache-get): Small code clean-up.
Bastien Guerry 12 years ago
parent
commit
0ac65cc663
1 changed files with 12 additions and 14 deletions
  1. 12 14
      lisp/org-publish.el

+ 12 - 14
lisp/org-publish.el

@@ -1045,13 +1045,12 @@ the project."
 (defun org-publish-write-cache-file (&optional free-cache)
 (defun org-publish-write-cache-file (&optional free-cache)
   "Write `org-publish-cache' to file.
   "Write `org-publish-cache' to file.
 If FREE-CACHE, empty the cache."
 If FREE-CACHE, empty the cache."
-  (unless org-publish-cache
+  (or org-publish-cache
-    (error "%s" "`org-publish-write-cache-file' called, but no cache present"))
+      (error "`org-publish-write-cache-file' called, but no cache present"))
 
 
   (let ((cache-file (org-publish-cache-get ":cache-file:")))
   (let ((cache-file (org-publish-cache-get ":cache-file:")))
-    (unless cache-file
+    (or cache-file
-      (error
+	(error "Cannot find cache-file name in `org-publish-write-cache-file'"))
-       "%s" "Cannot find cache-file name in `org-publish-write-cache-file'"))
     (with-temp-file cache-file
     (with-temp-file cache-file
       (let ((print-level nil)
       (let ((print-level nil)
 	    (print-length nil))
 	    (print-length nil))
@@ -1068,9 +1067,8 @@ If FREE-CACHE, empty the cache."
 (defun org-publish-initialize-cache (project-name)
 (defun org-publish-initialize-cache (project-name)
   "Initialize the projects cache if not initialized yet and return it."
   "Initialize the projects cache if not initialized yet and return it."
 
 
-  (unless project-name
+  (or project-name
-    (error "%s%s" "Cannot initialize `org-publish-cache' without projects name"
+      (error "Cannot initialize `org-publish-cache' without projects name in `org-publish-initialize-cache'"))
-	   " in `org-publish-initialize-cache'"))
 
 
   (unless (file-exists-p org-publish-timestamp-directory)
   (unless (file-exists-p org-publish-timestamp-directory)
     (make-directory org-publish-timestamp-directory t))
     (make-directory org-publish-timestamp-directory t))
@@ -1110,8 +1108,8 @@ If FREE-CACHE, empty the cache."
 Return `t', if the file needs publishing.  The function also
 Return `t', if the file needs publishing.  The function also
 checks if any included files have been more recently published,
 checks if any included files have been more recently published,
 so that the file including them will be republished as well."
 so that the file including them will be republished as well."
-  (unless org-publish-cache
+  (or org-publish-cache
-    (error "%s" "`org-publish-cache-file-needs-publishing' called, but no cache present"))
+      (error "`org-publish-cache-file-needs-publishing' called, but no cache present"))
   (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
   (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
 	 (pstamp (org-publish-cache-get key))
 	 (pstamp (org-publish-cache-get key))
 	 (visiting (find-buffer-visiting filename))
 	 (visiting (find-buffer-visiting filename))
@@ -1174,15 +1172,15 @@ If the entry will be created, unless NO-CREATE is not nil."
   "Return the value stored in `org-publish-cache' for key KEY.
   "Return the value stored in `org-publish-cache' for key KEY.
 Returns nil, if no value or nil is found, or the cache does not
 Returns nil, if no value or nil is found, or the cache does not
 exist."
 exist."
-  (unless org-publish-cache
+  (or org-publish-cache
-    (error "%s" "`org-publish-cache-get' called, but no cache present"))
+      (error "`org-publish-cache-get' called, but no cache present"))
   (gethash key org-publish-cache))
   (gethash key org-publish-cache))
 
 
 (defun org-publish-cache-set (key value)
 (defun org-publish-cache-set (key value)
   "Store KEY VALUE pair in `org-publish-cache'.
   "Store KEY VALUE pair in `org-publish-cache'.
 Returns value on success, else nil."
 Returns value on success, else nil."
-  (unless org-publish-cache
+  (or org-publish-cache
-    (error "%s" "`org-publish-cache-set' called, but no cache present"))
+      (error "`org-publish-cache-set' called, but no cache present"))
   (puthash key value org-publish-cache))
   (puthash key value org-publish-cache))
 
 
 (defun org-publish-cache-ctime-of-src (f)
 (defun org-publish-cache-ctime-of-src (f)