Created
December 13, 2012 18:33
-
-
Save davazp/4278537 to your computer and use it in GitHub Desktop.
Emphatize text in ERC
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
(defun erc-emphatize () | |
(when (eq erc-interpret-controls-p t) | |
(goto-char (point-min)) | |
(while (re-search-forward "\\(?:^\\|\\s-\\)\\*\\([^*]+\\)\\*\\(:?$\\|\\s-\\)" nil t) | |
(replace-match "\C-b\\1\C-o" nil nil)) | |
(goto-char (point-min)) | |
(while (re-search-forward "\\(?:^\\|\\s-\\)_\\([^_]+\\)_\\(?:$\\|\\s-\\)" nil t) | |
(replace-match "\C-_\\1\C-O" nil nil)) | |
(goto-char (point-min)) | |
(while (re-search-forward "\\(?:^\\|\\s-\\)/\\([^/]+\\)/\\(?:$\\|\\s-\\)" nil t) | |
(replace-match "\C-V\\1\C-O" nil nil)))) | |
(add-hook 'erc-send-pre-hook | |
(lambda (string) | |
(with-temp-buffer | |
(insert string) | |
(erc-emphatize) | |
(setq str (buffer-substring (point-min) (point-max)))))) | |
(add-hook 'erc-insert-modify-hook 'erc-emphatize) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment