all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* compile.el: save compile-command
@ 2010-04-22 14:57 Alfred M. Szmidt
  2010-04-23  8:37 ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Alfred M. Szmidt @ 2010-04-22 14:57 UTC (permalink / raw)
  To: emacs-devel

This patch stores the compile command in a variable, so that it can be
reused for M-x compile or M-x recompile.

2010-04-22  Alfred M. Szmidt  <ams@gnu.org>

	* progmodes/compile.el (compilation-start): Save COMMAND in
	file local variable.

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 13cf862..5a1371e 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1266,11 +1266,11 @@ Returns the compilation buffer created."
 	;; Output a mode setter, for saving and later reloading this buffer.
 	(insert "-*- mode: " name-of-mode
 		"; default-directory: " (prin1-to-string default-directory)
+		"; compile-command: " (prin1-to-string command)
 		" -*-\n"
-		(format "%s started at %s\n\n"
+		(format "%s started at %s\n"
 			mode-name
-			(substring (current-time-string) 0 19))
-		command "\n")
+			(substring (current-time-string) 0 19)) "\n")
 	(setq thisdir default-directory))
       (set-buffer-modified-p nil))
     ;; Pop up the compilation buffer.




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: compile.el: save compile-command
  2010-04-22 14:57 compile.el: save compile-command Alfred M. Szmidt
@ 2010-04-23  8:37 ` Juri Linkov
  2010-04-23 14:31   ` Alfred M. Szmidt
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Juri Linkov @ 2010-04-23  8:37 UTC (permalink / raw)
  To: ams; +Cc: emacs-devel

> This patch stores the compile command in a variable, so that it can be
> reused for M-x compile or M-x recompile.
>
> 2010-04-22  Alfred M. Szmidt  <ams@gnu.org>
>
> 	* progmodes/compile.el (compilation-start): Save COMMAND in
> 	file local variable.
>
>  	(insert "-*- mode: " name-of-mode
>  		"; default-directory: " (prin1-to-string default-directory)
> +		"; compile-command: " (prin1-to-string command)
>  		" -*-\n"
> -		(format "%s started at %s\n\n"
> +		(format "%s started at %s\n"
>  			mode-name
> -			(substring (current-time-string) 0 19))
> -		command "\n")
> +			(substring (current-time-string) 0 19)) "\n")

The idea is good, but the output is very ugly: the first line becomes
too long, and the compile command is no more easy to find and read.

Since your intention was to save the command as a file local variable,
what do you think about putting an `invisible' property over the added
`compile-command' in the first line?

Then the first line doesn't become longer, and the compile command
still is clearly visible where it currently is.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: compile.el: save compile-command
  2010-04-23  8:37 ` Juri Linkov
@ 2010-04-23 14:31   ` Alfred M. Szmidt
  2010-04-23 14:36   ` Stefan Monnier
  2010-04-23 15:00   ` Davis Herring
  2 siblings, 0 replies; 6+ messages in thread
From: Alfred M. Szmidt @ 2010-04-23 14:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

   The idea is good, but the output is very ugly: the first line becomes
   too long, and the compile command is no more easy to find and read.

   Since your intention was to save the command as a file local variable,
   what do you think about putting an `invisible' property over the added
   `compile-command' in the first line?

The property would be lost if you save the compilation output, and use
it at a later point.  I don't see the problem with long lines, since
all lines are long when compiling anyway.  How about the following
instead.

2010-04-23  Alfred M. Szmidt  <ams@gnu.org>

	* progmodes/compile.el (compilation-start): Save COMMAND in file local variable.

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 13cf862..5a8ef69 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1266,6 +1266,7 @@ Returns the compilation buffer created."
 	;; Output a mode setter, for saving and later reloading this buffer.
 	(insert "-*- mode: " name-of-mode
 		"; default-directory: " (prin1-to-string default-directory)
+		"; compile-command: " (prin1-to-string command)
 		" -*-\n"
 		(format "%s started at %s\n\n"
 			mode-name




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: compile.el: save compile-command
  2010-04-23  8:37 ` Juri Linkov
  2010-04-23 14:31   ` Alfred M. Szmidt
@ 2010-04-23 14:36   ` Stefan Monnier
  2010-04-23 16:54     ` Juri Linkov
  2010-04-23 15:00   ` Davis Herring
  2 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-04-23 14:36 UTC (permalink / raw)
  To: Juri Linkov; +Cc: ams, emacs-devel

>> (insert "-*- mode: " name-of-mode
>> "; default-directory: " (prin1-to-string default-directory)
>> +		"; compile-command: " (prin1-to-string command)
>> " -*-\n"
>> -		(format "%s started at %s\n\n"
>> +		(format "%s started at %s\n"
>> mode-name
>> -			(substring (current-time-string) 0 19))
>> -		command "\n")
>> +			(substring (current-time-string) 0 19)) "\n")

> The idea is good, but the output is very ugly: the first line becomes
> too long, and the compile command is no more easy to find and read.

Actually, the other problem is that it's redundant: the compile command
is then printed twice at the beginning of the buffer.  I'd rather tweak
the current format so that the already printed command can be extracted
reliably and then -*- compilation -*- will be sufficient (assuming
compilation-mode can then look for the command and set the
compile-command var appropriately).

> Since your intention was to save the command as a file local variable,
> what do you think about putting an `invisible' property over the added
> `compile-command' in the first line?

Using `invisible' is always asking for trouble, so I'd rather try other
options first.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: compile.el: save compile-command
  2010-04-23  8:37 ` Juri Linkov
  2010-04-23 14:31   ` Alfred M. Szmidt
  2010-04-23 14:36   ` Stefan Monnier
@ 2010-04-23 15:00   ` Davis Herring
  2 siblings, 0 replies; 6+ messages in thread
From: Davis Herring @ 2010-04-23 15:00 UTC (permalink / raw)
  To: Juri Linkov; +Cc: ams, emacs-devel

> Since your intention was to save the command as a file local variable,
> what do you think about putting an `invisible' property over the added
> `compile-command' in the first line?

I would instead put a display property on the ; just before
"compile-command" so that the line broke there visually.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: compile.el: save compile-command
  2010-04-23 14:36   ` Stefan Monnier
@ 2010-04-23 16:54     ` Juri Linkov
  0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2010-04-23 16:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: ams, emacs-devel

> Actually, the other problem is that it's redundant: the compile command
> is then printed twice at the beginning of the buffer.  I'd rather tweak
> the current format so that the already printed command can be extracted
> reliably and then -*- compilation -*- will be sufficient (assuming
> compilation-mode can then look for the command and set the
> compile-command var appropriately).

`compilation-buffer-name' already tries to get the name of the current
buffer when it's in compilation-mode.  So `compilation-read-command'
could do something similar and try to get the command from the current
buffer (it can be extracted reliably from the fourth line of the output).

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-23 16:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 14:57 compile.el: save compile-command Alfred M. Szmidt
2010-04-23  8:37 ` Juri Linkov
2010-04-23 14:31   ` Alfred M. Szmidt
2010-04-23 14:36   ` Stefan Monnier
2010-04-23 16:54     ` Juri Linkov
2010-04-23 15:00   ` Davis Herring

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.