Okay… it’s time to finally define those function keys in Emacs…

Here’s my set-up. For “help”, most of the time apropos is what I need to do. Yes… I waste time mousing over to the drop down menu. The other twenty percent of the time, I want to know what a key is doing. Those two functions are going over to F1 and shift-F1 respectively. I’m not setting anything onto alt-F1 or super-duper-F1 because I’m not liable to remember more than two functions per function key.

The most important tool for the lazy roll-tester: comment and uncomment region go to F2 and shift-F2. (I’m sticking it next to F1 because I definitely “need help” if I’m using it a lot!)

F3 fires up the shell, because it’s the first thing I do most of the time anyway.

F4… “close” the current buffer. I sometimes use “kill other windows” (now shift-F4), but usually I forget what it does exactly and kill the wrong thing.

F5 is now the one stop keyboard macro stop. The usual scenario is… edit some code, start recording, save the file, change to the shell buffer, type the shell command to run the code I’m working on, then stop recording. Now F5 works like all those other IDE’s out there, except I get to keep my entire command and output history and I’m just one C-x b away from getting back to my code. Viva roll testing!

F6 switches to the “other” window. Yes. I still confuse C-x o and C-x 0. Maybe I’ll have more windows open if I have this, but I usually like just having one giant buffer, so I doubt I’ll use this.

F8 to run my emacs code I’m fiddling with– and shift-f8 to load a whole file. Yes… my left hand hurts from doing C-x C-e too many times today. (F8 was the next most often used key after F5 in one of my old IDE’s, so maybe I’ll think of something better, but I want something that will encourage me to fiddle with Emacs a little more often.)

Finally… what’s not listed here is what illustrates what an Emacs loser I am! (I’m still addicted to Tortoise SVN. Sad, but true.) Yes… those lists of things that “if you don’t know how to do these things with your editor, then you stink” are NOT yet represented here. Maybe some day…. For now… just preface your comment with, “I can’t believe you didn’t make a hotkey for ___! You are obviously an emacs loser n00b!”

(global-set-key [f1] 'apropos-command)
(global-set-key [S-f1] 'describe-key)

(global-set-key [f2] 'comment-region)
(global-set-key [S-f2] 'uncomment-region)

(global-set-key [f3] 'shell)

(global-set-key [f4] 'kill-this-buffer)
(global-set-key [S-f4] 'delete-other-windows)

(global-set-key [f5] 'call-last-kbd-macro)
(global-set-key [S-f5] 'start-kbd-macro)
(global-set-key [M-f5] 'end-kbd-macro)

(global-set-key [f6] 'other-window)

(global-set-key [f8] 'eval-last-sexp)
(global-set-key [S-f8] 'load-file)

3 Responses to “Okay… it’s time to finally define those function keys in Emacs…”

  1. Eric TF Bat Says:

    One thing I liked in an old Windows (sorry — I mean Windoze) editor was that the “start recording” and “stop recording” keys were the same. So, using your key settings, it would be: s-f5 [lots of stuff] s-f5. Now, call-last-kbd-macro already switches off recording when required, so presumably Emacs has an easy way of detecting whether we’re recording. Let’s see… oh, bother; it’s C source code, so I can’t read it for clues. And my gods, there are a lot of kmacro commands I’ve never heard of. Evidently there’s more to this than just c-x ( and c-x ) and c-x e! But writing some kind of toggle-kbd-macro will have to wait until I have time to experiment, I guess…

  2. Niels Giesen Says:

    C source code? No way, just the variable `defining-kbd-macro’, so it’s be:

    (defun toggle-kdb-macro ()
    (let ((cmd (if defining-kbd-macro
    (call-interactively cmd)))

  3. Geno Z Heinlein Says:

    > Yes… I waste time mousing over to the drop down menu.

    The three most useful commands for your .emacs file:

    (tool-bar-mode nil)
    (menu-bar-mode nil)
    (set-scroll-bar-mode nil)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: