From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99848: (compilation-save-buffers-predicate): Date: Fri, 09 Apr 2010 12:18:54 -0400 Message-ID: <4BBF536E.4090702@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1270830256 18277 80.91.229.12 (9 Apr 2010 16:24:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Apr 2010 16:24:16 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 09 18:24:14 2010 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.69) (envelope-from ) id 1O0H06-0002EU-9Y for ged-emacs-devel@m.gmane.org; Fri, 09 Apr 2010 18:24:10 +0200 Original-Received: from localhost ([127.0.0.1]:55032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0H05-0006JL-IJ for ged-emacs-devel@m.gmane.org; Fri, 09 Apr 2010 12:24:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0Gv9-00085M-0F for emacs-devel@gnu.org; Fri, 09 Apr 2010 12:19:03 -0400 Original-Received: from [140.186.70.92] (port=55702 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0Gv5-00080u-Nk for emacs-devel@gnu.org; Fri, 09 Apr 2010 12:19:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0Gv1-0008L9-Oh for emacs-devel@gnu.org; Fri, 09 Apr 2010 12:18:59 -0400 Original-Received: from mx2.janestreet.com ([38.105.200.115]:43066 helo=mx1.janestreet.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0Gv1-0008Ks-KJ for emacs-devel@gnu.org; Fri, 09 Apr 2010 12:18:55 -0400 Original-Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by mx1.janestreet.com with esmtp (Exim 4.71) (envelope-from ) id 1O0Gv0-0001ac-G9 for emacs-devel@gnu.org; Fri, 09 Apr 2010 20:18:54 +0400 Original-Received: from nyc-qws-005.delacy.com ([172.25.131.105]) by nyc-qsv-mail1.delacy.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1O0Gv0-0003Kz-Dn; Fri, 09 Apr 2010 12:18:54 -0400 User-Agent: Thunderbird 2.0.0.24 (X11/20100318) In-Reply-To: X-Enigmail-Version: 0.95.6 X-detected-operating-system: by eggs.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:123400 Archived-At: Stefan Monnier wrote: >>> - Please don't autoload defcustoms unless you have a *really* good >>> reason to do it (and even then, ask permission first). >> I autoloaded this one because its sibling compilation-ask-about-save >> is autoloaded. > > Thanks. So we can remove this ;;;###autoload done. >>> - I like where this is going, but I'm not sure this is enough. >>> Could you explain how you see it being used? >> if you edit a huge file which is expensive to save, you do not want it >> to be saved whenever you start a compilation elsewhere. > > ;-) that part I understand of course. > But I mean what value do you expect users to use it with? > Would they globally set it to save one particular directory of theirs? > What if they have more than one project? this is problematic because compile does not announce what it's working directory is. I can add a variable compile-default-directory which will be nil globally and bound to default-directory in compile and recompile; then the users will be able to set compilation-save-buffers-predicate to (lambda () (string-prefix-p (locate-dominating-file compile-default-directory "foo") (file-truename (buffer-file-name)))) so that only files located in the currently compiled project are saved. here "foo" should identify the project root, it can be, e.g., "configure" or "COPYING" or "README" or "OMakeroot" or "ANNOUNCE". we can also use "bzr root"/"hg root" instead of locate-dominating-file. this, however, becomes more and more expensive. > Part of the question is because Customize doesn't know how to set/handle > defcustoms other than globally. I think the above setting would be fine globally. Note that the "foo" above is very project-dependent and should be tweaked by the user to the flavor of one's projects. >>> Could you also explain why `compilation-directory' can't be >>> used instead? >> because if you are working on a project foo and compile in directory foo/src, >> you do want to save buffers editing foo/headers/baz.h, >> but it is not under compilation-directory, which is foo/src/. > > Can you imagine a way to make it "work automatically", maybe assuming > some particular convention that's followed half-often or that would be > easy to adjust to? we can add compile-root-directory in addition to compile-default-directory to save on locate-dominating-file / "bzr root" calls. the reasonable heuristics are: 1. if the compilation directory or the one right above it (for those who build in separate directories) is under a VC system which supports the "root" command, use that. this fails for multiple projects in the same tree - although not catastrophically (i.e., we might save extra files, but we are not likely to miss saving when it is necessary). 2. if the compile-command invokes "omake", then (locate-dominating-file compile-default-directory "OMakeroot") should be good. 3. locate-dominating-file on "configure", "ANNOUNCE" and "INSTALL" should be good, although "README" probably not.