diff options
author | tdback <tyler@tdback.net> | 2025-02-11 23:30:17 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2025-02-11 23:30:17 -0500 |
commit | 171608ece8d234df5d638c8a46934d3ec708e6fd (patch) | |
tree | 13188031887bf40ca1e250ef4cdb1828b837745a | |
parent | ff49b83fe4cf5e6e05daed48415a1cf5a854435b (diff) |
lisp: create separate theme and shell modules. add expand-region
-rw-r--r-- | lisp/td-common.el | 45 | ||||
-rw-r--r-- | lisp/td-shell.el | 88 | ||||
-rw-r--r-- | lisp/td-theme.el | 94 |
3 files changed, 203 insertions, 24 deletions
diff --git a/lisp/td-common.el b/lisp/td-common.el index d355609..ae80872 100644 --- a/lisp/td-common.el +++ b/lisp/td-common.el @@ -1,7 +1,21 @@ -;;; td-common.el --- common configuration -*- lexical-binding: t; -*- +;;; td-common.el --- a step up from vanilla -*- lexical-binding: t; -*- ;;; Code: +;;; Functions + +(defun td/quit-if-not-in-macro () + "Allow for an unintentional `C-g' when recording macros." + (interactive) + (if (or defining-kbd-macro executing-kbd-macro) + (progn + (if (region-active-p) + (deactivate-mark) + (message "Macro running. Can't quit."))) + (keyboard-quit))) + +;;; Packages + (use-package async :ensure t :config @@ -33,34 +47,13 @@ :custom (consult-dir-project-list-function nil)) -(use-package doom-modeline - :ensure t - :init - (doom-modeline-mode 1) - :custom - (doom-modeline-height 10) - (doom-modeline-buffer-encoding nil) - (doom-modeline-modal-icon nil)) - -(use-package eat - :ensure t - :bind (("C-x E" . eat)) - :custom - (eat-enable-autoline-mode t)) - -(use-package ef-themes - :ensure t - :config - ;; By default start with a light theme. - (load-theme 'ef-day t)) - (use-package emacs :ensure nil :demand t :bind (("M-c" . capitalize-dwim) ("M-u" . upcase-dwim) ("M-l" . downcase-dwim) - ("C-x S" . eshell) + ("C-x E" . eshell) ("C-x M-t" . transpose-regions) ("C-g" . td/quit-if-not-in-macro))) @@ -81,7 +74,11 @@ :ensure t :after embark) -(use-package help +(use-package expand-region + :ensure t + :bind ([remap mark-paragraph] . er/expand-region)) + +(use-package helpful :ensure t :custom (counsel-describe-function-function #'helpful-callable) diff --git a/lisp/td-shell.el b/lisp/td-shell.el new file mode 100644 index 0000000..328fb2e --- /dev/null +++ b/lisp/td-shell.el @@ -0,0 +1,88 @@ +;;; td-shell.el --- a shell and a repl! -*- lexical-binding: t; -*- + +;;; Code: + +;;; Functions + +(defun td/meow-insert-state (mode) + "If meow is installed, start `mode' in INSERT state." + (when (package-installed-p 'meow) + (add-to-list 'meow-mode-state-list `(,mode . insert)))) + +(defun td/eshell-prompt () + (concat + (propertize (abbreviate-file-name (eshell/pwd)) 'face `(:foreground "white")) + (if (zerop (user-uid)) + (propertize " # " 'face `(:foreground "red")) + (propertize " λ " 'face `(:foreground "yellow"))))) + +(defun td/eshell-configure () + (require 'xterm-color) + (push 'xterm-color-filter eshell-preoutput-filter-functions) + (delq 'eshell-handle-ansi-color eshell-output-filter-functions) + + (add-hook 'eshell-before-prompt-hook + (lambda () + (setq xterm-color-preserve-properties t))) + + ;; Use xterm-256color when running interactive commands. + (add-hook 'eshell-pre-command-hook + (lambda () (setenv "TERM" "xterm-256color"))) + (add-hook 'eshell-post-command-hook + (lambda () (setenv "TERM" "dumb"))) + + ;; Save command history when commands are entered. + (add-hook 'eshell-pre-command-hook 'eshell-save-some-history) + + ;; Initialize the shell history. + (eshell-hist-initialize) + + ;; Truncate buffer for performance. + (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer) + + (setq eshell-prompt-function 'td/eshell-prompt + eshell-prompt-regexp "^.+ λ " + eshell-history-size 10000 + eshell-buffer-maximum-lines 10000 + eshell-hist-ignoredups t + eshell-highlight-prompt t + eshell-scroll-to-bottom-on-input t + eshell-prefer-lisp-functions nil)) + +(defun td/eshell-clear () + "Allow the user to clear the current eshell buffer while retaining the +current line input." + (interactive) + (let ((input (eshell-get-old-input))) + (eshell/clear t) + (eshell-emit-prompt) + (insert input))) + +;;; Packages + +(use-package eat + :ensure t + :bind (("C-x S" . eat)) + :custom + (eat-enable-autoline-mode t) + (eat-kill-buffer-on-exit t) + :config + (td/meow-insert-state 'eat-mode)) + +(use-package eshell + :ensure nil + :hook (eshell-first-time-mode . td/eshell-configure) + :bind (("C-l" . td/eshell-clear)) + :config + (td/meow-insert-state 'eshell-mode)) + +(use-package eshell-syntax-highlighting + :ensure t + :after eshell + :config + (eshell-syntax-highlighting-global-mode +1)) + +(use-package xterm-color) + +(provide 'td-shell) +;;; td-shell.el ends here diff --git a/lisp/td-theme.el b/lisp/td-theme.el new file mode 100644 index 0000000..381cc97 --- /dev/null +++ b/lisp/td-theme.el @@ -0,0 +1,94 @@ +;;; td-theme.el --- emacs appearance -*- lexical-binding: t; -*- + +;;; Code: + +;;; Functions + +(defun td/set-font () + (when (display-graphic-p) + (message "Setting font...") + (set-face-attribute 'default nil + :font "Aporetic Sans Mono" + :weight 'normal + :height 200) + (set-face-attribute 'fixed-pitch nil + :font "Aporetic Sans Mono" + :weight 'normal + :height 200) + (set-face-attribute 'variable-pitch nil + :font "Aporetic Sans Mono" + :weight 'normal + :height 200))) + +(defun td/disable-theme () + "Disable all currently enabled themes." + (interactive) + (dolist (theme custom-enabled-themes) + (disable-theme theme))) + +(defun td/toggle-theme () + "Toggle between light and dark modes." + (interactive) + (let ((theme (if (eq (car custom-enabled-themes) 'ef-dark) + 'ef-day + 'ef-dark))) + (td/disable-theme) + (load-theme theme t))) + +(defun td/display-startup-time () + (message (if (daemonp) + "emacs daemon loaded in %s with %d garbage collections." + "emacs loaded in %s with %d garbage collections.") + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done)) +;;; Packages + +(use-package doom-modeline + :ensure t + :init + (doom-modeline-mode 1) + :custom + (doom-modeline-height 10) + (doom-modeline-buffer-encoding nil) + (doom-modeline-modal-icon nil)) + +(use-package ef-themes + :ensure t + :config + ;; By default start with a light theme. + (load-theme 'ef-day t)) + +(use-package emacs + :ensure nil + :config + (add-hook 'emacs-startup-hook #'td/display-startup-time) + + ;; Fix font issues when opening a client window. + (if (daemonp) + (add-hook 'after-make-frame-functions (lambda (frame) + (with-selected-frame frame + (td/set-font)))) + (td/set-font)) + + ;; Disable line numbers for some modes. + (dolist (mode '(eat-mode-hook + eshell-mode-hook + dired-mode-hook + olivetti-mode-hook + org-mode-hook + shell-mode-hook + term-mode-hook + vterm-mode-hook)) + (add-hook mode (lambda () + (display-line-numbers-mode 0)))) + + ;; Prettify the lambda symbol. + (dolist (mode '(emacs-lisp-mode-hook + lisp-mode-hook + scheme-mode-hook)) + (add-hook mode 'prettify-symbols-mode))) + +(provide 'td-theme) +;;; td-theme.el ends here |