3

I have a frequently opened file in Emacs, which is deep inside my device. I want to bind the F5 key(or any other key) to open that file, how can I do that? (Using android to run emacs. [GNURoot, Wheezy. ])

Drew
  • 75,699
  • 9
  • 109
  • 225
Joshua Lilleberg
  • 371
  • 1
  • 2
  • 5
  • 3
    Try [File Register](http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Registers.html) – xuchunyang May 11 '15 at 10:30
  • 5
    Not a single keybinding, but [bookmarks](https://www.gnu.org/software/emacs/manual/html_node/emacs/Bookmarks.html) are also useful. – giordano May 11 '15 at 10:51
  • 1
    Here are four (4) options in the link to the following thread entitled **How can I open quickly a file in emacs?** -- http://stackoverflow.com/a/19284395/2112489 – lawlist May 12 '15 at 07:23

3 Answers3

3

Try bookmarks.

  • visit the file
  • add a bookmark to it with C-x r m or by running bookmark-set
  • jump to the bookmark at any time with C-x r b (M-x bookmark-jump) or display a list of all your bookmarks with C-x r l (M-x bookmark-bmenu-list)

You can, of course, also bind F5 (or any other key) to a function that calls bookmark-jump with a given bookmark name.

2

One way of doing could be:

;; quickly open some files
(global-set-key (kbd "<f6> h") (lambda () (interactive) (find-file "~/.emacs.d/lisp/init_hooks.el")))

Another way of doing:

(require 'ido) ; part of emacs

(defvar xah-filelist nil "alist for files i need to open frequently. Key is a short abbrev string, Value is file path string.")

(setq xah-filelist
      '(
        ("3emacs" . "~/web/ergoemacs_org/emacs/blog.html" )
        ("4code" . "~/web/xahlee_info/comp/blog.html" )
        ("keys" . "~/git/xah_emacs_init/xah_emacs_keybinding.el" )
        ("download" . "~/Downloads/" )
        ("pictures" . "~/Pictures/" )
        ;; more here
        ) )

(defun xah-open-file-fast ()
  "Prompt to open a file from `xah-filelist'.
URL `http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html'
Version 2015-04-23"
  (interactive)
  (let ((ξabbrevCode
         (ido-completing-read "Open:" (mapcar (lambda (ξx) (car ξx)) xah-filelist))))
    (find-file (cdr (assoc ξabbrevCode xah-filelist)))))

Courtesy of ErgoEmacs

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
Nsukami _
  • 6,341
  • 2
  • 22
  • 35
0

I'm using bookmarks for this purpose, together with the headlong package (to select the bookmark much faster). See my blog post.

One cool feature that I recently added to my config is ido-use-virtual-buffers / ivy-use-virtual-buffers: if you set them to t, then ido-switch-buffer / ivy-switch-buffer will actually use all your bookmarks.

abo-abo
  • 13,943
  • 1
  • 29
  • 43