From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: C-x C-f RET problem... Date: Fri, 17 May 2002 13:29:17 -0600 (MDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200205171929.g4HJTHM20476@aztec.santafe.edu> References: <1021575722.24318.936.camel@space-ghost> Reply-To: rms@gnu.org NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1021663855 26832 127.0.0.1 (17 May 2002 19:30:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 17 May 2002 19:30:55 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 178nRG-0006yf-00 for ; Fri, 17 May 2002 21:30:54 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 178ndt-0001qZ-00 for ; Fri, 17 May 2002 21:43:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 178nRV-0003QJ-00; Fri, 17 May 2002 15:31:09 -0400 Original-Received: from pele.santafe.edu ([192.12.12.119]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 178nPi-00034x-00; Fri, 17 May 2002 15:29:18 -0400 Original-Received: from aztec.santafe.edu (aztec [192.12.12.49]) by pele.santafe.edu (8.11.6+Sun/8.9.3) with ESMTP id g4HJTHk10473; Fri, 17 May 2002 13:29:17 -0600 (MDT) Original-Received: (from rms@localhost) by aztec.santafe.edu (8.10.2+Sun/8.9.3) id g4HJTHM20476; Fri, 17 May 2002 13:29:17 -0600 (MDT) X-Authentication-Warning: aztec.santafe.edu: rms set sender to rms@aztec using -f Original-To: walters@verbum.org In-Reply-To: <1021575722.24318.936.camel@space-ghost> (message from Colin Walters on 16 May 2002 15:02:02 -0400) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:4066 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:4066 Here's another idea for how to implement the feature. It only affects interactive calls to find-file and friends. If you just type RET, you visit the directory, but if you want to use the visited file name instead, you just have to type M-n to get it. What do you think? *** files.el.~1.573.~ Tue May 14 01:16:00 2002 --- files.el Fri May 17 12:15:04 2002 *************** *** 768,781 **** (pop-to-buffer buffer t norecord) (raise-frame (window-frame (selected-window))))) (defun find-file (filename &optional wildcards) "Edit file FILENAME. Switch to a buffer visiting file FILENAME, creating one if none already exists. Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files. Wildcard expansion can be suppressed by setting `find-file-wildcards'." ! (interactive "FFind file: \np") (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (mapcar 'switch-to-buffer (nreverse value)) --- 768,799 ---- (pop-to-buffer buffer t norecord) (raise-frame (window-frame (selected-window))))) + (defun find-file-read-args (prompt) + (list (let ((find-file-default + (and buffer-file-name + (abbreviate-file-name buffer-file-name))) + (minibuffer-setup-hook + '((lambda () + (setq minibuffer-default find-file-default) + ;; Clear out this hook so it does not interfere + ;; with any recursive minibuffer usage. + (setq minibuffer-setup-hook nil))))) + (read-file-name prompt nil default-directory)) + current-prefix-arg)) + (defun find-file (filename &optional wildcards) "Edit file FILENAME. Switch to a buffer visiting file FILENAME, creating one if none already exists. + Interactively, the default if you just type RET is the current directory, + but the visited file name is available through the minibuffer history: + type M-n to pull it into the minibuffer. + Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files. Wildcard expansion can be suppressed by setting `find-file-wildcards'." ! (interactive ! (find-file-read-args "Find file: ")) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (mapcar 'switch-to-buffer (nreverse value)) *************** *** 785,793 **** "Edit file FILENAME, in another window. May create a new window, or reuse an existing one. See the function `display-buffer'. Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." ! (interactive "FFind file in other window: \np") (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (progn --- 803,816 ---- "Edit file FILENAME, in another window. May create a new window, or reuse an existing one. See the function `display-buffer'. + + Interactively, the default if you just type RET is the current directory, + but the visited file name is available through the minibuffer history: + type M-n to pull it into the minibuffer. + Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." ! (interactive (find-file-read-args "FFind file in other window: ")) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (progn *************** *** 800,808 **** "Edit file FILENAME, in another frame. May create a new frame, or reuse an existing one. See the function `display-buffer'. Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." ! (interactive "FFind file in other frame: \np") (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (progn --- 823,836 ---- "Edit file FILENAME, in another frame. May create a new frame, or reuse an existing one. See the function `display-buffer'. + + Interactively, the default if you just type RET is the current directory, + but the visited file name is available through the minibuffer history: + type M-n to pull it into the minibuffer. + Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." ! (interactive (find-file-read-args "FFind file in other frame: ")) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (progn *************** *** 813,821 **** (defun find-file-read-only (filename &optional wildcards) "Edit file FILENAME but don't allow changes. ! Like `find-file' but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive "fFind file read-only: \np") (find-file filename wildcards) (toggle-read-only 1) (current-buffer)) --- 841,849 ---- (defun find-file-read-only (filename &optional wildcards) "Edit file FILENAME but don't allow changes. ! Like \\[find-file] but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive (find-file-read-args "fFind file read-only: ")) (find-file filename wildcards) (toggle-read-only 1) (current-buffer)) *************** *** 824,830 **** "Edit file FILENAME in another window but don't allow changes. Like \\[find-file-other-window] but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive "fFind file read-only other window: \np") (find-file-other-window filename wildcards) (toggle-read-only 1) (current-buffer)) --- 852,858 ---- "Edit file FILENAME in another window but don't allow changes. Like \\[find-file-other-window] but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive (find-file-read-args "fFind file read-only other window: ")) (find-file-other-window filename wildcards) (toggle-read-only 1) (current-buffer)) *************** *** 833,839 **** "Edit file FILENAME in another frame but don't allow changes. Like \\[find-file-other-frame] but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive "fFind file read-only other frame: \np") (find-file-other-frame filename wildcards) (toggle-read-only 1) (current-buffer)) --- 861,867 ---- "Edit file FILENAME in another frame but don't allow changes. Like \\[find-file-other-frame] but marks buffer as read-only. Use \\[toggle-read-only] to permit editing." ! (interactive (find-file-read-args "fFind file read-only other frame: ")) (find-file-other-frame filename wildcards) (toggle-read-only 1) (current-buffer))