emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99848: (compilation-save-buffers


From: Sam Steingold
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99848: (compilation-save-buffers-predicate):
Date: Fri, 09 Apr 2010 12:18:54 -0400
User-agent: Thunderbird 2.0.0.24 (X11/20100318)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]