Mercurial > emacs
comparison lisp/erc/erc-imenu.el @ 68451:fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Creator: Michael Olson <mwolson@gnu.org>
Install ERC.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 29 Jan 2006 13:08:58 +0000 |
parents | |
children | 7010bb070445 |
comparison
equal
deleted
inserted
replaced
68450:a3ba4ef5d590 | 68451:fc745b05e928 |
---|---|
1 ;;; erc-imenu.el -- Imenu support for ERC | |
2 | |
3 ;; Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Mario Lang <mlang@delysid.org> | |
6 ;; Keywords: comm | |
7 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcImenu | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
24 ;; Boston, MA 02110-1301, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; This file contains code related to Ibuffer and ERC. Totally alpha, | |
29 ;; needs work. Usage: Type / C-e C-h when in Ibuffer-mode to see new | |
30 ;; limiting commands | |
31 | |
32 ;;; Code: | |
33 | |
34 | |
35 ;; Author: Mario Lang <mlang@delysid.org> | |
36 | |
37 ;; This file is not part of GNU Emacs. But the same license applies. | |
38 | |
39 ;;; Commentary: | |
40 | |
41 ;; This package defines the function `erc-create-imenu-index'. ERC | |
42 ;; uses this for `imenu-create-index-function', and autoloads it. | |
43 ;; Therefore, nothing needs to be done to use this package. | |
44 | |
45 ;;; Code: | |
46 | |
47 (require 'erc) | |
48 (require 'imenu) | |
49 | |
50 (defun erc-unfill-notice () | |
51 "Return text from point to a computed end as a string unfilled. | |
52 Don't rely on this function, read it first!" | |
53 (let ((str (buffer-substring | |
54 (save-excursion | |
55 (re-search-forward (regexp-quote erc-notice-prefix))) | |
56 (progn | |
57 (while (save-excursion | |
58 (forward-line 1) | |
59 (looking-at " ")) | |
60 (forward-line 1)) | |
61 (end-of-line) (point))))) | |
62 (with-temp-buffer | |
63 (insert str) | |
64 (goto-char (point-min)) | |
65 (while (re-search-forward "\n +" nil t) | |
66 (replace-match " ")) | |
67 (buffer-substring (point-min) (point-max))))) | |
68 | |
69 ;;;###autoload | |
70 (defun erc-create-imenu-index () | |
71 (let ((index-alist '()) | |
72 (notice-alist '()) | |
73 (join-alist '()) | |
74 (left-alist '()) | |
75 (quit-alist '()) | |
76 (message-alist '()) | |
77 (mode-change-alist '()) | |
78 (topic-change-alist '()) | |
79 prev-pos) | |
80 (goto-char (point-max)) | |
81 (imenu-progress-message prev-pos 0) | |
82 (while (if (bolp) | |
83 (> (forward-line -1) | |
84 -1) | |
85 (progn (forward-line 0) | |
86 t)) | |
87 (imenu-progress-message prev-pos nil t) | |
88 (save-match-data | |
89 (when (looking-at (concat (regexp-quote erc-notice-prefix) | |
90 "\\(.+\\)$")) | |
91 (let ((notice-text ;; Ugly hack, but seems to work. | |
92 (save-excursion (erc-unfill-notice))) | |
93 (pos (point))) | |
94 (push (cons notice-text pos) notice-alist) | |
95 (or | |
96 (when (string-match "^\\(.*\\) has joined channel" notice-text) | |
97 (push (cons (match-string 1 notice-text) pos) join-alist)) | |
98 (when (string-match "^\\(.+\\) has left channel" notice-text) | |
99 (push (cons (match-string 1 notice-text) pos) left-alist)) | |
100 (when (string-match "^\\(.+\\) has quit\\(.*\\)$" notice-text) | |
101 (push (cons (concat (match-string 1 notice-text) | |
102 (match-string 2 notice-text)) | |
103 (point)) | |
104 quit-alist)) | |
105 (when (string-match | |
106 "^\\(\\S-+\\) (.+) has changed mode for \\S-+ to \\(.*\\)$" | |
107 notice-text) | |
108 (push (cons (concat (match-string 1 notice-text) ": " | |
109 (match-string 2 notice-text)) | |
110 (point)) | |
111 mode-change-alist)) | |
112 (when (string-match | |
113 "^\\(\\S-+\\) (.+) has set the topic for \\S-+: \\(.*\\)$" | |
114 notice-text) | |
115 (push (cons (concat (match-string 1 notice-text) ": " | |
116 (match-string 2 notice-text)) pos) | |
117 topic-change-alist))))) | |
118 (when (looking-at "<\\(\\S-+\\)> \\(.+\\)$") | |
119 (let ((from (match-string 1)) | |
120 (message-text (match-string 2))) | |
121 (push (cons (concat from ": " message-text) (point)) | |
122 message-alist))))) | |
123 (and notice-alist (push (cons "notices" notice-alist) index-alist)) | |
124 (and join-alist (push (cons "joined" join-alist) index-alist)) | |
125 (and left-alist (push (cons "parted" left-alist) index-alist)) | |
126 (and quit-alist (push (cons "quit" quit-alist) index-alist)) | |
127 (and mode-change-alist (push (cons "mode-change" mode-change-alist) | |
128 index-alist)) | |
129 (and message-alist (push (cons "messages" message-alist) index-alist)) | |
130 (and topic-change-alist (push (cons "topic-change" topic-change-alist) | |
131 index-alist)) | |
132 index-alist)) | |
133 | |
134 (provide 'erc-imenu) | |
135 | |
136 ;;; erc-imenu.el ends here | |
137 ;; | |
138 ;; Local Variables: | |
139 ;; indent-tabs-mode: t | |
140 ;; tab-width: 8 | |
141 ;; End: | |
142 | |
143 ;; arch-tag: 35c69082-ca29-43f7-a050-8da5f400de81 |