aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-10-04 05:10:54 +0000
committerRichard M. Stallman1996-10-04 05:10:54 +0000
commit47afc068c062f3fbc04e6938705ded7fe468eecf (patch)
tree4025c73a3cdc3f87c62b00cffc3693534d0a96f7
parent213d0b1f8bbaba95ef61bf50ebc1dc63bb4f532f (diff)
downloademacs-47afc068c062f3fbc04e6938705ded7fe468eecf.tar.gz
emacs-47afc068c062f3fbc04e6938705ded7fe468eecf.zip
(file-name-non-special): New function.
Add it to file-name-handler-alist.
-rw-r--r--lisp/files.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el
index d99b42476bd..c44b1f31610 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2729,6 +2729,50 @@ With prefix arg, silently save all file-visiting buffers, then kill."
2729 (run-hook-with-args-until-failure 'kill-emacs-query-functions) 2729 (run-hook-with-args-until-failure 'kill-emacs-query-functions)
2730 (kill-emacs))) 2730 (kill-emacs)))
2731 2731
2732;; We use /: as a prefix to "quote" a file name
2733;; so that magic file name handlers will not apply to it.
2734
2735(setq file-name-handler-alist
2736 (cons '("\\`/:" . file-name-non-special)
2737 file-name-handler-alist))
2738
2739;; We depend on being the last handler on the list,
2740;; so that anything else which does need handling
2741;; has been handled already.
2742;; So it is safe for us to inhibit *all* magic file name handlers.
2743
2744(defun file-name-non-special (operation &rest arguments)
2745 (let ((file-name-handler-alist nil)
2746 ;; Get a list of the indices of the args which are file names.
2747 (file-arg-indices
2748 (cdr (or (assq operation
2749 ;; The first four are special because they
2750 ;; return a file name. We want to include the /:
2751 ;; in the return value.
2752 ;; So just avoid stripping it in the first place.
2753 '((expand-file-name . nil)
2754 (file-name-directory . nil)
2755 (file-name-as-directory . nil)
2756 (directory-file-name . nil)
2757 (rename-file 0 1)
2758 (copy-file 0 1)
2759 (make-symbolic-link 0 1)
2760 (add-name-to-file 0 1)))
2761 ;; For all other operations, treat the first argument only
2762 ;; as the file name.
2763 '(nil 0))))
2764 ;; Copy ARGUMENTS so we can replace elements in it.
2765 (arguments (copy-sequence arguments)))
2766 ;; Strip off the /: from the file names that have this handler.
2767 (save-match-data
2768 (while file-arg-indices
2769 (and (nth (car file-arg-indices) arguments)
2770 (string-match "\\`/:" (nth (car file-arg-indices) arguments))
2771 (setcar (nthcdr (car file-arg-indices) arguments)
2772 (substring (nth (car file-arg-indices) arguments) 2)))
2773 (setq file-arg-indices (cdr file-arg-indices))))
2774 (apply operation arguments)))
2775
2732(define-key ctl-x-map "\C-f" 'find-file) 2776(define-key ctl-x-map "\C-f" 'find-file)
2733(define-key ctl-x-map "\C-q" 'toggle-read-only) 2777(define-key ctl-x-map "\C-q" 'toggle-read-only)
2734(define-key ctl-x-map "\C-r" 'find-file-read-only) 2778(define-key ctl-x-map "\C-r" 'find-file-read-only)