;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/erc/erc-element.el ;; ;; Tab through and cycle ERC interactive elements. ;; ;; An element is as for now either a button or the ERC input ;; prompt but it should or could be any interactive object ;; visible in the ERC buffer. ;; ;; To use this with keys, bind for example backtab to ;; `erc-element-prev' and C- to `erc-element-next' in ;; `erc-mode-map'. But note then that these keys must also be ;; bound the same way in `erc-button-keymap' since that is in ;; effect when point is over a button. (require 'erc) (require 'erc-button) (defun erc-at-prompt-p () (let ((pos (marker-position erc-insert-marker))) (<= pos (point)) )) (defun erc-element-next (&optional prev) (interactive "P") (when (erc-at-prompt-p) (goto-char (point-min)) ) (condition-case nil (if prev (erc-button-previous 1) (erc-button-next 1) ) (error (progn (goto-char (point-max)) (when prev (erc-bol) ))))) (defun erc-element-prev () (interactive) (let ((beg (point))) (erc-element-next t) (when (= (point) beg) (forward-line 0) (backward-char) (erc-element-next t) ))) (provide 'erc-element)