From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aleksandr Vityazev Newsgroups: gmane.emacs.bugs Subject: bug#51614: 29.0.50; [PATCH] vc-switches ignore file or directory variables Date: Fri, 05 Nov 2021 16:39:49 +0000 Message-ID: <875yt68skq.fsf@posteo.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12590"; mail-complaints-to="usenet@ciao.gmane.io" To: 51614@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 05 17:40:30 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mj2GT-00034Y-QD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Nov 2021 17:40:29 +0100 Original-Received: from localhost ([::1]:56210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mj2GS-0004x4-5Q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Nov 2021 12:40:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj2G2-0004pG-NF for bug-gnu-emacs@gnu.org; Fri, 05 Nov 2021 12:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mj2G2-00043p-8U for bug-gnu-emacs@gnu.org; Fri, 05 Nov 2021 12:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mj2G2-0005CJ-3p for bug-gnu-emacs@gnu.org; Fri, 05 Nov 2021 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Nov 2021 16:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163613039419957 (code B ref -1); Fri, 05 Nov 2021 16:40:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Nov 2021 16:39:54 +0000 Original-Received: from localhost ([127.0.0.1]:46986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mj2Ft-0005Bp-LJ for submit@debbugs.gnu.org; Fri, 05 Nov 2021 12:39:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mj2Fo-0005Bd-RU for submit@debbugs.gnu.org; Fri, 05 Nov 2021 12:39:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj2Fo-0004Tp-1d for bug-gnu-emacs@gnu.org; Fri, 05 Nov 2021 12:39:48 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:49499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj2Fk-000402-Ao for bug-gnu-emacs@gnu.org; Fri, 05 Nov 2021 12:39:47 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 18B5A240101 for ; Fri, 5 Nov 2021 17:39:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.org; s=2017; t=1636130378; bh=vq13Kot2f0rDdJTsSlECxTp1KSIy9sU0JFyjaZ4YfWU=; h=From:To:Subject:Date:From; b=Hcm5zQgzgp7L8lW1vlDfnJX2ak06cPBmpUxa7MoLpWUVziIecCtgO8HMwQ548u5bN UHXIGoqIBDm+P6jLBYP9igGzC6H9tZr09rx/mz7KXAJSKTpWUV7xr8fxQZA50uFZOM 0m2pmOdzvlTYUfNknvtcVc58L6nhii8DXnQqVAR6npH9evFpoX18HXnHuwFozKLe/p +1kE6yHZ+/nZmAZLP/AWTlmIDDpWCrZTNxtUUSqLRS9FM5hVvQuakajAwQRj6wFdYE NOQdVa8IHUYgMJYFw1ZVAw1fKgLkO9F2dtSiR7pjqwcHZ07i0ArOgFDRMCRrNlfIAb toFFBZtjSR3hQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Hm5nh55Qrz9rxB for ; Fri, 5 Nov 2021 17:39:36 +0100 (CET) Received-SPF: pass client-ip=185.67.36.66; envelope-from=avityazev@posteo.org; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219013 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, The current implementation of the vc-switches function from lisp/vc/vc.el ignores the values =E2=80=8B=E2=80=8Bof vc-BACKEND-diff-switc= hes, vc-diff-switches set as local directory or file variables. Here's a reproduction: 1. Run "emacs -Q" 2. "C-x C-f" to open file /tmp/test-project/.dir-locals.el 3. Type this into the buffer: ((nil ((vc-git-diff-switches . ("--binary" "--textconv"))))) 4. "C-x C-s" to save the buffer 5. "C-x C-f" to open the file /tmp/test-project/test.gpg. Without --binary and --textconv, diff will not be displayed for a file with a .gpg extension. 6. Type something in the buffer for example: "Just a test" 7. "C-x C-s" to save the file 8. "C-x v v" to choose VCS backend: in this case, Git and register the file under VCS 9. "C-x v v" to commit changes 10. Type commit message and "C-c C-c" 11. Type something in the buffer with file /tmp/test-project/test.gpg 12. "C-x C-s" to save the buffer 13. "C-x v =3D" to show the diff 14. Bug occurs: diff is not displayed. Perhaps the attached patch can solve the problem. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-vc-vc.el-vc-switches-Handle-dir-local-variables.patch Content-Description: lisp/vc/vc.el >From 9b031423294224a6fe142abf6bd469b5cfa99c83 Mon Sep 17 00:00:00 2001 From: Alexandr Vityazev Date: Thu, 28 Oct 2021 22:43:28 +0300 Subject: [PATCH] * lisp/vc/vc.el (vc-switches): Handle dir local variables. * lisp/vc/vc.el (vc-switches): Handle vc-BACKEND-diff-switches, vc-diff-switches set as local directory or file variables. --- lisp/vc/vc.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 927a241a60..a858cbc451 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1700,16 +1700,17 @@ diff only, `diff-switches'. If the chosen value is not a string or a list, return nil. This is so that you may set, e.g. `vc-svn-diff-switches' to t in order to override the value of `vc-diff-switches' and `diff-switches'." - (let ((switches - (or (when backend - (let ((sym (vc-make-backend-sym - backend (intern (concat (symbol-name op) - "-switches"))))) - (when (boundp sym) (symbol-value sym)))) - (let ((sym (intern (format "vc-%s-switches" (symbol-name op))))) - (when (boundp sym) (symbol-value sym))) - (cond - ((eq op 'diff) diff-switches))))) + (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))))) (if (stringp switches) (list switches) ;; If not a list, return nil. ;; This is so we can set vc-diff-switches to t to override -- 2.33.1 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=--