[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kill-buffer-if-not-modified: Wrong type argument: bufferp, t
From: |
Sven Joachim |
Subject: |
Re: kill-buffer-if-not-modified: Wrong type argument: bufferp, t |
Date: |
Thu, 24 Jan 2008 19:48:38 +0100 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) |
On 2008-01-21 21:44 +0100, Sven Joachim wrote:
> On 2008-01-21 21:07 +0100, Eli Zaretskii wrote:
>
>> Sorry for messing up. Please show me the full traceback, I didn't
>> expect this function to be called with t as its argument.
>
> Here it comes:
>
> ,----
> | Debugger entered--Lisp error: (wrong-type-argument bufferp t)
> | buffer-modified-p(t)
> | kill-buffer-if-not-modified(#<buffer junk>)
> | view-mode-exit(((#<window 249 on sven> nil #<buffer sven> 6889 8214)
> (#<window 177> nil #<buffer sven> 7472 8351) (#<window 164> nil #<buffer
> sven> 7755 8214)) kill-buffer-if-not-modified)
> | View-quit()
> | call-interactively(View-quit)
> `----
>
> The reason is that (bufferp buf) returns t if buf is a buffer, so
> (or (bufferp buf) (get-buffer buf)) returns t as well and buf is set to t.
And buffer-modified-p does not accept t as argument, I should add.
>>> It seems that this patch fixes the issue:
>>>
>>> --8<---------------cut here---------------start------------->8---
>>> --- view.el 21 Jan 2008 18:51:02 +0100 1.84.2.9
>>> +++ view.el 21 Jan 2008 19:26:10 +0100
>>> @@ -244,7 +244,9 @@
>>> ;; types C-x C-q again to return to view mode.
>>> (defun kill-buffer-if-not-modified (buf)
>>> "Like `kill-buffer', but does nothing if the buffer is modified."
>>> - (let ((buf (or (bufferp buf) (get-buffer buf))))
>>> + (let ((buf (if (bufferp buf)
>>> + buf
>>> + (get-buffer buf))))
>>> (and buf (not (buffer-modified-p buf))
>>> (kill-buffer buf))))
>>
>> I'm not sure this is the right fix, that's why I want to see the
>> traceback.
>
> As Andreas and Stefan already noted, just
>
> (let ((buf (get-buffer buf)))
>
> would suffice.
Here is a cleaned up patch (that I've been using for two days) and
Changelog entry. Would you please install that?
--8<---------------cut here---------------start------------->8---
--- view.el 21 Jan 2008 18:51:02 +0100 1.84.2.9
+++ view.el 22 Jan 2008 08:30:22 +0100
@@ -244,7 +244,7 @@
;; types C-x C-q again to return to view mode.
(defun kill-buffer-if-not-modified (buf)
"Like `kill-buffer', but does nothing if the buffer is modified."
- (let ((buf (or (bufferp buf) (get-buffer buf))))
+ (let ((buf (get-buffer buf)))
(and buf (not (buffer-modified-p buf))
(kill-buffer buf))))
--8<---------------cut here---------------end--------------->8---
2008-01-24 Sven Joachim <address@hidden>
* view.el (kill-buffer-if-not-modified): Don't pass t to
buffer-modified-p.
Re: kill-buffer-if-not-modified: Wrong type argument: bufferp, t, Stefan Monnier, 2008/01/21