| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
(require 'erc) |
|---|
| 43 |
(require 'imenu) |
|---|
| 44 |
|
|---|
| 45 |
(defun erc-unfill-notice () |
|---|
| 46 |
"Return text from point to a computed end as a string unfilled. |
|---|
| 47 |
Don't rely on this function, read it first!" |
|---|
| 48 |
(let ((str (buffer-substring |
|---|
| 49 |
(save-excursion |
|---|
| 50 |
(re-search-forward (regexp-quote erc-notice-prefix))) |
|---|
| 51 |
(progn |
|---|
| 52 |
(while (save-excursion |
|---|
| 53 |
(forward-line 1) |
|---|
| 54 |
(looking-at " ")) |
|---|
| 55 |
(forward-line 1)) |
|---|
| 56 |
(end-of-line) (point))))) |
|---|
| 57 |
(with-temp-buffer |
|---|
| 58 |
(insert str) |
|---|
| 59 |
(goto-char (point-min)) |
|---|
| 60 |
(while (re-search-forward "\n +" nil t) |
|---|
| 61 |
(replace-match " ")) |
|---|
| 62 |
(buffer-substring (point-min) (point-max))))) |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
(defun erc-create-imenu-index () |
|---|
| 66 |
(let ((index-alist '()) |
|---|
| 67 |
(notice-alist '()) |
|---|
| 68 |
(join-alist '()) |
|---|
| 69 |
(left-alist '()) |
|---|
| 70 |
(quit-alist '()) |
|---|
| 71 |
(message-alist '()) |
|---|
| 72 |
(mode-change-alist '()) |
|---|
| 73 |
(topic-change-alist '()) |
|---|
| 74 |
prev-pos) |
|---|
| 75 |
(goto-char (point-max)) |
|---|
| 76 |
(imenu-progress-message prev-pos 0) |
|---|
| 77 |
(while (if (bolp) |
|---|
| 78 |
(> (forward-line -1) |
|---|
| 79 |
-1) |
|---|
| 80 |
(progn (forward-line 0) |
|---|
| 81 |
t)) |
|---|
| 82 |
(imenu-progress-message prev-pos nil t) |
|---|
| 83 |
(save-match-data |
|---|
| 84 |
(when (looking-at (concat (regexp-quote erc-notice-prefix) |
|---|
| 85 |
"\\(.+\\)$")) |
|---|
| 86 |
(let ((notice-text |
|---|
| 87 |
(save-excursion (erc-unfill-notice))) |
|---|
| 88 |
(pos (point))) |
|---|
| 89 |
(push (cons notice-text pos) notice-alist) |
|---|
| 90 |
(or |
|---|
| 91 |
(when (string-match "^\\(.*\\) has joined channel" notice-text) |
|---|
| 92 |
(push (cons (match-string 1 notice-text) pos) join-alist)) |
|---|
| 93 |
(when (string-match "^\\(.+\\) has left channel" notice-text) |
|---|
| 94 |
(push (cons (match-string 1 notice-text) pos) left-alist)) |
|---|
| 95 |
(when (string-match "^\\(.+\\) has quit\\(.*\\)$" notice-text) |
|---|
| 96 |
(push (cons (concat (match-string 1 notice-text) |
|---|
| 97 |
(match-string 2 notice-text)) |
|---|
| 98 |
(point)) |
|---|
| 99 |
quit-alist)) |
|---|
| 100 |
(when (string-match |
|---|
| 101 |
"^\\(\\S-+\\) (.+) has changed mode for \\S-+ to \\(.*\\)$" |
|---|
| 102 |
notice-text) |
|---|
| 103 |
(push (cons (concat (match-string 1 notice-text) ": " |
|---|
| 104 |
(match-string 2 notice-text)) |
|---|
| 105 |
(point)) |
|---|
| 106 |
mode-change-alist)) |
|---|
| 107 |
(when (string-match |
|---|
| 108 |
"^\\(\\S-+\\) (.+) has set the topic for \\S-+: \\(.*\\)$" |
|---|
| 109 |
notice-text) |
|---|
| 110 |
(push (cons (concat (match-string 1 notice-text) ": " |
|---|
| 111 |
(match-string 2 notice-text)) pos) |
|---|
| 112 |
topic-change-alist))))) |
|---|
| 113 |
(when (looking-at "<\\(\\S-+\\)> \\(.+\\)$") |
|---|
| 114 |
(let ((from (match-string 1)) |
|---|
| 115 |
(message-text (match-string 2))) |
|---|
| 116 |
(push (cons (concat from ": " message-text) (point)) |
|---|
| 117 |
message-alist))))) |
|---|
| 118 |
(and notice-alist (push (cons "notices" notice-alist) index-alist)) |
|---|
| 119 |
(and join-alist (push (cons "joined" join-alist) index-alist)) |
|---|
| 120 |
(and left-alist (push (cons "parted" left-alist) index-alist)) |
|---|
| 121 |
(and quit-alist (push (cons "quit" quit-alist) index-alist)) |
|---|
| 122 |
(and mode-change-alist (push (cons "mode-change" mode-change-alist) |
|---|
| 123 |
index-alist)) |
|---|
| 124 |
(and message-alist (push (cons "messages" message-alist) index-alist)) |
|---|
| 125 |
(and topic-change-alist (push (cons "topic-change" topic-change-alist) |
|---|
| 126 |
index-alist)) |
|---|
| 127 |
index-alist)) |
|---|
| 128 |
|
|---|
| 129 |
(provide 'erc-imenu) |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|