Merge from emacs--rel--22
[bpt/emacs.git] / lisp / term / sun.el
1 ;;; sun.el --- keybinding for standard default sunterm keys
2
3 ;; Copyright (C) 1987, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
5
6 ;; Author: Jeff Peck <peck@sun.com>
7 ;; Keywords: terminals
8
9 ;; This file is part of GNU Emacs.
10
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 3, or (at your option)
14 ;; any later version.
15
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.
20
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.
25
26 ;;; Commentary:
27
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.
30
31 ;;; Code:
32
33 (defun scroll-down-in-place (n)
34 (interactive "p")
35 (forward-line (- n))
36 (scroll-down n))
37
38 (defun scroll-up-in-place (n)
39 (interactive "p")
40 (forward-line n)
41 (scroll-up n))
42
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))
49
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)))
57
58 (defun rerun-prev-command ()
59 "Repeat Previous-complex-command."
60 (interactive)
61 (eval (nth 0 command-history)))
62
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)))
71 )
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))))
77
78 (defun research-forward ()
79 "Repeat RE search forward."
80 (interactive)
81 (re-search-forward (grep-arg)))
82
83 (defun research-backward ()
84 "Repeat RE search backward."
85 (interactive)
86 (re-search-backward (grep-arg)))
87 \f
88 ;;
89 ;; handle sun's extra function keys
90 ;; this version for those who run with standard .ttyswrc and no emacstool
91 ;;
92 ;; sunview picks up expose and open on the way UP,
93 ;; so we ignore them on the way down
94 ;;
95
96 (defvar sun-raw-prefix (make-sparse-keymap))
97
98 ;; Since .emacs gets loaded before this file, a hook is supplied
99 ;; for you to put your own bindings in.
100
101 (defvar sun-raw-prefix-hooks nil
102 "List of forms to evaluate after setting sun-raw-prefix.")
103
104 \f
105
106 (defun terminal-init-sun ()
107 "Terminal initialization function for sun."
108 (define-key local-function-key-map "\e[" sun-raw-prefix)
109
110 (define-key sun-raw-prefix "210z" [r3])
111 (define-key sun-raw-prefix "213z" [r6])
112 (define-key sun-raw-prefix "214z" [r7])
113 (define-key sun-raw-prefix "216z" [r9])
114 (define-key sun-raw-prefix "218z" [r11])
115 (define-key sun-raw-prefix "220z" [r13])
116 (define-key sun-raw-prefix "222z" [r15])
117 (define-key sun-raw-prefix "193z" [redo])
118 (define-key sun-raw-prefix "194z" [props])
119 (define-key sun-raw-prefix "195z" [undo])
120 ;; (define-key sun-raw-prefix "196z" 'ignore) ; Expose-down
121 ;; (define-key sun-raw-prefix "197z" [put])
122 ;; (define-key sun-raw-prefix "198z" 'ignore) ; Open-down
123 ;; (define-key sun-raw-prefix "199z" [get])
124 (define-key sun-raw-prefix "200z" [find])
125 ;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark) ; Delete
126 (define-key sun-raw-prefix "224z" [f1])
127 (define-key sun-raw-prefix "225z" [f2])
128 (define-key sun-raw-prefix "226z" [f3])
129 (define-key sun-raw-prefix "227z" [f4])
130 (define-key sun-raw-prefix "228z" [f5])
131 (define-key sun-raw-prefix "229z" [f6])
132 (define-key sun-raw-prefix "230z" [f7])
133 (define-key sun-raw-prefix "231z" [f8])
134 (define-key sun-raw-prefix "232z" [f9])
135 (define-key sun-raw-prefix "233z" [f10])
136 (define-key sun-raw-prefix "234z" [f11])
137 (define-key sun-raw-prefix "235z" [f12])
138 (define-key sun-raw-prefix "A" [up]) ; R8
139 (define-key sun-raw-prefix "B" [down]) ; R14
140 (define-key sun-raw-prefix "C" [right]) ; R12
141 (define-key sun-raw-prefix "D" [left]) ; R10
142
143 (global-set-key [r3] 'backward-page)
144 (global-set-key [r6] 'forward-page)
145 (global-set-key [r7] 'beginning-of-buffer)
146 (global-set-key [r9] 'scroll-down)
147 (global-set-key [r11] 'recenter)
148 (global-set-key [r13] 'end-of-buffer)
149 (global-set-key [r15] 'scroll-up)
150 (global-set-key [redo] 'redraw-display) ;FIXME: collides with default.
151 (global-set-key [props] 'list-buffers)
152 (global-set-key [put] 'sun-select-region)
153 (global-set-key [get] 'sun-yank-selection)
154 (global-set-key [find] 'exchange-point-and-mark)
155 (global-set-key [f3] 'scroll-down-in-place)
156 (global-set-key [f4] 'scroll-up-in-place)
157 (global-set-key [f6] 'shrink-window)
158 (global-set-key [f7] 'enlarge-window)
159
160 (when sun-raw-prefix-hooks
161 (message "sun-raw-prefix-hooks is obsolete! Use term-setup-hook instead!")
162 (let ((hooks sun-raw-prefix-hooks))
163 (while hooks
164 (eval (car hooks))
165 (setq hooks (cdr hooks))))))
166
167 ;;; arch-tag: db761d47-fd7d-42b4-aae1-04fa116b6ba6
168 ;;; sun.el ends here