;;; -*- lexical-binding: t -*- ;; ;; -------------------------------------------------------------------------- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) ;; -------------------------------------------------------------------------- (-> 'll-file) (-> 'nnmail) ;; -------------------------------------------------------------------------- (defun do-show-file (file) (interactive "ffile: ") (let ((buf (current-buffer)) (dst (find-file-noselect file))) (if (eq buf dst) ($ "here already") (find-file file) (unless (buffer-modified-p) (revert-buffer 'ignore-auto 'noconfirm))))) (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 (@f "%s %s" key-prefix key)) (file (expand-file-name file file-prefix))) (keymap-global-set key (L () (do-show-file file))))) (defun shortcut-to-function (key-prefix key function) (keymap-global-set (@f "%s %s" key-prefix key) function)) (defun set-keys (ks &optional key path) (or key (setq key "")) (or path (setq path "")) ;; TODO: pcase-let* (let ((key (string-trim (@f "%s %s" key (1st ks)))) (path (format "%s%s" path (2nd ks))) (kps (3rd ks))) (dolist (kp kps) (if (= 2 (--- kp)) (if (functionp (2nd kp)) (shortcut-to-function key (1st kp) (2nd kp)) (shortcut-to-file key (1st kp) (2nd kp) path)) (set-keys kp key path))))) ;; -------------------------------------------------------------------------- (define-prefix-command 'C-j-prefix) (keymap-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' ;; ;; notes: ;; * keys are case sensitive, but "A" equals "a" when unset [TODO: verify] ;; * can be nested [hint: mnemonic] e.g., ;; C-j e w k -> (e)macs (w)3m (k)eys-> ~/.emacs.d/elisp/w3m/w3m-keys.el ;; * works for sudo and Tramp ("a" ".authinfo") ("." (lambda () (interactive) (dired-jump))) ; don't change, unlucky lisp ("B" "public_html/books/" ( ("." ".") ("b" "books.bib") ("l" "books.tex") ("m" "Makefile") )) ("s" "src/bad-6/bad-studio.el") ("b" "src/bad-6" ( ("." ".") ("r" ".") ("A" "bad-align.el") ("a" "bad-ascii.el") ("b" "bad-box.el") ("B" "bad-borderless.el") ("d" "bad-draw.el") ("C" "~/public_html/bad-el/bad-el.css") ("c" "bad-color.el") ("e" "bad-elem.el") ("f" "bad-font.el") ("g" "bad-game.el") ("i" "~/public_html/bad-el/index.html") ("l" "bad.el") ("m" "bad-mode.el") ("p" "bad-pos.el") ("P" "bad-program.el") ("S" "bad-size.el") ("s" "bad-studio.el") ("w" "bad-write.el") ("x" "bad-box.el") )) ("n" "~/.cwmrc") ("w" "~/.cwmrc") ("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") ("k" ".config/kitty/kitty.conf") ("K" "/etc/console-setup/remap.inc") ("L" "public_html/HYPERLIST") ("M" ,mail-personal-alias-file) ("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") ("l" "HYPERLIST") ("m" "../moas/" ( ("." ".") ("c" "moas.css") ("m" "index.html") ("i" "index.html") )) ("s" "style.css") )) ("T" "~/.tmux.conf") ("x" "./" ( ("k" ".xbindkeysrc") ("p" ".xpdfrc") ("t" ".tmux") ("x" ".xinitrc") ("X" ".Xresources") )) ("z" ".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/emacs-init/ll/" ( ("." ".") (";" "~/.emacs") ("a" "ll-abc.el") ("A" "ll-align.el") ("B" "ll-buffer-menu.el") ("d" "ll-dired.el") ("e" "ll-edit.el") ("f" "ll-face.el") ("F" "ll-face.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" "ll-keys.el") ("K" "kill.el") ("l" "latex.el") ("L" "linux-shell.el") ("M" "Makefile") ("m" "man-incal.el") ("N" "native.el") ("n" "ll-navigate.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" "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") ("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" "ll-x.el") ("z" "ide/find-command.el") )) ("E" ".emacs.d/") ("G" "public_html/GATOR") ))) ;; -------------------------------------------------------------------------- (<- 'll-navigate)