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: Thu, 24 Jan 2008 19:48:38 +0100 Message-ID: <87y7af3vqx.fsf@gmx.de> References: <87fxwrc92i.fsf@gmx.de> <87ve5mc3if.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 1201200476 21511 80.91.229.12 (24 Jan 2008 18:47:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jan 2008 18:47:56 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 24 19:48:15 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 1JI77J-0002cZ-4J for ged-emacs-devel@m.gmane.org; Thu, 24 Jan 2008 19:48:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JI76t-0006Wv-2f for ged-emacs-devel@m.gmane.org; Thu, 24 Jan 2008 13:47:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JI76n-0006V4-UE for emacs-devel@gnu.org; Thu, 24 Jan 2008 13:47:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JI76m-0006UL-A7 for emacs-devel@gnu.org; Thu, 24 Jan 2008 13:47:29 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JI76m-0006UI-6L for emacs-devel@gnu.org; Thu, 24 Jan 2008 13:47:28 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JI76l-0000kV-1f for emacs-devel@gnu.org; Thu, 24 Jan 2008 13:47:27 -0500 Original-Received: (qmail invoked by alias); 24 Jan 2008 18:47:24 -0000 Original-Received: from p54863DA3.dip.t-dialin.net (EHLO debian) [84.134.61.163] by mail.gmx.net (mp027) with SMTP; 24 Jan 2008 19:47:24 +0100 X-Authenticated: #28250155 X-Provags-ID: V01U2FsdGVkX1/ccmp+S6PcjlBQFA+A4WvMRPPinIcbg7bKl4dWgx iMeFPqzNElXOLI In-Reply-To: <87ve5mc3if.fsf@gmx.de> (Sven Joachim's message of "Mon, 21 Jan 2008 21:44:40 +0100") 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: Linux 2.6, seldom 2.4 (older, 4) 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:87448 Archived-At: 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(#) > | 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. 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 * view.el (kill-buffer-if-not-modified): Don't pass t to buffer-modified-p.