From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Change in files.el Date: Sat, 28 Jan 2017 11:51:07 -0500 Message-ID: References: <83mvebzh0k.fsf@gnu.org> <83bmurz0y9.fsf@gnu.org> <8360kzyxor.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1485622314 22904 195.159.176.226 (28 Jan 2017 16:51:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 28 Jan 2017 16:51:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 28 17:51:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXWDs-00049w-Bb for ged-emacs-devel@m.gmane.org; Sat, 28 Jan 2017 17:51:32 +0100 Original-Received: from localhost ([::1]:52478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXWDx-0007Ot-FK for ged-emacs-devel@m.gmane.org; Sat, 28 Jan 2017 11:51:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXWDq-0007Oc-Fv for emacs-devel@gnu.org; Sat, 28 Jan 2017 11:51:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXWDp-0001og-7d for emacs-devel@gnu.org; Sat, 28 Jan 2017 11:51:30 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:19399) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cXWDW-0001gR-2D; Sat, 28 Jan 2017 11:51:24 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ByNQAu3EVY/0gvq8BdGgEBAQECAQEBAQgBAQEBgyoOAQEBAQEfhFuFVJwCJgGWXoYcBAICghFEEAECAQEBAQEBAWIoQhIBhBQBBAFWIwULCzQSFBgNJIh6CK0Ui0QBAQgCJYsZigseBY98imqbGoY6kg82IHgTDoVzIIYxgnwBAQE X-IPAS-Result: A0ByNQAu3EVY/0gvq8BdGgEBAQECAQEBAQgBAQEBgyoOAQEBAQEfhFuFVJwCJgGWXoYcBAICghFEEAECAQEBAQEBAWIoQhIBhBQBBAFWIwULCzQSFBgNJIh6CK0Ui0QBAQgCJYsZigseBY98imqbGoY6kg82IHgTDoVzIIYxgnwBAQE X-IronPort-AV: E=Sophos;i="5.33,749,1477972800"; d="scan'208";a="290682524" Original-Received: from 192-171-47-72.cpe.pppoe.ca (HELO pastel.home) ([192.171.47.72]) by smtp.teksavvy.com with ESMTP; 28 Jan 2017 11:51:07 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id B52776574D; Sat, 28 Jan 2017 11:51:07 -0500 (EST) In-Reply-To: <8360kzyxor.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 28 Jan 2017 18:08:20 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211702 Archived-At: >> >> - More generally, so that you can slightly change its behavior without >> >> having to re-implement the default behavior by hand. >> >> - Also, so as to make sure that it is *possible* to reimplement >> >> the default behavior by hand (i.e. to make sure the predicate has >> >> access to all the info it needs to reproduce the default >> >> behavior). >> > These sound minor to me (and the last two are also possible without >> > the requirement, AFAIU). >> Hmm... how do you get the last two without that requirement? > Are we still talking about a predicate, i.e. a function that returns > either t or nil? If so, I think the last two are so trivial that I > don't know where to begin answering your question. I don't see what the form of the return value changes to the problem. Regarding "More generally, so that you can slightly change its behavior without having to re-implement the default behavior by hand": - what code would you write which preserves the behavior except that it logs all calls to some global variable? - what code would you write which preserves the behavior except that it returns nil for one specific buffer? Regarding "Also, so as to make sure that it is *possible* to reimplement the default behavior by hand": in my experience trying to change *-function to default to a non-nil value, it often happens that the preexisting default behavior *cannot* be implemented faithfully (or without a lot of extra gymnastic) because it relies on some local variable which is not passed as argument to the predicate. The situation is often worse when the code is written in C, where the fix sometimes involves exporting new vars to Elisp, an that sometimes proves problematic because that var was not designed to be accessible to random code. > (defcustom save-some-buffers-default-predicate #'some-func > ...) > > (if save-some-buffers-default-predicate DO-SOMETHING) [ Side note: "(if save-some-buffers-default-predicate ...)" is already a bad idea. the only thing you should do with such a var is pass it to `funcall` or `apply`. ] > requires me to go and look at some-func, which is "one more level of > indirection". I see what you mean. Yes, the default behavior ends up moved into its own function. I'm surprised you feel so strongly about it, tho, because it never caused me such trouble. When debugging a specific execution, I'm usually doing it with Edebug, and indeed it might require some extra instrumentation step to get Edebug to enter `some-func`, but that hasn't been terribly annoying (otherwise, I'd have gotten around around to making `i` work on funcall to automate the extra step). And when just reading the code without any specific execution in mind, I typically don't look at the value of save-some-buffers-default-predicate at all since the code should work correctly regardless of that value and the same problem shows up if the (funcall save-some-buffers-default-predicate) is replaced by (if save-some-buffers-default-predicate (funcall save-some-buffers-default-predicate ..args..)) ..do-the-default-thing..) -- Stefan