From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Unknown Newsgroups: gmane.emacs.bugs Subject: bug#43401: 28.0.50; [PATCH] Emacs Lisp type error when the buffer passed to diff-buffer-with-file is not visiting a file Date: Mon, 14 Sep 2020 18:12:11 +0200 Message-ID: References: Reply-To: =?UTF-8?Q?Reply-to=3A_Daniel_Mart=C3=83=C2=ADn_=3Cmardani29=40yahoo=2Ees?= =?UTF-8?Q?=3E=0A?= 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="21205"; mail-complaints-to="usenet@ciao.gmane.io" To: 43401@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 14 18:13:47 2020 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 1kHr6x-0005Oq-8e for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Sep 2020 18:13:47 +0200 Original-Received: from localhost ([::1]:58838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHr6w-0001Jc-6M for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Sep 2020 12:13:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHr6E-0000RZ-V8 for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 12:13:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHr6E-0003VU-LS for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 12:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kHr6E-00009j-H6 for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 12:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Sep 2020 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43401 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.1600099949542 (code B ref -1); Mon, 14 Sep 2020 16:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Sep 2020 16:12:29 +0000 Original-Received: from localhost ([127.0.0.1]:56010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHr5g-00008e-Nu for submit@debbugs.gnu.org; Mon, 14 Sep 2020 12:12:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:50168) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHr5d-00008T-RD for submit@debbugs.gnu.org; Mon, 14 Sep 2020 12:12:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHr5d-0008Ks-GB for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 12:12:25 -0400 Original-Received: from sonic304-22.consmr.mail.ir2.yahoo.com ([77.238.179.147]:42232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHr5a-0003P2-7d for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 12:12:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1600099938; bh=MtjdQ4V5wSn6zkCG4EsgTKDouFdwAyfRMPcic7t8ICM=; h=From:To:Subject:Date:References:From:Subject; b=tw1kkjgyxtM0sKpPZhY0uCorgypCz5HWGX7hRv6xUplDn9tKlTO7l9aRdrrUtcNWrYiT0xTHoqphcbdTp7DGWpdE7Fb0h+OhL9UVDX++ZC77FI9WXayIb4GMiRX4DK1Kxmbw9N5DSzhB7WXCMvCW60tQFNjZsfCB0aw6mxmk5VFCOnCg3RJsDAESQ1RNE4/8QaHVEdPQd7tr5PpDvxNiddIIyJiS3am5Stalri6/1Yr7RKAel29evhtgYBVXANXwtijbP0W8VY4E4B3mZR3zn3SpozJ5p8Mh+EGfvLb1aha7aqnNn8p0X1UWHo0SiaQ2pE8jye6YcjvRBpSZbh0lCw== X-YMail-OSG: saeLNggVM1lpjNEIuPjmwWltmU8LtbFJkKlnbB7gUTySuqw.YcGA3gGZaqGn.5Q 0p6RBxSJ4LE5THA48fNkv7MXjCAM6mv8OIbLv3mjJJzEChLXnyQcZmqRSJ0SVXEKdrshTCOikTow cNm69NPIZjtpfsYys_zrAk3NLHhbR0UkBZgWo.6DTk4k.wGU_Fa6oTtzu0CBD1cRLwCgk2ZsV2zz NUm1eT7fGwhastHtL48vTF1JYzIadSSXd33m_qYz5IGpiN8Wmk0pL16Wgu9.2QGrFDSCmfZNwloO AN_i8.ydSMXaLc0C9zZmzWAJW88P452HWq6dbiIEAMGQRT7MMVGqTkQr1LH2_X2ZZtUfR7hnRxPF 9nVv4jYrHp2Vhn55VmlqnbnPGWTgtAetV2.fUHidUglVUTVWliAWgRnDOCo.tcDyTPNvwqhbVsNE 6N83MHVZ8iu1neQm26L6EOSbNBT50HqXM7nHGrEgQgyOydO0igd8GbpwL5JN6QLQORUzOOkSieiD w9zhiyKNKM2qqCLLjAZkYbnkrD9hSVydsn4euSrF1Qd9T_mrBn70l3aQitIasWSts6A8y58AhGo6 9Dj7md4w_9l8IP6t_EUaijp.BbAKhFXELuHOUv9PtHNy9_IKiz3lsY7xefRbvdAtAv2Baog9xmWS In2tNXLU4uuwpzfkovKAcDvOGlY3gDcOe3OWspUbz9XXL3P74suwznGo4DS6pNihw0ggl5NqKlE. 9nYCiczQQmMuu9sUsiThmPkJHVSL.BZIbj3Ck98CVgo0LMCD3fMIxcBVor2c0WSk_2X8BywHTra0 lpS_cRPxlW_DomNe82qG.a61bBpwBpZSQGpCJo0m2_ Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ir2.yahoo.com with HTTP; Mon, 14 Sep 2020 16:12:18 +0000 Original-Received: by smtp417.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID af2c6ca677efc03304816abff320d586; Mon, 14 Sep 2020 16:12:12 +0000 (UTC) X-Mailer: WebService/1.1.16565 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) Received-SPF: pass client-ip=77.238.179.147; envelope-from=mardani29@yahoo.es; helo=sonic304-22.consmr.mail.ir2.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/14 12:12:18 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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" Original-From: Xref: news.gmane.io gmane.emacs.bugs:188071 Archived-At: --=-=-= Content-Type: text/plain Steps to reproduce the problem: emacs -Q C-x b "Sample" RET (that is, create an empty buffer) M-x diff-buffer-with-file RET RET (confirm the default buffer) Actual result: Emacs shows "Wrong type argument: stringp, nil" Expected result: Emacs shows a more descriptive error that explains why the command couldn't be executed. I've attached a patch that implements the expected result. Thank you very much. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Check-that-the-buffer-in-diff-buffer-with-file-is-vi.patch >From 5fdeef8b44a4742ef9f745981e3c202a43697085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Mon, 14 Sep 2020 17:58:58 +0200 Subject: [PATCH] Check that the buffer in diff-buffer-with-file is visiting a file * lisp/vc/diff.el (diff-buffer-with-file): Signal a specific error when the buffer passed to diff-buffer-with-file is not visiting a file. --- lisp/vc/diff.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el index 469888078c..b7f17bf3c7 100644 --- a/lisp/vc/diff.el +++ b/lisp/vc/diff.el @@ -258,6 +258,8 @@ diff-buffer-with-file (interactive "bBuffer: ") (let ((buf (get-buffer (or buffer (current-buffer))))) (with-current-buffer (or (buffer-base-buffer buf) buf) + (unless buffer-file-name + (error "Buffer is not visiting a file")) (diff buffer-file-name (current-buffer) nil 'noasync)))) ;;;###autoload -- 2.28.0 --=-=-=--