Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 406:b8cc9ab3f761 r21-2-33
Import from CVS: tag r21-2-33
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:17:09 +0200 |
parents | 2f8bb876ab1d |
children | 501cfd01ee6d |
comparison
equal
deleted
inserted
replaced
405:0e08f63c74d2 | 406:b8cc9ab3f761 |
---|---|
1665 ; (setq mark-active nil) | 1665 ; (setq mark-active nil) |
1666 ; (run-hooks 'deactivate-mark-hook) | 1666 ; (run-hooks 'deactivate-mark-hook) |
1667 ; (set-marker (mark-marker) nil))) | 1667 ; (set-marker (mark-marker) nil))) |
1668 | 1668 |
1669 (defvar mark-ring nil | 1669 (defvar mark-ring nil |
1670 "The list of former marks of the current buffer, most recent first.") | 1670 "The list of former marks of the current buffer, most recent first. |
1671 This variable is automatically buffer-local.") | |
1671 (make-variable-buffer-local 'mark-ring) | 1672 (make-variable-buffer-local 'mark-ring) |
1672 (put 'mark-ring 'permanent-local t) | 1673 (put 'mark-ring 'permanent-local t) |
1674 | |
1675 (defvar dont-record-current-mark nil | |
1676 "If set to t, the current mark value should not be recorded on the mark ring. | |
1677 This is set by commands that manipulate the mark incidentally, to avoid | |
1678 cluttering the mark ring unnecessarily. Under most circumstances, you do | |
1679 not need to set this directly; it is automatically reset each time | |
1680 `push-mark' is called, according to `mark-ring-unrecorded-commands'. This | |
1681 variable is automatically buffer-local.") | |
1682 (make-variable-buffer-local 'dont-record-current-mark) | |
1683 (put 'dont-record-current-mark 'permanent-local t) | |
1684 | |
1685 ;; a conspiracy between push-mark and handle-pre-motion-command | |
1686 (defvar in-shifted-motion-command nil) | |
1687 | |
1688 (defcustom mark-ring-unrecorded-commands '(shifted-motion-commands | |
1689 yank | |
1690 mark-beginning-of-buffer | |
1691 mark-bob | |
1692 mark-defun | |
1693 mark-end-of-buffer | |
1694 mark-end-of-line | |
1695 mark-end-of-sentence | |
1696 mark-eob | |
1697 mark-marker | |
1698 mark-page | |
1699 mark-paragraph | |
1700 mark-sexp | |
1701 mark-whole-buffer | |
1702 mark-word) | |
1703 "*List of commands whose marks should not be recorded on the mark stack. | |
1704 Many commands set the mark as part of their action. Normally, all such | |
1705 marks get recorded onto the mark stack. However, this tends to clutter up | |
1706 the mark stack unnecessarily. You can control this by putting a command | |
1707 onto this list. Then, any marks set by the function will not be recorded. | |
1708 | |
1709 The special value `shifted-motion-commands' causes marks set as a result | |
1710 of selection using any shifted motion commands to not be recorded. | |
1711 | |
1712 The value `yank' affects all yank-like commands, as well as just `yank'." | |
1713 :type '(repeat (choice (const :tag "shifted motion commands" | |
1714 'shifted-motion-commands) | |
1715 (const :tag "functions that select text" | |
1716 :inline t | |
1717 '(mark-beginning-of-buffer | |
1718 mark-bob | |
1719 mark-defun | |
1720 mark-end-of-buffer | |
1721 mark-end-of-line | |
1722 mark-end-of-sentence | |
1723 mark-eob | |
1724 mark-marker | |
1725 mark-page | |
1726 mark-paragraph | |
1727 mark-sexp | |
1728 mark-whole-buffer | |
1729 mark-word)) | |
1730 (const :tag "functions that paste text" | |
1731 'yank) | |
1732 function)) | |
1733 :group 'killing) | |
1673 | 1734 |
1674 (defcustom mark-ring-max 16 | 1735 (defcustom mark-ring-max 16 |
1675 "*Maximum size of mark ring. Start discarding off end if gets this big." | 1736 "*Maximum size of mark ring. Start discarding off end if gets this big." |
1676 :type 'integer | 1737 :type 'integer |
1677 :group 'killing) | 1738 :group 'killing) |
1689 "Set mark at where point is, or jump to mark. | 1750 "Set mark at where point is, or jump to mark. |
1690 With no prefix argument, set mark, push old mark position on local mark | 1751 With no prefix argument, set mark, push old mark position on local mark |
1691 ring, and push mark on global mark ring. | 1752 ring, and push mark on global mark ring. |
1692 With argument, jump to mark, and pop a new position for mark off the ring | 1753 With argument, jump to mark, and pop a new position for mark off the ring |
1693 \(does not affect global mark ring\). | 1754 \(does not affect global mark ring\). |
1755 | |
1756 The mark ring is a per-buffer stack of marks, most recent first. Its | |
1757 maximum length is controlled by `mark-ring-max'. Generally, when new | |
1758 marks are set, the current mark is pushed onto the stack. You can pop | |
1759 marks off the stack using \\[universal-argument] \\[set-mark-command]. The term \"ring\" is used because when | |
1760 you pop a mark off the stack, the current mark value is pushed onto the | |
1761 far end of the stack. If this is confusing, just think of the mark ring | |
1762 as a stack. | |
1694 | 1763 |
1695 Novice Emacs Lisp programmers often try to use the mark for the wrong | 1764 Novice Emacs Lisp programmers often try to use the mark for the wrong |
1696 purposes. See the documentation of `set-mark' for more information." | 1765 purposes. See the documentation of `set-mark' for more information." |
1697 (interactive "P") | 1766 (interactive "P") |
1698 (if (null arg) | 1767 (if (null arg) |
1699 (push-mark nil nil t) | 1768 (push-mark nil nil t) |
1700 (if (null (mark t)) | 1769 (if (null (mark t)) |
1701 (error "No mark set in this buffer") | 1770 (error "No mark set in this buffer") |
1771 (if dont-record-current-mark (pop-mark)) | |
1702 (goto-char (mark t)) | 1772 (goto-char (mark t)) |
1703 (pop-mark)))) | 1773 (pop-mark)))) |
1704 | 1774 |
1705 ;; XEmacs: Extra parameter | 1775 ;; XEmacs: Extra parameter |
1706 (defun push-mark (&optional location nomsg activate-region buffer) | 1776 (defun push-mark (&optional location nomsg activate-region buffer) |
1711 Activate mark if optional third arg ACTIVATE-REGION non-nil. | 1781 Activate mark if optional third arg ACTIVATE-REGION non-nil. |
1712 | 1782 |
1713 Novice Emacs Lisp programmers often try to use the mark for the wrong | 1783 Novice Emacs Lisp programmers often try to use the mark for the wrong |
1714 purposes. See the documentation of `set-mark' for more information." | 1784 purposes. See the documentation of `set-mark' for more information." |
1715 (setq buffer (decode-buffer buffer)) ; XEmacs | 1785 (setq buffer (decode-buffer buffer)) ; XEmacs |
1716 (if (null (mark t buffer)) ; XEmacs | 1786 (if (or dont-record-current-mark (null (mark t buffer))) ; XEmacs |
1717 nil | 1787 nil |
1718 ;; The save-excursion / set-buffer is necessary because mark-ring | 1788 ;; The save-excursion / set-buffer is necessary because mark-ring |
1719 ;; is a buffer local variable | 1789 ;; is a buffer local variable |
1720 (save-excursion | 1790 (save-excursion |
1721 (set-buffer buffer) | 1791 (set-buffer buffer) |
1725 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil buffer) | 1795 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil buffer) |
1726 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil))))) | 1796 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil))))) |
1727 (set-mark (or location (point buffer)) buffer) | 1797 (set-mark (or location (point buffer)) buffer) |
1728 ; (set-marker (mark-marker) (or location (point)) (current-buffer)) ; FSF | 1798 ; (set-marker (mark-marker) (or location (point)) (current-buffer)) ; FSF |
1729 ;; Now push the mark on the global mark ring. | 1799 ;; Now push the mark on the global mark ring. |
1730 (if (or (null global-mark-ring) | 1800 (if (and (not dont-record-current-mark) |
1731 (not (eq (marker-buffer (car global-mark-ring)) buffer))) | 1801 (or (null global-mark-ring) |
1802 (not (eq (marker-buffer (car global-mark-ring)) buffer)))) | |
1732 ;; The last global mark pushed wasn't in this same buffer. | 1803 ;; The last global mark pushed wasn't in this same buffer. |
1733 (progn | 1804 (progn |
1734 (setq global-mark-ring (cons (copy-marker (mark-marker t buffer)) | 1805 (setq global-mark-ring (cons (copy-marker (mark-marker t buffer)) |
1735 global-mark-ring)) | 1806 global-mark-ring)) |
1736 (if (> (length global-mark-ring) global-mark-ring-max) | 1807 (if (> (length global-mark-ring) global-mark-ring-max) |
1737 (progn | 1808 (progn |
1738 (move-marker (car (nthcdr global-mark-ring-max global-mark-ring)) | 1809 (move-marker (car (nthcdr global-mark-ring-max global-mark-ring)) |
1739 nil buffer) | 1810 nil buffer) |
1740 (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil))))) | 1811 (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil))))) |
1741 (or nomsg executing-kbd-macro (> (minibuffer-depth) 0) | 1812 (setq dont-record-current-mark |
1813 (not (not (or (and in-shifted-motion-command | |
1814 (memq 'shifted-motion-commands | |
1815 mark-ring-unrecorded-commands)) | |
1816 (memq this-command mark-ring-unrecorded-commands))))) | |
1817 (or dont-record-current-mark nomsg executing-kbd-macro | |
1818 (> (minibuffer-depth) 0) | |
1742 (display-message 'command "Mark set")) | 1819 (display-message 'command "Mark set")) |
1743 (if activate-region | 1820 (if activate-region |
1744 (progn | 1821 (progn |
1745 (setq zmacs-region-stays t) | 1822 (setq zmacs-region-stays t) |
1746 (zmacs-activate-region))) | 1823 (zmacs-activate-region))) |
1875 (handle-pre-motion-command-current-command-is-motion) | 1952 (handle-pre-motion-command-current-command-is-motion) |
1876 zmacs-regions | 1953 zmacs-regions |
1877 shifted-motion-keys-select-region | 1954 shifted-motion-keys-select-region |
1878 (not (region-active-p)) | 1955 (not (region-active-p)) |
1879 (memq 'shift (event-modifiers last-input-event))) | 1956 (memq 'shift (event-modifiers last-input-event))) |
1880 (push-mark nil nil t))) | 1957 (let ((in-shifted-motion-command t)) |
1958 (push-mark nil nil t)))) | |
1881 | 1959 |
1882 (defun handle-post-motion-command () | 1960 (defun handle-post-motion-command () |
1883 (if | 1961 (if |
1884 (and | 1962 (and |
1885 (handle-pre-motion-command-current-command-is-motion) | 1963 (handle-pre-motion-command-current-command-is-motion) |
3274 (setq element (car alist))) | 3352 (setq element (car alist))) |
3275 (setq alist (cdr alist))) | 3353 (setq alist (cdr alist))) |
3276 element)) | 3354 element)) |
3277 | 3355 |
3278 | 3356 |
3357 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3358 ;; mail composition code ;; | |
3359 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3360 | |
3279 (defcustom mail-user-agent 'sendmail-user-agent | 3361 (defcustom mail-user-agent 'sendmail-user-agent |
3280 "*Your preference for a mail composition package. | 3362 "*Your preference for a mail composition package. |
3281 Various Emacs Lisp packages (e.g. reporter) require you to compose an | 3363 Various Emacs Lisp packages (e.g. reporter) require you to compose an |
3282 outgoing email message. This variable lets you specify which | 3364 outgoing email message. This variable lets you specify which |
3283 mail-sending package you prefer. | 3365 mail-sending package you prefer. |
3419 (list nil nil nil current-prefix-arg)) | 3501 (list nil nil nil current-prefix-arg)) |
3420 (compose-mail to subject other-headers continue | 3502 (compose-mail to subject other-headers continue |
3421 'switch-to-buffer-other-frame yank-action send-actions)) | 3503 'switch-to-buffer-other-frame yank-action send-actions)) |
3422 | 3504 |
3423 | 3505 |
3506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3507 ;; set variable ;; | |
3508 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3509 | |
3424 (defun set-variable (var val) | 3510 (defun set-variable (var val) |
3425 "Set VARIABLE to VALUE. VALUE is a Lisp object. | 3511 "Set VARIABLE to VALUE. VALUE is a Lisp object. |
3426 When using this interactively, supply a Lisp expression for VALUE. | 3512 When using this interactively, supply a Lisp expression for VALUE. |
3427 If you want VALUE to be a string, you must surround it with doublequotes. | 3513 If you want VALUE to be a string, you must surround it with doublequotes. |
3428 If VARIABLE is a specifier, VALUE is added to it as an instantiator in | 3514 If VARIABLE is a specifier, VALUE is added to it as an instantiator in |
3461 'arg)) | 3547 'arg)) |
3462 (eval-minibuffer (format "Set %s to value: " var))))))) | 3548 (eval-minibuffer (format "Set %s to value: " var))))))) |
3463 (if (and (boundp var) (specifierp (symbol-value var))) | 3549 (if (and (boundp var) (specifierp (symbol-value var))) |
3464 (set-specifier (symbol-value var) val) | 3550 (set-specifier (symbol-value var) val) |
3465 (set var val))) | 3551 (set var val))) |
3552 | |
3466 | 3553 |
3467 ;; XEmacs | 3554 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3468 (defun activate-region () | 3555 ;; case changing code ;; |
3469 "Activate the region, if `zmacs-regions' is true. | 3556 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3470 Setting `zmacs-regions' to true causes LISPM-style active regions to be used. | |
3471 This function has no effect if `zmacs-regions' is false." | |
3472 (interactive) | |
3473 (and zmacs-regions (zmacs-activate-region))) | |
3474 | |
3475 ;; XEmacs | |
3476 (defsubst region-exists-p () | |
3477 "Return t if the region exists. | |
3478 If active regions are in use (i.e. `zmacs-regions' is true), this means that | |
3479 the region is active. Otherwise, this means that the user has pushed | |
3480 a mark in this buffer at some point in the past. | |
3481 The functions `region-beginning' and `region-end' can be used to find the | |
3482 limits of the region." | |
3483 (not (null (mark)))) | |
3484 | |
3485 ;; XEmacs | |
3486 (defun region-active-p () | |
3487 "Return non-nil if the region is active. | |
3488 If `zmacs-regions' is true, this is equivalent to `region-exists-p'. | |
3489 Otherwise, this function always returns false." | |
3490 (and zmacs-regions zmacs-region-extent)) | |
3491 | 3557 |
3492 ;; A bunch of stuff was moved elsewhere: | 3558 ;; A bunch of stuff was moved elsewhere: |
3493 ;; completion-list-mode-map | 3559 ;; completion-list-mode-map |
3494 ;; completion-reference-buffer | 3560 ;; completion-reference-buffer |
3495 ;; completion-base-size | 3561 ;; completion-base-size |
3563 (not (looking-at uncapitalized-title-word-regexp))) | 3629 (not (looking-at uncapitalized-title-word-regexp))) |
3564 (capitalize-word 1) | 3630 (capitalize-word 1) |
3565 (forward-word 1)) | 3631 (forward-word 1)) |
3566 (setq first nil)))))) | 3632 (setq first nil)))))) |
3567 | 3633 |
3634 | |
3635 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3636 ;; zmacs active region code ;; | |
3637 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3638 | |
3568 ;; Most of the zmacs code is now in elisp. The only thing left in C | 3639 ;; Most of the zmacs code is now in elisp. The only thing left in C |
3569 ;; are the variables zmacs-regions, zmacs-region-active-p and | 3640 ;; are the variables zmacs-regions, zmacs-region-active-p and |
3570 ;; zmacs-region-stays plus the function zmacs_update_region which | 3641 ;; zmacs-region-stays plus the function zmacs_update_region which |
3571 ;; simply calls the lisp level zmacs-update-region. It must remain | 3642 ;; simply calls the lisp level zmacs-update-region. It must remain |
3572 ;; for convenience, since it is called by core C code. | 3643 ;; for convenience, since it is called by core C code. |
3644 | |
3645 ;; XEmacs | |
3646 (defun activate-region () | |
3647 "Activate the region, if `zmacs-regions' is true. | |
3648 Setting `zmacs-regions' to true causes LISPM-style active regions to be used. | |
3649 This function has no effect if `zmacs-regions' is false." | |
3650 (interactive) | |
3651 (and zmacs-regions (zmacs-activate-region))) | |
3652 | |
3653 ;; XEmacs | |
3654 (defsubst region-exists-p () | |
3655 "Return t if the region exists. | |
3656 If active regions are in use (i.e. `zmacs-regions' is true), this means that | |
3657 the region is active. Otherwise, this means that the user has pushed | |
3658 a mark in this buffer at some point in the past. | |
3659 The functions `region-beginning' and `region-end' can be used to find the | |
3660 limits of the region." | |
3661 (not (null (mark)))) | |
3662 | |
3663 ;; XEmacs | |
3664 (defun region-active-p () | |
3665 "Return non-nil if the region is active. | |
3666 If `zmacs-regions' is true, this is equivalent to `region-exists-p'. | |
3667 Otherwise, this function always returns false." | |
3668 (and zmacs-regions zmacs-region-extent)) | |
3573 | 3669 |
3574 (defvar zmacs-activate-region-hook nil | 3670 (defvar zmacs-activate-region-hook nil |
3575 "Function or functions called when the region becomes active; | 3671 "Function or functions called when the region becomes active; |
3576 see the variable `zmacs-regions'.") | 3672 see the variable `zmacs-regions'.") |
3577 | 3673 |
3709 (when (marker-buffer (mark-marker t)) | 3805 (when (marker-buffer (mark-marker t)) |
3710 (zmacs-make-extent-for-region (cons (point-marker t) | 3806 (zmacs-make-extent-for-region (cons (point-marker t) |
3711 (mark-marker t)))) | 3807 (mark-marker t)))) |
3712 (run-hooks 'zmacs-update-region-hook))) | 3808 (run-hooks 'zmacs-update-region-hook))) |
3713 | 3809 |
3714 ;;;;;; | 3810 |
3715 ;;;;;; echo area stuff | 3811 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3716 ;;;;;; | 3812 ;; message logging code ;; |
3813 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3717 | 3814 |
3718 ;;; #### Should this be moved to a separate file, for clarity? | 3815 ;;; #### Should this be moved to a separate file, for clarity? |
3719 ;;; -hniksic | 3816 ;;; -hniksic |
3720 | 3817 |
3721 ;;; The `message-stack' is an alist of labels with messages; the first | 3818 ;;; The `message-stack' is an alist of labels with messages; the first |
4032 (clear-message label nil)) | 4129 (clear-message label nil)) |
4033 (let ((str (apply 'format fmt args))) | 4130 (let ((str (apply 'format fmt args))) |
4034 (display-message label str) | 4131 (display-message label str) |
4035 str))) | 4132 str))) |
4036 | 4133 |
4037 | 4134 |
4038 ;;;;;; | 4135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4039 ;;;;;; warning stuff | 4136 ;; warning code ;; |
4040 ;;;;;; | 4137 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4041 | 4138 |
4042 (defcustom log-warning-minimum-level 'info | 4139 (defcustom log-warning-minimum-level 'info |
4043 "Minimum level of warnings that should be logged. | 4140 "Minimum level of warnings that should be logged. |
4044 The warnings in levels below this are completely ignored, as if they never | 4141 The warnings in levels below this are completely ignored, as if they never |
4045 happened. | 4142 happened. |
4237 (point-max))) | 4334 (point-max))) |
4238 (funcall temp-buffer-show-function show-buffer)) | 4335 (funcall temp-buffer-show-function show-buffer)) |
4239 (set-window-start (display-buffer buffer) warning-marker)) | 4336 (set-window-start (display-buffer buffer) warning-marker)) |
4240 (set-marker warning-marker (point-max buffer) buffer))) | 4337 (set-marker warning-marker (point-max buffer) buffer))) |
4241 | 4338 |
4339 | |
4340 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4341 ;; misc junk ;; | |
4342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4343 | |
4242 (defun emacs-name () | 4344 (defun emacs-name () |
4243 "Return the printable name of this instance of Emacs." | 4345 "Return the printable name of this instance of Emacs." |
4244 (cond ((featurep 'infodock) "InfoDock") | 4346 (cond ((featurep 'infodock) "InfoDock") |
4245 ((featurep 'xemacs) "XEmacs") | 4347 ((featurep 'xemacs) "XEmacs") |
4246 (t "Emacs"))) | 4348 (t "Emacs"))) |