#+property: header-args :lexical t :tangle yes :comments yes :results silent :shebang ";; -*- lexical-binding: t -*-" :tangle-mode (identity #o644) #+auto_tangle: t * Packages *** Use package #+begin_src emacs-lisp (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (require 'use-package) #+end_src *** ELPA Keyring #+begin_src emacs-lisp (use-package gnu-elpa-keyring-update :ensure t) #+end_src *** Loading .el newer than .elc files, and eln stuff #+begin_src emacs-lisp (setq load-prefer-newer t) (setq comp-async-report-warnings-errors nil warning-suppress-types '((comp))) #+end_src * Initialisation *** Portability macros #+begin_src emacs-lisp (defmacro jao-syscase (clauses) (let ((cls (assoc system-type clauses))) (when cls `(progn ,@(cdr cls))))) (defmacro jao-d-l (darw linux) `(jao-syscase ((darwin ,darw) (gnu/linux ,linux)))) (defmacro jao-when-darwin (&rest body) `(jao-syscase ((darwin ,@body)))) (defmacro jao-when-linux (&rest body) `(jao-syscase ((gnu/linux ,@body)))) #+end_src *** Paths #+begin_src emacs-lisp (defvar jao-local-lisp-dir "~/lib/elisp" "Directory for external elisp libraries and repos") (defvar jao-data-dir (expand-file-name "data" jao-emacs-dir) "Directory containing static data, such as images.") (defun jao-data-file (file) (expand-file-name file jao-data-dir)) (defvar jao-org-dir (expand-file-name "~/org")) (defvar jao-sink-dir (file-name-as-directory (expand-file-name "~/doc/sink")) "Directory used for downloads and such.") (defvar jao-site-dir (expand-file-name "site" jao-emacs-dir)) (defun jao-site-el (basename &optional gpg) (expand-file-name (concat basename ".el" (when gpg ".gpg")) jao-site-dir)) (defun jao-load-site-el (basename &optional gpg) (let ((lf (jao-site-el basename gpg))) (if (file-exists-p lf) (load lf) (message "Attempted to load non existing %s" lf)))) (defun jao-exec-path (file) (let ((fn (expand-file-name file))) (add-to-list 'exec-path fn nil) (setenv "PATH" (concat fn ":" (getenv "PATH"))))) (defun jao-load-path (subdir) "Add to load path a subdir of `jao-local-lisp-dir'" (let ((path (expand-file-name subdir jao-local-lisp-dir))) (when (file-directory-p path) (add-to-list 'load-path path)))) #+end_src *** Load and info path initialisation #+begin_src emacs-lisp (add-to-list 'load-path jao-site-dir) (add-to-list 'load-path jao-local-lisp-dir) (let ((libd (expand-file-name "lib" jao-emacs-dir))) (add-to-list 'load-path libd) (dolist (f (directory-files libd t "^[^.]+$")) (when (file-directory-p f) (add-to-list 'load-path f)))) (defvar jao-info-dir (expand-file-name (jao-d-l "~/.emacs.d/info" "~/doc/info"))) (require 'info) (add-to-list 'Info-directory-list jao-info-dir) #+end_src *** Custom location of custom.el and co. #+begin_src emacs-lisp (setq custom-file (jao-site-el "custom")) ;; (load custom-file) (setq custom-unlispify-tag-names nil) (setq custom-buffer-done-kill t) (setq custom-raised-buttons nil) #+end_src *** Preamble (pre.el) #+begin_src emacs-lisp (jao-load-site-el "pre") #+end_src *** Session and history #+BEGIN_SRC emacs-lisp (setq backup-directory-alist (quote (("." . "~/.emacs.d/backups")))) (setq delete-old-versions t kept-new-versions 3 kept-old-versions 2) (require 'saveplace) (setq save-place-file (expand-file-name "~/.emacs.d/cache/places")) (save-place-mode 1) (setq recentf-save-file (expand-file-name "~/.emacs.d/cache/recentf") recentf-max-saved-items 2000 recentf-exclude '("/home/jao/\\.emacs\\.d/elpa.*/.*" ".*/.git/COMMIT_EDITMSG")) (require 'recentf) (recentf-mode 1) ;; Command history (setq savehist-file (expand-file-name "~/.emacs.d/cache/history")) (require 'savehist) (savehist-mode t) (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring) savehist-ignored-variables '(ido-file-history)) #+END_SRC *** yes/no, bell, startup message #+BEGIN_SRC emacs-lisp ;;; change yes/no for y/n (if (version< emacs-version "28") (fset 'yes-or-no-p 'y-or-n-p) (setq use-short-answers t)) (setq inhibit-startup-message t) (setq visible-bell t) #+END_SRC *** Server #+BEGIN_SRC emacs-lisp (setenv "EDITOR" "emacsclient") (when (not (daemonp)) (server-start)) #+END_SRC * System utilities *** Tramp #+begin_src emacs-lisp (setq tramp-mode nil) #+end_src *** Sleep/awake #+begin_src emacs-lisp (use-package jao-sleep) (jao-sleep-dbus-register) #+end_src *** Process runners #+begin_src emacs-lisp (defun jao-exec-string (fmt &rest args) (string-trim (shell-command-to-string (apply 'format fmt args)))) (defun jao-exec (command) (interactive (list (read-shell-command "$ " (if current-prefix-arg (cons (concat " " (buffer-file-name)) 0) "")))) (start-process-shell-command command nil command)) (defmacro jao-def-exec (name &rest args) `(defun ,name (&rest other-args) (interactive) (start-process-shell-command ,(car args) "* jao-exec - console *" (string-join (append (list ,@args) other-args) " ")))) #+end_src *** App launcher #+begin_src emacs-lisp (jao-load-path "app-launcher") (use-package app-launcher :bind (("s-r" . app-launcher-run-app) ("H-s-r" . app-launcher-run-app))) #+end_src *** Brightness control #+begin_src emacs-lisp (jao-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+") (jao-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-") (defun jao-bright-show () (interactive) (message "%s" (thread-first (jao-exec-string "brightnessctl") (split-string "\n") (cadr) (string-trim)))) (defun jao-bright-up () (interactive) (jao-exec-string "brightnessctl -q s %%5+") (jao-bright-show)) (defun jao-bright-down () (interactive) (jao-exec-string "brightnessctl -q s %%5-") (jao-bright-show)) #+end_src *** Keyboard and hydra #+begin_src emacs-lisp (use-package repeat :config (setq repeat-echo-function #'repeat-echo-mode-line)) (when (> emacs-major-version 27) (repeat-mode)) (use-package hydra :ensure t) (use-package major-mode-hydra :ensure t :custom (major-mode-hydra-invisible-quit-key "q") :bind (("s-SPC" . major-mode-hydra) ("H-s-SPC" . major-mode-hydra) ("C-s-SPC" . major-mode-hydra))) (require 'major-mode-hydra) (defun jao-kb-toggle (&optional lyt) (interactive) (shell-command-to-string (or lyt (if (jao-kb-toggled-p) "setxkbmap us" "setxkbmap us -variant intl")))) (defun jao-kb-toggled-p () (not (string-empty-p (shell-command-to-string "setxkbmap -query|grep variant")))) (set-keyboard-coding-system 'latin-1) (set-language-environment "UTF-8") ;; must be set after current-language-environment (customize-set-variable 'default-input-method "catalan-prefix") (defun jao--set-kb-system (frame) (select-frame frame) (set-keyboard-coding-system 'latin-1) t) (add-to-list 'after-make-frame-functions 'jao--set-kb-system) (setq echo-keystrokes 1 suggest-key-bindings nil) #+end_src * Crypto *** PGP, EPG, passwords #+begin_src emacs-lisp (setq epg-pinentry-mode 'loopback) (setq auth-source-debug nil) (require 'auth-source) (add-to-list 'auth-source-protocols '(local "local")) (setq auth-sources '("~/.emacs.d/authinfo.gpg" "~/.netrc")) (use-package epa-file :init (setq epa-file-cache-passphrase-for-symmetric-encryption t) :config (epa-file-enable)) (require 'epa-file) (defun jao--get-user/password (h) (let ((item (car (auth-source-search :type 'netrc :host h :max 1)))) (when item (let ((user (plist-get item :user)) (pwd (plist-get item :secret))) (list user (when pwd (funcall pwd))))))) #+end_src *** Pinentry #+begin_src emacs-lisp (use-package pinentry :ensure t) (pinentry-start) #+end_src * Fonts and colour themes *** Transparency #+begin_src emacs-lisp (defvar jao-frames-default-alpha (if (eq window-system 'pgtk) 100 90)) (defvar jao-transparent-p t) (defun jao-sway-set-transparency (level) (when jao-sway-enabled-p (let ((alpha (/ level 100.0))) (jao-swaymsg (format "[app_id=emacs] opacity %s" alpha))))) (defun jao-toggle-transparency (&optional all) (interactive "P") (setq jao-transparent-p (not jao-transparent-p)) (cond (jao-sway-enabled-p (jao-sway-set-transparency (if jao-transparent-p 90 100))) (all (let* ((trans (/= jao-frames-default-alpha 100)) (new-alpha (if trans 100 jao-frames-default-alpha)) (a `((alpha . (,new-alpha ,new-alpha))))) (modify-all-frames-parameters a))) ((/= (or (cadr (frame-parameter nil 'alpha)) 100) 100) (set-frame-parameter nil 'alpha '(100 100))) (t (set-frame-parameter nil 'alpha `(,jao-frames-default-alpha ,jao-frames-default-alpha))))) (defun jao-transparent-p () (if jao-sway-enabled-p jao-transparent-p (/= (or (cadr (frame-parameter nil 'alpha)) 100) 100))) (defun jao-set-transparency (level) (interactive "nOpacity (0-100): ") (let ((level (or level jao-frames-default-alpha))) (setq jao-transparent-p (< level 100)) (if jao-sway-enabled-p (jao-sway-set-transparency level) (set-frame-parameter nil 'alpha (list level level))))) #+end_src *** Fonts ***** Unicode fonts See [[https://emacs.stackexchange.com/questions/251/line-height-with-unicode-characters/5386#5386][fonts - Line height with unicode characters]] for a good discussion. #+begin_src emacs-lisp (defun jao--set-fontsets (frame) (set-fontset-font t 64257 "Quivira") (set-fontset-font t 'egyptian "Noto Sans Egyptian Hieroglyphs") (set-fontset-font t 'hangul "NanumGothicCoding") (set-fontset-font t 'unicode (face-attribute 'default :family)) (set-fontset-font t 'unicode-bmp (face-attribute 'default :family)) (set-fontset-font t 'symbol "Symbola-10") (set-fontset-font t 'greek "GFS Didot") (set-fontset-font t 'mathematical "FreeSerif") ;; boxes (set-fontset-font t '(9472 . 9599) "Source Code Pro") ;; variation selector-16 (set-fontset-font t 65039 "BabelStone Modern-1")) (jao--set-fontsets nil) (add-to-list 'after-make-frame-functions 'jao--set-fontsets) #+end_src ***** nobreak char display #+begin_src emacs-lisp (setq nobreak-char-display nil) #+end_src ***** list-fonts-display #+begin_src emacs-lisp (defun list-fonts-display (&optional matching) "Display a list of font-families available via font-config, in a new buffer. If the optional argument MATCHING is non-nil, only font families matching that regexp are displayed; interactively, a prefix argument will prompt for the regexp. The name of each font family is displayed using that family, as well as in the default font (to handle the case where a font cannot be used to display its own name)." (interactive (list (and current-prefix-arg (read-string "Display font families matching regexp: ")))) (let (families) (with-temp-buffer (shell-command "fc-list : family" t) (goto-char (point-min)) (while (not (eobp)) (let ((fam (buffer-substring (line-beginning-position) (line-end-position)))) (when (or (null matching) (string-match matching fam)) (push fam families))) (forward-line))) (setq families (sort families (lambda (x y) (string-lessp (downcase x) (downcase y))))) (let ((buf (get-buffer-create "*Font Families*"))) (with-current-buffer buf (erase-buffer) (dolist (family families) ;; We need to pick one of the comma-separated names to ;; actually use the font; choose the longest one because some ;; fonts have ambiguous general names as well as specific ;; ones. (let ((family-name (car (sort (split-string family ",") (lambda (x y) (> (length x) (length y)))))) (nice-family (replace-regexp-in-string "," ", " family))) (insert (concat (propertize nice-family 'face (list :family family-name)) " (" nice-family ")")) (newline))) (goto-char (point-min))) (display-buffer buf)))) #+end_src *** Themes #+begin_src emacs-lisp (defun jao-colors-scheme-dark-p () (equal "dark" (getenv "JAO_COLOR_SCHEME"))) (setq custom-theme-directory (expand-file-name "lib/themes" jao-emacs-dir)) (defvar jao-default-font "Hack-9") ;; "Fira Code-9" (require 'jao-themes) (defun jao-themes-setup () (let ((dark (jao-colors-scheme-dark-p))) (load-theme (if dark 'jao-dark 'jao-light) t))) (when (and window-system (not (eq window-system 'pgtk))) (jao-themes-setup)) (global-font-lock-mode 1) #+end_src * Help system *** Help buffers #+begin_src emacs-lisp (setq help-window-select t) #+end_src *** Bookmarks #+BEGIN_SRC emacs-lisp (setq bookmark-default-file "~/.emacs.d/emacs.bmk" bookmark-fontify nil) #+END_SRC *** Man pages #+begin_src emacs-lisp (setq Man-notify-method 'aggressive) ;; pushy - same window #+end_src *** Recoll #+begin_src emacs-lisp (use-package jao-recoll) #+end_src * Window manager helpers *** exwm To start emacs in an exwm session we use the flag ~-f jao-exwm-enable~, which calls the function below enabling it. This function, in turn, loads exwm's configuration from [[./exwm.org][exwm.org]]. #+begin_src emacs-lisp (defvar jao-exwm-enabled-p nil) (defun jao-exwm-enable () (jao-load-org "exwm.org") (setq jao-exwm-enabled-p t) (display-time-mode -1) ;; (jao-ednc-setup 95) (exwm-enable) (jao-minibuffer-adjust-mode-line-faces) (jao-trisect t) (message "Welcome to exwm")) #+end_src *** sway When starting emacs inside a sway session, we use ~-f jao-sway-enable~ and don't load any separate configuration file. #+begin_src emacs-lisp (defun jao-swaymsg (msg) (shell-command (format "swaymsg '%s' >/dev/null" msg))) (defmacro jao-def-swaymsg (name msg) `(defun ,(intern (format "jao-sway-%s" name)) () (interactive) (jao-swaymsg ,msg))) (jao-def-swaymsg firefox "[app_id=firefox] focus") (defvar jao-sway-enabled-p nil) (defun jao-sway-set-wallpaper (f) (jao-swaymsg (format "output * bg %s fill" f)) (make-symbolic-link f "~/.wallpaper.sway" t)) (defun jao-sway-run-or-focus (cmd &optional ws) (if (not (string-blank-p (shell-command-to-string (format "pidof %s" cmd)))) (jao-swaymsg (format "[app_id=%s] focus" cmd)) (jao-swaymsg (format "workspace %s" (or ws 2))) (start-process-shell-command cmd nil cmd))) (defun jao-sway-enable () (setq jao-sway-enabled-p t) (setq jao-browse-doc-use-emacs-p t) (setq jao-minibuffer-right-margin 1) (jao-toggle-inactive-mode-line t) (jao-trisect) (jao-set-transparency 92) (jao-themes-setup) (message "Welcome to sway")) #+end_src *** Wallpaper #+begin_src emacs-lisp (defvar jao-wallpaper-dir "~/.wallpapers/") (defvar jao-wallpaper-random-candidates '("wallpaper.jpg" "wallpaper2.jpg")) (defvar jao-wallpaper-random-candidates-light '("wallpaper.jpg" "wallpaper2.jpg")) (defvar jao-wallpaper-random-wake t "Set to t for getting a new wallpaper on awaking from sleep") (defun jao-set-wallpaper (&optional path) (interactive) (let ((current (format "~/.wallpaper.%s" (if (jao-colors-scheme-dark-p) "dark" "light")))) (when-let ((f (or path (read-file-name "Image: " jao-wallpaper-dir (file-symlink-p current) t)))) (make-symbolic-link (expand-file-name f) current t) (if jao-sway-enabled-p (jao-sway-set-wallpaper (expand-file-name f)) (shell-command (format "xwallpaper --zoom %s" f)))))) (defun jao-set-random-wallpaper () (interactive) (when jao-wallpaper-random-wake (let* ((ws (if (jao-colors-scheme-dark-p) jao-wallpaper-random-candidates jao-wallpaper-random-candidates-light)) (f (seq-random-elt ws))) (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir)) (message "%s" f)))) (add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper) #+end_src *** Screensaver and lock #+begin_src emacs-lisp (defun jao-screensaver-enabled () (string= (jao-exec-string "xdg-screensaver status") "enabled")) (defun jao-screensaver-toggle () (interactive) (let ((wid (jao-exec-string "xdotool getwindowfocus"))) (if (jao-screensaver-enabled) (jao-exec-string "xdg-screensaver suspend %s" wid) (jao-exec-string "xdg-screensaver resume %s" wid)) (jao-notify (format "Using '%s'" (jao-exec-string "xdotool getwindowname %s" wid)) (format "Screensaver %s" (jao-exec-string "xdg-screensaver status"))))) (jao-def-exec jao-xlock-screen "xdg-screensaver" "activate") (jao-def-exec jao-suspend "sudo" "/usr/sbin/pm-suspend") (defun jao-lock-screen () (interactive) (if jao-sway-enabled-p (shell-command "swaylock -i ~/.lockimage") (jao-xlock-screen))) (pretty-hydra-define jao-hydra-sleep (:color blue) ("Sleep" (("l" jao-lock-screen "lock screen") ("z" jao-suspend "sleep") ("u" jao-screensaver-toggle "enable/disable screensaver") ("q" nil "cancel")))) #+end_src *** X clipboard #+BEGIN_SRC emacs-lisp (setq select-enable-clipboard t select-enable-primary t selection-timeout 100) #+END_SRC * Mode line and minibuffer *** Minibuffer #+begin_src emacs-lisp (use-package jao-minibuffer :config (if (jao-colors-scheme-dark-p) (setq jao-minibuffer-active-buffer-line-color "burlywood4" jao-minibuffer-inactive-buffer-line-color "grey25") (setq jao-minibuffer-active-buffer-line-color "burlywood3")) :commands (jao-minibuffer-add-variable jao-minibuffer-refresh jao-minibuffer-add-mode-line)) (setq enable-recursive-minibuffers t) (when window-system (jao-minibuffer-add-mode-line 90)) #+end_src *** Time display #+BEGIN_SRC emacs-lisp (setq display-time-world-list '(("Europe/Paris" "Barcelona") ("America/Los_Angeles" "Los Angeles") ("America/New_York" "New York") ("Europe/London" "London") ("Asia/Calcutta" "Bangalore") ("Asia/Tokyo" "Tokyo"))) (defun jao-time--pdt-hour () (jao-time-at-zone "%H" "America/Los_Angeles")) (defun jao-time--chicago-hour () (jao-time-at-zone "%H" "America/Chicago")) (defun jao-time-at-zone (format zone) (set-time-zone-rule zone) (prog1 (format-time-string format) (set-time-zone-rule nil))) (defun jao-time-echo-la-time () (interactive) (message (jao-time-at-zone "LA %H:%M" "America/Los_Angeles"))) (defun jao-time-echo-times () (interactive) (let ((msg (format "%s (%s)" (format-time-string "%a, %e %B - %H:%M") (jao-time-at-zone "%H:%M" "America/Los_Angeles")))) (jao-notify msg "" (jao-data-file "clock-world-icon.png")))) (defun jao-time-to-epoch (&optional s) (interactive) (let ((s (or s (read-string "Time string: " (thing-at-point 'string))))) (message "%s = %s" s (round (* 1000 (time-to-seconds (parse-time-string s))))))) (defun jao-epoch-to-time (&optional v) (interactive) (let ((v (or v (read-number "Milliseconds: " (thing-at-point 'number))))) (message "%s = %s" v (format-time-string "%Y-%m-%d %H:%M:%S" (seconds-to-time (/ v 1000.0)))))) #+END_SRC *** Mode line format #+begin_src emacs-lisp (setq line-number-display-limit-width 250 display-time-string-forms '(24-hours ":" minutes)) (display-time-mode -1) (setq mode-line-position-column-format '(" %c") mode-line-position-line-format '(" %l,%c")) (setq mode-line-percent-position '(" %l" (:eval (format "/%d" (line-number-at-pos (point-max)))))) (line-number-mode -1) (column-number-mode 1) #+end_src *** Mode line toggle #+begin_src emacs-lisp (defun jao-toggle--face-height (face &optional all) (let* ((h (face-attribute face :height (window-frame))) (nh (if (eq 'unspecified h) 1 'unspecified))) (set-face-attribute face (when (not all) (window-frame)) :height nh))) (defun jao-toggle-mode-line (&optional all) (interactive "P") (jao-toggle--face-height 'mode-line all)) (defun jao-toggle-inactive-mode-line (&optional all) (interactive "P") (jao-toggle--face-height 'mode-line-inactive all)) (defun jao-echo-mode-line () (interactive) (message "%s" (format-mode-line mode-line-format))) (defun jao--hide-inactive-mode-line (frame) (set-face-attribute 'mode-line-inactive frame :height 1)) (add-to-list 'after-make-frame-functions #'jao--hide-inactive-mode-line) (global-set-key (kbd "") #'jao-toggle-inactive-mode-line) (global-set-key (kbd "") #'jao-toggle-mode-line) (global-set-key (kbd "") #'jao-echo-mode-line) #+end_src *** Diminish #+BEGIN_SRC emacs-lisp (use-package diminish :ensure t) (when (require 'use-package-diminish nil 'noerror) (eval-after-load "simple" '(diminish 'auto-fill-function " §")) (eval-after-load "autorevert" '(diminish 'auto-revert-mode ""))) #+END_SRC *** Battery #+begin_src emacs-lisp (use-package battery :init (setq battery-load-low 15 battery-load-critical 8 battery-mode-line-limit 40 battery-echo-area-format "%L %r %B (%p%% load, remaining time %t)" battery-mode-line-format " %b%p ")) (display-battery-mode 1) (setq global-mode-string (delq 'battery-mode-line-string global-mode-string)) (with-eval-after-load "jao-minibuffer" (jao-minibuffer-add-variable 'battery-mode-line-string 80)) #+end_src * Notifications *** alert #+BEGIN_SRC emacs-lisp (use-package alert :ensure t :init (setq alert-default-style 'message ;; 'libnotify alert-hide-all-notifications nil)) #+END_SRC *** jao-notify #+begin_src emacs-lisp (require 'jao-notify) (setq jao-notify-use-messages-p t) ;; "/usr/share/icons/Papirus/64x64/mimetypes/audio-x-generic.svg" ;; "/usr/share/icons/Tango/scalable/mimetypes/audio-x-generic.svg" (defvar jao-notify-audio-icon (jao-data-file "music-player-icon.png")) #+end_src *** tracking #+begin_src emacs-lisp (use-package tracking :demand t :init (setq tracking-position 'before-modes tracking-frame-behavior nil tracking-most-recent-first nil tracking-max-mode-line-entries 10 tracking-sort-faces-first t tracking-shorten-modes '()) :config (setq erc-track-enable-keybindings nil) :bind (("C-c C-SPC" . tracking-next-buffer))) (use-package jao-tracking :demand t :init (setq jao-tracking-bkg (if (jao-colors-scheme-dark-p) "grey20" "grey93"))) #+end_src * Calendar, diary, weather *** Diary #+BEGIN_SRC emacs-lisp (setq diary-file (expand-file-name "diary" jao-org-dir) diary-display-function 'diary-fancy-display diary-mail-addr "jao@localhost" diary-comment-start ";;" diary-comment-end "") (add-hook 'diary-list-entries-hook 'diary-sort-entries t) #+END_SRC *** Calendar #+BEGIN_SRC emacs-lisp (setq appt-display-format nil) (appt-activate 1) (setq calendar-latitude 55.9533 calendar-longitude -3.1883 calendar-location-name "Edinburgh, Scotland" calendar-mark-diary-entries-flag t calendar-date-echo-text '(format "ISO date: %s" (calendar-iso-date-string (list month day year)))) (setq calendar-holidays '((holiday-fixed 1 1 "New Year's Day") (holiday-fixed 4 1 "April Fools' Day") (holiday-float 5 0 2 "Mother's Day") (holiday-fixed 3 19 "Father's Day") (holiday-float 11 4 4 "Thanksgiving") (holiday-fixed 12 25 "Christmas") (holiday-chinese-new-year) (solar-equinoxes-solstices) (holiday-sexp calendar-daylight-savings-starts (format "Daylight Saving Time Begins %s" (solar-time-string (/ calendar-daylight-savings-starts-time (float 60)) calendar-standard-time-zone-name))) (holiday-sexp calendar-daylight-savings-ends (format "Daylight Saving Time Ends %s" (solar-time-string (/ calendar-daylight-savings-ends-time (float 60)) calendar-daylight-time-zone-name))))) #+END_SRC *** Weather ***** winttr #+begin_src emacs-lisp (defun jao-weather (&optional wide) (interactive "P") (if (not wide) (message "%s" (jao-exec-string "curl -s 'https://wttr.in/?format=%s'" "%l++%m++%C+%c+%t+%w++%p")) (jao-afio--goto-scratch) (if-let ((b (get-buffer "*wttr*"))) (progn (pop-to-buffer b) (term-send-string "clear;curl wttr.in\n")) (jao-exec-in-term "curl wttr.in" "*wttr*")))) (global-set-key (kbd "") #'jao-weather) #+end_src *** Timers #+BEGIN_SRC emacs-lisp (put 'list-timers 'disabled nil) #+END_SRC * Files, dired and scratch buffer *** so-long #+begin_src emacs-lisp (setq large-file-warning-threshold (* 200 1024 1024)) (use-package so-long :ensure t :diminish) (global-so-long-mode 1) #+end_src *** Persistent scratch #+BEGIN_SRC emacs-lisp (use-package persistent-scratch :ensure t :config (persistent-scratch-setup-default)) #+END_SRC *** Automatically uncompress #+BEGIN_SRC emacs-lisp (require 'jka-compr) (auto-compression-mode 1) #+END_SRC *** wgrep #+begin_src emacs-lisp (use-package wgrep :ensure t) (require 'wgrep) #+end_src *** dired - [[https://www.masteringemacs.org/article/working-multiple-files-dired][Working with multiple files in dired - Mastering Emacs]] #+begin_src emacs-lisp (require 'dired) (require 'dired-x nil t) (put 'dired-find-alternate-file 'disabled nil) (setq dired-recursive-deletes 'top) (setq dired-recursive-copies 'top) (setq dired-listing-switches "-alhF --group-directories-first") (setq dired-free-space-args "-Ph") (setq ls-lisp-dirs-first t) (setq dired-dwim-target t) (setq wdired-create-parent-directories t) (use-package find-dired :init (setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld"))) (add-hook 'dired-mode-hook #'turn-on-gnus-dired-mode) (define-key dired-mode-map [(control meta ?m)] #'gnus-dired-attach) (define-key dired-mode-map (kbd "C-c C-r") #'wdired-change-to-wdired-mode) (global-set-key (kbd "C-c D") #'find-name-dired) #+END_SRC ***** Dired packages #+BEGIN_SRC emacs-lisp (use-package dired-git-info :ensure t :bind (:map dired-mode-map (")" . dired-git-info-mode))) #+END_SRC * General editing *** eldoc #+begin_src emacs-lisp (use-package eldoc :init (setq eldoc-mode-line-string nil eldoc-echo-area-use-multiline-p t) :config (global-eldoc-mode 1) :diminish ((eldoc-mode . ""))) #+end_src *** Long lines [[https://200ok.ch/posts/2020-09-29_comprehensive_guide_on_handling_long_lines_in_emacs.html][Comprehensive guide on handling long lines in Emacs - 200ok]] #+begin_src emacs-lisp (when (version<= "27.1" emacs-version) (setq bidi-inhibit-bpa t)) #+end_src *** Spaces, tabs, kill #+begin_src emacs-lisp (setq kill-whole-line t) (setq-default indent-tabs-mode nil) (setq indent-tabs-width 4) (setq-default default-tab-width 8) (setq tab-always-indent t) (setq kill-read-only-ok t) (setq view-read-only nil) #+end_src *** Whitespace #+BEGIN_SRC emacs-lisp (add-hook 'write-file-functions 'delete-trailing-whitespace) (setq-default indicate-empty-lines nil) #+END_SRC *** Filling Some variables to control where fci mode will be or is being used #+BEGIN_SRC emacs-lisp (setq fill-column 78) (setq comment-auto-fill-only-comments nil) (add-hook 'prog-mode-hook #'display-fill-column-indicator-mode) (setq-default display-fill-column-indicator-column 80) #+END_SRC *** Visible mode #+begin_src emacs-lisp (use-package visible-mode :bind (("s-v" . visible-mode))) #+end_src *** Changes #+BEGIN_SRC emacs-lisp (use-package goto-chg :ensure t :bind (("C-." . goto-last-change) ("C-," . goto-last-change-reverse))) #+END_SRC *** Eval-and-replace #+BEGIN_SRC emacs-lisp (defun fc-eval-and-replace () "Replace the preceding sexp with its value." (interactive) (backward-kill-sexp) (condition-case nil (prin1 (eval (read (current-kill 0))) (current-buffer)) (error (message "Invalid expression") (insert (current-kill 0))))) (global-set-key "\C-ce" 'fc-eval-and-replace) #+END_SRC *** Completion #+begin_src emacs-lisp (jao-load-org "completion") #+end_src * Buffers *** cursor and mark #+begin_src emacs-lisp (transient-mark-mode -1) (blink-cursor-mode -1) (setq cursor-in-non-selected-windows nil) #+end_src *** uniquifiy #+begin_src emacs-lisp (require 'uniquify) (setq uniquify-buffer-name-style 'forward uniquify-trailing-separator-p t) #+end_src *** autosave #+BEGIN_SRC emacs-lisp (setq auto-save-list-file-prefix "~/.emacs.d/auto-save-list/.saves-" auto-save-no-message t) #+END_SRC *** autoinsert #+BEGIN_SRC emacs-lisp (use-package autoinsert :config (setq auto-insert-directory "~/.emacs.d/autoinsert/" auto-insert t auto-insert-quert t) (setf (alist-get 'html-mode auto-insert-alist nil t) nil)) (add-hook 'find-file-hooks #'auto-insert) #+END_SRC *** autorevert #+BEGIN_SRC emacs-lisp (setq auto-revert-check-vc-info nil) (setq auto-revert-verbose nil) (setq auto-revert-avoid-polling t) (setq auto-revert-mode-text "") (require 'autorevert) (global-auto-revert-mode 1) #+END_SRC *** attached buffers #+begin_src emacs-lisp (defun jao-display-buffer-below-selected (buffer alist) (delete-other-windows-vertically) (display-buffer-below-selected buffer alist)) (defun jao-attached-buffer-entry (name-rx height) `(,name-rx (display-buffer-reuse-window jao-display-buffer-below-selected) (window-height . ,(or height 25)))) (defmacro jao-with-attached-buffer (name-rx height &rest body) `(let ((display-buffer-alist '(,(jao-attached-buffer-entry name-rx height)))) ,@body)) (defun jao-define-attached-buffer (name-rx &optional height) (add-to-list 'display-buffer-alist (jao-attached-buffer-entry name-rx height))) #+end_src *** images #+begin_src emacs-lisp (setq image-use-external-converter t) (setq widget-image-enable nil) #+end_src *** same mode #+begin_src emacs-lisp (defun jao-buffer-same-mode (&optional mode pre-fn) (interactive) (let* ((mode (or mode major-mode)) (modes (if (symbolp mode) (list mode) mode)) (pred `(lambda (b) (let ((b (get-buffer (if (consp b) (car b) b)))) (member (buffer-local-value 'major-mode b) ',modes)))) (buff (read-buffer "Buffer: " nil t pred))) (when pre-fn (funcall pre-fn)) (pop-to-buffer buff))) (global-set-key (kbd "C-c C-b") #'jao-buffer-same-mode) #+end_src *** buffer quit function (the triple ESC) #+begin_src emacs-lisp (setq buffer-quit-function (lambda () t)) #+end_src * Windows *** Scrolling #+begin_src emacs-lisp (setq scroll-preserve-screen-position 'always scroll-conservatively most-positive-fixnum scroll-margin 0 scroll-step 2 redisplay-skip-fontification-on-input t) (setq line-move-visual t) (use-package iscroll :ensure t :diminish) (with-eval-after-load "gnus-art" (add-hook 'gnus-article-mode-hook #'iscroll-mode)) (with-eval-after-load "eww" (add-hook 'eww-mode-hook #'iscroll-mode)) #+end_src *** Splitting and switch #+begin_src emacs-lisp (setq split-height-threshold 80 split-width-threshold 144) (setq switch-to-buffer-preserve-window-point nil switch-to-buffer-obey-display-actions t switch-to-prev-buffer-skip 'this) ;; don't switch to a ;; buffer visible in ;; same frame (global-set-key (kbd "C-x _") #'delete-other-windows-vertically) #+end_src *** Transpose #+begin_src emacs-lisp (defun jao-transpose-windows (arg) "Transpose the buffers shown in two windows." (interactive "p") (let ((selector (if (>= arg 0) 'next-window 'previous-window))) (while (/= arg 0) (let ((this-win (window-buffer)) (next-win (window-buffer (funcall selector)))) (set-window-buffer (selected-window) next-win) (set-window-buffer (funcall selector) this-win) (select-window (funcall selector))) (setq arg (if (plusp arg) (1- arg) (1+ arg)))))) (define-key ctl-x-4-map (kbd "t") #'jao-transpose-windows) (global-set-key (kbd "M-O") #'jao-transpose-windows) #+end_src *** Window navigation #+begin_src emacs-lisp (defvar jao-first-window--from nil) (defun jao-first-window () "Go to previous windows in frame, remembering where we were." (interactive) (let ((cb (current-buffer))) (if (eq (get-buffer-window cb) (select-window (frame-first-window))) (when jao-first-window--from (pop-to-buffer jao-first-window--from)) (setq jao-first-window--from cb)))) (defun jao-prev-window () "Go to previous window." (interactive) (other-window -1)) (defun jao--nth-window (n) (let ((jao-minibuffer-enabled-p nil)) (select-window (frame-first-window)) (dotimes (x n) (other-window 1))) (jao-minibuffer-refresh)) (defalias 'jao-other-window 'other-window) (global-set-key (kbd "s-a") #'jao-first-window) (global-set-key (kbd "H-s-a") #'jao-first-window) (global-set-key (kbd "C-x p") 'jao-prev-window) (global-set-key (kbd "M-o") #'other-window) (global-set-key (kbd "C-c 0") #'jao-first-window) (dolist (n '(0 1 2 3 4 5 6 7 8)) (global-set-key (format "\C-c%s" (1+ n)) `(lambda () (interactive) (jao--nth-window ,n)))) #+end_src *** winner mode #+begin_src emacs-lisp (winner-mode 1) #+end_src * Frames *** Frame geometry #+begin_src emacs-lisp (setq frame-resize-pixelwise nil) ;;; modeline, toolbars and co. (modify-all-frames-parameters `((horizontal-scroll-bars . nil) (vertical-scroll-bars . nil) (scroll-bar-width . 11) (menu-bar . nil) (alpha . (,jao-frames-default-alpha ,jao-frames-default-alpha)) (font . ,jao-default-font))) #+end_src *** Frame layout, title, etc. #+BEGIN_SRC emacs-lisp (setq frame-title-format '("%b")) (use-package fringe) (fringe-mode) (menu-bar-mode (jao-d-l 1 -1)) ;; (setting it to nil avoids mouse wrapping after other-frame) (setq focus-follows-mouse t) (use-package scroll-bar) (set-scroll-bar-mode nil) (use-package tool-bar) (tool-bar-mode -1) (defun jao-trisect (&optional force) (interactive) (let ((fw (frame-width))) (delete-other-windows) (cond ((or force (>= fw 240)) (let ((w (- (/ fw 3)))) (delete-other-windows) (split-window-horizontally w) (split-window-horizontally w) (balance-windows))) ((> fw 162) (split-window-horizontally) (switch-to-buffer (other-buffer)))))) (defun jao-bisect () (interactive) (jao-trisect t) (next-window) (delete-window)) #+END_SRC *** afio #+begin_src emacs-lisp (use-package jao-afio) (defun jao-xmonad-goto-1 () (shell-command "sendCommand 1")) (defun jao-afio--goto-scratch-1 () (interactive) (jao-afio-goto-scratch t)) (jao-afio-setup 'jao-afio--goto-scratch-1 t) (defun jao-current--frame-id () (propertize (if (and jao-exwm-enabled-p (not (bound-and-true-p jao-exwm--use-afio))) (format "F%s" exwm-workspace-current-index) (format "%s" (jao-afio-current-no))) 'face 'font-lock-warning-face)) (add-hook 'jao-afio-switch-hook #'tracking-remove-visible-buffers) (jao-minibuffer-add-variable '(jao-current--frame-id) 100) #+end_src * Writing and writing modes *** Org mode #+begin_src emacs-lisp (jao-load-org "org") #+end_src *** Blog #+begin_src emacs-lisp (jao-load-org "blog") #+end_src *** Text-ish mode settings #+begin_src emacs-lisp ;;; SENTENCES separated by just one space (setq sentence-end "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*") (setq sentence-end-double-space t) ;;; copy rectangle (defun kill-rectangle-save (start end) "Save the region-rectangle as the last killed one." (interactive "r") (require 'rect) ; Make sure killed-rectangle is defvar'ed. (setq killed-rectangle (extract-rectangle start end)) (message "Rectangle saved")) ;;; indent on yank (defvar jao-auto-indent-modes '(emacs-lisp-mode ;; clojure-mode scheme-mode objc-mode tuareg-mode c-mode c++-mode tcl-mode sql-mode perl-mode cperl-mode java-mode jde-mode LaTeX-mode TeX-mode)) ;; (defadvice yank (after indent-region activate) ;; (if (member major-mode jao-auto-indent-modes) ;; (indent-region (region-beginning) (region-end) nil))) ;; text mode, autoinserts and write hooks ;;; misc (setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'write-file-functions 'copyright-update) #+end_src *** Dictionaries #+BEGIN_SRC emacs-lisp (defun jao-word-definition-lookup () "Look up the word under cursor in a browser." (interactive) (require 'thingatpt) (browse-url (concat "http://www.wordnik.com/words/" ;; "http://www.answers.com/main/ntquery?s=" (thing-at-point 'word)))) (use-package dictionary :init (setq dictionary-use-single-buffer t dictionary-server "localhost") :commands (dictionary-search dictionary-match-words dictionary-lookup-definition dictionary dictionary-mouse-popup-matching-words dictionary-popup-matching-words dictionary-tooltip-mode global-dictionary-tooltip-mode) :bind (("C-c d" . dictionary-search) ("C-c D" . jao-word-definition-lookup))) (setq ispell-personal-dictionary (expand-file-name "~/.emacs.d/ispell.dict")) #+END_SRC *** Markdown #+BEGIN_SRC emacs-lisp (use-package markdown-mode :ensure t) (use-package markdown-toc :ensure t) (dolist (ext '("\\.md$" "\\.markdown$")) (add-to-list 'auto-mode-alist (cons ext 'markdown-mode))) #+END_SRC *** TeX and LaTex #+BEGIN_SRC emacs-lisp (use-package tex-site :ensure auctex :init (progn (setq TeX-auto-save t) (setq TeX-parse-self t) (setq TeX-a4-paper t) (setq TeX-auto-local ".tex-auto-local") ;; Preferred view format: dvi, ps, pdf, pdfs (setq TeX-view-format "pdf") (setq-default TeX-master "../main") ; nil to ask (setq TeX-view-program-selection (jao-d-l '((output-dvi "open") (output-pdf "open") (output-html "open")) '(((output-dvi has-no-display-manager) "dvi2tty") ((output-dvi style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "xdg-open") (output-html "xdg-open")))) ;; to make RefTeX faster for large documents, try these: (setq reftex-enable-partial-scans t) (setq reftex-save-parse-info t) (setq reftex-use-multiple-selection-buffers t) ;; to integrate with AUCTeX (setq reftex-plug-into-AUCTeX t) (setq reftex-ref-style-default-list '("Hyperref" "Varioref" "Fancyref")) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq LaTeX-command "latex -shell-escape") (setq LaTeX-biblatex-use-Biber t) (setq bibtex-dialect 'biblatex) (jao-when-darwin (jao-exec-path "/usr/local/texlive/2016/bin/x86_64-darwin")))) ;; (use-package ebib ;; :ensure t ;; :config (setq ebib-bibtex-dialect 'biblatex)) ;; for M-x biblio-lookup ;; (use-package biblio :ensure t) #+END_SRC * Browsing *** Variables #+begin_src emacs-lisp (defvar jao-browse-doc-use-emacs-p t) (defvar jao-browse-url-function nil) (defvar jao-browse-url-external-function nil) #+end_src *** URL around point #+begin_src emacs-lisp (defun jao-url-around-point (&optional current-url) (or (and (fboundp 'w3m-anchor) (w3m-anchor)) (shr-url-at-point nil) (ffap-url-at-point) (thing-at-point 'url) (when current-url (or (and (fboundp 'w3m-anchor) (w3m-anchor)) (and (derived-mode-p 'eww-mode) (plist-get eww-data :url)))))) (defun jao--url-prompt () (let* ((def (jao-url-around-point t)) (prompt (concat "URL" (if def (format " (%s): " def) ": ")))) (read-string prompt nil nil def))) #+end_src *** Downloads using wget #+BEGIN_SRC emacs-lisp (defun jao-wget--get-title (filename) (let ((fn (file-name-base filename))) (if (string-blank-p fn) (plist-get eww-data :title) (subst-char-in-string ?- ? (capitalize fn))))) (defun jao-wget (url &optional user pwd) "Download URL using wget." (let* ((def (file-name-nondirectory url)) (pmt (format "Save %s to: " url)) (read-file-name-function nil) (dest (expand-file-name (read-file-name pmt jao-sink-dir nil nil def))) (title (jao-wget--get-title dest)) (src-url (jao-url-around-point t)) (auth (when (and user pwd) `(,(format "--http-user=%s" user) ,(format "--http-password=%s" pwd))))) (switch-to-buffer-other-window (get-buffer-create "*downloads*")) (erase-buffer) (kill-new (format "[[doc:%s][%s]] (from [[%s][here]])" (file-name-nondirectory dest) (read-string "Title: " title) (or src-url (file-name-directory url)))) (apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url)))) (defun jao-download (url &optional pws) "Download URL using wget" (interactive (list (jao--url-prompt))) (when url (let ((usr (and pws (read-string "Login name: "))) (pwd (and pws (read-passwd "Password: ")))) (jao-wget url usr pwd)))) (with-eval-after-load "embark" (define-key embark-url-map (kbd "d") #'jao-download)) #+END_SRC *** Video #+BEGIN_SRC emacs-lisp (defvar jao-video--url-rx (format "^https?://\\(?:www\\.\\)?%s/.+" (regexp-opt '("youtu.be" "youtube.com" "blip.tv" "vimeo.com" "infoq.com") t))) (defun jao-video--url-p (url) (string-match-p jao-video--url-rx url)) (defun jao--remote-run (url prg) (let ((args (format "%s %s" prg (shell-quote-argument url)))) (start-process-shell-command prg nil args))) (defun jao--mpv (url &rest args) (jao--remote-run url "mpv")) (defun jao--vlc (url &rest args) (jao--remote-run url "vlc")) (defvar jao--video-player 'jao--mpv) (defun jao-view-video (url) "Tries to stream a video from the current or given URL" (interactive (list (jao--url-prompt))) (when url (funcall jao--video-player url))) (defun jao-maybe-view-video (url &rest _ignored) (interactive) (if (y-or-n-p "View video (y) or web page (n)? ") (jao-view-video url) (funcall jao-browse-url-function url))) #+END_SRC *** Web browsers #+begin_src emacs-lisp (jao-load-org "w3m") #+end_src *** Browse URL #+begin_src emacs-lisp (require 'browse-url) (setq browse-url-generic-program "~/bin/firehog") (defun jao-browse-with-external-browser (&rest url) "Browse with external hogging" (interactive "s") (let ((url (or (car url) (jao-url-around-point)))) (if (not url) (message "No URL at point") (when (and jao-exwm-enabled-p (fboundp 'jao-exwm-firefox)) (jao-exwm-firefox)) (when (and jao-sway-enabled-p (fboundp 'jao-sway-firefox)) (jao-sway-firefox)) (browse-url-generic url)))) (setq jao-browse-url-external-function 'jao-browse-with-external-browser) (defun jao--fln (url) (shell-quote-argument (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url) (match-string-no-properties 1 url) url))) (defun jao--browse-doc (url search &optional no-add) (let* ((url (substring-no-properties url)) (file (jao--fln url))) (when file (unless (file-exists-p file) (error "File %s does not exist" file)) (jao-open-doc file)))) (defun jao--make-file-rx (exts) (format "file:/?/?.+\\.%s$" (regexp-opt exts))) (defvar jao--see-exts (jao--make-file-rx '("jpg" "jpeg" "png" "mov" "wmv" "avi" "mp4"))) (defvar jao--doc-exts (jao--make-file-rx '("ps" "ps.gz" "pdf" "dvi" "djvu" "chm"))) (defvar jao-browse-url-wget-exts '("ps" "pdf" "dvi" "djvu" "zip" "gz" "tgz" "mp4" "mp3" "flv")) (defun jao-wget--regexp () (concat "^http[s]?://.+\\(\\." (mapconcat 'identity jao-browse-url-wget-exts "\\|\\.") "\\)\\'")) (defun jao--see (url &rest _r) (start-process-shell-command "see" nil (format "see %s" (jao--fln url)))) (defun jao--find-file-other-window (url &rest _) (find-file-other-window (jao--fln url))) (use-package elpher :ensure t) (defun jao-elpher--browse (url &rest _) (elpher-go url)) (setq browse-url-handlers `(("^\\(gemini\\|gopher\\)://.*" . jao-elpher--browse) (,jao--doc-exts . jao--browse-doc) (,jao--see-exts . jao--see) ("^file://?.+\\.html?$" . ,jao-browse-url-function) ("^file://?" . jao--find-file-other-window) ("^https?://git\\(hub\\|lab\\)\\.com/.*" . ,jao-browse-url-external-function) ("^https?://.*\\.slack\\..*" . ,jao-browse-url-external-function) ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome) ("^https?://meet\\.google\\.com\\.*" . ,jao-browse-url-external-function) ("^https?://t\\(witter\\)?\\.com?/.*" . ,jao-browse-url-external-function) (,(jao-wget--regexp) . jao-download) (jao-video--url-p . jao-maybe-view-video) ("." . ,jao-browse-url-function))) (when (< emacs-major-version 28) (setf (alist-get 'jao-video--url-p browse-url-handlers nil t) nil) (setq browse-url-browser-function browse-url-handlers)) #+end_src *** Subscribe rss using r2e #+begin_src emacs-lisp (autoload 'View-quit "view") (defun jao-rss--find-url () (when (derived-mode-p 'w3m-mode 'eww-mode) (save-excursion (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source)) (goto-char (point-min)) (when (re-search-forward "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t) (let ((url (save-excursion (when (re-search-forward "href=\"\\([^\n\"]+\\)\"" nil t) (match-string-no-properties 1)))) (title (when (re-search-forward "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t) (match-string-no-properties 1)))) (if (fboundp 'w3m-view-mode) (w3m-view-source) (View-quit)) (when url (cons url (or title "")))))))) (defun jao-rss2e-append (name url mbox) (with-current-buffer (find-file-noselect "~/.config/rss2email.cfg") (goto-char (point-max)) (insert "[feed." name "]\nurl = " url) (insert "\nto = jao+feeds_" mbox "@localhost") (insert "\nmaildir-mailbox = " mbox "\n\n") (save-buffer))) (defun jao-rss-subscribe (&optional url) "Subscribe to a given RSS URL. If URL not given, look for it." (interactive) (let* ((url (or url (jao-url-around-point) (jao-rss--find-url) (read-string "Feed URL: "))) (url+title (if (consp url) url (list url))) (url (car url+title)) (title (cdr url+title))) (if url (let ((url (if (string-match "^feed:" url) (substring url 5) url))) (when (y-or-n-p (format "Subscribe to <%s>? " url)) (let* ((name (read-string "Feed name: " title)) (cat (completing-read "Category: " (jao-list-mailboxes "feeds") nil t))) (jao-rss2e-append name url cat) (shell-command (format "r2e run %s" name))))) (message "No feeds found")))) #+end_src * Email #+begin_src emacs-lisp (setq jao-afio-mail-function 'notmuch) (jao-load-org "email") #+end_src * PDFs *** doc-view and pdf-tools #+begin_src emacs-lisp ;; this is an ugly hack: when jao-minibuffer is active, ;; somehow docview scrolling is not triggering a refresh, ;; specially for scroll down movements, so we advice the ;; scrolling functions to force a redisplay by going to ;; another window. (defun jao--refresh (&rest _rest) (let ((jao-minibuffer-enabled-p nil)) (other-window 1) (other-window -1))) (use-package doc-view :init (setq doc-view-cache-directory "~/.emacs.d/cache/docview" doc-view-resolution 110 doc-view-continuous t doc-view-conversion-refresh-interval 1) :config (dolist (f '(doc-view-scroll-up-or-next-page doc-view-scroll-down-or-previous-page doc-view-previous-line-or-previous-page doc-view-next-line-or-next-page image-forward-hscroll image-backward-hscroll image-scroll-down image-scroll-up image-eol image-bol)) (advice-add f :after #'jao--refresh)) :bind (:map doc-view-mode-map ("j" . doc-view-next-line-or-next-page) ("J" . doc-view-scroll-up-or-next-page) ("k" . doc-view-previous-line-or-previous-page) ("K" . doc-view-scroll-down-or-previous-page))) (use-package jao-doc-view :config (dolist (f '(image-forward-hscroll image-backward-hscroll image-scroll-down image-scroll-up image-eol image-bol)) (advice-add f :after #'jao--refresh)) :bind (:map doc-view-mode-map ("b" . jao-doc-view-back) ("B" . jao-doc-view-forward) ("S" . jao-doc-view-save-session) ("u" . jao-doc-view-visit-url))) (use-package pdf-tools :disabled t :ensure t :demand t :config (pdf-tools-install) (dolist (f '(pdf-view-scroll-up-or-next-page pdf-view-scroll-down-or-previous-page pdf-view-previous-line-or-previous-page pdf-view-next-line-or-next-page)) (advice-add f :after #'jao--refresh)) :diminish ((pdf-view-midnight-minor-mode . "")) :bind (:map pdf-view-mode-map (("C-c C-d" . pdf-view-midnight-minor-mode) ("j" . pdf-view-next-line-or-next-page) ("J" . pdf-view-scroll-up-or-next-page) ("k" . pdf-view-previous-line-or-previous-page) ("K" . pdf-view-scroll-down-or-previous-page)))) (use-package saveplace-pdf-view :ensure t :demand t :after doc-view) #+end_src *** open pdfs #+begin_src emacs-lisp (setq jao-open-doc-fun 'jao-find-or-open) (defun jao-find-or-open (file) (let* ((buffs (buffer-list)) (b (catch 'done (while buffs (when (string-equal (buffer-file-name (car buffs)) file) (throw 'done (car buffs))) (setq buffs (cdr buffs)))))) (jao-afio--goto-docs) (if b (pop-to-buffer b) (find-file file)))) (defun jao-open-doc (&optional file) (interactive) (when-let (file (or file (read-file-name "Document: " (concat jao-org-dir "/doc/")))) (funcall jao-open-doc-fun file))) (defun jao-afio-open-pdf (file page &optional height) (jao-open-doc file) (when page (jao-doc-view-goto-page page height))) (setq jao-org-open-pdf-fun #'jao-afio-open-pdf) #+end_src *** hydra #+begin_src emacs-lisp (major-mode-hydra-define doc-view-mode nil ("Notes" (("o" jao-org-pdf-goto-org "notes file") ("O" (jao-org-pdf-goto-org 4) "notes file, linking")) "Navigation" (("b" jao-doc-view-back "back jump") ("B" jao-doc-view-back "forward jump") ("u" jao-doc-view-visit-url "visit URL")) "Slices" (("cb" doc-view-set-slice-from-bounding-box "bounding box") ("cm" doc-view-set-slice-using-mouse "using mouse")) "Session" (("s" jao-open-pdf-session "load session") ("S" jao-doc-view-save-session "save session") ("d" doc-view-dired-cache "visit cache directory")))) #+end_src * Shells *** shell modes #+begin_src emacs-lisp (setq sh-basic-offset 2) ;; translates ANSI colors into text-properties, for eshell (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) #+end_src *** term #+begin_src emacs-lisp (defvar-local jao-term--cmd nil) (defun jao-term--find (cmd) (seq-find (lambda (b) (with-current-buffer b (and (derived-mode-p 'term-mode) (string= (or jao-term--cmd "") cmd)))) (buffer-list))) (defun jao-exec-in-term (cmd &optional name) (ansi-term "bash" name) (set-process-sentinel (get-buffer-process (current-buffer)) (lambda (process event) (when (string= event "finished\n") (kill-buffer (process-buffer process))))) (term-send-string nil (concat cmd ";exit\n"))) (defmacro jao-def-exec-in-term (name cmd &rest prelude) `(defun ,(intern (format "jao-term-%s" name)) () (interactive) ,@prelude (if-let ((b (jao-term--find ,cmd))) (pop-to-buffer b) (jao-exec-in-term ,cmd ,(format "*%s*" name)) (setq-local jao-term--cmd ,cmd)))) (jao-def-exec-in-term "aptitude" "aptitude" (jao-afio--goto-scratch)) (jao-def-exec-in-term "htop" "htop" (jao-afio--goto-scratch)) #+end_src *** eshell ***** Basic custom #+begin_src emacs-lisp (use-package eshell :init (setq eshell-directory-name "~/.emacs.d/eshell") (setq eshell-aliases-file (jao-data-file "eshell.alias")) (setq eshell-hist-ignoredups 'erase) :config (add-hook 'eshell-mode-hook (lambda () (setq outline-regexp eshell-prompt-regexp)))) #+end_src ***** Colors #+begin_src emacs-lisp (autoload 'ansi-color-apply "ansi-color") ;; (add-hook 'eshell-preoutput-filter-functions 'ansi-color-filter-apply) (add-hook 'eshell-preoutput-filter-functions 'ansi-color-apply) (use-package eshell-syntax-highlighting :after esh-mode :ensure t :config ;; Enable in all Eshell buffers. (eshell-syntax-highlighting-global-mode +1)) #+end_src ***** Visual commands #+BEGIN_SRC emacs-lisp (require 'em-term) ;;; commands using ansi scape seqs (dolist (c '("editor" "more" "wget" "dict" "vim" "links" "w3m" "ssh" "autossh" "zmore" "pager" "aptitude" "su" "htop" "top" "screen" "whizzml" "iex")) (add-to-list 'eshell-visual-commands c)) (setq eshell-visual-subcommands '(("git" "log" "diff" "show") ("sudo" "vim")) eshell-destroy-buffer-when-process-dies nil eshell-escape-control-x t) #+END_SRC ***** bol #+begin_src emacs-lisp (defun jao-eshell-maybe-bol () (interactive) (let ((p (point))) (eshell-bol) (if (= p (point)) (beginning-of-line)))) #+end_src ***** Prompt #+BEGIN_SRC emacs-lisp ;; tracking git repos (defun jao-eshell--git-dirty () (shell-command-to-string "git diff-index --quiet HEAD -- || echo -n '*'")) (use-package git-ps1-mode :ensure t :init (setq git-ps1-mode-showupstream "1" git-ps1-mode-showdirtystate "1")) (defun jao-eshell--git-info () (if (fboundp 'git-ps1-mode-get-current) (git-ps1-mode-get-current) (let ((desc (shell-command-to-string "git branch --no-color"))) (when (string-match "^* \\(\\<.+\\>\\)" desc) (format "%s%s" (match-string 1 desc) (jao-eshell--git-dirty)))))) (defun jao-eshell--git-current-branch (suffix) (let ((desc (or (jao-eshell--git-info) ""))) (cond ((and (string-empty-p desc) suffix) (format " (%s)" suffix)) ((string-empty-p (or suffix "")) (format " (%s)" desc)) (t (format " (%s %s)" desc suffix))))) (defun jao-eshell--virtualenv () (let ((venv (getenv "VIRTUAL_ENV"))) (when (and venv (string-match ".*/\\([^/]+\\)/$" venv)) (match-string-no-properties 1 venv)))) (defun jao-eshell-prompt-function () (let* ((venv (jao-eshell--virtualenv)) (venv (if venv (format "%s" venv) ""))) (concat (abbreviate-file-name (eshell/pwd)) (jao-eshell--git-current-branch venv) (if (= (user-uid) 0) " # " " $ ")))) (setq eshell-prompt-function 'jao-eshell-prompt-function) #+END_SRC ***** in-term #+begin_src emacs-lisp (defun eshell/in-term (prog &rest args) (switch-to-buffer (apply #'make-term (format "in-term %s %s" prog args) prog nil args)) (term-mode) (term-char-mode)) #+end_src ***** Dir navigation #+BEGIN_SRC emacs-lisp (use-package eshell-up :ensure t :config (setq eshell-up-print-parent-dir t)) (use-package eshell-autojump :ensure t) #+END_SRC ***** Completion #+begin_src emacs-lisp (defun jao-eshell-completion-capf () (let ((c (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point) t))) (when (and c (listp c)) (append c '(:exclusive no))))) (defun jao-eshell--add-bash-completion () (setq completion-at-point-functions '(jao-eshell-completion-capf pcomplete-completions-at-point t))) (use-package bash-completion :ensure t :hook (eshell-mode . jao-eshell--add-bash-completion)) #+end_src ***** History #+BEGIN_SRC emacs-lisp (setq eshell-history-size 10000) ;;; Fix eshell history completion to allow !$ ;; This is done by advising eshell-history-reference to expand !$ ;; into !!:$ which works... (defadvice jao-eshell-history-reference (before ben-fix-eshell-history) "Fixes eshell history to allow !$ as abbreviation for !!:$" (when (string= (ad-get-arg 0) "!$") (ad-set-arg 0 "!!:$"))) (ad-activate 'jao-eshell-history-reference) #+END_SRC This is needed if we want ! to expand in emacs >= 27 #+BEGIN_SRC emacs-lisp (add-hook 'eshell-expand-input-functions #'eshell-expand-history-references) #+END_SRC ***** Workarounds #+begin_src emacs-lisp ;; at some point, bash completion started insertig the TAB ;; after the commands ends (defun jao-eshell--clean-prompt () (eshell-bol) (ignore-errors (kill-line))) (add-hook 'eshell-after-prompt-hook 'jao-eshell--clean-prompt) #+end_src ***** Keybindings #+begin_src emacs-lisp (defun jao-eshell--kbds () (define-key eshell-mode-map "\C-a" 'jao-eshell-maybe-bol) (define-key eshell-mode-map "\C-ci" 'consult-outline)) ;; Eshell mode is sillily re-creating its mode map ;; in every buffer in emacs < 28. (if (> emacs-major-version 27) (jao-eshell--kbds) (add-hook 'eshell-mode-hook #'jao-eshell--kbds)) #+end_src *** shell here #+begin_src emacs-lisp (defun jao-shell-here--find-window (b) (when-let ((w (car (cl-remove-if-not `(lambda (w) (eq (window-buffer w) ,b)) (window-list))))) (select-window w))) (defvar jao-shell-here-use-term nil) (defun jao-shell-frame-buffer (&optional b vt) (let ((p (if (or vt jao-shell-here-use-term) 'jao-term-buffer 'jao-eshell-buffer))) (if b (set-frame-parameter nil p b) (frame-parameter nil p)))) (defun jao-shell--cd-here (dir) (if jao-shell-here-use-term (progn (term-send-raw-string "\C-a\C-k") (term-send-string (format "cd %s\n" dir))) (eshell-kill-input) (eshell/cd dir) (insert "\n") (eshell-send-input))) (defun jao-shell-here (&optional stay) (interactive) (let* ((dir default-directory) (b (jao-shell-frame-buffer))) (jao-with-attached-buffer "^\\*\\(ansi-term\\|eshell\\)" 35 (if (buffer-live-p b) (pop-to-buffer b nil t) (if jao-shell-here-use-term (jao-exec-in-term "") (eshell (when (and (boundp 'jao-exwm--use-afio) (not jao-exwm--use-afio)) exwm-workspace-current-index))) (jao-shell-frame-buffer (current-buffer)))) (when (not jao-shell-here-use-term) (eshell-save-some-history)) (unless stay (jao-shell--cd-here dir)))) (defun eshell/x () (when (derived-mode-p 'eshell-mode) (when (fboundp 'eshell-autojump-save) (eshell-autojump-save)) (eshell-save-some-history)) (if (> (frame-height) (window-height)) (delete-window) (bury-buffer))) (defun jao-shell-here-toggle () (interactive) (if (or (eq (current-buffer) (jao-shell-frame-buffer)) (eq (current-buffer) (jao-shell-frame-buffer nil t))) (eshell/x) (jao-shell-here t))) (defun jao-term-here-toggle () (interactive) (let ((jao-shell-here-use-term t)) (call-interactively 'jao-shell-here-toggle))) (global-set-key (kbd "C-!") #'jao-shell-here) (global-set-key [(f1)] #'jao-shell-here-toggle) #+end_src * Version control and CI *** General options #+BEGIN_SRC emacs-lisp (setq vc-follow-symlinks t) (setq auto-revert-check-vc-info nil) #+END_SRC *** Diff fringe indicators (diff-hl) #+BEGIN_SRC emacs-lisp (use-package diff-hl :ensure t :config (setq diff-hl-draw-borders nil diff-hl-side 'right) (map-keymap (lambda (_k cmd) (put cmd 'repeat-map 'diff-hl-command-map)) diff-hl-command-map) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)) (global-diff-hl-mode) #+END_SRC *** Git config files: more informative diffs See [[https://protesilaos.com/codelog/2021-01-26-git-diff-hunk-elisp-org/][Informative diff hunks for Emacs Lisp and Org | Protesilaos Stavrou]] #+begin_src config :tangle ~/.config/git/attributtes :comments no *.clj diff=lisp *.cljc diff=lisp *.cljs diff=lisp *.lisp diff=lisp *.el diff=lisp *.org diff=org #+end_src #+begin_src gitconfig :tangle ~/.config/git/config [diff "lisp"] xfuncname = "^(((;;;+ )|\\(|([ \t]+\\(((cl-|el-patch-)?def(un|var|macro|method|custom)|gb/))).*)$" [diff "org"] xfuncname = "^(\\*+ +.*)$" #+end_src *** Magit and forge #+begin_src emacs-lisp (use-package magit :ensure t :commands magit-status :init (setq magit-status-initial-section nil magit-completing-read-function 'magit-builtin-completing-read magit-display-buffer-function 'magit-display-buffer-fullcolumn-most-v1 magit-delete-by-moving-to-trash nil magit-last-seen-setup-instructions "1.4.0" magit-log-edit-confirm-cancellation t magit-omit-untracked-dir-contents t magit-process-connection-type nil magit-push-always-verify nil magit-repository-directories '(("/home/jao/usr/bigml" . 2) ("/home/jao/usr/jao" . 2) ("/home/jao/lib" . 2)) magit-save-repository-buffers 'dontask magit-status-buffer-switch-function 'switch-to-buffer magit-status-show-hashes-in-headers t) :bind (("" . magit-status) :map magit-status-mode-map ("C-c C-r" . github-review-forge-pr-at-point))) (use-package forge :ensure t :after magit :init (setq forge-database-file (format "~/.emacs.d/forge-database-%s.sqlite" emacs-major-version) forge-topic-list-limit (cons 25 10)) ;; workaround for ghub problems (shoudn't be needed in 27.x) (when (< emacs-major-version 27) (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") (setq ghub-use-workaround-for-emacs-bug nil)) :bind (:map forge-topic-mode-map ("M-w" . copy-region-as-kill)) :config (remove-hook 'magit-status-sections-hook #'forge-insert-issues) ;; (add-hook 'magit-status-sections-hook #'forge-insert-notifications t) (add-hook 'magit-status-sections-hook #'forge-insert-requested-reviews t) (add-hook 'magit-status-sections-hook #'forge-insert-assigned-issues t) (add-hook 'magit-status-sections-hook #'forge-insert-issues t)) #+end_src *** Eldoc for magit status/log buffers [[https://tsdh.org/posts/2021-06-21-using-eldoc-with-magit.html][Using Eldoc with Magit]]. #+begin_src emacs-lisp (defun jao-magit-eldoc-for-commit (_callback) (when-let ((commit (magit-commit-at-point))) (with-temp-buffer (magit-git-insert "show" "--format=format:%an <%ae>, %ar" (format "--stat=%d" (window-width)) commit) (goto-char (point-min)) (put-text-property (point-min) (line-end-position) 'face 'bold) (buffer-string)))) (defun jao-magit-eldoc-setup () (add-hook 'eldoc-documentation-functions #'jao-magit-eldoc-for-commit nil t) (eldoc-mode 1)) (add-hook 'magit-log-mode-hook #'jao-magit-eldoc-setup) ;; (add-hook 'magit-status-mode-hook #'jao-magit-eldoc-setup) (with-eval-after-load "eldoc" (eldoc-add-command 'magit-next-line) (eldoc-add-command 'magit-previous-line) (eldoc-add-command 'magit-section-forward) (eldoc-add-command 'magit-section-backward)) #+end_src *** Other git packages #+begin_src emacs-lisp (use-package git-messenger :ensure t :bind (("C-x v p" . git-messenger:popup-message))) (use-package gist :ensure t) (use-package git-timemachine :ensure t) ;; git config --local git-link.remote / git-link.branch (use-package git-link :ensure t) (use-package gitconfig-mode :ensure t) (use-package github-review :ensure t :config (defun jao-gnus-github-review () (interactive) (gnus-summary-select-article-buffer) (goto-char (point-min)) (when (re-search-forward "https://github\.com/.*/pull/.*" nil t) (let ((url (match-string-no-properties 0))) (when (yes-or-no-p (format "Start review for %s" url)) (github-review-start url))))) (eval-after-load "gnus-art" '(progn (define-key gnus-summary-mode-map "\C-cG" 'jao-gnus-github-review) (define-key gnus-article-mode-map "\C-cG" 'jao-gnus-github-review))) :mode-hydra (github-review-mode nil ("Review" (("a" github-review-approve "Approve") ("r" github-review-reject "Reject") ("c" github-review-reject "Comment")) "Quit" (("Q" bury-buffer "Bury buffer") ("k" kill-buffer "Kill buffer"))))) #+end_src *** Jenkins [[https://github.com/rmuslimov/jenkins.el][GitHub - rmuslimov/jenkins.el: Jenkins plugin for emacs]] #+BEGIN_SRC emacs-lisp (use-package jenkins :ensure t :init ;; one also needs jenkins-api-token, jenkins-username and jenkins-url ;; optionally: jenkins-colwidth-id, jenkins-colwidth-last-status (setq jenkins-colwidth-name 35) :config (defun jao-jenkins-first-job () (interactive) (goto-char (point-min)) (when (re-search-forward "^- Job" nil t) (goto-char (match-beginning 0)))) (add-hook 'jenkins-job-view-mode-hook #'jao-jenkins-first-job) :bind (:map jenkins-job-view-mode-map (("n" . next-line) ("p" . previous-line) ("f" . jao-jenkins-first-job) ("RET" . jenkins--show-console-output-from-job-screen)) :map jenkins-console-output-mode-map (("n" . next-line) ("p" . previous-line) ("g" . jenkins--refresh-console-output)))) #+END_SRC * Programming *** Automatic modes #+BEGIN_SRC emacs-lisp (add-to-list 'auto-mode-alist '("\\.mix\\'" . hexl-mode)) (add-to-list 'auto-mode-alist '("\\.m4\\'" . m4-mode)) (add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode)) (add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode)) #+END_SRC *** Smart scan #+begin_src emacs-lisp (use-package smartscan :ensure t :commands smartscan-mode :init (add-hook 'prog-mode-hook #'smartscan-mode) :diminish) #+end_src *** Paredit and parens #+begin_src emacs-lisp (require 'paren) (show-paren-mode t) (use-package paredit :ensure t :commands paredit-mode :hook ((pie-mode . paredit-mode) (scheme-mode . paredit-mode) (clojure-mode . paredit-mode) (emacs-lisp-mode . paredit-mode) (eval-expression-minibuffer-setup . paredit-mode) (lisp-interaction-mode . disable-paredit-mode)) :diminish ((paredit-mode . " þ"))) #+end_src *** Diff/Ediff #+BEGIN_SRC emacs-lisp (setq ediff-split-window-function 'split-window-horizontally) (setq ediff-make-buffers-readonly-at-startup nil) (setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-keep-variants nil) #+END_SRC *** Compilation ***** Compilation mode options #+begin_src emacs-lisp (require 'compile) (setq compilation-scroll-output t) (setq compilation-error-regexp-alist (remove 'omake compilation-error-regexp-alist)) ;; (add-hook 'compilation-mode-hook #'visual-line-mode) #+end_src ***** Mode line (no "Compiling"!) #+BEGIN_SRC emacs-lisp (require 'compile) (diminish 'compilation-minor-mode " ‡") (when (< emacs-major-version 27) (setcdr (assq 'compilation-in-progress minor-mode-alist) '(" ‡"))) (when (> emacs-major-version 26) (setcdr (assq 'compilation-in-progress mode-line-modes) '("‡ "))) #+END_SRC ***** Colorizing compilation buffer #+BEGIN_SRC emacs-lisp (require 'ansi-color) (defun endless/colorize-compilation () "Colorize from `compilation-filter-start' to `point'." (let ((inhibit-read-only t)) (ansi-color-apply-on-region compilation-filter-start (point)))) (add-hook 'compilation-filter-hook #'endless/colorize-compilation) #+END_SRC ***** Compilation commands #+begin_src emacs-lisp (use-package jao-compilation :commands jao-compilation-setup :bind (("C-c C" . compile) ("C-c c" . jao-compile))) (jao-compilation-setup) #+end_src ***** Next error #+begin_src emacs-lisp (setq next-error-find-buffer-function #'next-error-buffer-on-selected-frame next-error-verbose t) #+end_src *** Flymake #+begin_src emacs-lisp (use-package flymake :ensure t :custom ((flymake-mode-line-format '(" " flymake-mode-line-counters))) :hook ((haskell-mode . flymake-mode)) :config (jao-define-attached-buffer "^\\*Flymake diagnostics .*\\*\\'") :bind (:map flymake-mode-map (("s-f n" . flymake-goto-next-error) ("s-f p" . flymake-goto-prev-error) ("s-f i" . flymake-show-diagnostic) ("s-f f" . flymake-show-diagnostics-buffer) ("s-f l" . consult-flymake)))) #+end_src * Programming languages *** Elisp ***** Functions to operate on elisp sexps a la slime or geiser #+begin_src emacs-lisp (defun elisp-disassemble (function) (interactive (list (function-called-at-point))) (disassemble function)) (defun elisp-pp (sexp) (with-output-to-temp-buffer "*Pp Eval Output*" (pp sexp) (with-current-buffer standard-output (emacs-lisp-mode)))) (defun elisp-macroexpand (form) (interactive (list (form-at-point 'sexp))) (elisp-pp (macroexpand form))) (defun elisp-macroexpand-all (form) (interactive (list (form-at-point 'sexp))) (elisp-pp (cl-macroexpand-all form))) (defun elisp-push-point-marker () (require 'etags) (cond ((featurep 'xemacs) (push-tag-mark)) (t (ring-insert find-tag-marker-ring (point-marker))))) (defun elisp-pop-found-function () (interactive) (cond ((featurep 'xemacs) (pop-tag-mark nil)) (t (pop-tag-mark)))) (defun elisp-find-definition (name) "Jump to the definition of the function (or variable) at point." (interactive (list (thing-at-point 'symbol))) (cond (name (let ((symbol (intern-soft name)) (search (lambda (fun sym) (let* ((r (save-excursion (funcall fun sym))) (buffer (car r)) (point (cdr r))) (cond ((not point) (error "Found no definition for %s in %s" name buffer)) (t (switch-to-buffer buffer) (goto-char point) (recenter 1))))))) (cond ((fboundp symbol) (elisp-push-point-marker) (funcall search 'find-function-noselect symbol)) ((boundp symbol) (elisp-push-point-marker) (funcall search 'find-variable-noselect symbol)) (t (message "Symbol not bound: %S" symbol))))) (t (message "No symbol at point")))) (defun elisp-bytecompile-and-load () (interactive) (or buffer-file-name (error "The buffer must be saved in a file first")) (require 'bytecomp) ;; Recompile if file or buffer has changed since last compilation. (when (and (buffer-modified-p) (y-or-n-p (format "save buffer %s first? " (buffer-name)))) (save-buffer)) (let ((filename (expand-file-name buffer-file-name))) (with-temp-buffer (byte-compile-file filename t)))) #+end_src Bindinging the functions above to "natural" keys in elisp buffers: #+begin_src emacs-lisp (defvar elisp-extra-keys '( ;; ((kbd "C-c d") 'elisp-disassemble) ((kbd "C-c C-m") 'elisp-macroexpand) ((kbd "C-c C-M") 'elisp-macroexpand-all) ((kbd "C-c C-c") 'compile-defun) ((kbd "C-c C-k") 'elisp-bytecompile-and-load) ((kbd "C-c C-l") 'load-file) ((kbd "C-c C-p") 'pp-eval-last-sexp) ((kbd "M-.") 'elisp-find-definition) ((kbd "M-,") 'elisp-pop-found-function) ((kbd "C-c <") 'list-callers))) (dolist (binding elisp-extra-keys) (let ((key (eval (car binding))) (val (eval (cadr binding)))) (define-key emacs-lisp-mode-map key val) (define-key lisp-interaction-mode-map key val))) #+end_src ***** Literate elisp #+begin_src emacs-lisp (use-package poly-org :ensure t) ;; (use-package org-auto-tangle ;; :ensure t ;; :hook (org-mode . org-auto-tangle-mode) ;; :diminish) #+end_src ***** Some helper packages #+begin_SRC emacs-lisp (use-package edit-list :ensure t) (use-package package-lint :ensure t) #+end_SRC *** Erlang #+begin_src emacs-lisp (use-package erlang :ensure t :custom ((inferior-erlang-machine-options '("shell")) (inferior-erlang-machine "rebar3") (inferior-erlang-shell-type nil) (erlang-indent-level 4)) ;; :bind (:map erlang-mode-map (("C-c C-z" . jao-vterm-repl-pop-to-repl))) :init ;; (require 'jao-vterm-repl) ;; (add-to-list 'auto-mode-alist '("^rebar\\.config\\`" . erlang-mode)) ;; (jao-vterm-repl-register "rebar.config" "rebar3 shell" "^[0-9]+> ") :config ;; (defun jao-erlang-current-module () ;; (when (save-excursion (goto-char (point-min)) ;; (re-search-forward "^-module(\\([^)]+\\))" nil t)) ;; (match-string-no-properties 1))) ;; (defun jao-erlang-compile (arg) ;; (interactive "P") ;; (save-some-buffers) ;; (when-let ((mname (jao-erlang-current-module))) ;; (with-current-buffer (jao-vterm-repl) ;; (vterm-send-string (format "c(%s).\n" mname)) ;; (sit-for 0) ;; (setq compilation-last-buffer (current-buffer)) ;; (when arg (jao-vterm-repl-pop-to-repl))))) ;; (setq erlang-shell-function #'jao-vterm-repl ;; erlang-shell-display-function #'jao-vterm-repl-pop-to-repl ;; erlang-compile-function #'jao-erlang-compile) ) #+end_src *** Idris #+begin_src emacs-lisp :tangle no (use-package idris-mode :ensure t :custom ((idris-interpreter-path "idris2") (idris-pretty-printer-width 80) (idris-repl-history-file "~/.emacs.d/cache/idris-history.eld") (idris-stay-in-current-window-on-compiler-error t))) (jao-define-attached-buffer "^\\*idris.*" 0.4) #+end_src *** Clojure #+begin_src emacs-lisp (use-package clojure-mode :ensure t :config (defun jao-clojure--fix-things () (setq-local completion-styles '(basic partial-completion emacs22)) (eldoc-mode 1) (setq mode-name "λ")) :hook (clojure-mode . jao-clojure--fix-things)) (use-package cider :ensure t :commands cider-mode :init (setq cider-annotate-completion-candidates t cider-auto-select-error-buffer nil clojure-docstring-fill-column 72 cider-show-error-buffer 'except-in-repl cider-lein-parameters "repl :headless :host localhost" cider-mode-line " ÷" cider-prompt-for-symbol nil cider-repl-pop-to-buffer-on-connect nil cider-repl-history-file (expand-file-name "~/.emacs.d/cache/cider.history") cider-repl-use-pretty-printing t cider-test-show-report-on-success nil cider-auto-select-test-report-buffer nil cider-use-overlays nil cider-use-fringe-indicators nil cider-eldoc-display-for-symbol-at-point t nrepl-prompt-to-kill-server-buffer-on-quit nil)) (with-eval-after-load "cider-test" (advice-add 'cider-scale-background-color :override (lambda () (frame-parameter nil 'background-color))) (setq cider-test-items-background-color (frame-parameter nil 'background-color))) (use-package cider-macroexpansion :after cider :diminish " µ") #+end_src *** Geiser #+begin_src emacs-lisp (defun jao-org--set-geiser-impl () (setq-local geiser-repl--impl 'guile)) (add-hook 'org-mode-hook #'jao-org--set-geiser-impl) (jao-load-path "geiser/geiser/elisp") (use-package geiser :init (setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history") (setq geiser-repl-startup-time 20000) (setq geiser-debug-auto-display-images-p t)) (jao-load-path "geiser/mit") (use-package geiser-mit) ;; (jao-load-path "geiser/chicken") ;; (use-package geiser-chicken) ;; (jao-load-path "geiser/chibi") ;; (use-package geiser-chibi) (jao-load-path "geiser/guile") (use-package geiser-guile) (jao-load-path "geiser/chez") (use-package geiser-chez :init (setq geiser-chez-binary "scheme")) (jao-load-path "geiser/gambit") (use-package geiser-gambit) #+end_src *** Pie #+begin_src emacs-lisp (jao-load-path "pie") (use-package pie :demand t :commands (pie-mode)) #+end_src *** Lisp #+begin_src emacs-lisp :tangle no (use-package sly :ensure t :init (setq inferior-lisp-program "sbcl") :config (sly-setup)) (use-package sly-quicklisp :after (sly) :ensure t) #+end_src *** Haskell ***** packages #+begin_src emacs-lisp (use-package haskell-mode :ensure t :custom ((inferior-haskell-find-project-root t) (haskell-check-remember-last-command-p nil) (haskell-font-lock-symbols nil) (haskell-interactive-popup-errors nil) (haskell-process-auto-import-loaded-modules t) (haskell-process-log t) (haskell-process-suggest-remove-import-lines t) (haskell-process-suggest-hoogle-imports t) (haskell-process-type 'cabal-repl) (haskell-process-use-presentation-mode t) (haskell-stylish-on-save nil)) :config (defun jao-haskell-hoogle (query) (interactive (hoogle-prompt)) (haskell-hoogle query t)) (put 'haskell-process-args-cabal-repl 'safe-local-variable (apply-partially #'seq-every-p #'stringp)) (require 'haskell-doc) (dolist (h '(interactive-haskell-mode haskell-doc-mode haskell-decl-scan-mode haskell-indentation-mode haskell-auto-insert-module-template)) (add-hook 'haskell-mode-hook h)) :bind (:map haskell-mode-map (("C-c C-d" . jao-haskell-hoogle) ("C-c h" . haskell-hoogle-lookup-from-local) ("C-c C-c" . haskell-compile)))) (require 'haskell) (diminish 'interactive-haskell-mode " λ") (diminish haskell-doc-mode) (diminish haskell-decl-scan-mode) (jao-define-attached-buffer "\\*hoogle\\*.*") ;; needs cabal install apply-refact (use-package hlint-refactor :ensure t :after (haskell-mode) :diminish "" :hook (haskell-mode . hlint-refactor-mode)) #+end_src ***** hydra #+begin_src emacs-lisp (major-mode-hydra-define haskell-mode nil ("Imports" (("in" haskell-navigate-imports "Navigate imports") ("if" haskell-mode-format-imports "Format imports") ("is" haskell-sort-imports "Sort imports") ("ia" haskell-align-imports "Align imports")) "Code" (("c" haskell-compile "Compile") ("s" haskell-mode-stylish-buffer "stylish on buffer")) "Hoogle" (("h" jao-haskell-hoogle "Hoogle") ("H" haskell-hoogle-lookup-from-local "Hoogle from local server")))) #+end_src *** Prolog #+BEGIN_SRC emacs-lisp (use-package ediprolog :ensure t) (use-package prolog :ensure t :commands (run-prolog prolog-mode mercury-mode) :init (progn (setq prolog-system 'swi) (add-to-list 'auto-mode-alist '("\\.pl$" . prolog-mode)) (setq prolog-consult-string '((t "[%f]."))) (setq prolog-program-name '(((getenv "EPROLOG") (eval (getenv "EPROLOG"))) (eclipse "eclipse") (mercury nil) (sicstus "sicstus") (swi "swipl") (t "prolog"))))) #+END_SRC *** Python ***** Virtual envs (with eshell support) See also [[https://github.com/porterjamesj/virtualenvwrapper.el][the docs]]. #+begin_src emacs-lisp (use-package virtualenvwrapper :ensure t :config (venv-initialize-eshell) (jao-compilation-env "VIRTUAL_ENV")) #+end_src *** JSON #+BEGIN_SRC emacs-lisp (use-package json-mode :ensure t) ;; (use-package json-navigator :ensure nil) #+END_SRC * Graphics *** Images #+begin_src emacs-lisp (setq image-use-external-converter t) #+end_src *** Gnuplot #+BEGIN_SRC emacs-lisp (use-package gnuplot :ensure t :commands (gnuplot-mode gnuplot-make-buffer) :init (add-to-list 'auto-mode-alist '("\\.gp$" . gnuplot-mode))) #+END_SRC * Network *** network monitor #+begin_src emacs-lisp (jao-def-exec jao-nm-applet "nm-applet") (defun jao-toggle-nm-applet () (interactive) (if (string-empty-p (jao-exec-string "pidof nm-applet")) (jao-nm-applet) (jao-exec-string "killall nm-applet"))) #+end_src *** Bluetooth #+BEGIN_SRC emacs-lisp (use-package bluetooth :ensure t) #+END_SRC *** Proton #+BEGIN_SRC emacs-lisp (require 'jao-proton-utils) (defalias 'proton-vpn 'proton-vpn-status) #+END_SRC *** ssh #+begin_src emacs-lisp (use-package tramp) (defun jao-tramp-hosts () (remove-duplicates (mapcan (lambda (x) (remove* nil (mapcar 'cadr (apply (car x) (cdr x))))) (tramp-get-completion-function "ssh")) :test #'string=)) (defun jao-ssh () (interactive) (let ((h (completing-read "Host: " (jao-tramp-hosts)))) (jao-exec-in-term (format "ssh %s" h) (format "* ssh %s *" h)))) #+end_src * Chats *** circe #+begin_src emacs-lisp (defvar jao-libera-channels '()) (defvar jao-oftc-channels '()) (defvar jao-bitlbee-channels '()) (use-package circe :ensure t :bind (:map circe-channel-mode-map (("C-c C-a" . lui-track-jump-to-indicator))) :init (setq circe-chat-buffer-name "{target}" circe-default-realname "https://jao.io" circe-default-part-message "" circe-default-quit-message "" circe-ignore-list nil circe-server-coding-system '(undecided . undecided) circe-server-killed-confirmation 'ask-and-kill-all circe-server-auto-join-default-type :after-auth circe-format-say "({nick}) {body}" circe-format-self-say "(jao) {body}" circe-new-buffer-behavior 'ignore circe-new-buffer-behavior-ignore-auto-joins t circe-nickserv-ghost-style 'after-auth circe-prompt-string ": " circe-completion-suffix ", " circe-reduce-lurker-spam t circe-nick-next-function (lambda (old) (replace-regexp-in-string "-" "`" (circe-nick-next old))) circe-lagmon-mode-line-format-string "" ;; "%.0f " circe-lagmon-mode-line-unknown-lag-string "" ;; "? " circe-lagmon-timer-tick 120 circe-lagmon-reconnect-interval 180 lui-max-buffer-size 30000 lui-fill-column 80 lui-time-stamp-position 'right lui-time-stamp-format "%H:%M" lui-flyspell-p nil lui-track-indicator 'fringe lui-track-behavior 'before-tracking-next-buffer) :config (defun circe-command-RECOVER (&rest ignore) "Recover nick" (let* ((fn (jao--get-user/password "freenode")) (u (car fn)) (p (cadr fn))) (circe-command-MSG "nickserv" (format "IDENTIFY %s %s" u p)) (circe-command-MSG "nickserv" (format "GHOST %s" u)) (circe-command-MSG "nickserv" (format "RELEASE %s" u)) (circe-command-NICK u))) (setq circe-network-options (let ((up (jao--get-user/password "libera")) (oup (jao--get-user/password "oftc")) (bup (jao--get-user/password "bitlbee"))) `(("Libera Chat" :nick ,(car up) :channels ,jao-libera-channels :tls t :sasl-username ,(car up) :sasl-password ,(cadr up)) ("OFTC" :nick ,(car oup) :channels ,jao-oftc-channels :nickserv-password ,(cadr oup) :tls t :sasl-username ,(car oup) :sasl-password ,(cadr oup)) ("Bitlbee" :host "127.0.0.1" :nick ,(car bup) :channels ,jao-bitlbee-channels :lagmon-disabled t :nickserv-password ,(cadr bup) :user ,(car bup))))) (jao-shorten-modes 'circe-channel-mode 'circe-server-mode 'circe-query-mode) (enable-lui-track) (circe-lagmon-mode) (enable-circe-display-images)) #+end_src *** slack [[https://github.com/jackellenberger/emojme#finding-a-slack-token][How to get a token]]: It's easyish! Open and sign into the slack customization page, e.g. https://my.slack.com/customize, right click anywhere > inspect element. Open the console and paste: =window.prompt("your api token is: ", TS.boot_data.api_token)= Lately things are iffy. We've needed to add the ~:override~ to slack-counts update, and it might be needed to replace ~slack-conversations-view~ by ~slack-conversations-history~ #+begin_src emacs-lisp (use-package slack :commands (slack-start) :init (setq slack-alert-icon (jao-data-file "slack.svg") slack-buffer-emojify nil slack-buffer-create-on-notify t slack-display-team-name t slack-typing-visibility 'never ;; 'buffer, 'frame slack-profile-image-file-directory "/tmp/slack-imgs/" slack-image-file-directory "/tmp/slack-imgs/" slack-file-dir "/tmp/slack-files/" slack-prefer-current-team t slack-message-tracking-faces '(warning) slack-log-level 'warn slack-message-custom-notifier (lambda (msg room team) room)) :bind (:map slack-mode-map (("@" . slack-message-embed-mention) ("#" . slack-message-embed-channel))) :config (dolist (f (list slack-file-dir slack-image-file-directory)) (when (not (file-exists-p f)) (make-directory f))) (jao-shorten-modes 'slack-message-buffer-mode 'slack-thread-message-buffer-mode) (jao-tracking-faces 'warning)) #+end_src *** telegram #+begin_src emacs-lisp (use-package telega :ensure t :custom (telega-use-tracking-for '(unmuted) ;; '(or unmuted mention) telega-rainbow-color-custom-for nil telega-msg-rainbow-title nil telega-sticker-set-download t) :config (define-key global-map (kbd "C-c C-t") telega-prefix-map) (setq telega-chat-show-avatars nil telega-root-show-avatars nil telega-chat-prompt-show-avatar-for nil telega-emoji-use-images nil telega-temp-dir "/tmp/telega" telega-symbol-checkmark "·" telega-symbol-heavy-checkmark "×" telega-symbol-verified "*" telega-mode-line-string-format '(:eval (telega-mode-line-unread-unmuted))) (with-eval-after-load "tracking" (jao-shorten-modes 'telega-chat-mode) (jao-tracking-faces 'telega-tracking)) (telega-mode-line-mode 1)) #+end_src *** signel #+begin_src emacs-lisp (jao-load-org "lib/net/signel.org") (with-eval-after-load "tracking" (jao-tracking-faces 'signel-notification) (jao-shorten-modes 'signel-chat-mode)) (setq signel-report-deliveries t) #+end_src *** startup #+begin_src emacs-lisp (defun jao-chats (&optional p) (interactive "P") (when (or p (y-or-n-p "Connect to slack? ")) (slack-start)) (when (or p (y-or-n-p "Connect to telegram? ")) (telega)) (when (or p (y-or-n-p "Connect to libera? ")) (circe "Libera Chat"))) (pretty-hydra-define jao-hydra-chats (global-map "s-q" :color blue :quit-key "q") ("Connect" (("A" (jao-chats t) "all chats -y") ("a" jao-chats "all chats") ("S" slack-start "slack") ("g" signel-start "signal") ("e" (jao-erc t) "erc -y") ("s-q" jao-hydra-chats/body nil)) "Go" (("i" (jao-buffer-same-mode 'erc-mode) "irc") ("s" (jao-buffer-same-mode 'slack-message-buffer-mode) "slack buffer") ("t" (jao-buffer-same-mode 'telega-chat-mode) "telega buffer") ("T" telega "telega rooster")))) (global-set-key (kbd "H-s-q") #'jao-hydra-chats/body) #+end_src * Multimedia *** mixer #+begin_src emacs-lisp (defun jao-mixer-get-level (dev) (let* ((s (shell-command-to-string (format "amixer sget %s" dev))) (s (car (last (split-string s "\n" t))))) (when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s) (let ((level (match-string 1 s))) (message "%s level: %s%%" dev level) (string-to-number level))))) (defun jao-mixer-set (dev v) (jao-exec-string "amixer sset %s %s" dev v) (jao-mixer-get-level dev)) (defun jao-mixer-master-toggle () (interactive) (jao-mixer-set "Master" "toggle")) (defun jao-mixer-master-up () (interactive) (jao-mixer-set "Master" "10%+")) (defun jao-mixer-master-down () (interactive) (jao-mixer-set "Master" "10%-")) (defun jao-mixer-capture-up () (interactive) (jao-mixer-set "Capture" "10%+")) (defun jao-mixer-capture-down () (interactive) (jao-mixer-set "Capture" "10%-")) (jao-def-exec jao-audio-applet "pasystray") (defun jao-toggle-audio-applet () (interactive) (if (string-empty-p (jao-exec-string "pidof pasystray")) (jao-audio-applet) (jao-exec-string "killall pasystray"))) (global-set-key (kbd "") #'jao-toggle-audio-applet) #+end_src *** spotify Access to spotify uses packages tangled from [[./lib/media/espotify.org][espotify.org]], which offers functionality tailored to the completion engines at hand: #+begin_src emacs-lisp (jao-load-path "espotify") (use-package espotify :demand t) (use-package consult-spotify :demand t) (defalias 'jao-spotify-album #'consult-spotify-album) (defalias 'jao-spotify-track #'consult-spotify-track) (defalias 'jao-spotify-artist #'consult-spotify-artist) (defalias 'jao-spotify-playlist #'consult-spotify-playlist) #+end_src *** mpc #+begin_src emacs-lisp (use-package jao-mpc :demand t :commands jao-mpc-setup) (defvar jao-mopidy-port 6669) (jao-mpc-setup jao-mopidy-port) (defun jao-mpc-pport () (when (jao-mpc--playing-p jao-mopidy-port) jao-mopidy-port)) (defmacro jao-defun-play (name &optional mpc-name) `(defun ,(intern (format "jao-player-%s" name)) () (interactive) (,(intern (format "jao-mpc-%s" (or mpc-name name))) (jao-mpc-pport)))) (jao-defun-play toggle) (jao-defun-play next) (jao-defun-play previous) (jao-defun-play stop) (jao-defun-play echo echo-current) (jao-defun-play list show-playlist) (jao-defun-play info lyrics-track-data) (defun jao-player-seek (delta) (jao-mpc-seek delta (jao-mpc-pport))) (defalias 'jao-player-browse 'jao-mpc-show-albums) (defalias 'jao-player-connect 'jao-mpc-connect) (defalias 'jao-player-play 'jao-mpc-play) #+end_src *** hydras #+begin_src emacs-lisp (require 'jao-lyrics) (setq jao-lyrics-info-function #'jao-player-info) (defun jao-player-volume-delta (raise) (jao-player-vol-delta (if raise 5 -5)) (sit-for 0.05) (jao-player-show-volume)) (defun jao-player-volume-raise () (interactive) (jao-player-volume-delta t)) (defun jao-player-volume-lower () (interactive) (jao-player-volume-delta nil)) (defun jao-player-show-volume () (interactive) (jao-notify "Volume" (format "%s%%" (jao-player-volume)))) (use-package jao-random-album :demand t) (pretty-hydra-define jao-hydra-spotify (global-map "s-s" :color blue :quit-key "q") ("Search" (("a" jao-spotify-album "album") ("A" jao-spotify-artist "artist") ("t" jao-spotify-track "track") ("P" jao-spotify-playlist "playlist")) "Play" (("s" espotify-play-pause "toggle") ("n" espotify-next "next") ("p" espotify-previous "previous") ("f" (jao-mpc-seek 10 jao-mopidy-port) "seek fwd" :color red) ("F" (jao-mpc-seek -10 jao-mopidy-port) "seek bwd" :color red)) "Browse" (("l" (jao-mpc-show-playlist jao-mopidy-port) "playing list") ("c" (jao-mpc-clear jao-mopidy-port) "clear list" :color red) ("w" (jao-mpc-echo-current jao-mopidy-port) "currently playing") ("s-s" jao-hydra-spotify/body nil)))) (pretty-hydra-define jao-hydra-media (global-map "s-m" :color blue :quit-key "q") ("Play" (("m" jao-player-toggle "toggle") ("n" jao-player-next "next") ("p" jao-player-previous "previous") ("s" (espotify-play-pause) "toggle spotify")) "Seek and search" (("f" (jao-player-seek 10) "seek fwd" :color red) ("F" (jao-player-seek -10) "seek bwd" :color red) ("a" jao-mpc-select-album "select album")) "Browse" (("b" jao-player-browse "browse") ("l" jao-player-list "show play list") ("L" jao-show-lyrics "show lyrics") ("w" jao-player-echo "now playing (text)")) "Master volume" (("d" jao-mixer-master-down "master down" :color red) ("u" jao-mixer-master-up "master up" :color red) ("M" jao-mixer-master-toggle "master toggle") ("v" (jao-mixer-get-level "Master") "show")) "Capture volume" (("D" jao-mixer-capture-down "capture down" :color red) ("U" jao-mixer-capture-up "capture up" :color red) ("V" (jao-mixer-get-level "Capture") "show")) "Utilities" (("c" jao-player-connect "reconnect to mpd") ("N" jao-random-album-next "next random album") ("r" jao-random-album-toggle "toggle random album" :toggle jao-random-album-p) ("s-m" jao-hydra-media/body nil)))) #+end_src * Key bindings #+begin_src emacs-lisp (global-set-key "\C-cj" #'join-line) (global-set-key "\C-cq" #'auto-fill-mode) (global-set-key "\C-xr\M-w" #'kill-rectangle-save) (global-set-key "\C-c\C-z" #'comment-or-uncomment-region) (global-set-key "\C-z" #'comment-or-uncomment-region) (pretty-hydra-define jao-hydra-emacs-utils (global-map "s-w" :color blue :quit-key "q") ("Notes" (("n" jao-org-notes-open-or-create "capture note") ("N" jao-org-notes-open "go to note")) "Docs" (("d" (jao-buffer-same-mode '(pdf-view-mode docview-mode) #'jao-afio--goto-docs) "go to doc") ("D" jao-open-doc "open to doc")) "Packages" (("a" jao-term-aptitude "aptitude") ("l" list-packages "packages") ("s-w" jao-hydra-emacs-utils/body nil)) "Network" (("S" jao-ssh "ssh") ("T" telega "telegram rooster") ("m" run-proton-bridge "proton bridge") ("v" jao-exwm-proton-vpn "proton vpn") ("c" (jao-chats t) "connect chats")) "Monitors" (("p" jao-term-htop "htop") ("b" jao-exwm-bluetooth "bluetooth") ;; ("P" jao-exwm-proced "proced") ("x" jao-exwm-xmobar "restart xmobar") ;; ("X" jao-exwm-kill-xmobar "kill xmobar") ;; ("t" jao-time-echo-times "current time") ) "Chats" (("t" (jao-buffer-same-mode 'telega-chat-mode) "telegram buffers") ("s" (jao-buffer-same-mode 'slack-message-buffer-mode) "slack buffers") ("i" (jao-buffer-same-mode '(circe-channel-mode erc-mode)) "irc channels")) "Looks" (;; ("T" jao-toggle-transparency "toggle transparency" ;; :toggle (jao-transparent-p) :color red) ("w" jao-set-wallpaper "set wallpaper") ("W" jao-set-random-wallpaper "set radom wallpaper")) "Helpers" (("r" org-reveal "org reveal") ("k" jao-kb-toggle "toggle keyboard" :toggle (jao-kb-toggled-p) :color red) ("M" jao-minibuffer-toggle "toggle minibuffer" :toggle jao-minibuffer-enabled-p)))) #+end_src * Last minute (post.el) #+begin_src emacs-lisp (jao-load-site-el "post") #+end_src