SaltyCrane Blog — Notes on JavaScript and web development

How to sort a Python dict (dictionary) by keys or values

Updated to work with both Python 2 and 3

How to sort a dict by key

mydict = {
    "carl": 40,
    "alan": 2,
    "bob": 1,
    "danny": 3,
}

for key in sorted(mydict.keys()):
    print("%s: %s" % (key, mydict[key]))

Results:

alan: 2
bob: 1
carl: 40
danny: 3

To sort the keys in reverse, add reverse=True as a keyword argument to the sorted function.

How to sort a dict by value

for key, value in sorted(mydict.items(), key=lambda item: item[1]):
    print("%s: %s" % (key, value))

Results:

bob: 1
alan: 2
danny: 3
carl: 40

Originally taken from Nick Galbreath's Digital Sanitation Engineering blog article

See also

Emacs 22 Command Index (sorted by Category)

I could not find an Emacs command reference arranged by category so I wrote a Python script to create one. Here is the original index sorted by command name. Below is the index sorted by category. This command index is for Emacs 22.1 Windows. UPDATE: I recategorized the commands at a higher level so they match the top level chapters in the Emacs manual. I also added default keybindings for those commands which have them.

CONTENTS
Inportant General Concepts
1. The Organization of the Screen
7. Exiting Emacs

Fundamental Editing Commands
8. Basic Editing Commands
9. The Minibuffer
10. Running Commands by Name
11. Help

Important Text-Changing Commands
12. The Mark and the Region
13. Killing and Moving Text
14. Yanking
15. Accumulating Text
16. Rectangles
17. CUA Bindings
18. Registers
19. Controlling the Display
20. Searching and Replacement
21. Commands for Fixing Typos
22. Keyboard Macros

Major Structures of Emacs
23. File Handling
24. Using Multiple Buffers
25. Multiple Windows
26. Frames and Graphical Displays
27. International Character Set Support

Advanced Features
28. Major Modes
29. Indentation
30. Commands for Human Languages
31. Editing Programs
32. Compiling and Testing Programs
33. Maintaining Large Programs
34. Abbrevs
35. Editing Pictures
36. Sending Mail
37. Reading Mail with Rmail
38. Dired, the Directory Editor
39. The Calendar and the Diary
40. Gnus
41. Running Shell Commands from Emacs
42. Using Emacs as a Server
43. Printing Hard Copies
44. PostScript Hardcopy
46. Printing Package
47. Sorting Text
48. Narrowing
49. Two-Column Editing
51. Saving Emacs Sessions
52. Recursive Editing Levels
53. Emulation
54. Hyperlinking and Navigation Features
55. Dissociated Press
56. Other Amusements
57. Customization

Recovery from Problems
58. Quitting and Aborting
59. Dealing with Emacs Trouble
60. Reporting Bugs
Appendix. C Command Line Arguments for Emacs Invocation
Appendix. F Emacs and Mac OS
Appendix. G Emacs and Microsoft Windows/MS-DOS

