emacs-devel
[Top][All Lists]
Advanced

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

Re: C-x C-v considered harmful


From: Bob Rogers
Subject: Re: C-x C-v considered harmful
Date: Wed, 1 Jul 2009 23:10:09 -0400

   From: Miles Bader <address@hidden>
   Date: Thu, 02 Jul 2009 11:39:17 +0900

   Bob Rogers <address@hidden> writes:
   >    1.  Bind find-alternate-file to something different.  
   >    2.  Add a "[Confirm]" step if nonexistent, as for selecting files or
   > buffers with confirm-nonexistent-file-or-buffer set to t.
   >    3.  Do not bind find-alternate-file to anything at all.

   How  about:

     4.  Make find-alternate-file use a yes-or-no-p confirmation prompt if
          the buffer has no associated file.  My guess is that the vast
          majority of uses of find-alternate-file are replacing one file
          buffer with another, and that intentionally replacing "special"
          buffers is very rare.

Agreed; I like this best.  Please find a patch below that broadens the
case for modified files to cover non-files as well.

          If there are specific modes or buffers for which "replacement"
          _is_ commonly used, then there could be a variable to tell
          find-alternate-file not to confirm that buffer (and a user could
          set the global default value of that variable to turn off all
          confirmation)

   -Miles

Here is the way find-alternate-file describes itself:

    Find file FILENAME, select its buffer, kill previous buffer.  If the
    current buffer now contains an empty file that you just visited
    (presumably by mistake), use this command to visit the file you
    really want.

Given this perspective, the replace-a-non-file-buffer use case would
seem to be rare -- and always asking about non-file buffers makes sense.

                                        -- Bob

------------------------------------------------------------------------
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.1052
diff -c -r1.1052 files.el
*** lisp/files.el       22 Jun 2009 07:02:08 -0000      1.1052
--- lisp/files.el       2 Jul 2009 03:02:48 -0000
***************
*** 1465,1471 ****
           t)))
    (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
      (error "Aborted"))
!   (when (and (buffer-modified-p) (buffer-file-name))
      (if (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
                             (buffer-name)))
        (unless (yes-or-no-p "Kill and replace the buffer without saving it? ")
--- 1465,1472 ----
           t)))
    (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
      (error "Aborted"))
!   (when (or (not (buffer-file-name))
!           (buffer-modified-p))
      (if (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
                             (buffer-name)))
        (unless (yes-or-no-p "Kill and replace the buffer without saving it? ")




reply via email to

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