Skip to content

Instantly share code, notes, and snippets.

@davazp
Created December 13, 2012 18:33
Show Gist options
  • Save davazp/4278537 to your computer and use it in GitHub Desktop.
Save davazp/4278537 to your computer and use it in GitHub Desktop.
Emphatize text in ERC
(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