all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6870: Make vc-root-diff work in more modes
@ 2010-08-17  1:55 rogers-emacs
  2011-07-04 15:18 ` Lars Magne Ingebrigtsen
  2020-08-25 13:38 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: rogers-emacs @ 2010-08-17  1:55 UTC (permalink / raw)
  To: 6870

   It makes sense to me that vc-root-diff uses "(vc-responsible-backend
default-directory)" when in a dired-mode buffer.  But since vc-root-diff
is not at all about the current buffer, why not also make that the
default for shell-mode, diff-mode, or any of the other modes for
non-version-controlled buffers that may be generated in a working copy?

					-- Bob Rogers
					   http://www.rgrjr.com/

------------------------------------------------------------------------
diff --git a/lisp/vc.el b/lisp/vc.el
index 1e52a3c..abba202 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -1655,8 +1655,8 @@ saving the buffer."
     (when buffer-file-name (vc-buffer-sync not-urgent))
     (let ((backend
 	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
-		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
-		 (vc-mode (vc-backend buffer-file-name))))
+		 (vc-mode (vc-backend buffer-file-name))
+		 (t (vc-responsible-backend default-directory))))
 	  rootdir working-revision)
       (unless backend
 	(error "Buffer is not version controlled"))





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

* bug#6870: Make vc-root-diff work in more modes
  2010-08-17  1:55 bug#6870: Make vc-root-diff work in more modes rogers-emacs
@ 2011-07-04 15:18 ` Lars Magne Ingebrigtsen
  2011-07-04 18:13   ` Stefan Monnier
  2020-08-25 13:38 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-04 15:18 UTC (permalink / raw)
  To: rogers-emacs; +Cc: 6870

rogers-emacs@rgrjr.dyndns.org writes:

>    It makes sense to me that vc-root-diff uses "(vc-responsible-backend
> default-directory)" when in a dired-mode buffer.  But since vc-root-diff
> is not at all about the current buffer, why not also make that the
> default for shell-mode, diff-mode, or any of the other modes for
> non-version-controlled buffers that may be generated in a working copy?
>
> 					-- Bob Rogers
> 					   http://www.rgrjr.com/
>
> ------------------------------------------------------------------------
> diff --git a/lisp/vc.el b/lisp/vc.el
> index 1e52a3c..abba202 100644
> --- a/lisp/vc.el
> +++ b/lisp/vc.el
> @@ -1655,8 +1655,8 @@ saving the buffer."
>      (when buffer-file-name (vc-buffer-sync not-urgent))
>      (let ((backend
>  	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
> -		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
> -		 (vc-mode (vc-backend buffer-file-name))))
> +		 (vc-mode (vc-backend buffer-file-name))
> +		 (t (vc-responsible-backend default-directory))))
>  	  rootdir working-revision)
>        (unless backend
>  	(error "Buffer is not version controlled"))

This looks very reasonable to me, but I'm not all that familiar with
vc.el internals.  Does anybody else have any opinions on this?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





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

* bug#6870: Make vc-root-diff work in more modes
  2011-07-04 15:18 ` Lars Magne Ingebrigtsen
@ 2011-07-04 18:13   ` Stefan Monnier
  2011-07-05 13:32     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-07-04 18:13 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: rogers-emacs, 6870

>> (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
>> -		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
>> -		 (vc-mode (vc-backend buffer-file-name))))
>> +		 (vc-mode (vc-backend buffer-file-name))
>> +		 (t (vc-responsible-backend default-directory))))
>> rootdir working-revision)
>> (unless backend
>> (error "Buffer is not version controlled"))

> This looks very reasonable to me, but I'm not all that familiar with
> vc.el internals.  Does anybody else have any opinions on this?

It's only reasonable in buffers where default-directory is really
meaningful.  E.g. in *Help* or *info* it's likely not going to do you
much good.
So feel free to add more major modes (rather than just `dired'), but
I don't think using (vc-responsible-backend default-directory)
everywhere is a good idea.


        Stefan





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