CATEGORYCOMMANDS
The Organization of the Screenmenu-bar-open
tmm-menubar['M-`']
Exiting Emacsiconify-or-deiconify-frame['C-z', 'C-x C-z']
save-buffers-kill-emacs['C-x C-c']
suspend-emacs
Basic Editing Commandsbackward-char['C-b', '<left>']
beginning-of-buffer['<C-home>', '<begin>', 'M-<']
count-lines-region['M-=']
delete-blank-lines['C-x C-o']
digit-argument['C-0 .. C-9', 'M-0 .. M-9', 'C-M-0 .. C-M-9']
end-of-buffer['<C-end>', 'M->']
forward-char['C-f', '<right>']
goto-char
goto-line['M-g g', 'M-g M-g']
help-with-tutorial['C-h t', '<f1> t', '<help> t']
move-beginning-of-line['C-a', '<home>']
move-end-of-line['C-e', '<end>']
move-to-window-line['M-r']
negative-argument['C--', 'M--', 'C-M--']
newline['RET']
next-line['C-n', '<down>']
open-line['C-o', '<insertline>']
previous-line['C-p', '<up>']
quoted-insert['C-q']
repeat['C-x z']
self-insert
set-goal-column['C-x C-n']
universal-argument['C-u']
what-cursor-position['C-x =']
what-line
what-page
The Minibufferchoose-completion
file-name-shadow-mode
icomplete-mode
list-command-history
minibuffer-complete
minibuffer-complete-word
mouse-choose-completion
next-completion
next-history-element
next-matching-history-element
partial-completion-mode
previous-completion
previous-history-element
previous-matching-history-element
repeat-complex-command['<again>', '<redo>', 'C-x ESC ESC', 'C-x M-:']
switch-to-completions
Running Commands by Nameexecute-extended-command['<execute>', '<menu>', 'M-x']
HelpInfo-goto-emacs-command-node['C-h F', '<f1> F', '<help> F']
Info-goto-emacs-key-command-node['C-h K', '<f1> K', '<help> K']
apropos
apropos-command['C-h a', '<f1> a', '<help> a']
apropos-documentation['C-h d', '<f1> d', '<help> d']
apropos-value
apropos-variable
browse-url
describe-bindings['C-h b', '<f1> b', '<help> b']
describe-copying['C-h C-c', '<f1> C-c', '<help> C-c']
describe-distribution['C-h C-d', '<f1> C-d', '<help> C-d']
describe-function['C-h f', '<f1> f', '<help> f']
describe-key['C-h k', '<f1> k', '<help> k']
describe-key-briefly['C-h c', '<f1> c', '<help> c']
describe-mode['C-h m', '<f1> m', '<help> m']
describe-no-warranty['C-h C-w', '<f1> C-w', '<help> C-w']
describe-project['C-h C-p', '<f1> C-p', '<help> C-p']
describe-variable['C-h v', '<f1> v', '<help> v']
display-local-help['C-h .', '<f1> .', '<help> .']
finder-by-keyword['C-h p', '<f1> p', '<help> p']
help-command['C-h', '<f1>', '<help>']
help-for-help['C-h C-h', 'C-h ?', 'C-h <f1>', 'C-h <help>', '<f1> C-h', '<f1> ?', '<f1> <f1>', '<f1> <help>', '<help> C-h', '<help> ?', '<help> <f1>', '<help> <help>']
help-next-ref
help-previous-ref
info['C-h i', '<f1> i', '<help> i']
info-lookup-symbol['C-h S', '<f1> S', '<help> S']
view-echo-area-messages['C-h e', '<f1> e', '<help> e']
view-emacs-FAQ['C-h C-f', '<f1> C-f', '<help> C-f']
view-emacs-news['C-h C-n', 'C-h n', '<f1> C-n', '<f1> n', '<help> C-n', '<help> n']
view-emacs-problems['C-h C-e', '<f1> C-e', '<help> C-e']
view-emacs-todo
view-lossage['C-h l', '<f1> l', '<help> l']
where-is['C-h w', '<f1> w', '<help> w']
The Mark and the Regionexchange-point-and-mark['C-x C-x']
mark-whole-buffer['C-x h']
pop-global-mark['C-x C-@', 'C-x C-SPC']
set-mark-command['C-@', 'C-SPC']
transient-mark-mode
Killing and Moving Textdelete-backward-char
delete-char['C-d', '<deletechar>']
delete-horizontal-space['M-\\']
just-one-space['M-SPC']
kill-line['C-k', '<deleteline>']
kill-region['C-w', '<S-delete>']
kill-whole-line['<C-S-backspace>']
normal-erase-is-backspace-mode
zap-to-char['M-z']
Yankingappend-next-kill['C-M-w']
kill-ring-save['<C-insert>', '<C-insertchar>', 'M-w']
yank['C-y', '<S-insert>', '<S-insertchar>']
yank-pop['M-y']
Accumulating Textappend-to-buffer
append-to-file
copy-to-buffer
prepend-to-buffer
Rectanglesclear-rectangle['C-x r c']
delete-rectangle['C-x r d']
delete-whitespace-rectangle
kill-rectangle['C-x r k']
open-rectangle['C-x r o']
string-insert-rectangle
string-rectangle['C-x r t']
yank-rectangle['C-x r y']
CUA Bindingscua-mode
Registersappend-to-register
bookmark-delete
bookmark-insert
bookmark-insert-location
bookmark-jump['C-x r b']
bookmark-load
bookmark-save
bookmark-set['C-x r m']
bookmark-write
copy-rectangle-to-register['C-x r r']
copy-to-register['C-x r s', 'C-x r x']
frame-configuration-to-register['C-x r f']
increment-register['C-x r +']
insert-register['C-x r g', 'C-x r i']
jump-to-register['C-x r j']
list-bookmarks
number-to-register['C-x r n']
point-to-register['C-x r C-@', 'C-x r SPC', 'C-x r C-SPC']
prepend-to-register
view-register
window-configuration-to-register['C-x r w']
Controlling the Displayblink-cursor-mode
column-number-mode
delete-trailing-whitespace
display-time
follow-mode
font-lock-add-keywords
font-lock-mode
font-lock-remove-keywords
fringe-mode
global-font-lock-mode
global-hl-line-mode
hi-lock-find-patterns
hi-lock-mode
hi-lock-write-interactive-patterns
highlight-changes-mode
highlight-lines-matching-regexp
highlight-regexp
hl-line-mode
line-number-mode
list-faces-display['<C-down-mouse-2> <df>']
recenter['C-l']
reposition-window['C-M-l']
scroll-down['<prior>', 'M-v']
scroll-left['<C-next>', 'C-x <']
scroll-right['<C-prior>', 'C-x >']
scroll-up['C-v', '<next>']
set-face-background
set-face-foreground
set-fringe-style
set-selective-display['C-x $']
size-indication-mode
toggle-truncate-lines
tty-suppress-bold-inverse-default-colors
turn-on-font-lock
unhighlight-regexp
Searching and Replacementdelete-matching-lines
delete-non-matching-lines
describe-categories
flush-lines
how-many
isearch-backward['C-r']
isearch-backward-regexp['C-M-r']
isearch-forward['C-s']
isearch-forward-regexp['C-M-s']
isearch-toggle-input-method
isearch-toggle-specified-input-method
keep-lines
list-matching-lines
multi-occur
multi-occur-in-matching-buffers
occur
query-replace['M-%']
query-replace-regexp['C-M-%']
re-search-backward
re-search-forward
replace-regexp
replace-string
search-backward
search-forward['<find>']
word-search-backward
word-search-forward
Commands for Fixing Typosflyspell-mode
flyspell-prog-mode
ispell
ispell-buffer
ispell-complete-word
ispell-kill-ispell
ispell-region
ispell-word['M-$']
transpose-chars['C-t']
transpose-lines['C-x C-t']
transpose-words['M-t']
undo['C-_', 'C-/', '<undo>']
undo-only
Keyboard Macrosapply-macro-to-region-lines
edit-kbd-macro
insert-kbd-macro
kbd-macro-query['C-x q']
kmacro-add-counter
kmacro-bind-to-key
kmacro-cycle-ring-next
kmacro-cycle-ring-previous
kmacro-edit-lossage
kmacro-edit-macro
kmacro-end-and-call-macro['C-x e']
kmacro-end-macro['C-x )']
kmacro-end-or-call-macro-repeat
kmacro-insert-counter
kmacro-name-last-macro
kmacro-set-counter
kmacro-set-format
kmacro-start-macro['C-x (']
kmacro-step-edit-macro
File Handlingadd-name-to-file
ask-user-about-lock
auto-compression-mode
auto-revert-mode
auto-revert-tail-mode
auto-save-mode
cd
compare-windows
copy-file
delete-file
diff
diff-backup
diff-mode
do-auto-save
file-cache-add-directory
file-cache-minibuffer-complete
filesets-add-buffer
filesets-init
filesets-remove-buffer
find-alternate-file['C-x C-v']
find-file['<open>', 'C-x C-f']
find-file-literally
find-file-other-frame['C-x 5 C-f', 'C-x 5 f']
find-file-other-window['C-x 4 C-f', 'C-x 4 f']
find-file-read-only['C-x C-r']
global-auto-revert-mode
image-mode
image-toggle-display
insert-file['C-x i']
insert-file-literally
list-directory['C-x C-d']
log-edit-insert-changelog
make-symbolic-link
mode, thumbs
not-modified['M-~']
pwd
recentf-edit-list
recentf-mode
recentf-save-list
recover-file
recover-session
rename-file
revert-buffer
save-buffer['C-x C-s']
save-some-buffers['C-x s']
set-visited-file-name
shadow-initialize
smerge-mode
substitute-in-file-name
thumbs-mode
time-stamp
vc-annotate['C-x v g']
vc-cancel-version['C-x v c']
vc-create-snapshot['C-x v s']
vc-diff['C-x v =']
vc-directory['C-x v d']
vc-dired-mark-locked
vc-dired-toggle-terse-mode
vc-insert-headers['C-x v h']
vc-merge['C-x v m']
vc-next-action['C-x v v']
vc-print-log['C-x v l']
vc-register['C-x v i']
vc-rename-file
vc-retrieve-snapshot['C-x v r']
vc-revert-buffer['C-x v u']
vc-switch-backend['C-x v b']
vc-toggle-read-only
vc-update-change-log['C-x v a']
vc-version-other-window['C-x v ~']
view-file
write-file['C-x C-w']
write-region
Using Multiple Buffersbs-show
buffer-menu
buffer-menu-other-window
clean-buffer-list
clone-indirect-buffer
clone-indirect-buffer-other-window['C-x 4 c']
iswitchb-mode
kill-buffer['C-x k']
kill-some-buffers
list-buffers['C-x C-b']
make-indirect-buffer
mouse-buffer-menu['<C-down-mouse-1>']
msb-mode
next-buffer['C-x <C-right>', 'C-x <right>']
previous-buffer['C-x <C-left>', 'C-x <left>']
rename-buffer
rename-uniquely
switch-to-buffer['C-x b']
switch-to-buffer-other-frame['C-x 5 b']
switch-to-buffer-other-window['C-x 4 b']
toggle-read-only['C-x C-q']
view-buffer
Multiple Windowsbalance-windows['C-x +']
delete-other-windows['C-x 1']
delete-window['C-x 0']
enlarge-window['C-x ^']
enlarge-window-horizontally['C-x }']
kill-buffer-and-window['C-x 4 0']
other-window['C-x o']
scroll-other-window['<M-next>', 'C-M-v', 'ESC <next>']
shrink-window-if-larger-than-buffer['C-x -']
split-window-horizontally['C-x 3']
split-window-vertically['C-x 2']
windmove-default-keybindings
windmove-right
winner-mode
Frames and Graphical Displaysauto-lower-mode
auto-raise-mode
delete-frame['C-x 5 0']
delete-other-frames['C-x 5 1']
delete-selection-mode
find-file-read-only-other-frame['C-x 5 r']
iconify-or-deiconify-frame['C-z', 'C-x C-z']
make-frame-command['C-x 5 2']
make-frame-on-display
menu-bar-enable-clipboard
menu-bar-mode
mouse-avoidance-mode
mouse-save-then-click
mouse-secondary-save-then-kill['<M-mouse-3>']
mouse-set-point['<double-mouse-1>', '<mouse-1>', '<triple-mouse-1>', '<right-fringe> <mouse-1>', '<left-fringe> <mouse-1>']
mouse-set-region['<drag-mouse-1>']
mouse-set-secondary['<M-drag-mouse-1>']
mouse-start-secondary['<M-mouse-1>']
mouse-wheel-mode
mouse-yank-at-click['<mouse-2>', '<right-fringe> <mouse-2>', '<left-fringe> <mouse-2>']
mouse-yank-secondary['<M-mouse-2>']
other-frame['C-x 5 o']
scroll-bar-mode
select-frame-by-name
set-frame-name
toggle-scroll-bar
tool-bar-mode
tooltip-mode
International Character Set Supportcreate-fontset-from-fontset-spec
describe-character-set
describe-coding-system['C-h C', '<f1> C', '<help> C']
describe-input-method['C-h C-\\', 'C-h I', '<f1> C-\\', '<f1> I', '<help> C-\\', '<help> I']
describe-language-environment['C-h L', '<f1> L', '<help> L']
list-charset-chars
list-coding-systems
list-input-methods
prefer-coding-system
quail-set-keyboard-layout
quail-show-key
recode-file-name
recode-region
revert-buffer-with-coding-system['C-x RET r']
set-buffer-file-coding-system['C-x RET f']
set-buffer-process-coding-system['C-x RET p']
set-file-name-coding-system['C-x RET F']
set-input-method['C-x RET C-\\']
set-keyboard-coding-system['C-x RET k']
set-language-environment['C-x RET l']
set-locale-environment
set-next-selection-coding-system['C-x RET X']
set-selection-coding-system['C-x RET x']
set-terminal-coding-system['C-x RET t']
standard-display-8bit
toggle-enable-multibyte-characters
toggle-input-method['C-\\']
unify-8859-on-decoding-mode
universal-coding-system-argument['C-x RET c']
view-hello-file['C-h h', '<f1> h', '<help> h']
Major Modesnormal-mode
Indentationback-to-indentation['M-m']
delete-indentation['M-^']
edit-tab-stops
edit-tab-stops-note-changes
indent-region['C-M-\\']
indent-relative
indent-rigidly['C-x TAB']
split-line['C-M-o']
tab-to-tab-stop['M-i']
tabify
untabify
Commands for Human Languagesauto-fill-mode
backward-kill-sentence['C-x DEL']
backward-kill-word['<C-backspace>', 'M-DEL']
backward-page['C-x [']
backward-paragraph['<C-up>', 'M-{']
backward-sentence['M-a']
backward-text-line
backward-word['<C-left>', '<M-left>', 'M-b', 'ESC <left>']
capitalize-word['M-c']
center-line
count-lines-page['C-x l']
count-text-lines
describe-text-properties['<C-down-mouse-2> <dp>']
doctex-mode
downcase-region['C-x C-l']
downcase-word['M-l']
electric-nroff-mode
enriched-mode
facemenu-remove-all['<C-down-mouse-2> <ra>']
facemenu-remove-face-props['<C-down-mouse-2> <rm>']
facemenu-set-background['<C-down-mouse-2> <bg> o']
facemenu-set-bold['M-o b', '<C-down-mouse-2> <fc> b']
facemenu-set-bold-italic['M-o l', '<C-down-mouse-2> <fc> l']
facemenu-set-default['M-o d', '<C-down-mouse-2> <fc> d']
facemenu-set-face['M-o o', '<C-down-mouse-2> <fc> o']
facemenu-set-foreground['<C-down-mouse-2> <fg> o']
facemenu-set-italic['M-o i', '<C-down-mouse-2> <fc> i']
facemenu-set-underline['M-o u', '<C-down-mouse-2> <fc> u']
fill-individual-paragraphs
fill-nonuniform-paragraphs
fill-paragraph['M-q']
fill-region
fill-region-as-paragraph
foldout-exit-fold
foldout-zoom-subtree
format-find-file
forward-page['C-x ]']
forward-paragraph['<C-down>', 'M-}']
forward-sentence['M-e']
forward-text-line
forward-word['<C-right>', '<M-right>', 'M-f', 'ESC <right>']
hide-body
hide-entry
hide-leaves
hide-other
hide-sublevels
hide-subtree
increase-left-margin['']
iso-gtex2iso
iso-iso2gtex
iso-iso2tex
iso-tex2iso
kill-sentence['M-k']
kill-word['<C-delete>', 'M-d']
latex-mode
longlines-auto-wrap
longlines-mode
longlines-show-hard-newlines
mark-page['C-x C-p']
mark-paragraph['M-h']
mark-word['M-@']
nroff-mode
outline-backward-same-level
outline-forward-same-level
outline-minor-mode
outline-mode
outline-next-visible-heading
outline-previous-visible-heading
outline-up-heading
paragraph-indent-minor-mode
paragraph-indent-text-mode
plain-tex-mode
reveal-mode
set-fill-column['C-x f']
set-fill-prefix['C-x .']
set-justification-center['<C-down-mouse-2> <ju> c']
set-justification-full['<C-down-mouse-2> <ju> b']
set-justification-left['<C-down-mouse-2> <ju> l']
set-justification-none['<C-down-mouse-2> <ju> u']
set-justification-right['<C-down-mouse-2> <ju> r']
set-left-margin
set-right-margin
sgml-attributes
sgml-close-tag
sgml-delete-tag
sgml-name-8bit-mode
sgml-name-char
sgml-skip-tag-backward
sgml-skip-tag-forward
sgml-tag
sgml-tag-help
sgml-tags-invisible
sgml-validate
show-all
show-branches
show-children
show-entry
show-subtree
slitex-mode
table-backward-cell
table-capture
table-delete-row
table-fixed-width-mode
table-forward-cell
table-generate-source
table-heighten-cell
table-insert
table-insert-column
table-insert-row
table-insert-sequence
table-justify
table-narrow-cell
table-query-dimension
table-recognize
table-recognize-cell
table-recognize-region
table-recognize-table
table-release
table-shorten-cell
table-span-cell
table-split-cell
table-split-cell-horizontally
table-split-cell-vertically
table-unrecognize
table-unrecognize-cell
table-unrecognize-region
table-unrecognize-table
table-widen-cell
tex-bibtex-file
tex-buffer
tex-close-latex-block
tex-compile
tex-file
tex-insert-braces
tex-insert-quote
tex-kill-job
tex-latex-block
tex-mode
tex-print
tex-recenter-output-buffer
tex-region
tex-show-print-queue
tex-terminate-paragraph
tex-validate-region
tex-view
text-mode
up-list
upcase-region['C-x C-u']
upcase-word['M-u']
Editing ProgramsMan-fontify-manpage
backward-list['C-M-p']
backward-sexp['<C-M-left>', 'C-M-b', 'ESC <C-left>']
backward-up-list['<C-M-up>', 'C-M-u', 'ESC <C-up>']
beginning-of-defun['<C-M-home>', 'C-M-a', 'ESC <C-home>']
c-backslash-region
c-backward-conditional
c-beginning-of-defun
c-beginning-of-statement
c-context-line-break
c-electric-backspace
c-end-of-defun
c-end-of-statement
c-fill-paragraph
c-forward-conditional
c-hungry-delete-backwards
c-hungry-delete-forward
c-indent-command
c-indent-command
c-indent-defun
c-indent-exp
c-macro-expand
c-mark-function
c-set-style
c-show-syntactic-information
c-subword-mode
c-toggle-auto-newline
c-toggle-electric-state
c-toggle-hungry-state
c-up-conditional
check-parens
comment-dwim['M-;']
comment-indent-new-line
comment-kill
comment-region
comment-set-column['C-x ;']
complete-symbol
cpp-highlight-buffer
cwarn-mode
down-list['<C-M-down>', 'C-M-d', 'ESC <C-down>']
eldoc-mode
end-of-defun['<C-M-end>', 'C-M-e', 'ESC <C-end>']
f90-beginning-of-block
f90-end-of-block
f90-mode
f90-next-block
f90-next-statement
f90-previous-block
f90-previous-statement
ff-find-related-file
fortran-beginning-of-block
fortran-column-ruler
fortran-comment-region
fortran-end-of-block
fortran-indent-comment
fortran-indent-subprogram
fortran-join-line
fortran-mode
fortran-next-statement
fortran-previous-statement
fortran-split-line
fortran-strip-sequence-nos
fortran-window-create
fortran-window-create-momentarily
forward-list['C-M-n']
forward-sexp['<C-M-right>', 'C-M-f', 'ESC <C-right>']
glasses-mode
global-cwarn-mode
hide-ifdef-mode
hs-hide-all
hs-hide-block
hs-hide-level
hs-minor-mode
hs-show-all
hs-show-block
hs-show-region
imenu
imenu-add-menubar-index
indent-code-rigidly
indent-for-tab-command
indent-line-function
indent-pp-sexp['C-M-q']
info-lookup-file
info-lookup-symbol['C-h S', '<f1> S', '<help> S']
kill-sexp['C-M-k']
lisp-complete-symbol['M-TAB']
manual-entry
mark-defun['C-M-h']
mark-sexp['C-M-@', 'C-M-SPC']
newline-and-indent
show-paren-mode
transpose-sexps['C-M-t']
which-function-mode
woman
Compiling and Testing Programscompilation-next-error
compilation-next-file
compilation-previous-error
compilation-previous-file
compile
compile-goto-error
dbx
emacs-lisp-mode
eval-buffer
eval-defun['C-M-x']
eval-expression['M-:', 'M-ESC :']
eval-last-sexp['C-x C-e']
eval-region
find-grep
gdb
gdb-delete-breakpoint
gdb-edit-value
gdb-frames-select
gdb-goto-breakpoint
gdb-many-windows
gdb-restore-windows
gdb-threads-select
gdb-toggle-breakpoint
gdb-var-delete
gdba
grep
grep-find
gud-cont
gud-def
gud-down
gud-finish
gud-gdb-complete-command
gud-jump
gud-next
gud-print
gud-refresh
gud-remove
gud-step
gud-stepi
gud-tbreak
gud-until
gud-up
gud-watch
ielm
jdb
kill-compilation
lgrep
lisp-eval-defun
lisp-interaction-mode
lisp-mode
load
load-file
load-library
next-error['C-x `', 'M-g n', 'M-g M-n']
next-error-follow-minor-mode
pdb
perldb
recompile
rgrep
run-lisp
sdb
toggle-gdb-all-registers
xdb
Maintaining Large Programsadd-change-log-entry-other-window['C-x 4 a']
change-log-merge
change-log-mode
emerge-auto-advance-mode
emerge-buffers
emerge-buffers-with-ancestor
emerge-files
emerge-files-with-ancestor
emerge-skip-prefers-mode
find-tag['M-.']
find-tag-other-frame['C-x 5 .']
find-tag-other-window['C-x 4 .']
find-tag-regexp['C-M-.']
list-tags
pop-tag-mark['M-*']
tags-apropos
tags-loop-continue['M-,']
tags-query-replace
tags-search
visit-tags-table
Abbrevsabbrev-mode
abbrev-prefix-mark["M-'"]
add-global-abbrev['C-x a g']
add-mode-abbrev['C-x a C-a', 'C-x a +', 'C-x a l']
dabbrev-completion['C-M-/']
dabbrev-expand['M-/']
define-abbrevs
define-global-abbrev
define-mode-abbrev
edit-abbrevs
expand-abbrev["C-x '", "C-x a '", 'C-x a e']
expand-region-abbrevs
insert-abbrevs
inverse-add-global-abbrev['C-x a -', 'C-x a i g']
inverse-add-mode-abbrev['C-x a i l']
kill-all-abbrevs
list-abbrevs
quietly-read-abbrev-file
read-abbrev-file
unexpand-abbrev
write-abbrev-file
Editing Picturesedit-picture
picture-backward-clear-column
picture-backward-column
picture-clear-column
picture-clear-line
picture-clear-rectangle
picture-clear-rectangle-to-register
picture-forward-column
picture-motion
picture-motion-reverse
picture-move-down
picture-move-up
picture-movement-down
picture-movement-left
picture-movement-ne
picture-movement-nw
picture-movement-right
picture-movement-se
picture-movement-sw
picture-movement-up
picture-newline
picture-open-line
picture-set-tab-stops
picture-tab
picture-tab-search
picture-yank-rectangle
picture-yank-rectangle-from-register
Sending Mailcompose-mail['C-x m']
compose-mail-other-frame['C-x 5 m']
compose-mail-other-window['C-x 4 m']
define-mail-abbrev
define-mail-alias
expand-mail-aliases
fortune-to-signature
ispell-message
mail-attach-file
mail-bcc
mail-cc
mail-complete
mail-fcc
mail-fill-yanked-message
mail-interactive-insert-alias
mail-send
mail-send-and-exit
mail-signature
mail-subject
mail-text
mail-to
mail-yank-original
mail-yank-region
spook
Reading Mail with Rmailrmail
rmail-add-label
rmail-beginning-of-message
rmail-bury
rmail-continue
rmail-delete-backward
rmail-delete-forward
rmail-edit-current-message
rmail-end-of-message
rmail-expunge
rmail-expunge-and-save
rmail-first-message
rmail-forward
rmail-get-new-mail
rmail-input
rmail-kill-label
rmail-last-message
rmail-mail
rmail-mode
rmail-next-labeled-message
rmail-next-message
rmail-next-undeleted-message
rmail-output
rmail-output-body-to-file
rmail-output-to-rmail-file
rmail-previous-labeled-message
rmail-previous-message
rmail-previous-undeleted-message
rmail-quit
rmail-redecode-body
rmail-reply
rmail-resend
rmail-retry-failure
rmail-search
rmail-show-message
rmail-summary
rmail-summary-by-labels
rmail-summary-by-recipients
rmail-summary-by-regexp
rmail-summary-by-topic
rmail-summary-quit
rmail-summary-wipe
rmail-toggle-header
rmail-undelete-previous-message
rot13-other-window
set-rmail-inbox-list
undigestify-rmail-message
unforward-rmail-message
unrmail
Dired, the Directory Editordired['C-x d']
dired-backup-diff
dired-change-marks
dired-clean-directory
dired-compare-directories
dired-copy-filename-as-kill
dired-create-directory
dired-diff
dired-display-file
dired-do-byte-compile
dired-do-chgrp
dired-do-chmod
dired-do-chown
dired-do-compress
dired-do-copy
dired-do-copy-regexp
dired-do-delete
dired-do-flagged-delete
dired-do-hardlink
dired-do-hardlink-regexp
dired-do-kill-lines
dired-do-load
dired-do-print
dired-do-query-replace-regexp
dired-do-redisplay
dired-do-rename
dired-do-rename-regexp
dired-do-search
dired-do-shell-command
dired-do-symlink
dired-do-symlink-regexp
dired-do-touch
dired-downcase
dired-find-file
dired-find-file-other-window
dired-flag-auto-save-files
dired-flag-backup-files
dired-flag-file-deletion
dired-flag-files-regexp
dired-flag-garbage-files
dired-goto-file
dired-hide-all
dired-hide-subdir
dired-mark
dired-mark-directories
dired-mark-executables
dired-mark-files-containing-regexp
dired-mark-files-regexp
dired-mark-subdir-files
dired-mark-symlinks
dired-maybe-insert-subdir
dired-mouse-find-file-other-window
dired-next-dirline
dired-next-marked-file
dired-next-subdir
dired-other-frame['C-x 5 d']
dired-other-window['C-x 4 d']
dired-prev-dirline
dired-prev-marked-file
dired-prev-subdir
dired-sort-toggle-or-edit
dired-toggle-marks
dired-tree-down
dired-tree-up
dired-undo
dired-unmark
dired-unmark-all-files
dired-unmark-all-marks
dired-unmark-backward
dired-up-directory
dired-upcase
dired-view-file
find-dired
find-grep-dired
find-name-dired
image-dired-display-thumbs
locate
locate-with-filter
revert-buffer(Dired)
wdired-change-to-wdired-mode
wdired-finish-edit
The Calendar and the Diaryamerican-calendar
appt-activate
appt-add
appt-delete
calendar
calendar-backward-day
calendar-backward-month
calendar-backward-week
calendar-beginning-of-month
calendar-beginning-of-week
calendar-beginning-of-year
calendar-count-days-region
calendar-cursor-holidays
calendar-end-of-month
calendar-end-of-week
calendar-end-of-year
calendar-forward-day
calendar-forward-month
calendar-forward-week
calendar-forward-year
calendar-goto-astro-day-number
calendar-goto-chinese-date
calendar-goto-coptic-date
calendar-goto-date
calendar-goto-day-of-year
calendar-goto-ethiopic-date
calendar-goto-french-date
calendar-goto-hebrew-date
calendar-goto-islamic-date
calendar-goto-iso-date
calendar-goto-iso-week
calendar-goto-iso-week
calendar-goto-julian-date
calendar-goto-mayan-long-count-date
calendar-goto-persian-date
calendar-goto-today
calendar-mark-today
calendar-next-calendar-round-date
calendar-next-haab-date
calendar-next-tzolkin-date
calendar-other-month
calendar-phases-of-moon
calendar-previous-haab-date
calendar-previous-tzolkin-date
calendar-print-astro-day-number
calendar-print-chinese-date
calendar-print-coptic-date
calendar-print-day-of-year
calendar-print-ethiopic-date
calendar-print-french-date
calendar-print-hebrew-date
calendar-print-islamic-date
calendar-print-iso-date
calendar-print-julian-date
calendar-print-mayan-date
calendar-print-persian-date
calendar-star-date
calendar-sunrise-sunset
calendar-unmark
diary
diary-anniversary
diary-anniversary
diary-astro-day-number
diary-block
diary-cyclic
diary-cyclic
diary-date
diary-day-of-year
diary-float
diary-float
diary-french-date
diary-hebrew-date
diary-islamic-date
diary-iso-date
diary-julian-date
diary-mail-entries
diary-mayan-date
diary-omer
diary-parasha
diary-phases-of-moon
diary-remind
diary-rosh-hodesh
diary-sabbath-candles
diary-show-all-entries
diary-sunrise-sunset
diary-view-entries
diary-yahrzeit
european-calendar
exit-calendar
fancy-diary-display
holidays
icalendar-export-file, icalendar-export-region
icalendar-import-buffer
icalendar-import-file
include-other-diary-files
insert-anniversary-diary-entry
insert-block-diary-entry
insert-cyclic-diary-entry
insert-diary-entry
insert-hebrew-diary-entry
insert-islamic-diary-entry
insert-monthly-diary-entry
insert-monthly-hebrew-diary-entry
insert-monthly-islamic-diary-entry
insert-weekly-diary-entry
insert-yearly-diary-entry
insert-yearly-hebrew-diary-entry
insert-yearly-islamic-diary-entry
list-calendar-holidays
list-hebrew-diary-entries
list-holidays
list-islamic-diary-entries
list-yahrzeit-dates
mark-calendar-holidays
mark-diary-entries
mark-hebrew-diary-entries
mark-included-diary-files
mark-islamic-diary-entries
phases-of-moon
print-diary-entries
redraw-calendar
scroll-calendar-left
scroll-calendar-left-three-months
scroll-calendar-right
scroll-calendar-right-three-months
simple-diary-display
sort-diary-entries
sunrise-sunset
timeclock-change
timeclock-in
timeclock-modeline-display
timeclock-out
timeclock-reread-log
timeclock-when-to-leave
timeclock-workday-remaining
Gnusgnus
gnus-group-exit
gnus-group-kill-group
gnus-group-list-all-groups
gnus-group-list-groups
gnus-group-next-group
gnus-group-next-unread-group
gnus-group-prev-group
gnus-group-prev-unread-group
gnus-group-read-group
gnus-group-unsubscribe-current-group
gnus-summary-isearch-article
gnus-summary-next-subject
gnus-summary-next-unread-article
gnus-summary-prev-page
gnus-summary-prev-subject
gnus-summary-prev-unread-article
gnus-summary-search-article-forward
Running Shell Commands from Emacscomint-bol-or-process-mark
comint-continue-subjob
comint-copy-old-input
comint-delchar-or-maybe-eof
comint-delete-output
comint-dynamic-complete
comint-dynamic-list-filename...
comint-dynamic-list-input-ring
comint-get-next-from-history
comint-input-previous-argument
comint-interrupt-subjob
comint-kill-input
comint-magic-space
comint-next-input
comint-next-matching-input
comint-next-prompt
comint-previous-input
comint-previous-matching-input
comint-previous-prompt
comint-quit-subjob
comint-run
comint-send-input
comint-show-maximum-output
comint-show-output
comint-stop-subjob
comint-strip-ctrl-m
comint-truncate-buffer
comint-write-output
dirs
dirtrack-mode
send-invisible
shell
shell-backward-command
shell-command['M-!']
shell-command-on-region['M-|']
shell-forward-command
shell-pushd-dextract
shell-pushd-dunique
shell-pushd-tohome
term
term-char-mode
term-line-mode
term-pager-toggle
Using Emacs as a Serverserver-edit
server-start
Printing Hard Copieslpr-buffer
lpr-region
print-buffer
print-region
PostScript Hardcopyhandwrite
ps-print-buffer
ps-print-buffer-with-faces
ps-print-region
ps-print-region-with-faces
ps-spool-buffer
ps-spool-buffer-with-faces
ps-spool-region
ps-spool-region-with-faces
Printing Packagepr-interface
Sorting Textsort-columns
sort-fields
sort-lines
sort-numeric-fields
sort-pages
sort-paragraphs
Narrowingnarrow-to-defun['C-x n d']
narrow-to-page['C-x n p']
narrow-to-region['C-x n n']
widen['C-x n w']
Two-Column Editing2C-associate-buffer
2C-dissociate
2C-merge
2C-newline
2C-split
2C-two-columns
Saving Emacs Sessionsdesktop-change-dir
desktop-clear
desktop-revert
desktop-save
Recursive Editing Levelsexit-recursive-edit['C-M-c']
Emulationcrisp-mode
edt-emulation-off
edt-emulation-on
scroll-all-mode
tpu-edt-on
vi-mode
vip-mode
viper-mode
wordstar-mode
Hyperlinking and Navigation Featuresbrowse-url
browse-url-at-mouse
browse-url-at-point
dired-at-point
ffap
ffap-menu
ffap-mode
ffap-next
find-file-at-point
goto-address
Dissociated Pressdissociated-press
Other Amusements5x5
blackbox
decipher
dunnet
gomoku
hanoi
life
lm
morse-region
mpuz
pong
snake
solitaire
studlify-region
tetris
unmorse-region
yow
zone
Customizationadd-hook
binary-overwrite-mode
customize
customize-apropos
customize-browse
customize-changed
customize-create-theme
customize-face
customize-group
customize-option
customize-saved
customize-unsaved
default-value
define-key
describe-syntax['C-h s', '<f1> s', '<help> s']
disable-command
disable-theme
enable-command
enable-theme
global-set-key
global-unset-key
kill-local-variable
load-theme
local-set-key
local-unset-key
make-local-variable
make-variable-buffer-local
modify-face
overwrite-mode['<insert>', '<insertchar>']
remove-hook
set-variable
setq-default
substitute-key-definition
widget-backward
widget-complete
widget-forward
Quitting and Abortingabort-recursive-edit['C-]']
keyboard-escape-quit['M-ESC ESC']
keyboard-quit['C-g']
top-level
Dealing with Emacs Troubledoctor
normal-erase-is-backspace-mode
Reporting Bugsdebug_print
emacs-version
open-dribble-file
open-termscript
report-emacs-bug
toggle-debug-on-error
C Command Line Arguments for Emacs Invocationgetenv
list-colors-display['<C-down-mouse-2> <dc>']
setenv
F Emacs and Mac OSdo-applescript
mac-file-name-to-posix
mac-get-file-creator
mac-get-file-type
mac-get-preference
mac-set-file-creator
mac-set-file-type
posix-file-name-to-mac
G Emacs and Microsoft Windows/MS-DOSadd-untranslated-filesystem
codepage-setup
compile(MS-DOS)
grep(MS-DOS)
mode25
mode4350
msdos-set-mouse-buttons
print-buffer(MS-DOS)
print-region(MS-DOS)
ps-print-buffer(MS-DOS)
ps-spool-buffer(MS-DOS)
remove-untranslated-filesystem
w32-shell-execute

