Mercurial > emacs
comparison lisp/emulation/tpu-edt.el @ 39540:a386ffde71f8
Make messages match original TPU/edt editor.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Wed, 03 Oct 2001 19:44:55 +0000 |
parents | b174db545cfd |
children | 32f917f3edf7 |
comparison
equal
deleted
inserted
replaced
39539:1f0f069f32ea | 39540:a386ffde71f8 |
---|---|
750 and the total number of lines in the buffer." | 750 and the total number of lines in the buffer." |
751 (interactive) | 751 (interactive) |
752 (if (eobp) | 752 (if (eobp) |
753 (message "You are at the End of Buffer. The last line is %d." | 753 (message "You are at the End of Buffer. The last line is %d." |
754 (count-lines 1 (point-max))) | 754 (count-lines 1 (point-max))) |
755 (message "Line %d of %d" | 755 (let* ((cur (count-lines 1 (1+ (point)))) |
756 (count-lines 1 (1+ (point))) | 756 (max (count-lines 1 (point-max))) |
757 (count-lines 1 (point-max))))) | 757 (pct (/ (* 100 (+ cur (/ max 200))) max))) |
758 (message "You are on line %d out of %d (%d%%)." cur max pct)))) | |
758 | 759 |
759 (defun tpu-exit nil | 760 (defun tpu-exit nil |
760 "Exit the way TPU does, save current buffer and ask about others." | 761 "Exit the way TPU does, save current buffer and ask about others." |
761 (interactive) | 762 (interactive) |
762 (if (not (eq (recursion-depth) 0)) | 763 (if (not (eq (recursion-depth) 0)) |
812 | 813 |
813 ;; Apparently TPU users really expect to do M-x help RET to get help. | 814 ;; Apparently TPU users really expect to do M-x help RET to get help. |
814 ;; So it is really necessary to redefine this. | 815 ;; So it is really necessary to redefine this. |
815 (fset 'help 'tpu-help) | 816 (fset 'help 'tpu-help) |
816 (fset 'HELP 'tpu-help) | 817 (fset 'HELP 'tpu-help) |
818 | |
819 ;; Real TPU error messages end in periods. | |
820 ;; Define this to avoid openly flouting Emacs coding standards. | |
821 (defalias 'tpu-error 'error) | |
817 | 822 |
818 (fset 'set\ cursor\ free 'tpu-set-cursor-free) | 823 (fset 'set\ cursor\ free 'tpu-set-cursor-free) |
819 (fset 'SET\ CURSOR\ FREE 'tpu-set-cursor-free) | 824 (fset 'SET\ CURSOR\ FREE 'tpu-set-cursor-free) |
820 | 825 |
821 (fset 'set\ cursor\ bound 'tpu-set-cursor-bound) | 826 (fset 'set\ cursor\ bound 'tpu-set-cursor-bound) |
1069 (defun tpu-next-file-buffer nil | 1074 (defun tpu-next-file-buffer nil |
1070 "Go to next buffer in ring that is visiting a file or directory." | 1075 "Go to next buffer in ring that is visiting a file or directory." |
1071 (interactive) | 1076 (interactive) |
1072 (let ((list (tpu-make-file-buffer-list (buffer-list)))) | 1077 (let ((list (tpu-make-file-buffer-list (buffer-list)))) |
1073 (setq list (delq (current-buffer) list)) | 1078 (setq list (delq (current-buffer) list)) |
1074 (if (not list) (error "No other buffers")) | 1079 (if (not list) (tpu-error "No other buffers.")) |
1075 (switch-to-buffer (car (reverse list))))) | 1080 (switch-to-buffer (car (reverse list))))) |
1076 | 1081 |
1077 (defun tpu-make-file-buffer-list (buffer-list) | 1082 (defun tpu-make-file-buffer-list (buffer-list) |
1078 "Returns names from BUFFER-LIST excluding those beginning with a space or star." | 1083 "Returns names from BUFFER-LIST excluding those beginning with a space or star." |
1079 (delq nil (mapcar '(lambda (b) | 1084 (delq nil (mapcar '(lambda (b) |
1341 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) | 1346 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) |
1342 (setq tpu-last-deleted-region (buffer-substring beg end)) | 1347 (setq tpu-last-deleted-region (buffer-substring beg end)) |
1343 (delete-region beg end) | 1348 (delete-region beg end) |
1344 (tpu-unset-match))) | 1349 (tpu-unset-match))) |
1345 (t | 1350 (t |
1346 (error "No selection active")))) | 1351 (tpu-error "No selection active.")))) |
1347 | 1352 |
1348 (defun tpu-store-text nil | 1353 (defun tpu-store-text nil |
1349 "Copy the selected region to the cut buffer without deleting it. | 1354 "Copy the selected region to the cut buffer without deleting it. |
1350 The text is saved for the tpu-paste command." | 1355 The text is saved for the tpu-paste command." |
1351 (interactive) | 1356 (interactive) |
1363 ((tpu-check-match) | 1368 ((tpu-check-match) |
1364 (setq tpu-last-deleted-region | 1369 (setq tpu-last-deleted-region |
1365 (buffer-substring (tpu-match-beginning) (tpu-match-end))) | 1370 (buffer-substring (tpu-match-beginning) (tpu-match-end))) |
1366 (tpu-unset-match)) | 1371 (tpu-unset-match)) |
1367 (t | 1372 (t |
1368 (error "No selection active")))) | 1373 (tpu-error "No selection active.")))) |
1369 | 1374 |
1370 (defun tpu-cut (arg) | 1375 (defun tpu-cut (arg) |
1371 "Copy selected region to the cut buffer. In the absence of an | 1376 "Copy selected region to the cut buffer. In the absence of an |
1372 argument, delete the selected region too." | 1377 argument, delete the selected region too." |
1373 (interactive "P") | 1378 (interactive "P") |
1390 (concat tpu-last-deleted-region | 1395 (concat tpu-last-deleted-region |
1391 (buffer-substring beg end))) | 1396 (buffer-substring beg end))) |
1392 (if (not arg) (delete-region beg end)) | 1397 (if (not arg) (delete-region beg end)) |
1393 (tpu-unset-match))) | 1398 (tpu-unset-match))) |
1394 (t | 1399 (t |
1395 (error "No selection active")))) | 1400 (tpu-error "No selection active.")))) |
1396 | 1401 |
1397 (defun tpu-delete-current-line (num) | 1402 (defun tpu-delete-current-line (num) |
1398 "Delete one or specified number of lines after point. | 1403 "Delete one or specified number of lines after point. |
1399 This includes the newline character at the end of each line. | 1404 This includes the newline character at the end of each line. |
1400 They are saved for the TPU-edt undelete-lines command." | 1405 They are saved for the TPU-edt undelete-lines command." |
1530 (setq tpu-last-replaced-text (buffer-substring beg end)) | 1535 (setq tpu-last-replaced-text (buffer-substring beg end)) |
1531 (replace-match tpu-last-deleted-region | 1536 (replace-match tpu-last-deleted-region |
1532 (not case-replace) (not tpu-regexp-p)) | 1537 (not case-replace) (not tpu-regexp-p)) |
1533 (tpu-unset-match))) | 1538 (tpu-unset-match))) |
1534 (t | 1539 (t |
1535 (error "No selection active")))) | 1540 (tpu-error "No selection active.")))) |
1536 | 1541 |
1537 (defun tpu-substitute (num) | 1542 (defun tpu-substitute (num) |
1538 "Replace the selected region with the contents of the cut buffer, and | 1543 "Replace the selected region with the contents of the cut buffer, and |
1539 repeat most recent search. A numeric argument serves as a repeat count. | 1544 repeat most recent search. A numeric argument serves as a repeat count. |
1540 A negative argument means replace all occurrences of the search string." | 1545 A negative argument means replace all occurrences of the search string." |
1546 (if tpu-searching-forward (forward-char -1) (goto-char beg)) | 1551 (if tpu-searching-forward (forward-char -1) (goto-char beg)) |
1547 (if (= num 1) (tpu-search-internal tpu-search-last-string) | 1552 (if (= num 1) (tpu-search-internal tpu-search-last-string) |
1548 (tpu-search-internal-core tpu-search-last-string))) | 1553 (tpu-search-internal-core tpu-search-last-string))) |
1549 (setq num (1- num)))) | 1554 (setq num (1- num)))) |
1550 (t | 1555 (t |
1551 (error "No selection active")))) | 1556 (tpu-error "No selection active.")))) |
1552 | 1557 |
1553 (defun tpu-lm-replace (from to) | 1558 (defun tpu-lm-replace (from to) |
1554 "Interactively search for OLD-string and substitute NEW-string." | 1559 "Interactively search for OLD-string and substitute NEW-string." |
1555 (interactive (list (tpu-regexp-prompt "Old String: ") | 1560 (interactive (list (tpu-regexp-prompt "Old String: ") |
1556 (tpu-regexp-prompt "New String: "))) | 1561 (tpu-regexp-prompt "New String: "))) |
1557 | 1562 |
1558 (let ((doit t) (strings 0)) | 1563 (let ((doit t) (strings 0)) |
1559 | 1564 |
1560 ;; Can't replace null strings | 1565 ;; Can't replace null strings |
1561 (if (string= "" from) (error "No string to replace")) | 1566 (if (string= "" from) (tpu-error "No string to replace.")) |
1562 | 1567 |
1563 ;; Find the first occurrence | 1568 ;; Find the first occurrence |
1564 (tpu-set-search) | 1569 (tpu-set-search) |
1565 (tpu-search-internal from t) | 1570 (tpu-search-internal from t) |
1566 | 1571 |
1629 (defun tpu-add-at-bol (text) | 1634 (defun tpu-add-at-bol (text) |
1630 "Add text to the beginning of each line in a region, | 1635 "Add text to the beginning of each line in a region, |
1631 or each line in the entire buffer if no region is selected." | 1636 or each line in the entire buffer if no region is selected." |
1632 (interactive | 1637 (interactive |
1633 (list (tpu-string-prompt "String to add: " 'tpu-add-at-bol-hist))) | 1638 (list (tpu-string-prompt "String to add: " 'tpu-add-at-bol-hist))) |
1634 (if (string= "" text) (error "No string specified")) | 1639 (if (string= "" text) (tpu-error "No string specified.")) |
1635 (cond ((tpu-mark) | 1640 (cond ((tpu-mark) |
1636 (save-excursion | 1641 (save-excursion |
1637 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) | 1642 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) |
1638 (while (and (< (point) (tpu-mark)) (re-search-forward "^" (tpu-mark) t)) | 1643 (while (and (< (point) (tpu-mark)) (re-search-forward "^" (tpu-mark) t)) |
1639 (if (< (point) (tpu-mark)) (replace-match text)))) | 1644 (if (< (point) (tpu-mark)) (replace-match text)))) |
1647 (defun tpu-add-at-eol (text) | 1652 (defun tpu-add-at-eol (text) |
1648 "Add text to the end of each line in a region, | 1653 "Add text to the end of each line in a region, |
1649 or each line of the entire buffer if no region is selected." | 1654 or each line of the entire buffer if no region is selected." |
1650 (interactive | 1655 (interactive |
1651 (list (tpu-string-prompt "String to add: " 'tpu-add-at-eol-hist))) | 1656 (list (tpu-string-prompt "String to add: " 'tpu-add-at-eol-hist))) |
1652 (if (string= "" text) (error "No string specified")) | 1657 (if (string= "" text) (tpu-error "No string specified.")) |
1653 (cond ((tpu-mark) | 1658 (cond ((tpu-mark) |
1654 (save-excursion | 1659 (save-excursion |
1655 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) | 1660 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) |
1656 (while (< (point) (tpu-mark)) | 1661 (while (< (point) (tpu-mark)) |
1657 (end-of-line) | 1662 (end-of-line) |
1952 | 1957 |
1953 (defun tpu-goto-percent (perc) | 1958 (defun tpu-goto-percent (perc) |
1954 "Move point to ARG percentage of the buffer." | 1959 "Move point to ARG percentage of the buffer." |
1955 (interactive "NGoto-percentage: ") | 1960 (interactive "NGoto-percentage: ") |
1956 (if (or (> perc 100) (< perc 0)) | 1961 (if (or (> perc 100) (< perc 0)) |
1957 (error "Percentage %d out of range 0 < percent < 100" perc) | 1962 (tpu-error "Percentage %d out of range 0 < percent < 100." perc) |
1958 (goto-char (/ (* (point-max) perc) 100)))) | 1963 (goto-char (/ (* (point-max) perc) 100)))) |
1959 | 1964 |
1960 (defun tpu-beginning-of-window nil | 1965 (defun tpu-beginning-of-window nil |
1961 "Move cursor to top of window." | 1966 "Move cursor to top of window." |
1962 (interactive) | 1967 (interactive) |
2466 (goto-char (point-min)) | 2471 (goto-char (point-min)) |
2467 (beep) | 2472 (beep) |
2468 (and (tpu-y-or-n-p "Copy key definitions to the new file now? ") | 2473 (and (tpu-y-or-n-p "Copy key definitions to the new file now? ") |
2469 (condition-case conditions | 2474 (condition-case conditions |
2470 (copy-file oldname newname) | 2475 (copy-file oldname newname) |
2471 (error (message "Sorry, couldn't copy - %s" (cdr conditions))))) | 2476 (tpu-error (message "Sorry, couldn't copy - %s." (cdr conditions))))) |
2472 (kill-buffer "*TPU-Notice*"))) | 2477 (kill-buffer "*TPU-Notice*"))) |
2473 | 2478 |
2474 | 2479 |
2475 ;;; | 2480 ;;; |
2476 ;;; Start and Stop TPU-edt | 2481 ;;; Start and Stop TPU-edt |