sxemacs-devel
[Top] [All Lists]

backup-buffer idiociy (was: %backup%~)

From: "Johann 'Myrkraverk' Oskarsson" <johann@xxxxxxxxxxxxxx>
Subject: backup-buffer idiociy (was: %backup%~)
Date: Thu, 17 Feb 2005 15:10:47 +0000
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux)
Hi,

Looking at the (defun backup-buffer ...) I found some code duplication
I'd like to get rid of.

Unless I'm mistaken,

  (condition-case ()
      (copy-file real-file-name backupname t t)
    (file-error
     ;; If copying fails because file BACKUPNAME
     ;; is not writable, delete that file and try again.
     (if (and (file-exists-p backupname)
              (not (file-writable-p backupname)))
         (delete-file backupname))
     (copy-file real-file-name backupname t t)))

occurs twice in the function.  I'm pretty sure this can be put in a
defun on its own.

I'm a bit hesitant to actually provide a merge request right now, I'm
not that strong in lisp...

I believe it's a lot easier to put %backup%~ in auto-save-directory
and still fallback to ~ once the code duplication is removed.

To actually use auto-save-directory, I propose

  (expand-file-name "%backup%~" (or auto-save-directory
                                    (convert-standard-filename "~")))

becouse:

> (expand-file-name NAME &optional DEFAULT-DIRECTORY)
[snip]
> if DEFAULT-DIRECTORY is nil or missing, the current buffer's value
> of `default-directory' is used.

Which I'm not sure I'd like.

Now it's just a matter of putting this all together.

What do you guys think?


Johann

-- 
This line is left blank intentionally


<Prev in Thread] Current Thread [Next in Thread>