diff options
author | Case Duckworth | 2021-08-28 23:08:17 -0500 |
---|---|---|
committer | Case Duckworth | 2021-08-28 23:09:00 -0500 |
commit | 782cc6e31b08d73dfe4b0770f0cf6a20fc9d9859 (patch) | |
tree | 049786c11ab2ba1610fd311bcb5415f01dff8ae7 /lisp | |
parent | DON'T FORGET! PRIVATE.EL! ZNC! (diff) | |
download | emacs-782cc6e31b08d73dfe4b0770f0cf6a20fc9d9859.tar.gz emacs-782cc6e31b08d73dfe4b0770f0cf6a20fc9d9859.zip |
Change to circe
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw-irc.el | 84 | ||||
-rw-r--r-- | lisp/acdw-modeline.el | 5 |
2 files changed, 89 insertions, 0 deletions
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. | ||
40 | Stolen 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. | ||
52 | When 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'. | ||
65 | Optional arguments BEFORE and AFTER specify strings to go | ||
66 | ... before and after the string. ALIGNMENT aligns left on nil | ||
67 | and 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 df2811f..6a11418 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el | |||
@@ -155,6 +155,11 @@ is, if point < mark." | |||
155 | " (%-d)") | 155 | " (%-d)") |
156 | text-scale-mode-amount))) | 156 | text-scale-mode-amount))) |
157 | 157 | ||
158 | (defun acdw-modeline/track () | ||
159 | "Display `tracking-mode' information." | ||
160 | (when tracking-mode | ||
161 | tracking-mode-line-buffers)) | ||
162 | |||
158 | (defun acdw-modeline/vc-branch () | 163 | (defun acdw-modeline/vc-branch () |
159 | "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." |
160 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom | 165 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom |