comparison lisp/simple.el @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 966663fcf606
children 90d73dddcdc4
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
32 ;; A grab-bag of basic XEmacs commands not specifically related to some 32 ;; A grab-bag of basic XEmacs commands not specifically related to some
33 ;; major mode or to file-handling. 33 ;; major mode or to file-handling.
34 34
35 ;; Changes for zmacs-style active-regions: 35 ;; Changes for zmacs-style active-regions:
36 ;; 36 ;;
37 ;; beginning-of-buffer, end-of-buffer, count-lines-region, 37 ;; beginning-of-buffer, end-of-buffer, count-lines-region,
38 ;; count-lines-buffer, what-line, what-cursor-position, set-goal-column, 38 ;; count-lines-buffer, what-line, what-cursor-position, set-goal-column,
39 ;; set-fill-column, prefix-arg-internal, and line-move (which is used by 39 ;; set-fill-column, prefix-arg-internal, and line-move (which is used by
40 ;; next-line and previous-line) set zmacs-region-stays to t, so that they 40 ;; next-line and previous-line) set zmacs-region-stays to t, so that they
41 ;; don't affect the current region-hilighting state. 41 ;; don't affect the current region-hilighting state.
42 ;; 42 ;;
43 ;; mark-whole-buffer, mark-word, exchange-point-and-mark, and 43 ;; mark-whole-buffer, mark-word, exchange-point-and-mark, and
44 ;; set-mark-command (without an argument) call zmacs-activate-region. 44 ;; set-mark-command (without an argument) call zmacs-activate-region.
45 ;; 45 ;;
46 ;; mark takes an optional arg like the new Fmark_marker() does. When 46 ;; mark takes an optional arg like the new Fmark_marker() does. When
47 ;; the region is not active, mark returns nil unless the optional arg is true. 47 ;; the region is not active, mark returns nil unless the optional arg is true.
48 ;; 48 ;;
49 ;; push-mark, pop-mark, exchange-point-and-mark, and set-marker, and 49 ;; push-mark, pop-mark, exchange-point-and-mark, and set-marker, and
50 ;; set-mark-command use (mark t) so that they can access the mark whether 50 ;; set-mark-command use (mark t) so that they can access the mark whether
51 ;; the region is active or not. 51 ;; the region is active or not.
52 ;; 52 ;;
53 ;; shell-command, shell-command-on-region, yank, and yank-pop (which all 53 ;; shell-command, shell-command-on-region, yank, and yank-pop (which all
54 ;; push a mark) have been altered to call exchange-point-and-mark with an 54 ;; push a mark) have been altered to call exchange-point-and-mark with an
55 ;; argument, meaning "don't activate the region". These commands only use 55 ;; argument, meaning "don't activate the region". These commands only use
56 ;; exchange-point-and-mark to position the newly-pushed mark correctly, so 56 ;; exchange-point-and-mark to position the newly-pushed mark correctly, so
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 ;; #### Does this have any relevance in XEmacs?
109 (let ((flag (and (not (bobp)) 109 (let ((flag (and (not (bobp))
110 (bolp) 110 (bolp)
111 ;; Make sure the newline before point isn't intangible. 111 ;; Make sure the newline before point isn't intangible.
112 (not (get-char-property (1- (point)) 'intangible)) 112 (not (get-char-property (1- (point)) 'intangible))
113 ;; Make sure the newline before point isn't read-only. 113 ;; Make sure the newline before point isn't read-only.
114 (not (get-char-property (1- (point)) 'read-only)) 114 (not (get-char-property (1- (point)) 'read-only))
117 ;; This should probably also test for the previous char 117 ;; This should probably also test for the previous char
118 ;; being the *last* character too. 118 ;; being the *last* character too.
119 (not (get-char-property (1- (point)) 'end-open)) 119 (not (get-char-property (1- (point)) 'end-open))
120 ;; Make sure the newline before point has the same 120 ;; Make sure the newline before point has the same
121 ;; properties as the char before it (if any). 121 ;; properties as the char before it (if any).
122 (< (or (previous-extent-change (point)) -2) 122 (< (or (previous-extent-change (point)) -2)
123 (- (point) 2)))) 123 (- (point) 2))))
124 (was-page-start (and (bolp) 124 (was-page-start (and (bolp)
125 (looking-at page-delimiter))) 125 (looking-at page-delimiter)))
126 (beforepos (point))) 126 (beforepos (point)))
127 (if flag (backward-char 1)) 127 (if flag (backward-char 1))
1045 ;; [... code snipped ...] 1045 ;; [... code snipped ...]
1046 1046
1047 (defcustom kill-hooks nil 1047 (defcustom kill-hooks nil
1048 "*Functions run when something is added to the XEmacs kill ring. 1048 "*Functions run when something is added to the XEmacs kill ring.
1049 These functions are called with one argument, the string most recently 1049 These functions are called with one argument, the string most recently
1050 cut or copied. You can use this to, for example, make the most recent 1050 cut or copied. You can use this to, for example, make the most recent
1051 kill become the X Clipboard selection." 1051 kill become the X Clipboard selection."
1052 :type 'hook 1052 :type 'hook
1053 :group 'killing) 1053 :group 'killing)
1054 1054
1055 ;;; `kill-hooks' seems not sufficient because 1055 ;;; `kill-hooks' seems not sufficient because
1142 (defun current-kill (n &optional do-not-move) 1142 (defun current-kill (n &optional do-not-move)
1143 "Rotate the yanking point by N places, and then return that kill. 1143 "Rotate the yanking point by N places, and then return that kill.
1144 If N is zero, `interprogram-paste-function' is set, and calling it 1144 If N is zero, `interprogram-paste-function' is set, and calling it
1145 returns a string, then that string is added to the front of the 1145 returns a string, then that string is added to the front of the
1146 kill ring and returned as the latest kill. 1146 kill ring and returned as the latest kill.
1147 If optional arg DO-NOT-MOVE is non-nil, then don't actually move the 1147 If optional arg DO-NOT-MOVE is non-nil, then don't actually move the
1148 yanking point\; just return the Nth kill forward." 1148 yanking point\; just return the Nth kill forward."
1149 (let ((interprogram-paste (and (= n 0) 1149 (let ((interprogram-paste (and (= n 0)
1150 interprogram-paste-function 1150 interprogram-paste-function
1151 (funcall interprogram-paste-function)))) 1151 (funcall interprogram-paste-function))))
1152 (if interprogram-paste 1152 (if interprogram-paste
1394 BUFFER may be a buffer or a buffer name." 1394 BUFFER may be a buffer or a buffer name."
1395 (interactive 1395 (interactive
1396 (list 1396 (list
1397 (progn 1397 (progn
1398 (barf-if-buffer-read-only) 1398 (barf-if-buffer-read-only)
1399 (read-buffer "Insert buffer: " 1399 (read-buffer "Insert buffer: "
1400 ;; XEmacs: we have different args 1400 ;; XEmacs: we have different args
1401 (other-buffer (current-buffer) nil t) 1401 (other-buffer (current-buffer) nil t)
1402 t)))) 1402 t))))
1403 (or (bufferp buffer) 1403 (or (bufferp buffer)
1404 (setq buffer (get-buffer buffer))) 1404 (setq buffer (get-buffer buffer)))
2168 This function is called with no args with point at the beginning of 2168 This function is called with no args with point at the beginning of
2169 the comment's starting delimiter.") 2169 the comment's starting delimiter.")
2170 2170
2171 (defconst comment-indent-function 2171 (defconst comment-indent-function
2172 ;; XEmacs - add at least one space after the end of the text on the 2172 ;; XEmacs - add at least one space after the end of the text on the
2173 ;; current line... 2173 ;; current line...
2174 (lambda () 2174 (lambda ()
2175 (save-excursion 2175 (save-excursion
2176 (beginning-of-line) 2176 (beginning-of-line)
2177 (let ((eol (save-excursion (end-of-line) (point)))) 2177 (let ((eol (save-excursion (end-of-line) (point))))
2178 (and comment-start-skip 2178 (and comment-start-skip
2179 (re-search-forward comment-start-skip eol t) 2179 (re-search-forward comment-start-skip eol t)
2180 (setq eol (match-beginning 0))) 2180 (setq eol (match-beginning 0)))
2181 (goto-char eol) 2181 (goto-char eol)
2236 ;; If that's different from current, change it. 2236 ;; If that's different from current, change it.
2237 (skip-chars-backward " \t") 2237 (skip-chars-backward " \t")
2238 (delete-region (point) begpos) 2238 (delete-region (point) begpos)
2239 (indent-to indent)) 2239 (indent-to indent))
2240 ;; An existing comment? 2240 ;; An existing comment?
2241 (if cpos 2241 (if cpos
2242 (progn (goto-char cpos) 2242 (progn (goto-char cpos)
2243 (set-marker cpos nil)) 2243 (set-marker cpos nil))
2244 ;; No, insert one. 2244 ;; No, insert one.
2245 (insert starter) 2245 (insert starter)
2246 (save-excursion 2246 (save-excursion
2592 ; (fill-prefix fill-prefix)) 2592 ; (fill-prefix fill-prefix))
2593 ; (if (or (not (setq justify (current-justification))) 2593 ; (if (or (not (setq justify (current-justification)))
2594 ; (null (setq fc (current-fill-column))) 2594 ; (null (setq fc (current-fill-column)))
2595 ; (and (eq justify 'left) 2595 ; (and (eq justify 'left)
2596 ; (<= (current-column) fc)) 2596 ; (<= (current-column) fc))
2597 ; (save-excursion (beginning-of-line) 2597 ; (save-excursion (beginning-of-line)
2598 ; ;; (setq bol (point)) 2598 ; ;; (setq bol (point))
2599 ; (and auto-fill-inhibit-regexp 2599 ; (and auto-fill-inhibit-regexp
2600 ; (looking-at auto-fill-inhibit-regexp)))) 2600 ; (looking-at auto-fill-inhibit-regexp))))
2601 ; nil ;; Auto-filling not required 2601 ; nil ;; Auto-filling not required
2602 ; (if (memq justify '(full center right)) 2602 ; (if (memq justify '(full center right))
2663 ; (save-excursion 2663 ; (save-excursion
2664 ; (goto-char fill-point) 2664 ; (goto-char fill-point)
2665 ; (funcall comment-line-break-function t))) 2665 ; (funcall comment-line-break-function t)))
2666 ; ;; Now do justification, if required 2666 ; ;; Now do justification, if required
2667 ; (if (not (eq justify 'left)) 2667 ; (if (not (eq justify 'left))
2668 ; (save-excursion 2668 ; (save-excursion
2669 ; (end-of-line 0) 2669 ; (end-of-line 0)
2670 ; (justify-current-line justify nil t))) 2670 ; (justify-current-line justify nil t)))
2671 ; ;; If making the new line didn't reduce the hpos of 2671 ; ;; If making the new line didn't reduce the hpos of
2672 ; ;; the end of the line, then give up now; 2672 ; ;; the end of the line, then give up now;
2673 ; ;; trying again will not help. 2673 ; ;; trying again will not help.
2740 If you want to continue one comment across several lines, use \\[newline-and-indent]. 2740 If you want to continue one comment across several lines, use \\[newline-and-indent].
2741 2741
2742 If a fill column is specified, it overrides the use of the comment column 2742 If a fill column is specified, it overrides the use of the comment column
2743 or comment indentation. 2743 or comment indentation.
2744 2744
2745 The inserted newline is marked hard if `use-hard-newlines' is true, 2745 The inserted newline is marked hard if `use-hard-newlines' is true,
2746 unless optional argument SOFT is non-nil." 2746 unless optional argument SOFT is non-nil."
2747 (interactive) 2747 (interactive)
2748 (let (comcol comstart) 2748 (let (comcol comstart)
2749 (skip-chars-backward " \t") 2749 (skip-chars-backward " \t")
2750 ;; 97/3/14 jhod: Kinsoku processing 2750 ;; 97/3/14 jhod: Kinsoku processing
2759 (indent-to-left-margin) 2759 (indent-to-left-margin)
2760 (insert fill-prefix)) 2760 (insert fill-prefix))
2761 ;; #### - Eric Eide reverts to v18 semantics for this function in 2761 ;; #### - Eric Eide reverts to v18 semantics for this function in
2762 ;; fa-extras, which I'm not gonna do. His changes are to (1) execute 2762 ;; fa-extras, which I'm not gonna do. His changes are to (1) execute
2763 ;; the save-excursion below unconditionally, and (2) uncomment the check 2763 ;; the save-excursion below unconditionally, and (2) uncomment the check
2764 ;; for (not comment-multi-line) further below. --Stig 2764 ;; for (not comment-multi-line) further below. --Stig
2765 ;;### jhod: probably need to fix this for kinsoku processing 2765 ;;### jhod: probably need to fix this for kinsoku processing
2766 (if (not comment-multi-line) 2766 (if (not comment-multi-line)
2767 (save-excursion 2767 (save-excursion
2768 (if (and comment-start-skip 2768 (if (and comment-start-skip
2769 (let ((opoint (point))) 2769 (let ((opoint (point)))
2838 (princ "." t)) 2838 (princ "." t))
2839 2839
2840 ;; XEmacs 2840 ;; XEmacs
2841 (defun nuke-selective-display () 2841 (defun nuke-selective-display ()
2842 "Ensure that the buffer is not in selective-display mode. 2842 "Ensure that the buffer is not in selective-display mode.
2843 If `selective-display' is t, then restore the buffer text to it's original 2843 If `selective-display' is t, then restore the buffer text to its original
2844 state before disabling selective display." 2844 state before disabling selective display."
2845 ;; by Stig@hackvan.com 2845 ;; by Stig@hackvan.com
2846 (interactive) 2846 (interactive)
2847 (and (eq t selective-display) 2847 (and (eq t selective-display)
2848 (save-excursion 2848 (save-excursion
2849 (save-restriction 2849 (save-restriction
3219 If VARIABLE has a `variable-interactive' property, that is used as if 3219 If VARIABLE has a `variable-interactive' property, that is used as if
3220 it were the arg to `interactive' (which see) to interactively read the value." 3220 it were the arg to `interactive' (which see) to interactively read the value."
3221 (interactive 3221 (interactive
3222 (let* ((var (read-variable "Set variable: ")) 3222 (let* ((var (read-variable "Set variable: "))
3223 ;; #### - yucky code replication here. This should use something 3223 ;; #### - yucky code replication here. This should use something
3224 ;; from help.el or hyper-apropos.el 3224 ;; from help.el or hyper-apropos.el
3225 (minibuffer-help-form 3225 (minibuffer-help-form
3226 '(funcall myhelp)) 3226 '(funcall myhelp))
3227 (myhelp 3227 (myhelp
3228 #'(lambda () 3228 #'(lambda ()
3229 (with-output-to-temp-buffer "*Help*" 3229 (with-output-to-temp-buffer "*Help*"
3246 ;; as an interactive spec for prompting. 3246 ;; as an interactive spec for prompting.
3247 (call-interactively (list 'lambda '(arg) 3247 (call-interactively (list 'lambda '(arg)
3248 (list 'interactive prop) 3248 (list 'interactive prop)
3249 'arg)) 3249 'arg))
3250 (eval-minibuffer (format "Set %s to value: " var))))))) 3250 (eval-minibuffer (format "Set %s to value: " var)))))))
3251 (if (specifierp (symbol-value var)) 3251 (if (and (boundp var) (specifierp (symbol-value var)))
3252 (set-specifier (symbol-value var) val) 3252 (set-specifier (symbol-value var) val)
3253 (set var val))) 3253 (set var val)))
3254 3254
3255 ;; XEmacs 3255 ;; XEmacs
3256 (defun activate-region () 3256 (defun activate-region ()
3260 (interactive) 3260 (interactive)
3261 (and zmacs-regions (zmacs-activate-region))) 3261 (and zmacs-regions (zmacs-activate-region)))
3262 3262
3263 ;; XEmacs 3263 ;; XEmacs
3264 (defsubst region-exists-p () 3264 (defsubst region-exists-p ()
3265 "Non-nil iff the region exists. 3265 "Return t if the region exists.
3266 If active regions are in use (i.e. `zmacs-regions' is true), this means that 3266 If active regions are in use (i.e. `zmacs-regions' is true), this means that
3267 the region is active. Otherwise, this means that the user has pushed 3267 the region is active. Otherwise, this means that the user has pushed
3268 a mark in this buffer at some point in the past. 3268 a mark in this buffer at some point in the past.
3269 The functions `region-beginning' and `region-end' can be used to find the 3269 The functions `region-beginning' and `region-end' can be used to find the
3270 limits of the region." 3270 limits of the region."
3271 (not (null (mark)))) 3271 (not (null (mark))))
3272 3272
3273 ;; XEmacs 3273 ;; XEmacs
3274 (defun region-active-p () 3274 (defun region-active-p ()
3275 "Non-nil iff the region is active. 3275 "Return non-nil if the region is active.
3276 If `zmacs-regions' is true, this is equivalent to `region-exists-p'. 3276 If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
3277 Otherwise, this function always returns false." 3277 Otherwise, this function always returns false."
3278 (and zmacs-regions zmacs-region-extent)) 3278 (and zmacs-regions zmacs-region-extent))
3279 3279
3280 ;; A bunch of stuff was moved elsewhere: 3280 ;; A bunch of stuff was moved elsewhere:
3495 (send-string-to-terminal "\n")) 3495 (send-string-to-terminal "\n"))
3496 3496
3497 (defvar message-stack nil 3497 (defvar message-stack nil
3498 "An alist of label/string pairs representing active echo-area messages. 3498 "An alist of label/string pairs representing active echo-area messages.
3499 The first element in the list is currently displayed in the echo area. 3499 The first element in the list is currently displayed in the echo area.
3500 Do not modify this directly--use the `message' or 3500 Do not modify this directly--use the `message' or
3501 `display-message'/`clear-message' functions.") 3501 `display-message'/`clear-message' functions.")
3502 3502
3503 (defvar remove-message-hook 'log-message 3503 (defvar remove-message-hook 'log-message
3504 "A function or list of functions to be called when a message is removed 3504 "A function or list of functions to be called when a message is removed
3505 from the echo area at the bottom of the frame. The label of the removed 3505 from the echo area at the bottom of the frame. The label of the removed
3549 ;; "^Deleting article " 3549 ;; "^Deleting article "
3550 ;; W3 3550 ;; W3
3551 ;; "^Parsed [0-9]+ of [0-9]+ ([0-9]+%)" 3551 ;; "^Parsed [0-9]+ of [0-9]+ ([0-9]+%)"
3552 ) 3552 )
3553 "List of regular expressions matching messages which shouldn't be logged. 3553 "List of regular expressions matching messages which shouldn't be logged.
3554 See `log-message'. 3554 See `log-message'.
3555 3555
3556 Ideally, packages which generate messages which might need to be ignored 3556 Ideally, packages which generate messages which might need to be ignored
3557 should label them with 'progress, 'prompt, or 'no-log, so they can be 3557 should label them with 'progress, 'prompt, or 'no-log, so they can be
3558 filtered by the log-message-ignore-labels." 3558 filtered by the log-message-ignore-labels."
3559 :type '(repeat regexp) 3559 :type '(repeat regexp)
3560 :group 'log-message) 3560 :group 'log-message)
3561 3561
3562 (defcustom log-message-ignore-labels 3562 (defcustom log-message-ignore-labels
3563 '(help-echo command progress prompt no-log garbage-collecting auto-saving) 3563 '(help-echo command progress prompt no-log garbage-collecting auto-saving)
3564 "List of symbols indicating labels of messages which shouldn't be logged. 3564 "List of symbols indicating labels of messages which shouldn't be logged.
3565 See `display-message' for some common labels. See also `log-message'." 3565 See `display-message' for some common labels. See also `log-message'."
3566 :type '(repeat (symbol :tag "Label")) 3566 :type '(repeat (symbol :tag "Label"))
3567 :group 'log-message) 3567 :group 'log-message)
3572 "Show the \" *Message-Log*\" buffer, which contains old messages and errors." 3572 "Show the \" *Message-Log*\" buffer, which contains old messages and errors."
3573 (interactive) 3573 (interactive)
3574 (pop-to-buffer (get-buffer-create " *Message-Log*"))) 3574 (pop-to-buffer (get-buffer-create " *Message-Log*")))
3575 3575
3576 (defvar log-message-filter-function 'log-message-filter 3576 (defvar log-message-filter-function 'log-message-filter
3577 "Value must be a function of two arguments: a symbol (label) and 3577 "Value must be a function of two arguments: a symbol (label) and
3578 a string (message). It should return non-nil to indicate a message 3578 a string (message). It should return non-nil to indicate a message
3579 should be logged. Possible values include 'log-message-filter and 3579 should be logged. Possible values include 'log-message-filter and
3580 'log-message-filter-errors-only.") 3580 'log-message-filter-errors-only.")
3581 3581
3582 (defun log-message-filter (label message) 3582 (defun log-message-filter (label message)
3736 * no-log messages that should never be logged" 3736 * no-log messages that should never be logged"
3737 (clear-message label frame stdout-p t) 3737 (clear-message label frame stdout-p t)
3738 (append-message label message frame stdout-p)) 3738 (append-message label message frame stdout-p))
3739 3739
3740 (defun current-message (&optional frame) 3740 (defun current-message (&optional frame)
3741 "Returns the current message in the echo area, or nil. 3741 "Return the current message in the echo area, or nil.
3742 The FRAME argument is currently unused." 3742 The FRAME argument is currently unused."
3743 (cdr (car message-stack))) 3743 (cdr (car message-stack)))
3744 3744
3745 ;;; may eventually be frame-dependent 3745 ;;; may eventually be frame-dependent
3746 (defun current-message-label (&optional frame) 3746 (defun current-message-label (&optional frame)