From Eclipse to Emacs

I am trying to learn Emacs after about a year of using Eclipse 3.2/3.3. See this post for some reasons why. Below is a list of Eclipse keyboard shortcuts and their Emacs equivalents. I'm using Emacs 22.1 for Windows.

Update 2009-07-20: After almost 2 years, I am still happily using Emacs (now Emacs 23 on Ubuntu). I made a few small corrections/updates to the table below.

ECLIPSE COMMANDSIMILAR EMACS COMMAND
(Emacs manuals use C for the CTRL key and M for the Meta or Alt key. So, e.g. C-x means CTRL+X. For Emacs long commands, you can type TAB to complete the command name.)

Cancel a command
ESC
Cancel a command
C-g

Open resource
CTRL+SHIFT+R
Find file
Keybinding: C-x C-f
Command: M-x find-file
Notes: Type in the file to open. Hit TAB for filename completion. Hit up and down arrows for recently used files.

Save file
CTRL+S
Save buffer
Keybinding: C-x C-s
Command: M-x save-buffer

Save As
Write file
Keybinding: C-x C-w
Command: M-x write-file

Close
CTRL+F4

Unlike Eclipse, Emacs' buffers and windows are distinct so closing a buffer and closing a window require separate commands.

Kill this buffer
Keybinding: C-x k
Command: M-x kill-this-buffer

