Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: docs/erc_irc.md

Issue 1309473002: WIP: Migrate Wiki content over to src/docs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 It's very simple to get started with ERC; just do the following:
2 1. Optional: Sign up at freenode.net to claim your nickname.
3 1. M-x
4 1. erc (and accept default for the first couple of items)
5 1. /join #chromium
6
7 You may notice the following problems:
8 * It's hard to notice when you're mentioned.
9 * ERC does not have built-in accidental paste prevention, so you might acciden tally paste multiple lines of text into the IRC channel.
10
11 You can modify the following and add it to your .emacs file to fix both of the a bove. Note that you'll need to install and configure sendxmpp for the mention ha ck, which also requires you to create an account for your "robot" on e.g. jabber .org:
12
13 ```
14 (require 'erc)
15
16 ;; Notify me when someone mentions my nick or aliases on IRC.
17 (erc-match-mode 1)
18 (add-to-list 'erc-keywords "\\bjoi\\b")
19 ;; Only when I'm sheriff.
20 ;;(add-to-list 'erc-keywords "\\bsheriff\\b")
21 ;;(add-to-list 'erc-keywords "\\bsheriffs\\b")
22 (defun erc-global-notify (matched-type nick msg)
23 (interactive)
24 (when (or (eq matched-type 'current-nick) (eq matched-type 'keyword)))
25 (shell-command
26 (concat "echo \"Mentioned by " (car (split-string nick "!")) ": " msg
27 "\" | sendxmpp joi@google.com")))
28 (add-hook 'erc-text-matched-hook 'erc-global-notify)
29
30 (defvar erc-last-input-time 0
31 "Time of last call to `erc-send-current-line' (as returned by `float-time'),
32 or 0 if that function has never been called.
33 Used to detect accidental pastes (i.e., large amounts of text
34 accidentally entered into the ERC buffer.)")
35
36 (defcustom erc-accidental-paste-threshold-seconds 1
37 "Time in seconds that must pass between invocations of
38 `erc-send-current-line' in order for that function to consider
39 the new line to be intentional."
40 :group 'erc
41 :type '(choice number (other :tag "disabled" nil)))
42
43 (defun erc-send-current-line-with-paste-protection ()
44 "Parse current line and send it to IRC, with accidental paste protection."
45 (interactive)
46 (let ((now (float-time)))
47 (if (or (not erc-accidental-paste-threshold-seconds)
48 (< erc-accidental-paste-threshold-seconds (- now erc-last-input-time )))
49 (save-restriction
50 (widen)
51 (if (< (point) (erc-beg-of-input-line))
52 (erc-error "Point is not in the input area")
53 (let ((inhibit-read-only t)
54 (str (erc-user-input))
55 (old-buf (current-buffer)))
56 (if (and (not (erc-server-buffer-live-p))
57 (not (erc-command-no-process-p str)))
58 (erc-error "ERC: No process running")
59 (erc-set-active-buffer (current-buffer))
60
61 ;; Kill the input and the prompt
62 (delete-region (erc-beg-of-input-line)
63 (erc-end-of-input-line))
64
65 (unwind-protect
66 (erc-send-input str)
67 ;; Fix the buffer if the command didn't kill it
68 (when (buffer-live-p old-buf)
69 (with-current-buffer old-buf
70 (save-restriction
71 (widen)
72 (goto-char (point-max))
73 (when (processp erc-server-process)
74 (set-marker (process-mark erc-server-process) (point)) )
75 (set-marker erc-insert-marker (point))
76 (let ((buffer-modified (buffer-modified-p)))
77 (erc-display-prompt)
78 (set-buffer-modified-p buffer-modified))))))
79
80 ;; Only when last hook has been run...
81 (run-hook-with-args 'erc-send-completed-hook str))))
82 (setq erc-last-input-time now))
83 (switch-to-buffer "*ERC Accidental Paste Overflow*")
84 (lwarn 'erc :warning "You seem to have accidentally pasted some text!"))))
85
86 (add-hook 'erc-mode-hook
87 '(lambda ()
88 (define-key erc-mode-map "\C-m" 'erc-send-current-line-with-paste-p rotection)
89 ))
90 ```
91
92 Note: The paste protection code is modified from a paste by user 'yashh' at http ://paste.lisp.org/display/78068 (Google cache [here](http://webcache.googleuserc ontent.com/search?q=cache:p_S9ZKlWZPoJ:paste.lisp.org/display/78068+paste+78068& cd=1&hl=en&ct=clnk&gl=ca&source=www.google.ca)).
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698