;;; Time-stamp: <2022-01-28 11:09:33 philip> ;; Note, this is just a less flexible implementation of registers. (defvar goto-alist `((?p . ,(format "/proj/i4passt/students/%s/" (user-login-name))) (?s . "/proj/i4sp2/") (?1 . "/proj/i4sp1/") (?2 . "/proj/i4sp2/") (?w . "~/www/")) "Alist of shortcuts. The car value is the key, the cdr is the path.") (defun goto (key) "Jump to a path using a single key. The shortcuts and paths are specified in the variable `goto-alist'." (interactive "cGoto (press ? for a overview): ") (if (eq key ??) (let ((buf (generate-new-buffer " *goto*"))) (with-current-buffer buf (dolist (sc goto-alist) (insert (format "%c\t%s\n" (car sc) (cdr sc)))) (special-mode)) (pop-to-buffer buf)) (let ((sc (assq key goto-alist))) (unless sc (error "No shortcut behind key \"%c\"" key)) (find-file (expand-file-name (cdr sc)))))) ;; Run to bind globally: ;; (global-set-key (kbd "C-x C-g") #'goto)