diff options
author | Case Duckworth | 2023-05-10 13:27:06 -0500 |
---|---|---|
committer | Case Duckworth | 2023-05-10 13:27:06 -0500 |
commit | 0aaf20598d40cfbf17e047d27fcf5d1dcef0012c (patch) | |
tree | 3dc71c947c65f46acf79c9cf6958fb5196b13037 /definitions.el | |
parent | Combine {definitions,packages}.el to init.el (diff) | |
download | emacs-0aaf20598d40cfbf17e047d27fcf5d1dcef0012c.tar.gz emacs-0aaf20598d40cfbf17e047d27fcf5d1dcef0012c.zip |
Remove spurious files
Diffstat (limited to 'definitions.el')
-rw-r--r-- | definitions.el | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/definitions.el b/definitions.el deleted file mode 100644 index 125c87e..0000000 --- a/definitions.el +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | ;;; definitions.el --- definitions for my Emacs config -*- lexical-binding: t; -*- | ||
2 | |||
3 | (defun other-window-or-switch-buffer (&optional arg) | ||
4 | "Switch to the other window. | ||
5 | If a window is the only buffer on a frame, switch buffer. When | ||
6 | run with \\[universal-argument], unconditionally switch buffer." | ||
7 | (interactive "P") | ||
8 | (if (or arg (one-window-p)) | ||
9 | (switch-to-buffer (other-buffer) nil t) | ||
10 | (other-window 1))) | ||
11 | |||
12 | (defun cycle-spacing@ (&optional n) | ||
13 | ;; `cycle-spacing' is wildly different in 29.1 over 28. | ||
14 | "Negate N argument on `cycle-spacing'. | ||
15 | That is, with a positive N, deletes newlines as well, leaving -N | ||
16 | spaces. If N is negative, it will not delete newlines and leave | ||
17 | N spaces." | ||
18 | (interactive "*p") | ||
19 | (cycle-spacing (- n))) | ||
20 | |||
21 | (defun first-frame@set-fonts () | ||
22 | (remove-hook 'server-after-make-frame-hook | ||
23 | #'first-frame@set-fonts) | ||
24 | (face-spec-set 'default | ||
25 | `((t :family "Recursive Mono Casual Static" | ||
26 | :height 110))) | ||
27 | ;; Emojis | ||
28 | (cl-loop with ffl = (font-family-list) | ||
29 | for font in '("Noto Emoji" "Noto Color Emoji" | ||
30 | "Segoe UI Emoji" "Apple Color Emoji" | ||
31 | "FreeSans" "FreeMono" "FreeSerif" | ||
32 | "Unifont" "Symbola") | ||
33 | if (member font ffl) | ||
34 | do (set-fontset-font t 'symbol font)) | ||
35 | ;; International fonts | ||
36 | (cl-loop with ffl = (font-family-list) | ||
37 | for (charset . font) | ||
38 | in '((latin . "Noto Sans") | ||
39 | (han . "Noto Sans CJK SC Regular") | ||
40 | (kana . "Noto Sans CJK JP Regular") | ||
41 | (hangul . "Noto Sans CJK KR Regular") | ||
42 | (cjk-misc . "Noto Sans CJK KR Regular") | ||
43 | (khmer . "Noto Sans Khmer") | ||
44 | (lao . "Noto Sans Lao") | ||
45 | (burmese . "Noto Sans Myanmar") | ||
46 | (thai . "Noto Sans Thai") | ||
47 | (ethiopic . "Noto Sans Ethiopic") | ||
48 | (hebrew . "Noto Sans Hebrew") | ||
49 | (arabic . "Noto Sans Arabic") | ||
50 | (gujarati . "Noto Sans Gujarati") | ||
51 | (devanagari . "Noto Sans Devanagari") | ||
52 | (kannada . "Noto Sans Kannada") | ||
53 | (malayalam . "Noto Sans Malayalam") | ||
54 | (oriya . "Noto Sans Oriya") | ||
55 | (sinhala . "Noto Sans Sinhala") | ||
56 | (tamil . "Noto Sans Tamil") | ||
57 | (telugu . "Noto Sans Telugu") | ||
58 | (tibetan . "Noto Sans Tibetan")) | ||
59 | if (member font ffl) | ||
60 | do (set-fontset-font t charset font))) | ||
61 | |||
62 | (defun switch-themes () | ||
63 | (interactive) | ||
64 | (let ((current-theme (car custom-enabled-themes))) | ||
65 | (mapc #'disable-theme custom-enabled-themes) | ||
66 | (enable-theme (pcase current-theme | ||
67 | ('modus-operandi 'modus-vivendi) | ||
68 | ('modus-vivendi 'modus-operandi))))) | ||
69 | |||
70 | (defun renz/sort-by-alpha-length (elems) | ||
71 | "Sort ELEMS first alphabetically, then by length." | ||
72 | (sort elems (lambda (c1 c2) | ||
73 | (or (string-version-lessp c1 c2) | ||
74 | (< (length c1) (length c2)))))) | ||
75 | |||
76 | (defun renz/sort-by-history (elems) | ||
77 | "Sort ELEMS by minibuffer history. | ||
78 | Use `mct-sort-sort-by-alpha-length' if no history is available." | ||
79 | (if-let ((hist (and (not (eq minibuffer-history-variable t)) | ||
80 | (symbol-value minibuffer-history-variable)))) | ||
81 | (minibuffer--sort-by-position hist elems) | ||
82 | (renz/sort-by-alpha-length elems))) | ||
83 | |||
84 | (defun renz/completion-category () | ||
85 | "Return completion category." | ||
86 | (when-let ((window (active-minibuffer-window))) | ||
87 | (with-current-buffer (window-buffer window) | ||
88 | (completion-metadata-get | ||
89 | (completion-metadata (buffer-substring-no-properties | ||
90 | (minibuffer-prompt-end) | ||
91 | (max (minibuffer-prompt-end) (point))) | ||
92 | minibuffer-completion-table | ||
93 | minibuffer-completion-predicate) | ||
94 | 'category)))) | ||
95 | |||
96 | (defun renz/sort-multi-category (elems) | ||
97 | "Sort ELEMS per completion category." | ||
98 | (pcase (renz/completion-category) | ||
99 | ('nil elems) ; no sorting | ||
100 | ('kill-ring elems) | ||
101 | ('project-file (renz/sort-by-alpha-length elems)) | ||
102 | (_ (renz/sort-by-history elems)))) | ||
103 | |||
104 | (defvar no-tabs-modes '(emacs-lisp-mode | ||
105 | lisp-mode | ||
106 | scheme-mode | ||
107 | python-mode | ||
108 | haskell-mode) | ||
109 | "Modes /not/ to indent with tabs.") | ||
110 | |||
111 | (defun indent-tabs-mode-maybe () | ||
112 | (if (apply #'derived-mode-p no-tabs-modes) | ||
113 | (indent-tabs-mode -1) | ||
114 | (indent-tabs-mode 1))) | ||
115 | |||
116 | (define-minor-mode truncate-lines-mode | ||
117 | "Buffer-local mode to toggle `truncate-lines'." | ||
118 | :lighter "" | ||
119 | (setq-local truncate-lines truncate-lines-mode)) | ||
120 | |||
121 | ;;; Region or buffer stuff | ||
122 | |||
123 | (defun call-with-region-or-buffer (fn &rest _r) | ||
124 | "Call function FN with current region or buffer. | ||
125 | Good to use for :around advice." | ||
126 | (if (region-active-p) | ||
127 | (funcall fn (region-beginning) (region-end)) | ||
128 | (funcall fn (point-min) (point-max)))) | ||
129 | |||
130 | (defun delete-trailing-whitespace-except-current-line () | ||
131 | (save-excursion | ||
132 | (delete-trailing-whitespace (point-min) | ||
133 | (line-beginning-position)) | ||
134 | (delete-trailing-whitespace (line-end-position) | ||
135 | (point-max)))) | ||
136 | |||
137 | (defun create-missing-directories () | ||
138 | "Automatically create missing directories." | ||
139 | (let ((target-dir (file-name-directory buffer-file-name))) | ||
140 | (unless (file-exists-p target-dir) | ||
141 | (make-directory target-dir :parents)))) | ||
142 | |||
143 | |||
144 | (defun vc-remote-off () | ||
145 | "Turn VC off when remote." | ||
146 | (when (file-remote-p (buffer-file-name)) | ||
147 | (setq-local vc-handled-backends nil))) | ||
148 | |||
149 | |||