Created
February 21, 2013 16:42
-
-
Save ieure/5006072 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval-after-load 'erc-button | |
'(progn | |
(defun erc-button-skip-forward () | |
"Skip to the end of the button point is in." | |
(let ((p (point))) | |
(goto-char | |
(progn | |
(while (and (get-text-property p 'erc-callback) | |
(not (= p (point-max)))) | |
(setq p (1+ p))) | |
p)))) | |
(defun erc-button-skip-backward () | |
"Skip to the start of the button point is in." | |
(let ((p (point))) | |
(goto-char | |
(progn | |
(while (and (get-text-property p 'erc-callback) | |
(not (= p (point-min)))) | |
(setq p (1- p))) | |
p)))) | |
(defun erc-next-link (arg) | |
"Move point to the ARGth URL, or the end of the buffer if none." | |
(interactive "p") | |
(erc-button-skip-forward) | |
(save-match-data | |
(if (re-search-forward erc-button-url-regexp (point-max) t arg) | |
(goto-char (- (match-end 0) 1)) | |
(goto-char (point-max))))) | |
(defun erc-previous-link (arg) | |
"Move point to the ARGth most recent URL." | |
(interactive "p") | |
(erc-button-skip-backward) | |
(when (looking-at erc-button-url-regexp) | |
(re-search-backward "\\\s")) | |
(re-search-backward erc-button-url-regexp 0 t)) | |
(define-key erc-mode-map "\C-cp" 'erc-previous-link) | |
(define-key erc-mode-map "\C-cn" 'erc-next-link) | |
(defadvice erc-button-press-button (after end-on-press last nil activate) | |
(erc-next-link 1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment