emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ido.el patch: don't automatically overwrite file on TAB


From: Karl Chen
Subject: ido.el patch: don't automatically overwrite file on TAB
Date: 09 Apr 2004 20:58:18 -0700

I find annoying the following behavior: when using ido-write-file,
pressing TAB on a substring that uniquely matches an existing file
will complete the filename and overwrite it without confirmation.

(Usually when I do [ido-]write-file I mean to make a copy as a new
file.  Overwriting existing files based on a substring or
fuzzy+regexp matching is dangerous.)

The patch below will change the default behavior so that if you
mean to overwrite an existing file you need to press TAB RET.


If this change to the default behavior of ido-write-file is not
acceptable please still accept the rest of the patch (ido-complete
and ido-exit-on-unique-tab-completion), because otherwise it is
very difficult to modify the behavior even through advice.





-- 
Karl 2004-04-09 20:35




Index: ido.el
===================================================================
--- ido.el      (revision 6237)
+++ ido.el      (working copy)
@@ -552,7 +552,11 @@
   :type '(repeat regexp)
   :group 'ido)
 
+(defcustom ido-exit-on-unique-tab-completion t
+  "*Non-nil means if there is only one completion, TAB should accept it.
 
+Else the minibuffer is only updated with the completion; press RET to accept.")
+
 (defcustom ido-enable-tramp-completion t
   "*Non-nil means that ido shall perform tramp method and server name 
completion.
 A tramp file name uses the following syntax: /method:address@hidden:filename."
@@ -1990,7 +1994,11 @@
                     (string-equal ido-current-directory "/")
                     (string-match "..[@:]\\'" (car ido-matches)))))
       ;; only one choice, so select it.
-      (exit-minibuffer))
+      (if ido-exit-on-unique-tab-completion
+          (exit-minibuffer)
+        (setq ido-rescan (not ido-enable-prefix))
+        (delete-region (minibuffer-prompt-end) (point))
+        (insert (car ido-matches))))
 
      (t ;; else there could be some completions
       (setq res ido-common-match-string)
@@ -3326,6 +3334,7 @@
        (ido-work-directory-match-only nil)
        (ido-ignore-files (cons "[^/]\\'" ido-ignore-files))
        (ido-report-no-match nil)
+        (ido-exit-on-unique-tab-completion nil)
        (ido-auto-merge-work-directories-length -1))
     (ido-file-internal 'write 'write-file nil "Write file: ")))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]