Delete window
Keybinding: C-x 0
Command: M-x delete-window

Undo/Redo
CTRL+Z / CTRL+Y

Undo/ Undo Undo
Keybinding: C-_, C-x u, C-/
Command: M-x undo

To redo, interrupt the undo sequence by entering any command (e.g. C-f), then undo again. This undoes what you just undid, which is like redo. See 21.1 Undo in the GNU Emacs Manual.

This behavior can be confusing so there is also a RedoMode which behaves more like Eclipse and other editors. See RedoMode on the Emacs Wiki.

Switch editors
Keybinding: CTRL+F6 or CTRL+SHIFT+F6
Command: CTRL+3 Next Editor or CTRL+3 Previous Editor

Switch buffers
Keybinding: C-x RIGHTARROW or C-x LEFTARROW
See also: 24 Using Multiple Buffers in the Emacs Manual

Switch views
Keybinding: CTRL+F7 or CTRL+SHIFT+F7
Command: CTRL+3 Next View or CTRL+3 Previous View

After splitting into 2 windows with C-x 2, use C-x o to switch between windows.

To scroll the other window, use C-M-v. This is useful to reference one window while editing in the other.

To close the other window, type C-x 1 in the window you want to keep.

Find and Replace
Keybinding: CTRL+F
Incremental Search
Keybinding: C-s

