1 ;;; erc-imenu.el -- Imenu support for ERC
3 ;; Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
5 ;; Author: Mario Lang <mlang@delysid.org>
7 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcImenu
9 ;; This file is part of GNU Emacs.
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)
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.
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.
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
35 ;; Author: Mario Lang <mlang@delysid.org>
37 ;; This file is not part of GNU Emacs. But the same license applies.
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.
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
55 (re-search-forward (regexp-quote erc-notice-prefix
)))
57 (while (save-excursion
61 (end-of-line) (point)))))
64 (goto-char (point-min))
65 (while (re-search-forward "\n +" nil t
)
67 (buffer-substring (point-min) (point-max)))))
70 (defun erc-create-imenu-index ()
71 (let ((index-alist '())
77 (mode-change-alist '())
78 (topic-change-alist '())
80 (goto-char (point-max))
81 (imenu-progress-message prev-pos
0)
85 (progn (forward-line 0)
87 (imenu-progress-message prev-pos nil t
)
89 (when (looking-at (concat (regexp-quote erc-notice-prefix
)
91 (let ((notice-text ;; Ugly hack, but seems to work.
92 (save-excursion (erc-unfill-notice)))
94 (push (cons notice-text pos
) notice-alist
)
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
))
106 "^\\(\\S-+\\) (.+) has changed mode for \\S-+ to \\(.*\\)$"
108 (push (cons (concat (match-string 1 notice-text
) ": "
109 (match-string 2 notice-text
))
113 "^\\(\\S-+\\) (.+) has set the topic for \\S-+: \\(.*\\)$"
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))
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
)
129 (and message-alist
(push (cons "messages" message-alist
) index-alist
))
130 (and topic-change-alist
(push (cons "topic-change" topic-change-alist
)
136 ;;; erc-imenu.el ends here
139 ;; indent-tabs-mode: t
143 ;; arch-tag: 35c69082-ca29-43f7-a050-8da5f400de81