;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/navigate-fs-keys.el (require 'file-incal) (require 'nnmail) (require 'sudo-user-path) (require 'super) (require 'w3m-bookmark) (defun do-show-file (file) (interactive "ffile: ") (let ((buf (current-buffer)) (dst (find-file-noselect file) )) (if (eq buf dst) (message "here already") (find-file file) (unless (buffer-modified-p) (revert-buffer t t nil) )))) (defun shortcut-to-file (key-prefix key file &optional file-prefix) "Make shortcut with key KEY-PREFIX KEY to FILE-PREFIX FILE." (or file-prefix (setq file-prefix "~")) (let*((key (format "%s %s" key-prefix key)) (file (expand-file-name file file-prefix))) (keymap-global-set key (lambda () (interactive) (do-show-file file) )))) (defun shortcut-to-function (key-prefix key function) (keymap-global-set (format "%s %s" key-prefix key) function) ) (defun set-keys (ks &optional key path) (or key (setq key "")) (or path (setq path "")) (let ((key (string-trim (format "%s %s" key (car ks)))) (path (format "%s%s" path (cadr ks))) (kps (caddr ks))) (dolist (kp kps) (if (= 2 (length kp)) (if (functionp (cadr kp)) (shortcut-to-function key (car kp) (cadr kp)) (shortcut-to-file key (car kp) (cadr kp) path) ) (set-keys kp key path) )))) (define-prefix-command 'C-j-prefix) (super-global-set "C-j" 'C-j-prefix) (set-keys `("C-j" ; key "~/" ; base path ( ;; syntax: ;; ;; ("key" "/absolute/path") - OK ;; ("key" "relative/path") - OK ;; ("key" function) - OK, interactive lambda only ;; ("key" ,variable) - OK, first `require' ;; ;; * keys are case sensitive but "A" equals "a" when unset ;; ;; * path syntax works, e.g., ~ and /sudo:user@host:/path ;; (for sudo, see `sudo-user-path') ;; ;; * can be nested - hint, make them mnemonic, ;; especially for non-everyday shortcuts, e.g., ;; C-j e w k -> (e)macs (w)3m (k)eys ;; -> ~/.emacs.d/emacs-init/w3m/w3m-keys.el ;; ;; * and works for Tramp as well ("a" ".authinfo") ("." (lambda () (interactive) (dired-jump))) ("A" ,(sudo-root-path "/etc/apt/sources.list")) ("B" "public_html/books/" ( ("." ".") ("b" "books.bib") ("l" "books.tex") ("m" "Makefile") )) ("b" "public_html/bad" ( ("." ".") ("b" ".") (";" "../../game") )) ("g" "cl/general-base" ( ("." ".") ("g" "gb.lisp") )) ("2" "common-lisp/2d-demo" ( ("." ".") ("2" "2d-demo.lisp") ("d" "2d-demo.lisp") ("r" "rect.lisp") ("R" "run") )) ("w" "~/.cwmrc") ("S" "~/public_html/SOFTWARE") ("s" "~/public_html/conf/.zsh/swamp") ("m" ".config/mpv" ( ("." ".") ("c" "mpv.conf") ("i" "input.conf") ("l" "mpv.log") ("m" ".") ("M" "MM") )) ("r" "terror/terror-3" ( ("." ".") ("" ".") ("C" "ev3-color-stop-on-color.el") ("c" "ev3-control.el") ("d" "ev3-demo.el") ("g" "~/.joy2keyrc") ("i" "ev3-motor-init.el") ("m" "ev3-motor.el") ("M" "Makefile") ("p" "ev3-ir-prox-stop.el") ("r" "README") ("t" "ev3-touch.el") ) ) ("v" "public_html/about/cv/cv.txt") ("d" "data") ("D" "public_html/DOS") ("f" "public_html/conf/feh/keys") ("F" "public_html/FILM") ("j" "public_html/jsn" ( ("." ".") ("w" "world.el") )) ("J" "jargon/JARGON-4.4.7") ("I" "public_html/TRACK") ("K" "/etc/console-setup/remap.inc") ("k" ,(sudo-root-path "/etc/default/console-setup")) ("l" (lambda () (interactive) (switch-to-buffer (slime-repl-buffer)))) ("L" "public_html/HYPERLIST") ("M" ,mail-personal-alias-file) ("n" "ny" (("." ".") ; Nyquist ("E" "~/src/nyquist-3.12+ds/demos/src/examples.lsp") ("e" "~/.emacs.d/emacs-init/ny.el") ("i" "init-incal.lsp") ("l" "init-incal.lsp") ("n" (lambda () (interactive) (ny) )) )) ("p" "public_html/sek.el") ("h" "public_html/" ( ("." ".") ("A" "~/kb/kb-full-group.conf") ("a" "~/public_html/conf/.zsh/led-kb") ("b" "BIRDS") ("c" "style.css") ("e" "emacs.html") ("f" "conf/feh/keys") ("g" "gnus/index.html") ("h" "/-:incal@srv.dataswamp.org:public_html/COMP-HIST") ("i" "/-:incal@srv.dataswamp.org:public_html/index.html") ("l" "HYPERLIST") ("m" "../moas/" ( ("." ".") ("c" "moas.css") ("m" "index.html") ("i" "index.html") )) ("s" "style.css") )) ("i" ".irssi/" ( ("." ".") ("" ".") ("c" "config") ) ) ("T" "~/.tmux.conf") ("t" (lambda () (interactive) (todo-show-file))) ("x" "./" ( ("k" ".xbindkeysrc") ("p" ".xpdfrc") ("t" ".tmux") ("x" ".xinitrc") ("X" ".Xresources") )) ("z" "public_html/conf/.zsh/" ( ("." ".") (";" "~/.zshrc") ("" ".") ("a" "apt") ("A" "audio") ("b" "bike") ("c" "caps") ("C" "cid") ("D" "dl") ("d" "dl") ("e" "error") ("E" "~/.zshenv") ("F" "files-edit") ("f" "files-fs") ("g" "git") ("G" "gfx") ("h" "hw") ("I" "ice") ("i" "ide") ("j" "navigate-fs") ("L" "latex") ("l" "ls") ("M" "map") ("m" "mpv") ("n" "navigate-fs") ("N" "net") ("P" "pdf") ("p" "~/.zprofile") ("r" "remote") ("s" "swamp") ("S" "~/swamp/.zshrc") ("u" "mount") ("U" "url") ("V" "volume") ("v" "vt") ("w" "web") ("W" "wifi") ("x" "x") ("z" "zip") )) ("E" ".emacs.d/") ("e" ".emacs.d/emacs-init/" ( ("." ".") (";" "~/.emacs") ("" ".") ("A" "align-incal.el") ("a" "~/.emacs.d/lisp/abbrev.el") ("B" "buffer-menu.el") ("b" "bibtex/") ("c" "caps-back.el") ("C" "console-keys.el") ("d" "dired-incal.el") ("e" "edit.el") ("E" "erc/" (("." "."))) ("F" "face.el") ("f" "file-incal.el") ("G" "buc.el") ("g" "gnus/" ( ("." ".") ("" ".") (";" "gnus-incal.el") ("a" "article.el") ("b" "browse.el") ("c" "gnus-cite-incal.el") ("f" "gnus-faces.el") ("g" "gnus-incal.el") ("h" "../geh.el") ("G" "group.el") ("i" "/usr/share/info/emacs-24/gnus.info") ("l" "mail-to-many.el") ("m" "mail.el") ("M" "message-incal.el") ("n" ,nnmail-message-id-cache-file) ("o" "moggle.el") ("p" "~/.emacs.d/passwords.el") ("S" "gnus-server.el") ("s" "summary.el") )) ("h" "help-incal.el") ("H" "geh.el") ("i" "ide/" ( ("." ".") (";" "ide.el") ("" ".") ("C" "c-and-cpp.el") ("c" "compile-incal.el") ("e" "elisp.el") ("f" "find-command.el") ("h" "html.el") ("i" "ide.el") ("l" "lisp-incal.el") ("s" "slime-incal.el") ("z" "find-command.el") )) ("k" "global-keys.el") ("K" "kill.el") ("l" "latex.el") ("L" "linux-shell.el") ("M" "Makefile") ("m" "man-incal.el") ("N" "native.el") ("n" "navigate-fs-keys.el") ("O" "../lisp/erc-robot.el") ("o" "bot.el") ("P" "elpa.el") ("p" "~/public_html/emacs-packs") ("q" "quit.el") ("R" "~/.emacs.d/emacs-init/search-regexp-in-files.el") ("s" "sort-incal.el") ;; ("s" "ide/slime-incal.el") ("S" "spell.el") ("T" "time-incal.el") ("t" "todo-did.el") ("v" "vt.el") ("V" "window-incal.el") ("W" "wrap-search.el") ("y" "yank.el") ("w" "w3m/" ( ("." ".") ("" ".") ("b" "bookmarks.el") ("B" ,w3m-bookmark-file) ("d" "w3m-download.el") ("k" "w3m-keys.el") ("s" "w3m-unisearch.el") ("S" "w3m-survivor.el") ("t" "w3m-tabs.el") ("w" "w3m-incal.el") )) ("x" "xsel.el") ("z" "ide/find-command.el") )) ("G" "public_html/GATOR") ;; ("g" "public_html/guns/" ( ;; ("." ".") ;; ("b" "guns.bib") ;; ("g" "guns.tex") ;; ("l" "guns.tex") ;; ("m" "Makefile") ;; ("M" "Makefile") ;; )) ("u" "~/public_html/cnc/sign.tap") ("U" "URL") ;; ("U" ,(sudo-root-path "/usr/lib/systemd/system/getty@.service")) ))) (provide 'navigate-fs-keys)