Mercurial > emacs
comparison lisp/minibuffer.el @ 93945:76ebfa5df8a2
* minibuffer.el (minibuffer--double-dollars, read-file-name-internal):
New functions.
* fileio.c (read_file_name_cleanup, Fread_file_name_internal):
Move functions to minibuffer.el.
(syms_of_fileio): Don't declare them.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 10 Apr 2008 03:12:49 +0000 |
parents | a5df3c8bf64a |
children | bd1b8b62427b |
comparison
equal
deleted
inserted
replaced
93944:a5df3c8bf64a | 93945:76ebfa5df8a2 |
---|---|
448 (if (characterp last-command-char) | 448 (if (characterp last-command-char) |
449 (call-interactively 'self-insert-command) | 449 (call-interactively 'self-insert-command) |
450 (ding)) | 450 (ding)) |
451 (exit-minibuffer)) | 451 (exit-minibuffer)) |
452 | 452 |
453 (defun minibuffer--double-dollars (str) | |
454 (replace-regexp-in-string "\\$" "$$" str)) | |
455 | |
456 (defun read-file-name-internal (string dir action) | |
457 "Internal subroutine for read-file-name. Do not call this." | |
458 (setq dir (expand-file-name dir)) | |
459 (if (and (zerop (length string)) (eq 'lambda action)) | |
460 nil ; FIXME: why? | |
461 (let* ((str (substitute-in-file-name string)) | |
462 (name (file-name-nondirectory str)) | |
463 (specdir (file-name-directory str)) | |
464 (realdir (if specdir (expand-file-name specdir dir) | |
465 (file-name-as-directory dir)))) | |
466 | |
467 (cond | |
468 ((null action) | |
469 (let ((comp (file-name-completion name realdir | |
470 read-file-name-predicate))) | |
471 (if (stringp comp) | |
472 ;; Requote the $s before returning the completion. | |
473 (minibuffer--double-dollars (concat specdir comp)) | |
474 ;; Requote the $s before checking for changes. | |
475 (setq str (minibuffer--double-dollars str)) | |
476 (if (string-equal string str) | |
477 comp | |
478 ;; If there's no real completion, but substitute-in-file-name | |
479 ;; changed the string, then return the new string. | |
480 str)))) | |
481 | |
482 ((eq action t) | |
483 (let ((all (file-name-all-completions name realdir))) | |
484 (if (memq read-file-name-predicate '(nil file-exists-p)) | |
485 all | |
486 (let ((comp ()) | |
487 (pred | |
488 (if (eq read-file-name-predicate 'file-directory-p) | |
489 ;; Brute-force speed up for directory checking: | |
490 ;; Discard strings which don't end in a slash. | |
491 (lambda (s) | |
492 (let ((len (length s))) | |
493 (and (> len 0) (eq (aref s (1- len)) ?/)))) | |
494 ;; Must do it the hard (and slow) way. | |
495 read-file-name-predicate))) | |
496 (let ((default-directory realdir)) | |
497 (dolist (tem all) | |
498 (if (funcall pred tem) (push tem comp)))) | |
499 (nreverse comp))))) | |
500 | |
501 (t | |
502 ;; Only other case actually used is ACTION = lambda. | |
503 (let ((default-directory dir)) | |
504 (funcall (or read-file-name-predicate 'file-exists-p) str))))))) | |
505 | |
506 | |
453 (provide 'minibuffer) | 507 (provide 'minibuffer) |
454 ;;; minibuffer.el ends here | 508 ;;; minibuffer.el ends here |