[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: Mon, 21 Jan 2008 21:44:40 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

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.

>> It seems that this patch fixes the issue:
>> --8<---------------cut here---------------start------------->8---
>> --- view.el  21 Jan 2008 18:51:02 +0100
>> +++ 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.

>> Eli, is switching away from the buffer even if it is modified the
>> intended behavior?
> Sorry, I don't understand the question.  Could you please explain?

In a Dired buffer, I typed v to view the file at point.  Then I typed
C-x C-q, edited the buffer and pressed C-x C-q again to re-enter view
mode.  Then I typed q and the result was that I was back in the Dired
buffer.  Yet C-x C-b showed the modified (now writable) file buffer at
the top of the buffer list.  I would expect that it would either

a) not be switched away from; or
b) buried.

But maybe this is not so important.  There is another inconsistency,
though: pressing C-x C-q in the modified buffer does not enter view mode

reply via email to

[Prev in Thread] Current Thread [Next in Thread]