Created
July 28, 2009 02:20
-
-
Save GeorgeJahad/156879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun gbj-backup-shell (&optional arg) | |
"makes a copy of the current shell with timestamp appended to the filename" | |
(interactive) | |
(let* | |
( | |
(save-dir "~/build/shells/") | |
(orig-file arg) | |
(mod-str nil) | |
) | |
(if (not orig-file) | |
(setq orig-file (concat save-dir (buffer-name)))) | |
(with-temp-buffer | |
; get the time stamp | |
(insert (current-time-string)) | |
;fix up the bad chars | |
(goto-char (point-min)) | |
(while (re-search-forward "[ :]" nil t) | |
(replace-match "-" nil nil)) | |
(goto-char (point-min)) | |
(while (re-search-forward "--" nil t) | |
(replace-match "-" nil nil)) | |
(setq mod-str (buffer-string))) | |
; copy out the file | |
(write-file (concat orig-file "." (substring mod-str 4 ))) | |
(rename-buffer (file-name-nondirectory orig-file)) | |
(setq buffer-file-name nil) | |
(auto-save-mode -1) | |
(message (format "Wrote out %s" (concat orig-file "." (substring mod-str 4 )))) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment