diff options
Diffstat (limited to 'emacs/site-lisp')
| -rwxr-xr-x | emacs/site-lisp/coding-config.el | 130 | ||||
| -rw-r--r-- | emacs/site-lisp/evil-config.el | 80 | ||||
| -rw-r--r-- | emacs/site-lisp/exwm-pref.el | 318 | ||||
| -rw-r--r-- | emacs/site-lisp/general-text.el | 32 | ||||
| -rw-r--r-- | emacs/site-lisp/irc-config.el | 24 | ||||
| -rw-r--r-- | emacs/site-lisp/modeline-config.el | 39 | ||||
| -rw-r--r-- | emacs/site-lisp/my-binds.el | 24 | ||||
| -rw-r--r-- | emacs/site-lisp/my-funcs.el | 164 | ||||
| -rwxr-xr-x | emacs/site-lisp/single-header.el | 171 |
9 files changed, 129 insertions, 853 deletions
diff --git a/emacs/site-lisp/coding-config.el b/emacs/site-lisp/coding-config.el deleted file mode 100755 index edf252f..0000000 --- a/emacs/site-lisp/coding-config.el +++ /dev/null @@ -1,130 +0,0 @@ -;;; The config specifically for editing code - -(provide 'coding-config) - -;; (add-hook 'xref-backend-functions 'gxref-xref-backend) - -;; better commenting binds -(global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region) -(global-set-key (kbd "C-x ;") 'comment-line) -(global-set-key (kbd "C-x :") 'comment-set-column) ;never gonna use but whatever - -(setq asm-comment-char ?#) ; prefer # over ; for asm comments - -;; generate tags for label names in asm files, based on asm files in the current directory -(add-hook 'asm-mode-hook - (lambda () - (add-hook 'after-save-hook - (lambda () - (shell-command - "find . -iregex '.*\\.[sS]' -exec etags -l none -r '/\\([a-zA-Z0-9\\-_]+\\):/\1/' {} +")) - 0 t))) - -(use-package lsp-mode) - -(use-package lsp-haskell) - -(use-package pyvenv) - -(use-package sideline - :init - (setq sideline-backends-right '())) -(use-package sideline-flycheck - :init - (push 'sideline-flycheck sideline-backends-right)) -(use-package sideline-flymake - :init - (push 'sideline-flymake sideline-backends-right)) -(use-package sideline-lsp - :init - (push 'sideline-lsp sideline-backends-right)) - -(use-package flycheck - :config - ;; flymake stuff to be less annoying - ;; (face-spec-set 'flycheck-note '((t :underline nil))) - ;; (face-spec-set 'flycheck-info '((t :underline nil))) - ;; (face-spec-set 'flycheck-warning '((t :underline nil))) - ;; (face-spec-set 'flycheck-error '((t :underline nil))) - (add-hook 'prog-mode-hook (lambda () flycheck-mode 1))) - -;; Find defs in various ways -(global-set-key (kbd "M-i") 'imenu) -(global-set-key (kbd "M-I") 'xref-find-definitions) - -(setq imenu-auto-rescan t) -(setq imenu-flatten t) - -;; make shells and whatnot slightly better -(require 'comint) -(setq comint-scroll-to-bottom-on-input t) -(setq comint-scroll-to-bottom-on-output t) - -;; ediff -(setq ediff-window-setup-function 'ediff-setup-windows-plain) - -;; various folding types and binds -;;(autoload 'hide-lines "hide-lines" "Hide lines based on a regexp" t) -;;(global-set-key (kbd "C-c /") 'hide-lines) -(use-package fold-this - :init - (define-prefix-command 'fold-map) - (global-set-key (kbd "M-F") 'fold-map) - (define-keymap :full nil - :parent nil - :suppress nil - :keymap nil - :name "fold-map" - :prefix 'fold-map - (kbd "c") 'fold-this - (kbd "e") 'fold-this-unfold-at-point - (kbd "t") 'hs-toggle-hiding - (kbd "f") 'fold-this-fold-forward - (kbd "b") 'fold-this-fold-backward - (kbd "l") 'hs-hide-level)) - -;; global prog stuff that differs from global/text -(require 'my-funcs) -(add-hook 'prog-mode-hook (lambda () - (hs-minor-mode 1) - (hl-todo-mode 1) - (superword-mode 1) - (modify-syntax-entry ?_ "w") - - (display-fill-column-indicator-mode 1) - (add-hook 'before-save-hook - (lambda () - (if (not (eq major-mode 'makefile-gmake-mode)) - (clean-prog-file (current-buffer))))))) - -;; haskell flavor and tags -(use-package haskell-mode - :custom - (haskell-tags-on-save t) - (haskell-process-type 'cabal-repl) - :hook - (haskell-mode . (lambda () - ;; (hindent-mode 1) - (interactive-haskell-mode 1)))) - -(global-set-key (kbd "M-m") 'goto-next-locus) -(global-set-key (kbd "M-M") 'recompile) -(setq compilation-always-kill t - compilation-scroll-output t) -;; Allow compilation buffer to be dedicated across frames -(push '("\\*compilation\\*" . (nil (reusable-frames . t))) display-buffer-alist) - -;; better searching -(use-package swiper) -(use-package counsel) -(use-package ivy) -(setq counsel-grep-base-command - "rg -i -M 120 --no-heading --line-number --color never '%s' %s") -(global-set-key (kbd "C-s") 'counsel-grep-or-swiper) -(global-set-key (kbd "C-S-s") 'isearch-forward) - -;; racket -(use-package racket-mode) - -;; rust -(use-package rustic) diff --git a/emacs/site-lisp/evil-config.el b/emacs/site-lisp/evil-config.el deleted file mode 100644 index 38db735..0000000 --- a/emacs/site-lisp/evil-config.el +++ /dev/null @@ -1,80 +0,0 @@ -;;; evil config -(provide 'evil-config) - -(use-package evil - :custom - (evil-want-keybinding nil) - (evil-want-integration t) - :init - (evil-mode 1)) -(use-package evil-collection - :init - (evil-collection-init)) -(use-package evil-easymotion - :init - (evilem-default-keybindings "SPC")) -(use-package evil-surround - :config - (global-evil-surround-mode 1)) -(use-package evil-snipe - :config - (evil-snipe-mode 1) - (evil-snipe-override-mode 1) - (evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s) - (evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S) - :custom - (evil-snipe-scope 'buffer)) -(define-key evil-insert-state-map (kbd "C-d") 'delete-char) -(define-key evil-insert-state-map (kbd "C-e") 'move-end-of-line) -(define-key evil-insert-state-map (kbd "C-a") 'move-beginning-of-line) -(define-key evil-normal-state-map (kbd "M-.") 'xref-find-definitions) -(define-key evil-normal-state-map (kbd "M-Z") 'suspend-frame) - -(use-package treemacs-evil) - -(define-key evil-motion-state-map (kbd "TAB") 'indent-for-tab-command) -(evil-set-initial-state 'vterm-mode 'emacs) -(evil-set-initial-state 'eshell-mode 'emacs) - -;;; sasha bindings -(defun evil-window-split-and-switch () - "Split the window vertically and switch to the new buffer." - (interactive) - (evil-window-split) - (other-window 1)) - -(defun evil-window-vsplit-and-switch () - "Split the window horizontally and switch to the new buffer." - (interactive) - (evil-window-vsplit) - (other-window 1)) - -(define-key evil-insert-state-map (kbd "C-t") 'transpose-chars) -(define-key evil-normal-state-map (kbd "C-t") 'transpose-chars) -(evil-define-key 'normal global-map (kbd "SPC i") 'imenu) -(evil-define-key 'normal global-map (kbd "SPC o") 'other-window) -(evil-define-key 'normal global-map (kbd "SPC q") 'kill-current-buffer) -(evil-define-key 'normal global-map (kbd "SPC RET") 'vterm) -(evil-define-key 'normal global-map (kbd "SPC v") 'vterm) -(evil-define-key 'normal global-map (kbd "SPC !") 'abort-recursive-edit) -(evil-define-key 'normal global-map (kbd "SPC f f") 'find-file) - -(evil-define-key 'normal global-map (kbd "SPC SPC SPC j") 'evil-window-split-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC k") 'evil-window-split-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC h") 'evil-window-vsplit-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC l") 'evil-window-vsplit-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC h") 'evil-window-left) -(evil-define-key 'normal global-map (kbd "SPC SPC j") 'evil-window-down) -(evil-define-key 'normal global-map (kbd "SPC SPC k") 'evil-window-up) -(evil-define-key 'normal global-map (kbd "SPC SPC l") 'evil-window-right) -(evil-define-key 'normal global-map (kbd "M-h") 'evil-window-left) -(evil-define-key 'normal global-map (kbd "M-j") 'evil-window-down) -(evil-define-key 'normal global-map (kbd "M-k") 'evil-window-up) -(evil-define-key 'normal global-map (kbd "M-l") 'evil-window-right) -(evil-define-key 'normal global-map (kbd "SPC SPC w") 'delete-window) -(evil-define-key 'normal global-map (kbd "SPC SPC q") 'delete-window) -(evil-define-key 'normal global-map (kbd "SPC SPC b") 'balance-windows) -(evil-define-key 'normal global-map (kbd "SPC s s") 'save-buffer) -(evil-define-key 'normal global-map (kbd "SPC s f") 'counsel-find-file) -(evil-define-key 'normal global-map (kbd "SPC s r") 'counsel-rg) -(evil-define-key 'normal global-map (kbd "SPC ;") 'frog-jump-buffer) diff --git a/emacs/site-lisp/exwm-pref.el b/emacs/site-lisp/exwm-pref.el deleted file mode 100644 index d955e50..0000000 --- a/emacs/site-lisp/exwm-pref.el +++ /dev/null @@ -1,318 +0,0 @@ -;;; My full EXWM config -(provide 'exwm-pref) - -;; stuff for exwm -(use-package exwm) -(require 'exwm-randr) -(require 'exwm-xim) -(require 'exwm-systemtray) -(require 'exwm-manage) - -(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) - (message (buffer-substring (point-min) (point-max))) - (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) - (message "iter") - (move-beginning-of-line 1) - (push-mark) - (search-forward-regexp " ") - (backward-char) - (message (buffer-substring (mark) (point))) - (push (buffer-substring (mark) (point)) out-plist) - (push i out-plist) - (setq i (+ i 1)) - (pop-mark) - (next-line)))) - (kill-buffer buf) - (setq exwm-randr-workspace-monitor-plist out-plist)) - -;; (setq exwm-workspace-number 2) -;; (setq exwm-randr-workspace-monitor-plist '(0 "DP-0" 1 "HDMI-0")) -(setq exwm-workspace-show-all-buffers t) -(setq exwm-layout-show-all-buffers t) - -(use-package exwm-modeline) -(setq exwm-modeline-randr t) -(setq exwm-modeline-short nil) -(setq exwm-modeline-urgent t) -;; (add-hook 'exwm-init-hook (lambda () (exwm-modeline-mode 1))) - -;; (require exwm-firefox-evil) -;; (require 'exwm-firefox) -;; (exwm-firefox-mode) - -(setq exwm-title-length 50) - -(setq exwm-manage-force-tiling t) - - -(defun b3n-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)))) - -(add-hook 'exwm-update-class-hook 'b3n-exwm-set-buffer-name) -(add-hook 'exwm-update-title-hook 'b3n-exwm-set-buffer-name) - -(defun exwm-assign-workspace (index) - "switch to workspace without changing monitor" - (interactive "p") - (let* ((current-index exwm-workspace-current-index) - (current-monitor (plist-get exwm-randr-workspace-monitor-plist current-index)) - (displaced-monitor (plist-get exwm-randr-workspace-monitor-plist index))) - ;; if not associated, copy current association - (unless displaced-monitor - (setq displaced-monitor current-monitor)) - ;; (message "%s, %s" current-monitor displaced-monitor) - ;; swapping prevents a monitor losing all of its associations - (plist-put exwm-randr-workspace-monitor-plist current-index displaced-monitor) - (plist-put exwm-randr-workspace-monitor-plist index current-monitor) - - (exwm-workspace-switch-create index) - - (exwm-randr-refresh) - ;; (message "%s, %s, %s" exwm-randr-workspace-monitor-plist current-index index) - )) - -(defun exwm-other-assigned-workspace () - "focus other monitor's workspace. Assumes 2 monitors" - (interactive) - ;; super hacky, assumes that there are only two active workspaces - (exwm-workspace-switch-create (exwm-workspace--workspace-from-frame-or-index - (let* ((workspace-list (seq-filter 'exwm-workspace--active-p exwm-workspace--list)) - (active-workspaces workspace-list)) - (while (not (eq (car active-workspaces) (selected-frame))) - (setq active-workspaces (cdr active-workspaces))) - (setq active-workspaces (cdr active-workspaces)) - (if (eq active-workspaces nil) - (car workspace-list) - (car active-workspaces)))))) - -;; (add-hook 'exwm-randr-screen-change-hook -;; (lambda () -;; (let ((connected (shell-command-to-string "xrandr"))) -;; (if (and (string-match "HDMI-0 connected" connected) (string-match "DP-0 connected" connected) (string-match "DVI-I-1 connected" connected)) -;; (start-process-shell-command -;; "xrandr" nil "xrandr --output HDMI-0 --rotate right --pos 0x240 --output DP-0 --auto --pos 1080x0 --output DVI-I-1 --auto --pos 1080x1080") -;; ;;else -;; (start-process-shell-command -;; "xrandr" nil "xrandr --output DP-0 --auto --primary --output HDMI-0 --auto"))) -;; (exwm-randr-refresh))) -(exwm-randr-mode) - -;;(exwm-config-default) -(exwm-systemtray-mode) -(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 - -;; All buffers created in EXWM mode are named "*EXWM*". You may want to -;; change it in `exwm-update-class-hook' and `exwm-update-title-hook', which -;; are run when a new X window class name or title is available. Here's -;; some advice on this topic: -;; + Always use `exwm-workspace-rename-buffer` to avoid naming conflict. -;; + For applications with multiple windows (e.g. GIMP), the class names of - ; all windows are probably the same. Using window titles for them makes -;; more sense. -;; In the following example, we use class names for all windows except for -;; Java applications and GIMP. -;; (add-hook 'exwm-update-class-hook -;; (lambda () -;; (unless (or (string-prefix-p "sun-awt-X11-" exwm-instance-name) -;; (string= "gimp" exwm-instance-name)) -;; (exwm-workspace-rename-buffer exwm-class-name)))) -;; (add-hook 'exwm-update-title-hook -;; (lambda () -;; (when (or (not exwm-instance-name) -;; (string-prefix-p "sun-awt-X11-" exwm-instance-name) -;; (string= "gimp" exwm-instance-name)) -;; (exwm-workspace-rename-buffer exwm-title)))) - - -;; store the buffer we were at before a jump -(setq exwm-marked-buffer "*scratch*") - -;; Global keybindings can be defined with `exwm-input-global-keys'. -;; Here are a few examples: -(setq exwm-input-global-keys - `( - ;; Bind "s-r" to exit char-mode and fullscreen mode. - ([?\s-r] . exwm-reset) - ([?\M-r] . exwm-reset) - ;; Bind "s-w" to window switcher - ([?\s-w] . consult-buffer) - ;; ([?\M-w] . open-window-by-buffer) - ([?\M-W] . consult-buffer) - - ;;quicker 2-split swtiching - ([?\s-o] . (lambda () - (interactive) - (other-window 1))) - ([?\M-o] . (lambda () - (interactive) - (other-window 1))) - - ;;fast workspace switch - ([?\s-O] . exwm-other-assigned-workspace) - ([?\M-O] . exwm-other-assigned-workspace) - - ;;quick calc switching - ;; ([?\s-c] . switch-to-calc) - - ;;mark the buffer - ;; ([?\s- ] . (lambda () - ;; (interactive) - ;; (setq exwm-marked-buffer (current-buffer)) - ;; (message "Marked the current buffer, return (across workspaces) with s-x"))) - - ;;return to marked buffer - ;; ([?\s-x] . (lambda () - ;; (interactive) - ;; (let ((hold exwm-marked-buffer)) - ;; (setq exwm-marked-buffer (current-buffer)) - ;; (exwm-workspace-switch-to-buffer hold)))) - - ;; Bind "s-0" to "s-9" to switch to a layout. - ;; ,@(mapcar - ;; (lambda (digit) - ;; ;; `(,(kbd (concat "s-" (int-to-string digit))) . (lambda () (interactive) (exwm-assign-workspace ,digit))) - ;; `(,(kbd (concat "s-" (int-to-string digit))) . (lambda () - ;; (interactive) - ;; (exwm-workspace-switch-create ,digit))) - ;; ) - ;; (number-sequence 0 9)) - - ([?\s-d] . (lambda (command) - (interactive (list (read-shell-command "$ "))) - (start-process-shell-command command nil command))) - ;; ([?\M-d] . (lambda (command) - ;; (interactive (list (read-shell-command "$ "))) - ;; (start-process-shell-command command nil command))) - ;; browser - ([?\s-e] . (lambda () - (interactive) - (start-process-shell-command "vimb" nil "vimb"))) - ([?\s-E] . (lambda () - (interactive) - (start-process-shell-command "firefox" nil "firefox"))) - ;; ([?\M-e] . (lambda () - ;; (interactive) - ;; (start-process-shell-command "vimb" nil "vimb"))) - - ;;terminal - ([s-return] . eshell) - ;; ((kbd "M-<return>") . eshell) - ;; ([?\M-return] . (lambda () - ;; (interactive) - ;;if we are already there, switch back - ;; (if (string= (buffer-name (current-buffer)) "*vterm*") - ;; (exwm-workspace-switch-to-buffer exwm-last-buffer) - ;; (progn - ;; (setq exwm-last-buffer (current-buffer)) - ;; (vterm))))) - - ;; return to the last window - ;; ([?\s-tab] . (lambda () - ;; (interactive) - ;; (exwm-workspace-switch-to-buffer (other-buffer)))) - - ;; kill the current window and close the buffer if possible - ([?\s-Q] . kill-buffer-and-window) - ([?\M-Q] . kill-buffer-and-window) - - ;; kill current buffer but leave window - ([?\s-q] . (lambda () (interactive) (kill-buffer nil))) - - ;; suspend - ;; ([?\s-`] . (lambda () - ;; (interactive) - ;; (start-process "" nil "loginctl" "suspend"))) - )) - -;; requires some custom shell scripts not included in my emacs config -(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%")) - -;; To add a key binding only available in line-mode, simply define it in -;; `exwm-mode-map'. The following example shortens 'C-c q' to 'C-q'. -(define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key) -(define-key exwm-mode-map [?\M-!] #'shell-command) -(define-key exwm-mode-map [?\s-d] (lambda (command) - (interactive (list (read-shell-command "$ "))) - (start-process-shell-command command nil command))) -(define-key exwm-mode-map [?\M-o] #'other-window) - -(global-set-key (kbd "<XF86MonBrightnessDown>") 'my/brightnessdown) -(global-set-key (kbd "<XF86MonBrightnessUp>") 'my/brightnessup) -(global-set-key (kbd "<XF86AudioMute>") 'my/mute) -(global-set-key (kbd "<XF86AudioLowerVolume>") 'my/voldown) -(global-set-key (kbd "<XF86AudioRaiseVolume>") 'my/volup) - -(define-key exwm-mode-map (kbd "<XF86MonBrightnessDown>") 'my/brightnessdown) -(define-key exwm-mode-map (kbd "<XF86MonBrightnessUp>") 'my/brightnessup) -(define-key exwm-mode-map (kbd "<XF86AudioMute>") 'my/mute) -(define-key exwm-mode-map (kbd "<XF86AudioLowerVolume>") 'my/voldown) -(define-key exwm-mode-map (kbd "<XF86AudioRaiseVolume>") 'my/volup) - -;; The following example demonstrates how to use simulation keys to mimic -;; the behavior of Emacs. The value of `exwm-input-simulation-keys` is a -;; list of cons cells (SRC . DEST), where SRC is the key sequence you press -;; and DEST is what EXWM actually sends to application. Note that both SRC -;; and DEST should be key sequences (vector or string). -(setq 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]) - ([?\C-d] . [delete]) - ([?\C-k] . [S-end delete]) - ;; cut/paste. - ;; ([?\C-w] . [?\C-x]) - ([?\M-w] . [?\C-c]) - ([?\C-y] . [?\C-v]) - ;; search - ([?\C-s] . [?\C-f]))) - -;; You can hide the minibuffer and echo area when they're not used, by -;; uncommenting the following line. -;; (setq exwm-workspace-minibuffer-position 'bottom) - - -;; specifically disable S-return in the minibuffer so you don't hit it on accident -;; This is here cause cause the other s-* bindings are here -(if vertico-mode - (define-key vertico-map (kbd "s-<return>") 'vertico-exit) - (define-key minibuffer-mode-map (kbd "s-<return>") 'minibuffer-complete-and-exit)) - -;; Do not forget to enable EXWM. It will start by itself when things are -;; ready. You can put it _anywhere_ in your configuration. -(exwm-enable) -(call-process "dunst" nil 0) -(call-process "bash" nil 0 nil "-c" "uname -a | grep -q gentoo && gentoo-pipewire-launcher") - diff --git a/emacs/site-lisp/general-text.el b/emacs/site-lisp/general-text.el deleted file mode 100644 index e593487..0000000 --- a/emacs/site-lisp/general-text.el +++ /dev/null @@ -1,32 +0,0 @@ -;; General stuff for editing all text, but particularly prose - -(provide 'general-text) - -;; dictionaries -(define-prefix-command 'dict-map) -(define-keymap :full nil - :parent nil - :suppress nil - :keymap nil - :name "dict-map" - :prefix 'dict-map - (kbd "w") 'sdcv-search-input - (kbd "c") (lambda () (interactive) - (activate-input-method 'pyim) - (sdcv-search-input (read-from-minibuffer "Chinese Word: " - nil nil nil - nil nil t)) - (activate-input-method nil))) - -(setq ispell-personal-dictionary "/home/tmu/.aspell.en.pws") -(add-hook 'text-mode-hook (lambda () - (ispell-minor-mode 1) - (local-set-key (kbd "M-l") 'dict-map))) - -(electric-pair-mode 1) - -(use-package dabbrev - :config - (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode) - (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode) - (add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)) diff --git a/emacs/site-lisp/irc-config.el b/emacs/site-lisp/irc-config.el deleted file mode 100644 index eba66a0..0000000 --- a/emacs/site-lisp/irc-config.el +++ /dev/null @@ -1,24 +0,0 @@ - -;; erc stuff -(require 'erc) -(setq erc-modules '(services autojoin button completion fill imenu irccontrols list match menu - move-to-prompt netsplit networks readonly ring stamp track) - erc-nick "tccq" - erc-use-auth-source-for-nickserv-password t - erc-autojoin-channels-alist '(("libera.chat" - "#emacs" "#emacs-social" "#linux" "#archlinux" "#haskell" "#invidious")) - - erc-hide-list '("JOIN" "PART" "QUIT") - erc-current-nick-highlight-type 'nick - erc-keywords nil - erc-track-exclude-types '("JOIN" "PART" "QUIT" "NICK" "MODE") - erc-track-use-faces t - erc-track-faces-priority-list '(erc-current-nick-face erc-keyword-face) - erc-track-priority-faces-only 'all) - -(defun my/start-erc () - "Start erc and autojoin various channels" - (interactive) - (erc :server "irc.libera.chat" :port 6667)) - -(provide 'irc-config) diff --git a/emacs/site-lisp/modeline-config.el b/emacs/site-lisp/modeline-config.el deleted file mode 100644 index 5b1f7e5..0000000 --- a/emacs/site-lisp/modeline-config.el +++ /dev/null @@ -1,39 +0,0 @@ -;;; Modeline config - -(provide 'modeline-config) - -(use-package doom-modeline - :init - (doom-modeline-mode 1)) -(use-package minions - :init - (minions-mode 1) - :custom - (minions-prominent-modes '(persp-mode auto-fill-mode eldoc-mode eglot-mode lsp-mode))) - -(setq-default global-mode-string '("" (:eval (concat (with-face (format " [%s] " (shorten-path default-directory)) - :weight 'bold - :foreground "green2"))))) - -;; ----------------------------------------------------------------------------- -;; telephone line stuff - -;; (setq telephone-line-primary-left-separator 'telephone-line-tan-left) -;; (setq telephone-line-primary-right-separator 'telephone-line-tan-right) - -;; (telephone-line-defsegment* telephone-line-time-segment () -;; (telephone-line-raw display-time-string t)) - -;; (setq telephone-line-lhs -;; '((evil . (telephone-line-evil-tag-segment)) -;; (accent . (telephone-line-vc-segment -;; telephone-line-erc-modified-channels-segment -;; telephone-line-process-segment)) -;; (nil . (telephone-line-buffer-segment -;; telephone-line-minions-mode-segment)))) -;; (setq telephone-line-rhs -;; '((nil . (telephone-line-misc-info-segment)) -;; (accent . (telephone-line-time-segment)) -;; (evil . (telephone-line-airline-position-segment)))) - -;; (telephone-line-mode 1) diff --git a/emacs/site-lisp/my-binds.el b/emacs/site-lisp/my-binds.el deleted file mode 100644 index 990dd46..0000000 --- a/emacs/site-lisp/my-binds.el +++ /dev/null @@ -1,24 +0,0 @@ -;;; Various custom binds that aren't part of an external package - -(provide 'my-binds) -(require 'my-funcs) - -(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal) -(global-set-key (kbd "C-x C-c") 'close-or-kill) -(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor -(global-set-key (kbd "M-(") 'wrap-region-paren) -(global-set-key (kbd "M-z") 'zap-whitespace) -(global-set-key (kbd "C-M-z") 'wrap-sexp) -(global-set-key (kbd "M-o") 'other-window) -(global-set-key (kbd "M-c") 'calc) -(global-set-key (kbd "M-U") 'scroll-lock-mode) -(global-set-key (kbd "M-Q") 'auto-fill-mode) -(require 'dired) -(keymap-set dired-mode-map "C-o" 'dired-display-file) -(keymap-set dired-mode-map "F" 'dired-do-find-marked-files) - -;; searching -(global-set-key (kbd "M-s g") 'rgrep) -(global-set-key (kbd "M-s r") 'counsel-rg) - -(global-set-key (kbd "C-x w o") 'toggle-window-other-reachability) diff --git a/emacs/site-lisp/my-funcs.el b/emacs/site-lisp/my-funcs.el deleted file mode 100644 index 37a8b7b..0000000 --- a/emacs/site-lisp/my-funcs.el +++ /dev/null @@ -1,164 +0,0 @@ -;;; Various functions functions that are not part of an external package - -(provide 'my-funcs) - - -;; see transparancy in init.el -(defun toggle-frame-transparency () - "Toggle transparency." - (interactive) - (let ((alpha-transparency 90)) - (if (eq alpha-transparency (frame-parameter nil 'alpha-background)) - (set-frame-parameter nil 'alpha-background 100) - (set-frame-parameter nil 'alpha-background alpha-transparency)))) - -(defun wrap-region-paren () - "Wraps the region in parens. -Similar to pressing ( with the region active." - (interactive) - (let ((beg (region-beginning)) - (end (region-end))) - (save-excursion - (goto-char beg) - (insert "(") - (goto-char (+ end 1)) - (insert ")") - ))) - -(defun zap-whitespace () - "zaps the whitespace around the point in both directions" - (interactive) - (push-mark) - (skip-chars-backward " \t\n") - (push-mark) - (skip-chars-forward " \t\n") - (delete-region (mark) (point)) - (pop-mark) - (goto-char (mark)) - (pop-mark)) - -(defun wrap-sexp (&optional arg) - "Wraps the following sexp in a pair of parens. -Places inside the new pair, with prefix arg do the same backwards, pushing the -mark. Does the same of ARG number sexps if given" - (interactive "p") - (message "%s" arg) - (if arg - (progn - (push-mark) - (insert-pair arg ?\( ?\))) - (insert-pair 1 ?\( ?\)))) - -(defun close-or-kill () - "If this is the sole frame, kill emacs. Otherwise close the frame." - (interactive) - (if (eq 1 (length (frame-list))) - ;; sole frame, exit - (save-buffers-kill-terminal) - (delete-frame))) - -(defun toggle-window-other-reachability () - (interactive) - (let* ((win (get-buffer-window (current-buffer))) - (current (window-parameter win 'no-other-window))) - (set-window-parameter win 'no-other-window (not current)))) - -;; indent code when pasting, from -;; https://trey-jackson.blogspot.com/2008/03/emacs-tip-15-indent-yanked-code.html - -;; automatically indenting yanked text if in programming-modes -(defvar yank-indent-modes '(emacs-lisp-mode - c-mode c++-mode - tcl-mode sql-mode - perl-mode cperl-mode - java-mode jde-mode - lisp-interaction-mode - LaTeX-mode TeX-mode - rust-mode - rustic-mode) - "Modes in which to indent regions that are yanked (or yank-popped).") - -(defun yank-advised-indent-function (beg end) - "Do indentation, as long as the region isn't too large. -BEG and END define the region." - (indent-region beg end nil)) - -(defadvice yank (after yank-indent activate) - "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." - (if (and (not (ad-get-arg 0)) - (member major-mode yank-indent-modes)) - (let ((transient-mark-mode nil)) - (yank-advised-indent-function (region-beginning) (region-end))))) - -(defadvice yank-pop (after yank-pop-indent activate) - "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." - (if (and (not (ad-get-arg 0)) - (member major-mode yank-indent-modes)) - (let ((transient-mark-mode nil)) - (yank-advised-indent-function (region-beginning) (region-end))))) - -(if want-evil - (progn - (defadvice evil-paste-before (after yank-indent activate) - "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." - (if (and (not (ad-get-arg 0)) - (member major-mode yank-indent-modes)) - (let ((transient-mark-mode nil)) - (yank-advised-indent-function (region-beginning) (region-end))))) - - (defadvice evil-paste-after (after yank-indent activate) - "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." - (if (and (not (ad-get-arg 0)) - (member major-mode yank-indent-modes)) - (let ((transient-mark-mode nil)) - (yank-advised-indent-function (region-beginning) (region-end))))))) - -(defun fold-this-fold-forward (&optional arg) - "Fold forward ARG number of sexps, defaulting to one." - (interactive "p") - (push-mark) - (forward-sexp arg) - (fold-this (mark) (point)) - (pop-mark)) - -(defun fold-this-fold-backward (&optional arg) - "Fold backward ARG number of sexps, defaulting to one." - (interactive "p") - (push-mark) - (backward-sexp arg) - (fold-this (point) (mark)) - (pop-mark)) - -(defun clean-prog-file (buffer) - "Fixes whitespace in buffer" - (save-excursion - (with-current-buffer buffer - (untabify (point-min) (point-max)) - (goto-char (point-min)) - (while (re-search-forward " +$" nil t) - (replace-match "" nil nil))))) - -(defun open-window-by-buffer (buffer) - "Move focus to an extant window by the buffer it contains." - (interactive "bBuffer: ") - (let ((win (get-buffer-window buffer t))) - (if win - (select-window win) - (switch-to-buffer buffer)))) - -(defun dired-do-find-marked-files () - (interactive) - (seq-do 'find-file (dired-get-marked-files))) - -(defun shorten-path (path) - "Shortens each directory in PATH except for the last directory to its first character." - (let* ((components (split-string path "/")) ; Split the path into components - (last-component (-last (lambda (s) (not (string-empty-p s))) components)) ; Extract the last component - (shortened-components ; Shorten all components except the last - (mapcar (lambda (comp) - (if (or (string-equal comp last-component) (string-empty-p comp)) - comp - (substring comp 0 1))) - components))) - (mapconcat 'identity shortened-components "/"))) ; Recombine components into a path - diff --git a/emacs/site-lisp/single-header.el b/emacs/site-lisp/single-header.el index 06faff5..2713c5b 100755 --- a/emacs/site-lisp/single-header.el +++ b/emacs/site-lisp/single-header.el @@ -1,40 +1,103 @@ -(provide 'single-header) +(require 'ednc) +(require 'battery) +(require 's) +(require 'dash) -(defvar single-header--current-header-buffer nil "Read the name") +;; not toggled with the mode to prevent user from having to restart +;; applications producing notifs. +(when (equal window-system 'x) + (ednc-mode 1)) -(defvar single-header-format '(make-header-info-string) "evaluated to fill the header") +;; testing +;; (require 'notifications) +;; (notifications-notify :title "2st test" :body "hello, world" :app-name "EDNC" +;; :actions '("default" "default")) + +(defvar single-header-update-increment 3 "Number of seconds before updating the header again.") + +(defvar single-header--current-header-buffer nil "Read the name") (defface single-header '((default . (:background "#000000" :family "Source Code Pro"))) "Face for top line") -(require 'battery) -(defun with-face (str &rest face-plist) +(setq single-header--active-notifs nil) +(setq single-header--timer nil +;; "Timer that triggers updates of the header contents. Use `single-header-update' for forcing updates." + ) + +(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 make-header-info-string () - "generates the mode line string that contains all the info to the right" +(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)))) + +(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)) + +(defun single-header-format () + "Evaluated in the header buffer when empty to fill the buffer." + (let* ((win (get-buffer-window (current-buffer))) + (win-width (window-max-chars-per-line win 'single-header)) + (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)) + (setq padding (single-header--with-face padding 'single-header)) + (setq info (single-header--with-face info 'single-header)) + (insert notifs padding info))) + + + +(defun single-header--make-header-info-string () + "Generates the mode line string that contains all the info to the right." (let ((str (concat - (with-face (battery-format "[%b%p%%] " (and battery-status-function (funcall battery-status-function))) + (single-header--with-face (battery-format "[%b%p%%] " (and battery-status-function (funcall battery-status-function))) :weight 'bold) - (with-face (let* ((mi (memory-info)) + (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") - (with-face (format "<%03.2f> " (car (load-average 1))) + (single-header--with-face (format "<%03.2f> " (car (load-average 1))) :foreground "#da70d6") (format-time-string "%a, %b %+4Y-%0m-%0d ") - (with-face (format-time-string "%R") + (single-header--with-face (format-time-string "%R") :weight 'bold) ))) - (setq str (concat (make-string - (- (window-max-chars-per-line (minibuffer-window) 'single-header) - (length str)) - ? ) - str)) - (with-face str 'single-header))) + (single-header--with-face str 'single-header))) (defun single-header-init-buffer (buf) (with-current-buffer buf @@ -69,7 +132,7 @@ (window-preserve-size win nil t)))) (defun single-header-show (buf) - "show / make a header" + "Show the header, making it if necessary." (if (buffer-live-p buf) (let ((win (display-buffer-in-side-window buf '((side . top) (slot . -100))))) @@ -77,43 +140,67 @@ (single-header-make))) (defun single-header-make () - "create the fake header line" + "Create the header and show it." (interactive) + + (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)))) (unless (buffer-live-p single-header--current-header-buffer) (let ((buf (generate-new-buffer "*header*"))) (single-header-init-buffer buf) (setq single-header--current-header-buffer buf) - (single-header-show buf)))) + (single-header-show buf))) + (unless (timerp 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" + "Remove an existing header buffer." (interactive) + (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))) + + (when (timerp single-header--timer) + (cancel-timer single-header--timer) + (setq single-header--timer nil)) (when (buffer-live-p single-header--current-header-buffer) (kill-buffer single-header--current-header-buffer))) (defun single-header-update () - "update the contents of the header line according to `single-header-format'" + "Update the contents of the header line by calling `single-header-format' +with the header buffer current and empty." (when (buffer-live-p single-header--current-header-buffer) (with-current-buffer single-header--current-header-buffer (erase-buffer) - (insert (eval single-header-format))) - - ;; (when exwm-state - ;; (exwm-input--set-active-window - ;; (or (frame-parameter exwm-workspace--current 'exwm-outer-id) - ;; xcb:Window:None))) - )) - -(add-hook 'after-make-frame-functions (lambda (frame) - (with-selected-frame frame - (single-header-show single-header--current-header-buffer)))) - -;; (use-package lv - ;; :custom ((lv-use-separator . nil))) - -;; do init frame seperately -(single-header-show single-header--current-header-buffer) -(setq single-header--timer nil) -(unless single-header--timer - (setq single-header--timer (run-with-timer 0 3 'single-header-update))) + (single-header-format)))) + +(define-minor-mode single-header-mode + "Global minor mode to enable a single info line at the top of each frame." + :global t + :init-value nil + ;; :keymap '(("s-l d" . 'single-header-dismiss) + ;; ("s-l t" . 'single-header-mode)) + :interactive t + (if (not single-header-mode) + (single-header-delete) + (single-header-make))) + +(provide 'single-header) |
