unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43401: 28.0.50; [PATCH] Emacs Lisp type error when the buffer passed to diff-buffer-with-file is not visiting a file
       [not found] <m1zh5s72xw.fsf.ref@yahoo.es>
@ 2020-09-14 16:12 ` Unknown
  2020-09-15 12:56   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Unknown @ 2020-09-14 16:12 UTC (permalink / raw)
  To: 43401

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Check-that-the-buffer-in-diff-buffer-with-file-is-vi.patch --]
[-- Type: text/x-patch, Size: 947 bytes --]

From 5fdeef8b44a4742ef9f745981e3c202a43697085 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
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


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

* bug#43401: 28.0.50; [PATCH] Emacs Lisp type error when the buffer passed to diff-buffer-with-file is not visiting a file
  2020-09-14 16:12 ` bug#43401: 28.0.50; [PATCH] Emacs Lisp type error when the buffer passed to diff-buffer-with-file is not visiting a file Unknown
@ 2020-09-15 12:56   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-15 12:56 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 43401

Daniel Martín <mardani29@yahoo.es> writes:

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

Thanks; applied to Emacs 28.

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





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

end of thread, other threads:[~2020-09-15 12:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <m1zh5s72xw.fsf.ref@yahoo.es>
2020-09-14 16:12 ` bug#43401: 28.0.50; [PATCH] Emacs Lisp type error when the buffer passed to diff-buffer-with-file is not visiting a file Unknown
2020-09-15 12:56   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).