Custom 'save-a-copy-as' interactive function begins to error
Posted: Tue Jul 08, 2008 4:15 am
I wrote my own 'save-a-copy-as' function (how much does it suck that emacs doesn't ship with one?) which worked great until recently. I don't know what changed -- nothing, I would have said -- but now when I run it on Cygwin emacs 21.x, it errors:
Here's the code:
Code: Select all
find-coding-systems-region: Wrong type argument: integer-or-marker-p, nil
Code: Select all
(defun save-a-copy-as (file-or-directory)
"Saves a copy of the current buffer in the given directory or file, leaving
the original file in the buffer, and asking for confirmation before
overwriting an existing file."
(interactive "FSave a copy as file: ")
(save-excursion
(save-a-copy-as-confirming file-or-directory t)))
(defun save-a-copy-as-confirming (target-file-or-directory confirming)
"Saves a copy of the current buffer in the given target directory or file,
leaving the original file in the buffer.
If argument confirming is nil, will overwrite any existing file with the same
name; if confirming is anything else, will prompt the user first."
(let ((target-file
(concat target-file-or-directory
(when (string-match "/$" target-file-or-directory)
(buffer-name)))))
(write-region nil nil target-file nil nil nil confirming)))