293 |
:group 'auto-save) |
:group 'auto-save) |
294 |
|
|
295 |
(defcustom auto-save-file-name-transforms |
(defcustom auto-save-file-name-transforms |
296 |
`(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)" |
`(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" |
297 |
;; Don't put "\\2" inside expand-file-name, since it will be |
;; Don't put "\\2" inside expand-file-name, since it will be |
298 |
;; transformed to "/2" on DOS/Windows. |
;; transformed to "/2" on DOS/Windows. |
299 |
,(concat temporary-file-directory "\\2") t)) |
,(concat temporary-file-directory "\\2") t)) |
1357 |
rawfile truename number)))))) |
rawfile truename number)))))) |
1358 |
|
|
1359 |
(defun find-file-noselect-1 (buf filename nowarn rawfile truename number) |
(defun find-file-noselect-1 (buf filename nowarn rawfile truename number) |
1360 |
(let ((inhibit-read-only t) |
(let (error) |
|
error) |
|
1361 |
(with-current-buffer buf |
(with-current-buffer buf |
1362 |
(kill-local-variable 'find-file-literally) |
(kill-local-variable 'find-file-literally) |
1363 |
;; Needed in case we are re-visiting the file with a different |
;; Needed in case we are re-visiting the file with a different |
1364 |
;; text representation. |
;; text representation. |
1365 |
(kill-local-variable 'buffer-file-coding-system) |
(kill-local-variable 'buffer-file-coding-system) |
1366 |
(kill-local-variable 'cursor-type) |
(kill-local-variable 'cursor-type) |
1367 |
(erase-buffer) |
(let ((inhibit-read-only t)) |
1368 |
(and (default-value 'enable-multibyte-characters) |
(erase-buffer) |
1369 |
(not rawfile) |
(and (default-value 'enable-multibyte-characters) |
1370 |
(set-buffer-multibyte t)) |
(not rawfile) |
1371 |
(if rawfile |
(set-buffer-multibyte t)) |
1372 |
(condition-case () |
(if rawfile |
1373 |
(insert-file-contents-literally filename t) |
(condition-case () |
1374 |
(file-error |
(insert-file-contents-literally filename t) |
1375 |
(when (and (file-exists-p filename) |
(file-error |
1376 |
(not (file-readable-p filename))) |
(when (and (file-exists-p filename) |
1377 |
(kill-buffer buf) |
(not (file-readable-p filename))) |
1378 |
(signal 'file-error (list "File is not readable" |
(kill-buffer buf) |
1379 |
filename))) |
(signal 'file-error (list "File is not readable" |
1380 |
;; Unconditionally set error |
filename))) |
1381 |
(setq error t))) |
;; Unconditionally set error |
|
(condition-case () |
|
|
(insert-file-contents filename t) |
|
|
(file-error |
|
|
(when (and (file-exists-p filename) |
|
|
(not (file-readable-p filename))) |
|
|
(kill-buffer buf) |
|
|
(signal 'file-error (list "File is not readable" |
|
|
filename))) |
|
|
;; Run find-file-not-found-hooks until one returns non-nil. |
|
|
(or (run-hook-with-args-until-success 'find-file-not-found-functions) |
|
|
;; If they fail too, set error. |
|
1382 |
(setq error t))))) |
(setq error t))))) |
1383 |
|
(condition-case () |
1384 |
|
(let ((inhibit-read-only t)) |
1385 |
|
(insert-file-contents filename t)) |
1386 |
|
(file-error |
1387 |
|
(when (and (file-exists-p filename) |
1388 |
|
(not (file-readable-p filename))) |
1389 |
|
(kill-buffer buf) |
1390 |
|
(signal 'file-error (list "File is not readable" |
1391 |
|
filename))) |
1392 |
|
;; Run find-file-not-found-hooks until one returns non-nil. |
1393 |
|
(or (run-hook-with-args-until-success 'find-file-not-found-functions) |
1394 |
|
;; If they fail too, set error. |
1395 |
|
(setq error t)))) |
1396 |
;; Record the file's truename, and maybe use that as visited name. |
;; Record the file's truename, and maybe use that as visited name. |
1397 |
(if (equal filename buffer-file-name) |
(if (equal filename buffer-file-name) |
1398 |
(setq buffer-file-truename truename) |
(setq buffer-file-truename truename) |
4487 |
(directory-file-name . nil) |
(directory-file-name . nil) |
4488 |
(file-name-sans-versions . nil) |
(file-name-sans-versions . nil) |
4489 |
;; `identity' means just return the first arg |
;; `identity' means just return the first arg |
4490 |
;; as stripped of its quoting. |
;; not stripped of its quoting. |
4491 |
(substitute-in-file-name . identity) |
(substitute-in-file-name identity) |
4492 |
(file-name-completion 1) |
(file-name-completion 1) |
4493 |
(file-name-all-completions 1) |
(file-name-all-completions 1) |
4494 |
|
;; t means add "/:" to the result. |
4495 |
|
(file-truename t 0) |
4496 |
(rename-file 0 1) |
(rename-file 0 1) |
4497 |
(copy-file 0 1) |
(copy-file 0 1) |
4498 |
(make-symbolic-link 0 1) |
(make-symbolic-link 0 1) |
4500 |
;; For all other operations, treat the first argument only |
;; For all other operations, treat the first argument only |
4501 |
;; as the file name. |
;; as the file name. |
4502 |
'(nil 0)))) |
'(nil 0)))) |
4503 |
|
method |
4504 |
;; Copy ARGUMENTS so we can replace elements in it. |
;; Copy ARGUMENTS so we can replace elements in it. |
4505 |
(arguments (copy-sequence arguments))) |
(arguments (copy-sequence arguments))) |
4506 |
;; Strip off the /: from the file names that have this handler. |
(if (symbolp (car file-arg-indices)) |
4507 |
|
(setq method (pop file-arg-indices))) |
4508 |
|
;; Strip off the /: from the file names that have it. |
4509 |
(save-match-data |
(save-match-data |
4510 |
(while (consp file-arg-indices) |
(while (consp file-arg-indices) |
4511 |
(let ((pair (nthcdr (car file-arg-indices) arguments))) |
(let ((pair (nthcdr (car file-arg-indices) arguments))) |
4516 |
"/" |
"/" |
4517 |
(substring (car pair) 2))))) |
(substring (car pair) 2))))) |
4518 |
(setq file-arg-indices (cdr file-arg-indices)))) |
(setq file-arg-indices (cdr file-arg-indices)))) |
4519 |
(if (eq file-arg-indices 'identity) |
(cond ((eq method 'identity) |
4520 |
(car arguments) |
(car arguments)) |
4521 |
(apply operation arguments)))) |
(method |
4522 |
|
(concat "/:" (apply operation arguments))) |
4523 |
|
(t |
4524 |
|
(apply operation arguments))))) |
4525 |
|
|
4526 |
(define-key ctl-x-map "\C-f" 'find-file) |
(define-key ctl-x-map "\C-f" 'find-file) |
4527 |
(define-key ctl-x-map "\C-r" 'find-file-read-only) |
(define-key ctl-x-map "\C-r" 'find-file-read-only) |