From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: public@heslin.eclipse.co.uk Newsgroups: gmane.emacs.devel Subject: Re: File menu changes (suggestions) Date: Fri, 01 Jul 2005 02:45:19 +0100 Message-ID: <87zmt75mfk.fsf@heslin.eclipse.co.uk> References: <87psu7xdgo.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1120182779 28461 80.91.229.2 (1 Jul 2005 01:52:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Jul 2005 01:52:59 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 01 03:52:50 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DoAhf-0004qA-VX for ged-emacs-devel@m.gmane.org; Fri, 01 Jul 2005 03:52:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DoAq2-00082X-2q for ged-emacs-devel@m.gmane.org; Thu, 30 Jun 2005 22:01:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DoAoZ-0007rH-6W for emacs-devel@gnu.org; Thu, 30 Jun 2005 21:59:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DoAoN-0007kj-JO for emacs-devel@gnu.org; Thu, 30 Jun 2005 21:59:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DoAoM-0007fd-Qh for emacs-devel@gnu.org; Thu, 30 Jun 2005 21:59:22 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DoAgF-0007iv-Jv for emacs-devel@gnu.org; Thu, 30 Jun 2005 21:50:59 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DoATn-0002YZ-F7 for emacs-devel@gnu.org; Fri, 01 Jul 2005 03:38:07 +0200 Original-Received: from 213-152-32-235.dsl.eclipse.net.uk ([213.152.32.235]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2005 03:38:07 +0200 Original-Received: from public by 213-152-32-235.dsl.eclipse.net.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2005 03:38:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 41 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 213-152-32-235.dsl.eclipse.net.uk User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:nacffprgQN0yq3/Lfziik5fRjcI= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:39994 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:39994 Stefan Monnier writes: > E.g. find-file might require confirmation before opening > a non-existent file. I'll love such a new feature, seeing how often I do > "C-x C-f emacs/src/rege TAB RET" only to find myself in "regexp." rather > than in the "regexp.c" that I intended to open. Here is what I use in Easymacs, which I have modified from http://www-xray.ast.cam.ac.uk/~gmorris/dotemacs.html -- I just added the make-directory bit. (defadvice find-file (around confirm-new-file activate) "If file does not exist, prompt." (let ((file (ad-get-arg 0))) (when (or (not (interactive-p)) (find-buffer-visiting file) (string-match "\\`/\\[" file) ; old-style TRAMP (string-match "\\`/[a-zA-Z0-9@]:" file) ; new-style TRAMP (file-directory-p file) ;; file-exists-p does not handle wildcards. (file-expand-wildcards file) ;; A nice trick, but not necessary. ;;; (string-match "0\n\\'" (shell-command-to-string ;;; (format "ls %s; echo $?" file))) (yes-or-no-p (format "`%s' does not exist, create new file? " file))) ;; Is this a good idea? If we open a new file by accident, ;; despite the confirmation, we probably don't want the directory. (unless (file-directory-p (file-name-directory file)) (make-directory (file-name-directory file) t)) ad-do-it))) (defadvice switch-to-buffer (around confirm-new-buffer activate) "If buffer does not exist, prompt." (let ((buff (ad-get-arg 0))) (if (or (not (interactive-p)) (get-buffer buff) (yes-or-no-p (format "`%s' does not exist, create new file? " buff))) ad-do-it)))