Mercurial > emacs
annotate lisp/erc/erc-list.el @ 92899:f1e7eae84755
*** empty log message ***
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 14 Mar 2008 02:53:03 +0000 |
parents | e5108169bd0c |
children | cdc45872161c |
rev | line source |
---|---|
87952
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
1 ;;; erc-list.el --- /list support for ERC |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
2 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 2008 Free Software Foundation, Inc. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
4 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Tom Tromey <tromey@redhat.com> |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
6 ;; Version: 0.1 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
7 ;; Keywords: comm |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
8 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
9 ;; This file is part of ERC. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
10 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
11 ;; ERC is free software; you can redistribute it and/or modify |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
14 ;; any later version. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
15 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
16 ;; ERC is distributed in the hope that it will be useful, |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
20 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
22 ;; along with ERC; see the file COPYING. If not, write to the |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
25 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
27 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
28 ;; This file provides nice support for /list in ERC. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
29 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
30 ;;; Code: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
31 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
32 (require 'erc) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
33 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
34 ;; This is implicitly the width of the channel name column. Pick |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
35 ;; something small enough that the topic has a chance of being |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
36 ;; readable, but long enough that most channel names won't make for |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
37 ;; strange formatting. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
38 (defconst erc-list-nusers-column 25) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
39 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
40 ;; Width of the number-of-users column. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
41 (defconst erc-list-topic-column (+ erc-list-nusers-column 10)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
42 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
43 ;; The list buffer. This is buffer local in the server buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
44 (defvar erc-list-buffer nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
45 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
46 ;; The argument to the last "/list". This is buffer local in the |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
47 ;; server buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
48 (defvar erc-list-last-argument nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
49 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
50 ;; The server buffer corresponding to the list buffer. This is buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
51 ;; local in the list buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
52 (defvar erc-list-server-buffer nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
53 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
54 ;; Define module: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
55 ;;;###autoload (autoload 'erc-list-mode "erc-list") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
56 (define-erc-module list nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
57 "List channels nicely in a separate buffer." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
58 ((remove-hook 'erc-server-321-functions 'erc-server-321-message) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
59 (remove-hook 'erc-server-322-functions 'erc-server-322-message)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
60 ((erc-with-all-buffers-of-server nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
61 #'erc-open-server-buffer-p |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
62 (remove-hook 'erc-server-322-functions 'erc-list-handle-322 t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
63 (add-hook 'erc-server-321-functions 'erc-server-321-message t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
64 (add-hook 'erc-server-322-functions 'erc-server-322-message t))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
65 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
66 ;; Format a record for display. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
67 (defun erc-list-make-string (channel users topic) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
68 (concat |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
69 channel |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
70 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
71 'display (list 'space :align-to erc-list-nusers-column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
72 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
73 users |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
74 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
75 'display (list 'space :align-to erc-list-topic-column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
76 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
77 topic)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
78 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
79 ;; Insert a record into the list buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
80 (defun erc-list-insert-item (channel users topic) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
81 (save-excursion |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
82 (let ((buffer-read-only nil)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
83 (goto-char (point-max)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
84 (insert (erc-list-make-string channel users topic) "\n")))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
85 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
86 (defun erc-list-join () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
87 "Join the irc channel named on this line." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
88 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
89 (unless (eobp) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
90 (beginning-of-line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
91 (unless (looking-at "\\([&#+!][^ \n]+\\)") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
92 (error "Not looking at channel name?")) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
93 (let ((chan (match-string 1))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
94 (with-current-buffer erc-list-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
95 (erc-join-channel chan))))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
96 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
97 (defun erc-list-kill () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
98 "Kill the current ERC list buffer." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
99 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
100 (kill-buffer (current-buffer))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
101 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
102 (defun erc-list-revert () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
103 "Refresh the list of channels." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
104 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
105 (with-current-buffer erc-list-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
106 (erc-cmd-LIST erc-list-last-argument))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
107 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
108 (defun erc-list-menu-sort-by-column (&optional e) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
109 "Sort the channel list by the column clicked on." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
110 (interactive (list last-input-event)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
111 (if e (mouse-select-window e)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
112 (let* ((pos (event-start e)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
113 (obj (posn-object pos)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
114 (col (if obj |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
115 (get-text-property (cdr obj) 'column-number (car obj)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
116 (get-text-property (posn-point pos) 'column-number)))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
117 (let ((buffer-read-only nil)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
118 (if (= col 1) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
119 (sort-fields col (point-min) (point-max)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
120 (sort-numeric-fields col (point-min) (point-max)))))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
121 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
122 (defvar erc-list-menu-mode-map nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
123 "Local keymap for `erc-list-mode' buffers.") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
124 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
125 (unless erc-list-menu-mode-map |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
126 (setq erc-list-menu-mode-map (make-keymap)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
127 (suppress-keymap erc-list-menu-mode-map) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
128 (define-key erc-list-menu-mode-map "k" 'erc-list-kill) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
129 (define-key erc-list-menu-mode-map "j" 'erc-list-join) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
130 (define-key erc-list-menu-mode-map "g" 'erc-list-revert) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
131 (define-key erc-list-menu-mode-map "n" 'next-line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
132 (define-key erc-list-menu-mode-map "p" 'previous-line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
133 (define-key erc-list-menu-mode-map "q" 'quit-window)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
134 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
135 (defvar erc-list-menu-sort-button-map nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
136 "Local keymap for ERC list menu mode sorting buttons.") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
137 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
138 (unless erc-list-menu-sort-button-map |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
139 (let ((map (make-sparse-keymap))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
140 (define-key map [header-line mouse-1] 'erc-list-menu-sort-by-column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
141 (define-key map [follow-link] 'mouse-face) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
142 (setq erc-list-menu-sort-button-map map))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
143 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
144 ;; Helper function that makes a buttonized column header. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
145 (defun erc-list-button (title column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
146 (erc-propertize title |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
147 'column-number column |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
148 'help-echo "mouse-1: sort by column" |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
149 'mouse-face 'highlight |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
150 'keymap erc-list-menu-sort-button-map)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
151 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
152 (define-derived-mode erc-list-menu-mode nil "ERC-List" |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
153 "Major mode for editing a list of irc channels." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
154 (setq header-line-format |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
155 (concat |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
156 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
157 'display '(space :align-to 0) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
158 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
159 (erc-list-make-string (erc-list-button "Channel" 1) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
160 (erc-list-button "# Users" 2) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
161 "Topic"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
162 (setq truncate-lines t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
163 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
164 (put 'erc-list-menu-mode 'mode-class 'special) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
165 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
166 ;; Handle a "322" response. This response tells us about a single |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
167 ;; channel. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
168 (defun erc-list-handle-322 (proc parsed) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
169 (let* ((args (cdr (erc-response.command-args parsed))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
170 (channel (car args)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
171 (nusers (car (cdr args))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
172 (topic (erc-response.contents parsed))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
173 (when (buffer-live-p erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
174 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
175 (erc-list-insert-item channel nusers topic)))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
176 ;; Don't let another hook run. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
177 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
178 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
179 ;; Helper function to install our 322 handler and make our buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
180 (defun erc-list-install-322-handler (server-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
181 (with-current-buffer server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
182 ;; Arrange for 322 responses to insert into our buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
183 (add-hook 'erc-server-322-functions 'erc-list-handle-322 t t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
184 ;; Arrange for 323 (end of list) to end this. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
185 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
186 323 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
187 '(progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
188 (remove-hook 'erc-server-322-functions 'erc-list-handle-322 t))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
189 ;; Find the list buffer, empty it, and display it. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
190 (set (make-local-variable 'erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
191 (get-buffer-create (concat "*Channels of " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
192 erc-server-announced-name |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
193 "*"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
194 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
195 (erc-list-menu-mode) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
196 (setq buffer-read-only nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
197 (erase-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
198 (set (make-local-variable 'erc-list-server-buffer) server-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
199 (setq buffer-read-only t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
200 (pop-to-buffer erc-list-buffer)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
201 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
202 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
203 ;; The main entry point. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
204 (defun erc-cmd-LIST (&optional line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
205 "Show a listing of channels on the current server in a separate window. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
206 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
207 If LINE is specified, include it with the /LIST command. It |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
208 should usually be one or more channels, separated by commas. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
209 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
210 Please note that this function only works with IRC servers which conform |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
211 to RFC and send the LIST header (#321) at start of list transmission." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
212 (erc-with-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
213 (set (make-local-variable 'erc-list-last-argument) line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
214 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
215 321 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
216 (list 'progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
217 (list 'erc-list-install-322-handler (current-buffer))))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
218 (erc-server-send (concat "LIST :" (or (and line (substring line 1)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
219 "")))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
220 (put 'erc-cmd-LIST 'do-not-parse-args t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
221 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
222 ;;; erc-list.el ends here |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
223 ;; |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
224 ;; Local Variables: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
225 ;; indent-tabs-mode: t |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
226 ;; tab-width: 8 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
227 ;; End: |
87959 | 228 |
229 ;; arch-tag: 99c5f9cb-6bac-4224-86bf-e394768cd1d0 |