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

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 10 Sep 2022 06:43:36 +0200

Aleksandr Vityazev <[email-masked]> writes:

> The current implementation of the vc-switches function from
> lisp/vc/vc.el ignores the values ​​of vc-BACKEND-diff-switches,
> vc-diff-switches set as local directory or file variables.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

> Perhaps the attached patch can solve the problem.

[...]

> +  (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.

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