]> code.delx.au - gnu-emacs/blobdiff - lisp/ido.el
(ido-save-history): Set the `coding' local
[gnu-emacs] / lisp / ido.el
index 0808075b495ee4f8e275832976300f7243aa8a55..2a32743907853cd871917daf8c733f665ed88b77 100644 (file)
@@ -11,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -449,7 +449,7 @@ in merged file and directory lists."
 ;(setq ido-ignore-files '("^ " "\\.c$" "\\.h$"))
 
 (defcustom ido-default-file-method  'raise-frame
-    "*How to visit a new file when using `ido-find-file'.
+  "*How to visit a new file when using `ido-find-file'.
 Possible values:
 `selected-window' Show new file in selected window
 `other-window'   Show new file in another window (same frame)
@@ -469,7 +469,7 @@ Possible values:
     :group 'ido)
 
 (defcustom ido-default-buffer-method  'raise-frame
-    "*How to switch to new buffer when using `ido-switch-buffer'.
+  "*How to switch to new buffer when using `ido-switch-buffer'.
 See `ido-default-file-method' for details."
     :type '(choice (const :tag "Show in selected window" selected-window)
                   (const :tag "Show in other window" other-window)
@@ -898,7 +898,7 @@ See documentation of `walk-windows' for useful values.")
 (defcustom ido-minibuffer-setup-hook nil
   "*Ido-specific customization of minibuffer setup.
 
-This hook is run during minibuffer setup iff `ido' will be active.
+This hook is run during minibuffer setup if `ido' is active.
 It is intended for use in customizing ido for interoperation
 with other packages.  For instance:
 
@@ -1309,6 +1309,8 @@ Value is an integer which is number of chars to right of prompt.")
       (unwind-protect
          (with-current-buffer buf
            (erase-buffer)
+           (insert ";;; -*- coding: utf-8 -*-\n")
+           (setq buffer-file-coding-system 'utf-8)
            (ido-pp 'ido-last-directory-list)
            (ido-pp 'ido-work-directory-list)
            (ido-pp 'ido-work-file-list)
@@ -2280,9 +2282,10 @@ If cursor is not at the end of the user input, move to end of input."
                filename t))
 
         ((and ido-use-filename-at-point
-              (setq fn (if (eq ido-use-filename-at-point 'guess)
-                           (with-no-warnings (ffap-guesser))
-                         (ffap-string-at-point)))
+              (setq fn (with-no-warnings
+                         (if (eq ido-use-filename-at-point 'guess)
+                             (ffap-guesser)
+                           (ffap-string-at-point))))
               (not (string-match "^http:/" fn))
               (setq d (file-name-directory fn))
               (file-directory-p d))
@@ -3354,7 +3357,7 @@ for first matching file."
 
 (defun ido-to-end (items)
   ;; Move the elements from ITEMS to the end of `ido-temp-list'
-  (mapcar
+  (mapc
    (lambda (elem)
      (setq ido-temp-list (delq elem ido-temp-list)))
    items)
@@ -3362,6 +3365,8 @@ for first matching file."
       (nconc ido-temp-list items)
     (setq ido-temp-list items)))
 
+(declare-function tramp-tramp-file-p "net/tramp" (name))
+
 (defun ido-file-name-all-completions-1 (dir)
   (cond
    ((ido-nonreadable-directory-p dir) '())
@@ -3369,24 +3374,25 @@ for first matching file."
    ;; Caller must have done that if necessary.
 
    ((and ido-enable-tramp-completion
-        (or (fboundp 'tramp-completion-mode)
+        (or (fboundp 'tramp-completion-mode-p)
             (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 "./"))))))
+    (let* ((len (1- (length dir)))
+          (tramp-completion-mode t)
+          (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)))
@@ -3603,7 +3609,7 @@ for first matching file."
         full-matches suffix-matches prefix-matches matches)
     (setq ido-incomplete-regexp nil)
     (condition-case error
-        (mapcar
+        (mapc
          (lambda (item)
            (let ((name (ido-name item)))
             (if (and (or non-prefix-dot
@@ -3648,7 +3654,7 @@ for first matching file."
       (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*"))
       (if ido-enable-prefix
          (setq re (concat "\\`" re)))
-      (mapcar
+      (mapc
        (lambda (item)
         (let ((name (ido-name item)))
           (if (string-match re name)