Unconditional Replace
Command: M-x replace-string RET string RET newstring RET

Regexp Replacement
Command: M-x replace-regexp RET regexp RET newstring RET

See also: 20.9 Replacement Commands

Show line numbers
Keybinding: none
Command: CTRL+3 Show Line Numbers

Linum (Emacs >= 23 only)
Keybinding: none
Command: M-x linum-mode

For Emacs <= 22, look in your status bar for the line number or see http://www.emacswiki.org/cgi-bin/wiki/LineNumbers

Code Completion
Keybinding: CTRL+SPC

Dynamic Abbrev Expansion
Keybinding: M-/
Command: M-x dabbrev-expand

This command is much faster and simpler than Eclipse because it doesn't use the compiler/interpreter. However, I think it is less robust for the same reason. At this point, I think I like the Eclipse version better.

See also 34.6 Dynamic Abbrev Expansion in the manual.

Keys
Command: CTRL+3 Keys - General

Key Bindings
Keybinding: C-h b
Command: M-x describe-bindings

Comment
Keybinding: CTRL+/

Comment DWIM (Do What I Mean)
Keybinding: M-;
Command: M-x comment-dwim

Shift Right (or Left)
Keybinding: TAB (SHIFT+BACKSPACE)

Shift Region Right (or Left)
Keybinding: C-c > (C-c <)
Command: ???

