Subject: Re: bug#51614: 29.0.50; [PATCH] vc-switches ignore file or directory variables

From: Dmitry Gutov <[email-masked]>
Date: Fri, 7 Oct 2022 03:09:24 +0300

On 10.09.2022 07:43, Lars Ingebrigtsen wrote:
>> +  (let* ((buffer (other-buffer (current-buffer) t))
>> +         (switches
>> +	  (or (when backend
>> +	        (let ((sym (vc-make-backend-sym
>> +			    backend (intern (concat (symbol-name op)
>> +						    "-switches")))))
>> +		  (when (boundp sym) (buffer-local-value sym buffer))))
>> +	      (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
>> +	        (when (boundp sym) (buffer-local-value sym buffer)))
>> +	      (cond
>> +	       ((eq op 'diff) diff-switches)))))
> I don't think using `other-buffer' here is a reliable way of getting the
> buffer we're interested in here, so I think this would have to be fixed
> in a different way.

Right.

> I'm adding Dmitry to the CCs; perhaps he has some comments here.

I was thinking vc-switches could have a new, optional argument: buffer. 
But even that seems hard to get ahold of in vc-diff-internal (the FILES 
var might have one element, which is a directory, with no visiting buffers).

Perhaps support for this would need to be added on command-by-command 
basis, with some helper which would collect all buffer-local vars and 
bind them dynamically.

Alternatively, we could support setting 'vc-XX-switches' to a function 
value. That function could take the current default-directory and 
compute the value based on it. I'm not sure if that'll fit Aleksandr's 
workflow, though.