From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sven Joachim Newsgroups: gmane.emacs.devel Subject: Re: kill-buffer-if-not-modified: Wrong type argument: bufferp, t Date: Mon, 21 Jan 2008 21:44:40 +0100 Message-ID: <87ve5mc3if.fsf@gmx.de> References: <87fxwrc92i.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1200948248 24721 80.91.229.12 (21 Jan 2008 20:44:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Jan 2008 20:44:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 21 21:44:26 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JH3V1-0003Qb-R3 for ged-emacs-devel@m.gmane.org; Mon, 21 Jan 2008 21:44:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JH3Uc-0000gK-AG for ged-emacs-devel@m.gmane.org; Mon, 21 Jan 2008 15:43:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JH3UY-0000fu-2u for emacs-devel@gnu.org; Mon, 21 Jan 2008 15:43:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JH3UX-0000fX-0N for emacs-devel@gnu.org; Mon, 21 Jan 2008 15:43:37 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JH3UW-0000fU-Pl for emacs-devel@gnu.org; Mon, 21 Jan 2008 15:43:36 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JH3UW-00080L-BZ for emacs-devel@gnu.org; Mon, 21 Jan 2008 15:43:36 -0500 Original-Received: (qmail invoked by alias); 21 Jan 2008 20:43:34 -0000 Original-Received: from p54865DD2.dip.t-dialin.net (EHLO debian) [84.134.93.210] by mail.gmx.net (mp026) with SMTP; 21 Jan 2008 21:43:34 +0100 X-Authenticated: #28250155 X-Provags-ID: V01U2FsdGVkX19mIbh+zZxmoZrRkwuy5D7qZbh3F2foW55yc95xJF x/+wmBr7UcoZId In-Reply-To: (Eli Zaretskii's message of "Mon, 21 Jan 2008 22:07:54 +0200") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:87246 Archived-At: 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(#) | view-mode-exit(((# nil # 6889 8214) (# nil # 7472 8351) (# nil # 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 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. >> 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 again.