diff options
Diffstat (limited to 'jakob.org')
| -rw-r--r-- | jakob.org | 90 |
1 files changed, 82 insertions, 8 deletions
@@ -218,6 +218,13 @@ Enable the default-disabled functions that I use. (column-number-mode t) #+END_SRC +Unbind =C-z= and =C-x C-z= so I'm not accidentally calling =suspend-frame=. + +#+BEGIN_SRC elisp +(global-unset-key (kbd "C-z")) +(global-unset-key (kbd "C-x C-z")) +#+END_SRC + * Custom Functionality This section is for any nontrivial Elisp functions written by me. @@ -385,11 +392,23 @@ Improvements upon manually switching channel buffers. Channels can now be cycled through interactively. #+BEGIN_SRC elisp +(defun bitlbee-control-buffer-p (buffer-or-name) + "Returns whether or not BUFFER-OR-NAME is connected to the +current inferior bitlbee process." + (let ((name (if (bufferp buffer-or-name) + (buffer-name buffer-or-name) + buffer-or-name))) + (and (char-equal (elt name 0) (string-to-char "&")) + (equal (erc-with-buffer ((get-buffer buffer-or-name)) + (erc-server-buffer)) + (get-buffer "bitlbee"))))) + (defun irc-cycle-buffer-list (starting-buffer) "Returns the forward order in which to cycle channel buffers. Channels with activity take priority in the order of `erc-modified-channels-alist', followed by other channels in -alphabetical order." +alphabetical order. Control buffers belonging to bitlbee are +omitted." (let* ((modified (map 'list #'(lambda (channel) (first channel)) @@ -404,7 +423,8 @@ alphabetical order." (string< (subseq channel1 1) (subseq channel2 1)))))) (split-index (position (get-buffer starting-buffer) rest))) - (remove-if #'(lambda (buffer) (equal buffer (get-buffer starting-buffer))) + (remove-if #'(lambda (buffer) (or (equal buffer (get-buffer starting-buffer)) + (bitlbee-control-buffer-p buffer))) (if split-index (concatenate 'list modified @@ -425,6 +445,61 @@ alphabetical order." (switch-to-buffer (car (last (irc-cycle-buffer-list (current-buffer)))))) #+END_SRC +Interactive function for marking a channel's backlog as read in ZNC. + +#+BEGIN_SRC elisp +(defun clear-irc-buffer () + "Query ZNC to clear the backlog for the current buffer." + (interactive) + (let ((channel-to-clear (buffer-name)) + (buffer (erc-query "*status" (erc-server-buffer)))) + (erc-with-buffer (buffer) + (erc-send-message (format "clearbuffer %s" channel-to-clear))))) +#+END_SRC + +ERC tracking bar. Not mine. Shamelessly lifted from [[https://www.emacswiki.org/emacs/ErcBar][EmacsWiki]]. + +#+BEGIN_SRC elisp +(eval-after-load 'erc-track + '(progn + (defun erc-bar-move-back (n) + "Moves back n message lines. Ignores wrapping, and server messages." + (interactive "nHow many lines ? ") + (re-search-backward "^.*<.*>" nil t n)) + + (defun erc-bar-update-overlay () + "Update the overlay for current buffer, based on the content of +erc-modified-channels-alist. Should be executed on window change." + (interactive) + (let* ((info (assq (current-buffer) erc-modified-channels-alist)) + (count (cadr info))) + (if (and info (> count erc-bar-threshold)) + (save-excursion + (end-of-buffer) + (when (erc-bar-move-back count) + (let ((inhibit-field-text-motion t)) + (move-overlay erc-bar-overlay + (line-beginning-position) + (line-end-position) + (current-buffer))))) + (delete-overlay erc-bar-overlay)))) + + (defvar erc-bar-threshold 1 + "Display bar when there are more than erc-bar-threshold unread messages.") + (defvar erc-bar-overlay nil + "Overlay used to set bar") + (setq erc-bar-overlay (make-overlay 0 0)) + (overlay-put erc-bar-overlay 'face '(:underline "red")) + ;;put the hook before erc-modified-channels-update + (defadvice erc-track-mode (after erc-bar-setup-hook + (&rest args) activate) + ;;remove and add, so we know it's in the first place + (remove-hook 'window-configuration-change-hook 'erc-bar-update-overlay) + (add-hook 'window-configuration-change-hook 'erc-bar-update-overlay)) + (add-hook 'erc-send-completed-hook (lambda (str) + (erc-bar-update-overlay))))) +#+END_SRC + * Appearance ** Windowing @@ -1208,17 +1283,16 @@ available [[http://jakob.space/links/][on my website]] with links to the sites i * ERC Only load the modules I actually use. This list deviates from the default by -including =keep-place= and =truncate=, but omitting =autojoin=. +including =truncate=, but omitting =autojoin=. #+BEGIN_SRC elisp (use-package erc :config (setq erc-modules '(button completion fill - irccontrols keep-place list - match menu move-to-prompt - netsplit networks noncommands - readonly ring stamp - track truncate)) + irccontrols list match + menu move-to-prompt netsplit + networks noncommands readonly + ring stamp track truncate)) (erc-update-modules) #+END_SRC |