For a long time I've been using this function (originally made by Steve Yegge) to move files in emacs. This lets the user move the file associated with the currently open buffer to a different folder which is selected interactively. What I'd like to do now is to start using an additional version which always moves files to a specific "archive" folder rather than having the user select it. But looking at it for a while I'm not sure how to replace the user input with a default variable and have it always move files there. How could that be done?
(defun move-buffer-file (dir) "Moves both current buffer and file it's visiting to DIR." (interactive "DNew directory: ") (let* ((name (buffer-name)) (filename (buffer-file-name)) (dir (if (string-match dir "\\(?:/\\|\\\\)$") (substring dir 0 -1) dir)) (newname (concat dir "/" name))) (if (not filename) (message "Buffer '%s' is not visiting a file!" name) (progn (copy-file filename newname 1) (delete-file filename) (set-visited-file-name newname) (set-buffer-modified-p nil) t))))