Mercurial > emacs
comparison lisp/simple.el @ 52966:6fc70221e5c7
(overriding-map-is-bound, saved-overriding-map): New variables.
(ensure-overriding-map-is-bound, restore-overriding-map): New functions.
(universal-argument, universal-argument-more, negative-argument)
(digit-argument, universal-argument-other-key): Minor changes.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 01 Nov 2003 17:01:36 +0000 |
parents | ae9d36444079 |
children | bb31cf348e05 |
comparison
equal
deleted
inserted
replaced
52965:0f3d00e06554 | 52966:6fc70221e5c7 |
---|---|
1655 (defvar universal-argument-num-events nil | 1655 (defvar universal-argument-num-events nil |
1656 "Number of argument-specifying events read by `universal-argument'. | 1656 "Number of argument-specifying events read by `universal-argument'. |
1657 `universal-argument-other-key' uses this to discard those events | 1657 `universal-argument-other-key' uses this to discard those events |
1658 from (this-command-keys), and reread only the final command.") | 1658 from (this-command-keys), and reread only the final command.") |
1659 | 1659 |
1660 (defvar overriding-map-is-bound nil | |
1661 "Non-nil when `overriding-terminal-local-map' is `universal-argument-map'.") | |
1662 | |
1663 (defvar saved-overriding-map nil | |
1664 "The saved value of `overriding-terminal-local-map'. | |
1665 That variable gets restored to this value on exiting \"universal | |
1666 argument mode\".") | |
1667 | |
1668 (defun ensure-overriding-map-is-bound () | |
1669 "Check `overriding-terminal-local-map' is `universal-argument-map'." | |
1670 (unless overriding-map-is-bound | |
1671 (setq saved-overriding-map overriding-terminal-local-map) | |
1672 (setq overriding-terminal-local-map universal-argument-map) | |
1673 (setq overriding-map-is-bound t))) | |
1674 | |
1675 (defun restore-overriding-map () | |
1676 "Restore `overriding-terminal-local-map' to its saved value." | |
1677 (setq overriding-terminal-local-map saved-overriding-map) | |
1678 (setq overriding-map-is-bound nil)) | |
1679 | |
1660 (defun universal-argument () | 1680 (defun universal-argument () |
1661 "Begin a numeric argument for the following command. | 1681 "Begin a numeric argument for the following command. |
1662 Digits or minus sign following \\[universal-argument] make up the numeric argument. | 1682 Digits or minus sign following \\[universal-argument] make up the numeric argument. |
1663 \\[universal-argument] following the digits or minus sign ends the argument. | 1683 \\[universal-argument] following the digits or minus sign ends the argument. |
1664 \\[universal-argument] without digits or minus sign provides 4 as argument. | 1684 \\[universal-argument] without digits or minus sign provides 4 as argument. |
1668 which is different in effect from any particular numeric argument. | 1688 which is different in effect from any particular numeric argument. |
1669 These commands include \\[set-mark-command] and \\[start-kbd-macro]." | 1689 These commands include \\[set-mark-command] and \\[start-kbd-macro]." |
1670 (interactive) | 1690 (interactive) |
1671 (setq prefix-arg (list 4)) | 1691 (setq prefix-arg (list 4)) |
1672 (setq universal-argument-num-events (length (this-command-keys))) | 1692 (setq universal-argument-num-events (length (this-command-keys))) |
1673 (setq overriding-terminal-local-map universal-argument-map)) | 1693 (ensure-overriding-map-is-bound)) |
1674 | 1694 |
1675 ;; A subsequent C-u means to multiply the factor by 4 if we've typed | 1695 ;; A subsequent C-u means to multiply the factor by 4 if we've typed |
1676 ;; nothing but C-u's; otherwise it means to terminate the prefix arg. | 1696 ;; nothing but C-u's; otherwise it means to terminate the prefix arg. |
1677 (defun universal-argument-more (arg) | 1697 (defun universal-argument-more (arg) |
1678 (interactive "P") | 1698 (interactive "P") |
1679 (if (consp arg) | 1699 (if (consp arg) |
1680 (setq prefix-arg (list (* 4 (car arg)))) | 1700 (setq prefix-arg (list (* 4 (car arg)))) |
1681 (if (eq arg '-) | 1701 (if (eq arg '-) |
1682 (setq prefix-arg (list -4)) | 1702 (setq prefix-arg (list -4)) |
1683 (setq prefix-arg arg) | 1703 (setq prefix-arg arg) |
1684 (setq overriding-terminal-local-map nil))) | 1704 (restore-overriding-map))) |
1685 (setq universal-argument-num-events (length (this-command-keys)))) | 1705 (setq universal-argument-num-events (length (this-command-keys)))) |
1686 | 1706 |
1687 (defun negative-argument (arg) | 1707 (defun negative-argument (arg) |
1688 "Begin a negative numeric argument for the next command. | 1708 "Begin a negative numeric argument for the next command. |
1689 \\[universal-argument] following digits or minus sign ends the argument." | 1709 \\[universal-argument] following digits or minus sign ends the argument." |
1693 ((eq arg '-) | 1713 ((eq arg '-) |
1694 (setq prefix-arg nil)) | 1714 (setq prefix-arg nil)) |
1695 (t | 1715 (t |
1696 (setq prefix-arg '-))) | 1716 (setq prefix-arg '-))) |
1697 (setq universal-argument-num-events (length (this-command-keys))) | 1717 (setq universal-argument-num-events (length (this-command-keys))) |
1698 (setq overriding-terminal-local-map universal-argument-map)) | 1718 (ensure-overriding-map-is-bound)) |
1699 | 1719 |
1700 (defun digit-argument (arg) | 1720 (defun digit-argument (arg) |
1701 "Part of the numeric argument for the next command. | 1721 "Part of the numeric argument for the next command. |
1702 \\[universal-argument] following digits or minus sign ends the argument." | 1722 \\[universal-argument] following digits or minus sign ends the argument." |
1703 (interactive "P") | 1723 (interactive "P") |
1712 ;; Treat -0 as just -, so that -01 will work. | 1732 ;; Treat -0 as just -, so that -01 will work. |
1713 (setq prefix-arg (if (zerop digit) '- (- digit)))) | 1733 (setq prefix-arg (if (zerop digit) '- (- digit)))) |
1714 (t | 1734 (t |
1715 (setq prefix-arg digit)))) | 1735 (setq prefix-arg digit)))) |
1716 (setq universal-argument-num-events (length (this-command-keys))) | 1736 (setq universal-argument-num-events (length (this-command-keys))) |
1717 (setq overriding-terminal-local-map universal-argument-map)) | 1737 (ensure-overriding-map-is-bound)) |
1718 | 1738 |
1719 ;; For backward compatibility, minus with no modifiers is an ordinary | 1739 ;; For backward compatibility, minus with no modifiers is an ordinary |
1720 ;; command if digits have already been entered. | 1740 ;; command if digits have already been entered. |
1721 (defun universal-argument-minus (arg) | 1741 (defun universal-argument-minus (arg) |
1722 (interactive "P") | 1742 (interactive "P") |
1733 (keylist (listify-key-sequence key))) | 1753 (keylist (listify-key-sequence key))) |
1734 (setq unread-command-events | 1754 (setq unread-command-events |
1735 (append (nthcdr universal-argument-num-events keylist) | 1755 (append (nthcdr universal-argument-num-events keylist) |
1736 unread-command-events))) | 1756 unread-command-events))) |
1737 (reset-this-command-lengths) | 1757 (reset-this-command-lengths) |
1738 (setq overriding-terminal-local-map nil)) | 1758 (restore-overriding-map)) |
1739 | 1759 |
1740 ;;;; Window system cut and paste hooks. | 1760 ;;;; Window system cut and paste hooks. |
1741 | 1761 |
1742 (defvar interprogram-cut-function nil | 1762 (defvar interprogram-cut-function nil |
1743 "Function to call to make a killed region available to other programs. | 1763 "Function to call to make a killed region available to other programs. |
3346 (interactive "P") | 3366 (interactive "P") |
3347 (if (consp arg) | 3367 (if (consp arg) |
3348 (setq arg (current-column))) | 3368 (setq arg (current-column))) |
3349 (if (not (integerp arg)) | 3369 (if (not (integerp arg)) |
3350 ;; Disallow missing argument; it's probably a typo for C-x C-f. | 3370 ;; Disallow missing argument; it's probably a typo for C-x C-f. |
3351 (error "set-fill-column requires an explicit argument") | 3371 (error "Set-fill-column requires an explicit argument") |
3352 (message "Fill column set to %d (was %d)" arg fill-column) | 3372 (message "Fill column set to %d (was %d)" arg fill-column) |
3353 (setq fill-column arg))) | 3373 (setq fill-column arg))) |
3354 | 3374 |
3355 (defun set-selective-display (arg) | 3375 (defun set-selective-display (arg) |
3356 "Set `selective-display' to ARG; clear it if no arg. | 3376 "Set `selective-display' to ARG; clear it if no arg. |