emacs: open your own files FAST

Perm URL with updates: http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html

Here's command that lets you open file fast, by typing a letter or digit:

(defvar xah-filelist nil "alist for files i need to open frequently. Key is a short abbrev, Value is file path.")
(setq xah-filelist
        ("3emacs" . "~/web/ergoemacs_org/emacs/blog.html" )
        ("4code" . "~/web/xahlee_info/comp/blog.html" )
        ("js" . "~/web/xahlee_info/js/blog.html" )
        ("math" . "~/web/xahlee_info/math/blog.html" )
        ("linguistics" . "~/web/wordyenglish_com/lit/blog.html" )
        ("chinese" . "~/web/wordyenglish_com/chinese/blog.html" )
        ("music" . "~/web/xahmusic_org/music/blog.html" )
        ("arts" . "~/web/xaharts_org/arts/blog.html" )
        ("sl" . "~/web/xahsl_org/sl/blog.html" )
        ("keys" . "~/git/xah_emacs_init/xah_emacs_keybinding.el" )
        ("ahk" . "~/git/xah_autohotkey_scripts/xah autohotkeys.ahk" )
        ("download" . "~/Downloads/" )
        ) )

(defun xah-open-file-fast (openCode)
  "Prompt to open a file from a pre-defined set."
   (list (ido-completing-read "Open:" (mapcar (lambda (x) (car x)) xah-filelist)))
  (find-file (cdr (assoc openCode xah-filelist)) ) )

When called, it will prompt in the same way as ido-mode, with automatic name completion.

You type a key, then press Enter ↵, then the file will be opened.

You need to modify the file path for your own use. You can also easily modify the code above so that one letter opens several files at once, such as a coding project.

Note: You should also use the following:

All the above requires eyeball. That is, spending half a second to look at the screen and make a choice.

The purpose of “xah-open-file-fast” is that you never need to look at the screen, just muscle memory, but you may want to be sure that the first chars of your file name abbrevs are all unique.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs