Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 219:262b8bb4a523 r20-4b8
Import from CVS: tag r20-4b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:09:35 +0200 |
parents | 1f0dabaa0855 |
children | 2c611d1463a6 |
comparison
equal
deleted
inserted
replaced
218:c9f226976f56 | 219:262b8bb4a523 |
---|---|
103 (barf-if-buffer-read-only nil (point)) | 103 (barf-if-buffer-read-only nil (point)) |
104 ;; Inserting a newline at the end of a line produces better redisplay in | 104 ;; Inserting a newline at the end of a line produces better redisplay in |
105 ;; try_window_id than inserting at the beginning of a line, and the textual | 105 ;; try_window_id than inserting at the beginning of a line, and the textual |
106 ;; result is the same. So, if we're at beginning of line, pretend to be at | 106 ;; result is the same. So, if we're at beginning of line, pretend to be at |
107 ;; the end of the previous line. | 107 ;; the end of the previous line. |
108 ;; #### Does this have any relevance in XEmacs? | |
108 (let ((flag (and (not (bobp)) | 109 (let ((flag (and (not (bobp)) |
109 (bolp) | 110 (bolp) |
110 ;; Make sure the newline before point isn't intangible. | 111 ;; Make sure the newline before point isn't intangible. |
111 (not (get-char-property (1- (point)) 'intangible)) | 112 (not (get-char-property (1- (point)) 'intangible)) |
112 ;; Make sure the newline before point isn't read-only. | 113 ;; Make sure the newline before point isn't read-only. |
1189 (if (markerp end) (setq end (marker-position end))) | 1190 (if (markerp end) (setq end (marker-position end))) |
1190 (or (and beg end) (if zmacs-regions ;; rewritten for I18N3 snarfing | 1191 (or (and beg end) (if zmacs-regions ;; rewritten for I18N3 snarfing |
1191 (error "The region is not active now") | 1192 (error "The region is not active now") |
1192 (error "The mark is not set now"))) | 1193 (error "The mark is not set now"))) |
1193 (if verbose (if buffer-read-only | 1194 (if verbose (if buffer-read-only |
1194 (display-message | 1195 (lmessage 'command "Copying %d characters" |
1195 'command | 1196 (- (max beg end) (min beg end))) |
1196 (format "Copying %d characters" | 1197 (lmessage 'command "Killing %d characters" |
1197 (- (max beg end) (min beg end)))) | 1198 (- (max beg end) (min beg end))))) |
1198 (display-message | |
1199 'command | |
1200 (format "Killing %d characters" | |
1201 (- (max beg end) (min beg end)))))) | |
1202 (cond | 1199 (cond |
1203 | 1200 |
1204 ;; I don't like this large change in behavior -- jwz | 1201 ;; I don't like this large change in behavior -- jwz |
1205 ;; Read-Only text means it shouldn't be deleted, so I'm restoring | 1202 ;; Read-Only text means it shouldn't be deleted, so I'm restoring |
1206 ;; this code, but only for text-properties and not full extents. -sb | 1203 ;; this code, but only for text-properties and not full extents. -sb |
1306 (interactive "_") | 1303 (interactive "_") |
1307 (if (interactive-p) | 1304 (if (interactive-p) |
1308 (progn | 1305 (progn |
1309 (setq this-command 'kill-region) | 1306 (setq this-command 'kill-region) |
1310 (display-message 'command | 1307 (display-message 'command |
1311 "If the next command is a kill, it will append")) | 1308 "If the next command is a kill, it will append")) |
1312 (setq last-command 'kill-region))) | 1309 (setq last-command 'kill-region))) |
1313 | 1310 |
1314 (defun yank-pop (arg) | 1311 (defun yank-pop (arg) |
1315 "Replace just-yanked stretch of killed text with a different stretch. | 1312 "Replace just-yanked stretch of killed text with a different stretch. |
1316 This command is allowed only immediately after a `yank' or a `yank-pop'. | 1313 This command is allowed only immediately after a `yank' or a `yank-pop'. |
1761 (defvar temporary-goal-column 0 | 1758 (defvar temporary-goal-column 0 |
1762 "Current goal column for vertical motion. | 1759 "Current goal column for vertical motion. |
1763 It is the column where point was | 1760 It is the column where point was |
1764 at the start of current run of vertical motion commands. | 1761 at the start of current run of vertical motion commands. |
1765 When the `track-eol' feature is doing its job, the value is 9999.") | 1762 When the `track-eol' feature is doing its job, the value is 9999.") |
1763 (make-variable-buffer-local 'temporary-goal-column) | |
1766 | 1764 |
1767 ;XEmacs: not yet ported, so avoid compiler warnings | 1765 ;XEmacs: not yet ported, so avoid compiler warnings |
1768 (eval-when-compile | 1766 (eval-when-compile |
1769 (defvar inhibit-point-motion-hooks)) | 1767 (defvar inhibit-point-motion-hooks)) |
1770 | 1768 |
2172 (re-search-backward comment-start-skip) | 2170 (re-search-backward comment-start-skip) |
2173 (beginning-of-line) | 2171 (beginning-of-line) |
2174 (re-search-forward comment-start-skip) | 2172 (re-search-forward comment-start-skip) |
2175 (goto-char (match-beginning 0)) | 2173 (goto-char (match-beginning 0)) |
2176 (setq comment-column (current-column)) | 2174 (setq comment-column (current-column)) |
2177 (display-message | 2175 (lmessage 'command "Comment column set to %d" comment-column)) |
2178 'command | |
2179 (format "Comment column set to %d" comment-column))) | |
2180 (indent-for-comment)) | 2176 (indent-for-comment)) |
2181 (setq comment-column (current-column)) | 2177 (setq comment-column (current-column)) |
2182 (display-message | 2178 (lmessage 'command "Comment column set to %d" comment-column)))) |
2183 'command | |
2184 (format "Comment column set to %d" comment-column))))) | |
2185 | 2179 |
2186 (defun kill-comment (arg) | 2180 (defun kill-comment (arg) |
2187 "Kill the comment on this line, if any. | 2181 "Kill the comment on this line, if any. |
2188 With argument, kill comments on that many lines starting with this one." | 2182 With argument, kill comments on that many lines starting with this one." |
2189 ;; this function loses in a lot of situations. it incorrectly recognises | 2183 ;; this function loses in a lot of situations. it incorrectly recognises |
2630 ((consp arg) | 2624 ((consp arg) |
2631 (setq fill-column (current-column))) | 2625 (setq fill-column (current-column))) |
2632 ;; Disallow missing argument; it's probably a typo for C-x C-f. | 2626 ;; Disallow missing argument; it's probably a typo for C-x C-f. |
2633 (t | 2627 (t |
2634 (error "set-fill-column requires an explicit argument"))) | 2628 (error "set-fill-column requires an explicit argument"))) |
2635 (display-message 'command (format "fill-column set to %d" fill-column))) | 2629 (lmessage 'command "fill-column set to %d" fill-column)) |
2636 | 2630 |
2637 (defcustom comment-multi-line t ; XEmacs - this works well with adaptive fill | 2631 (defcustom comment-multi-line t ; XEmacs - this works well with adaptive fill |
2638 "*Non-nil means \\[indent-new-comment-line] should continue same comment | 2632 "*Non-nil means \\[indent-new-comment-line] should continue same comment |
2639 on new line, with no new terminator or starter. | 2633 on new line, with no new terminator or starter. |
2640 This is obsolete because you might as well use \\[newline-and-indent]." | 2634 This is obsolete because you might as well use \\[newline-and-indent]." |
2916 (and blink-matching-paren-on-screen | 2910 (and blink-matching-paren-on-screen |
2917 (progn | 2911 (progn |
2918 (auto-show-make-point-visible) | 2912 (auto-show-make-point-visible) |
2919 (sit-for blink-matching-delay))) | 2913 (sit-for blink-matching-delay))) |
2920 (goto-char blinkpos) | 2914 (goto-char blinkpos) |
2921 (display-message | 2915 (lmessage 'command "Matches %s" |
2922 'command | |
2923 (format | |
2924 "Matches %s" | |
2925 ;; Show what precedes the open in its line, if anything. | 2916 ;; Show what precedes the open in its line, if anything. |
2926 (if (save-excursion | 2917 (if (save-excursion |
2927 (skip-chars-backward " \t") | 2918 (skip-chars-backward " \t") |
2928 (not (bolp))) | 2919 (not (bolp))) |
2929 (buffer-substring (progn (beginning-of-line) (point)) | 2920 (buffer-substring (progn (beginning-of-line) (point)) |
2950 (point))) | 2941 (point))) |
2951 ;; Replace the newline and other whitespace with `...'. | 2942 ;; Replace the newline and other whitespace with `...'. |
2952 "..." | 2943 "..." |
2953 (buffer-substring blinkpos (1+ blinkpos))) | 2944 (buffer-substring blinkpos (1+ blinkpos))) |
2954 ;; There is nothing to show except the char itself. | 2945 ;; There is nothing to show except the char itself. |
2955 (buffer-substring blinkpos (1+ blinkpos))))))))) | 2946 (buffer-substring blinkpos (1+ blinkpos)))))))) |
2956 (cond (mismatch | 2947 (cond (mismatch |
2957 (display-message 'no-log "Mismatched parentheses")) | 2948 (display-message 'no-log "Mismatched parentheses")) |
2958 ((not blink-matching-paren-distance) | 2949 ((not blink-matching-paren-distance) |
2959 (display-message 'no-log "Unmatched parenthesis")))))))) | 2950 (display-message 'no-log "Unmatched parenthesis")))))))) |
2960 | 2951 |
3498 "Default value of log-message-filter-function. | 3489 "Default value of log-message-filter-function. |
3499 Mesages whose text matches one of the log-message-ignore-regexps | 3490 Mesages whose text matches one of the log-message-ignore-regexps |
3500 or whose label appears in log-message-ignore-labels are not saved." | 3491 or whose label appears in log-message-ignore-labels are not saved." |
3501 (let ((r log-message-ignore-regexps) | 3492 (let ((r log-message-ignore-regexps) |
3502 (ok (not (memq label log-message-ignore-labels)))) | 3493 (ok (not (memq label log-message-ignore-labels)))) |
3503 (while (and r ok) | 3494 (save-match-data |
3504 (if (save-match-data (string-match (car r) message)) | 3495 (while (and r ok) |
3496 (when (string-match (car r) message) | |
3505 (setq ok nil)) | 3497 (setq ok nil)) |
3506 (setq r (cdr r))) | 3498 (setq r (cdr r)))) |
3507 ok)) | 3499 ok)) |
3508 | 3500 |
3509 (defun log-message-filter-errors-only (label message) | 3501 (defun log-message-filter-errors-only (label message) |
3510 "For use as the log-message-filter-function. Only logs error messages." | 3502 "For use as the log-message-filter-function. Only logs error messages." |
3511 (eq label 'error)) | 3503 (eq label 'error)) |
3513 (defun log-message (label message) | 3505 (defun log-message (label message) |
3514 "Stuff a copy of the message into the \" *Message-Log*\" buffer, | 3506 "Stuff a copy of the message into the \" *Message-Log*\" buffer, |
3515 if it satisfies the log-message-filter-function. | 3507 if it satisfies the log-message-filter-function. |
3516 | 3508 |
3517 For use on remove-message-hook." | 3509 For use on remove-message-hook." |
3518 (if (and (not noninteractive) | 3510 (when (and (not noninteractive) |
3519 (funcall log-message-filter-function label message)) | 3511 (funcall log-message-filter-function label message)) |
3520 (save-excursion | 3512 (with-current-buffer (get-buffer-create " *Message-Log*") |
3521 (set-buffer (get-buffer-create " *Message-Log*")) | 3513 (goto-char (point-max)) |
3522 (goto-char (point-max)) | 3514 ;; (insert (concat (upcase (symbol-name label)) ": " message "\n")) |
3523 ;; (insert (concat (upcase (symbol-name label)) ": " message "\n")) | 3515 (insert message "\n") |
3524 (insert message "\n") | 3516 (when (> (point-max) (max log-message-max-size (point-min))) |
3525 (if (> (point-max) (max log-message-max-size (point-min))) | 3517 ;; trim log to ~90% of max size |
3526 (progn | 3518 (goto-char (max (- (point-max) |
3527 ;; trim log to ~90% of max size | 3519 (truncate (* 0.9 log-message-max-size))) |
3528 (goto-char (max (- (point-max) | 3520 (point-min))) |
3529 (truncate (* 0.9 log-message-max-size))) | 3521 (forward-line 1) |
3530 (point-min))) | 3522 (delete-region (point-min) (point)))))) |
3531 (forward-line 1) | |
3532 (delete-region (point-min) (point))))))) | |
3533 | 3523 |
3534 (defun message-displayed-p (&optional return-string frame) | 3524 (defun message-displayed-p (&optional return-string frame) |
3535 "Return a non-nil value if a message is presently displayed in the\n\ | 3525 "Return a non-nil value if a message is presently displayed in the\n\ |
3536 minibuffer's echo area. If optional argument RETURN-STRING is non-nil,\n\ | 3526 minibuffer's echo area. If optional argument RETURN-STRING is non-nil,\n\ |
3537 return a string containing the message, otherwise just return t." | 3527 return a string containing the message, otherwise just return t." |
3567 (if clear-stream | 3557 (if clear-stream |
3568 (send-string-to-terminal ?\n stdout-p)) | 3558 (send-string-to-terminal ?\n stdout-p)) |
3569 (if no-restore | 3559 (if no-restore |
3570 nil ; just preparing to put another msg up | 3560 nil ; just preparing to put another msg up |
3571 (if message-stack | 3561 (if message-stack |
3572 (let ((oldmsg (cdr (car message-stack)))) | 3562 (let ((oldmsg (cdr (car message-stack)))) |
3573 (raw-append-message oldmsg frame stdout-p) | 3563 (raw-append-message oldmsg frame stdout-p) |
3574 oldmsg) | 3564 oldmsg) |
3575 ;; ### should we (redisplay-echo-area) here? messes some things up. | 3565 ;; ### should we (redisplay-echo-area) here? messes some things up. |
3576 nil)))) | 3566 nil)))) |
3577 | 3567 |
3596 (while log | 3586 (while log |
3597 (condition-case e | 3587 (condition-case e |
3598 (run-hook-with-args 'remove-message-hook | 3588 (run-hook-with-args 'remove-message-hook |
3599 (car (car log)) (cdr (car log))) | 3589 (car (car log)) (cdr (car log))) |
3600 (error (setq remove-message-hook nil) | 3590 (error (setq remove-message-hook nil) |
3601 (message "remove-message-hook error: %s" e) | 3591 (lwarn 'message-log 'warning |
3602 (sit-for 2) | 3592 "Error caught in `remove-message-hook': %s" |
3593 (error-message-string e)) | |
3603 (let ((inhibit-read-only t)) | 3594 (let ((inhibit-read-only t)) |
3604 (erase-buffer (get-buffer " *Echo Area*"))) | 3595 (erase-buffer (get-buffer " *Echo Area*"))) |
3605 (signal (car e) (cdr e)))) | 3596 (signal (car e) (cdr e)))) |
3606 (setq log (cdr log))))) | 3597 (setq log (cdr log))))) |
3607 | 3598 |
3617 ;; really append the message to the echo area. no fiddling with message-stack. | 3608 ;; really append the message to the echo area. no fiddling with message-stack. |
3618 (defun raw-append-message (message &optional frame stdout-p) | 3609 (defun raw-append-message (message &optional frame stdout-p) |
3619 (if (eq message "") nil | 3610 (if (eq message "") nil |
3620 (let ((buffer (get-buffer " *Echo Area*")) | 3611 (let ((buffer (get-buffer " *Echo Area*")) |
3621 (zmacs-region-stays zmacs-region-stays)) ; preserve from change | 3612 (zmacs-region-stays zmacs-region-stays)) ; preserve from change |
3622 (save-excursion | 3613 (with-current-buffer buffer |
3623 (set-buffer buffer) | |
3624 (let ((inhibit-read-only t)) | 3614 (let ((inhibit-read-only t)) |
3625 (insert message))) | 3615 (insert message))) |
3626 ;; Conditionalizing on the device type in this way is not that clean, | 3616 ;; Conditionalizing on the device type in this way is not that clean, |
3627 ;; but neither is having a device method, as I originally implemented | 3617 ;; but neither is having a device method, as I originally implemented |
3628 ;; it: all non-stream devices behave in the same way. Perhaps | 3618 ;; it: all non-stream devices behave in the same way. Perhaps |
3669 minibuffer contents show." | 3659 minibuffer contents show." |
3670 ;; questionable junk in the C code | 3660 ;; questionable junk in the C code |
3671 ;; (if (framep default-minibuffer-frame) | 3661 ;; (if (framep default-minibuffer-frame) |
3672 ;; (make-frame-visible default-minibuffer-frame)) | 3662 ;; (make-frame-visible default-minibuffer-frame)) |
3673 (if (and (null fmt) (null args)) | 3663 (if (and (null fmt) (null args)) |
3674 (progn | 3664 (prog1 nil |
3675 (clear-message nil) | 3665 (clear-message nil)) |
3676 nil) | |
3677 (let ((str (apply 'format fmt args))) | 3666 (let ((str (apply 'format fmt args))) |
3678 (display-message 'message str) | 3667 (display-message 'message str) |
3679 str))) | 3668 str))) |
3669 | |
3670 (defun lmessage (label fmt &rest args) | |
3671 "Print a one-line message at the bottom of the frame. | |
3672 First argument LABEL is an identifier for this message. The rest of the | |
3673 arguments are the same as to `format'. | |
3674 | |
3675 See `display-message' for a list of standard labels." | |
3676 (if (and (null fmt) (null args)) | |
3677 (prog1 nil | |
3678 (clear-message label nil)) | |
3679 (let ((str (apply 'format fmt args))) | |
3680 (display-message label str) | |
3681 str))) | |
3682 | |
3680 | 3683 |
3681 ;;;;;; | 3684 ;;;;;; |
3682 ;;;;;; warning stuff | 3685 ;;;;;; warning stuff |
3683 ;;;;;; | 3686 ;;;;;; |
3684 | 3687 |
3784 (defun display-warning (class message &optional level) | 3787 (defun display-warning (class message &optional level) |
3785 "Display a warning message. | 3788 "Display a warning message. |
3786 CLASS should be a symbol describing what sort of warning this is, such | 3789 CLASS should be a symbol describing what sort of warning this is, such |
3787 as `resource' or `key-mapping'. A list of such symbols is also | 3790 as `resource' or `key-mapping'. A list of such symbols is also |
3788 accepted. (Individual classes can be suppressed; see | 3791 accepted. (Individual classes can be suppressed; see |
3789 `display-warning-suppressed-classes'.) Optional argument LEVEL can | 3792 `display-warning-suppressed-classes'.) Optional argument LEVEL can |
3790 be used to specify a priority for the warning, other than default priority | 3793 be used to specify a priority for the warning, other than default priority |
3791 `warning'. (See `display-warning-minimum-level'). The message is | 3794 `warning'. (See `display-warning-minimum-level'). The message is |
3792 inserted into the *Warnings* buffer, which is made visible at appropriate | 3795 inserted into the *Warnings* buffer, which is made visible at appropriate |
3793 times." | 3796 times." |
3794 (or level (setq level 'warning)) | 3797 (or level (setq level 'warning)) |
3804 (if (< level-num (cdr (assq log-warning-minimum-level | 3807 (if (< level-num (cdr (assq log-warning-minimum-level |
3805 warning-level-alist))) | 3808 warning-level-alist))) |
3806 (throw 'ignored nil)) | 3809 (throw 'ignored nil)) |
3807 (if (intersection class log-warning-suppressed-classes) | 3810 (if (intersection class log-warning-suppressed-classes) |
3808 (throw 'ignored nil)) | 3811 (throw 'ignored nil)) |
3809 | 3812 |
3810 (if (< level-num (cdr (assq display-warning-minimum-level | 3813 (if (< level-num (cdr (assq display-warning-minimum-level |
3811 warning-level-alist))) | 3814 warning-level-alist))) |
3812 (setq display-p nil)) | 3815 (setq display-p nil)) |
3813 (if (and display-p | 3816 (if (and display-p |
3814 (intersection class display-warning-suppressed-classes)) | 3817 (intersection class display-warning-suppressed-classes)) |
3815 (setq display-p nil)) | 3818 (setq display-p nil)) |
3816 (save-excursion | 3819 (let ((buffer (get-buffer-create "*Warnings*"))) |
3817 (let ((buffer (get-buffer-create "*Warnings*"))) | 3820 (when display-p |
3818 (when display-p | 3821 ;; The C code looks at display-warning-tick to determine |
3819 ;; The C code looks at display-warning-tick to determine | 3822 ;; when it should call `display-warning-buffer'. Change it |
3820 ;; when it should call `display-warning-buffer'. Change it | 3823 ;; to get the C code's attention. |
3821 ;; to get the C code's attention. | 3824 (incf display-warning-tick)) |
3822 (incf display-warning-tick)) | 3825 (with-current-buffer buffer |
3823 (set-buffer buffer) | |
3824 (goto-char (point-max)) | 3826 (goto-char (point-max)) |
3825 (setq warning-count (1+ warning-count)) | 3827 (incf warning-count) |
3826 (princ (format "(%d) (%s/%s) " | 3828 (princ (format "(%d) (%s/%s) " |
3827 warning-count | 3829 warning-count |
3828 (mapconcat 'symbol-name class ",") | 3830 (mapconcat 'symbol-name class ",") |
3829 level) buffer) | 3831 level) |
3832 buffer) | |
3830 (princ message buffer) | 3833 (princ message buffer) |
3831 (terpri buffer) | 3834 (terpri buffer) |
3832 (terpri buffer))))))) | 3835 (terpri buffer))))))) |
3833 | 3836 |
3834 (defun warn (&rest args) | 3837 (defun warn (&rest args) |
3836 The message is constructed by passing all args to `format'. The message | 3839 The message is constructed by passing all args to `format'. The message |
3837 is placed in the *Warnings* buffer, which will be popped up at the next | 3840 is placed in the *Warnings* buffer, which will be popped up at the next |
3838 redisplay. The class of the warning is `warning'. See also | 3841 redisplay. The class of the warning is `warning'. See also |
3839 `display-warning'." | 3842 `display-warning'." |
3840 (display-warning 'warning (apply 'format args))) | 3843 (display-warning 'warning (apply 'format args))) |
3844 | |
3845 (defun lwarn (class level &rest args) | |
3846 "Display a labeled warning message. | |
3847 CLASS should be a symbol describing what sort of warning this is, such | |
3848 as `resource' or `key-mapping'. A list of such symbols is also | |
3849 accepted. (Individual classes can be suppressed; see | |
3850 `display-warning-suppressed-classes'.) If non-nil, LEVEL can be used | |
3851 to specify a priority for the warning, other than default priority | |
3852 `warning'. (See `display-warning-minimum-level'). The message is | |
3853 inserted into the *Warnings* buffer, which is made visible at appropriate | |
3854 times. | |
3855 | |
3856 The rest of the arguments are passed to `format'." | |
3857 (display-warning class (apply 'format args) | |
3858 (or level 'warning))) | |
3841 | 3859 |
3842 (defvar warning-marker nil) | 3860 (defvar warning-marker nil) |
3843 | 3861 |
3844 ;; When this function is called by the C code, all non-local exits are | 3862 ;; When this function is called by the C code, all non-local exits are |
3845 ;; trapped and C-g is inhibited; therefore, it would be a very, very | 3863 ;; trapped and C-g is inhibited; therefore, it would be a very, very |