Peter Reavy

There and back again in Emacs (and Visual Studio)

Posted in emacs by Peter Reavy on June 27, 2012

In Emacs, when you’re editing a line and you know need to make a brief change somewhere else before coming back, then store the mark before you go so you can jump back when you’re done.

Type C-SPC C-SPC the store the mark & cancel region highlighting (I’m assuming you have transient mark mode enabled as it normally is by default).

Navigate to where you wanted and do your other edit. When you’re done, C-U C-SPC to jump back.

The exemplary Mastering Emacs has much more on the topic of the mark commands.

In Visual Studio, if you’ve set up Emacs Emulation, you can do nearly the same thing.
Type C-SPC ESC to store the mark then cancel region selection.

Then go somewhere else in your code and do something. It’s the same C-U C-SPC to come back again.


Emacs Dired Tips

Posted in emacs by Peter Reavy on May 4, 2011

I’m using Emacs 23.1, primarily on Windows 7, and want to make a note of some Dired tips for my own use.

! will run a shell command on the marked files or the file at point.

So, to look at the end of a log file on a remote server (and since I have Cygwin installed):

! tail RET

To copy the name of the file at point, in order to make use of it elsewhere, use dired-copy-filename-as-kill, which is bound to w. To make it copy the absolute path:

0 w

To copy the path to the folder you’re looking at in dired:

M-< w

To create an archive of the currently marked files using 7zip:

! 7z a zipfilename * RET

To extract the archive of the file at point:

! 7z e * RET

UPDATE: here’s another one I keep forgetting to use.

From dired, to search for files containing a string, just do this, remembering that your regexp will be case-sensitive:

M-x find-grep-dired

Very basic SQL Server 2005 querying from Emacs

Posted in emacs, Uncategorized by Peter Reavy on June 8, 2010

M-x sql-ms (then enter your connection info)
M-x rename-buffer (the help recommends something like Connection 1)
Now open your .sql file, which will pick up your Connection 1 buffer as
its default
Make sure your SQL statement has a GO at the end
M-h to select a region
C-c C-r to send that region off to the SQL buffer you created in the
same step