Emacs: Writing to read-only files

Just found this little gem regarding read-only buffers in Emacs:

A buffer visiting a write-protected file is normally read-only.

Here, the purpose is to inform the user that editing the buffer with the aim of saving it in the file may be futile or undesirable. The user who wants to change the buffer text despite this can do so after clearing the read-only flag with C-x C-q.

This is cool, because Perforce makes files read-only by default (to encourage you to open them before you edit them, though you can do this after the fact if you’re careful) and because I’ve been making the files for my web site read-only as a small measure to deter site defacement. I had been using vim for editing my web site files because w! can write to read-only files, but now it looks like I have a convenient way to use Emacs as well.


Even though I’ve been using Emacs for years, I still have trouble
remembering a lot of the key combinations for commands that I
don’t use all the time (e.g.: killing and yanking rectangles,
bookmarks, etc.). I think Lotus 123 for DOS had a remarkably cool
user interface in that the menus let you explore around and find
things if you were a newbie, but once you knew the key sequences,
you could become very fast with it. This is my attempt at doing
something like the Lotus 123 menu system for Emacs.


The above elisp defines only the primitives for creating menus and not the menus themselves. The nice thing about this is that the user is free to define whatever menus and keybindings are most convenient for them.

Here’s an example of how I use it in my .emacs:

If you use this, let me know what you think and if you have any suggestions for improvements.

Blog posting via Emacs?

I’ve never really gotten into the WYSIWYG HTML editor (TinyMCE) that comes with WordPress. It’s an impressive application of DHTML, but for blog posting I don’t need a ton of fancy formatting and would rather have something lightweight, fast, and keyboard-oriented. Like for instance, Emacs.

Do you post to your blogs using Emacs? What package(s) do you use?

-1:--   blog\_with\_emacs      (XHTML) --L0--C0-----------------------------------------------
M-x post-to-blog

Yes, these CSS styles are a blatantly ripped off and then hacked version of the stuff from http://emacsen.org/.

links for 2006-10-16

Remote compiling in Emacs

I wanted to get remote compiles going in Emacs because I wanted to work in Aquamacs on my Mac. In terminal mode, a lot of keys don’t work like in particular Control + the arrow keys and in X11, I lose my Emacs session every time I disconnect and take my laptop home (unless I use something like VNC (slow) or figure out how to get FreeNX to suspend & resume properly).

Here’s how I did it. The basic approach is to use rcompile.el which seems geared for doing remote compiles over rsh, but it can be cajoled into working over ssh:

  1. Set the Emacs variable remote-compile-host to foobar.com -p 8000. The -p 8000 was only necessary for me because I am sshing to a particular FreeBSD jail that has the build environment i need for the particular project I’m working on.
  2. Set the Emacs variable remote-shell-program to /sw/bin/ssh. This path is a little unusual because I’m using a version of OpenSSH that I installed on my PowerBook using Fink. I’m choosing this over the stock OS X ssh because OpenSSH 4.0 and up support the ControlMaster feature which speeds up repeated connections to the same remote host.
  3. Instead of the Emacs compile command, use remote-compile (defined in rcompile.el).

At this point, Emacs was still crapping out because it was confused by the remote file pathname from TRAMP and didn’t know how to change directories on the remote host:

bash: line 0: cd: /ssh:foobar.com:/home/marc/src/foo/bar: 
No such file or directory

In order to solve this I got tricky and did this:

sudo ln -s / /ssh:foobar.com:

This is very hacky though and not everyone may have root access to the remote host they’re using, so I came up with a patch for rcompile.el which works for me.

Let me know if it works for you…

Writing GNU Emacs Extensions: Editor Customizations and Creations with Lisp (O\'Reilly Nutshell)

Made the switch

After deliberating for a while, I’ve finally done it.

Yes, that’s right. Like a true Emacs geek, I’ve swapped my “caps lock” and “control” keys. I could see that this could be nice once I get accustomed to it, though for now I keep reaching for the “control” and turning on “caps lock”. I had almost contemplating making both of them act as “control” but decided against it as that will probably just stop me from learning properly.

Doing this on a Mac once required extra software like uControl, fKeys, or DoubleCommand, but now in Tiger you can just do it in the Keyboard & Mouse System Preferences panel.