unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: C-x C-f RET problem...
Date: Fri, 17 May 2002 13:29:17 -0600 (MDT)	[thread overview]
Message-ID: <200205171929.g4HJTHM20476@aztec.santafe.edu> (raw)
In-Reply-To: <1021575722.24318.936.camel@space-ghost> (message from Colin Walters on 16 May 2002 15:02:02 -0400)

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

  parent reply	other threads:[~2002-05-17 19:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-16  7:45 C-x C-f RET problem Pavel Janík
2002-05-16  8:02 ` Miles Bader
2002-05-16 19:02 ` Colin Walters
2002-05-16 19:24   ` Miles Bader
2002-05-16 21:51     ` Kim F. Storm
2002-05-16 21:13       ` Alan Shutko
2002-05-16 21:18       ` Miles Bader
2002-05-17 19:29   ` Richard Stallman [this message]
2002-05-17 21:43     ` Colin Walters
2002-05-18  2:02     ` Miles Bader
2002-05-18  6:36       ` Eli Zaretskii
2002-05-18  7:12         ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200205171929.g4HJTHM20476@aztec.santafe.edu \
    --to=rms@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).