* bug#6870: Make vc-root-diff work in more modes
  2011-07-04 18:13   ` Stefan Monnier
@ 2011-07-05 13:32     ` Lars Magne Ingebrigtsen
  2011-07-05 19:04       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-07-05 13:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: rogers-emacs, 6870

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> It's only reasonable in buffers where default-directory is really
> meaningful.  E.g. in *Help* or *info* it's likely not going to do you
> much good.
> So feel free to add more major modes (rather than just `dired'), but
> I don't think using (vc-responsible-backend default-directory)
> everywhere is a good idea.

What about all buffers that have file names?  A la

(and (buffer-file-name)
     (vc-responsible-backend default-directory))

or something along those lines...
     
-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





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

* bug#6870: Make vc-root-diff work in more modes
  2011-07-05 13:32     ` Lars Magne Ingebrigtsen
@ 2011-07-05 19:04       ` Stefan Monnier
  2011-07-05 20:58         ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-07-05 19:04 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: rogers-emacs, 6870

>> It's only reasonable in buffers where default-directory is really
>> meaningful.  E.g. in *Help* or *info* it's likely not going to do you
>> much good.
>> So feel free to add more major modes (rather than just `dired'), but
>> I don't think using (vc-responsible-backend default-directory)
>> everywhere is a good idea.

> What about all buffers that have file names?  A la

> (and (buffer-file-name)
>      (vc-responsible-backend default-directory))

That'd be fine, yes.


        Stefan





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

* bug#6870: Make vc-root-diff work in more modes
  2011-07-05 19:04       ` Stefan Monnier
@ 2011-07-05 20:58         ` Chong Yidong
  0 siblings, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2011-07-05 20:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lars Magne Ingebrigtsen, rogers-emacs, 6870

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> What about all buffers that have file names?  A la
>
>> (and (buffer-file-name)
>>      (vc-responsible-backend default-directory))
>
> That'd be fine, yes.

But this might be confusing, since this check would not trigger for
non-file buffers generated from those file buffers.

i.e., if you have a buffer with a file name that is not handled by VC,
vc-root-diff would work for that buffer but not for a diff file
generated from that buffer.

Whereas if a buffer with a file name *is* handled by VC, vc-root-diff
would work for both that buffer and a diff file generated for that
buffer.





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

* bug#6870: Make vc-root-diff work in more modes
  2010-08-17  1:55 bug#6870: Make vc-root-diff work in more modes rogers-emacs
  2011-07-04 15:18 ` Lars Magne Ingebrigtsen
@ 2020-08-25 13:38 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-25 13:38 UTC (permalink / raw)
  To: rogers-emacs; +Cc: 6870

rogers-emacs@rgrjr.dyndns.org writes:

>    It makes sense to me that vc-root-diff uses "(vc-responsible-backend
> default-directory)" when in a dired-mode buffer.  But since vc-root-diff
> is not at all about the current buffer, why not also make that the
> default for shell-mode, diff-mode, or any of the other modes for
> non-version-controlled buffers that may be generated in a working copy?

[...]

> -		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
> -		 (vc-mode (vc-backend buffer-file-name))))
> +		 (vc-mode (vc-backend buffer-file-name))
> +		 (t (vc-responsible-backend default-directory))))

This has been extended somewhat over the years:

(defun vc-deduce-backend ()
  (cond ((derived-mode-p 'vc-dir-mode)   vc-dir-backend)
	((derived-mode-p 'log-view-mode) log-view-vc-backend)
	((derived-mode-p 'log-edit-mode) log-edit-vc-backend)
	((derived-mode-p 'diff-mode)     diff-vc-backend)
        ;; Maybe we could even use comint-mode rather than shell-mode?
	((derived-mode-p 'dired-mode 'shell-mode 'compilation-mode)
	 (ignore-errors (vc-responsible-backend default-directory)))
	(vc-mode (vc-backend buffer-file-name))))

So we still don't do this in all buffers, but since there's some issues
with that, I think this works well now.  So I'm closing this bug
report.  If there's more to be done here, respond to the debbugs address
and we'll reopen the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2020-08-25 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17  1:55 bug#6870: Make vc-root-diff work in more modes rogers-emacs
2011-07-04 15:18 ` Lars Magne Ingebrigtsen
2011-07-04 18:13   ` Stefan Monnier
2011-07-05 13:32     ` Lars Magne Ingebrigtsen
2011-07-05 19:04       ` Stefan Monnier
2011-07-05 20:58         ` Chong Yidong
2020-08-25 13:38 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.