2024-01-23 08:01:12 -09:00
|
|
|
;;; mir-defuns.el --- custom-defined functions
|
2022-06-19 14:13:36 -08:00
|
|
|
;;; Commentary:
|
2024-01-23 10:06:00 -09:00
|
|
|
|
|
|
|
;; _ _ __ _
|
|
|
|
;; _ __ ___ (_) _ __ __| | ___ / _| _ _ _ __ ___ ___ | |
|
|
|
|
;; | '_ ` _ \ | || '__|_____ / _` | / _ \| |_ | | | || '_ \ / __| / _ \| |
|
|
|
|
;; | | | | | || || | |_____|| (_| || __/| _|| |_| || | | |\__ \ _| __/| |
|
|
|
|
;; |_| |_| |_||_||_| \__,_| \___||_| \__,_||_| |_||___/(_)\___||_|
|
|
|
|
|
2022-06-19 14:13:36 -08:00
|
|
|
;; Some functions to run when loading packages...
|
|
|
|
|
|
|
|
;;; Code:
|
2024-01-23 08:01:12 -09:00
|
|
|
(defun mir/evil-config ()
|
2022-06-19 14:13:36 -08:00
|
|
|
"A batch of commands to run as the :config of evil's `use-package'.
|
|
|
|
Made solely to reduce lines in the init-file."
|
2022-10-10 12:16:37 -08:00
|
|
|
;; Visual moving
|
|
|
|
(defun move-screen-down-line ()
|
|
|
|
"Scroll down line but keep cursor in same visual position."
|
|
|
|
(interactive)
|
|
|
|
(evil-previous-line)
|
|
|
|
(scroll-down-line))
|
|
|
|
(defun move-screen-up-line ()
|
|
|
|
"Scroll up line but keep cursor in same visual position."
|
|
|
|
(interactive)
|
|
|
|
(evil-next-line)
|
|
|
|
(scroll-up-line))
|
2023-03-13 14:47:06 -08:00
|
|
|
;; Search showing
|
2024-01-23 08:01:12 -09:00
|
|
|
(defun mir/search-and-rebalance (&optional &rest flush)
|
2023-03-13 14:47:06 -08:00
|
|
|
(evil-scroll-line-to-center (car flush)))
|
2024-01-23 08:01:12 -09:00
|
|
|
(advice-add 'evil-search-next :filter-return #'mir/search-and-rebalance)
|
|
|
|
(add-hook 'isearch-mode-end-hook #'mir/search-and-rebalance))
|
|
|
|
(defun mir/visual-setup ()
|
2022-10-10 13:36:52 -08:00
|
|
|
"Commands to run when setting up any display. To be called in use-package
|
|
|
|
declarations for color schemes."
|
|
|
|
(tooltip-mode -1)
|
|
|
|
(menu-bar-mode -1)
|
2023-01-03 21:11:18 -09:00
|
|
|
(set-face-attribute 'fixed-pitch nil
|
2024-01-23 07:48:22 -09:00
|
|
|
:family "MesloLGS Nerd Font")
|
2023-01-03 21:11:18 -09:00
|
|
|
(set-face-attribute 'default nil
|
2024-01-23 07:48:22 -09:00
|
|
|
:family "MesloLGS Nerd Font")
|
2022-11-19 17:13:25 -09:00
|
|
|
;; (set-face-attribute 'variable-pitch nil
|
|
|
|
;; :inherit 'default
|
|
|
|
;; :family "Sans Serif")
|
2022-10-10 13:36:52 -08:00
|
|
|
(setq window-divider-default-places t)
|
|
|
|
(setq right-divider-width 5)
|
|
|
|
(setq ring-bell-function 'ignore)
|
2023-01-03 21:11:18 -09:00
|
|
|
(add-to-list 'initial-frame-alist '(alpha-background . 65))
|
|
|
|
(add-to-list 'default-frame-alist '(alpha-background . 65))
|
2022-10-10 13:36:52 -08:00
|
|
|
(add-to-list 'default-frame-alist '(cursor-color . "white"))
|
2022-11-01 14:19:28 -08:00
|
|
|
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
|
|
|
;; see also https://emacs.stackexchange.com/questions/7228/nice-tty-window-borders-in-24-4
|
2024-01-23 21:16:59 -09:00
|
|
|
(unless (display-graphic-p)
|
|
|
|
(let ((display-table (or standard-display-table (make-display-table))))
|
|
|
|
(set-display-table-slot display-table 'vertical-border (make-glyph-code ?│))
|
|
|
|
(setq standard-display-table display-table))))
|
2024-01-23 08:01:12 -09:00
|
|
|
(defun mir/graphical-setup ()
|
2022-10-04 17:50:38 -08:00
|
|
|
"Commands to run at the beginning of init when on a graphical display.
|
|
|
|
This prevents errors in termux and speeds up init when editing from the
|
|
|
|
console."
|
2022-06-19 14:13:36 -08:00
|
|
|
;; hide gui scrollbars and menubar etc
|
2022-07-16 17:57:38 -08:00
|
|
|
(scroll-bar-mode -1) ;; use `yascroll' instead
|
2022-06-19 14:13:36 -08:00
|
|
|
(setq scroll-bar-adjust-thumb-portion nil)
|
|
|
|
(tool-bar-mode 0)
|
|
|
|
(menu-bar-mode 0)
|
|
|
|
(set-fringe-mode 8)
|
|
|
|
;; diable stupid file open box thingy
|
|
|
|
(setq use-file-dialog nil)
|
|
|
|
(setq use-dialog-box nil)
|
|
|
|
;; Pixel scrolling. Only in emacs 29+...
|
|
|
|
(if (>= (string-to-number emacs-version) 29)
|
2022-10-04 17:55:09 -08:00
|
|
|
(pixel-scroll-precision-mode t)
|
|
|
|
(pixel-scroll-mode t))
|
2024-01-23 10:35:52 -09:00
|
|
|
;; Size of text. おまえ わ もう しんでいる.
|
|
|
|
(let* ((resolution (mapcar #'string-to-number
|
|
|
|
(split-string
|
|
|
|
(cadr (split-string
|
|
|
|
(shell-command-to-string
|
|
|
|
"neofetch resolution"))) "x")))
|
|
|
|
(resx (car resolution))
|
|
|
|
(resy (cadr resolution))
|
2024-02-01 15:47:26 -09:00
|
|
|
(font-height (+ 15 (/ resy 8))))
|
2024-01-23 10:35:52 -09:00
|
|
|
(set-face-attribute 'fixed-pitch nil :height font-height)
|
|
|
|
(set-face-attribute 'default nil :height font-height)
|
|
|
|
(set-face-attribute 'variable-pitch nil :height (+ font-height 10))))
|
2022-06-19 14:13:36 -08:00
|
|
|
|
|
|
|
(defun toggle-ja-input ()
|
2024-01-23 21:17:35 -09:00
|
|
|
"Switch between english and japanese. Not broken."
|
2022-06-19 14:13:36 -08:00
|
|
|
(interactive)
|
|
|
|
(if (eq current-input-method 'japanese)
|
|
|
|
(setq current-input-method 'japanese-ascii)
|
|
|
|
(setq current-input-method 'japanese)))
|
|
|
|
|
|
|
|
(defun turn-off-line-numbers ()
|
2022-06-22 06:31:32 -08:00
|
|
|
"A tiny wrapper around `display-line-numbers-mode' or `linum'.
|
2022-06-19 14:13:36 -08:00
|
|
|
For use in hooks."
|
|
|
|
(interactive)
|
2022-07-16 18:03:19 -08:00
|
|
|
(if (bound-and-true-p display-line-numbers-mode)
|
2022-06-22 06:31:32 -08:00
|
|
|
(display-line-numbers-mode -1))
|
2022-07-22 16:23:10 -08:00
|
|
|
(if (fboundp #'linum-mode)
|
|
|
|
(linum-mode -1))
|
2022-07-16 18:03:19 -08:00
|
|
|
(if (fboundp #'linum-relative-mode)
|
2022-11-30 16:27:43 -09:00
|
|
|
(linum-relative-mode -1))
|
|
|
|
(if (fboundp #'nlinum-mode)
|
|
|
|
(nlinum-mode -1))
|
|
|
|
(if (fboundp #'nlinum-relative-mode)
|
|
|
|
(nlinum-relative-mode -1)))
|
2022-06-19 14:13:36 -08:00
|
|
|
|
2024-01-23 08:01:12 -09:00
|
|
|
(defun mir/terminal-setup ()
|
2022-06-19 14:13:36 -08:00
|
|
|
"A batch of commands to run when opening anything that looks like a terminal.
|
|
|
|
For instance:
|
|
|
|
- Shell
|
|
|
|
- (ansi-)term
|
|
|
|
- eshell
|
|
|
|
- vterm
|
|
|
|
- Maybe SLIME too."
|
|
|
|
(turn-off-line-numbers))
|
|
|
|
|
|
|
|
;; This one line cost me over an hour of frustration...
|
2024-01-23 08:01:12 -09:00
|
|
|
(provide 'mir-defuns)
|
2022-06-19 14:13:36 -08:00
|
|
|
|
2024-01-23 08:01:12 -09:00
|
|
|
;;; mir-defuns.el ends here
|