Mercurial > emacs
comparison lisp/emulation/edt.el @ 91085:880960b70474
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 11 Nov 2007 00:56:44 +0000 |
parents | 4b09bb044f38 2ca0af23d79d |
children | 53108e6cea98 |
comparison
equal
deleted
inserted
replaced
91084:a4347a111894 | 91085:880960b70474 |
---|---|
319 ;;; | 319 ;;; |
320 ;;; Emacs version identifiers - currently referenced by | 320 ;;; Emacs version identifiers - currently referenced by |
321 ;;; | 321 ;;; |
322 ;;; o edt-emulation-on o edt-load-keys | 322 ;;; o edt-emulation-on o edt-load-keys |
323 ;;; | 323 ;;; |
324 (defconst edt-emacs19-p (not (string-lessp emacs-version "19")) | 324 (defconst edt-emacs-variant (if (featurep 'emacs) "gnu" "xemacs") |
325 "Non-nil if we are running GNU Emacs or XEmacs version 19, or higher.") | |
326 | |
327 (defconst edt-x-emacs19-p | |
328 (and edt-emacs19-p (string-match "XEmacs" emacs-version)) | |
329 "Non-nil if we are running XEmacs version 19, or higher.") | |
330 | |
331 (defconst edt-gnu-emacs19-p (and edt-emacs19-p (not edt-x-emacs19-p)) | |
332 "Non-nil if we are running GNU Emacs version 19, or higher.") | |
333 | |
334 (defconst edt-emacs-variant (if edt-gnu-emacs19-p "gnu" "xemacs") | |
335 "Indicates Emacs variant: GNU Emacs or XEmacs \(aka Lucid Emacs\).") | 325 "Indicates Emacs variant: GNU Emacs or XEmacs \(aka Lucid Emacs\).") |
336 | 326 |
337 (defconst edt-window-system (if edt-gnu-emacs19-p window-system (console-type)) | 327 (defconst edt-window-system (if (featurep 'emacs) window-system (console-type)) |
338 "Indicates window system \(in GNU Emacs\) or console type \(in XEmacs\).") | 328 "Indicates window system \(in GNU Emacs\) or console type \(in XEmacs\).") |
339 | 329 |
340 (defconst edt-xserver (if (eq edt-window-system 'x) | 330 (defconst edt-xserver (if (eq edt-window-system 'x) |
341 (if edt-x-emacs19-p | 331 (if (featurep 'xemacs) |
342 ;; The Cygwin window manager has a `/' in its | 332 ;; The Cygwin window manager has a `/' in its |
343 ;; name, which breaks the generated file name of | 333 ;; name, which breaks the generated file name of |
344 ;; the custom key map file. Replace `/' with a | 334 ;; the custom key map file. Replace `/' with a |
345 ;; `-' to work around that. | 335 ;; `-' to work around that. |
346 (replace-in-string (x-server-vendor) "[ /]" "-") | 336 (replace-in-string (x-server-vendor) "[ /]" "-") |
407 (if (bobp) | 397 (if (bobp) |
408 (error "Beginning of buffer") | 398 (error "Beginning of buffer") |
409 (progn | 399 (progn |
410 (backward-page num) | 400 (backward-page num) |
411 (edt-line-to-top-of-window) | 401 (edt-line-to-top-of-window) |
412 (if edt-x-emacs19-p (setq zmacs-region-stays t))))) | 402 (if (featurep 'xemacs) (setq zmacs-region-stays t))))) |
413 | 403 |
414 (defun edt-page (num) | 404 (defun edt-page (num) |
415 "Move in current direction to next page delimiter. | 405 "Move in current direction to next page delimiter. |
416 Argument NUM is the number of page delimiters to move." | 406 Argument NUM is the number of page delimiters to move." |
417 (interactive "p") | 407 (interactive "p") |
468 (forward-line (* -1 num)) | 458 (forward-line (* -1 num)) |
469 (progn | 459 (progn |
470 (setq num (1- num)) | 460 (setq num (1- num)) |
471 (forward-line (* -1 num)))) | 461 (forward-line (* -1 num)))) |
472 (edt-top-check beg num)) | 462 (edt-top-check beg num)) |
473 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 463 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
474 | 464 |
475 | 465 |
476 ;;; | 466 ;;; |
477 ;;; EOL (End of Line) | 467 ;;; EOL (End of Line) |
478 ;;; | 468 ;;; |
484 (edt-check-prefix num) | 474 (edt-check-prefix num) |
485 (let ((beg (edt-current-line))) | 475 (let ((beg (edt-current-line))) |
486 (forward-char) | 476 (forward-char) |
487 (end-of-line num) | 477 (end-of-line num) |
488 (edt-bottom-check beg num)) | 478 (edt-bottom-check beg num)) |
489 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 479 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
490 | 480 |
491 | 481 |
492 (defun edt-end-of-line-backward (num) | 482 (defun edt-end-of-line-backward (num) |
493 "Move backward to next end of line mark. | 483 "Move backward to next end of line mark. |
494 Argument NUM is the number of EOL marks to move." | 484 Argument NUM is the number of EOL marks to move." |
495 (interactive "p") | 485 (interactive "p") |
496 (edt-check-prefix num) | 486 (edt-check-prefix num) |
497 (let ((beg (edt-current-line))) | 487 (let ((beg (edt-current-line))) |
498 (end-of-line (1- num)) | 488 (end-of-line (1- num)) |
499 (edt-top-check beg num)) | 489 (edt-top-check beg num)) |
500 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 490 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
501 | 491 |
502 | 492 |
503 (defun edt-end-of-line (num) | 493 (defun edt-end-of-line (num) |
504 "Move in current direction to next end of line mark. | 494 "Move in current direction to next end of line mark. |
505 Argument NUM is the number of EOL marks to move." | 495 Argument NUM is the number of EOL marks to move." |
540 (not (eolp)) | 530 (not (eolp)) |
541 (not (eobp)) | 531 (not (eobp)) |
542 (eq ?\ (char-syntax (following-char))) | 532 (eq ?\ (char-syntax (following-char))) |
543 (not (memq (following-char) edt-word-entities))) | 533 (not (memq (following-char) edt-word-entities))) |
544 (forward-char)))) | 534 (forward-char)))) |
545 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 535 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
546 | 536 |
547 (defun edt-one-word-backward () | 537 (defun edt-one-word-backward () |
548 "Move backward to first character of previous word." | 538 "Move backward to first character of previous word." |
549 (interactive) | 539 (interactive) |
550 (if (bobp) | 540 (if (bobp) |
564 (not (bolp)) | 554 (not (bolp)) |
565 (not (bobp)) | 555 (not (bobp)) |
566 (not (eq ?\ (char-syntax (preceding-char)))) | 556 (not (eq ?\ (char-syntax (preceding-char)))) |
567 (not (memq (preceding-char) edt-word-entities))) | 557 (not (memq (preceding-char) edt-word-entities))) |
568 (backward-char))))) | 558 (backward-char))))) |
569 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 559 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
570 | 560 |
571 (defun edt-word-forward (num) | 561 (defun edt-word-forward (num) |
572 "Move forward to first character of next word. | 562 "Move forward to first character of next word. |
573 Argument NUM is the number of words to move." | 563 Argument NUM is the number of words to move." |
574 (interactive "p") | 564 (interactive "p") |
604 (interactive "p") | 594 (interactive "p") |
605 (edt-check-prefix num) | 595 (edt-check-prefix num) |
606 (if (equal edt-direction-string edt-forward-string) | 596 (if (equal edt-direction-string edt-forward-string) |
607 (forward-char num) | 597 (forward-char num) |
608 (backward-char num)) | 598 (backward-char num)) |
609 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 599 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
610 | 600 |
611 ;;; | 601 ;;; |
612 ;;; LINE | 602 ;;; LINE |
613 ;;; | 603 ;;; |
614 ;;; When direction is set to BACKUP, LINE behaves just like BEGINNING | 604 ;;; When direction is set to BACKUP, LINE behaves just like BEGINNING |
627 (interactive "p") | 617 (interactive "p") |
628 (edt-check-prefix num) | 618 (edt-check-prefix num) |
629 (let ((beg (edt-current-line))) | 619 (let ((beg (edt-current-line))) |
630 (forward-line num) | 620 (forward-line num) |
631 (edt-bottom-check beg num)) | 621 (edt-bottom-check beg num)) |
632 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 622 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
633 | 623 |
634 (defun edt-line (num) | 624 (defun edt-line (num) |
635 "Move in current direction to next beginning of line mark. | 625 "Move in current direction to next beginning of line mark. |
636 Argument NUM is the number of BOL marks to move." | 626 Argument NUM is the number of BOL marks to move." |
637 (interactive "p") | 627 (interactive "p") |
649 (interactive "p") | 639 (interactive "p") |
650 (edt-check-prefix num) | 640 (edt-check-prefix num) |
651 (let ((beg (edt-current-line))) | 641 (let ((beg (edt-current-line))) |
652 (forward-line num) | 642 (forward-line num) |
653 (edt-bottom-check beg num)) | 643 (edt-bottom-check beg num)) |
654 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 644 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
655 | 645 |
656 (defun edt-previous-line (num) | 646 (defun edt-previous-line (num) |
657 "Move cursor up one line. | 647 "Move cursor up one line. |
658 Argument NUM is the number of lines to move." | 648 Argument NUM is the number of lines to move." |
659 (interactive "p") | 649 (interactive "p") |
660 (edt-check-prefix num) | 650 (edt-check-prefix num) |
661 (let ((beg (edt-current-line))) | 651 (let ((beg (edt-current-line))) |
662 (forward-line (- num)) | 652 (forward-line (- num)) |
663 (edt-top-check beg num)) | 653 (edt-top-check beg num)) |
664 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 654 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
665 | 655 |
666 | 656 |
667 ;;; | 657 ;;; |
668 ;;; TOP | 658 ;;; TOP |
669 ;;; | 659 ;;; |
670 | 660 |
671 (defun edt-top () | 661 (defun edt-top () |
672 "Move cursor to the beginning of buffer." | 662 "Move cursor to the beginning of buffer." |
673 (interactive) | 663 (interactive) |
674 (goto-char (point-min)) | 664 (goto-char (point-min)) |
675 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 665 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
676 | 666 |
677 ;;; | 667 ;;; |
678 ;;; BOTTOM | 668 ;;; BOTTOM |
679 ;;; | 669 ;;; |
680 | 670 |
716 (setq left (save-excursion (forward-line height))) | 706 (setq left (save-excursion (forward-line height))) |
717 (if (= 0 left) (recenter top-margin) | 707 (if (= 0 left) (recenter top-margin) |
718 (recenter (- left bottom-up-margin)))) | 708 (recenter (- left bottom-up-margin)))) |
719 (t | 709 (t |
720 (and (> (point) bottom) (recenter bottom-margin))))))) | 710 (and (> (point) bottom) (recenter bottom-margin))))))) |
721 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 711 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
722 | 712 |
723 (defun edt-find-backward (&optional find) | 713 (defun edt-find-backward (&optional find) |
724 "Find first occurrence of a string in the backward direction and save it. | 714 "Find first occurrence of a string in the backward direction and save it. |
725 Optional argument FIND is t if this function is called from `edt-find'." | 715 Optional argument FIND is t if this function is called from `edt-find'." |
726 (interactive) | 716 (interactive) |
741 (far (save-excursion | 731 (far (save-excursion |
742 (goto-char bottom) (forward-line (- height 2)) (point)))) | 732 (goto-char bottom) (forward-line (- height 2)) (point)))) |
743 (if (search-backward edt-find-last-text) | 733 (if (search-backward edt-find-last-text) |
744 (edt-set-match)) | 734 (edt-set-match)) |
745 (and (< (point) top) (recenter (min beg top-margin)))) | 735 (and (< (point) top) (recenter (min beg top-margin)))) |
746 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 736 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
747 | 737 |
748 (defun edt-find () | 738 (defun edt-find () |
749 "Find first occurrence of string in current direction and save it." | 739 "Find first occurrence of string in current direction and save it." |
750 (interactive) | 740 (interactive) |
751 (set 'edt-find-last-text (read-string "Search: ")) | 741 (set 'edt-find-last-text (read-string "Search: ")) |
787 (t | 777 (t |
788 (and (> (point) bottom) (recenter bottom-margin))))) | 778 (and (> (point) bottom) (recenter bottom-margin))))) |
789 (progn | 779 (progn |
790 (backward-char 1) | 780 (backward-char 1) |
791 (error "Search failed: \"%s\"" edt-find-last-text)))) | 781 (error "Search failed: \"%s\"" edt-find-last-text)))) |
792 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 782 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
793 | 783 |
794 (defun edt-find-next-backward () | 784 (defun edt-find-next-backward () |
795 "Find next occurrence of a string in backward direction." | 785 "Find next occurrence of a string in backward direction." |
796 (interactive) | 786 (interactive) |
797 (let* ((left nil) | 787 (let* ((left nil) |
811 (if (not (search-backward edt-find-last-text nil t)) | 801 (if (not (search-backward edt-find-last-text nil t)) |
812 (error "Search failed: \"%s\"" edt-find-last-text) | 802 (error "Search failed: \"%s\"" edt-find-last-text) |
813 (progn | 803 (progn |
814 (edt-set-match) | 804 (edt-set-match) |
815 (and (< (point) top) (recenter (min beg top-margin)))))) | 805 (and (< (point) top) (recenter (min beg top-margin)))))) |
816 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 806 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
817 | 807 |
818 (defun edt-find-next () | 808 (defun edt-find-next () |
819 "Find next occurrence of a string in current direction." | 809 "Find next occurrence of a string in current direction." |
820 (interactive) | 810 (interactive) |
821 (if (equal edt-direction-string edt-forward-string) | 811 (if (equal edt-direction-string edt-forward-string) |
889 (set-mark-command nil)) | 879 (set-mark-command nil)) |
890 | 880 |
891 (defun edt-reset () | 881 (defun edt-reset () |
892 "Cancel text selection." | 882 "Cancel text selection." |
893 (interactive) | 883 (interactive) |
894 (if edt-gnu-emacs19-p | 884 (if (featurep 'emacs) |
895 (deactivate-mark) | 885 (deactivate-mark) |
896 (zmacs-deactivate-region))) | 886 (zmacs-deactivate-region))) |
897 | 887 |
898 ;;; | 888 ;;; |
899 ;;; CUT | 889 ;;; CUT |
1106 (setq edt-direction-string edt-forward-string) | 1096 (setq edt-direction-string edt-forward-string) |
1107 (force-mode-line-update) | 1097 (force-mode-line-update) |
1108 (if (string-equal " *Minibuf" | 1098 (if (string-equal " *Minibuf" |
1109 (substring (buffer-name) 0 (min (length (buffer-name)) 9))) | 1099 (substring (buffer-name) 0 (min (length (buffer-name)) 9))) |
1110 (exit-minibuffer)) | 1100 (exit-minibuffer)) |
1111 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1101 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1112 | 1102 |
1113 | 1103 |
1114 ;;; | 1104 ;;; |
1115 ;;; BACKUP | 1105 ;;; BACKUP |
1116 ;;; | 1106 ;;; |
1122 (setq edt-direction-string edt-backward-string) | 1112 (setq edt-direction-string edt-backward-string) |
1123 (force-mode-line-update) | 1113 (force-mode-line-update) |
1124 (if (string-equal " *Minibuf" | 1114 (if (string-equal " *Minibuf" |
1125 (substring (buffer-name) 0 (min (length (buffer-name)) 9))) | 1115 (substring (buffer-name) 0 (min (length (buffer-name)) 9))) |
1126 (exit-minibuffer)) | 1116 (exit-minibuffer)) |
1127 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1117 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1128 | 1118 |
1129 | 1119 |
1130 ;;; | 1120 ;;; |
1131 ;;; CHNGCASE | 1121 ;;; CHNGCASE |
1132 ;;; | 1122 ;;; |
1172 (defun edt-define-key () | 1162 (defun edt-define-key () |
1173 "Assign an interactively-callable function to a specified key sequence. | 1163 "Assign an interactively-callable function to a specified key sequence. |
1174 The current key definition is saved in `edt-last-replaced-key-definition'. | 1164 The current key definition is saved in `edt-last-replaced-key-definition'. |
1175 Use `edt-restore-key' to restore last replaced key definition." | 1165 Use `edt-restore-key' to restore last replaced key definition." |
1176 (interactive) | 1166 (interactive) |
1177 (if edt-x-emacs19-p (setq zmacs-region-stays t)) | 1167 (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
1178 (let (edt-function | 1168 (let (edt-function |
1179 edt-key-definition) | 1169 edt-key-definition) |
1180 (setq edt-key-definition | 1170 (setq edt-key-definition |
1181 (read-key-sequence "Press the key to be defined: ")) | 1171 (read-key-sequence "Press the key to be defined: ")) |
1182 (if (if edt-gnu-emacs19-p | 1172 (if (if (featurep 'emacs) |
1183 (string-equal "\C-m" edt-key-definition) | 1173 (string-equal "\C-m" edt-key-definition) |
1184 (string-equal "\C-m" (events-to-keys edt-key-definition))) | 1174 (string-equal "\C-m" (events-to-keys edt-key-definition))) |
1185 (message "Key not defined") | 1175 (message "Key not defined") |
1186 (progn | 1176 (progn |
1187 (setq edt-function (read-command "Enter command name: ")) | 1177 (setq edt-function (read-command "Enter command name: ")) |
1257 (let* ((height (window-height)) | 1247 (let* ((height (window-height)) |
1258 (margin (+ 1 (/ (* height edt-bottom-scroll-margin) 100))) | 1248 (margin (+ 1 (/ (* height edt-bottom-scroll-margin) 100))) |
1259 ;; subtract 1 from height because it includes mode line | 1249 ;; subtract 1 from height because it includes mode line |
1260 (difference (- height margin 1))) | 1250 (difference (- height margin 1))) |
1261 (cond ((> beg difference) (recenter beg)) | 1251 (cond ((> beg difference) (recenter beg)) |
1262 ((and edt-x-emacs19-p (> (+ beg lines 1) difference)) | 1252 ((and (featurep 'xemacs) (> (+ beg lines 1) difference)) |
1263 (recenter (- margin))) | 1253 (recenter (- margin))) |
1264 ((> (+ beg lines) difference) (recenter (- margin)))))) | 1254 ((> (+ beg lines) difference) (recenter (- margin)))))) |
1265 | 1255 |
1266 (defun edt-current-line nil | 1256 (defun edt-current-line nil |
1267 "Return the vertical position of point in the selected window. | 1257 "Return the vertical position of point in the selected window. |
1361 (setq left (save-excursion (forward-line height))) | 1351 (setq left (save-excursion (forward-line height))) |
1362 (if (= 0 left) (recenter top-margin) | 1352 (if (= 0 left) (recenter top-margin) |
1363 (recenter (- left bottom-up-margin)))) | 1353 (recenter (- left bottom-up-margin)))) |
1364 (t | 1354 (t |
1365 (and (> (point) bottom) (recenter bottom-margin))))) | 1355 (and (> (point) bottom) (recenter bottom-margin))))) |
1366 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1356 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1367 | 1357 |
1368 (defun edt-sentence-backward (num) | 1358 (defun edt-sentence-backward (num) |
1369 "Move backward to next sentence beginning. | 1359 "Move backward to next sentence beginning. |
1370 Argument NUM is the positive number of sentences to move." | 1360 Argument NUM is the positive number of sentences to move." |
1371 (interactive "p") | 1361 (interactive "p") |
1387 (if (eobp) | 1377 (if (eobp) |
1388 (progn | 1378 (progn |
1389 (error "End of buffer")) | 1379 (error "End of buffer")) |
1390 (backward-sentence num)) | 1380 (backward-sentence num)) |
1391 (and (< (point) top) (recenter (min beg top-margin)))) | 1381 (and (< (point) top) (recenter (min beg top-margin)))) |
1392 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1382 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1393 | 1383 |
1394 (defun edt-sentence (num) | 1384 (defun edt-sentence (num) |
1395 "Move in current direction to next sentence. | 1385 "Move in current direction to next sentence. |
1396 Argument NUM is the positive number of sentences to move." | 1386 Argument NUM is the positive number of sentences to move." |
1397 (interactive "p") | 1387 (interactive "p") |
1432 (setq left (save-excursion (forward-line height))) | 1422 (setq left (save-excursion (forward-line height))) |
1433 (if (= 0 left) (recenter top-margin) | 1423 (if (= 0 left) (recenter top-margin) |
1434 (recenter (- left bottom-up-margin)))) | 1424 (recenter (- left bottom-up-margin)))) |
1435 (t | 1425 (t |
1436 (and (> (point) bottom) (recenter bottom-margin))))) | 1426 (and (> (point) bottom) (recenter bottom-margin))))) |
1437 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1427 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1438 | 1428 |
1439 (defun edt-paragraph-backward (num) | 1429 (defun edt-paragraph-backward (num) |
1440 "Move backward to beginning of paragraph. | 1430 "Move backward to beginning of paragraph. |
1441 Argument NUM is the positive number of paragraphs to move." | 1431 Argument NUM is the positive number of paragraphs to move." |
1442 (interactive "p") | 1432 (interactive "p") |
1457 (goto-char bottom) (forward-line (- height 2)) (point)))) | 1447 (goto-char bottom) (forward-line (- height 2)) (point)))) |
1458 (while (> num 0) | 1448 (while (> num 0) |
1459 (start-of-paragraph-text) | 1449 (start-of-paragraph-text) |
1460 (setq num (1- num))) | 1450 (setq num (1- num))) |
1461 (and (< (point) top) (recenter (min beg top-margin)))) | 1451 (and (< (point) top) (recenter (min beg top-margin)))) |
1462 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1452 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1463 | 1453 |
1464 (defun edt-paragraph (num) | 1454 (defun edt-paragraph (num) |
1465 "Move in current direction to next paragraph. | 1455 "Move in current direction to next paragraph. |
1466 Argument NUM is the positive number of paragraphs to move." | 1456 Argument NUM is the positive number of paragraphs to move." |
1467 (interactive "p") | 1457 (interactive "p") |
1475 | 1465 |
1476 (defun edt-restore-key () | 1466 (defun edt-restore-key () |
1477 "Restore last replaced key definition. | 1467 "Restore last replaced key definition. |
1478 Definition is stored in `edt-last-replaced-key-definition'." | 1468 Definition is stored in `edt-last-replaced-key-definition'." |
1479 (interactive) | 1469 (interactive) |
1480 (if edt-x-emacs19-p (setq zmacs-region-stays t)) | 1470 (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
1481 (if edt-last-replaced-key-definition | 1471 (if edt-last-replaced-key-definition |
1482 (progn | 1472 (progn |
1483 (let (edt-key-definition) | 1473 (let (edt-key-definition) |
1484 (set 'edt-key-definition | 1474 (set 'edt-key-definition |
1485 (read-key-sequence "Press the key to be restored: ")) | 1475 (read-key-sequence "Press the key to be restored: ")) |
1486 (if (if edt-gnu-emacs19-p | 1476 (if (if (featurep 'emacs) |
1487 (string-equal "\C-m" edt-key-definition) | 1477 (string-equal "\C-m" edt-key-definition) |
1488 (string-equal "\C-m" (events-to-keys edt-key-definition))) | 1478 (string-equal "\C-m" (events-to-keys edt-key-definition))) |
1489 (message "Key not restored") | 1479 (message "Key not restored") |
1490 (progn | 1480 (progn |
1491 (define-key (current-global-map) | 1481 (define-key (current-global-map) |
1492 edt-key-definition edt-last-replaced-key-definition) | 1482 edt-key-definition edt-last-replaced-key-definition) |
1493 (if edt-gnu-emacs19-p | 1483 (if (featurep 'emacs) |
1494 (message "Key definition for %s has been restored." | 1484 (message "Key definition for %s has been restored." |
1495 edt-key-definition) | 1485 edt-key-definition) |
1496 (message "Key definition for %s has been restored." | 1486 (message "Key definition for %s has been restored." |
1497 (events-to-keys edt-key-definition))))))) | 1487 (events-to-keys edt-key-definition))))))) |
1498 (error "No replaced key definition to restore!"))) | 1488 (error "No replaced key definition to restore!"))) |
1505 "Move the cursor to the top of the window." | 1495 "Move the cursor to the top of the window." |
1506 (interactive) | 1496 (interactive) |
1507 (let ((start-column (current-column))) | 1497 (let ((start-column (current-column))) |
1508 (move-to-window-line 0) | 1498 (move-to-window-line 0) |
1509 (move-to-column start-column)) | 1499 (move-to-column start-column)) |
1510 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1500 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1511 | 1501 |
1512 ;;; | 1502 ;;; |
1513 ;;; WINDOW BOTTOM | 1503 ;;; WINDOW BOTTOM |
1514 ;;; | 1504 ;;; |
1515 | 1505 |
1517 "Move the cursor to the bottom of the window." | 1507 "Move the cursor to the bottom of the window." |
1518 (interactive) | 1508 (interactive) |
1519 (let ((start-column (current-column))) | 1509 (let ((start-column (current-column))) |
1520 (move-to-window-line (- (window-height) 2)) | 1510 (move-to-window-line (- (window-height) 2)) |
1521 (move-to-column start-column)) | 1511 (move-to-column start-column)) |
1522 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1512 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1523 | 1513 |
1524 ;;; | 1514 ;;; |
1525 ;;; SCROLL WINDOW LINE | 1515 ;;; SCROLL WINDOW LINE |
1526 ;;; | 1516 ;;; |
1527 | 1517 |
1528 (defun edt-scroll-window-forward-line () | 1518 (defun edt-scroll-window-forward-line () |
1529 "Move window forward one line leaving cursor at position in window." | 1519 "Move window forward one line leaving cursor at position in window." |
1530 (interactive) | 1520 (interactive) |
1531 (scroll-up 1) | 1521 (scroll-up 1) |
1532 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1522 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1533 | 1523 |
1534 (defun edt-scroll-window-backward-line () | 1524 (defun edt-scroll-window-backward-line () |
1535 "Move window backward one line leaving cursor at position in window." | 1525 "Move window backward one line leaving cursor at position in window." |
1536 (interactive) | 1526 (interactive) |
1537 (scroll-down 1) | 1527 (scroll-down 1) |
1538 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1528 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1539 | 1529 |
1540 (defun edt-scroll-line () | 1530 (defun edt-scroll-line () |
1541 "Move window one line in current direction." | 1531 "Move window one line in current direction." |
1542 (interactive) | 1532 (interactive) |
1543 (if (equal edt-direction-string edt-forward-string) | 1533 (if (equal edt-direction-string edt-forward-string) |
1580 | 1570 |
1581 (defun edt-line-to-bottom-of-window () | 1571 (defun edt-line-to-bottom-of-window () |
1582 "Move the current line to the bottom of the window." | 1572 "Move the current line to the bottom of the window." |
1583 (interactive) | 1573 (interactive) |
1584 (recenter -1) | 1574 (recenter -1) |
1585 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1575 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1586 | 1576 |
1587 ;;; | 1577 ;;; |
1588 ;;; LINE TO TOP OF WINDOW | 1578 ;;; LINE TO TOP OF WINDOW |
1589 ;;; | 1579 ;;; |
1590 | 1580 |
1591 (defun edt-line-to-top-of-window () | 1581 (defun edt-line-to-top-of-window () |
1592 "Move the current line to the top of the window." | 1582 "Move the current line to the top of the window." |
1593 (interactive) | 1583 (interactive) |
1594 (recenter 0) | 1584 (recenter 0) |
1595 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1585 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1596 | 1586 |
1597 ;;; | 1587 ;;; |
1598 ;;; LINE TO MIDDLE OF WINDOW | 1588 ;;; LINE TO MIDDLE OF WINDOW |
1599 ;;; | 1589 ;;; |
1600 | 1590 |
1601 (defun edt-line-to-middle-of-window () | 1591 (defun edt-line-to-middle-of-window () |
1602 "Move window so line with cursor is in the middle of the window." | 1592 "Move window so line with cursor is in the middle of the window." |
1603 (interactive) | 1593 (interactive) |
1604 (recenter '(4)) | 1594 (recenter '(4)) |
1605 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1595 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1606 | 1596 |
1607 ;;; | 1597 ;;; |
1608 ;;; GOTO PERCENTAGE | 1598 ;;; GOTO PERCENTAGE |
1609 ;;; | 1599 ;;; |
1610 | 1600 |
1613 Argument NUM is the percentage into the buffer to move." | 1603 Argument NUM is the percentage into the buffer to move." |
1614 (interactive "NGoto-percentage: ") | 1604 (interactive "NGoto-percentage: ") |
1615 (if (or (> num 100) (< num 0)) | 1605 (if (or (> num 100) (< num 0)) |
1616 (error "Percentage %d out of range 0 < percent < 100" num) | 1606 (error "Percentage %d out of range 0 < percent < 100" num) |
1617 (goto-char (/ (* (point-max) num) 100))) | 1607 (goto-char (/ (* (point-max) num) 100))) |
1618 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1608 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1619 | 1609 |
1620 ;;; | 1610 ;;; |
1621 ;;; FILL REGION | 1611 ;;; FILL REGION |
1622 ;;; | 1612 ;;; |
1623 | 1613 |
1783 ;;; | 1773 ;;; |
1784 | 1774 |
1785 (defun edt-display-the-time () | 1775 (defun edt-display-the-time () |
1786 "Display the current time." | 1776 "Display the current time." |
1787 (interactive) | 1777 (interactive) |
1788 (if edt-x-emacs19-p (setq zmacs-region-stays t)) | 1778 (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
1789 (message "%s" (current-time-string))) | 1779 (message "%s" (current-time-string))) |
1790 | 1780 |
1791 ;;; | 1781 ;;; |
1792 ;;; LEARN | 1782 ;;; LEARN |
1793 ;;; | 1783 ;;; |
1811 (progn | 1801 (progn |
1812 (end-kbd-macro nil) | 1802 (end-kbd-macro nil) |
1813 (let (edt-key-definition) | 1803 (let (edt-key-definition) |
1814 (set 'edt-key-definition | 1804 (set 'edt-key-definition |
1815 (read-key-sequence "Enter key for binding: ")) | 1805 (read-key-sequence "Enter key for binding: ")) |
1816 (if (if edt-gnu-emacs19-p | 1806 (if (if (featurep 'emacs) |
1817 (string-equal "\C-m" edt-key-definition) | 1807 (string-equal "\C-m" edt-key-definition) |
1818 (string-equal "\C-m" (events-to-keys edt-key-definition))) | 1808 (string-equal "\C-m" (events-to-keys edt-key-definition))) |
1819 (message "Key sequence not remembered") | 1809 (message "Key sequence not remembered") |
1820 (progn | 1810 (progn |
1821 (set 'edt-learn-macro-count (+ edt-learn-macro-count 1)) | 1811 (set 'edt-learn-macro-count (+ edt-learn-macro-count 1)) |
1864 (defun edt-split-window () | 1854 (defun edt-split-window () |
1865 "Split current window and place cursor in the new window." | 1855 "Split current window and place cursor in the new window." |
1866 (interactive) | 1856 (interactive) |
1867 (split-window) | 1857 (split-window) |
1868 (other-window 1) | 1858 (other-window 1) |
1869 (if edt-x-emacs19-p (setq zmacs-region-stays t))) | 1859 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
1870 | 1860 |
1871 ;;; | 1861 ;;; |
1872 ;;; COPY RECTANGLE | 1862 ;;; COPY RECTANGLE |
1873 ;;; | 1863 ;;; |
1874 | 1864 |
2150 (error "Unable to find EDT terminal specific file edt-pc.el") | 2140 (error "Unable to find EDT terminal specific file edt-pc.el") |
2151 (edt-load-keys nil)) | 2141 (edt-load-keys nil)) |
2152 (setq edt-term term)))) | 2142 (setq edt-term term)))) |
2153 (edt-load-keys nil)) | 2143 (edt-load-keys nil)) |
2154 ;; Make highlighting of selected text work properly for EDT commands. | 2144 ;; Make highlighting of selected text work properly for EDT commands. |
2155 (if edt-gnu-emacs19-p | 2145 (if (featurep 'emacs) |
2156 (progn | 2146 (progn |
2157 (setq edt-orig-transient-mark-mode transient-mark-mode) | 2147 (setq edt-orig-transient-mark-mode transient-mark-mode) |
2158 (add-hook 'activate-mark-hook | 2148 (add-hook 'activate-mark-hook |
2159 (function | 2149 (function |
2160 (lambda () | 2150 (lambda () |
2186 (setq page-delimiter edt-orig-page-delimiter)) | 2176 (setq page-delimiter edt-orig-page-delimiter)) |
2187 (setq edt-direction-string "") | 2177 (setq edt-direction-string "") |
2188 (setq edt-select-mode-current nil) | 2178 (setq edt-select-mode-current nil) |
2189 (edt-reset) | 2179 (edt-reset) |
2190 (force-mode-line-update t) | 2180 (force-mode-line-update t) |
2191 (if edt-gnu-emacs19-p | 2181 (if (featurep 'emacs) |
2192 (setq transient-mark-mode edt-orig-transient-mark-mode)) | 2182 (setq transient-mark-mode edt-orig-transient-mark-mode)) |
2193 (message "Original key bindings restored; EDT Emulation disabled")) | 2183 (message "Original key bindings restored; EDT Emulation disabled")) |
2194 | 2184 |
2195 (defun edt-default-emulation-setup (&optional user-setup) | 2185 (defun edt-default-emulation-setup (&optional user-setup) |
2196 "Setup emulation of DEC's EDT editor. | 2186 "Setup emulation of DEC's EDT editor. |
2201 ;; wish to retain in EDT emulation mode keymaps. It also permits | 2191 ;; wish to retain in EDT emulation mode keymaps. It also permits |
2202 ;; customization of these bindings in the EDT global maps without | 2192 ;; customization of these bindings in the EDT global maps without |
2203 ;; disturbing the original bindings in global-map. | 2193 ;; disturbing the original bindings in global-map. |
2204 (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix)) | 2194 (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix)) |
2205 (setq edt-default-global-map (copy-keymap (current-global-map))) | 2195 (setq edt-default-global-map (copy-keymap (current-global-map))) |
2206 (if edt-gnu-emacs19-p | 2196 (if (featurep 'emacs) |
2207 (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) | 2197 (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) |
2208 (define-key edt-default-global-map [escape] 'edt-default-ESC-prefix)) | 2198 (define-key edt-default-global-map [escape] 'edt-default-ESC-prefix)) |
2209 (define-prefix-command 'edt-default-gold-map) | 2199 (define-prefix-command 'edt-default-gold-map) |
2210 (edt-setup-default-bindings) | 2200 (edt-setup-default-bindings) |
2211 ;; If terminal has additional function keys, the terminal-specific | 2201 ;; If terminal has additional function keys, the terminal-specific |
2237 ;; Initialize EDT default bindings. | 2227 ;; Initialize EDT default bindings. |
2238 (edt-default-emulation-setup t) | 2228 (edt-default-emulation-setup t) |
2239 ;; Setup user EDT global map by copying default EDT global map bindings. | 2229 ;; Setup user EDT global map by copying default EDT global map bindings. |
2240 (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix)) | 2230 (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix)) |
2241 (setq edt-user-global-map (copy-keymap edt-default-global-map)) | 2231 (setq edt-user-global-map (copy-keymap edt-default-global-map)) |
2242 (if edt-gnu-emacs19-p | 2232 (if (featurep 'emacs) |
2243 (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) | 2233 (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) |
2244 (define-key edt-user-global-map [escape] 'edt-user-ESC-prefix)) | 2234 (define-key edt-user-global-map [escape] 'edt-user-ESC-prefix)) |
2245 ;; If terminal has additional function keys, the user's initialization | 2235 ;; If terminal has additional function keys, the user's initialization |
2246 ;; file can assign bindings to them via the optional | 2236 ;; file can assign bindings to them via the optional |
2247 ;; function edt-setup-extra-default-bindings. | 2237 ;; function edt-setup-extra-default-bindings. |
2251 (edt-select-user-global-map)) | 2241 (edt-select-user-global-map)) |
2252 | 2242 |
2253 (defun edt-select-default-global-map() | 2243 (defun edt-select-default-global-map() |
2254 "Select default EDT emulation key bindings." | 2244 "Select default EDT emulation key bindings." |
2255 (interactive) | 2245 (interactive) |
2256 (if edt-gnu-emacs19-p | 2246 (if (featurep 'emacs) |
2257 (transient-mark-mode 1)) | 2247 (transient-mark-mode 1)) |
2258 (use-global-map edt-default-global-map) | 2248 (use-global-map edt-default-global-map) |
2259 (if (not edt-keep-current-page-delimiter) | 2249 (if (not edt-keep-current-page-delimiter) |
2260 (progn | 2250 (progn |
2261 (setq edt-orig-page-delimiter page-delimiter) | 2251 (setq edt-orig-page-delimiter page-delimiter) |
2269 (defun edt-select-user-global-map() | 2259 (defun edt-select-user-global-map() |
2270 "Select user EDT emulation custom key bindings." | 2260 "Select user EDT emulation custom key bindings." |
2271 (interactive) | 2261 (interactive) |
2272 (if edt-user-map-configured | 2262 (if edt-user-map-configured |
2273 (progn | 2263 (progn |
2274 (if edt-gnu-emacs19-p | 2264 (if (featurep 'emacs) |
2275 (transient-mark-mode 1)) | 2265 (transient-mark-mode 1)) |
2276 (use-global-map edt-user-global-map) | 2266 (use-global-map edt-user-global-map) |
2277 (if (not edt-keep-current-page-delimiter) | 2267 (if (not edt-keep-current-page-delimiter) |
2278 (progn | 2268 (progn |
2279 (setq edt-orig-page-delimiter page-delimiter) | 2269 (setq edt-orig-page-delimiter page-delimiter) |