diff options
-rw-r--r-- | definitions.el | 149 | ||||
-rw-r--r-- | packages.el | 129 |
2 files changed, 0 insertions, 278 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 | |||
diff --git a/packages.el b/packages.el deleted file mode 100644 index 42d8eeb..0000000 --- a/packages.el +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | ;;; packages.el --- my Emacs packages -*- lexical-binding: t; -*- | ||
2 | |||
3 | (use-package scule | ||
4 | :load-path "~/src/scule.el/" | ||
5 | :bind-keymap ("M-c" . scule-map) | ||
6 | :init | ||
7 | ;; Use M-u for prefix keys | ||
8 | (keymap-global-set "M-u" #'universal-argument) | ||
9 | (keymap-set universal-argument-map "M-u" #'universal-argument-more)) | ||
10 | |||
11 | (use-package frowny | ||
12 | :load-path "~/src/frowny.el/" | ||
13 | :hook ((jabber-chat-mode . frowny-mode))) | ||
14 | |||
15 | (use-package hippie-completing-read | ||
16 | :load-path "~/src/hippie-completing-read.el/" | ||
17 | :bind (("M-/" . hippie-completing-read))) | ||
18 | |||
19 | (use-package mode-line-bell | ||
20 | :load-path "~/src/mode-line-bell.el/" | ||
21 | :config | ||
22 | (setq mode-line-bell-flash-time 0.25) | ||
23 | (mode-line-bell-mode)) | ||
24 | |||
25 | (use-package titlecase | ||
26 | :load-path "~/src/titlecase.el/" | ||
27 | :preface | ||
28 | (defun +titlecase-sentence-style-dwim (&optional arg) | ||
29 | "Titlecase a sentence. | ||
30 | With prefix ARG, toggle the value of | ||
31 | `titlecase-downcase-sentences' before sentence-casing." | ||
32 | (interactive "P") | ||
33 | (let ((titlecase-downcase-sentences (if arg (not titlecase-downcase-sentences) | ||
34 | titlecase-downcase-sentences))) | ||
35 | (titlecase-dwim 'sentence))) | ||
36 | (defun +titlecase-org-headings () | ||
37 | (interactive) | ||
38 | (require 'org) | ||
39 | (save-excursion | ||
40 | (goto-char (point-min)) | ||
41 | ;; See also `org-map-tree'. I'm not using that function because I want to | ||
42 | ;; skip the first headline. A better solution would be to patch | ||
43 | ;; `titlecase-line' to ignore org-mode metadata (TODO cookies, tags, etc). | ||
44 | (let ((level (funcall outline-level)) | ||
45 | (org-special-ctrl-a/e t)) | ||
46 | (while (and (progn (outline-next-heading) | ||
47 | (> (funcall outline-level) level)) | ||
48 | (not (eobp))) | ||
49 | (titlecase-region (progn (org-beginning-of-line) (point)) | ||
50 | (progn (org-end-of-line) (point))))))) | ||
51 | :config | ||
52 | (with-eval-after-load 'scule | ||
53 | (keymap-set scule-map "M-t" #'titlecase-dwim))) | ||
54 | |||
55 | ;;; Jabber | ||
56 | |||
57 | (use-package jabber | ||
58 | :load-path "~/src/jabber.el" | ||
59 | :defer t | ||
60 | :bind-keymap (("C-c j" . jabber-global-keymap)) | ||
61 | :preface nil | ||
62 | (setq-default jabber-chat-buffer-format "*%n*" | ||
63 | jabber-browse-buffer-format "*%n*" | ||
64 | jabber-groupchat-buffer-format "*%n*" | ||
65 | jabber-muc-private-buffer-format "*%n*") | ||
66 | :custom-face | ||
67 | (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign | ||
68 | :foreground unspecified | ||
69 | :weight normal))) | ||
70 | (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local | ||
71 | :foreground unspecified | ||
72 | :weight bold))) | ||
73 | (jabber-chat-prompt-local ((t :inherit minibuffer-prompt | ||
74 | :foreground unspecified | ||
75 | :weight normal | ||
76 | :slant italic))) | ||
77 | (jabber-chat-prompt-foreign ((t :inherit warning | ||
78 | :foreground unspecified | ||
79 | :weight normal))) | ||
80 | (jabber-chat-prompt-system ((t :inherit font-lock-doc-face | ||
81 | :foreground unspecified))) | ||
82 | (jabber-rare-time-face ((t :inherit font-lock-comment-face | ||
83 | :foreground unspecified | ||
84 | :underline nil))) | ||
85 | :config | ||
86 | (require 'jabber-httpupload nil t) | ||
87 | (setopt jabber-auto-reconnect t | ||
88 | jabber-last-read-marker "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~" | ||
89 | jabber-muc-decorate-presence-patterns | ||
90 | '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil) | ||
91 | ("Mode #.*" . jabber-muc-presence-dim) | ||
92 | ("." . jabber-muc-presence-dim)) | ||
93 | jabber-activity-make-strings #'jabber-activity-make-strings-shorten | ||
94 | jabber-rare-time-format | ||
95 | (format " - - - - - %%H:%d %%F" | ||
96 | (let ((min (string-to-number (format-time-string "%M")))) | ||
97 | (* 5 (floor min 5)))) | ||
98 | jabber-muc-header-line-format '(" " jabber-muc-topic)) | ||
99 | |||
100 | (setopt jabber-groupchat-prompt-format "%n. " | ||
101 | jabber-chat-local-prompt-format "%n. " | ||
102 | jabber-chat-foreign-prompt-format "%n. " | ||
103 | jabber-muc-private-foreign-prompt-format "%g/%n. ") | ||
104 | |||
105 | (keymap-global-set "C-c C-SPC" #'jabber-activity-switch-to) | ||
106 | (map-keymap (lambda (key command) | ||
107 | (define-key jabber-global-keymap (vector (+ key #x60)) command)) | ||
108 | jabber-global-keymap) | ||
109 | (keymap-global-set "C-x C-j" #'dired-jump) | ||
110 | |||
111 | (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons) | ||
112 | (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo) | ||
113 | (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo) | ||
114 | (add-hook 'jabber-chat-mode-hook 'visual-line-mode) | ||
115 | (add-hook 'jabber-chat-mode-hook (defun jabber-no-position () | ||
116 | (setq-local mode-line-position nil))) | ||
117 | |||
118 | (add-hook 'jabber-alert-muc-hooks | ||
119 | (defun jabber@highlight-acdw (&optional _ _ buf _ _) | ||
120 | (when buf | ||
121 | (with-current-buffer buf | ||
122 | (let ((regexp (rx word-boundary | ||
123 | "acdw" ; maybe get from the config? | ||
124 | word-boundary))) | ||
125 | (hi-lock-unface-buffer regexp) | ||
126 | (highlight-regexp regexp 'jabber-chat-prompt-local)))))) | ||
127 | |||
128 | (when (fboundp 'jabber-chat-update-focus) | ||
129 | (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus))) | ||