265 |
;; than the emulated TPU commands. Also, it works only in the forward |
;; than the emulated TPU commands. Also, it works only in the forward |
266 |
;; direction, regardless of the current TPU-edt direction. |
;; direction, regardless of the current TPU-edt direction. |
267 |
|
|
268 |
|
;;; Todo/Bugs: |
269 |
|
|
270 |
|
;; We shouldn't use vt100 ESC sequences since it is uselessly fighting |
271 |
|
;; against function-key-map. Better use real key names. |
272 |
|
|
273 |
;;; Code: |
;;; Code: |
274 |
|
|
275 |
|
;; we use picture-mode functions |
276 |
|
(require 'picture) |
277 |
|
|
278 |
(defgroup tpu nil |
(defgroup tpu nil |
279 |
"Emacs emulating TPU emulating EDT." |
"Emacs emulating TPU emulating EDT." |
280 |
:prefix "tpu-" |
:prefix "tpu-" |
324 |
;;; |
;;; |
325 |
;;; Global Keymaps |
;;; Global Keymaps |
326 |
;;; |
;;; |
327 |
(defvar CSI-map (make-sparse-keymap) |
(defvar CSI-map |
328 |
|
(let ((map (make-sparse-keymap))) |
329 |
|
(define-key map "A" 'tpu-previous-line) ; up |
330 |
|
(define-key map "B" 'tpu-next-line) ; down |
331 |
|
(define-key map "D" 'tpu-backward-char) ; left |
332 |
|
(define-key map "C" 'tpu-forward-char) ; right |
333 |
|
|
334 |
|
(define-key map "1~" 'tpu-search) ; Find |
335 |
|
(define-key map "2~" 'tpu-paste) ; Insert Here |
336 |
|
(define-key map "3~" 'tpu-cut) ; Remove |
337 |
|
(define-key map "4~" 'tpu-select) ; Select |
338 |
|
(define-key map "5~" 'tpu-scroll-window-down) ; Prev Screen |
339 |
|
(define-key map "6~" 'tpu-scroll-window-up) ; Next Screen |
340 |
|
|
341 |
|
(define-key map "11~" 'nil) ; F1 |
342 |
|
(define-key map "12~" 'nil) ; F2 |
343 |
|
(define-key map "13~" 'nil) ; F3 |
344 |
|
(define-key map "14~" 'nil) ; F4 |
345 |
|
(define-key map "15~" 'nil) ; F5 |
346 |
|
(define-key map "17~" 'nil) ; F6 |
347 |
|
(define-key map "18~" 'nil) ; F7 |
348 |
|
(define-key map "19~" 'nil) ; F8 |
349 |
|
(define-key map "20~" 'nil) ; F9 |
350 |
|
(define-key map "21~" 'tpu-exit) ; F10 |
351 |
|
(define-key map "23~" 'tpu-insert-escape) ; F11 (ESC) |
352 |
|
(define-key map "24~" 'tpu-next-beginning-of-line) ; F12 (BS) |
353 |
|
(define-key map "25~" 'tpu-delete-previous-word) ; F13 (LF) |
354 |
|
(define-key map "26~" 'tpu-toggle-overwrite-mode) ; F14 |
355 |
|
(define-key map "28~" 'tpu-help) ; HELP |
356 |
|
(define-key map "29~" 'execute-extended-command) ; DO |
357 |
|
(define-key map "31~" 'tpu-goto-breadcrumb) ; F17 |
358 |
|
(define-key map "32~" 'nil) ; F18 |
359 |
|
(define-key map "33~" 'nil) ; F19 |
360 |
|
(define-key map "34~" 'nil) ; F20 |
361 |
|
map) |
362 |
"Maps the CSI function keys on the VT100 keyboard. |
"Maps the CSI function keys on the VT100 keyboard. |
363 |
CSI is DEC's name for the sequence <ESC>[.") |
CSI is DEC's name for the sequence <ESC>[.") |
364 |
|
|
365 |
(defvar SS3-map (make-sparse-keymap) |
(defvar GOLD-CSI-map |
366 |
"Maps the SS3 function keys on the VT100 keyboard. |
(let ((map (make-sparse-keymap))) |
367 |
SS3 is DEC's name for the sequence <ESC>O.") |
(define-key map "A" 'tpu-move-to-beginning) ; up-arrow |
368 |
|
(define-key map "B" 'tpu-move-to-end) ; down-arrow |
369 |
|
(define-key map "C" 'end-of-line) ; right-arrow |
370 |
|
(define-key map "D" 'beginning-of-line) ; left-arrow |
371 |
|
|
372 |
|
(define-key map "1~" 'nil) ; Find |
373 |
|
(define-key map "2~" 'nil) ; Insert Here |
374 |
|
(define-key map "3~" 'tpu-store-text) ; Remove |
375 |
|
(define-key map "4~" 'tpu-unselect) ; Select |
376 |
|
(define-key map "5~" 'tpu-previous-window) ; Prev Screen |
377 |
|
(define-key map "6~" 'tpu-next-window) ; Next Screen |
378 |
|
|
379 |
|
(define-key map "11~" 'nil) ; F1 |
380 |
|
(define-key map "12~" 'nil) ; F2 |
381 |
|
(define-key map "13~" 'nil) ; F3 |
382 |
|
(define-key map "14~" 'nil) ; F4 |
383 |
|
(define-key map "16~" 'nil) ; F5 |
384 |
|
(define-key map "17~" 'nil) ; F6 |
385 |
|
(define-key map "18~" 'nil) ; F7 |
386 |
|
(define-key map "19~" 'nil) ; F8 |
387 |
|
(define-key map "20~" 'nil) ; F9 |
388 |
|
(define-key map "21~" 'nil) ; F10 |
389 |
|
(define-key map "23~" 'nil) ; F11 |
390 |
|
(define-key map "24~" 'nil) ; F12 |
391 |
|
(define-key map "25~" 'nil) ; F13 |
392 |
|
(define-key map "26~" 'nil) ; F14 |
393 |
|
(define-key map "28~" 'describe-bindings) ; HELP |
394 |
|
(define-key map "29~" 'nil) ; DO |
395 |
|
(define-key map "31~" 'tpu-drop-breadcrumb) ; F17 |
396 |
|
(define-key map "32~" 'nil) ; F18 |
397 |
|
(define-key map "33~" 'nil) ; F19 |
398 |
|
(define-key map "34~" 'nil) ; F20 |
399 |
|
map) |
400 |
|
"Maps the function keys on the VT100 keyboard preceded by GOLD-CSI.") |
401 |
|
|
402 |
|
(defvar GOLD-SS3-map |
403 |
|
(let ((map (make-sparse-keymap))) |
404 |
|
(define-key map "A" 'tpu-move-to-beginning) ; up-arrow |
405 |
|
(define-key map "B" 'tpu-move-to-end) ; down-arrow |
406 |
|
(define-key map "C" 'end-of-line) ; right-arrow |
407 |
|
(define-key map "D" 'beginning-of-line) ; left-arrow |
408 |
|
|
409 |
|
(define-key map "P" 'keyboard-quit) ; PF1 |
410 |
|
(define-key map "Q" 'help-for-help) ; PF2 |
411 |
|
(define-key map "R" 'tpu-search) ; PF3 |
412 |
|
(define-key map "S" 'tpu-undelete-lines) ; PF4 |
413 |
|
(define-key map "p" 'open-line) ; KP0 |
414 |
|
(define-key map "q" 'tpu-change-case) ; KP1 |
415 |
|
(define-key map "r" 'tpu-delete-to-eol) ; KP2 |
416 |
|
(define-key map "s" 'tpu-special-insert) ; KP3 |
417 |
|
(define-key map "t" 'tpu-move-to-end) ; KP4 |
418 |
|
(define-key map "u" 'tpu-move-to-beginning) ; KP5 |
419 |
|
(define-key map "v" 'tpu-paste) ; KP6 |
420 |
|
(define-key map "w" 'execute-extended-command) ; KP7 |
421 |
|
(define-key map "x" 'tpu-fill) ; KP8 |
422 |
|
(define-key map "y" 'tpu-replace) ; KP9 |
423 |
|
(define-key map "m" 'tpu-undelete-words) ; KP- |
424 |
|
(define-key map "l" 'tpu-undelete-char) ; KP, |
425 |
|
(define-key map "n" 'tpu-unselect) ; KP. |
426 |
|
(define-key map "M" 'tpu-substitute) ; KPenter |
427 |
|
map) |
428 |
|
"Maps the function keys on the VT100 keyboard preceded by GOLD-SS3.") |
429 |
|
|
430 |
(defvar GOLD-map (make-keymap) |
(defvar GOLD-map |
431 |
|
(let ((map (make-keymap))) |
432 |
|
(define-key map "\e[" GOLD-CSI-map) ; GOLD-CSI map |
433 |
|
(define-key map "\eO" GOLD-SS3-map) ; GOLD-SS3 map |
434 |
|
;; |
435 |
|
(define-key map "\C-A" 'tpu-toggle-overwrite-mode) ; ^A |
436 |
|
(define-key map "\C-B" 'nil) ; ^B |
437 |
|
(define-key map "\C-C" 'nil) ; ^C |
438 |
|
(define-key map "\C-D" 'nil) ; ^D |
439 |
|
(define-key map "\C-E" 'nil) ; ^E |
440 |
|
(define-key map "\C-F" 'set-visited-file-name) ; ^F |
441 |
|
(define-key map "\C-g" 'keyboard-quit) ; safety first |
442 |
|
(define-key map "\C-h" 'delete-other-windows) ; BS |
443 |
|
(define-key map "\C-i" 'other-window) ; TAB |
444 |
|
(define-key map "\C-J" 'nil) ; ^J |
445 |
|
(define-key map "\C-K" 'tpu-define-macro-key) ; ^K |
446 |
|
(define-key map "\C-l" 'downcase-region) ; ^L |
447 |
|
(define-key map "\C-M" 'nil) ; ^M |
448 |
|
(define-key map "\C-N" 'nil) ; ^N |
449 |
|
(define-key map "\C-O" 'nil) ; ^O |
450 |
|
(define-key map "\C-P" 'nil) ; ^P |
451 |
|
(define-key map "\C-Q" 'nil) ; ^Q |
452 |
|
(define-key map "\C-R" 'nil) ; ^R |
453 |
|
(define-key map "\C-S" 'nil) ; ^S |
454 |
|
(define-key map "\C-T" 'tpu-toggle-control-keys) ; ^T |
455 |
|
(define-key map "\C-u" 'upcase-region) ; ^U |
456 |
|
(define-key map "\C-V" 'nil) ; ^V |
457 |
|
(define-key map "\C-w" 'tpu-write-current-buffers) ; ^W |
458 |
|
(define-key map "\C-X" 'nil) ; ^X |
459 |
|
(define-key map "\C-Y" 'nil) ; ^Y |
460 |
|
(define-key map "\C-Z" 'nil) ; ^Z |
461 |
|
(define-key map " " 'undo) ; SPC |
462 |
|
(define-key map "!" 'nil) ; ! |
463 |
|
(define-key map "#" 'nil) ; # |
464 |
|
(define-key map "$" 'tpu-add-at-eol) ; $ |
465 |
|
(define-key map "%" 'tpu-goto-percent) ; % |
466 |
|
(define-key map "&" 'nil) ; & |
467 |
|
(define-key map "(" 'nil) ; ( |
468 |
|
(define-key map ")" 'nil) ; ) |
469 |
|
(define-key map "*" 'tpu-toggle-regexp) ; * |
470 |
|
(define-key map "+" 'nil) ; + |
471 |
|
(define-key map "," 'tpu-goto-breadcrumb) ; , |
472 |
|
(define-key map "-" 'negative-argument) ; - |
473 |
|
(define-key map "." 'tpu-drop-breadcrumb) ; . |
474 |
|
(define-key map "/" 'tpu-emacs-replace) ; / |
475 |
|
(define-key map "0" 'digit-argument) ; 0 |
476 |
|
(define-key map "1" 'digit-argument) ; 1 |
477 |
|
(define-key map "2" 'digit-argument) ; 2 |
478 |
|
(define-key map "3" 'digit-argument) ; 3 |
479 |
|
(define-key map "4" 'digit-argument) ; 4 |
480 |
|
(define-key map "5" 'digit-argument) ; 5 |
481 |
|
(define-key map "6" 'digit-argument) ; 6 |
482 |
|
(define-key map "7" 'digit-argument) ; 7 |
483 |
|
(define-key map "8" 'digit-argument) ; 8 |
484 |
|
(define-key map "9" 'digit-argument) ; 9 |
485 |
|
(define-key map ":" 'nil) ; : |
486 |
|
(define-key map ";" 'tpu-trim-line-ends) ; ; |
487 |
|
(define-key map "<" 'nil) ; < |
488 |
|
(define-key map "=" 'nil) ; = |
489 |
|
(define-key map ">" 'nil) ; > |
490 |
|
(define-key map "?" 'tpu-spell-check) ; ? |
491 |
|
(define-key map "A" 'tpu-toggle-newline-and-indent) ; A |
492 |
|
(define-key map "B" 'tpu-next-buffer) ; B |
493 |
|
(define-key map "C" 'repeat-complex-command) ; C |
494 |
|
(define-key map "D" 'shell-command) ; D |
495 |
|
(define-key map "E" 'tpu-exit) ; E |
496 |
|
(define-key map "F" 'tpu-set-cursor-free) ; F |
497 |
|
(define-key map "G" 'tpu-get) ; G |
498 |
|
(define-key map "H" 'nil) ; H |
499 |
|
(define-key map "I" 'tpu-include) ; I |
500 |
|
(define-key map "K" 'tpu-kill-buffer) ; K |
501 |
|
(define-key map "L" 'tpu-what-line) ; L |
502 |
|
(define-key map "M" 'buffer-menu) ; M |
503 |
|
(define-key map "N" 'tpu-next-file-buffer) ; N |
504 |
|
(define-key map "O" 'occur) ; O |
505 |
|
(define-key map "P" 'lpr-buffer) ; P |
506 |
|
(define-key map "Q" 'tpu-quit) ; Q |
507 |
|
(define-key map "R" 'tpu-toggle-rectangle) ; R |
508 |
|
(define-key map "S" 'replace) ; S |
509 |
|
(define-key map "T" 'tpu-line-to-top-of-window) ; T |
510 |
|
(define-key map "U" 'undo) ; U |
511 |
|
(define-key map "V" 'tpu-version) ; V |
512 |
|
(define-key map "W" 'save-buffer) ; W |
513 |
|
(define-key map "X" 'tpu-save-all-buffers-kill-emacs) ; X |
514 |
|
(define-key map "Y" 'copy-region-as-kill) ; Y |
515 |
|
(define-key map "Z" 'suspend-emacs) ; Z |
516 |
|
(define-key map "[" 'blink-matching-open) ; [ |
517 |
|
(define-key map "\\" 'nil) ; \ |
518 |
|
(define-key map "]" 'blink-matching-open) ; ] |
519 |
|
(define-key map "^" 'tpu-add-at-bol) ; ^ |
520 |
|
(define-key map "_" 'split-window-vertically) ; - |
521 |
|
(define-key map "`" 'what-line) ; ` |
522 |
|
(define-key map "a" 'tpu-toggle-newline-and-indent) ; a |
523 |
|
(define-key map "b" 'tpu-next-buffer) ; b |
524 |
|
(define-key map "c" 'repeat-complex-command) ; c |
525 |
|
(define-key map "d" 'shell-command) ; d |
526 |
|
(define-key map "e" 'tpu-exit) ; e |
527 |
|
(define-key map "f" 'tpu-set-cursor-free) ; f |
528 |
|
(define-key map "g" 'tpu-get) ; g |
529 |
|
(define-key map "h" 'nil) ; h |
530 |
|
(define-key map "i" 'tpu-include) ; i |
531 |
|
(define-key map "k" 'tpu-kill-buffer) ; k |
532 |
|
(define-key map "l" 'goto-line) ; l |
533 |
|
(define-key map "m" 'buffer-menu) ; m |
534 |
|
(define-key map "n" 'tpu-next-file-buffer) ; n |
535 |
|
(define-key map "o" 'occur) ; o |
536 |
|
(define-key map "p" 'lpr-region) ; p |
537 |
|
(define-key map "q" 'tpu-quit) ; q |
538 |
|
(define-key map "r" 'tpu-toggle-rectangle) ; r |
539 |
|
(define-key map "s" 'replace) ; s |
540 |
|
(define-key map "t" 'tpu-line-to-top-of-window) ; t |
541 |
|
(define-key map "u" 'undo) ; u |
542 |
|
(define-key map "v" 'tpu-version) ; v |
543 |
|
(define-key map "w" 'save-buffer) ; w |
544 |
|
(define-key map "x" 'tpu-save-all-buffers-kill-emacs) ; x |
545 |
|
(define-key map "y" 'copy-region-as-kill) ; y |
546 |
|
(define-key map "z" 'suspend-emacs) ; z |
547 |
|
(define-key map "{" 'nil) ; { |
548 |
|
(define-key map "|" 'split-window-horizontally) ; | |
549 |
|
(define-key map "}" 'nil) ; } |
550 |
|
(define-key map "~" 'exchange-point-and-mark) ; ~ |
551 |
|
(define-key map "\177" 'delete-window) ; <X] |
552 |
|
map) |
553 |
"Maps the function keys on the VT100 keyboard preceded by PF1. |
"Maps the function keys on the VT100 keyboard preceded by PF1. |
554 |
GOLD is the ASCII 7-bit escape sequence <ESC>OP.") |
GOLD is the ASCII 7-bit escape sequence <ESC>OP.") |
555 |
|
|
556 |
(defvar GOLD-CSI-map (make-sparse-keymap) |
(defvar SS3-map |
557 |
"Maps the function keys on the VT100 keyboard preceded by GOLD-CSI.") |
(let ((map (make-sparse-keymap))) |
558 |
|
(define-key map "P" GOLD-map) ; GOLD map |
559 |
(defvar GOLD-SS3-map (make-sparse-keymap) |
;; |
560 |
"Maps the function keys on the VT100 keyboard preceded by GOLD-SS3.") |
(define-key map "A" 'tpu-previous-line) ; up |
561 |
|
(define-key map "B" 'tpu-next-line) ; down |
562 |
|
(define-key map "C" 'tpu-forward-char) ; right |
563 |
|
(define-key map "D" 'tpu-backward-char) ; left |
564 |
|
|
565 |
|
(define-key map "Q" 'tpu-help) ; PF2 |
566 |
|
(define-key map "R" 'tpu-search-again) ; PF3 |
567 |
|
(define-key map "S" 'tpu-delete-current-line) ; PF4 |
568 |
|
(define-key map "p" 'tpu-line) ; KP0 |
569 |
|
(define-key map "q" 'tpu-word) ; KP1 |
570 |
|
(define-key map "r" 'tpu-end-of-line) ; KP2 |
571 |
|
(define-key map "s" 'tpu-char) ; KP3 |
572 |
|
(define-key map "t" 'tpu-advance-direction) ; KP4 |
573 |
|
(define-key map "u" 'tpu-backup-direction) ; KP5 |
574 |
|
(define-key map "v" 'tpu-cut) ; KP6 |
575 |
|
(define-key map "w" 'tpu-page) ; KP7 |
576 |
|
(define-key map "x" 'tpu-scroll-window) ; KP8 |
577 |
|
(define-key map "y" 'tpu-append-region) ; KP9 |
578 |
|
(define-key map "m" 'tpu-delete-current-word) ; KP- |
579 |
|
(define-key map "l" 'tpu-delete-current-char) ; KP, |
580 |
|
(define-key map "n" 'tpu-select) ; KP. |
581 |
|
(define-key map "M" 'newline) ; KPenter |
582 |
|
map) |
583 |
|
"Maps the SS3 function keys on the VT100 keyboard. |
584 |
|
SS3 is DEC's name for the sequence <ESC>O.") |
585 |
|
|
586 |
(defvar tpu-global-map nil "TPU-edt global keymap.") |
(defvar tpu-global-map nil "TPU-edt global keymap.") |
587 |
(defvar tpu-original-global-map global-map |
(defvar tpu-original-global-map global-map |
588 |
"Original global keymap.") |
"Original non-TPU global keymap.") |
589 |
|
|
590 |
(and tpu-lucid-emacs-p |
(and (not (boundp 'minibuffer-local-ns-map)) |
591 |
(defvar minibuffer-local-ns-map (make-sparse-keymap) |
(defvar minibuffer-local-ns-map (make-sparse-keymap) |
592 |
"Hack to give Lucid Emacs the same maps as ordinary Emacs.")) |
"Hack to give Lucid Emacs the same maps as ordinary Emacs.")) |
593 |
|
|
595 |
;;; |
;;; |
596 |
;;; Global Variables |
;;; Global Variables |
597 |
;;; |
;;; |
|
(defvar tpu-edt-mode nil |
|
|
"If non-nil, TPU-edt mode is active.") |
|
|
|
|
598 |
(defvar tpu-last-replaced-text "" |
(defvar tpu-last-replaced-text "" |
599 |
"Last text deleted by a TPU-edt replace command.") |
"Last text deleted by a TPU-edt replace command.") |
600 |
(defvar tpu-last-deleted-region "" |
(defvar tpu-last-deleted-region "" |
679 |
|
|
680 |
(defun tpu-set-mode-line (for-tpu) |
(defun tpu-set-mode-line (for-tpu) |
681 |
"Set ``minor-mode-alist'' for TPU-edt, or reset it to default Emacs." |
"Set ``minor-mode-alist'' for TPU-edt, or reset it to default Emacs." |
682 |
(cond ((not for-tpu) |
(let ((entries '((tpu-newline-and-indent-p tpu-newline-and-indent-string) |
683 |
(setq minor-mode-alist tpu-original-mm-alist)) |
(tpu-rectangular-p tpu-rectangle-string) |
684 |
(t |
(tpu-direction-string tpu-direction-string) |
685 |
(or (assq 'tpu-newline-and-indent-p minor-mode-alist) |
(tpu-mark-flag tpu-mark-flag)))) |
686 |
(setq minor-mode-alist |
(dolist (entry entries) |
687 |
(cons '(tpu-newline-and-indent-p |
(if for-tpu |
688 |
tpu-newline-and-indent-string) |
(add-to-list 'minor-mode-alist entry) |
689 |
minor-mode-alist))) |
(setq minor-mode-alist (remove entry minor-mode-alist)))))) |
|
(or (assq 'tpu-rectangular-p minor-mode-alist) |
|
|
(setq minor-mode-alist |
|
|
(cons '(tpu-rectangular-p tpu-rectangle-string) |
|
|
minor-mode-alist))) |
|
|
(or (assq 'tpu-direction-string minor-mode-alist) |
|
|
(setq minor-mode-alist |
|
|
(cons '(tpu-direction-string tpu-direction-string) |
|
|
minor-mode-alist))) |
|
|
(or (assq 'tpu-mark-flag minor-mode-alist) |
|
|
(setq minor-mode-alist |
|
|
(cons '(tpu-mark-flag tpu-mark-flag) |
|
|
minor-mode-alist)))))) |
|
690 |
|
|
691 |
(defun tpu-update-mode-line nil |
(defun tpu-update-mode-line nil |
692 |
"Make sure mode-line in the current buffer reflects all changes." |
"Make sure mode-line in the current buffer reflects all changes." |
716 |
"Set markers at match beginning and end." |
"Set markers at match beginning and end." |
717 |
;; Add one to beginning mark so it stays with the first character of |
;; Add one to beginning mark so it stays with the first character of |
718 |
;; the string even if characters are added just before the string. |
;; the string even if characters are added just before the string. |
719 |
(setq tpu-match-beginning-mark (copy-marker (1+ (match-beginning 0)))) |
(setq tpu-match-beginning-mark (copy-marker (match-beginning 0) t)) |
720 |
(setq tpu-match-end-mark (copy-marker (match-end 0)))) |
(setq tpu-match-end-mark (copy-marker (match-end 0)))) |
721 |
|
|
722 |
(defun tpu-unset-match nil |
(defun tpu-unset-match nil |
726 |
|
|
727 |
(defun tpu-match-beginning nil |
(defun tpu-match-beginning nil |
728 |
"Returns the location of the last match beginning." |
"Returns the location of the last match beginning." |
729 |
(1- (marker-position tpu-match-beginning-mark))) |
(marker-position tpu-match-beginning-mark)) |
730 |
|
|
731 |
(defun tpu-match-end nil |
(defun tpu-match-end nil |
732 |
"Returns the location of the last match end." |
"Returns the location of the last match end." |
742 |
;; beginning, end, and point are equal. |
;; beginning, end, and point are equal. |
743 |
(cond ((and |
(cond ((and |
744 |
(equal (marker-buffer tpu-match-beginning-mark) (current-buffer)) |
(equal (marker-buffer tpu-match-beginning-mark) (current-buffer)) |
745 |
(>= (point) (1- (marker-position tpu-match-beginning-mark))) |
(>= (point) (marker-position tpu-match-beginning-mark)) |
746 |
(or |
(or |
747 |
(< (point) (marker-position tpu-match-end-mark)) |
(< (point) (marker-position tpu-match-end-mark)) |
748 |
(and (= (1- (marker-position tpu-match-beginning-mark)) |
(and (= (marker-position tpu-match-beginning-mark) |
749 |
(marker-position tpu-match-end-mark)) |
(marker-position tpu-match-end-mark)) |
750 |
(= (marker-position tpu-match-end-mark) (point))))) t) |
(= (marker-position tpu-match-end-mark) (point))))) t) |
751 |
(t |
(t |
755 |
"Show the values of the match markers." |
"Show the values of the match markers." |
756 |
(interactive) |
(interactive) |
757 |
(if (markerp tpu-match-beginning-mark) |
(if (markerp tpu-match-beginning-mark) |
758 |
(let ((beg (marker-position tpu-match-beginning-mark))) |
(message "(%s, %s) in %s -- current %s in %s" |
759 |
(message "(%s, %s) in %s -- current %s in %s" |
(marker-position tpu-match-beginning-mark) |
760 |
(if beg (1- beg) nil) |
(marker-position tpu-match-end-mark) |
761 |
(marker-position tpu-match-end-mark) |
(marker-buffer tpu-match-end-mark) |
762 |
(marker-buffer tpu-match-end-mark) |
(point) (current-buffer)))) |
|
(point) (current-buffer))))) |
|
763 |
|
|
764 |
|
|
765 |
;;; |
;;; |
782 |
Sets the mark at POS and activates the region according to the |
Sets the mark at POS and activates the region according to the |
783 |
current version of Emacs." |
current version of Emacs." |
784 |
(set-mark pos) |
(set-mark pos) |
785 |
(and tpu-lucid-emacs-p pos (zmacs-activate-region))) |
;; We use a separate `if' for the fboundp so the byte-compiler notices it |
786 |
|
;; and doesn't complain about the subsequent call. |
787 |
|
(if (fboundp 'zmacs-activate-region) (if pos (zmacs-activate-region)))) |
788 |
|
|
789 |
(defun tpu-string-prompt (prompt history-symbol) |
(defun tpu-string-prompt (prompt history-symbol) |
790 |
"Read a string with PROMPT." |
"Read a string with PROMPT." |
1010 |
;;; Command and Function Aliases |
;;; Command and Function Aliases |
1011 |
;;; |
;;; |
1012 |
;;;###autoload |
;;;###autoload |
1013 |
(defalias 'tpu-edt-mode 'tpu-edt-on) |
(define-minor-mode tpu-edt-mode |
1014 |
(defalias 'TPU-EDT-MODE 'tpu-edt-on) |
"TPU/edt emulation." |
1015 |
|
:global t |
1016 |
|
(if tpu-edt-mode (tpu-edt-on) (tpu-edt-off))) |
1017 |
|
|
1018 |
|
(defalias 'TPU-EDT-MODE 'tpu-edt-mode) |
1019 |
|
|
1020 |
;;;###autoload |
;;;###autoload |
1021 |
(defalias 'tpu-edt 'tpu-edt-on) |
(defalias 'tpu-edt 'tpu-edt-on) |
1403 |
(defun tpu-set-search (&optional arg) |
(defun tpu-set-search (&optional arg) |
1404 |
"Set the search functions and set the search direction to the current |
"Set the search functions and set the search direction to the current |
1405 |
direction. If an argument is specified, don't set the search direction." |
direction. If an argument is specified, don't set the search direction." |
1406 |
(if (not arg) (setq tpu-searching-forward (if tpu-advance t nil))) |
(if (not arg) (setq tpu-searching-forward tpu-advance)) |
1407 |
(cond (tpu-searching-forward |
(cond (tpu-searching-forward |
1408 |
(cond (tpu-regexp-p |
(cond (tpu-regexp-p |
1409 |
(fset 'tpu-emacs-search 're-search-forward) |
(fset 'tpu-emacs-search 're-search-forward) |
1456 |
"%sSearch failed: \"%s\"" |
"%sSearch failed: \"%s\"" |
1457 |
(if tpu-regexp-p "RE " "") tpu-search-last-string))))))))) |
(if tpu-regexp-p "RE " "") tpu-search-last-string))))))))) |
1458 |
|
|
1459 |
(fset 'tpu-search-internal-core (symbol-function 'tpu-search-internal)) |
(defalias 'tpu-search-internal-core (symbol-function 'tpu-search-internal)) |
1460 |
|
|
1461 |
(defun tpu-check-search-case (string) |
(defun tpu-check-search-case (string) |
1462 |
"Returns t if string contains upper case." |
"Returns t if string contains upper case." |
2244 |
|
|
2245 |
|
|
2246 |
;;; |
;;; |
|
;;; Define keymaps |
|
|
;;; |
|
|
(define-key SS3-map "P" GOLD-map) ; GOLD map |
|
|
(define-key GOLD-map "\e[" GOLD-CSI-map) ; GOLD-CSI map |
|
|
(define-key GOLD-map "\eO" GOLD-SS3-map) ; GOLD-SS3 map |
|
|
|
|
|
|
|
|
;;; |
|
|
;;; CSI-map key definitions |
|
|
;;; |
|
|
(define-key CSI-map "A" 'tpu-previous-line) ; up |
|
|
(define-key CSI-map "B" 'tpu-next-line) ; down |
|
|
(define-key CSI-map "D" 'tpu-backward-char) ; left |
|
|
(define-key CSI-map "C" 'tpu-forward-char) ; right |
|
|
|
|
|
(define-key CSI-map "1~" 'tpu-search) ; Find |
|
|
(define-key CSI-map "2~" 'tpu-paste) ; Insert Here |
|
|
(define-key CSI-map "3~" 'tpu-cut) ; Remove |
|
|
(define-key CSI-map "4~" 'tpu-select) ; Select |
|
|
(define-key CSI-map "5~" 'tpu-scroll-window-down) ; Prev Screen |
|
|
(define-key CSI-map "6~" 'tpu-scroll-window-up) ; Next Screen |
|
|
|
|
|
(define-key CSI-map "11~" 'nil) ; F1 |
|
|
(define-key CSI-map "12~" 'nil) ; F2 |
|
|
(define-key CSI-map "13~" 'nil) ; F3 |
|
|
(define-key CSI-map "14~" 'nil) ; F4 |
|
|
(define-key CSI-map "15~" 'nil) ; F5 |
|
|
(define-key CSI-map "17~" 'nil) ; F6 |
|
|
(define-key CSI-map "18~" 'nil) ; F7 |
|
|
(define-key CSI-map "19~" 'nil) ; F8 |
|
|
(define-key CSI-map "20~" 'nil) ; F9 |
|
|
(define-key CSI-map "21~" 'tpu-exit) ; F10 |
|
|
(define-key CSI-map "23~" 'tpu-insert-escape) ; F11 (ESC) |
|
|
(define-key CSI-map "24~" 'tpu-next-beginning-of-line) ; F12 (BS) |
|
|
(define-key CSI-map "25~" 'tpu-delete-previous-word) ; F13 (LF) |
|
|
(define-key CSI-map "26~" 'tpu-toggle-overwrite-mode) ; F14 |
|
|
(define-key CSI-map "28~" 'tpu-help) ; HELP |
|
|
(define-key CSI-map "29~" 'execute-extended-command) ; DO |
|
|
(define-key CSI-map "31~" 'tpu-goto-breadcrumb) ; F17 |
|
|
(define-key CSI-map "32~" 'nil) ; F18 |
|
|
(define-key CSI-map "33~" 'nil) ; F19 |
|
|
(define-key CSI-map "34~" 'nil) ; F20 |
|
|
|
|
|
|
|
|
;;; |
|
|
;;; SS3-map key definitions |
|
|
;;; |
|
|
(define-key SS3-map "A" 'tpu-previous-line) ; up |
|
|
(define-key SS3-map "B" 'tpu-next-line) ; down |
|
|
(define-key SS3-map "C" 'tpu-forward-char) ; right |
|
|
(define-key SS3-map "D" 'tpu-backward-char) ; left |
|
|
|
|
|
(define-key SS3-map "Q" 'tpu-help) ; PF2 |
|
|
(define-key SS3-map "R" 'tpu-search-again) ; PF3 |
|
|
(define-key SS3-map "S" 'tpu-delete-current-line) ; PF4 |
|
|
(define-key SS3-map "p" 'tpu-line) ; KP0 |
|
|
(define-key SS3-map "q" 'tpu-word) ; KP1 |
|
|
(define-key SS3-map "r" 'tpu-end-of-line) ; KP2 |
|
|
(define-key SS3-map "s" 'tpu-char) ; KP3 |
|
|
(define-key SS3-map "t" 'tpu-advance-direction) ; KP4 |
|
|
(define-key SS3-map "u" 'tpu-backup-direction) ; KP5 |
|
|
(define-key SS3-map "v" 'tpu-cut) ; KP6 |
|
|
(define-key SS3-map "w" 'tpu-page) ; KP7 |
|
|
(define-key SS3-map "x" 'tpu-scroll-window) ; KP8 |
|
|
(define-key SS3-map "y" 'tpu-append-region) ; KP9 |
|
|
(define-key SS3-map "m" 'tpu-delete-current-word) ; KP- |
|
|
(define-key SS3-map "l" 'tpu-delete-current-char) ; KP, |
|
|
(define-key SS3-map "n" 'tpu-select) ; KP. |
|
|
(define-key SS3-map "M" 'newline) ; KPenter |
|
|
|
|
|
|
|
|
;;; |
|
|
;;; GOLD-map key definitions |
|
|
;;; |
|
|
(define-key GOLD-map "\C-A" 'tpu-toggle-overwrite-mode) ; ^A |
|
|
(define-key GOLD-map "\C-B" 'nil) ; ^B |
|
|
(define-key GOLD-map "\C-C" 'nil) ; ^C |
|
|
(define-key GOLD-map "\C-D" 'nil) ; ^D |
|
|
(define-key GOLD-map "\C-E" 'nil) ; ^E |
|
|
(define-key GOLD-map "\C-F" 'set-visited-file-name) ; ^F |
|
|
(define-key GOLD-map "\C-g" 'keyboard-quit) ; safety first |
|
|
(define-key GOLD-map "\C-h" 'delete-other-windows) ; BS |
|
|
(define-key GOLD-map "\C-i" 'other-window) ; TAB |
|
|
(define-key GOLD-map "\C-J" 'nil) ; ^J |
|
|
(define-key GOLD-map "\C-K" 'tpu-define-macro-key) ; ^K |
|
|
(define-key GOLD-map "\C-l" 'downcase-region) ; ^L |
|
|
(define-key GOLD-map "\C-M" 'nil) ; ^M |
|
|
(define-key GOLD-map "\C-N" 'nil) ; ^N |
|
|
(define-key GOLD-map "\C-O" 'nil) ; ^O |
|
|
(define-key GOLD-map "\C-P" 'nil) ; ^P |
|
|
(define-key GOLD-map "\C-Q" 'nil) ; ^Q |
|
|
(define-key GOLD-map "\C-R" 'nil) ; ^R |
|
|
(define-key GOLD-map "\C-S" 'nil) ; ^S |
|
|
(define-key GOLD-map "\C-T" 'tpu-toggle-control-keys) ; ^T |
|
|
(define-key GOLD-map "\C-u" 'upcase-region) ; ^U |
|
|
(define-key GOLD-map "\C-V" 'nil) ; ^V |
|
|
(define-key GOLD-map "\C-w" 'tpu-write-current-buffers) ; ^W |
|
|
(define-key GOLD-map "\C-X" 'nil) ; ^X |
|
|
(define-key GOLD-map "\C-Y" 'nil) ; ^Y |
|
|
(define-key GOLD-map "\C-Z" 'nil) ; ^Z |
|
|
(define-key GOLD-map " " 'undo) ; SPC |
|
|
(define-key GOLD-map "!" 'nil) ; ! |
|
|
(define-key GOLD-map "#" 'nil) ; # |
|
|
(define-key GOLD-map "$" 'tpu-add-at-eol) ; $ |
|
|
(define-key GOLD-map "%" 'tpu-goto-percent) ; % |
|
|
(define-key GOLD-map "&" 'nil) ; & |
|
|
(define-key GOLD-map "(" 'nil) ; ( |
|
|
(define-key GOLD-map ")" 'nil) ; ) |
|
|
(define-key GOLD-map "*" 'tpu-toggle-regexp) ; * |
|
|
(define-key GOLD-map "+" 'nil) ; + |
|
|
(define-key GOLD-map "," 'tpu-goto-breadcrumb) ; , |
|
|
(define-key GOLD-map "-" 'negative-argument) ; - |
|
|
(define-key GOLD-map "." 'tpu-drop-breadcrumb) ; . |
|
|
(define-key GOLD-map "/" 'tpu-emacs-replace) ; / |
|
|
(define-key GOLD-map "0" 'digit-argument) ; 0 |
|
|
(define-key GOLD-map "1" 'digit-argument) ; 1 |
|
|
(define-key GOLD-map "2" 'digit-argument) ; 2 |
|
|
(define-key GOLD-map "3" 'digit-argument) ; 3 |
|
|
(define-key GOLD-map "4" 'digit-argument) ; 4 |
|
|
(define-key GOLD-map "5" 'digit-argument) ; 5 |
|
|
(define-key GOLD-map "6" 'digit-argument) ; 6 |
|
|
(define-key GOLD-map "7" 'digit-argument) ; 7 |
|
|
(define-key GOLD-map "8" 'digit-argument) ; 8 |
|
|
(define-key GOLD-map "9" 'digit-argument) ; 9 |
|
|
(define-key GOLD-map ":" 'nil) ; : |
|
|
(define-key GOLD-map ";" 'tpu-trim-line-ends) ; ; |
|
|
(define-key GOLD-map "<" 'nil) ; < |
|
|
(define-key GOLD-map "=" 'nil) ; = |
|
|
(define-key GOLD-map ">" 'nil) ; > |
|
|
(define-key GOLD-map "?" 'tpu-spell-check) ; ? |
|
|
(define-key GOLD-map "A" 'tpu-toggle-newline-and-indent) ; A |
|
|
(define-key GOLD-map "B" 'tpu-next-buffer) ; B |
|
|
(define-key GOLD-map "C" 'repeat-complex-command) ; C |
|
|
(define-key GOLD-map "D" 'shell-command) ; D |
|
|
(define-key GOLD-map "E" 'tpu-exit) ; E |
|
|
(define-key GOLD-map "F" 'tpu-set-cursor-free) ; F |
|
|
(define-key GOLD-map "G" 'tpu-get) ; G |
|
|
(define-key GOLD-map "H" 'nil) ; H |
|
|
(define-key GOLD-map "I" 'tpu-include) ; I |
|
|
(define-key GOLD-map "K" 'tpu-kill-buffer) ; K |
|
|
(define-key GOLD-map "L" 'tpu-what-line) ; L |
|
|
(define-key GOLD-map "M" 'buffer-menu) ; M |
|
|
(define-key GOLD-map "N" 'tpu-next-file-buffer) ; N |
|
|
(define-key GOLD-map "O" 'occur) ; O |
|
|
(define-key GOLD-map "P" 'lpr-buffer) ; P |
|
|
(define-key GOLD-map "Q" 'tpu-quit) ; Q |
|
|
(define-key GOLD-map "R" 'tpu-toggle-rectangle) ; R |
|
|
(define-key GOLD-map "S" 'replace) ; S |
|
|
(define-key GOLD-map "T" 'tpu-line-to-top-of-window) ; T |
|
|
(define-key GOLD-map "U" 'undo) ; U |
|
|
(define-key GOLD-map "V" 'tpu-version) ; V |
|
|
(define-key GOLD-map "W" 'save-buffer) ; W |
|
|
(define-key GOLD-map "X" 'tpu-save-all-buffers-kill-emacs) ; X |
|
|
(define-key GOLD-map "Y" 'copy-region-as-kill) ; Y |
|
|
(define-key GOLD-map "Z" 'suspend-emacs) ; Z |
|
|
(define-key GOLD-map "[" 'blink-matching-open) ; [ |
|
|
(define-key GOLD-map "\\" 'nil) ; \ |
|
|
(define-key GOLD-map "]" 'blink-matching-open) ; ] |
|
|
(define-key GOLD-map "^" 'tpu-add-at-bol) ; ^ |
|
|
(define-key GOLD-map "_" 'split-window-vertically) ; - |
|
|
(define-key GOLD-map "`" 'what-line) ; ` |
|
|
(define-key GOLD-map "a" 'tpu-toggle-newline-and-indent) ; a |
|
|
(define-key GOLD-map "b" 'tpu-next-buffer) ; b |
|
|
(define-key GOLD-map "c" 'repeat-complex-command) ; c |
|
|
(define-key GOLD-map "d" 'shell-command) ; d |
|
|
(define-key GOLD-map "e" 'tpu-exit) ; e |
|
|
(define-key GOLD-map "f" 'tpu-set-cursor-free) ; f |
|
|
(define-key GOLD-map "g" 'tpu-get) ; g |
|
|
(define-key GOLD-map "h" 'nil) ; h |
|
|
(define-key GOLD-map "i" 'tpu-include) ; i |
|
|
(define-key GOLD-map "k" 'tpu-kill-buffer) ; k |
|
|
(define-key GOLD-map "l" 'goto-line) ; l |
|
|
(define-key GOLD-map "m" 'buffer-menu) ; m |
|
|
(define-key GOLD-map "n" 'tpu-next-file-buffer) ; n |
|
|
(define-key GOLD-map "o" 'occur) ; o |
|
|
(define-key GOLD-map "p" 'lpr-region) ; p |
|
|
(define-key GOLD-map "q" 'tpu-quit) ; q |
|
|
(define-key GOLD-map "r" 'tpu-toggle-rectangle) ; r |
|
|
(define-key GOLD-map "s" 'replace) ; s |
|
|
(define-key GOLD-map "t" 'tpu-line-to-top-of-window) ; t |
|
|
(define-key GOLD-map "u" 'undo) ; u |
|
|
(define-key GOLD-map "v" 'tpu-version) ; v |
|
|
(define-key GOLD-map "w" 'save-buffer) ; w |
|
|
(define-key GOLD-map "x" 'tpu-save-all-buffers-kill-emacs) ; x |
|
|
(define-key GOLD-map "y" 'copy-region-as-kill) ; y |
|
|
(define-key GOLD-map "z" 'suspend-emacs) ; z |
|
|
(define-key GOLD-map "{" 'nil) ; { |
|
|
(define-key GOLD-map "|" 'split-window-horizontally) ; | |
|
|
(define-key GOLD-map "}" 'nil) ; } |
|
|
(define-key GOLD-map "~" 'exchange-point-and-mark) ; ~ |
|
|
(define-key GOLD-map "\177" 'delete-window) ; <X] |
|
|
|
|
|
|
|
|
;;; |
|
|
;;; GOLD-CSI-map key definitions |
|
|
;;; |
|
|
(define-key GOLD-CSI-map "A" 'tpu-move-to-beginning) ; up-arrow |
|
|
(define-key GOLD-CSI-map "B" 'tpu-move-to-end) ; down-arrow |
|
|
(define-key GOLD-CSI-map "C" 'end-of-line) ; right-arrow |
|
|
(define-key GOLD-CSI-map "D" 'beginning-of-line) ; left-arrow |
|
|
|
|
|
(define-key GOLD-CSI-map "1~" 'nil) ; Find |
|
|
(define-key GOLD-CSI-map "2~" 'nil) ; Insert Here |
|
|
(define-key GOLD-CSI-map "3~" 'tpu-store-text) ; Remove |
|
|
(define-key GOLD-CSI-map "4~" 'tpu-unselect) ; Select |
|
|
(define-key GOLD-CSI-map "5~" 'tpu-previous-window) ; Prev Screen |
|
|
(define-key GOLD-CSI-map "6~" 'tpu-next-window) ; Next Screen |
|
|
|
|
|
(define-key GOLD-CSI-map "11~" 'nil) ; F1 |
|
|
(define-key GOLD-CSI-map "12~" 'nil) ; F2 |
|
|
(define-key GOLD-CSI-map "13~" 'nil) ; F3 |
|
|
(define-key GOLD-CSI-map "14~" 'nil) ; F4 |
|
|
(define-key GOLD-CSI-map "16~" 'nil) ; F5 |
|
|
(define-key GOLD-CSI-map "17~" 'nil) ; F6 |
|
|
(define-key GOLD-CSI-map "18~" 'nil) ; F7 |
|
|
(define-key GOLD-CSI-map "19~" 'nil) ; F8 |
|
|
(define-key GOLD-CSI-map "20~" 'nil) ; F9 |
|
|
(define-key GOLD-CSI-map "21~" 'nil) ; F10 |
|
|
(define-key GOLD-CSI-map "23~" 'nil) ; F11 |
|
|
(define-key GOLD-CSI-map "24~" 'nil) ; F12 |
|
|
(define-key GOLD-CSI-map "25~" 'nil) ; F13 |
|
|
(define-key GOLD-CSI-map "26~" 'nil) ; F14 |
|
|
(define-key GOLD-CSI-map "28~" 'describe-bindings) ; HELP |
|
|
(define-key GOLD-CSI-map "29~" 'nil) ; DO |
|
|
(define-key GOLD-CSI-map "31~" 'tpu-drop-breadcrumb) ; F17 |
|
|
(define-key GOLD-CSI-map "32~" 'nil) ; F18 |
|
|
(define-key GOLD-CSI-map "33~" 'nil) ; F19 |
|
|
(define-key GOLD-CSI-map "34~" 'nil) ; F20 |
|
|
|
|
|
|
|
|
;;; |
|
|
;;; GOLD-SS3-map key definitions |
|
|
;;; |
|
|
(define-key GOLD-SS3-map "A" 'tpu-move-to-beginning) ; up-arrow |
|
|
(define-key GOLD-SS3-map "B" 'tpu-move-to-end) ; down-arrow |
|
|
(define-key GOLD-SS3-map "C" 'end-of-line) ; right-arrow |
|
|
(define-key GOLD-SS3-map "D" 'beginning-of-line) ; left-arrow |
|
|
|
|
|
(define-key GOLD-SS3-map "P" 'keyboard-quit) ; PF1 |
|
|
(define-key GOLD-SS3-map "Q" 'help-for-help) ; PF2 |
|
|
(define-key GOLD-SS3-map "R" 'tpu-search) ; PF3 |
|
|
(define-key GOLD-SS3-map "S" 'tpu-undelete-lines) ; PF4 |
|
|
(define-key GOLD-SS3-map "p" 'open-line) ; KP0 |
|
|
(define-key GOLD-SS3-map "q" 'tpu-change-case) ; KP1 |
|
|
(define-key GOLD-SS3-map "r" 'tpu-delete-to-eol) ; KP2 |
|
|
(define-key GOLD-SS3-map "s" 'tpu-special-insert) ; KP3 |
|
|
(define-key GOLD-SS3-map "t" 'tpu-move-to-end) ; KP4 |
|
|
(define-key GOLD-SS3-map "u" 'tpu-move-to-beginning) ; KP5 |
|
|
(define-key GOLD-SS3-map "v" 'tpu-paste) ; KP6 |
|
|
(define-key GOLD-SS3-map "w" 'execute-extended-command) ; KP7 |
|
|
(define-key GOLD-SS3-map "x" 'tpu-fill) ; KP8 |
|
|
(define-key GOLD-SS3-map "y" 'tpu-replace) ; KP9 |
|
|
(define-key GOLD-SS3-map "m" 'tpu-undelete-words) ; KP- |
|
|
(define-key GOLD-SS3-map "l" 'tpu-undelete-char) ; KP, |
|
|
(define-key GOLD-SS3-map "n" 'tpu-unselect) ; KP. |
|
|
(define-key GOLD-SS3-map "M" 'tpu-substitute) ; KPenter |
|
|
|
|
|
|
|
|
;;; |
|
2247 |
;;; Minibuffer map additions to make KP_enter = RET |
;;; Minibuffer map additions to make KP_enter = RET |
2248 |
;;; |
;;; |
2249 |
(define-key minibuffer-local-map "\eOM" 'exit-minibuffer) |
;; Standard Emacs settings under xterm in function-key-map map |
2250 |
(define-key minibuffer-local-ns-map "\eOM" 'exit-minibuffer) |
;; "\eOM" to [kp-enter] and [kp-enter] to RET, but since the output of the map |
2251 |
(define-key minibuffer-local-completion-map "\eOM" 'exit-minibuffer) |
;; is not fed back into the map, the key stays as kp-enter :-(. |
2252 |
(define-key minibuffer-local-must-match-map "\eOM" 'minibuffer-complete-and-exit) |
(define-key minibuffer-local-map [kp-enter] 'exit-minibuffer) |
2253 |
|
;; These are not necessary because they are inherited. |
2254 |
|
;; (define-key minibuffer-local-ns-map [kp-enter] 'exit-minibuffer) |
2255 |
|
;; (define-key minibuffer-local-completion-map [kp-enter] 'exit-minibuffer) |
2256 |
|
(define-key minibuffer-local-must-match-map [kp-enter] 'minibuffer-complete-and-exit) |
2257 |
|
|
2258 |
|
|
2259 |
;;; |
;;; |
2260 |
;;; Minibuffer map additions to set search direction |
;;; Minibuffer map additions to set search direction |
2261 |
;;; |
;;; |
2262 |
(define-key minibuffer-local-map "\eOt" 'tpu-search-forward-exit) |
(define-key minibuffer-local-map "\eOt" 'tpu-search-forward-exit) ;KP4 |
2263 |
(define-key minibuffer-local-map "\eOu" 'tpu-search-backward-exit) |
(define-key minibuffer-local-map "\eOu" 'tpu-search-backward-exit) ;KP5 |
2264 |
|
|
2265 |
|
|
2266 |
;;; |
;;; |
2290 |
(doit (or tpu emacs))) |
(doit (or tpu emacs))) |
2291 |
(cond (doit |
(cond (doit |
2292 |
(if emacs (setq tpu-global-map (copy-keymap global-map))) |
(if emacs (setq tpu-global-map (copy-keymap global-map))) |
2293 |
(let ((map (if tpu |
(let ((map (if tpu tpu-global-map tpu-original-global-map))) |
|
(copy-keymap tpu-global-map) |
|
|
(copy-keymap tpu-original-global-map)))) |
|
2294 |
|
|
2295 |
(define-key global-map "\C-\\" (lookup-key map "\C-\\")) ; ^\ |
(define-key global-map "\C-\\" (lookup-key map "\C-\\")) ; ^\ |
2296 |
(define-key global-map "\C-a" (lookup-key map "\C-a")) ; ^A |
(define-key global-map "\C-a" (lookup-key map "\C-a")) ; ^A |
2334 |
(defun tpu-arrow-history nil |
(defun tpu-arrow-history nil |
2335 |
"Modify minibuffer maps to use arrows for history recall." |
"Modify minibuffer maps to use arrows for history recall." |
2336 |
(interactive) |
(interactive) |
2337 |
(let ((loc (where-is-internal 'tpu-previous-line)) (cur nil)) |
(dolist (cur (where-is-internal 'tpu-previous-line)) |
2338 |
(while (setq cur (car loc)) |
(define-key read-expression-map cur 'tpu-previous-history-element) |
2339 |
(define-key read-expression-map cur 'tpu-previous-history-element) |
(define-key minibuffer-local-map cur 'tpu-previous-history-element) |
2340 |
(define-key minibuffer-local-map cur 'tpu-previous-history-element) |
;; These are inherited anyway. --Stef |
2341 |
(define-key minibuffer-local-ns-map cur 'tpu-previous-history-element) |
;; (define-key minibuffer-local-ns-map cur 'tpu-previous-history-element) |
2342 |
(define-key minibuffer-local-completion-map cur 'tpu-previous-history-element) |
;; (define-key minibuffer-local-completion-map cur 'tpu-previous-history-element) |
2343 |
(define-key minibuffer-local-must-match-map cur 'tpu-previous-history-element) |
;; (define-key minibuffer-local-must-match-map cur 'tpu-previous-history-element) |
2344 |
(setq loc (cdr loc))) |
) |
2345 |
|
|
2346 |
(setq loc (where-is-internal 'tpu-next-line)) |
(dolist (cur (where-is-internal 'tpu-next-line)) |
2347 |
(while (setq cur (car loc)) |
(define-key read-expression-map cur 'tpu-next-history-element) |
2348 |
(define-key read-expression-map cur 'tpu-next-history-element) |
(define-key minibuffer-local-map cur 'tpu-next-history-element) |
2349 |
(define-key minibuffer-local-map cur 'tpu-next-history-element) |
;; These are inherited anyway. --Stef |
2350 |
(define-key minibuffer-local-ns-map cur 'tpu-next-history-element) |
;; (define-key minibuffer-local-ns-map cur 'tpu-next-history-element) |
2351 |
(define-key minibuffer-local-completion-map cur 'tpu-next-history-element) |
;; (define-key minibuffer-local-completion-map cur 'tpu-next-history-element) |
2352 |
(define-key minibuffer-local-must-match-map cur 'tpu-next-history-element) |
;; (define-key minibuffer-local-must-match-map cur 'tpu-next-history-element) |
2353 |
(setq loc (cdr loc))))) |
)) |
2354 |
|
|
2355 |
|
|
2356 |
;;; |
;;; |
2443 |
;;; Start and Stop TPU-edt |
;;; Start and Stop TPU-edt |
2444 |
;;; |
;;; |
2445 |
;;;###autoload |
;;;###autoload |
2446 |
(defun tpu-edt-on nil |
(defun tpu-edt-on () |
2447 |
"Turn on TPU/edt emulation." |
"Turn on TPU/edt emulation." |
2448 |
(interactive) |
(interactive) |
2449 |
(cond |
(and window-system (tpu-load-xkeys nil)) |
2450 |
((not tpu-edt-mode) |
(tpu-arrow-history) |
2451 |
;; we use picture-mode functions |
(transient-mark-mode t) |
2452 |
(require 'picture) |
(add-hook 'post-command-hook 'tpu-search-highlight) |
2453 |
(tpu-set-control-keys) |
(tpu-set-mode-line t) |
2454 |
(and window-system (tpu-load-xkeys nil)) |
(tpu-advance-direction) |
2455 |
(tpu-arrow-history) |
;; set page delimiter, display line truncation, and scrolling like TPU |
2456 |
(transient-mark-mode t) |
(setq-default page-delimiter "\f") |
2457 |
(add-hook 'post-command-hook 'tpu-search-highlight) |
(setq-default truncate-lines t) |
2458 |
(tpu-set-mode-line t) |
(setq scroll-step 1) |
2459 |
(tpu-advance-direction) |
(setq global-map (copy-keymap global-map)) |
2460 |
;; set page delimiter, display line truncation, and scrolling like TPU |
(tpu-set-control-keys) |
2461 |
(setq-default page-delimiter "\f") |
(define-key global-map "\e[" CSI-map) |
2462 |
(setq-default truncate-lines t) |
(define-key global-map "\eO" SS3-map) |
2463 |
(setq scroll-step 1) |
(setq tpu-edt-mode t)) |
|
(setq tpu-original-global-map global-map) |
|
|
(setq global-map (copy-keymap global-map)) |
|
|
(define-key global-map "\e[" CSI-map) |
|
|
(define-key global-map "\eO" SS3-map) |
|
|
(setq tpu-edt-mode t)))) |
|
2464 |
|
|
2465 |
(defun tpu-edt-off nil |
(defun tpu-edt-off () |
2466 |
"Turn off TPU/edt emulation. Note that the keypad is left on." |
"Turn off TPU/edt emulation. Note that the keypad is left on." |
2467 |
(interactive) |
(interactive) |
2468 |
(cond |
(tpu-reset-control-keys nil) |
2469 |
(tpu-edt-mode |
(remove-hook 'post-command-hook 'tpu-search-highlight) |
2470 |
(tpu-reset-control-keys nil) |
(tpu-set-mode-line nil) |
2471 |
(remove-hook 'post-command-hook 'tpu-search-highlight) |
(setq-default page-delimiter "^\f") |
2472 |
(tpu-set-mode-line nil) |
(setq-default truncate-lines nil) |
2473 |
(setq-default page-delimiter "^\f") |
(setq scroll-step 0) |
2474 |
(setq-default truncate-lines nil) |
(setq global-map tpu-original-global-map) |
2475 |
(setq scroll-step 0) |
(use-global-map global-map) |
2476 |
(setq global-map tpu-original-global-map) |
(setq tpu-edt-mode nil)) |
|
(use-global-map global-map) |
|
|
(setq tpu-edt-mode nil)))) |
|
2477 |
|
|
2478 |
(provide 'tpu-edt) |
(provide 'tpu-edt) |
2479 |
|
|
2480 |
;;; arch-tag: f3dfe61c-2cbd-4f73-b9cc-eb215020b857 |
;; arch-tag: f3dfe61c-2cbd-4f73-b9cc-eb215020b857 |
2481 |
;;; tpu-edt.el ends here |
;;; tpu-edt.el ends here |