Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to pre-load compile command history?

5 views
Skip to first unread message

Roy Smith

unread,
Nov 16, 2011, 12:16:22 PM11/16/11
to help-gn...@gnu.org
I'm running GNU Emacs 23.1.1. In my init.el file, I set my default compile command:

(global-set-key "\C-cm" 'compile)
(setq compile-command "cd /home/roy/songza/code/radio/api/mobile/test; python test_api.py")

That works fine, but now I've got several different commands that I run often. Is there some way to pre-load them into the compile history, so I can just do c-c m, then up-arrow though the history to pick the one I want?

---
Roy Smith
r...@panix.com


Drew Adams

unread,
Nov 16, 2011, 12:54:52 PM11/16/11
to Roy Smith, help-gn...@gnu.org
> (global-set-key "\C-cm" 'compile)
> (setq compile-command "cd
> /home/roy/songza/code/radio/api/mobile/test; python test_api.py")
>
> That works fine, but now I've got several different commands
> that I run often. Is there some way to pre-load them into
> the compile history, so I can just do c-c m, then up-arrow
> though the history to pick the one I want?

If option `compilation-read-command' is non-nil then you are prompted with
completion for the compilation command to use. You can set the history variable
`compile-history' ahead of time, so you can then use `M-n', `M-p', `M-s', and
`M-r' to access the commands on your list.

(This is according to what I see in the code in `compile.el'. I don't often use
`compile' myself.)


Roy Smith

unread,
Nov 16, 2011, 1:36:31 PM11/16/11
to Drew Adams, help-gn...@gnu.org
Hmmm, my lisp is really rusty, and I'm struggling with the syntax.  The following doesn't seem to work.

(setq compile-history (cons '("cd /home/roy/songza/pyza/djapi; python test_api.py"
                              "cd /home/roy/songza/code/radio/api/mobile/test; python test_api.py"
                              )
                            ))


---
Roy Smith



Drew Adams

unread,
Nov 16, 2011, 2:08:47 PM11/16/11
to Roy Smith, help-gn...@gnu.org
> The following doesn't seem to work.
> (setq compile-history (cons '("..." "...")))

Try this:

(setq compile-history
'("cd /home/roy/songza/pyza/djapi; python test_api.py"
"cd /home/roy/songza/code/radio/api/mobile/test; python test_api.py"))

Then use `M-p' to cycle backward through the history.


des...@verizon.net

unread,
Nov 16, 2011, 2:55:18 PM11/16/11
to
Easier to put the compile command into the file.

For example, here's my cron.tab file:

#mm hh dd mm weekday command
50 * * * * /u/dane/gif/Calc.next dane
# Local Variables:
# compile-command: "crontab ~/cron.linux"
# End:



--
Dan Espen

Tom

unread,
Nov 16, 2011, 2:58:46 PM11/16/11
to help-gn...@gnu.org
Roy Smith <roy <at> panix.com> writes:

>
> I'm running GNU Emacs 23.1.1. In my init.el file, I set my default compile
command:
>
> (global-set-key "\C-cm" 'compile)
> (setq compile-command "cd /home/roy/songza/code/radio/api/mobile/test; python
test_api.py")
>
> That works fine, but now I've got several different commands that I run often.
Is there some way to pre-load
> them into the compile history, so I can just do c-c m, then up-arrow though
the history to pick the one I want?
>

The simplest solution is to use savehist mode to save and restore minibuffer
histories. This is really useful in case of other history prompts too.

http://www.emacswiki.org/emacs/SaveHist



Roy Smith

unread,
Nov 16, 2011, 8:11:55 PM11/16/11
to Drew Adams, help-gn...@gnu.org
Yup, that did it. Exactly what I was looking for! Much obliged.
--
Roy Smith
r...@panix.com




Xah Lee

unread,
Nov 17, 2011, 2:43:52 AM11/17/11
to
i'd recommend Tom's suggestion.

Just turn on savehist-mode. Put this in your emacs init file:

(setq savehist-mode 1)

Xah
0 new messages