unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ido.el patch: don't automatically overwrite file on TAB
@ 2004-04-10  3:58 Karl Chen
  2004-04-10 22:21 ` Kim F. Storm
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Chen @ 2004-04-10  3:58 UTC (permalink / raw)



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:user@host: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: ")))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ido.el patch: don't automatically overwrite file on TAB
  2004-04-10  3:58 ido.el patch: don't automatically overwrite file on TAB Karl Chen
@ 2004-04-10 22:21 ` Kim F. Storm
  0 siblings, 0 replies; 2+ messages in thread
From: Kim F. Storm @ 2004-04-10 22:21 UTC (permalink / raw)
  Cc: Emacs Developement List

Karl Chen <quarl@hkn.eecs.berkeley.edu> writes:

> 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.

I will add your changes to ido.  Thanks you.

PS: You have not signed papers for contributing to emacs, but this
change (and a previous change that I used) is still small enough to
not require papers.  However, further changes from you will require
that you sign papers.


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-10 22:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-10  3:58 ido.el patch: don't automatically overwrite file on TAB Karl Chen
2004-04-10 22:21 ` Kim F. Storm

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).