1 ;;; emchat-menu.el --- Menus and keymaps for EMchat.
3 ;; Copyright (C) 2002 - 2011 Steve Youngs
5 ;; Author: Steve Youngs <steve@emchat.org>
6 ;; Maintainer: Steve Youngs <steve@emchat.org>
8 ;; Homepage: http://www.emchat.org/
11 ;; This file is part of EMchat.
13 ;; Redistribution and use in source and binary forms, with or without
14 ;; modification, are permitted provided that the following conditions
17 ;; 1. Redistributions of source code must retain the above copyright
18 ;; notice, this list of conditions and the following disclaimer.
20 ;; 2. Redistributions in binary form must reproduce the above copyright
21 ;; notice, this list of conditions and the following disclaimer in the
22 ;; documentation and/or other materials provided with the distribution.
24 ;; 3. Neither the name of the author nor the names of any contributors
25 ;; may be used to endorse or promote products derived from this
26 ;; software without specific prior written permission.
28 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
29 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
38 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 (require 'emchat-utils))
46 ;; Define new prefix for EMchat
47 (define-prefix-command 'emchat-prefix)
49 ;; Set EMchat global bindings
50 (define-key emchat-prefix "Xi" #'emchat-login)
51 (define-key emchat-prefix "w" #'emchat-show-window)
52 (define-key emchat-prefix "f" #'world-find)
54 ;; Bindings common to both log and buddy buffer.
55 (defvar emchat-main-map
56 (let ((map (make-keymap 'emchat-main-map)))
58 (define-key map [X] nil) ; BUG?
59 (define-key map [X i] #'emchat-login)
60 (define-key map [X o] #'emchat-logout)
61 (define-key map [X q] #'emchat-exit)
62 (define-key map [X s] #'emchat-change-status)
63 (define-key map [b] #'emchat-toggle-invisibility)
64 (define-key map [S] #'emchat-group-select-aliases)
65 (define-key map [s] #'emchat-group-select-aliases)
66 (define-key map [w] #'emchat-show-window)
67 (define-key map [H] #'emchat-history-save)
68 (define-key map [h] #'emchat-hide-window)
69 (define-key map [M] #'emchat-send-message)
70 (define-key map [m] #'emchat-send-message)
71 (define-key map [U] #'emchat-send-url)
72 (define-key map [u] #'emchat-send-url)
73 (define-key map [A] #'emchat-authorize)
74 (define-key map [a] #'emchat-authorize)
75 (define-key map [i] #'emchat-query-info)
76 (define-key map [I] #'emchat-query-info)
77 (define-key map [F] #'emchat-search)
78 (define-key map [f] #'world-find)
79 (define-key map [V] nil)
80 (define-key map [V c] #'emchat-buddy-view-connected)
81 (define-key map [V v] #'emchat-buddy-view-active)
82 (define-key map [V a] #'emchat-buddy-view-all)
84 "Keyboard map common for `emchat-log-mode-map' and `emchat-buddy-mode-map'.")
86 (defvar emchat-main-menu
88 ["Show Window" emchat-show-window t]
89 ["Hide Window" emchat-hide-window t]
90 ["Register New UIN" emchat-register-new-user t]
91 ["Change Password" emchat-change-password t]
92 ["Login" emchat-login t]
93 ["Logout" emchat-logout t]
94 ["Exit" emchat-exit t]
96 ["Select" emchat-group-select-aliases t]
97 ["Send Message" emchat-send-message t]
98 ["Send URL" emchat-send-url t]
99 ["Authorize" emchat-authorize t]
100 ["Change Status" emchat-change-status t]
101 ["Change Idle Timeout" emchat-change-idle-timeout t]
102 ["Search" emchat-search t]
103 ["Update Meta Info" emchat-update-meta-info t]
105 ["alias -> uin" emchat-alias-uin t]
106 ["uin -> alias" emchat-uin-alias t]
107 ["Redo Packet" emchat-redo-hex t]
108 ["Resend Contact List" emchat-send-contact-list t]
109 ["Buddy Buffer" emchat-buddy-show-buffer t]
110 ["Log Buffer" emchat-log-show-buffer t]
112 ["Email Author" emchat-email-author t]
113 ["Submit Bug Report" (emchat-report-bug emchat-blurb) t]
114 ["Make a Donation" emchat-donation t]
115 ["Customize" emchat-customize t])
116 "Menu for both `emchat-log-mode' and `emchat-buddy-mode'.")
119 emchat-main-easymenu nil "EMchat" emchat-main-menu)
121 (defvar emchat-log-menu
123 ["Select Around" emchat-select-alias-around t]
124 ["Send Message Around" emchat-send-message-alias-around t]
125 ["Send URL Around" emchat-send-url-alias-around t]
126 ["Forward Message" emchat-forward-message-around t]
127 ["Oops!" emchat-oops t]
128 ["Authorize Around" emchat-authorize-alias-around t]
129 ["Query Around" emchat-query-info-alias-around t]
130 ["History Around" emchat-history-around t]
132 ["New Log File" emchat-log-new-file t]
133 ["Contract Log" emchat-log-contract t]
134 ["Expand Log" emchat-log-expand t]
135 ["Previous Log" emchat-log-previous t]
136 ["Next Log" emchat-log-next t]
138 ["Mark Read" emchat-log-mark-read t]
139 ["Mark Unread" emchat-log-mark-unread t])
140 "Menu for `emchat-log-mode'.")
143 emchat-buddy-easymenu nil "Buddy" emchat-log-menu)
145 (defvar emchat-log-mode-map
146 (let ((map (make-sparse-keymap 'emchat-log-mode-map)))
147 (set-keymap-parents map (list emchat-main-map))
148 (define-key map [delete] #'emchat-log-contract)
149 (define-key map [insert] #'emchat-log-expand)
150 (define-key map [(control up)] #'emchat-log-previous)
151 (define-key map [(control down)] #'emchat-log-next)
152 (define-key map [v] #'emchat-log-mark-unread)
153 (define-key map [c] #'emchat-log-mark-read)
154 (define-key map [W] #'emchat-alias-around)
155 (define-key map [s] #'emchat-select-alias-around)
156 (define-key map [m] #'emchat-send-message-alias-around)
157 (define-key map [u] #'emchat-send-url-alias-around)
158 (define-key map [a] #'emchat-authorize-alias-around)
159 (define-key map [i] #'emchat-query-info-alias-around)
160 (define-key map [f] #'emchat-forward-message-around)
161 (define-key map [n] #'emchat-log-next-unread)
162 (define-key map [N] #'emchat-log-next)
163 (define-key map [o] #'emchat-switch-to-buddy-buffer)
164 (define-key map [O] #'emchat-oops)
165 (define-key map [p] #'emchat-log-previous-unread)
166 (define-key map [P] #'emchat-log-previous)
167 (define-key map [t] #'emchat-history-around)
168 (define-key map [T] #'emchat-history)
170 "Keymap for `emchat-log-mode'.")
172 (defvar emchat-history-menu
174 ["Prev Event" emchat-history-prev t]
175 ["Next Event" emchat-history-next t]
176 ["Save Histories" emchat-history-save t]
177 ["Quit" emchat-history-bury-buffer t])
178 "Menu for `emchat-history-mod'.")
180 (defvar emchat-history-mode-map
181 (let ((map (make-sparse-keymap 'emchat-history-mode-map)))
182 (define-key map [n] #'emchat-history-next)
183 (define-key map [p] #'emchat-history-prev)
184 (define-key map [s] #'emchat-history-save)
185 (define-key map [q] #'emchat-history-bury-buffer)
187 "Keymap for `emchat-history-mode'.")
190 emchat-history-easymenu nil "History" emchat-history-menu)
192 (defvar emchat-buddy-menu
194 ["Select Here" emchat-select-alias-here t]
195 ["Select By Status" emchat-buddy-select-all-in-view-by-status t]
196 ["Select By Regexp" emchat-buddy-select-all-in-view-by-regexp t]
197 ["Send Message Here" emchat-send-message-alias-here t]
198 ["Send URL Here" emchat-send-url-alias-here t]
199 ["Authorize Here" emchat-authorize-alias-here t]
200 ["Query Info Here" emchat-query-info-alias-here t]
201 ["History Here" emchat-history-here-other-window t]
203 ["View Connected" emchat-buddy-view-connected t]
204 ["View Active" emchat-buddy-view-active t]
205 ["View All" emchat-buddy-view-all t])
206 "Menu for `emchat-buddy-mode'.")
209 emchat-log-easymenu nil "Log" emchat-buddy-menu)
211 (defvar emchat-alias-map
212 (let ((map (make-sparse-keymap 'emchat-alias-map)))
213 (define-key map [button2] #'emchat-send-message-via-mouse)
215 "Keymap for alias extent.")
217 (defvar emchat-hyperlink-map
218 (let ((map (make-sparse-keymap 'emchat-hyperlink-map)))
219 (define-key map [button2] #'emchat-emphasis-visit-hyperlink-at-mouse)
220 (define-key map [return] #'emchat-emphasis-visit-hyperlink-at-point)
221 (emchat-do-in-sxemacs
222 (define-key map [(control button2)] #'emchat-curl-url-at-mouse)
223 (define-key map [(control return)] #'emchat-curl-url-at-point)
224 (define-key map [d] #'emchat-curl-url-at-point))
226 "Keymap for the hyperlink extents.")
228 (defvar emchat-buddy-mode-map
229 (let ((map (make-sparse-keymap 'emchat-buddy-mode-map)))
230 (set-keymap-parents map (list emchat-main-map))
231 (define-key map [W] #'emchat-alias-here)
232 (define-key map [s] #'emchat-select-alias-here)
233 (define-key map [m] #'emchat-send-message-alias-here)
234 (define-key map [u] #'emchat-send-url-alias-here)
235 (define-key map [a] #'emchat-authorize-alias-here)
236 (define-key map [i] #'emchat-query-info-alias-here)
237 (define-key map [n] #'next-line)
238 (define-key map [o] #'emchat-switch-to-log-buffer)
239 (define-key map [p] #'previous-line)
240 (define-key map [t] #'emchat-history-here-other-window)
242 "Keymap for `emchat-buddy-mode'.")
244 (provide 'emchat-menu)
245 ;;; emchat-menu.el ends here