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 | |
| parent | 1faabaaa91f189331074729f85ac366a4a296e1d (diff) | |
| download | emacs-c1105d052e58569a0136c4501dc584358e13b24d.tar.gz emacs-c1105d052e58569a0136c4501dc584358e13b24d.zip | |
Make `make-auto-save-file-name' a magic operation.
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/files.el | 98 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 74 | ||||
| -rw-r--r-- | lispref/ChangeLog | 8 | ||||
| -rw-r--r-- | lispref/files.texi | 4 |
7 files changed, 125 insertions, 80 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog index e803b5bef69..bf83b688b17 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2005-08-31 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * NEWS: Add entry for `make-auto-save-file-name'. | ||
| 4 | |||
| 1 | 2005-08-19 Emilio C. Lopes <eclig@gmx.net> | 5 | 2005-08-19 Emilio C. Lopes <eclig@gmx.net> |
| 2 | 6 | ||
| 3 | * emacsclient.1 (DESCRIPTION): Reflect inclusion in the | 7 | * emacsclient.1 (DESCRIPTION): Reflect inclusion in the |
| @@ -3908,6 +3908,10 @@ operations. | |||
| 3908 | This is useful for autoloaded handlers, to prevent them from being | 3908 | This is useful for autoloaded handlers, to prevent them from being |
| 3909 | autoloaded when not really necessary. | 3909 | autoloaded when not really necessary. |
| 3910 | 3910 | ||
| 3911 | +++ | ||
| 3912 | *** The function `make-auto-save-file-name' is now handled by file | ||
| 3913 | name handlers. This will be exploited for remote files mainly. | ||
| 3914 | |||
| 3911 | ** Input changes: | 3915 | ** Input changes: |
| 3912 | 3916 | ||
| 3913 | +++ | 3917 | +++ |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4167c8c679d..7f3d83d46b4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2005-08-31 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * files.el (make-auto-save-file-name): Add file name handler call | ||
| 4 | if applicable. | ||
| 5 | |||
| 6 | * net/tramp.el (tramp-file-name-handler-alist) | ||
| 7 | (tramp-file-name-for-operation): Add `make-auto-save-file-name'. | ||
| 8 | (tramp-handle-make-auto-save-file-name): Renamed from | ||
| 9 | `tramp-make-auto-save-file-name'. | ||
| 10 | (tramp-exists-file-name-handler): New defun. | ||
| 11 | (tramp-advice-make-auto-save-file-name): Make defadvice only when | ||
| 12 | `make-auto-save-file-name' is not a magic file name operation. | ||
| 13 | |||
| 1 | 2005-08-30 Carsten Dominik <dominik@science.uva.nl> | 14 | 2005-08-30 Carsten Dominik <dominik@science.uva.nl> |
| 2 | 15 | ||
| 3 | * textmodes/org.el (org-special-keyword): New face. | 16 | * textmodes/org.el (org-special-keyword): New face. |
diff --git a/lisp/files.el b/lisp/files.el index 4004cb2324b..90fb586cd30 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4062,53 +4062,57 @@ Does not consider `auto-save-visited-file-name' as that variable is checked | |||
| 4062 | before calling this function. You can redefine this for customization. | 4062 | before calling this function. You can redefine this for customization. |
| 4063 | See also `auto-save-file-name-p'." | 4063 | See also `auto-save-file-name-p'." |
| 4064 | (if buffer-file-name | 4064 | (if buffer-file-name |
| 4065 | (let ((list auto-save-file-name-transforms) | 4065 | (let ((handler (find-file-name-handler buffer-file-name |
| 4066 | (filename buffer-file-name) | 4066 | 'make-auto-save-file-name))) |
| 4067 | result uniq) | 4067 | (if handler |
| 4068 | ;; Apply user-specified translations | 4068 | (funcall handler 'make-auto-save-file-name) |
| 4069 | ;; to the file name. | 4069 | (let ((list auto-save-file-name-transforms) |
| 4070 | (while (and list (not result)) | 4070 | (filename buffer-file-name) |
| 4071 | (if (string-match (car (car list)) filename) | 4071 | result uniq) |
| 4072 | (setq result (replace-match (cadr (car list)) t nil | 4072 | ;; Apply user-specified translations |
| 4073 | filename) | 4073 | ;; to the file name. |
| 4074 | uniq (car (cddr (car list))))) | 4074 | (while (and list (not result)) |
| 4075 | (setq list (cdr list))) | 4075 | (if (string-match (car (car list)) filename) |
| 4076 | (if result | 4076 | (setq result (replace-match (cadr (car list)) t nil |
| 4077 | (if uniq | 4077 | filename) |
| 4078 | (setq filename (concat | 4078 | uniq (car (cddr (car list))))) |
| 4079 | (file-name-directory result) | 4079 | (setq list (cdr list))) |
| 4080 | (subst-char-in-string | 4080 | (if result |
| 4081 | ?/ ?! | 4081 | (if uniq |
| 4082 | (replace-regexp-in-string "!" "!!" | 4082 | (setq filename (concat |
| 4083 | filename)))) | 4083 | (file-name-directory result) |
| 4084 | (setq filename result))) | 4084 | (subst-char-in-string |
| 4085 | (setq result | 4085 | ?/ ?! |
| 4086 | (if (and (eq system-type 'ms-dos) | 4086 | (replace-regexp-in-string "!" "!!" |
| 4087 | (not (msdos-long-file-names))) | 4087 | filename)))) |
| 4088 | ;; We truncate the file name to DOS 8+3 limits | 4088 | (setq filename result))) |
| 4089 | ;; before doing anything else, because the regexp | 4089 | (setq result |
| 4090 | ;; passed to string-match below cannot handle | 4090 | (if (and (eq system-type 'ms-dos) |
| 4091 | ;; extensions longer than 3 characters, multiple | 4091 | (not (msdos-long-file-names))) |
| 4092 | ;; dots, and other atrocities. | 4092 | ;; We truncate the file name to DOS 8+3 limits |
| 4093 | (let ((fn (dos-8+3-filename | 4093 | ;; before doing anything else, because the regexp |
| 4094 | (file-name-nondirectory buffer-file-name)))) | 4094 | ;; passed to string-match below cannot handle |
| 4095 | (string-match | 4095 | ;; extensions longer than 3 characters, multiple |
| 4096 | "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" | 4096 | ;; dots, and other atrocities. |
| 4097 | fn) | 4097 | (let ((fn (dos-8+3-filename |
| 4098 | (concat (file-name-directory buffer-file-name) | 4098 | (file-name-nondirectory buffer-file-name)))) |
| 4099 | "#" (match-string 1 fn) | 4099 | (string-match |
| 4100 | "." (match-string 3 fn) "#")) | 4100 | "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" |
| 4101 | (concat (file-name-directory filename) | 4101 | fn) |
| 4102 | "#" | 4102 | (concat (file-name-directory buffer-file-name) |
| 4103 | (file-name-nondirectory filename) | 4103 | "#" (match-string 1 fn) |
| 4104 | "#"))) | 4104 | "." (match-string 3 fn) "#")) |
| 4105 | ;; Make sure auto-save file names don't contain characters | 4105 | (concat (file-name-directory filename) |
| 4106 | ;; invalid for the underlying filesystem. | 4106 | "#" |
| 4107 | (if (and (memq system-type '(ms-dos windows-nt)) | 4107 | (file-name-nondirectory filename) |
| 4108 | ;; Don't modify remote (ange-ftp) filenames | 4108 | "#"))) |
| 4109 | (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result))) | 4109 | ;; Make sure auto-save file names don't contain characters |
| 4110 | (convert-standard-filename result) | 4110 | ;; invalid for the underlying filesystem. |
| 4111 | result)) | 4111 | (if (and (memq system-type '(ms-dos windows-nt)) |
| 4112 | ;; Don't modify remote (ange-ftp) filenames | ||
| 4113 | (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result))) | ||
| 4114 | (convert-standard-filename result) | ||
| 4115 | result)))) | ||
| 4112 | 4116 | ||
| 4113 | ;; Deal with buffers that don't have any associated files. (Mail | 4117 | ;; Deal with buffers that don't have any associated files. (Mail |
| 4114 | ;; mode tends to create a good number of these.) | 4118 | ;; mode tends to create a good number of these.) |
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. |
diff --git a/lispref/ChangeLog b/lispref/ChangeLog index cc5384fdf08..9f71006f79a 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2005-08-31 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * files.texi (Magic File Names): Add `make-auto-save-file-name'. | ||
| 4 | |||
| 1 | 2005-08-29 Richard M. Stallman <rms@gnu.org> | 5 | 2005-08-29 Richard M. Stallman <rms@gnu.org> |
| 2 | 6 | ||
| 3 | * elisp.texi (Top): Update subnode menu. | 7 | * elisp.texi (Top): Update subnode menu. |
| @@ -20,7 +24,7 @@ | |||
| 20 | 24 | ||
| 21 | * display.texi (Finding Overlays): Fix `find-overlay-prop' in | 25 | * display.texi (Finding Overlays): Fix `find-overlay-prop' in |
| 22 | `next-overlay-change' example. | 26 | `next-overlay-change' example. |
| 23 | 27 | ||
| 24 | 2005-08-22 Juri Linkov <juri@jurta.org> | 28 | 2005-08-22 Juri Linkov <juri@jurta.org> |
| 25 | 29 | ||
| 26 | * display.texi (Attribute Functions): Add set-face-inverse-video-p. | 30 | * display.texi (Attribute Functions): Add set-face-inverse-video-p. |
| @@ -65,7 +69,7 @@ | |||
| 65 | (Frame Parameters): Refer to Geometry. | 69 | (Frame Parameters): Refer to Geometry. |
| 66 | 70 | ||
| 67 | * buffers.texi (The Buffer List): Fix xrefs. | 71 | * buffers.texi (The Buffer List): Fix xrefs. |
| 68 | 72 | ||
| 69 | * windows.texi (Splitting Windows): Fix xref. | 73 | * windows.texi (Splitting Windows): Fix xref. |
| 70 | 74 | ||
| 71 | * frames.texi (Layout Parameters): Add xref. | 75 | * frames.texi (Layout Parameters): Add xref. |
diff --git a/lispref/files.texi b/lispref/files.texi index d8d47964cdf..1ec4b2e5dc2 100644 --- a/lispref/files.texi +++ b/lispref/files.texi | |||
| @@ -2580,7 +2580,9 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 2580 | @code{get-file-buffer}, | 2580 | @code{get-file-buffer}, |
| 2581 | @code{insert-directory}, | 2581 | @code{insert-directory}, |
| 2582 | @code{insert-file-contents},@* | 2582 | @code{insert-file-contents},@* |
| 2583 | @code{load}, @code{make-directory}, | 2583 | @code{load}, |
| 2584 | @code{make-auto-save-file-name}, | ||
| 2585 | @code{make-directory}, | ||
| 2584 | @code{make-directory-internal}, | 2586 | @code{make-directory-internal}, |
| 2585 | @code{make-symbolic-link},@* | 2587 | @code{make-symbolic-link},@* |
| 2586 | @code{rename-file}, @code{set-file-modes}, @code{set-file-times}, | 2588 | @code{rename-file}, @code{set-file-modes}, @code{set-file-times}, |