Switch to recommended form of GPLv3 permissions notice.
[bpt/emacs.git] / lisp / term / sun.el
CommitLineData
092af6d8 1;;; sun.el --- keybinding for standard default sunterm keys
864a714e 2
5fd6d89f 3;; Copyright (C) 1987, 2001, 2002, 2003, 2004,
12dc447f 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
2fe590dc 5
864a714e
ER
6;; Author: Jeff Peck <peck@sun.com>
7;; Keywords: terminals
8
2fe590dc
EN
9;; This file is part of GNU Emacs.
10
1fecc8fe 11;; GNU Emacs is free software: you can redistribute it and/or modify
2fe590dc 12;; it under the terms of the GNU General Public License as published by
1fecc8fe
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
2fe590dc
EN
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.
e645a1dd 20
2fe590dc 21;; You should have received a copy of the GNU General Public License
1fecc8fe 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
e645a1dd 23
864a714e 24;;; Commentary:
e645a1dd
JB
25
26;; The function key sequences for the console have been converted for
27;; use with function-key-map, but the *tool stuff hasn't been touched.
28
864a714e 29;;; Code:
e645a1dd 30
e645a1dd
JB
31(defun scroll-down-in-place (n)
32 (interactive "p")
f7ba2ff4 33 (forward-line (- n))
e645a1dd
JB
34 (scroll-down n))
35
36(defun scroll-up-in-place (n)
37 (interactive "p")
f7ba2ff4 38 (forward-line n)
e645a1dd
JB
39 (scroll-up n))
40
41(defun kill-region-and-unmark (beg end)
42 "Like kill-region, but pops the mark [which equals point, anyway.]"
43 (interactive "r")
44 (kill-region beg end)
45 (setq this-command 'kill-region-and-unmark)
46 (set-mark-command t))
47
e645a1dd
JB
48(defun rerun-prev-command ()
49 "Repeat Previous-complex-command."
50 (interactive)
51 (eval (nth 0 command-history)))
52
53(defvar grep-arg nil "Default arg for RE-search")
54(defun grep-arg ()
55 (if (memq last-command '(research-forward research-backward)) grep-arg
56 (let* ((command (car command-history))
57 (command-name (symbol-name (car command)))
58 (search-arg (car (cdr command)))
db95369b 59 (search-command
e645a1dd
JB
60 (and command-name (string-match "search" command-name)))
61 )
62 (if (and search-command (stringp search-arg)) (setq grep-arg search-arg)
db95369b 63 (setq search-command this-command
e645a1dd
JB
64 grep-arg (read-string "REsearch: " grep-arg)
65 this-command search-command)
66 grep-arg))))
67
68(defun research-forward ()
69 "Repeat RE search forward."
70 (interactive)
71 (re-search-forward (grep-arg)))
72
73(defun research-backward ()
74 "Repeat RE search backward."
75 (interactive)
76 (re-search-backward (grep-arg)))
77\f
acd9f40c
SM
78;;
79;; handle sun's extra function keys
80;; this version for those who run with standard .ttyswrc and no emacstool
81;;
db95369b 82;; sunview picks up expose and open on the way UP,
acd9f40c
SM
83;; so we ignore them on the way down
84;;
e645a1dd 85
9039fed0
SM
86(defvar sun-raw-prefix
87 (let ((map (make-sparse-keymap)))
88 (define-key map "210z" [r3])
89 (define-key map "213z" [r6])
90 (define-key map "214z" [r7])
91 (define-key map "216z" [r9])
92 (define-key map "218z" [r11])
93 (define-key map "220z" [r13])
94 (define-key map "222z" [r15])
95 (define-key map "193z" [redo])
96 (define-key map "194z" [props])
97 (define-key map "195z" [undo])
98 ;; (define-key map "196z" 'ignore) ; Expose-down
99 ;; (define-key map "197z" [put])
100 ;; (define-key map "198z" 'ignore) ; Open-down
101 ;; (define-key map "199z" [get])
102 (define-key map "200z" [find])
103 ;; (define-key map "201z" 'kill-region-and-unmark) ; Delete
104 (define-key map "224z" [f1])
105 (define-key map "225z" [f2])
106 (define-key map "226z" [f3])
107 (define-key map "227z" [f4])
108 (define-key map "228z" [f5])
109 (define-key map "229z" [f6])
110 (define-key map "230z" [f7])
111 (define-key map "231z" [f8])
112 (define-key map "232z" [f9])
113 (define-key map "233z" [f10])
114 (define-key map "234z" [f11])
115 (define-key map "235z" [f12])
116 (define-key map "A" [up]) ; R8
117 (define-key map "B" [down]) ; R14
118 (define-key map "C" [right]) ; R12
119 (define-key map "D" [left]) ; R10
120 map))
e645a1dd 121
acd9f40c
SM
122;; Since .emacs gets loaded before this file, a hook is supplied
123;; for you to put your own bindings in.
e645a1dd 124
141e63d5
JB
125(defvar sun-raw-prefix-hooks nil
126 "List of forms to evaluate after setting sun-raw-prefix.")
e645a1dd 127
e645a1dd 128\f
e645a1dd 129
4f0c9ba7
DN
130(defun terminal-init-sun ()
131 "Terminal initialization function for sun."
9039fed0 132 (define-key input-decode-map "\e[" sun-raw-prefix)
4f0c9ba7
DN
133
134 (global-set-key [r3] 'backward-page)
135 (global-set-key [r6] 'forward-page)
136 (global-set-key [r7] 'beginning-of-buffer)
137 (global-set-key [r9] 'scroll-down)
138 (global-set-key [r11] 'recenter)
139 (global-set-key [r13] 'end-of-buffer)
140 (global-set-key [r15] 'scroll-up)
141 (global-set-key [redo] 'redraw-display) ;FIXME: collides with default.
142 (global-set-key [props] 'list-buffers)
143 (global-set-key [put] 'sun-select-region)
144 (global-set-key [get] 'sun-yank-selection)
145 (global-set-key [find] 'exchange-point-and-mark)
146 (global-set-key [f3] 'scroll-down-in-place)
147 (global-set-key [f4] 'scroll-up-in-place)
148 (global-set-key [f6] 'shrink-window)
149 (global-set-key [f7] 'enlarge-window)
150
151 (when sun-raw-prefix-hooks
152 (message "sun-raw-prefix-hooks is obsolete! Use term-setup-hook instead!")
153 (let ((hooks sun-raw-prefix-hooks))
154 (while hooks
155 (eval (car hooks))
ee756915 156 (setq hooks (cdr hooks))))))
864a714e 157
9039fed0 158;; arch-tag: db761d47-fd7d-42b4-aae1-04fa116b6ba6
864a714e 159;;; sun.el ends here