Mercurial > emacs
annotate lisp/erc/erc-list.el @ 104344:ffa2f09da5b2
(minibuffer-hide-completions): New function.
(completion--do-completion): Use it.
(completions-annotations): New face.
(completion--insert-strings): Use it.
(completion-pcm--delim-wild-regex): Add docstring.
(completion-pcm--string->pattern): Add support for 0-width delimiters
in completion-pcm--delim-wild-regex.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 19 Aug 2009 02:15:19 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
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 |
100908 | 3 ;; Copyright (C) 2008, 2009 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 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
120 (defvar erc-list-menu-mode-map nil |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
121 "Local keymap for `erc-list-mode' buffers.") |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
122 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
123 (unless erc-list-menu-mode-map |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
124 (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
|
125 (suppress-keymap erc-list-menu-mode-map) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
126 (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
|
127 (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
|
128 (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
|
129 (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
|
130 (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
|
131 (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
|
132 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
133 (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
|
134 "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
|
135 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
136 (unless erc-list-menu-sort-button-map |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
137 (let ((map (make-sparse-keymap))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
138 (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
|
139 (define-key map [follow-link] 'mouse-face) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
140 (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
|
141 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
142 ;; 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
|
143 (defun erc-list-button (title column) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
144 (erc-propertize title |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
145 'column-number column |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
146 'help-echo "mouse-1: sort by column" |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
147 'mouse-face 'highlight |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
148 'keymap erc-list-menu-sort-button-map)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
149 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
150 (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
|
151 "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
|
152 (setq header-line-format |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
153 (concat |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
154 (erc-propertize " " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
155 'display '(space :align-to 0) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
156 'face 'fixed-pitch) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
157 (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
|
158 (erc-list-button "# Users" 2) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
159 "Topic"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
160 (setq truncate-lines t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
161 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
162 (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
|
163 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
164 ;; 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
|
165 ;; channel. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
166 (defun erc-list-handle-322 (proc parsed) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
167 (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
|
168 (channel (car args)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
169 (nusers (car (cdr args))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
170 (topic (erc-response.contents parsed))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
171 (when (buffer-live-p erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
172 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
173 (erc-list-insert-item channel nusers topic)))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
174 ;; Don't let another hook run. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
175 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
176 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
177 ;; 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
|
178 (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
|
179 (with-current-buffer server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
180 ;; 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
|
181 (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
|
182 ;; 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
|
183 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
184 323 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
185 '(progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
186 (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
|
187 ;; 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
|
188 (set (make-local-variable 'erc-list-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
189 (get-buffer-create (concat "*Channels of " |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
190 erc-server-announced-name |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
191 "*"))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
192 (with-current-buffer erc-list-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
193 (erc-list-menu-mode) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
194 (setq buffer-read-only nil) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
195 (erase-buffer) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
196 (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
|
197 (setq buffer-read-only t)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
198 (pop-to-buffer erc-list-buffer)) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
199 t) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
200 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
201 ;; The main entry point. |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
202 (defun erc-cmd-LIST (&optional line) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
203 "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
|
204 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
205 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
|
206 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
|
207 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
208 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
|
209 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
|
210 (erc-with-server-buffer |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
211 (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
|
212 (erc-once-with-server-event |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
213 321 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
214 (list 'progn |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
215 (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
|
216 (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
|
217 "")))) |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
218 (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
|
219 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
220 ;;; erc-list.el ends here |
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 ;; Local Variables: |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
223 ;; indent-tabs-mode: t |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
224 ;; tab-width: 8 |
b8f89dd3680d
ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents:
diff
changeset
|
225 ;; End: |
87959 | 226 |
227 ;; arch-tag: 99c5f9cb-6bac-4224-86bf-e394768cd1d0 |