Mercurial > emacs
annotate lisp/erc/erc-list.el @ 112278:ef719132ddfa
Nuke arch-tags.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 15 Jan 2011 15:16:57 -0800 |
parents | 417b1e4d63cd |
children |
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 |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
87952
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 |
94681
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
87952
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
10 |
94681
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
87952
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 |
94681
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
14 ;; (at your option) any later version. |
87952
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
15 |
94681
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
87952
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 |
94681
cdc45872161c
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87959
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
87952
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
23 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
24 ;;; Commentary: |
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 ;; 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
|
27 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
28 ;;; Code: |
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 (require 'erc) |
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 ;; 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
|
33 ;; 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
|
34 ;; 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
|
35 ;; strange formatting. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
36 (defconst erc-list-nusers-column 25) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
37 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
38 ;; Width of the number-of-users column. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
39 (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
|
40 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
41 ;; 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
|
42 (defvar erc-list-buffer nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
43 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
44 ;; 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
|
45 ;; server buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
46 (defvar erc-list-last-argument nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
47 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
48 ;; 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
|
49 ;; local in the list buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
50 (defvar erc-list-server-buffer nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
51 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
52 ;; Define module: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
53 ;;;###autoload (autoload 'erc-list-mode "erc-list") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
54 (define-erc-module list nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
55 "List channels nicely in a separate buffer." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
56 ((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
|
57 (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
|
58 ((erc-with-all-buffers-of-server nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
59 #'erc-open-server-buffer-p |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
60 (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
|
61 (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
|
62 (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
|
63 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
64 ;; Format a record for display. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
65 (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
|
66 (concat |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
67 channel |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
68 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
69 '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
|
70 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
71 users |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
72 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
73 '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
|
74 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
75 topic)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
76 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
77 ;; Insert a record into the list buffer. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
78 (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
|
79 (save-excursion |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
80 (let ((buffer-read-only nil)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
81 (goto-char (point-max)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
82 (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
|
83 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
84 (defun erc-list-join () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
85 "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
|
86 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
87 (unless (eobp) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
88 (beginning-of-line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
89 (unless (looking-at "\\([&#+!][^ \n]+\\)") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
90 (error "Not looking at channel name?")) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
91 (let ((chan (match-string 1))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
92 (with-current-buffer erc-list-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
93 (erc-join-channel chan))))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
94 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
95 (defun erc-list-kill () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
96 "Kill the current ERC list buffer." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
97 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
98 (kill-buffer (current-buffer))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
99 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
100 (defun erc-list-revert () |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
101 "Refresh the list of channels." |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
102 (interactive) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
103 (with-current-buffer erc-list-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
104 (erc-cmd-LIST erc-list-last-argument))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
105 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
106 (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
|
107 "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
|
108 (interactive (list last-input-event)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
109 (if e (mouse-select-window e)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
110 (let* ((pos (event-start e)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
111 (obj (posn-object pos)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
112 (col (if obj |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
113 (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
|
114 (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
|
115 (let ((buffer-read-only nil)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
116 (if (= col 1) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
117 (sort-fields col (point-min) (point-max)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
118 (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
|
119 |
110909
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
120 (defvar erc-list-menu-mode-map |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
121 (let ((map (make-keymap))) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
122 (suppress-keymap map) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
123 (define-key map "k" 'erc-list-kill) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
124 (define-key map "j" 'erc-list-join) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
125 (define-key map "g" 'erc-list-revert) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
126 (define-key map "n" 'next-line) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
127 (define-key map "p" 'previous-line) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
128 (define-key map "q" 'quit-window) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
129 map) |
87952
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
130 "Local keymap for `erc-list-mode' buffers.") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
131 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
132 (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
|
133 "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
|
134 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
135 (unless erc-list-menu-sort-button-map |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
136 (let ((map (make-sparse-keymap))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
137 (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
|
138 (define-key map [follow-link] 'mouse-face) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
139 (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
|
140 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
141 ;; 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
|
142 (defun erc-list-button (title column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
143 (erc-propertize title |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
144 'column-number column |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
145 'help-echo "mouse-1: sort by column" |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
146 'mouse-face 'highlight |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
147 'keymap erc-list-menu-sort-button-map)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
148 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
149 (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
|
150 "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
|
151 (setq header-line-format |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
152 (concat |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
153 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
154 'display '(space :align-to 0) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
155 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
156 (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
|
157 (erc-list-button "# Users" 2) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
158 "Topic"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
159 (setq truncate-lines t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
160 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
161 (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
|
162 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
163 ;; 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
|
164 ;; channel. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
165 (defun erc-list-handle-322 (proc parsed) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
166 (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
|
167 (channel (car args)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
168 (nusers (car (cdr args))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
169 (topic (erc-response.contents parsed))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
170 (when (buffer-live-p erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
171 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
172 (erc-list-insert-item channel nusers topic)))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
173 ;; Don't let another hook run. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
174 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
175 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
176 ;; 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
|
177 (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
|
178 (with-current-buffer server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
179 ;; 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
|
180 (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
|
181 ;; 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
|
182 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
183 323 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
184 '(progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
185 (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
|
186 ;; 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
|
187 (set (make-local-variable 'erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
188 (get-buffer-create (concat "*Channels of " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
189 erc-server-announced-name |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
190 "*"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
191 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
192 (erc-list-menu-mode) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
193 (setq buffer-read-only nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
194 (erase-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
195 (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
|
196 (setq buffer-read-only t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
197 (pop-to-buffer erc-list-buffer)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
198 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
199 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
200 ;; The main entry point. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
201 (defun erc-cmd-LIST (&optional line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
202 "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
|
203 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
204 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
|
205 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
|
206 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
207 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
|
208 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
|
209 (erc-with-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
210 (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
|
211 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
212 321 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
213 (list 'progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
214 (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
|
215 (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
|
216 "")))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
217 (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
|
218 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
219 ;;; erc-list.el ends here |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
220 ;; |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
221 ;; Local Variables: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
222 ;; indent-tabs-mode: t |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
223 ;; tab-width: 8 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
224 ;; End: |
87959 | 225 |