Skip to content

Instantly share code, notes, and snippets.

@jmdeldin
Created February 13, 2013 05:16
Show Gist options
  • Save jmdeldin/4942461 to your computer and use it in GitHub Desktop.
Save jmdeldin/4942461 to your computer and use it in GitHub Desktop.
Some Elisp for getting the last modified date of files and comparing two files. The original idea was to use this for comparing whether a tangled .el file from org-babel was as new as the source .org file, but it turns out org-babel-load-file already does this!
(defun get-last-modifed (file)
"Returns the last modified date of a FILE."
(interactive)
(format-time-string "%Y-%m-%d %T"
(nth 5 (file-attributes file))))
(defun most-recent-p (file1 file2)
"Returns t if FILE1 was modified more recently than FILE2."
(string< (get-last-modifed file1) (get-last-modifed file2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment