diff options
| author | Michael Albinus | 2005-08-30 22:41:02 +0000 |
|---|---|---|
| committer | Michael Albinus | 2005-08-30 22:41:02 +0000 |
| commit | c1105d052e58569a0136c4501dc584358e13b24d (patch) | |
| tree | 657328085fed9c75cf720ef5f443d9a5e181f9f5 /lisp/net | |
| parent | 1faabaaa91f189331074729f85ac366a4a296e1d (diff) | |
| download | emacs-c1105d052e58569a0136c4501dc584358e13b24d.tar.gz emacs-c1105d052e58569a0136c4501dc584358e13b24d.zip | |
Make `make-auto-save-file-name' a magic operation.
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp.el | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e3ad3959591..7dda7bc0d4c 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -1856,6 +1856,7 @@ on the FILENAME argument, even if VISIT was a string.") | |||
| 1856 | (insert-file-contents . tramp-handle-insert-file-contents) | 1856 | (insert-file-contents . tramp-handle-insert-file-contents) |
| 1857 | (write-region . tramp-handle-write-region) | 1857 | (write-region . tramp-handle-write-region) |
| 1858 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 1858 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 1859 | (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) | ||
| 1859 | (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | 1860 | (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) |
| 1860 | (dired-compress-file . tramp-handle-dired-compress-file) | 1861 | (dired-compress-file . tramp-handle-dired-compress-file) |
| 1861 | (dired-call-process . tramp-handle-dired-call-process) | 1862 | (dired-call-process . tramp-handle-dired-call-process) |
| @@ -1863,7 +1864,7 @@ on the FILENAME argument, even if VISIT was a string.") | |||
| 1863 | . tramp-handle-dired-recursive-delete-directory) | 1864 | . tramp-handle-dired-recursive-delete-directory) |
| 1864 | (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | 1865 | (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) |
| 1865 | (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | 1866 | (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) |
| 1866 | "Alist of handler functions. | 1867 | "Alist of handler functions. |
| 1867 | Operations not mentioned here will be handled by the normal Emacs functions.") | 1868 | Operations not mentioned here will be handled by the normal Emacs functions.") |
| 1868 | 1869 | ||
| 1869 | ;; Handlers for partial tramp file names. For GNU Emacs just | 1870 | ;; Handlers for partial tramp file names. For GNU Emacs just |
| @@ -3807,6 +3808,34 @@ This will break if COMMAND prints a newline, followed by the value of | |||
| 3807 | 3808 | ||
| 3808 | (tramp-run-real-handler 'find-backup-file-name (list filename))))) | 3809 | (tramp-run-real-handler 'find-backup-file-name (list filename))))) |
| 3809 | 3810 | ||
| 3811 | (defun tramp-handle-make-auto-save-file-name () | ||
| 3812 | "Like `make-auto-save-file-name' for tramp files. | ||
| 3813 | Returns a file name in `tramp-auto-save-directory' for autosaving this file." | ||
| 3814 | (when tramp-auto-save-directory | ||
| 3815 | (unless (file-exists-p tramp-auto-save-directory) | ||
| 3816 | (make-directory tramp-auto-save-directory t))) | ||
| 3817 | ;; jka-compr doesn't like auto-saving, so by appending "~" to the | ||
| 3818 | ;; file name we make sure that jka-compr isn't used for the | ||
| 3819 | ;; auto-save file. | ||
| 3820 | (let ((buffer-file-name | ||
| 3821 | (if tramp-auto-save-directory | ||
| 3822 | (expand-file-name | ||
| 3823 | (tramp-subst-strs-in-string | ||
| 3824 | '(("_" . "|") | ||
| 3825 | ("/" . "_a") | ||
| 3826 | (":" . "_b") | ||
| 3827 | ("|" . "__") | ||
| 3828 | ("[" . "_l") | ||
| 3829 | ("]" . "_r")) | ||
| 3830 | (buffer-file-name)) | ||
| 3831 | tramp-auto-save-directory) | ||
| 3832 | (buffer-file-name))) | ||
| 3833 | ;; We set it to nil because `make-auto-save-file-name' shouldn't | ||
| 3834 | ;; recurse infinitely. | ||
| 3835 | tramp-auto-save-directory) | ||
| 3836 | (tramp-run-real-handler | ||
| 3837 | 'make-auto-save-file-name))) | ||
| 3838 | |||
| 3810 | 3839 | ||
| 3811 | ;; CCC grok APPEND, LOCKNAME, CONFIRM | 3840 | ;; CCC grok APPEND, LOCKNAME, CONFIRM |
| 3812 | (defun tramp-handle-write-region | 3841 | (defun tramp-handle-write-region |
| @@ -4086,8 +4115,9 @@ ARGS are the arguments OPERATION has been called with." | |||
| 4086 | (nth 2 args)) | 4115 | (nth 2 args)) |
| 4087 | ; BUF | 4116 | ; BUF |
| 4088 | ((member operation | 4117 | ((member operation |
| 4089 | (list 'set-visited-file-modtime 'verify-visited-file-modtime | 4118 | (list 'make-auto-save-file-name |
| 4090 | ; XEmacs only | 4119 | 'set-visited-file-modtime 'verify-visited-file-modtime |
| 4120 | ; XEmacs only | ||
| 4091 | 'backup-buffer)) | 4121 | 'backup-buffer)) |
| 4092 | (buffer-file-name | 4122 | (buffer-file-name |
| 4093 | (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer)))) | 4123 | (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer)))) |
| @@ -6905,33 +6935,17 @@ as default." | |||
| 6905 | 6935 | ||
| 6906 | ;; Auto saving to a special directory. | 6936 | ;; Auto saving to a special directory. |
| 6907 | 6937 | ||
| 6908 | (defun tramp-make-auto-save-file-name (fn) | 6938 | (defun tramp-exists-file-name-handler (operation) |
| 6909 | "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | 6939 | (let ((file-name-handler-alist (list (cons "/" 'identity)))) |
| 6910 | (when tramp-auto-save-directory | 6940 | (eq (find-file-name-handler "/" operation) 'identity))) |
| 6911 | (unless (file-exists-p tramp-auto-save-directory) | 6941 | |
| 6912 | (make-directory tramp-auto-save-directory t))) | 6942 | (unless (tramp-exists-file-name-handler 'make-auto-save-file-name) |
| 6913 | ;; jka-compr doesn't like auto-saving, so by appending "~" to the | 6943 | (defadvice make-auto-save-file-name |
| 6914 | ;; file name we make sure that jka-compr isn't used for the | 6944 | (around tramp-advice-make-auto-save-file-name () activate) |
| 6915 | ;; auto-save file. | 6945 | "Invoke `tramp-handle-make-auto-save-file-name' for tramp files." |
| 6916 | (let ((buffer-file-name (expand-file-name | 6946 | (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))) |
| 6917 | (tramp-subst-strs-in-string '(("_" . "|") | 6947 | (setq ad-return-value (tramp-make-auto-save-file-name)) |
| 6918 | ("/" . "_a") | 6948 | ad-do-it))) |
| 6919 | (":" . "_b") | ||
| 6920 | ("|" . "__") | ||
| 6921 | ("[" . "_l") | ||
| 6922 | ("]" . "_r")) | ||
| 6923 | fn) | ||
| 6924 | tramp-auto-save-directory))) | ||
| 6925 | (make-auto-save-file-name))) | ||
| 6926 | |||
| 6927 | (defadvice make-auto-save-file-name | ||
| 6928 | (around tramp-advice-make-auto-save-file-name () activate) | ||
| 6929 | "Invoke `tramp-make-auto-save-file-name' for tramp files." | ||
| 6930 | (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | ||
| 6931 | tramp-auto-save-directory) | ||
| 6932 | (setq ad-return-value | ||
| 6933 | (tramp-make-auto-save-file-name (buffer-file-name))) | ||
| 6934 | ad-do-it)) | ||
| 6935 | 6949 | ||
| 6936 | ;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have | 6950 | ;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have |
| 6937 | ;; permission 0666 minus umask. This is a security threat. | 6951 | ;; permission 0666 minus umask. This is a security threat. |