Browse Source

Backport commit 662bee7d7 from Emacs

* lisp/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org-attach.el (org-attach-commit):
* lisp/org-macro.el (org-macro-initialize-templates):
* lisp/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/ox-html.el (org-html-format-spec):
* lisp/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* lisp/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.

file-attributes cleanup
662bee7d70ccd3903e123b08c7ec9108a1a2ce0b
Paul Eggert
Sun Sep 23 18:32:59 2018 -0700
Paul Eggert 6 years ago
parent
commit
d64c9a996b
6 changed files with 14 additions and 10 deletions
  1. 1 1
      lisp/ob-eval.el
  2. 1 1
      lisp/org-attach.el
  3. 2 1
      lisp/org-macro.el
  4. 3 2
      lisp/org.el
  5. 2 1
      lisp/ox-html.el
  6. 5 4
      lisp/ox-publish.el

+ 1 - 1
lisp/ob-eval.el

@@ -120,7 +120,7 @@ function in various versions of Emacs.
       (delete-file input-file))
 
     (when (and error-file (file-exists-p error-file))
-      (when (< 0 (nth 7 (file-attributes error-file)))
+      (when (< 0 (file-attribute-size (file-attributes error-file)))
 	(with-current-buffer (get-buffer-create error-buffer)
 	  (let ((pos-from-end (- (point-max) (point))))
 	    (or (bobp)

+ 1 - 1
lisp/org-attach.el

@@ -354,7 +354,7 @@ This checks for the existence of a \".git\" directory in that directory."
                   (shell-command-to-string
                    "git ls-files -zmo --exclude-standard") "\0" t))
           (if (and use-annex
-                   (>= (nth 7 (file-attributes new-or-modified))
+                   (>= (file-attribute-size (file-attributes new-or-modified))
                        org-attach-git-annex-cutoff))
               (call-process "git" nil nil nil "annex" "add" new-or-modified)
             (call-process "git" nil nil nil "add" new-or-modified))

+ 2 - 1
lisp/org-macro.el

@@ -158,7 +158,8 @@ a file, \"input-file\" and \"modification-time\"."
                      '%s)))"
 			    (prin1-to-string visited-file)
 			    (prin1-to-string
-			     (nth 5 (file-attributes visited-file))))))))
+			     (file-attribute-modification-time
+			      (file-attributes visited-file))))))))
 	 ;; Install built-in macros.
 	 (list
 	  '("n" . "(eval (org-macro--counter-increment $1 $2))")

+ 3 - 2
lisp/org.el

@@ -253,8 +253,9 @@ file to byte-code before it is loaded."
   (let* ((age (lambda (file)
 		(float-time
 		 (time-subtract nil
-				(nth 5 (or (file-attributes (file-truename file))
-					   (file-attributes file)))))))
+				(file-attribute-modification-time
+				 (or (file-attributes (file-truename file))
+				     (file-attributes file)))))))
 	 (base-name (file-name-sans-extension file))
 	 (exported-file (concat base-name ".el")))
     ;; tangle if the Org file is newer than the elisp file

+ 2 - 1
lisp/ox-html.el

@@ -1953,7 +1953,8 @@ INFO is a plist used as a communication channel."
       (?c . ,(plist-get info :creator))
       (?C . ,(let ((file (plist-get info :input-file)))
 	       (format-time-string timestamp-format
-				   (and file (nth 5 (file-attributes file))))))
+				   (and file (file-attribute-modification-time
+					      (file-attributes file))))))
       (?v . ,(or (plist-get info :html-validation-link) "")))))
 
 (defun org-html--build-pre/postamble (type info)

+ 5 - 4
lisp/ox-publish.el

@@ -881,7 +881,8 @@ time in `current-time' format."
     (or (org-publish-cache-get-file-property file :date nil t)
 	(org-publish-cache-set-file-property
 	 file :date
-	 (if (file-directory-p file) (nth 5 (file-attributes file))
+	 (if (file-directory-p file)
+	     (file-attribute-modification-time (file-attributes file))
 	   (let ((date (org-publish-find-property file :date project)))
 	     ;; DATE is a secondary string.  If it contains
 	     ;; a time-stamp, convert it to internal format.
@@ -891,7 +892,8 @@ time in `current-time' format."
 			   (let ((value (org-element-interpret-data ts)))
 			     (and (org-string-nw-p value)
 				  (org-time-string-to-time value))))))
-		   ((file-exists-p file) (nth 5 (file-attributes file)))
+		   ((file-exists-p file)
+		    (file-attribute-modification-time (file-attributes file)))
 		   (t (error "No such file: \"%s\"" file)))))))))
 
 (defun org-publish-sitemap-default-entry (entry style project)
@@ -1364,8 +1366,7 @@ does not exist."
 	       (expand-file-name (or (file-symlink-p file) file)
 				 (file-name-directory file)))))
     (if (not attr) (error "No such file: \"%s\"" file)
-      (+ (ash (car (nth 5 attr)) 16)
-	 (cadr (nth 5 attr))))))
+      (floor (float-time (file-attribute-modification-time attr))))))
 
 
 (provide 'ox-publish)