unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* default file for diff-backup
@ 2014-06-20 12:32 Alfred M. Szmidt
  2014-06-20 19:10 ` Stefan Monnier
  2014-06-20 19:56 ` Herring, Davis
  0 siblings, 2 replies; 10+ messages in thread
From: Alfred M. Szmidt @ 2014-06-20 12:32 UTC (permalink / raw)
  To: emacs-devel

This makes diff-backup supply a default file name, making the
default behaviour a bit more useful.

*** lisp/vc/diff.el.~1~
--- lisp/vc/diff.el
***************
*** 187,194 ****
  If this file is a backup, diff it with its original.
  The backup file is the first file given to `diff'.
  With prefix arg, prompt for diff switches."
!   (interactive (list (read-file-name "Diff (file with backup): ")
! 		     (diff-switches)))
    (let (bak ori)
      (if (backup-file-name-p file)
  	(setq bak file
--- 187,201 ----
  If this file is a backup, diff it with its original.
  The backup file is the first file given to `diff'.
  With prefix arg, prompt for diff switches."
!   (interactive
!    (list
!     (if (and buffer-file-name (file-exists-p buffer-file-name))
! 	(read-file-name
! 	 (concat "Diff file with backup (default "
! 		 (file-name-nondirectory buffer-file-name) "): ")
! 	 nil buffer-file-name t)
!       (read-file-name "Diff file with backup: " nil nil t))
!     (diff-switches)))
    (let (bak ori)
      (if (backup-file-name-p file)
  	(setq bak file

Diff finished.  Fri Jun 20 14:06:26 2014



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

* Re: default file for diff-backup
  2014-06-20 12:32 default file for diff-backup Alfred M. Szmidt
@ 2014-06-20 19:10 ` Stefan Monnier
  2014-06-20 20:26   ` Alfred M. Szmidt
  2014-06-20 19:56 ` Herring, Davis
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2014-06-20 19:10 UTC (permalink / raw)
  To: Alfred M. Szmidt; +Cc: emacs-devel

> This makes diff-backup supply a default file name, making the
> default behaviour a bit more useful.

Looks OK, feel free to install into trunk.


        Stefan



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

* RE: default file for diff-backup
  2014-06-20 12:32 default file for diff-backup Alfred M. Szmidt
  2014-06-20 19:10 ` Stefan Monnier
@ 2014-06-20 19:56 ` Herring, Davis
  2014-06-20 20:26   ` Alfred M. Szmidt
  1 sibling, 1 reply; 10+ messages in thread
From: Herring, Davis @ 2014-06-20 19:56 UTC (permalink / raw)
  To: ams@gnu.org; +Cc: emacs-devel@gnu.org

> This makes diff-backup supply a default file name, making the
> default behaviour a bit more useful.

Is the idea to handle `insert-default-directory' being nil?  `diff-backup' already has the obvious default otherwise.  If so: you could just let-bind it, I guess, although overriding customization is not usually a good thing.

Davis



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

* Re: default file for diff-backup
  2014-06-20 19:56 ` Herring, Davis
@ 2014-06-20 20:26   ` Alfred M. Szmidt
  2014-06-20 20:29     ` Herring, Davis
  0 siblings, 1 reply; 10+ messages in thread
From: Alfred M. Szmidt @ 2014-06-20 20:26 UTC (permalink / raw)
  To: Herring, Davis; +Cc: emacs-devel

The idea is to supply the current file name of the buffer if you just
hit enter, i.e exact same behaviour as for M-x diff RET.



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

* Re: default file for diff-backup
  2014-06-20 19:10 ` Stefan Monnier
@ 2014-06-20 20:26   ` Alfred M. Szmidt
  0 siblings, 0 replies; 10+ messages in thread
From: Alfred M. Szmidt @ 2014-06-20 20:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

   > This makes diff-backup supply a default file name, making the
   > default behaviour a bit more useful.

   Looks OK, feel free to install into trunk.

Someone other than me will have to do that since I don't have commit
access.



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

* RE: default file for diff-backup
  2014-06-20 20:26   ` Alfred M. Szmidt
@ 2014-06-20 20:29     ` Herring, Davis
  2014-06-23  9:19       ` Alfred M. Szmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Herring, Davis @ 2014-06-20 20:29 UTC (permalink / raw)
  To: ams@gnu.org; +Cc: emacs-devel@gnu.org

> The idea is to supply the current file name of the buffer if you just
> hit enter, i.e exact same behaviour as for M-x diff RET.

I get that already (even though it doesn't explicitly say so in the prompt).  Just like, say, `copy-file'.

Davis



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

* Re: default file for diff-backup
  2014-06-20 20:29     ` Herring, Davis
@ 2014-06-23  9:19       ` Alfred M. Szmidt
  2014-06-23 15:42         ` Herring, Davis
  0 siblings, 1 reply; 10+ messages in thread
From: Alfred M. Szmidt @ 2014-06-23  9:19 UTC (permalink / raw)
  To: Herring, Davis; +Cc: emacs-devel


   > The idea is to supply the current file name of the buffer if you just
   > hit enter, i.e exact same behaviour as for M-x diff RET.

   I get that already (even though it doesn't explicitly say so in the prompt).  Just like, say, `copy-file'.

There are quite a few cases where the default could be improved for
the "RET" case, copy-file, rename-file, delete-file, ...



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

* RE: default file for diff-backup
  2014-06-23  9:19       ` Alfred M. Szmidt
@ 2014-06-23 15:42         ` Herring, Davis
  2014-06-23 21:20           ` Alfred M. Szmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Herring, Davis @ 2014-06-23 15:42 UTC (permalink / raw)
  To: ams@gnu.org; +Cc: emacs-devel@gnu.org

> There are quite a few cases where the default could be improved for
> the "RET" case, copy-file, rename-file, delete-file, ...

But they all already work!

At least, if `insert-default-directory' is non-nil, as is the default.  That's why I asked whether your patch was meant to address the other case.

Davis



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

* Re: default file for diff-backup
  2014-06-23 15:42         ` Herring, Davis
@ 2014-06-23 21:20           ` Alfred M. Szmidt
  2014-06-24  4:42             ` Herring, Davis
  0 siblings, 1 reply; 10+ messages in thread
From: Alfred M. Szmidt @ 2014-06-23 21:20 UTC (permalink / raw)
  To: Herring, Davis; +Cc: emacs-devel

   > There are quite a few cases where the default could be improved for
   > the "RET" case, copy-file, rename-file, delete-file, ...

   But they all already work!

So they seem! Though not clear that they do, it would be nicer if
there was some hint that one could just hint RET.  It is not the
behaviour that `diff' exhibits, where you are at least shown
something.

   At least, if `insert-default-directory' is non-nil, as is the
   default.  That's why I asked whether your patch was meant to
   address the other case.

I think I see what you are saying now, it was unclear to me.  What is
annoying to me, is that there is no mention of a "default" when you
invoke M-x diff-backup (or for the matter, M-x copy-file, rename-file,
...).  M-x diff does have one though, which is really all I want.

I.e.:

  C-x C-f ~/.emacs RET
  M-x copy-file RET
  Copy file: ~/

~/ isn't a file, why would I copy it?  So I type the file I want
instead of just hitting RET, which would give me the default file as
you note.  Where as with the simple modification to diff-backup:

  C-x C-f ~/.emacs RET
  M-x diff-backup RET
  Diff file with backup (default .emacs): ~/

This is far clearer.



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

* RE: default file for diff-backup
  2014-06-23 21:20           ` Alfred M. Szmidt
@ 2014-06-24  4:42             ` Herring, Davis
  0 siblings, 0 replies; 10+ messages in thread
From: Herring, Davis @ 2014-06-24  4:42 UTC (permalink / raw)
  To: ams@gnu.org; +Cc: emacs-devel@gnu.org

> Diff file with backup (default .emacs): ~/

You can address all use cases at once (and make it respect `insert-default-directory') by making this change in `read-file-name' instead.

Davis



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

end of thread, other threads:[~2014-06-24  4:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20 12:32 default file for diff-backup Alfred M. Szmidt
2014-06-20 19:10 ` Stefan Monnier
2014-06-20 20:26   ` Alfred M. Szmidt
2014-06-20 19:56 ` Herring, Davis
2014-06-20 20:26   ` Alfred M. Szmidt
2014-06-20 20:29     ` Herring, Davis
2014-06-23  9:19       ` Alfred M. Szmidt
2014-06-23 15:42         ` Herring, Davis
2014-06-23 21:20           ` Alfred M. Szmidt
2014-06-24  4:42             ` Herring, Davis

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