;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/navigate-fs-keys.el (require 'cl-lib) (require 'count) (require 'file) (require 'nnmail) (require 'sudo-user-path) (require 'super) (require 'w3m-bookmark) (defun do-show-file (file) (interactive "ffile: ") (let ((this-buffer (current-buffer)) (target-buffer (find-file-noselect file) )) (if (eq this-buffer target-buffer) (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." (let*((key (format "%s%s" key-prefix key)) (file-dir (or file-prefix "~")) (file (expand-file-name file file-dir))) (global-set-key key (lambda () (interactive) (do-show-file file) )))) (defun shortcut-to-function (key-prefix key function) (global-set-key (format "%s%s" key-prefix key) function) ) (defun set-keys (ks &optional key path) (let ((key (format "%s%s" (or key "") (car ks))) (the-path (format "%s%s" (or 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) the-path) ) (set-keys kp key the-path) )))) (define-prefix-command 'C-j-prefix) (super-global-set-key "\C-j" 'C-j-prefix) (set-keys `("\C-j" ; invocation 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" "bike" ( ("." ".") ("a" "adv") ("b" ".") ("c" "CHAIN") ("T" "adv/TOUR") ("t" "TIRE") )) ("g" "cl/general-base" ( ("." ".") ("g" "gb.lisp") ("v" "~/mm/girls/vids/play") )) ;; ("G" "borta" ( ;; ("." ".") ;; ("g" "~/public_html/GATOR") ; BUG ? ;; ("t" "borta-txt/borta.md") ;; ("b" "borta.bib") ;; ("l" "borta.tex") ;; ("m" "Makefile") ;; ("o" "parts.txt") ;; ("p" "parts.txt") )) ("C" "public_html/2020/computer-chronicles-comments.txt") ("c" "~/scad/metal-shelf/metal-shelf.scad") ("w" "~/.cwmrc") ("S" "~/public_html/SOFTWARE") ("s" "~/public_html/conf/.zsh/swamp") ("m" ".config/mpv") ("r" "terror/terror-3" ( ("." ".") ("\r" ".") ("m" "Makefile") ("r" "README") ("z" "/-:incal@ev3dev:.zshrc") ) ) ("v" "public_html/about/cv/cv.txt") ("d" "data") ("D" "public_html/DOS") ("f" "public_html/conf/feh/keys") ("F" "public_html/FILM") ;; ("S" (lambda () ;; (interactive) ;; (unless (switch-to-slime-buffer) ;; (find-file "/-:incal@srv.dataswamp.org:public_html/sth/sth.py") ))) ("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" "~/blog") ("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) )) )) ("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/" ( ("." ".") ("\r" ".") ("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") ("\r" ".") ("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" "gfx") ("h" "hw") ("I" "ice") ("i" "ide") ("j" "navigate-fs") ("L" "latex") ("l" "ls") ("M" "map") ("m" "mpv") ("n" "navigate-fs") ("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") ("\r" ".") ("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.el") ("G" "buc.el") ("g" "gnus/" ( ("." ".") ("\r" ".") (";" "gnus-incal.el") ("a" "article.el") ("b" "browse.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") ("\r" ".") ("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") ("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" "ny.el") ("n" "navigate-fs-keys.el") ("O" "../lisp/erc-robot.el") ("o" "bot.el") ("P" "elpa.el") ("p" "printer.el") ("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/" ( ("." ".") ("\r" ".") ("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")) ))) ;; (defun sth () ;; (interactive) ;; (find-file "/-:incal@srv.dataswamp.org:public_html/sth/sth.py") )