Commit 5dbfdacd authored by Jim Blandy's avatar Jim Blandy
Browse files

The find-file-name-handler function in ../src/fileio.c is now

	callable from lisp; use it instead of writing out its code.
	* dired-aux.el (dired-compress-file): Just that.
	* dired.el (dired-uncache): Just that.
	* files.el (file-local-copy, file-truename,
	file-name-sans-versions, make-directory, save-buffers-kill-emacs):
	Just that.
	* ls-lisp.el (insert-directory): Just that.
parent 7114f404
...@@ -477,14 +477,7 @@ and use this command with a prefix argument (the value does not matter)." ...@@ -477,14 +477,7 @@ and use this command with a prefix argument (the value does not matter)."
;; Compress or uncompress FILE. ;; Compress or uncompress FILE.
;; Return the name of the compressed or uncompressed file. ;; Return the name of the compressed or uncompressed file.
;; Rerurn nil if no change in files. ;; Rerurn nil if no change in files.
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler file)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(cond (handler (cond (handler
(funcall handler 'dired-compress-file file)) (funcall handler 'dired-compress-file file))
((file-symlink-p file) ((file-symlink-p file)
......
...@@ -581,14 +581,7 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh." ...@@ -581,14 +581,7 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh."
;; Remove directory DIR from any directory cache. ;; Remove directory DIR from any directory cache.
(defun dired-uncache (dir) (defun dired-uncache (dir)
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler dir)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) dir))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'dired-uncache dir)))) (funcall handler 'dired-uncache dir))))
......
...@@ -251,14 +251,7 @@ This is an interface to the function `load'." ...@@ -251,14 +251,7 @@ This is an interface to the function `load'."
"Copy the file FILE into a temporary file on this machine. "Copy the file FILE into a temporary file on this machine.
Returns the name of the local copy, or nil, if FILE is directly Returns the name of the local copy, or nil, if FILE is directly
accessible." accessible."
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler file)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'file-local-copy file) (funcall handler 'file-local-copy file)
nil))) nil)))
...@@ -270,14 +263,7 @@ both at the level of the file and at the level of the directories ...@@ -270,14 +263,7 @@ both at the level of the file and at the level of the directories
containing it, until no links are left at any level." containing it, until no links are left at any level."
(if (string= filename "~") (if (string= filename "~")
(setq filename (expand-file-name filename))) (setq filename (expand-file-name filename)))
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler filename)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) filename))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
;; For file name that has a special handler, call handler. ;; For file name that has a special handler, call handler.
;; This is so that ange-ftp can save time by doing a no-op. ;; This is so that ange-ftp can save time by doing a no-op.
(if handler (if handler
...@@ -299,6 +285,7 @@ containing it, until no links are left at any level." ...@@ -299,6 +285,7 @@ containing it, until no links are left at any level."
(file-truename (expand-file-name target dir)) (file-truename (expand-file-name target dir))
;; No, we are done! ;; No, we are done!
filename))))) filename)))))
(defun switch-to-buffer-other-window (buffer) (defun switch-to-buffer-other-window (buffer)
"Select buffer BUFFER in another window." "Select buffer BUFFER in another window."
...@@ -1037,14 +1024,7 @@ This is a separate procedure so your site-init or startup file can ...@@ -1037,14 +1024,7 @@ This is a separate procedure so your site-init or startup file can
redefine it. redefine it.
If the optional argument KEEP-BACKUP-VERSION is non-nil, If the optional argument KEEP-BACKUP-VERSION is non-nil,
we do not remove backup version numbers, only true file version numbers." we do not remove backup version numbers, only true file version numbers."
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler name)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) name))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'file-name-sans-versions name keep-backup-version) (funcall handler 'file-name-sans-versions name keep-backup-version)
(substring name 0 (substring name 0
...@@ -1407,14 +1387,7 @@ or multiple mail buffers, etc." ...@@ -1407,14 +1387,7 @@ or multiple mail buffers, etc."
(defun make-directory (dir &optional parents) (defun make-directory (dir &optional parents)
"Create the directory DIR and any nonexistent parent dirs." "Create the directory DIR and any nonexistent parent dirs."
(interactive "FMake directory: \nP") (interactive "FMake directory: \nP")
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler dir)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'make-directory dir parents) (funcall handler 'make-directory dir parents)
(if (not parents) (if (not parents)
...@@ -1655,14 +1628,7 @@ switches do not contain `d', so that a full listing is expected. ...@@ -1655,14 +1628,7 @@ switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program This works by running a directory listing program
whose name is in the variable `ls-program'. whose name is in the variable `ls-program'.
If WILDCARD, it also runs the shell specified by `shell-file-name'." If WILDCARD, it also runs the shell specified by `shell-file-name'."
(let (handler (handlers file-name-handler-alist)) (let ((handler (find-file-name-handler file)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'insert-directory file switches (funcall handler 'insert-directory file switches
wildcard full-directory-p) wildcard full-directory-p)
......
...@@ -57,14 +57,7 @@ It does not support ordinary shell wildcards; instead, it allows ...@@ -57,14 +57,7 @@ It does not support ordinary shell wildcards; instead, it allows
regular expressions to match file names. regular expressions to match file names.
The switches that work are: A a c i r S s t u" The switches that work are: A a c i r S s t u"
(let (handler (handlers file-name-handler-alist)) (let (handler ((find-file-name-handler file)))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'insert-directory file switches (funcall handler 'insert-directory file switches
wildcard full-directory-p) wildcard full-directory-p)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment