From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: mode-line-format - local variableness Date: Mon, 06 Apr 2009 09:30:50 -0400 Message-ID: References: <004901c9b63c$77c768e0$0200a8c0@us.oracle.com> <004f01c9b666$90775970$0200a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239024692 21958 80.91.229.12 (6 Apr 2009 13:31:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Apr 2009 13:31:32 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 06 15:32:50 2009 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 1LqowT-0007ty-0H for ged-emacs-devel@m.gmane.org; Mon, 06 Apr 2009 15:32:49 +0200 Original-Received: from localhost ([127.0.0.1]:48097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lqov4-0002De-SL for ged-emacs-devel@m.gmane.org; Mon, 06 Apr 2009 09:31:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lqoue-00022b-Ry for emacs-devel@gnu.org; Mon, 06 Apr 2009 09:30:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lqoua-0001zJ-29 for emacs-devel@gnu.org; Mon, 06 Apr 2009 09:30:56 -0400 Original-Received: from [199.232.76.173] (port=53000 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LqouZ-0001z9-Mp for emacs-devel@gnu.org; Mon, 06 Apr 2009 09:30:51 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:23551) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LqouZ-0005lr-CN for emacs-devel@gnu.org; Mon, 06 Apr 2009 09:30:51 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoYFAC+h2UlMCqib/2dsb2JhbACBUsg2hA8GhQk X-IronPort-AV: E=Sophos;i="4.39,330,1235970000"; d="scan'208";a="36590568" Original-Received: from 76-10-168-155.dsl.teksavvy.com (HELO pastel.home) ([76.10.168.155]) by ironport2-out.teksavvy.com with ESMTP; 06 Apr 2009 09:30:50 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 8CED580A8; Mon, 6 Apr 2009 09:30:50 -0400 (EDT) In-Reply-To: <004f01c9b666$90775970$0200a8c0@us.oracle.com> (Drew Adams's message of "Sun, 5 Apr 2009 20:19:57 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-detected-operating-system: 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:110094 Archived-At: > Oh, I thought it _was_ always buffer-local, even in recent Emacs. > And I thought the manual was advising not to use `let' with > buffer-local variables. "Always buffer-local" is used for variables for which a "global value" basically doesn't make any sense. `buffer-file-name' for example. mode-line-format, OTOH has a default global value shared by most buffers. Ideally it probably shouldn't even be made buffer-loal by `setq' but only by `make-local-variable'. > That text is not too clear to me. Is it trying to say instead to not > use `let' with a variable that _will be_ buffer-local but is not yet > so? But it's OK to use `let' with a variable that is already > buffer-local? Not too clear, IMO. In general it's better to avoid mixing let and buffer-local. If you have to, then try to make sure that during the let, the variable's buffer-localness is not changed. In older versions of Emacs (<21 IIRC) you alsa had to try and avoid switching into another buffer during the let (or at least revert back to the same buffer before finishing the let). > Whether or not that is actually cleaner, I don't know, but it > certainly looks so. I admit that I don't understand the problem with > `let' and buffer-local-to-be-but-not-yet vars. (let ((x e1)) e2) is more or less equivalent to (let ((old-x x)) (unwind-protect (progn (setq x e1) e2) (setq x old-x))) So if the buffer-localness of x is changed in `e2' we have a problem: if old-x was read from the global part of `x', should (setq x old-x) assign to the new buffer-local part of `x' or to the global part of `x' or both? If OTOH `old-x' was read from the buffer-local part of `x' but `x' was kill-local-variable'd, should (setq x old-x) "reset" the global part of `x' or do nothing? There are reasonable choices for these questions, but no matter what you choose, you will sooner or later find a situation where it doesn't actually do what was intended, and furthermore, the implementation tends to be painful and costly, which is a bummer since it's supposed to be a *very* rare case that's fairly easy to avoid, yet you'll end up paying for it all the time. Stefan