summary refs log tree commit diff stats
path: root/lisp/acdw-irc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw-irc.el')
-rw-r--r--lisp/acdw-irc.el72
1 files changed, 0 insertions, 72 deletions
diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el deleted file mode 100644 index 4427a4d..0000000 --- a/lisp/acdw-irc.el +++ /dev/null
@@ -1,72 +0,0 @@
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 s ss))
45 (setq num (1- num)))
46 (apply 'concat ss))))
47
48
49;;; IRC stuff
50
51(defun acdw-irc/margin-format (str &optional before after alignment)
52 "Print STR to fit in `acdw-irc/left-margin'.
53Optional arguments BEFORE and AFTER specify strings to go
54... before and after the string. ALIGNMENT aligns left on nil
55and right on t."
56 (let* ((before (or before ""))
57 (after (or after ""))
58 (str-length (length str))
59 (before-length (length before))
60 (after-length (length after))
61 (max-length (- acdw-irc/left-margin 1 (+ before-length after-length)))
62 (left-over (max 0 (- max-length str-length))))
63 (format "%s%s%s%s%s"
64 before
65 (if alignment (repeat-string left-over " ") "")
66 (truncate-string max-length str acdw-irc/ellipsis)
67 (if alignment "" (repeat-string left-over " "))
68 after)))
69
70
71(provide 'acdw-irc)
72;;; acdw-irc.el ends here