| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
(defun scroll-down-in-place (n) |
|---|
| 34 |
(interactive "p") |
|---|
| 35 |
(previous-line n) |
|---|
| 36 |
(scroll-down n)) |
|---|
| 37 |
|
|---|
| 38 |
(defun scroll-up-in-place (n) |
|---|
| 39 |
(interactive "p") |
|---|
| 40 |
(next-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 |
|
|---|
| 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 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
(defvar sun-raw-prefix (make-sparse-keymap)) |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
(defvar sun-raw-prefix-hooks nil |
|---|
| 102 |
"List of forms to evaluate after setting sun-raw-prefix.") |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
(defvar suntool-map (make-sparse-keymap) |
|---|
| 131 |
"*Keymap for Emacstool bindings.") |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
(defvar suntool-map-hooks nil |
|---|
| 138 |
"List of forms to evaluate after setting suntool-map.") |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
(autoload 'sun-mouse-handler "sun-mouse" |
|---|
| 149 |
"Sun Emacstool handler for mouse blips (not loaded)." t) |
|---|
| 150 |
|
|---|
| 151 |
(defun terminal-init-sun () |
|---|
| 152 |
"Terminal initialization function for sun." |
|---|
| 153 |
(define-key function-key-map "\e[" sun-raw-prefix) |
|---|
| 154 |
|
|---|
| 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 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
(define-key sun-raw-prefix "200z" [find]) |
|---|
| 170 |
|
|---|
| 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]) |
|---|
| 184 |
(define-key sun-raw-prefix "B" [down]) |
|---|
| 185 |
(define-key sun-raw-prefix "C" [right]) |
|---|
| 186 |
(define-key sun-raw-prefix "D" [left]) |
|---|
| 187 |
|
|---|
| 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) |
|---|
| 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) |
|---|
| 204 |
|
|---|
| 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))))) |
|---|
| 211 |
|
|---|
| 212 |
(define-key suntool-map "gr" 'beginning-of-buffer) |
|---|
| 213 |
(define-key suntool-map "iR" 'backward-page) |
|---|
| 214 |
(define-key suntool-map "ir" 'scroll-down) |
|---|
| 215 |
(define-key suntool-map "kr" 'recenter) |
|---|
| 216 |
(define-key suntool-map "mr" 'end-of-buffer) |
|---|
| 217 |
(define-key suntool-map "oR" 'forward-page) |
|---|
| 218 |
(define-key suntool-map "or" 'scroll-up) |
|---|
| 219 |
(define-key suntool-map "b\M-L" 'rerun-prev-command) |
|---|
| 220 |
(define-key suntool-map "b\M-l" 'prev-complex-command) |
|---|
| 221 |
(define-key suntool-map "bl" 'redraw-display) |
|---|
| 222 |
(define-key suntool-map "cl" 'list-buffers) |
|---|
| 223 |
(define-key suntool-map "dl" 'undo) |
|---|
| 224 |
(define-key suntool-map "el" 'ignore) |
|---|
| 225 |
(define-key suntool-map "fl" 'sun-select-region) |
|---|
| 226 |
(define-key suntool-map "f," 'copy-region-as-kill) |
|---|
| 227 |
(define-key suntool-map "gl" 'ignore) |
|---|
| 228 |
(define-key suntool-map "hl" 'sun-yank-selection) |
|---|
| 229 |
(define-key suntool-map "h," 'yank) |
|---|
| 230 |
(define-key suntool-map "il" 'research-forward) |
|---|
| 231 |
(define-key suntool-map "i," 're-search-forward) |
|---|
| 232 |
(define-key suntool-map "i\M-l" 'research-backward) |
|---|
| 233 |
(define-key suntool-map "i\M-," 're-search-backward) |
|---|
| 234 |
|
|---|
| 235 |
(define-key suntool-map "jL" 'yank) |
|---|
| 236 |
(define-key suntool-map "jl" 'kill-region-and-unmark) |
|---|
| 237 |
(define-key suntool-map "j\M-l" 'exchange-point-and-mark) |
|---|
| 238 |
(define-key suntool-map "j," |
|---|
| 239 |
(lambda () (interactive) (pop-mark))) |
|---|
| 240 |
|
|---|
| 241 |
(define-key suntool-map "fT" 'shrink-window-horizontally) |
|---|
| 242 |
(define-key suntool-map "gT" 'enlarge-window-horizontally) |
|---|
| 243 |
(define-key suntool-map "ft" 'shrink-window) |
|---|
| 244 |
(define-key suntool-map "gt" 'enlarge-window) |
|---|
| 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) |
|---|
| 248 |
(define-key suntool-map "dt" 'scroll-up-in-place) |
|---|
| 249 |
(define-key ctl-x-map "*" suntool-map) |
|---|
| 250 |
|
|---|
| 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))))) |
|---|
| 257 |
|
|---|
| 258 |
(define-key ctl-x-map "\C-@" 'sun-mouse-once)) |
|---|
| 259 |
|
|---|
| 260 |
(defun emacstool-init () |
|---|
| 261 |
"Set up Emacstool window, if you know you are in an emacstool." |
|---|
| 262 |
|
|---|
| 263 |
(require 'sun-fns) |
|---|
| 264 |
(define-key ctl-x-map "\C-@" 'sun-mouse-handler) |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 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\\")))) |
|---|
| 275 |
|
|---|
| 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)) |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|