summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2021-08-30 16:37:49 -0500
committerCase Duckworth2021-08-30 16:37:49 -0500
commit46d55405836a35e4a10a875307e1702d766bd704 (patch)
treeb21d51d6fab0c5598ae855a1c7b6c86943660a86 /lisp
parentBetterize typo-mode (diff)
parentDelete commented flyspell blocks (diff)
downloademacs-46d55405836a35e4a10a875307e1702d766bd704.tar.gz
emacs-46d55405836a35e4a10a875307e1702d766bd704.zip
Merge branch 'main' of tildegit.org:acdw/emacs
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-erc.el39
-rw-r--r--lisp/acdw-irc.el84
-rw-r--r--lisp/acdw-modeline.el70
3 files changed, 160 insertions, 33 deletions
diff --git a/lisp/acdw-erc.el b/lisp/acdw-erc.el index e375c61..dd8525d 100644 --- a/lisp/acdw-erc.el +++ b/lisp/acdw-erc.el
@@ -78,9 +78,9 @@ If USE-TLS is non-nil, use TLS."
78 "Reconnect to all IRC servers." 78 "Reconnect to all IRC servers."
79 (interactive) 79 (interactive)
80 (dolist (buffer (filter-server-buffers)) 80 (dolist (buffer (filter-server-buffers))
81 (with-message (format "Reconnecting to server: %s" (buffer-name buffer)) 81 (with-current-buffer buffer
82 (with-current-buffer buffer 82 (ignore-errors
83 (erc-server-reconnect))))) 83 (erc-cmd-RECONNECT)))))
84 84
85(defun erc/disconnect () 85(defun erc/disconnect ()
86 "Disconnect from all IRC servers." 86 "Disconnect from all IRC servers."
@@ -183,11 +183,9 @@ erc-modified-channels-alist. Should be executed on window change."
183 "Overlay used to set bar") 183 "Overlay used to set bar")
184 184
185(setq erc-bar-overlay (make-overlay 0 0)) 185(setq erc-bar-overlay (make-overlay 0 0))
186 186(overlay-put erc-bar-overlay 'face '(:overline "gray"))
187 187
188(with-eval-after-load 'erc-track 188(with-eval-after-load 'erc-track
189 (overlay-put erc-bar-overlay 'face '(:underline "gray"))
190
191 ;;put the hook before erc-modified-channels-update 189 ;;put the hook before erc-modified-channels-update
192 (defadvice erc-track-mode (after erc-bar-setup-hook 190 (defadvice erc-track-mode (after erc-bar-setup-hook
193 (&rest args) activate) 191 (&rest args) activate)
@@ -197,5 +195,34 @@ erc-modified-channels-alist. Should be executed on window change."
197 (erc-bar-update-overlay)))) 195 (erc-bar-update-overlay))))
198 196
199 197
198;;; ZNC babeee
199;; needed variables are stored in private.el
200(defun znc/connect (znc-server znc-port znc-nick irc-servers)
201 (interactive (let ((zserv (or znc/server
202 (read-string "ZNC Server: ")))
203 (zport (or znc/port
204 (read-number "ZNC Port: ")))
205 (znick (or znc/nick
206 (read-string "ZNC Nick: ")))
207 (servers (or znc/irc-servers
208 (list
209 (cons
210 (read-string "IRC Server to connect to: ")
211 (read-passwd "Password: "))))))
212 (list zserv zport znick servers)))
213 (let ((si 0))
214 (dolist (server irc-servers)
215 (run-at-time si nil
216 (lambda ()
217 (erc-tls :server znc-server
218 :port znc-port
219 :nick znc-nick
220 :password (format "%s/%s:%s"
221 znc-nick
222 (car server)
223 (cdr server)))))
224 (setq si (1+ si)))))
225
226
200(provide 'acdw-erc) 227(provide 'acdw-erc)
201;;; acdw-erc.el ends here 228;;; acdw-erc.el ends here
diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el new file mode 100644 index 0000000..193275c --- /dev/null +++ b/lisp/acdw-irc.el
@@ -0,0 +1,84 @@
1;;; acdw-irc.el -*- lexical-binding: t; coding: utf-8-unix -*-
2
3(require 's nil :noerror)
4
5(defgroup acdw-irc nil
6 "Customizations for IRC."
7 :group 'applications)
8
9(defcustom acdw-irc/left-margin 16
10 "The size of the margin for nicks, etc. on the left."
11 :type 'integer)
12
13(defcustom acdw-irc/pre-nick ""
14 "What to show before a nick."
15 :type 'string)
16
17(defcustom acdw-irc/post-nick " | "
18 "What to show after a nick."
19 :type 'string)
20
21(defcustom acdw-irc/pre-my-nick "-"
22 "What to show before the current user's nick."
23 :type 'string)
24
25(defcustom acdw-irc/post-my-nick "-> "
26 "What to show after the current user's nick."
27 :type 'string)
28
29(defcustom acdw-irc/ellipsis "~"
30 "The ellipsis for when a string is too long."
31 :type 'string)
32
33
34;;; Convenience functions (I don't want to /depend/ on s.el)
35
36(if (fboundp 's-repeat)
37 (defalias 'repeat-string 's-repeat)
38 (defun repeat-string (num s)
39 "Make a string of STR repeated NUM times.
40Stolen from s.el."
41 (declare (pure t) (side-effect-free t))
42 (let (ss)
43 (while (> num 0)
44 (setq ss (cons str ss)
45 num (1- num)))
46 (apply #'concat ss))))
47
48(if (fboundp 's-truncate)
49 (defalias 'truncate-string 's-truncate)
50 (defun truncate-string (len s &optional ellipsis)
51 "If STR is longer than LEN, cut it down and add ELLIPSIS to the end.
52When not specified, ELLIPSIS defaults to '...'."
53 (declare (pure t) (side-effect-free t))
54 (unless ellipsis
55 (setq ellipsis "..."))
56 (if (> (length s) len)
57 (format "%s%s" (substring s 0 (- len (length ellipsis))) ellipsis)
58 s)))
59
60
61;;; IRC stuff
62
63(defun acdw-irc/margin-format (str &optional before after alignment)
64 "Print STR to fit in `acdw-irc/left-margin'.
65Optional arguments BEFORE and AFTER specify strings to go
66... before and after the string. ALIGNMENT aligns left on nil
67and right on t."
68 (let* ((before (or before ""))
69 (after (or after ""))
70 (str-length (length str))
71 (before-length (length before))
72 (after-length (length after))
73 (max-length (- acdw-irc/left-margin 1 (+ before-length after-length)))
74 (left-over (max 0 (- max-length str-length))))
75 (format "%s%s%s%s%s"
76 before
77 (if alignment (repeat-string left-over " ") "")
78 (truncate-string max-length str acdw-irc/ellipsis)
79 (if alignment "" (repeat-string left-over " "))
80 after)))
81
82
83(provide 'acdw-irc)
84;;; acdw-irc.el ends here
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 5784148..6a11418 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el
@@ -22,6 +22,15 @@
22(require 'simple-modeline) 22(require 'simple-modeline)
23(require 'minions) 23(require 'minions)
24 24
25(defcustom acdw-modeline/word-count-modes
26 (mapcar (lambda (m) (cons m nil)) simple-modeline-word-count-modes)
27 "Alist of modes to functions that `acdw-modeline/word-count' should dispatch.
28If the cdr of the cons cell is nil, use the default function (`count-words').
29Otherwise, cdr should be a function that takes two points (see `count-words')."
30 :type '(alist :key-type (symbol :tag "Major-Mode")
31 :value-type function)
32 :group 'simple-modeline)
33
25(defun acdw-modeline/buffer-name () ; gonsie 34(defun acdw-modeline/buffer-name () ; gonsie
26 "Display the buffer name in a face reflecting its modified status." 35 "Display the buffer name in a face reflecting its modified status."
27 (propertize " %b " 36 (propertize " %b "
@@ -40,7 +49,35 @@
40(defun acdw-modeline/god-mode-indicator () 49(defun acdw-modeline/god-mode-indicator ()
41 "Display an indicator if `god-local-mode' is active." 50 "Display an indicator if `god-local-mode' is active."
42 (when (bound-and-true-p god-local-mode) 51 (when (bound-and-true-p god-local-mode)
43 " God")) 52 " Ω"))
53
54(defun acdw-modeline/major-mode ()
55 "Displays the current major mode in the mode-line."
56 (propertize
57 (concat " "
58 (or (and (boundp 'delighted-modes)
59 (cadr (assq major-mode delighted-modes)))
60 (format-mode-line mode-name)))
61 'face 'bold
62 'keymap mode-line-major-mode-keymap
63 'mouse-face 'mode-line-highlight))
64
65(defun acdw-modeline/minions () ; by me
66 "Display a button for `minions-minor-modes-menu'."
67 (concat
68 " "
69 (propertize
70 "&"
71 'help-echo (format
72 "Minor modes menu\nmouse-1: show menu.")
73 'local-map (purecopy (simple-modeline-make-mouse-map
74 'mouse-1
75 (lambda (event)
76 (interactive "e")
77 (with-selected-window (posn-window
78 (event-start event))
79 (minions-minor-modes-menu)))))
80 'mouse-face 'mode-line-highlight)))
44 81
45(defun acdw-modeline/modified () ; modified from `simple-modeline' 82(defun acdw-modeline/modified () ; modified from `simple-modeline'
46 "Displays a color-coded buffer modification/read-only 83 "Displays a color-coded buffer modification/read-only
@@ -64,23 +101,6 @@ indicator in the mode-line."
64 (read-only-mode 'toggle))))) 101 (read-only-mode 'toggle)))))
65 'mouse-face 'mode-line-highlight)))) 102 'mouse-face 'mode-line-highlight))))
66 103
67(defun acdw-modeline/minions () ; by me
68 "Display a button for `minions-minor-modes-menu'."
69 (concat
70 " "
71 (propertize
72 "&"
73 'help-echo (format
74 "Minor modes menu\nmouse-1: show menu.")
75 'local-map (purecopy (simple-modeline-make-mouse-map
76 'mouse-1
77 (lambda (event)
78 (interactive "e")
79 (with-selected-window (posn-window
80 (event-start event))
81 (minions-minor-modes-menu)))))
82 'mouse-face 'mode-line-highlight)))
83
84(defun acdw-modeline/narrowed () 104(defun acdw-modeline/narrowed ()
85 "Display an indication if the buffer is narrowed." 105 "Display an indication if the buffer is narrowed."
86 (when (buffer-narrowed-p) 106 (when (buffer-narrowed-p)
@@ -135,6 +155,11 @@ is, if point < mark."
135 " (%-d)") 155 " (%-d)")
136 text-scale-mode-amount))) 156 text-scale-mode-amount)))
137 157
158(defun acdw-modeline/track ()
159 "Display `tracking-mode' information."
160 (when tracking-mode
161 tracking-mode-line-buffers))
162
138(defun acdw-modeline/vc-branch () 163(defun acdw-modeline/vc-branch ()
139 "Display the version control branch of the current buffer in the modeline." 164 "Display the version control branch of the current buffer in the modeline."
140 ;; from https://www.gonsie.com/blorg/modeline.html, from Doom 165 ;; from https://www.gonsie.com/blorg/modeline.html, from Doom
@@ -148,15 +173,6 @@ Only shows if there is more than one window."
148 (> winum--window-count 1)) 173 (> winum--window-count 1))
149 (format winum-format (winum-get-number-string)))) 174 (format winum-format (winum-get-number-string))))
150 175
151(defcustom acdw-modeline/word-count-modes
152 (mapcar (lambda (m) (cons m nil)) simple-modeline-word-count-modes)
153 "Alist of modes to functions that `acdw-modeline/word-count' should dispatch.
154If the cdr of the cons cell is nil, use the default function (`count-words').
155Otherwise, cdr should be a function that takes two points (see `count-words')."
156 :type '(alist :key-type (symbol :tag "Major-Mode")
157 :value-type function)
158 :group 'simple-modeline)
159
160(defun acdw-modeline/word-count () 176(defun acdw-modeline/word-count ()
161 "Display a buffer word count, depending on the major mode. 177 "Display a buffer word count, depending on the major mode.
162Uses `acdw-modeline/word-count-modes' to determine which function to use." 178Uses `acdw-modeline/word-count-modes' to determine which function to use."