summaryrefslogtreecommitdiff
path: root/config/emacs/site-lisp/my-builtins.el
diff options
context:
space:
mode:
Diffstat (limited to 'config/emacs/site-lisp/my-builtins.el')
-rw-r--r--config/emacs/site-lisp/my-builtins.el200
1 files changed, 200 insertions, 0 deletions
diff --git a/config/emacs/site-lisp/my-builtins.el b/config/emacs/site-lisp/my-builtins.el
new file mode 100644
index 0000000..94e82c1
--- /dev/null
+++ b/config/emacs/site-lisp/my-builtins.el
@@ -0,0 +1,200 @@
+;;; Builtin config: -*- lexical-binding: t; -*-
+
+(use-package server ; allow emacsclient
+ :demand t
+ :config
+ (unless (server-running-p) (server-start)))
+
+(use-package proced ; process editor
+ :commands (proced)
+ :config
+ (setq-default proced-auto-update-flag t)
+ (setq-default proced-auto-update-interval 1))
+
+(use-package dabbrev ; dynamic abbreviations
+ :demand t
+ :config
+ (add-to-list 'dabbrev-ignored-buffer-modes 'exwm-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode))
+
+(progn ; dired directory editor
+ (require 'dired)
+ (defun dired-do-find-marked-files ()
+ (interactive)
+ (seq-do 'find-file (dired-get-marked-files)))
+ (define-key dired-mode-map (kbd "C-o") 'dired-display-file)
+ (define-key dired-mode-map (kbd "F") 'dired-do-find-marked-files))
+
+(use-package ibuffer ; give a nice list of buffers with extra info
+ :commands (ibuffer)
+ :custom
+ (ibuffer-formats
+ '((mark modified read-only " "
+ (name 50 50 :left :elide) ; was originally 18
+ " "
+ (size 9 -1 :right)
+ " "
+ (mode 16 16 :left :elide)
+ " " filename-and-process)
+ (mark " "
+ (name 16 -1)
+ " " filename)))
+ :bind
+ ("C-x C-b" . ibuffer))
+
+(progn ; isearch search in buffer
+ ;; swap basic and regex binds
+ (keymap-set global-map "C-s" 'isearch-forward-regexp)
+ (keymap-set global-map "C-r" 'isearch-backward-regexp)
+ (keymap-set global-map "C-M-s" 'isearch-forward)
+ (keymap-set global-map "C-M-r" 'isearch-backward))
+
+(use-package eshell ; emacs shell
+ :demand t
+ :config
+ (use-package esh-help)
+ (require 'em-hist)
+ (require 'em-term)
+ (setup-esh-help-eldoc)
+ :bind (:map eshell-mode-map
+ ("C-l" . my/eshell-clear-or-center)) ; todo make smarter with centering
+ :hook (eshell-mode . eldoc-mode))
+
+(use-package ediff ; emacs interactive diff
+ :custom
+ (ediff-window-setup-function 'ediff-setup-windows-plain))
+
+(progn ; comint, doesn't play with use-package
+ (require 'comint)
+ (setq-default comint-scroll-to-bottom-on-input t)
+ (setq-default comint-scroll-to-bottom-on-output t)
+ (setq-default comint-buffer-maximum-size 1048576)
+ (add-to-list 'comint-output-filter-functions #'comint-truncate-buffer)
+ (add-to-list 'comint-output-filter-functions #'ansi-color-process-output))
+
+(use-package tramp ; remote access for files
+ :demand t
+ :custom
+ (tramp-allow-unsafe-temporary-files t))
+
+(use-package asm-mode ; asm comments and tags generation
+ :demand t
+ :custom
+ (asm-comment-char ?#) ; prefer # over ; for asm comments
+ :init
+ (defun add-asm-label-tag-generation-hook ()
+ (add-hook 'after-save-hook
+ (lambda ()
+ (shell-command
+ "find . -iregex '.*\\.[sS]' -exec etags -l none -r '/\\([a-zA-Z0-9\\-_]+\\):/\1/' {} +"))
+ 0 t))
+ :hook
+ (asm-mode . 'add-asm-label-tag-generation-hook))
+
+(use-package compile ; compliation buffers and easy bind
+ :custom
+ (compilation-always-kill t)
+ (compilation-scroll-output t)
+ :bind (:map my/keys-mode-map ("M-M" . 'recompile))
+ :config
+ ;; Allow compilation buffer to be dedicated across frames
+ (add-to-list 'display-buffer-alist '("\\*compilation\\*" nil (reusable-frames . t)))
+ (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter))
+
+(use-package man ; view manuals in emacs
+ :custom
+ (Man-switches "-a"))
+
+(use-package imenu ; jump to items in the current buffer
+ :bind
+ ("M-i" . imenu)
+ :custom
+ (imenu-auto-rescan t)
+ (imenu-flatten t))
+
+(use-package xref ; jump to syntactic elements in project
+ ;; (add-hook 'xref-backend-functions 'gxref-xref-backend)
+ :bind ("M-I" . xref-find-definitions))
+
+(use-package time ; time if I want it in the modeline etc
+ :custom
+ (display-time-day-and-date t)
+ (display-time-24hr-format t))
+
+(use-package battery ; battery in modeline etc
+ )
+
+(progn ; indent code when pasting
+ (require 'dash)
+ (defvar yank-indent-modes '(prog-mode LaTeX-mode TeX-mode)
+ "Modes in which to indent regions that are yanked (or yank-popped).")
+
+ (defun yank-indent-func (&optional arg)
+ (let* ((parents (derived-mode-all-parents major-mode))
+ (helper (lambda (acc v) (or acc (member v yank-indent-modes))))
+ (included (-reduce helper parents)))
+ (when (and (not arg) included)
+ (indent-region (region-beginning) (region-end)))))
+
+ (advice-add 'yank :after 'yank-indent-func)
+ (advice-add 'yank-pop :after 'yank-indent-func))
+
+(progn ; 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-or-uncomment-region)
+ ;; ^ duped for terminal w/o C-;
+ )
+
+(progn ; default modeline config additions
+ (let ((dir '("" (:eval (let ((str (concat (format " [%s] " (my/shorten-path default-directory)))))
+ (add-face-text-property
+ 0 (length str)
+ '(:weight bold :foreground "green2")
+ t str)
+ str)))))
+ (add-to-list 'mode-line-misc-info dir)))
+
+(progn ; comfy scratch buffer
+ (require 'iimage)
+ (setq inhibit-startup-screen t)
+ (setq initial-scratch-message
+ (concat (propertize ";; " 'invisible t)
+ "</home/tmu/.emacs.d/splashLaputa.png>
+;; scratch for lisp evaluation and unsaved text
+
+"))
+ (add-hook 'emacs-startup-hook
+ (lambda ()
+ (with-current-buffer "*scratch*"
+ (emacs-lock-mode 'kill)
+ (iimage-mode 1)))))
+
+(use-package which-func ; headline
+ :custom
+ (which-func-display 'header)
+ (which-func-modes '(c-mode c++-mode))
+ :config
+ (set-face-foreground 'which-func "sky-blue")
+ (which-function-mode))
+
+(progn ; vc and related binds
+ (setq vc-follow-symlinks t)
+ (vc-auto-revert-mode 1)
+ (add-hook 'prog-mode-hook 'smerge-mode))
+
+(progn ; confirm fewer things
+ (setq kill-buffer-query-functions
+ (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
+ (setq confirm-kill-processes nil)
+ (setq async-shell-command-buffer 'new-buffer))
+
+;; misc vars
+(setq delete-pair-blink-delay 0
+ enable-recursive-minibuffers t
+ frame-resize-pixelwise t
+ c-guess-region-max 5000)
+(electric-pair-mode 1)
+(electric-indent-mode 1)