From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: Is this correct? Date: Sun, 27 Feb 2011 09:38:14 +1100 Organization: Unlimited download news at news.astraweb.com Message-ID: <87hbbq776x.fsf@puma.rapttech.com.au> References: <87tyfrp9p2.fsf@puma.rapttech.com.au> <4d68f5ae$0$23760$14726298@news.sunsite.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1298760034 21591 80.91.229.12 (26 Feb 2011 22:40:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 26 Feb 2011 22:40:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 26 23:40:30 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PtSoP-0000Uq-AN for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Feb 2011 23:40:29 +0100 Original-Received: from localhost ([127.0.0.1]:44487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtSoO-00069l-Rb for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Feb 2011 17:40:28 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:b6i3UKQFd2dqdsRjjM3Oxu7KOh8= Original-Lines: 62 Original-NNTP-Posting-Host: 2499495a.news.astraweb.com Original-X-Trace: DXC=^InWb3j1mOi^5mDXS]l4MgL?0kYOcDh@j7^o:UA4R?ceHIPDifKVMen]G; 2>V^?kWcCAkl5c@Xgkn6GAWCS[`KSdIabFNP@D1Eo Original-Xref: usenet.stanford.edu gnu.emacs.help:185355 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79511 Archived-At: Eli Zaretskii writes: >> Date: Sat, 26 Feb 2011 12:44:15 +0000 >> From: Uday Reddy >> >> On 2/26/2011 6:54 AM, Tim X wrote: >> >> > >> > (defun force-mode-line-update (&optional all) >> > (if all (with-current-buffer (other-buffer))) >> > (set-buffer-modified-p (buffer-modified-p))) >> > >> > The bit that doesn't look quite right to me is >> > >> > (if all (with-current-buffer (other-buffer))) >> > >> > I'm assuming that by calling with-current-buffer, this will temporarily >> > make 'other-buffer' active and as a side effect, the mode-line etc will get >> > updated. >> >> That would be quite magical if it were true. > > ?? > >> My guess is that the parentheses have been misplaced. > > ????? Doesn't force-mode-line-update work for you? > >> It should have been >> >> (if all (with-current-buffer (other-buffer) >> (set-buffer-modified-p (buffer-modified-p))) >> (set-buffer-modified-p (buffer-modified-p)) >> >> This doesn't make it right of course. The "other-buffer" doesn't equate >> to "all" buffers, and pretty often, the "other-buffer" is an invisible >> buffer. It is not guaranteed that the current-buffer is a visible >> buffer either. So, this code would seem to be wrong at many levels! > > I gets better: `(set-buffer-modified-p (buffer-modified-p))' > apparently does nothing, because it sets the buffer's modified flag to > the same value it has already. So this function actually does nothing > at all, right? > I looked at the C code that implements set-buffer-modified-p at it seems to me (who freely admits not understanding the low C level of emacs!) that as a side effect, the function updates mode-lines etc regardless of the setting/value for buffer-modified-p. Therefore, my interpretation was that this would call the function without actually changing the state of the modified flag and by side effect, result in an update of the mode-line. I do agree it doesn't look right and personally don't like code which does something via a non-intuitive/obvious side effect. While possibly convenient, from a maintenance standpoint, it would be better if it was more deliberate/obvious IMO. Tim -- tcross (at) rapttech dot com dot au