diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw-erc.el | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/lisp/acdw-erc.el b/lisp/acdw-erc.el index 22e6831..e375c61 100644 --- a/lisp/acdw-erc.el +++ b/lisp/acdw-erc.el | |||
@@ -128,10 +128,13 @@ Truncation is customized using the `erc-nick-truncate' variable. | |||
128 | See also `erc-format-nick-function'." | 128 | See also `erc-format-nick-function'." |
129 | (when user | 129 | (when user |
130 | (let* ((nick (erc-server-user-nickname user)) | 130 | (let* ((nick (erc-server-user-nickname user)) |
131 | (prefix (erc-get-user-mode-prefix nick)) | ||
131 | (ellipsis "~") | 132 | (ellipsis "~") |
132 | (max-len (- erc-nick-truncate 2 (length ellipsis)))) | 133 | (max-len (- erc-nick-truncate 2 ; one each for < and > |
134 | (length ellipsis) | ||
135 | (length prefix)))) | ||
133 | (concat (erc-propertize | 136 | (concat (erc-propertize |
134 | (erc-get-user-mode-prefix nick) | 137 | prefix |
135 | 'font-lock-face 'erc-nick-prefix-face) | 138 | 'font-lock-face 'erc-nick-prefix-face) |
136 | (if (and max-len (> (length nick) max-len)) | 139 | (if (and max-len (> (length nick) max-len)) |
137 | (format "%s%s" (substring nick 0 max-len) | 140 | (format "%s%s" (substring nick 0 max-len) |
@@ -147,5 +150,52 @@ Reverse prefix argument from `erc-switch-to-buffer'." | |||
147 | (interactive "P") | 150 | (interactive "P") |
148 | (erc-switch-to-buffer (not arg))) | 151 | (erc-switch-to-buffer (not arg))) |
149 | 152 | ||
153 | |||
154 | ;;; ERC-Bar | ||
155 | ;; NEEDS MUCH WORK | ||
156 | |||
157 | (defun erc-bar-move-back (n) | ||
158 | "Moves back n message lines. Ignores wrapping, and server messages." | ||
159 | (interactive "nHow many lines ? ") | ||
160 | (re-search-backward "^.*<.*>" nil t n)) | ||
161 | |||
162 | (defun erc-bar-update-overlay () | ||
163 | "Update the overlay for current buffer, based on the content of | ||
164 | erc-modified-channels-alist. Should be executed on window change." | ||
165 | (interactive) | ||
166 | (let* ((info (assq (current-buffer) erc-modified-channels-alist)) | ||
167 | (count (cadr info))) | ||
168 | (if (and info (> count erc-bar-threshold)) | ||
169 | (save-excursion | ||
170 | (end-of-buffer) | ||
171 | (when (erc-bar-move-back count) | ||
172 | (let ((inhibit-field-text-motion t)) | ||
173 | (move-overlay erc-bar-overlay | ||
174 | (line-beginning-position) | ||
175 | (line-end-position) | ||
176 | (current-buffer))))) | ||
177 | (delete-overlay erc-bar-overlay)))) | ||
178 | |||
179 | (defvar erc-bar-threshold 0 | ||
180 | "Display bar when there are more than erc-bar-threshold unread messages.") | ||
181 | |||
182 | (defvar erc-bar-overlay nil | ||
183 | "Overlay used to set bar") | ||
184 | |||
185 | (setq erc-bar-overlay (make-overlay 0 0)) | ||
186 | |||
187 | |||
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 | ||
192 | (defadvice erc-track-mode (after erc-bar-setup-hook | ||
193 | (&rest args) activate) | ||
194 | (add-hook 'window-configuration-change-hook 'erc-bar-update-overlay -90)) | ||
195 | |||
196 | (add-hook 'erc-send-completed-hook (lambda (str) | ||
197 | (erc-bar-update-overlay)))) | ||
198 | |||
199 | |||
150 | (provide 'acdw-erc) | 200 | (provide 'acdw-erc) |
151 | ;;; acdw-erc.el ends here | 201 | ;;; acdw-erc.el ends here |