(url-retrieve-internal): Bind url-proxy-object to nil.
[emacs.git] / lisp / term / sun.el
blob0d264f247ec64454e90ad71a3da71ac3a06c6c6c
1 ;;; sun.el --- keybinding for standard default sunterm keys
3 ;; Copyright (C) 1987, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Jeff Peck <peck@sun.com>
7 ;; Keywords: terminals
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; The function key sequences for the console have been converted for
29 ;; use with function-key-map, but the *tool stuff hasn't been touched.
31 ;;; Code:
33 (defun scroll-down-in-place (n)
34 (interactive "p")
35 (previous-line n)
36 (scroll-down n))
38 (defun scroll-up-in-place (n)
39 (interactive "p")
40 (next-line n)
41 (scroll-up n))
43 (defun kill-region-and-unmark (beg end)
44 "Like kill-region, but pops the mark [which equals point, anyway.]"
45 (interactive "r")
46 (kill-region beg end)
47 (setq this-command 'kill-region-and-unmark)
48 (set-mark-command t))
50 (defun select-previous-complex-command ()
51 "Select Previous-complex-command"
52 (interactive)
53 (if (zerop (minibuffer-depth))
54 (repeat-complex-command 1)
55 ;; FIXME: this function does not seem to exist. -stef'01
56 (previous-complex-command 1)))
58 (defun rerun-prev-command ()
59 "Repeat Previous-complex-command."
60 (interactive)
61 (eval (nth 0 command-history)))
63 (defvar grep-arg nil "Default arg for RE-search")
64 (defun grep-arg ()
65 (if (memq last-command '(research-forward research-backward)) grep-arg
66 (let* ((command (car command-history))
67 (command-name (symbol-name (car command)))
68 (search-arg (car (cdr command)))
69 (search-command
70 (and command-name (string-match "search" command-name)))
72 (if (and search-command (stringp search-arg)) (setq grep-arg search-arg)
73 (setq search-command this-command
74 grep-arg (read-string "REsearch: " grep-arg)
75 this-command search-command)
76 grep-arg))))
78 (defun research-forward ()
79 "Repeat RE search forward."
80 (interactive)
81 (re-search-forward (grep-arg)))
83 (defun research-backward ()
84 "Repeat RE search backward."
85 (interactive)
86 (re-search-backward (grep-arg)))
89 ;; handle sun's extra function keys
90 ;; this version for those who run with standard .ttyswrc and no emacstool
92 ;; sunview picks up expose and open on the way UP,
93 ;; so we ignore them on the way down
96 (defvar sun-raw-prefix (make-sparse-keymap))
98 ;; Since .emacs gets loaded before this file, a hook is supplied
99 ;; for you to put your own bindings in.
101 (defvar sun-raw-prefix-hooks nil
102 "List of forms to evaluate after setting sun-raw-prefix.")
105 ;;; This section adds definitions for the emacstool users
106 ;; emacstool event filter converts function keys to C-x*{c}{lrt}
108 ;; for example the Open key (L7) would be encoded as "\C-x*gl"
109 ;; the control, meta, and shift keys modify the character {lrt}
110 ;; note that (unshifted) C-l is ",", C-r is "2", and C-t is "4"
112 ;; {c} is [a-j] for LEFT, [a-i] for TOP, [a-o] for RIGHT.
113 ;; A higher level insists on encoding {h,j,l,n}{r} (the arrow keys)
114 ;; as ANSI escape sequences. Use the shell command
115 ;; % setkeys noarrows
116 ;; if you want these to come through for emacstool.
118 ;; If you are not using EmacsTool,
119 ;; you can also use this by creating a .ttyswrc file to do the conversion.
120 ;; but it won't include the CONTROL, META, or SHIFT keys!
122 ;; Important to define SHIFTed sequence before matching unshifted sequence.
123 ;; (talk about bletcherous old uppercase terminal conventions!*$#@&%*&#$%)
124 ;; this is worse than C-S/C-Q flow control anyday!
125 ;; Do *YOU* run in capslock mode?
128 ;; Note: al, el and gl are trapped by EmacsTool, so they never make it here.
130 (defvar suntool-map (make-sparse-keymap)
131 "*Keymap for Emacstool bindings.")
134 ;; Since .emacs gets loaded before this file, a hook is supplied
135 ;; for you to put your own bindings in.
137 (defvar suntool-map-hooks nil
138 "List of forms to evaluate after setting suntool-map.")
141 ;; If running under emacstool, arrange to call suspend-emacstool
142 ;; instead of suspend-emacs.
144 ;; First mouse blip is a clue that we are in emacstool.
146 ;; C-x C-@ is the mouse command prefix.
148 (autoload 'sun-mouse-handler "sun-mouse"
149 "Sun Emacstool handler for mouse blips (not loaded)." t)
151 (defun terminal-init-sun ()
152 "Terminal initialization function for sun."
153 (define-key function-key-map "\e[" sun-raw-prefix)
155 (define-key sun-raw-prefix "210z" [r3])
156 (define-key sun-raw-prefix "213z" [r6])
157 (define-key sun-raw-prefix "214z" [r7])
158 (define-key sun-raw-prefix "216z" [r9])
159 (define-key sun-raw-prefix "218z" [r11])
160 (define-key sun-raw-prefix "220z" [r13])
161 (define-key sun-raw-prefix "222z" [r15])
162 (define-key sun-raw-prefix "193z" [redo])
163 (define-key sun-raw-prefix "194z" [props])
164 (define-key sun-raw-prefix "195z" [undo])
165 ;; (define-key sun-raw-prefix "196z" 'ignore) ; Expose-down
166 ;; (define-key sun-raw-prefix "197z" [put])
167 ;; (define-key sun-raw-prefix "198z" 'ignore) ; Open-down
168 ;; (define-key sun-raw-prefix "199z" [get])
169 (define-key sun-raw-prefix "200z" [find])
170 ;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark) ; Delete
171 (define-key sun-raw-prefix "224z" [f1])
172 (define-key sun-raw-prefix "225z" [f2])
173 (define-key sun-raw-prefix "226z" [f3])
174 (define-key sun-raw-prefix "227z" [f4])
175 (define-key sun-raw-prefix "228z" [f5])
176 (define-key sun-raw-prefix "229z" [f6])
177 (define-key sun-raw-prefix "230z" [f7])
178 (define-key sun-raw-prefix "231z" [f8])
179 (define-key sun-raw-prefix "232z" [f9])
180 (define-key sun-raw-prefix "233z" [f10])
181 (define-key sun-raw-prefix "234z" [f11])
182 (define-key sun-raw-prefix "235z" [f12])
183 (define-key sun-raw-prefix "A" [up]) ; R8
184 (define-key sun-raw-prefix "B" [down]) ; R14
185 (define-key sun-raw-prefix "C" [right]) ; R12
186 (define-key sun-raw-prefix "D" [left]) ; R10
188 (global-set-key [r3] 'backward-page)
189 (global-set-key [r6] 'forward-page)
190 (global-set-key [r7] 'beginning-of-buffer)
191 (global-set-key [r9] 'scroll-down)
192 (global-set-key [r11] 'recenter)
193 (global-set-key [r13] 'end-of-buffer)
194 (global-set-key [r15] 'scroll-up)
195 (global-set-key [redo] 'redraw-display) ;FIXME: collides with default.
196 (global-set-key [props] 'list-buffers)
197 (global-set-key [put] 'sun-select-region)
198 (global-set-key [get] 'sun-yank-selection)
199 (global-set-key [find] 'exchange-point-and-mark)
200 (global-set-key [f3] 'scroll-down-in-place)
201 (global-set-key [f4] 'scroll-up-in-place)
202 (global-set-key [f6] 'shrink-window)
203 (global-set-key [f7] 'enlarge-window)
205 (when sun-raw-prefix-hooks
206 (message "sun-raw-prefix-hooks is obsolete! Use term-setup-hook instead!")
207 (let ((hooks sun-raw-prefix-hooks))
208 (while hooks
209 (eval (car hooks))
210 (setq hooks (cdr hooks)))))
212 (define-key suntool-map "gr" 'beginning-of-buffer) ; r7
213 (define-key suntool-map "iR" 'backward-page) ; R9
214 (define-key suntool-map "ir" 'scroll-down) ; r9
215 (define-key suntool-map "kr" 'recenter) ; r11
216 (define-key suntool-map "mr" 'end-of-buffer) ; r13
217 (define-key suntool-map "oR" 'forward-page) ; R15
218 (define-key suntool-map "or" 'scroll-up) ; r15
219 (define-key suntool-map "b\M-L" 'rerun-prev-command) ; M-AGAIN
220 (define-key suntool-map "b\M-l" 'prev-complex-command) ; M-Again
221 (define-key suntool-map "bl" 'redraw-display) ; Again
222 (define-key suntool-map "cl" 'list-buffers) ; Props
223 (define-key suntool-map "dl" 'undo) ; Undo
224 (define-key suntool-map "el" 'ignore) ; Expose-Open
225 (define-key suntool-map "fl" 'sun-select-region) ; Put
226 (define-key suntool-map "f," 'copy-region-as-kill) ; C-Put
227 (define-key suntool-map "gl" 'ignore) ; Open-Open
228 (define-key suntool-map "hl" 'sun-yank-selection) ; Get
229 (define-key suntool-map "h," 'yank) ; C-Get
230 (define-key suntool-map "il" 'research-forward) ; Find
231 (define-key suntool-map "i," 're-search-forward) ; C-Find
232 (define-key suntool-map "i\M-l" 'research-backward) ; M-Find
233 (define-key suntool-map "i\M-," 're-search-backward) ; C-M-Find
235 (define-key suntool-map "jL" 'yank) ; DELETE
236 (define-key suntool-map "jl" 'kill-region-and-unmark) ; Delete
237 (define-key suntool-map "j\M-l" 'exchange-point-and-mark) ; M-Delete
238 (define-key suntool-map "j,"
239 (lambda () (interactive) (pop-mark))) ; C-Delete
241 (define-key suntool-map "fT" 'shrink-window-horizontally) ; T6
242 (define-key suntool-map "gT" 'enlarge-window-horizontally) ; T7
243 (define-key suntool-map "ft" 'shrink-window) ; t6
244 (define-key suntool-map "gt" 'enlarge-window) ; t7
245 (define-key suntool-map "cT" (lambda (n) (interactive "p") (scroll-down n)))
246 (define-key suntool-map "dT" (lambda (n) (interactive "p") (scroll-up n)))
247 (define-key suntool-map "ct" 'scroll-down-in-place) ; t3
248 (define-key suntool-map "dt" 'scroll-up-in-place) ; t4
249 (define-key ctl-x-map "*" suntool-map)
251 (when suntool-map-hooks
252 (message "suntool-map-hooks is obsolete! Use term-setup-hook instead!")
253 (let ((hooks suntool-map-hooks))
254 (while hooks
255 (eval (car hooks))
256 (setq hooks (cdr hooks)))))
258 (define-key ctl-x-map "\C-@" 'sun-mouse-once))
260 (defun emacstool-init ()
261 "Set up Emacstool window, if you know you are in an emacstool."
262 ;; Make sure sun-mouse and sun-fns are loaded.
263 (require 'sun-fns)
264 (define-key ctl-x-map "\C-@" 'sun-mouse-handler)
266 ;; FIXME: this function does not seem to exist either. -stef'01
267 (if (< (sun-window-init) 0)
268 (message "Not a Sun Window")
269 (progn
270 (substitute-key-definition 'suspend-emacs 'suspend-emacstool global-map)
271 (substitute-key-definition 'suspend-emacs 'suspend-emacstool esc-map)
272 (substitute-key-definition 'suspend-emacs 'suspend-emacstool ctl-x-map))
273 (send-string-to-terminal
274 (concat "\033]lEmacstool - GNU Emacs " emacs-version "\033\\"))))
276 (defun sun-mouse-once ()
277 "Converts to emacstool and sun-mouse-handler on first mouse hit."
278 (interactive)
279 (emacstool-init)
280 (sun-mouse-handler)) ; Now, execute this mouse blip.
282 ;;; arch-tag: db761d47-fd7d-42b4-aae1-04fa116b6ba6
283 ;;; sun.el ends here