I really appreciate all of the comments that people leave on this blog. Occasionally, someone drops by and leaves an great comment with an incredibly useful tip.
shell-command and prefix argument
The first tip I’d like to highlight was at the end of a comment by Steve Vinoski. I didn’t realise how useful it would be when I first saw it but now I find it indispensable.
The tip was that using a prefix argument (i.e. pressing C-u before the command) before the synchronous shell calls inserts the output at point. Without the prefix, the output is (far less usefully) dumped in the mini-buffer.
One thing I use this for is for creating Makefiles where I need to pull in the list of headers and source files. I can now type C-u M-! ls *.H<RET>
HEADER_FILES=a.H \ b.H \ c.H \ ... \
Filtering ido results
Another thing I didn’t know about was that it is possible to filter ido results. Thanks very much to Reynaldo for pointing this out.
I’m using emacs –daemon and just realized that emacs no longer has a useful current directory. Any ideas on how to fix that?
Hi Robert,
I don’t use emacs -daemon so I’m not really familiar with the problem (see here for what I use). Having said that, perhaps adding a function to find-file-hook that sets the current directory might be what you want, or are you looking for a more complete solution?
Have a look at the function find-file-read-args which is what is
called for C-x C-f. You can see there is a local default-directory
which should be the directory the file your editing is in.
(setq default-directory “/usr/share/”)
And bingo your shell commands will now run from here. Although most of the time I find I want shell commands to run in the same directory as the file I’m messing with.
Hi Alex,
I think Robert was saying that when opening files using daemon it doesn’t set the current directory in the same way as find-file (although I might be mistaken).
Well default directory is set. This buffer’s default-directory is:
“/home/alex/.mozilla/firefox/m9cqb0pv.default/itsalltext/”
As it’s being edited via an emacsclient called via ItsAllText. Maybe Robert could clarify what he wants?
Sounds like a plan