Note: This doesn't work if you're in CUA mode (i.e. using C-x/C-c/C-v Cut and Paste)

Find text in Workspace
Keybinding: CTRL+ALT+G
Command: Find Text in Workspace

grep (and variants)
Command: M-x lgrep RET string RET filepattern RET directory RET.

See also 32.4 Searching with Grep under Emacs

I still miss this one in Eclipse. grep has more power than Eclipse, but the combination of pretty highlighting and searching across files is nice in Eclipse. I have created an Elisp function to at least grep for selected text with one key stroke. Put the following in your .emacs and you'll get something similar to CTRL+ALT+G in Eclipse.
;; my eclipse CTRL+ALT+G replacement
(defun grep-selected (start end)
  (interactive "r") 
  (grep (concat "grep -nH -e " 
                (buffer-substring start end)
                " * .*"))
(global-set-key "\C-\M-g" 'grep-selected)
I am just learning to customize emacs with Elisp so I'm sure there are improvements that can be made.

Cygwin, X, ratposoin, screen, rxvt setup

Here are my configuration files for my current Cygwin, X, ratpoison, screen, urxvt, bash setup.

General Cygwin and bash
  • I changed filename completion to be case-insensitive since we're on Windows. To do this, see the last line in ~/.bashrc and the last line in ~/.inputrc below.
  • I changed the "/cygdrive" prefix to just "/". To do this, type this command once: "mount -s --change-cygdrive-prefix /"
  • I added aliases to use "grep" and "ls" with color. And I added aliases to start various windows applications. See ~/.bashrc.

urxvt
  • urxvt (rxvt-unicode) is a better alternative to rxvt and xterm. See the ~.Xdefaults file for my urxvt customizations. I chose an anti-aliased font, removed the scrollbar, changed the background to dark blue and the foreground to light yellow, and set the number of saved lines to 8000. (Note, to scroll, hit SHIFT+PGUP or SHIFT+PGDN).

ratpoison and screen
  • GNU Screen is a terminal multiplexer which can be used to manage terminal sessions. Ratpoison is a simple keyboard driven window manager largely modeled after GNU Screen which is used as an alternative to complex window managers such as Gnome or KDE. Most of the ratpoison and screen configuration is copied from Mark Pilgrim. The layering, as I understand it, is: the Windows XP OS runs the Cygwin/X environment which runs the ratpoison window manager which runs the urxvt terminal emulator which runs the screen terminal multiplexer which runs the bash command shell.

Update 5/2/2008: I learned how to paste in urxvt (actually bash). See my post, How to paste in Cygwin bash using CTRL+V.

startxwin.bat (windows batch file)
@echo off
SET DISPLAY=127.0.0.1:0.0
SET CYGWIN_ROOT=\cygwin
SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/X11R6/bin
SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH%
SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
SET XNLSPATH=/usr/X11R6/lib/X11/locale

if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH
attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0
del %CYGWIN_ROOT%\tmp\.X11-unix\X0
:CLEANUP-FINISH

if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix
if "%OS%" == "Windows_NT" goto OS_NT
echo startxwin.bat - Starting on Windows 95/98/Me
goto STARTUP

:OS_NT
echo startxwin.bat - Starting on Windows NT/2000/XP/2003

:STARTUP
%RUN% XWin -rootless -clipboard -silent-dup-error
%RUN% /usr/local/bin/ratpoison
~/.ratpoisonrc
# initial frame and window setup
hsplit
focusright
exec urxvt -e screen -RD

# use Pause as prefix key instead of Ctrl-T
escape Pause

# use global cursor positioning (not per-frame)
warp off

# set appearance of ratpoison status messages and input line
set bgcolor black
set fgcolor grey95
set font -b&h-lucidatypewriter-bold-r-normal-sans-18-180-75-75-m-110-iso8859-1;
set inputwidth 1247
set bargravity ne
set barpadding 4 4
msgwait 3

# top-level shortcuts (don't require prefix key)
definekey top C-M-Up focusup
definekey top C-M-Down focusdown
definekey top C-M-Left focusleft
definekey top C-M-Right focusright
~/.Xdefaults
URxvt*background: #000033
URxvt*foreground: #ffffcc
! run "fc-list" for a list of available fonts
URxvt*font: xft:Bitstream Vera Sans Mono:size=12
Urxvt*boldFont: xft:Bitstream Vera Sans Mono:size=12:style=Bold
URxvt*scrollBar: False
URxvt*scrollTtyOutput: False
URxvt*scrollTtyKeypress: True
URxvt*secondaryScroll: True
URxvt*saveLines: 8000
~/.screenrc
shell /usr/bin/bash

# scrollback
defscrollback 8000

# Window numbering starts at 1
bind c screen 1
bind 0 select 10
screen 1

# Create initial windows
screen -t home 1
screen -t myproj 1
screen -t pydev 1
screen -t docs 1
screen -t misc 1

# Set the caption on the bottom line:
# window-list  ddyy> am/pm
# from http://diveintomark.org/public/2007/03/screenrc
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %1` %m/%d/%y %C:%s%a"

# use backtick for prefix key instead of Ctrl-A
escape ``

# use regular audible bell
vbell off

# skip intro
startup_message off

# detach on disconnect
autodetach on
~/.bashrc
# prompt 
# see http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
export PS1="\n\e[31;1m\w\n\e[0m\$ "

# cygwin aliases
alias where='type -a'
alias grep='grep --color'
alias ls='ls --color=auto'
alias la='ls -dlAog --time-style="+%Y %m/%d %H:%M" .*; ls -Xlog --time-style="+%Y %m/%d %H:%M"'
alias ll='ls -Xlog --hide "*~" --hide "*.bak" --hide "*.orig" --time-style="+%Y %m/%d %H:%M"'
alias dir='ll'
alias ec='emacsclient -n '

# directory aliases
alias home='cd ~'
alias progfiles='cd /c/Program\ Files'
alias incoming='cd ~/incoming'

# windows aliases
alias firefox='/c/Program\ Files/Mozilla\ Firefox/firefox.exe &'
alias eclipse='/c/Programs/eclipse3.3/eclipse.exe -vmargs -Xms192m -Xmx192m &'
alias serena='/c/Program\ Files/Serena/vm/win32/bin/pvcsvmnt.exe &'
alias kdiff='/c/Program\ Files/KDiff3/kdiff3'
alias explorer='/c/windows/explorer /e /root,'
alias outlook='/c/Program\ Files/Microsoft\ Office/OFFICE11/OUTLOOK.EXE &'
alias taskmgr='/c/windows/system32/taskmgr.exe &'
alias word='/c/Program\ Files/Microsoft\ Office/OFFICE11/WINWORD.EXE '
alias excel='/c/Program\ Files/Microsoft\ Office/OFFICE11/EXCEL.EXE '
alias powerpoint='/c/Program\ Files/Microsoft\ Office/OFFICE11/POWERPNT.EXE '
alias acrobat='/c/Program\ Files/Adobe/Acrobat/Acrobat.exe '

# Get bash filename completion to be case insensitive - there is also a line in .inputrc
shopt -s nocaseglob
~/.inputrc
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char

# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line

# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line

# Get bash filename completion to be case insensitive - see also .bashrc
set completion-ignore-case on

backing up with rsync

Here is a python script using rsync to backup my Users directory in Vista to an external hard drive.

import os

cmd = "rsync -avz --exclude '/AppData/'" + \
      "/cygdrive/c/Users/saltycrane" + \
      "/cygdrive/f/backup/Users"
os.system(cmd)

Why not to use the backup program that comes with your external hard drive:

Do not, whatever you do, feed your valuable data to a program that is going to save it in a file format that can only be read by that program, or by that kind of computer. Because when the program can’t or the computer can’t, you’re out of options. --Tim Bray, Protecting Your Data

Why to use rsync:

rsync -essh -rtpvz rocks. --Mark Pilgrim, Essentials

On trailing slashes

from the rsync man page:

A trailing slash on the source changes this behavior to avoid creating an addi‐ tional directory level at the destination. You can think of a trailing / on a source as meaning “copy the contents of this directory” as opposed to “copy the directory by name”, but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:

rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo

Use rsync with sudo on the remote host (added 2011-09-07)

Use the --rsync-path option. e.g.

$ rsync -avz --delete --rsync-path="sudo rsync" /tmp/something myhost:/some/path 

My software tools list

Inspired by Mark Pilgrim's 2006 Essentials list, below is a list of my current software tools. If you notice a lot of "I switched from ..." statements, keep in mind that I am a programmer who likes shiny things.

Other lists

Contents

My software tools list

CategoryCurrently usingComments

Operating System

Ubuntu 14.04 Trusty Tahr

My first Ubuntu install was in 2007 (dual-boot) and I got my first Windows-free machine in 2008. I have used Cygwin and coLinux when on Windows. Cygwin integrates better with Windows applications, but coLinux is super fast and allows you to run a full Linux distro on top of Windows. Windows does have some advantages, but overall I prefer Linux.

Update 2008-09: Switching jobs means I can now use Linux at work. I'm now using Linux about 90% of the time. My wife still uses Windows Vista on our laptop.

I don't have enough experience with OSX to draw any authoritative conclusions, though I think Mark Pilgrim has biased me against Apple. Also, I think Linux's free as in beer (and somewhat related free as in speech) characteristics vs. Mac's expensive (and somewhat related proprietary) characteristics resonate with the cheap engineer in me.

Additional Linux vs. Mac commentary:

History: 1987: Apple GS/OS, 1994: Windows 3.1, 2000: Windows 98, 2001: Windows XP, 2007: Windows Vista, 2007: Ubuntu

Window Manager

Qtile

The WM written in Python, recommended by Matt Harrison.

Previously, wmii: dynamic, tiling, scriptable window manager that doesn't require a mouse. It sucks less.

I switched from ratpoison at the same time I started using coLinux because running native Linux allowed me to use any Linux window manager as well.

Recently, some have switched from wmii to xmonad, the new Haskell tiling window manager. It has some nice features over wmii, including dual head support, but after a brief excursion, I slightly prefer wmii's way of doing things.

If you're a hard core Lisper, stumpwm is the window manager for you. It has a REPL. This one seems a little too hard core for me, especially since I don't know Lisp.

History: 2007: ratpoison, 2007: wmii, 2012: Qtile

Editor/IDE

GNU Emacs 24.3

Switched from Eclipse in 2007. It was a slow transition, but I think Emacs is worth the investment.

On Emacs vs. Vim: I really like that Vim can be used easily on remote machines. Currently, I use TRAMP for remote file editing. It is very cool, but it is slow, and I sometimes fall back on nano (*gasp*) for a quick config file edit when I am logged into a remote terminal. I also suspect that the dual modes of Vim are more efficient than Emacs-- I'm just not smart enough to get used to it. Maybe someday I will switch to Viper mode. Why Emacs over Vim? I choose Emacs because it is more powerful and closer to an IDE. Emacs Lisp allows you to do whatever you want.

On Emacs vs. Eclipse: I found Eclipse was too slow and heavy, used too much screen real estate, and was too difficult to customize. Scripting Eclipse required writing extensions in Java whereas Emacs can be extended in elegant Lisp. I think Eclipse (and other IDE's) are better for code exploration and they probably have features that I'm not aware of since I don't use them. I figure, though, that with enough Emacs Lisp, Emacs can do anything those IDEs can do. If you really want those features, it's a question of if you want to spend the time achieving perfection in Emacs or getting real work done in another IDE. I choose perfection. ;)

Additional commentary:

Screencasts:

Install method: from source sudo apt-get install emacs

Useful packages:

My emacs config on github: http://github.com/saltycrane/emacs

History: 2001: Emacs/NEdit/UltraEdit, 2006: Eclipse, 2007: Emacs

Terminal

urxvt

9.19 +
screen

urxvt supports xft (anti-aliased) fonts, real transparency (not that I actually use transparency with Qtile), and fading (which I do use with Qtile) and it is much faster and lighter than gnome-terminal or konsole. screen allows me to switch terminal sessions without ugly tabs, attach to remote sessions, search through the scrollback buffer, and more. Update: urxvt also has embedded perl.

Install method: from source sudo apt-get install rxvt-unicode

Version Control System

Git

Switched from Subversion to Mercurial in June 2007. The merging in Mercurial is very nice and can be done without thinking. I do miss Subversion/Subclipse's revision history viewer, file compare, and ability to isolate files apart from changesets. Update 2010-04-05: See my comment below.

Update 2011-05: Switched my personal repos to Git. Use Git almost exclusively now.

Additional commentary:

Install method: sudo apt-get install mercurial

History: 2001: SCCS, 2003: Other, 2007: Subversion, 2007: Mercurial, 2010: Mercurial/Git, 2011: Git

"High-level" Language

None

Previously, I used C. Now I use don't use any statically-typed languague. Wouldn't mind learning C++ Go. Although, Linus doesn't like it.

"High-high-level" Language

Python 2.7

My love for Python is strong. I switched from Perl in 2005 and have no regrets. Object-oriented, easy to read (no more TIMTOWTDI), and smart people use it. I also want to learn Javascript 2 becuase it is the "Next Big Language" and Lisp because it is the "most powerful language".

On Python vs. Ruby: from what I've read, I characterize Ruby as the more expressive language more similar to Perl (than Python is) and Python as the more regimented language. Since I like regimented, I like Python.

On Python vs. Lisp: I've concluded that I lack the intelligence to harness enough of Lisp's power to counteract its non-practicality (e.g. lack of libraries).

Additional commentary:

Install method: preinstalled on Ubuntu

History: 2001: Perl, 2005: Python

Web Framework

Django / Flask

2014-10:I now use Flask at work. Previously, I used Django. I think I like SQLAlchemy and Jinja2 better than Django. Django has a lot more built in and is put together better. Flask's thread locals are convenient and messy. Probably Pyramid is the best but no one uses it.

Here are some links:

Install method: pip install Django / pip install Flask

Web Browser

Firefox

Not to be confused with Konqueror, Conkeror is an emacs-like, keyboard driven, scriptable, Mozilla-based web browser. I've used it almost full time since January 2008. It is still considered alpha stage software so there are a number of bugs. However, it is still pretty sweet. I use Firefox as a backup (and IE Tab for Launchcast and Netflix on Windows).

Unfortunately, one of the annoying things in Firefox 2 is present in Conkeror as well-- memory leaks. Based on this Mozilla article and some brief personal experience, Firefox 3 has made fixes in this area. It would be nice if Conkeror could benefit from the Firefox 3 fixes.

Update 2010-05-04: Conkeror is really awesome, but I had some memory/cpu issues with it a while ago and haven't put in the work to merge my custom keybindings with the latest Conkeror code. Also waiting to see if there will be an Emacs version of Vimium (since, after all vimperator followed conkeror).

I'm currently using a combination of Google Chrome and Firefox. Chrome is faster, especially for Javascript-intensive sites, but I really hate the Google Chrome Omnibar. If you have a solution or workaround, please post an answer. Firefox also has some Add-ons that Chrome doesn't.

Email

Gmail

Update 2010-05-04: Gmail. It's slow but it has a lot of features and it's in my web browser and it's easy and it works and I don't really like using email that much anyways. Oh, and, big plus, syncing works almost perfect with my Android phone. (Actual full switch to Gmail was around December 2008.)

Graphical diff/merge

KDiff3

I started using KDiff a while ago on Windows and have always liked it. I'm thinking, though, since I'm an Emacs person, I ought to use Ediff.

Install method: sudo apt-get install kdiff3

Keyboard

Unicomp Endurapro / Leopold Tenkeyless w/ Cherry MX Browns

I realize a keyboard is hardware and not software, but it is hardware that can evoke strong opinions, so I made an exception.

One problem with hardware is I can't try out all the different types and choose the one I like the best as I can with software. So my selection is based on reviews not on actual experience. And, after buying the Endurapro, I found I actually did not like the integrated mouse stick, so I should have bought a Customizer 104/105 and saved $30.

Update 2011-05: Got the Leopold tenkeyless for work. Tenkeyless is a must for quicker mouse access. And I actually like the lighter touch of the Cherry MX Browns versus the Unicomp's buckling springs. I like it so much I want to replace my Unicomp at home with another Leopold.

Update: Got a second Leopold for home to replace my Unicomp.

Additional commentary:

History: 2009: Unicomp Endurapro, 2011: Leopold Tenkeyless (MX Browns)

Office Chair

Undecided

Herman Miller Aeron or Steelcase Leap

Mobile Phone

Motorola Droid 4

After almost 10 years (and 3 generations) of the Palm Treo, I got the Motorola Droid.

The Droid is pretty awesome, but I don't like switching to landscape mode to use the keyboard-- especially when toolbars and headers take up half the screen. I think Palm and Blackberry got this form factor Right. Just as I prefer the keyboard over the mouse on my PC, I want to use the keyboard and D-pad over the touchscreen on my phone. Update 2010-05-04: The keyboard is mediocre and use of the D-pad center button sucks. My Palm Treo 650 D-pad worked much better.

My reasons for choosing an Android phone are: I need a physical keyboard. I want to hack on my phone. I think Android has more potential than Palm's webOS or Maemo.

Useful apps:

  • Connectbot Secure shell (SSH) client for the Android platform. Use this all the time. Awesome.
  • Listen Listen from Google Labs brings podcast search, subscribe, download and stream to your Android-powered device.
  • My Tracks Record GPS tracks. Monitor your performance. Share your outdoor activities with friends. Really enjoy this one. Love tracking my romping.

2010-05-04 Updates:

  • Google Voice: Free text messages and better voicemail. Another useful app. Makes voicemail suck a lot less.
  • FoxyRing: automatically control the ringer volume based on ambient noise level. I was doubtful about this one, but it actually works well for me.
  • Flixter (Movies): Useful for checking movie showtimes.
  • Bible (YouVersion): This version is pretty good. I miss my Plucker created Bible on my Palm though. I wish there was something like Plucker for Android.
  • DroidLight: use the LED camera flash as a flashlight. Simple and useful. Works much better than using the screen as a flashlight.
  • Google Navigation: I don't need my Garmin anymore. (Each has advantages and disadvantages, but I have found it to be a capable replacement.)
  • Just want to mention that the Calendar sucks. It is great that I can sync with my Google calendar, but I really hate the Android Calendar UI.

Additional Commentary/Links:

History: 2002: Handspring Treo 180, 2003: Handspring Treo 600, 2005: Palm Treo 650, 2009: Motorola Droid 2011: Motorola Droid 4

Cannot contact Wind Registry on host

tgtsvr error: Cannot contact Wind Registry on host

  • make sure the Wind Registry is running by looking for either the icon in the system tray or wtxreg.exe or wtxregd.exe in the Processes tab of your Windows Task Manager (CTRL+ALT+DEL, Task Manager).
  • even if it is running as a service, try restarting it. Control Panel, Administrative Tools, Services. Go to Tornado Registry and restart.
  • make sure your host and target are on the same network. from your host computer, open a cmd.exe prompt and "ping 123.34.123.123" (insert your IP address). if you don't get a response back, this is a problem.
  • Go to the "Tools" menu, "Options...", "Tornado Registry" tab (all the way to the right) and make sure your registry option is correct. I am using a "Local registry". Note that Tornado is messed up here-- I had my setting correct-- but just navigating to this tab, and pressing the "OK" button (without changing the setting) fixed the problem.