(provide 'ido)
+(defvar cua-inhibit-cua-keys)
+
;;; User Variables
;;
;; These are some things you might want to change.
use either \\[customize] or the function `ido-mode'."
:set #'(lambda (symbol value)
(ido-mode value))
- :initialize 'custom-initialize-default
+ :initialize 'custom-initialize-set
:require 'ido
:link '(emacs-commentary-link "ido.el")
:set-after '(ido-save-directory-list-file)
(setq truncate-lines t)))))
(defun ido-is-tramp-root (&optional dir)
- (setq dir (or dir ido-current-directory))
(and ido-enable-tramp-completion
- (string-match "\\`/[^/][^/]+:\\([^/:@]+@\\)?\\'" dir)))
+ (string-match "\\`/[^/]+[@:]\\'"
+ (or dir ido-current-directory))))
(defun ido-is-root-directory (&optional dir)
(setq dir (or dir ido-current-directory))
(defun ido-set-current-directory (dir &optional subdir no-merge)
;; Set ido's current directory to DIR or DIR/SUBDIR
- (setq dir (ido-final-slash dir t))
+ (unless (and ido-enable-tramp-completion
+ (string-match "\\`/[^/]*@\\'" dir))
+ (setq dir (ido-final-slash dir t)))
(setq ido-use-merged-list nil
ido-try-merged-list (not no-merge))
- (if subdir
- (setq dir (ido-final-slash (concat dir subdir) t)))
+ (when subdir
+ (setq dir (concat dir subdir))
+ (unless (and ido-enable-tramp-completion
+ (string-match "\\`/[^/]*@\\'" dir))
+ (setq dir (ido-final-slash dir t))))
(if (equal dir ido-current-directory)
nil
(ido-trace "cd" dir)
(ido-record-command method dirname)
(ido-record-work-directory)
(funcall method dirname))
- ((y-or-n-p (format "Directory %s does not exist. Create it " filename))
+ ((y-or-n-p (format "Directory %s does not exist. Create it? " filename))
(ido-record-command method dirname)
(ido-record-work-directory dirname)
(make-directory-internal dirname)
((ido-nonreadable-directory-p dir) '())
;; do not check (ido-directory-too-big-p dir) here.
;; Caller must have done that if necessary.
+
((and ido-enable-tramp-completion
- (string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir))
-
- ;; Trick tramp's file-name-all-completions handler to DTRT, as it
- ;; has some pretty obscure requirements. This seems to work...
- ;; /ftp: => (f-n-a-c "/ftp:" "")
- ;; /ftp:kfs: => (f-n-a-c "" "/ftp:kfs:")
- ;; /ftp:kfs@ => (f-n-a-c "ftp:kfs@" "/")
- ;; /ftp:kfs@kfs: => (f-n-a-c "" "/ftp:kfs@kfs:")
- ;; Currently no attempt is made to handle multi: stuff.
-
- (let* ((prefix (match-string 1 dir))
- (user-flag (match-beginning 2))
- (len (and prefix (length prefix)))
- compl)
- (if user-flag
- (setq dir (substring dir 1)))
- (require 'tramp nil t)
- (ido-trace "tramp complete" dir)
- (setq compl (file-name-all-completions dir (if user-flag "/" "")))
- (if (> len 0)
+ (or (fboundp 'tramp-completion-mode)
+ (require 'tramp nil t))
+ (string-match "\\`/[^/]+[:@]\\'" dir))
+ ;; Strip method:user@host: part of tramp completions.
+ ;; Tramp completions do not include leading slash.
+ (let ((len (1- (length dir)))
+ (compl
+ (or (file-name-all-completions "" dir)
+ ;; work around bug in ange-ftp.
+ ;; /ftp:user@host: => nil
+ ;; /ftp:user@host:./ => ok
+ (and
+ (not (string= "/ftp:" dir))
+ (tramp-tramp-file-p dir)
+ (fboundp 'tramp-ftp-file-name-p)
+ (funcall 'tramp-ftp-file-name-p dir)
+ (string-match ":\\'" dir)
+ (file-name-all-completions "" (concat dir "./"))))))
+ (if (and compl
+ (> (length (car compl)) len)
+ (string= (substring (car compl) 0 len) (substring dir 1)))
(mapcar (lambda (c) (substring c len)) compl)
compl)))
(t
(if ido-file-extensions-order
#'ido-file-extension-lessp
#'ido-file-lessp)))
- (let ((default-directory ido-current-directory))
- (ido-to-end ;; move ftp hosts and visited files to end
- (delq nil (mapcar
- (lambda (x) (if (or (string-match "..:\\'" x)
- (and (not (ido-final-slash x))
- (get-file-buffer x))) x))
- ido-temp-list))))
+ (unless (ido-is-tramp-root ido-current-directory)
+ (let ((default-directory ido-current-directory))
+ (ido-to-end ;; move ftp hosts and visited files to end
+ (delq nil (mapcar
+ (lambda (x) (if (or (string-match "..:\\'" x)
+ (and (not (ido-final-slash x))
+ (get-file-buffer x))) x))
+ ido-temp-list)))))
(ido-to-end ;; move . files to end
(delq nil (mapcar
(lambda (x) (if (string-equal (substring x 0 1) ".") x))
(or (member name ido-ignore-item-temp-list)
(and
ido-process-ignore-lists re-list
- (let ((data (match-data))
- (ext-list (and ignore-ext ido-ignore-extensions
+ (save-match-data
+ (let ((ext-list (and ignore-ext ido-ignore-extensions
completion-ignored-extensions))
- ignorep nextstr
- (flen (length name)) slen)
- (while ext-list
- (setq nextstr (car ext-list))
- (if (cond
- ((stringp nextstr)
- (and (>= flen (setq slen (length nextstr)))
- (string-equal (substring name (- flen slen)) nextstr)))
- ((fboundp nextstr) (funcall nextstr name))
- (t nil))
- (setq ignorep t
- ext-list nil
- re-list nil)
- (setq ext-list (cdr ext-list))))
- (while re-list
- (setq nextstr (car re-list))
- (if (cond
- ((stringp nextstr) (string-match nextstr name))
- ((fboundp nextstr) (funcall nextstr name))
- (t nil))
- (setq ignorep t
- re-list nil)
- (setq re-list (cdr re-list))))
- ;; return the result
- (if ignorep
- (setq ido-ignored-list (cons name ido-ignored-list)))
- (set-match-data data)
- ignorep))))
-
+ (case-fold-search ido-case-fold)
+ ignorep nextstr
+ (flen (length name)) slen)
+ (while ext-list
+ (setq nextstr (car ext-list))
+ (if (cond
+ ((stringp nextstr)
+ (and (>= flen (setq slen (length nextstr)))
+ (string-equal (substring name (- flen slen)) nextstr)))
+ ((fboundp nextstr) (funcall nextstr name))
+ (t nil))
+ (setq ignorep t
+ ext-list nil
+ re-list nil)
+ (setq ext-list (cdr ext-list))))
+ (while re-list
+ (setq nextstr (car re-list))
+ (if (cond
+ ((stringp nextstr) (string-match nextstr name))
+ ((fboundp nextstr) (funcall nextstr name))
+ (t nil))
+ (setq ignorep t
+ re-list nil)
+ (setq re-list (cdr re-list))))
+ ;; return the result
+ (if ignorep
+ (setq ido-ignored-list (cons name ido-ignored-list)))
+ ignorep)))))
;; Private variable used by `ido-word-matching-substring'.
(defvar ido-change-word-sub)
(file-exists-p file)
(not (file-directory-p file))
(file-writable-p ido-current-directory)
- (yes-or-no-p (concat "Delete " file " ")))
+ (yes-or-no-p (concat "Delete " file "? ")))
(delete-file file)
;; Check if file still exists.
(if (file-exists-p file)