diff options
| author | Thomas Ulmer <thomasmulmer02@gmail.com> | 2026-02-04 14:24:16 -0800 |
|---|---|---|
| committer | Thomas Ulmer <thomasmulmer02@gmail.com> | 2026-02-04 14:24:16 -0800 |
| commit | 9139a1b136fa2b5adfcac0ac09a4f61aa1ee1ff4 (patch) | |
| tree | de82bc4776b87f1fbb86f14b4a15d35d009ddd28 /config/emacs/site-lisp | |
| parent | a9bf8f30c746f5b28bb7eb6938e8390127081a32 (diff) | |
full reorg
Diffstat (limited to 'config/emacs/site-lisp')
| -rw-r--r-- | config/emacs/site-lisp/chinese.el | 18 | ||||
| -rw-r--r-- | config/emacs/site-lisp/fbterm.el | 13 | ||||
| -rw-r--r-- | config/emacs/site-lisp/maze.el | 64 | ||||
| -rw-r--r-- | config/emacs/site-lisp/my-eglot.el | 7 | ||||
| -rw-r--r-- | config/emacs/site-lisp/my-exwm.el | 184 | ||||
| -rw-r--r-- | config/emacs/site-lisp/my-mail.el | 52 | ||||
| -rw-r--r-- | config/emacs/site-lisp/my-modal.el | 212 | ||||
| -rwxr-xr-x | config/emacs/site-lisp/single-header.el | 257 | ||||
| -rw-r--r-- | config/emacs/site-lisp/tex-conf.el | 47 | ||||
| -rwxr-xr-x | config/emacs/site-lisp/tmu-custom-theme.el | 67 |
10 files changed, 921 insertions, 0 deletions
diff --git a/config/emacs/site-lisp/chinese.el b/config/emacs/site-lisp/chinese.el new file mode 100644 index 0000000..4b01594 --- /dev/null +++ b/config/emacs/site-lisp/chinese.el @@ -0,0 +1,18 @@ +;; chinese input stuff +;; (require 'unicode-fonts) +;; (unicode-fonts-setup) +(require 'pyim) +(require 'pyim-basedict) +(pyim-basedict-enable) +;; (require 'pyim-wbdict) +(setq default-input-method "pyim") +(setq pyim-default-scheme 'quanpin) +;; (pyim-wbdict-v98-morphe-enable) +;; (dolist (charset '(kana han symbol cjk-misc bopomofo)) +;; (set-fontset-font (frame-parameter nil 'font) +;; charset +;; (font-spec :family "FangSong" :size 15))) +;; (setq rime-translate-keybindings +;; '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>")) +;; (setq rime-share-data-dir "~/.local/share/fcitx5/rime") +;; (setq rime-show-candidate 'popup) diff --git a/config/emacs/site-lisp/fbterm.el b/config/emacs/site-lisp/fbterm.el new file mode 100644 index 0000000..b8b3ba4 --- /dev/null +++ b/config/emacs/site-lisp/fbterm.el @@ -0,0 +1,13 @@ +;; config specifically for running emacs as the base process of fbterm + + +(require 'ednc) +(require 'single-header) + +;;; Code: + +(unless ednc-mode (ednc-mode 1)) +(unless single-header-mode (single-header-mode 1)) + +(provide 'fbterm) +;;; fbterm.el ends here diff --git a/config/emacs/site-lisp/maze.el b/config/emacs/site-lisp/maze.el new file mode 100644 index 0000000..784049f --- /dev/null +++ b/config/emacs/site-lisp/maze.el @@ -0,0 +1,64 @@ +;; [adj] movement and editing for lisp + +(provide 'maze-lisp) + +(defun maze--cur-end () + (push-mark) + (thing-at-point--end-of-sexp) + (let ((cur (point))) + (goto-char (mark)) + (pop-mark) + cur)) + +(defun maze--hl (beg end &optional buffer) + (let ((overlay (make-overlay beg end (or buffer (current-buffer))))) + (overlay-put overlay 'face 'highlight) + (setq maze-overlay overlay) + overlay)) + +(defun maze--unhl () + (if maze-overlay + (delete-overlay maze-overlay))) + +(defun maze--update-hl (beg end) + (if maze-overlay + (move-overlay maze-overlay beg end) + (maze--hl beg end))) + +(defun maze-forward (n) + (interactive "p") + (goto-char (or (scan-sexps (point) 2) (buffer-end 1))) + (thing-at-point--beginning-of-sexp) + (maze--update-hl (point) (maze--cur-end))) + +(defun maze-backward (n) + (interactive "p") + (let ((n (or n 1))) + (backward-sexp n)) + (maze--update-hl (point) (maze--cur-end))) + +(defun maze-inward (n) + (interactive "p") + (down-list n) + (maze--update-hl (point) (maze--cur-end))) + +(defun maze-outward (n) + (interactive "p") + (backward-up-list n) + (maze--update-hl (point) (maze--cur-end))) + +(defvar-keymap maze-mode-map + (kbd "j") 'maze-forward + (kbd "k") 'maze-backward + (kbd "l") 'maze-inward + (kbd "h") 'maze-outward) + + +(define-minor-mode maze-mode + "doc" + :keymap maze-mode-map + :init-value nil + :after-hook (progn + (setq-local parse-sexp-ignore-comments t) + (setq-local maze-overlay nil) + (font-lock-mode 1))) diff --git a/config/emacs/site-lisp/my-eglot.el b/config/emacs/site-lisp/my-eglot.el new file mode 100644 index 0000000..f4a00a3 --- /dev/null +++ b/config/emacs/site-lisp/my-eglot.el @@ -0,0 +1,7 @@ +(use-package eglot + :demand t) +(use-package eglot-tempel + :after eglot tempel + :config + (eglot-tempel-mode 1)) + diff --git a/config/emacs/site-lisp/my-exwm.el b/config/emacs/site-lisp/my-exwm.el new file mode 100644 index 0000000..be71f52 --- /dev/null +++ b/config/emacs/site-lisp/my-exwm.el @@ -0,0 +1,184 @@ +(use-package exwm ; emacs x window manager + :demand nil + :config + (require 'exwm-randr) + (require 'exwm-xim) + (require 'exwm-systemtray) + (require 'exwm-manage) + (add-to-list 'exwm-manage-configurations '((equal exwm-class-name "Slack") managed t)) + (use-package exwm-modeline) + ;;(exwm-xim-mode 1) + + (defun my/exwm-auto-workspace-montior () + "Autopopulate exwm-randr-workspace-monitor-plist and attempt to +have a workspace on each monitor. Try to keep up with xrandr +changes." + (let ((buf (generate-new-buffer "*xrandr-output*")) + (out-plist nil)) + (call-process-shell-command "xrandr --listmonitors -q" nil buf nil) + (with-current-buffer buf + (keep-lines "[^[:word:]]connected" (point-min) (point-max) nil) + ;; (goto-char (point-min)) + ;; (while (re-search-forward "^\\([a-zA-Z\\-0-9]+\\) .*$" nil t nil) + ;; (replace-match "\\1")) + ;; (goto-char (point-min)) + (let ((num-monitors (count-lines (point-min) (point-max))) + (i 0)) + (setq exwm-workspace-number num-monitors) + (goto-char (point-min)) + (while (< i num-monitors) + (move-beginning-of-line 1) + (push-mark) + (search-forward-regexp " ") + (backward-char) + (push (buffer-substring (mark) (point)) out-plist) + (if (> i 0) + (let ((prev (caddr out-plist)) + (cur (car out-plist))) + (call-process-shell-command + (format "xrandr --output %s --auto --right-of %s" cur prev) + nil nil nil)) + (call-process-shell-command + (format "xrandr --output %s --auto" (car out-plist)) nil nil nil)) + (push i out-plist) + (setq i (+ i 1)) + (pop-mark) + (forward-line)))) + (kill-buffer buf) + (setq exwm-randr-workspace-monitor-plist out-plist)) + (while (> exwm-workspace-number (length exwm-workspace--list)) + (exwm-workspace-add))) + (add-hook 'exwm-randr-screen-change-hook #'my/exwm-auto-workspace-montior) + + (defun my/exwm-set-buffer-name () + (if exwm-title + (let* ((shortened-title (replace-regexp-in-string + " - Mozilla Firefox" + "" + exwm-title)) + (class-and-title (concat + exwm-class-name + "<" + shortened-title + ">"))) + (setq-local exwm-title class-and-title) + (exwm-workspace-rename-buffer exwm-title)))) + + (defun my/exwm-other-workspace (arg) + "Focus other monitor's workspace." + (interactive "p") + ;; based on other-frame + (let ((filter-f (function (lambda (f) + (and (exwm-workspace--active-p f) + (not (eq (selected-frame) f)))))) + (sframe (selected-frame)) + (frame (selected-frame))) + (while (> arg 0) + (setq frame (next-frame frame)) + (while (and (not (eq frame sframe)) + (not (eq (frame-visible-p frame) t)) + (funcall filter-f frame)) + (setq frame (next-frame frame))) + (setq arg (1- arg))) + (while (< arg 0) + (setq frame (previous-frame frame)) + (while (and (not (eq frame sframe)) + (not (eq (frame-visible-p frame) t)) + (filter-f frame)) + (setq frame (previous-frame frame))) + (setq arg (1+ arg))) + (exwm-workspace-switch frame))) + + (defun my/dmenu (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command)) + + (defun my/browser () + (interactive) + (start-process-shell-command "glide" nil "glide")) + + (defun my/brightnessdown () (interactive) (start-process "" nil "brightnessdown")) + (defun my/brightnessup () (interactive) (start-process "" nil "brightnessup")) + (defun my/mute () (interactive) (start-process "" nil "pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle")) + (defun my/voldown () (interactive) (start-process "" nil "pactl" "set-sink-volume" "@DEFAULT_SINK@" "-5%")) + (defun my/volup () (interactive) (start-process "" nil "pactl" "set-sink-volume" "@DEFAULT_SINK@" "+5%")) + + (push ?\C-\\ exwm-input-prefix-keys) ;;C-\ to switch input method + (push ?\C-u exwm-input-prefix-keys) ;; send C-u to all windows too + (push ?\M-L exwm-input-prefix-keys) + (progn + ;; (exwm-enable) + ;; (exwm-randr-mode) + ;; (ednc-mode 1) + ;; (exwm-systemtray-mode) + ;; (add-hook 'after-init-hook #'exwm-randr-refresh) + ) + :hook + (exwm-update-class . my/exwm-set-buffer-name) + (exwm-update-title . my/exwm-set-buffer-name) + ;; (after-init . exwm-randr-refresh) + ;; (after-init . display-time-mode) + ;; (after-init . ednc-mode) + ;; (after-init . display-battery-mode) + :custom + (exwm-replace nil) + (exwm-title-length 50) + (exwm-workspace-show-all-buffers t) + (exwm-layout-show-all-buffers t) + + (exwm-modeline-randr t) + (exwm-modeline-short nil) + (exwm-modeline-urgent t) + + (exwm-manage-force-tiling t) + + (exwm-input-global-keys + `( + ([?\M-r] . exwm-reset) + ;; Bind "s-w" to window switcher + ([?\M-W] . consult-buffer) + ([?\M-o] . other-window) + ([?\M-O] . my/exwm-other-workspace) + + ([?\M-D] . my/dmenu) + ([?\M-E] . my/browser) + (,(kbd "M-C-m") . my/eshell) + ([?\M-K] . kill-current-buffer) + + ,@(mapcar (lambda (n) + (let* ((from (concat "C-x " (format "%d" n))) + (to (concat "M-" (format "%d" n))) + (bind (keymap-lookup global-map from))) + (cons (kbd to) bind))) + (number-sequence 0 9)) + + ([XF86MonBrightnessDown] . my/brightnessdown) + ([XF86MonBrightnessUp] . my/brightnessup) + ([XF86AudioMute] . my/mute) + ([XF86AudioLowerVolume] . my/voldown) + ([XF86AudioRaiseVolume] . my/volup))) + (exwm-input-simulation-keys + '(;; movement + ([?\C-b] . [left]) + ([?\M-b] . [C-left]) + ([?\C-f] . [right]) + ([?\M-f] . [C-right]) + ([?\C-p] . [up]) + ([?\C-n] . [down]) + ([?\C-a] . [home]) + ([?\C-e] . [end]) + ([?\M-v] . [prior]) + ([?\C-v] . [next]) + ;; edit, copy, paste + ([?\C-d] . [delete]) + ([?\C-k] . [S-end delete]) + ([M-backspace] . [C-backspace]) + ([?\M-w] . [?\C-c]) + ([?\C-y] . [?\C-v]) + ([?\C-s] . [?\C-f]))) + (exwm-input-move-event 'M-down-mouse-1) + (exwm-input-resize-event 'M-down-mouse-3) + :bind (:map exwm-mode-map + ("C-q" . 'exwm-input-send-next-key) + ("M-!" . 'shell-command))) + diff --git a/config/emacs/site-lisp/my-mail.el b/config/emacs/site-lisp/my-mail.el new file mode 100644 index 0000000..bcda232 --- /dev/null +++ b/config/emacs/site-lisp/my-mail.el @@ -0,0 +1,52 @@ +(use-package mu4e + :ensure nil + :demand nil + :init + ;; assumed Maildir layout + ;; ~/Maildir/Account0/{Inbox,Sent,Trash} + ;; ~/Maildir/Account1/{Inbox,Sent,Trash} + ;; where Account0 is context name + (defun my/make-mu4e-context (context-name full-name mail-address signature) + "Return a mu4e context named CONTEXT-NAME with :match-func matching + folder name CONTEXT-NAME in Maildir. The context's `user-mail-address', + `user-full-name' and `mu4e-compose-signature' is set to MAIL-ADDRESS + FULL-NAME and SIGNATURE respectively. + Special folders are set to context specific folders." + (let ((dir-name (concat "/" context-name))) + (make-mu4e-context + :name context-name + ;; we match based on the maildir of the message + ;; this matches maildir /Arkham and its sub-directories + :match-func + `(lambda (msg) + (when msg + (string-match-p + ,(concat "^" dir-name) + (mu4e-message-field msg :maildir)))) + :vars + `((user-mail-address . ,mail-address) + (user-full-name . ,full-name) + (mu4e-sent-folder . ,(concat dir-name "/sent")) + (mu4e-drafts-folder . ,(concat dir-name "/drafts")) + (mu4e-trash-folder . ,(concat dir-name "/trash")) + (mu4e-refile-folder . ,(concat dir-name "/archive")) + (mu4e-compose-signature . ,signature))))) + :custom + (mu4e-change-filenames-when-moving t) + (mu4e-get-mail-command "mbsync --all") + :config + ;;Fixing duplicate UID errors when using mbsync and mu4e + (setq mu4e-contexts + `(,(my/make-mu4e-context + "thomasmulmer02" "Thomas Ulmer" + "thomasmulmer02@gmail.com" "Thanks, +Thomas Ulmer"))) + + (require 'smtpmail) + (setq message-send-mail-function 'smtpmail-send-it) + (setq smtpmail-default-smtp-server "smtp.gmail.com" + smtpmail-smtp-server "smtp.gmail.com" + smtpmail-smtp-service 587 + starttls-use-gnutls t + smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) + smtp-auth-credentials (expand-file-name "~/.authinfo.gpg"))) diff --git a/config/emacs/site-lisp/my-modal.el b/config/emacs/site-lisp/my-modal.el new file mode 100644 index 0000000..1803609 --- /dev/null +++ b/config/emacs/site-lisp/my-modal.el @@ -0,0 +1,212 @@ +;;; bespoke vish modal -*- lexical-binding: t; -*- + +(require 's) + + +(defun do-nothing () (interactive)) + +(defun yank-looks-like-lines () + (s-contains? " +" (current-kill 0 t))) + +(defun paste-after-maybe-lines () + (interactive) + (if (yank-looks-like-lines) + (progn + (move-end-of-line nil) + (newline) + (yank)) + (forward-char-unless-eol) + (yank))) + +(defun paste-before-maybe-lines () + (interactive) + (if (yank-looks-like-lines) + (progn + (move-beginning-of-line nil) + (yank)) + (yank))) + +(defun forward-char-unless-eol (&optional arg) + (interactive "P") + (when (< (point) (point-at-eol)) (forward-char arg))) + +(defun mark-end-of-line (&optional arg) + (interactive "P") + (push-mark) + (move-end-of-line arg) + (exchange-point-and-mark)) + +(defun mark-beginning-of-line (&optional arg) + (interactive "P") + (push-mark) + (move-beginning-of-line arg) + (exchange-point-and-mark)) + +;; what I really want is a meta operator to invert the arg count, +;; but between how ryo calls functions and expects symbols in binds, +;; this is the best I can do. +(defun mark-word-backward (&optional arg allow-extend) + (interactive "P\np") + (cond + ((null arg) + (setq arg -1)) + ((numberp arg) + (setq arg (* -1 arg)))) + (mark-word arg allow-extend)) + +(defun mark-sexp-backward (&optional arg allow-extend) + (interactive "P\np") + (cond + ((null arg) + (setq arg -1)) + ((numberp arg) + (setq arg (* -1 arg)))) + (mark-sexp arg allow-extend)) + +(defun mark-defun-backward (&optional arg interactive) + (interactive "p\nd") + (cond + ((null arg) + (setq arg -1)) + ((numberp arg) + (setq arg (* -1 arg)))) + (mark-defun arg interactive)) + +(defun mark-paragraph-backward (&optional arg allow-extend) + (interactive "P\np") + (cond + ((null arg) + (setq arg -1)) + ((numberp arg) + (setq arg (* -1 arg)))) + (mark-paragraph arg allow-extend)) + +(defconst my/ryo-digits '(("1" "C-1" :norepeat t) + ("2" "C-2" :norepeat t) + ("3" "C-3" :norepeat t) + ("4" "C-4" :norepeat t) + ("5" "C-5" :norepeat t) + ("6" "C-6" :norepeat t) + ("7" "C-7" :norepeat t) + ("8" "C-8" :norepeat t) + ("9" "C-9" :norepeat t))) + +(defconst my/ryo-moves '(("h" backward-char) + ("j" next-line) + ("k" previous-line) + ("l" forward-char) + + ("e" forward-word) + ("b" backward-word) + ("E" forward-sexp) + ("B" backward-sexp) + + ("0" "C-a") + ("$" "C-e") + + ("[" beginning-of-defun) + ("]" end-of-defun) + ("{" backward-paragraph) + ("}" forward-paragraph) + )) + +(defconst my/ryo-marking-moves '(("h" backward-char :first (push-mark-command)) + ("j" next-line :first (push-mark-command)) + ("k" previous-line :first (push-mark-command)) + ("l" forward-char :first (push-mark-command)) + + ("b" mark-word-backward) + ("e" mark-word) + ("B" mark-sexp-backward) + ("E" mark-sexp) + + ("[" mark-defun-backward) + ("]" mark-defun) + + ("0" mark-beginning-of-line) + ("$" mark-end-of-line) + + ("{" mark-paragraph-backward) + ("}" mark-paragraph) + )) + +(defconst my/ryo-no-ops '( + "<escape>" + "`" "-" "+" + "q" "w" "r" "t" "\\" + "s" "f" ";" "'" + "z" "n" "m" "," "." + + "~" "!" "@" "#" "%" "^" "&" "*" "(" ")" "_" "+" + "Q" "W" "R" "T" "Y" "U" "|" + "S" "D" "F" "H" "J" "K" "L" ":" "\"" + "Z" "X" "C" "V" "N" "M" "<" ">" + )) + + + +(use-package ryo-modal + :demand t + :bind (:map my/keys-mode-map + ("C-c C-<space>" . ryo-modal-mode)) + :config + (define-minor-mode my/temp-nonmodal-mode + "Minor mode for a temporary exit that should return to ryo-modal-mode." + :keymap (define-keymap + "<escape>" + 'my/temp-nonmodal-mode) + :lighter " <NM>" + (ryo-modal-mode (if my/temp-nonmodal-mode -1 1))) + + (let* () + (eval + `(ryo-modal-keys + ,@my/ryo-moves + ,@my/ryo-digits + ,@(mapcar (lambda (key) (list key 'do-nothing)) my/ryo-no-ops) + ("g" (("g" beginning-of-buffer))) + ("G" end-of-buffer) + + ("i" my/temp-nonmodal-mode) + ("I" back-to-indentation :then '(my/temp-nonmodal-mode)) + ("a" forward-char-unless-eol :then '(my/temp-nonmodal-mode)) + ("A" move-end-of-line :then '(my/temp-nonmodal-mode)) + ("o" move-end-of-line :then '(newline-and-indent my/temp-nonmodal-mode)) + ("O" move-beginning-of-line + :then '(open-line indent-according-to-mode my/temp-nonmodal-mode)) + + ("x" delete-char) + ("d" (("d" kill-whole-line) + ("m" kill-region))) + ("d" ,my/ryo-marking-moves :then '(kill-region)) + + ("c" (("c" kill-whole-line)) + :then '(open-line my/temp-nonmodal-mode)) + ("c" (("m" kill-region)) + :then '(my/temp-nonmodal-mode)) + ("C" kill-line :then '(my/temp-nonmodal-mode)) + ("c" ,my/ryo-marking-moves :then '(kill-region my/temp-nonmodal-mode)) + + ("y" (("m" copy-region-as-kill))) + ("y" (("y" copy-region-as-kill)) + :first '(push-mark move-beginning-of-line push-mark move-end-of-line forward-char) + :then '(pop-mark pop-to-mark-command)) + + ("P" paste-before-maybe-lines) + ("p" paste-after-maybe-lines) + + ("/" isearch-forward-regexp) + ("?" isearch-backward-regexp) + + ("u" undo) + + ("SPC" set-mark-command) + ("v" set-mark-command) + ))) + (setq ryo-modal-cursor-color "aquamarine") + (defun ryo-modal-unless-minibuffer () + (unless (minibufferp) + (ryo-modal-mode 1))) + ;; (add-hook 'after-change-major-mode-hook 'ryo-modal-unless-minibuffer) + ) diff --git a/config/emacs/site-lisp/single-header.el b/config/emacs/site-lisp/single-header.el new file mode 100755 index 0000000..dc65335 --- /dev/null +++ b/config/emacs/site-lisp/single-header.el @@ -0,0 +1,257 @@ +;; single-header --- Display a topline inside each frame with global info -*- lexical-binding: t; -*- + +;; Author: Thomas Ulmer +;; Package-Requires: ((ednc) (battery) (s) (dash)) +;; Package-Version 1.0 + +(require 'battery) +(require 's) +(require 'dash) + +(use-package ednc ; make emacs a dbus notify reciever + ) + +;;; Commentary: +;;; + +;;; Code: + +;; testing +;; (require 'notifications) +;; (notifications-notify :title "2st test" :body "hello, world" :app-name "EDNC" +;; :actions '("default" "default")) + +(defgroup single-header + '((single-header-face custom-face) + (single-header-update-increment custom-variable)) + "Custom variables for the single header package." + :prefix "single-header" + :group 'emacs) +(defface single-header-face + '((default . (:background "#000000" :family "Source Code Pro"))) + "Base face for the header line." + :group 'single-header) +(defcustom single-header-update-increment + 3 + "Number of seconds before updating the header again." + :type 'natnum + :group 'single-header) +(defvar single-header--active-notifs nil) +(defvar single-header--timer nil) + +(defmacro single-header--time-lock (force frame name &rest body) + "" + (let* ((last-t-str (concat name "--last-time")) + (last-t (or (intern-soft last-t-str) (make-symbol last-t-str)))) + ;; cache contains the symol of the cache variable + ;; last-t contains the symbol of the last time it was evaluated + `(if force + (progn + (set-frame-parameter ,frame (quote ,last-t) (time-convert (current-time) 'integer)) + ,@body) + (let ((cur-time (time-convert (current-time) 'integer)) + (next-time (time-add (or (frame-parameter ,frame (quote ,last-t)) 0) + single-header-update-increment))) + (when (time-less-p next-time cur-time) + (progn + (set-frame-parameter ,frame (quote ,last-t) cur-time) + ,@body)))))) + +(defun single-header--with-face (str &rest face-plist) + "Convenience wrapper for `add-face-text-property'." + (add-face-text-property 0 (length str) face-plist t str) + str) + +(defun single-header--register-notif-change (old new) + "Function to hook `ednc-notification-presentation-functions'." + (when new + (push new single-header--active-notifs)) + (when (and old + (member old single-header--active-notifs)) + (setq single-header--active-notifs + (remove old single-header--active-notifs))) + (when (or new old) + (single-header-update t))) + +(defun single-header--make-notif-string () + "Produce a string representation of the active notifications." + (mapconcat (lambda (e) + (format "[%s | %s | %s] " + (s-truncate 8 (ednc-notification-app-name e)) + (s-truncate 8 (ednc-notification-summary e)) + (s-truncate 20 (ednc-notification-body e))) + ) + (ednc-notifications) + "")) + +(defun single-header-dismiss (num) + "Dismiss the most recent notification from the header line. With a prefix +arg, dismiss all the notifications." + (interactive "p") + (cond ((and (natnump num) (>= num 4)) + (mapc 'ednc-dismiss-notification (ednc-notifications))) + (t + (let ((notifs (ednc-notifications))) + (when notifs + (ednc-dismiss-notification (car notifs)))))) + (single-header-update t)) + +(defun single-header--make-header-info-string () + "Generates the mode line string that contains all the info to the right." + (let ((str (concat + (single-header--with-face (battery-format "[%b%p%%] " (and battery-status-function (funcall battery-status-function))) + :weight 'bold) + (single-header--with-face (let* ((mi (memory-info)) + (tm (float (car mi))) + (fm (float (cadr mi))) + (ts (float (caddr mi))) + (fs (float (cadddr mi)))) + (format "{%.2f %.2f} " (- 1 (/ fm tm)) (- 1 (/ fs ts)))) + :foreground "#00ced1") + (single-header--with-face (format "<%03.2f> " (car (load-average 1))) + :foreground "#da70d6") + (format-time-string "%a, %b %+4Y-%0m-%0d ") + (single-header--with-face (format-time-string "%R") + :weight 'bold) + ))) + (single-header--with-face str 'single-header-face))) + +(defun single-header--init-buffer (buf) + (with-current-buffer buf + (insert "header test") + (jit-lock-mode nil) + (font-lock-mode -1) + (buffer-disable-undo) + (setq-local mode-line-format nil) + (setq-local header-line-format nil) + (setq-local cursor-type nil) + (setq-local cursor-in-non-selected-windows nil) + (setq-local overflow-newline-into-fringe nil) + (setq-local word-wrap nil) + (setq-local show-trailing-whitespace nil))) + +(defun single-header--init-window (win) + (with-selected-window win + (set-window-dedicated-p win t) + (set-window-parameter win 'no-other-window t) + (set-window-parameter win 'no-delete-other-windows t) + (set-window-margins win 0 0) + (set-window-fringes win 0 0) + (set-window-scroll-bars win 0 nil 0 nil) + (setq-local window-min-height 1) + (setq-local window-safe-min-height 1) + (let + (window-size-fixed) + (fit-window-to-buffer win 1)) + (setq-local window-size-fixed t) + (when + (fboundp 'window-preserve-size) + (window-preserve-size win nil t)))) + +(defun single-header--init-frame (&optional frame) + (setq frame (or frame (selected-frame))) + (with-selected-frame frame + (let* ((buf (generate-new-buffer "*header*")) + (win (display-buffer-in-side-window buf '((side . top) + (slot . -100))))) + (single-header--init-buffer buf) + (single-header--init-window win) + (set-frame-parameter frame 'single-header-buf buf) + (set-frame-parameter frame 'single-header-win win)))) + +(defun single-header-update (&optional force) + "" + (mapc (lambda (f) (single-header-update-frame f force)) + (visible-frame-list))) + +(defun single-header-format (frame win buf) + "Evaluated in the header buffer when empty to fill the buffer." + (let* ((win-width (window-max-chars-per-line win 'single-header-face)) + (info (single-header--make-header-info-string)) + (info-width (string-width info)) + (notifs (s-truncate (- win-width info-width 2) + (single-header--make-notif-string))) + (notifs-width (string-width notifs)) + (filled (min win-width (+ info-width notifs-width))) + (padding-width (- win-width filled)) + (padding (make-string padding-width ? ))) + (setq notifs (single-header--with-face notifs 'single-header-face)) + (setq padding (single-header--with-face padding 'single-header-face)) + (setq info (single-header--with-face info 'single-header-face)) + (concat notifs padding info))) + +(defun single-header-update-frame (frame &optional force) + "" + (with-selected-frame frame + (let ((buf (frame-parameter frame 'single-header-buf)) + (win (frame-parameter frame 'single-header-win))) + (when (and buf win) + (with-current-buffer buf + (single-header--time-lock + force frame "header-lock" + (let ((str (single-header-format frame win buf))) + (erase-buffer) + (insert str)))))))) + +(defun single-header-make () + "Create the header and show it." + (let ((registered + (or (equal 'single-header--register-notif-change + ednc-notification-presentation-functions) + (and (listp ednc-notification-presentation-functions) + (-contains? ednc-notification-presentation-functions + 'single-header--register-notif-change))))) + (unless registered + (if (listp ednc-notification-presentation-functions) + (push 'single-header--register-notif-change + ednc-notification-presentation-functions) + (list 'single-header--register-notif-change + ednc-notification-presentation-functions)))) + (mapc (lambda (f) + (when (frame-live-p f) + (single-header--init-frame f))) + (frame-list)) + ;; TODO frame creation hook + (add-hook 'after-make-frame-functions #'single-header--init-frame) + (when single-header--timer + (cancel-timer single-header--timer)) + (setq single-header--timer + (run-with-timer 0 single-header-update-increment 'single-header-update))) + +(defun single-header-delete () + "Remove an existing header buffer." + (let ((reg-list (and (listp ednc-notification-presentation-functions) + (-contains? ednc-notification-presentation-functions + 'single-header--register-notif-change))) + (reg-equal (or (equal 'single-header--register-notif-change + ednc-notification-presentation-functions)))) + (when reg-list + (delete 'single-header--register-notif-change + ednc-notification-presentation-functions)) + (when reg-equal + (setq ednc-notification-presentation-functions + 'ednc--update-log-buffer))) + (cancel-timer single-header--timer) + (setq single-header--timer nil) + (remove-hook 'after-make-frame-functions 'single-header--init-frame) + (mapc (lambda (f) + (delete-window (frame-parameter f 'single-header-win)) + (kill-buffer (frame-parameter f 'single-header-buf)) + (set-frame-parameter f 'single-header-buf nil) + (set-frame-parameter f 'single-header-win nil)) + (frame-list))) + +(define-minor-mode single-header-mode + "Global minor mode to enable a single info line at the top of each frame." + :group 'single-header + :global t + :init-value nil + :keymap `((,(kbd "M-L d") . single-header-dismiss) + (,(kbd "M-L t") . single-header-mode)) + :interactive t + (if (not single-header-mode) + (single-header-delete) + (single-header-make))) + +(provide 'single-header) +;;; single-header.el ends here diff --git a/config/emacs/site-lisp/tex-conf.el b/config/emacs/site-lisp/tex-conf.el new file mode 100644 index 0000000..4592ce5 --- /dev/null +++ b/config/emacs/site-lisp/tex-conf.el @@ -0,0 +1,47 @@ +;; latex stuff +(require 'tex-mode) +(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive) + (push-mark) + (insert "\\[\n\n\\]") + (indent-region (mark) (point)) + (pop-mark) + (previous-line) + (indent-for-tab-command) + )) + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;; LaTeX ;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; ##### Don't forget to configure +;; ##### Okular to use emacs in +;; ##### "Configuration/Configure Okular/Editor" +;; ##### => Editor => Emacsclient. (you should see +;; ##### emacsclient -a emacs --no-wait +%l %f +;; ##### in the field "Command". + +(add-hook 'LaTeX-mode-hook 'turn-on-reftex) +(setq reftex-plug-into-AUCTeX t) + +;; ##### Always ask for the master file +;; ##### when creating a new TeX file. +(setq-default TeX-master nil) + +;; ##### Enable synctex correlation. From Okular just press +;; ##### Shift + Left click to go to the good line. +(setq TeX-source-correlate-mode t + TeX-source-correlate-start-server t) + +;; ### Set Okular as the default PDF viewer. +(eval-after-load "tex" + '(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "Okular")) + +(add-hook 'tex-mode-hook (lambda () + (setq spell-fu-faces-exclude + '(tex-math + font-lock-builtin-face + font-lock-keyword-face + font-lock-function-name-face + font-lock-variable-name-face + font-latex-sedate-face)) + (outline-minor-mode 1))) diff --git a/config/emacs/site-lisp/tmu-custom-theme.el b/config/emacs/site-lisp/tmu-custom-theme.el new file mode 100755 index 0000000..965d7c8 --- /dev/null +++ b/config/emacs/site-lisp/tmu-custom-theme.el @@ -0,0 +1,67 @@ +;; -*- lexical-binding: t; -*- +(provide 'tmu-custom-theme) + +(deftheme tmu-custom + "Created 2023-01-06.") + +(custom-theme-set-faces + 'tmu-custom + '(cursor ((((background light)) (:background "black")) (((background dark)) (:background "white")))) + '(fixed-pitch ((t (:family "Monospace")))) + '(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif")))) + '(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(minibuffer-prompt ((t (:weight bold :box (:line-width (1 . -1) :color "red" :style released-button) :foreground "white smoke" :background "royal blue")))) + '(highlight ((t (:background "gray30")))) + '(region ((t (:extend t :background "SeaGreen4")))) + '(shadow ((((class color grayscale) (min-colors 88) (background light)) (:foreground "grey50")) (((class color grayscale) (min-colors 88) (background dark)) (:foreground "grey70")) (((class color) (min-colors 8) (background light)) (:foreground "green")) (((class color) (min-colors 8) (background dark)) (:foreground "yellow")))) + '(secondary-selection ((t (:extend t :foreground "#f6f3e8" :background "#333366")))) + '(trailing-whitespace ((((class color) (background light)) (:background "red1")) (((class color) (background dark)) (:background "red1")) (t (:inverse-video t)))) + '(font-lock-bracket-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-builtin-face ((t (:foreground "chartreuse2")))) + '(font-lock-comment-delimiter-face ((default (:inherit (font-lock-comment-face))))) + '(font-lock-comment-face ((t (:foreground "orchid2")))) + '(font-lock-constant-face ((t (:foreground "maroon1")))) + '(font-lock-delimiter-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-doc-face ((t (:foreground "indian red")))) + '(font-lock-doc-markup-face ((t (:inherit (font-lock-constant-face))))) + '(font-lock-escape-face ((t (:inherit (font-lock-regexp-grouping-backslash))))) + '(font-lock-function-name-face ((t (:foreground "spring green")))) + '(font-lock-keyword-face ((t (:weight bold :foreground "light sea green")))) + '(font-lock-negation-char-face ((t nil))) + '(font-lock-number-face ((t nil))) + '(font-lock-misc-punctuation-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-operator-face ((t nil))) + '(font-lock-preprocessor-face ((t (:foreground "cornflower blue")))) + '(font-lock-property-face ((t (:inherit (font-lock-variable-name-face))))) + '(font-lock-punctuation-face ((t nil))) + '(font-lock-regexp-grouping-backslash ((t (:inherit (bold))))) + '(font-lock-regexp-grouping-construct ((t (:inherit (bold))))) + '(font-lock-string-face ((t (:foreground "Skyblue1")))) + '(font-lock-type-face ((t (:foreground "medium purple")))) + '(font-lock-variable-name-face ((t (:foreground "PaleGreen2")))) + '(font-lock-warning-face ((t (:weight bold :foreground "hot pink")))) + '(button ((t (:inherit (link))))) + '(link ((((class color) (min-colors 88) (background light)) (:underline t)) (((class color) (background light)) (:underline t)) (((class color) (min-colors 88) (background dark)) (:underline t)) (((class color) (background dark)) (:underline t)))) + '(link-visited ((default (:inherit (link))) (((class color) (background light)) (:foreground "magenta4")) (((class color) (background dark)) (:foreground "violet")))) + '(fringe ((((class color) (background light)) (:background "grey95")) (((class color) (background dark)) (:background "grey10")) (t (:background "gray")))) + '(header-line ((t (:inherit mode-line)))) + '(tooltip ((((class color)) (:inherit (variable-pitch) :foreground "black" :background "lightyellow")) (t (:inherit (variable-pitch))))) + '(mode-line ((t (:background "black" :family "DejaVu Sans")))) + '(mode-line-buffer-id ((t (:weight bold)))) + '(mode-line-emphasis ((t (:weight bold)))) + '(mode-line-highlight ((((supports :box t) (class color) (min-colors 88)) (:box (:line-width (2 . 2) :color "grey40" :style released-button))) (t (:inherit (highlight))))) + '(mode-line-inactive ((t (:inherit mode-line :foreground "dark gray")))) + '(isearch ((((class color) (min-colors 88) (background light)) (:foreground "lightskyblue1" :background "magenta3")) (((class color) (min-colors 88) (background dark)) (:foreground "brown4" :background "palevioletred2")) (((class color) (min-colors 16)) (:foreground "cyan1" :background "magenta4")) (((class color) (min-colors 8)) (:foreground "cyan1" :background "magenta4")) (t (:inverse-video t)))) + '(isearch-fail ((((class color) (min-colors 88) (background light)) (:background "RosyBrown1")) (((class color) (min-colors 88) (background dark)) (:background "red4")) (((class color) (min-colors 16)) (:background "red")) (((class color) (min-colors 8)) (:background "red")) (((class color grayscale)) (:foreground "grey")) (t (:inverse-video t)))) + '(lazy-highlight ((((class color) (min-colors 88) (background light)) (:distant-foreground "black" :background "paleturquoise")) (((class color) (min-colors 88) (background dark)) (:distant-foreground "white" :background "paleturquoise4")) (((class color) (min-colors 16)) (:distant-foreground "white" :background "turquoise3")) (((class color) (min-colors 8)) (:distant-foreground "white" :background "turquoise3")) (t (:underline t)))) + '(match ((((class color) (min-colors 88) (background light)) (:background "khaki1")) (((class color) (min-colors 88) (background dark)) (:background "RoyalBlue3")) (((class color) (min-colors 8) (background light)) (:foreground "black" :background "yellow")) (((class color) (min-colors 8) (background dark)) (:foreground "white" :background "blue")) (((type tty) (class mono)) (:inverse-video t)) (t (:background "gray")))) + '(next-error ((t (:inherit (region))))) + '(query-replace ((t (:inherit (isearch))))) + '(default ((t (:family "Source Code Pro" :foundry "ADBO" :width normal :height 98 :weight regular :slant normal :underline nil :overline nil :extend nil :strike-through nil :box nil :inverse-video nil :foreground "white smoke" :background "gray10" :stipple nil :inherit nil)))) + '(frog-menu-posframe-background-face ((t (:background "RoyalBlue4")))) + '(minibuffer-prompt ((t (:background "gray10" :foreground "cyan" :box nil :weight bold)))) + '(pyim-page ((t (:inherit default :background "#333333" :foreground "#dcdccc")))) + '(vterm-color-blue ((t (:inherit ansi-color-bright-green))))) + +(provide-theme 'tmu-custom) |
