comparison lisp/simple.el @ 99654:ade78ac09095

* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo) (undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command) (exchange-point-and-mark, set-goal-column, kill-line, backward-word) (kill-word, backward-kill-word): Doc fixes. (shell-command, repeat-complex-command): Reflow docstrings. (zap-to-char, pop-to-mark-command): Fix typos in docstrings.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 17 Nov 2008 01:54:02 +0000
parents 7f30197e15d8
children 3a08b596c63b
comparison
equal deleted inserted replaced
99653:d7ac626296a1 99654:ade78ac09095
666 (indent-according-to-mode))) 666 (indent-according-to-mode)))
667 667
668 (defun quoted-insert (arg) 668 (defun quoted-insert (arg)
669 "Read next input character and insert it. 669 "Read next input character and insert it.
670 This is useful for inserting control characters. 670 This is useful for inserting control characters.
671 With argument, insert ARG copies of the character.
671 672
672 If the first character you type after this command is an octal digit, 673 If the first character you type after this command is an octal digit,
673 you should type a sequence of octal digits which specify a character code. 674 you should type a sequence of octal digits which specify a character code.
674 Any nondigit terminates the sequence. If the terminator is a RET, 675 Any nondigit terminates the sequence. If the terminator is a RET,
675 it is discarded; any other terminator is used itself as input. 676 it is discarded; any other terminator is used itself as input.
1149 (defun repeat-complex-command (arg) 1150 (defun repeat-complex-command (arg)
1150 "Edit and re-evaluate last complex command, or ARGth from last. 1151 "Edit and re-evaluate last complex command, or ARGth from last.
1151 A complex command is one which used the minibuffer. 1152 A complex command is one which used the minibuffer.
1152 The command is placed in the minibuffer as a Lisp form for editing. 1153 The command is placed in the minibuffer as a Lisp form for editing.
1153 The result is executed, repeating the command as changed. 1154 The result is executed, repeating the command as changed.
1154 If the command has been changed or is not the most recent previous command 1155 If the command has been changed or is not the most recent previous
1155 it is added to the front of the command history. 1156 command it is added to the front of the command history.
1156 You can use the minibuffer history commands \\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element] 1157 You can use the minibuffer history commands \
1158 \\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element]
1157 to get different commands to edit and resubmit." 1159 to get different commands to edit and resubmit."
1158 (interactive "p") 1160 (interactive "p")
1159 (let ((elt (nth (1- arg) command-history)) 1161 (let ((elt (nth (1- arg) command-history))
1160 newcmd) 1162 newcmd)
1161 (if elt 1163 (if elt
1579 `(lambda (cmd) 1581 `(lambda (cmd)
1580 (minibuffer-history-isearch-pop-state cmd ,minibuffer-history-position))) 1582 (minibuffer-history-isearch-pop-state cmd ,minibuffer-history-position)))
1581 1583
1582 (defun minibuffer-history-isearch-pop-state (cmd hist-pos) 1584 (defun minibuffer-history-isearch-pop-state (cmd hist-pos)
1583 "Restore the minibuffer history search state. 1585 "Restore the minibuffer history search state.
1584 Go to the history element by the absolute history position `hist-pos'." 1586 Go to the history element by the absolute history position HIST-POS."
1585 (goto-history-element hist-pos)) 1587 (goto-history-element hist-pos))
1586 1588
1587 1589
1588 ;Put this on C-x u, so we can force that rather than C-_ into startup msg 1590 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
1589 (defalias 'advertised-undo 'undo) 1591 (defalias 'advertised-undo 'undo)
1604 If t, we undid all the way to the end of it.") 1606 If t, we undid all the way to the end of it.")
1605 1607
1606 (defun undo (&optional arg) 1608 (defun undo (&optional arg)
1607 "Undo some previous changes. 1609 "Undo some previous changes.
1608 Repeat this command to undo more changes. 1610 Repeat this command to undo more changes.
1609 A numeric argument serves as a repeat count. 1611 A numeric ARG serves as a repeat count.
1610 1612
1611 In Transient Mark mode when the mark is active, only undo changes within 1613 In Transient Mark mode when the mark is active, only undo changes within
1612 the current region. Similarly, when not in Transient Mark mode, just \\[universal-argument] 1614 the current region. Similarly, when not in Transient Mark mode, just \\[universal-argument]
1613 as an argument limits undo to changes within the current region." 1615 as an argument limits undo to changes within the current region."
1614 (interactive "*P") 1616 (interactive "*P")
1706 (setq buffer-undo-list t))) 1708 (setq buffer-undo-list t)))
1707 1709
1708 (defun undo-only (&optional arg) 1710 (defun undo-only (&optional arg)
1709 "Undo some previous changes. 1711 "Undo some previous changes.
1710 Repeat this command to undo more changes. 1712 Repeat this command to undo more changes.
1711 A numeric argument serves as a repeat count. 1713 A numeric ARG serves as a repeat count.
1712 Contrary to `undo', this will not redo a previous undo." 1714 Contrary to `undo', this will not redo a previous undo."
1713 (interactive "*p") 1715 (interactive "*p")
1714 (let ((undo-no-redo t)) (undo arg))) 1716 (let ((undo-no-redo t)) (undo arg)))
1715 1717
1716 (defvar undo-in-progress nil 1718 (defvar undo-in-progress nil
2049 `resize-mini-windows' and `max-mini-window-height'), it is shown 2051 `resize-mini-windows' and `max-mini-window-height'), it is shown
2050 there, but it is nonetheless available in buffer `*Shell Command 2052 there, but it is nonetheless available in buffer `*Shell Command
2051 Output*' even though that buffer is not automatically displayed. 2053 Output*' even though that buffer is not automatically displayed.
2052 2054
2053 To specify a coding system for converting non-ASCII characters 2055 To specify a coding system for converting non-ASCII characters
2054 in the shell command output, use \\[universal-coding-system-argument] 2056 in the shell command output, use \\[universal-coding-system-argument] \
2055 before this command. 2057 before this command.
2056 2058
2057 Noninteractive callers can specify coding systems by binding 2059 Noninteractive callers can specify coding systems by binding
2058 `coding-system-for-read' and `coding-system-for-write'. 2060 `coding-system-for-read' and `coding-system-for-write'.
2059 2061
2067 If the command terminates without error, but generates output, 2069 If the command terminates without error, but generates output,
2068 and you did not specify \"insert it in the current buffer\", 2070 and you did not specify \"insert it in the current buffer\",
2069 the output can be displayed in the echo area or in its buffer. 2071 the output can be displayed in the echo area or in its buffer.
2070 If the output is short enough to display in the echo area 2072 If the output is short enough to display in the echo area
2071 \(determined by the variable `max-mini-window-height' if 2073 \(determined by the variable `max-mini-window-height' if
2072 `resize-mini-windows' is non-nil), it is shown there. Otherwise, 2074 `resize-mini-windows' is non-nil), it is shown there.
2073 the buffer containing the output is displayed. 2075 Otherwise,the buffer containing the output is displayed.
2074 2076
2075 If there is output and an error, and you did not specify \"insert it 2077 If there is output and an error, and you did not specify \"insert it
2076 in the current buffer\", a message about the error goes at the end 2078 in the current buffer\", a message about the error goes at the end
2077 of the output. 2079 of the output.
2078 2080
3071 (setq this-command 'yank)) 3073 (setq this-command 'yank))
3072 nil) 3074 nil)
3073 3075
3074 (defun rotate-yank-pointer (arg) 3076 (defun rotate-yank-pointer (arg)
3075 "Rotate the yanking point in the kill ring. 3077 "Rotate the yanking point in the kill ring.
3076 With argument, rotate that many kills forward (or backward, if negative)." 3078 With ARG, rotate that many kills forward (or backward, if negative)."
3077 (interactive "p") 3079 (interactive "p")
3078 (current-kill arg)) 3080 (current-kill arg))
3079 3081
3080 ;; Some kill commands. 3082 ;; Some kill commands.
3081 3083
3130 (+ arg (if (zerop wh) 0 (1- wh)))) 3132 (+ arg (if (zerop wh) 0 (1- wh))))
3131 arg)) 3133 arg))
3132 killp)) 3134 killp))
3133 3135
3134 (defun zap-to-char (arg char) 3136 (defun zap-to-char (arg char)
3135 "Kill up to and including ARG'th occurrence of CHAR. 3137 "Kill up to and including ARGth occurrence of CHAR.
3136 Case is ignored if `case-fold-search' is non-nil in the current buffer. 3138 Case is ignored if `case-fold-search' is non-nil in the current buffer.
3137 Goes backward if ARG is negative; error if CHAR not found." 3139 Goes backward if ARG is negative; error if CHAR not found."
3138 (interactive "p\ncZap to char: ") 3140 (interactive "p\ncZap to char: ")
3139 (if (char-table-p translation-table-for-input) 3141 (if (char-table-p translation-table-for-input)
3140 (setq char (or (aref translation-table-for-input char) char))) 3142 (setq char (or (aref translation-table-for-input char) char)))
3150 :type 'boolean 3152 :type 'boolean
3151 :group 'killing) 3153 :group 'killing)
3152 3154
3153 (defun kill-line (&optional arg) 3155 (defun kill-line (&optional arg)
3154 "Kill the rest of the current line; if no nonblanks there, kill thru newline. 3156 "Kill the rest of the current line; if no nonblanks there, kill thru newline.
3155 With prefix argument, kill that many lines from point. 3157 With prefix argument ARG, kill that many lines from point.
3156 Negative arguments kill lines backward. 3158 Negative arguments kill lines backward.
3157 With zero argument, kills the text before point on the current line. 3159 With zero argument, kills the text before point on the current line.
3158 3160
3159 When calling from a program, nil means \"no arg\", 3161 When calling from a program, nil means \"no arg\",
3160 a number counts as a prefix arg. 3162 a number counts as a prefix arg.
3201 (goto-char end)))) 3203 (goto-char end))))
3202 (point)))) 3204 (point))))
3203 3205
3204 (defun kill-whole-line (&optional arg) 3206 (defun kill-whole-line (&optional arg)
3205 "Kill current line. 3207 "Kill current line.
3206 With prefix arg, kill that many lines starting from the current line. 3208 With prefix ARG, kill that many lines starting from the current line.
3207 If arg is negative, kill backward. Also kill the preceding newline. 3209 If ARG is negative, kill backward. Also kill the preceding newline.
3208 \(This is meant to make \\[repeat] work well with negative arguments.\) 3210 \(This is meant to make \\[repeat] work well with negative arguments.\)
3209 If arg is zero, kill current line but exclude the trailing newline." 3211 If ARG is zero, kill current line but exclude the trailing newline."
3210 (interactive "p") 3212 (interactive "p")
3211 (if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp))) 3213 (if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
3212 (signal 'end-of-buffer nil)) 3214 (signal 'end-of-buffer nil))
3213 (if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp))) 3215 (if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
3214 (signal 'beginning-of-buffer nil)) 3216 (signal 'beginning-of-buffer nil))
3541 Start discarding off end if gets this big." 3543 Start discarding off end if gets this big."
3542 :type 'integer 3544 :type 'integer
3543 :group 'editing-basics) 3545 :group 'editing-basics)
3544 3546
3545 (defun pop-to-mark-command () 3547 (defun pop-to-mark-command ()
3546 "Jump to mark, and pop a new position for mark off the ring 3548 "Jump to mark, and pop a new position for mark off the ring.
3547 \(does not affect global mark ring\)." 3549 \(Does not affect global mark ring\)."
3548 (interactive) 3550 (interactive)
3549 (if (null (mark t)) 3551 (if (null (mark t))
3550 (error "No mark set in this buffer") 3552 (error "No mark set in this buffer")
3551 (if (= (point) (mark t)) 3553 (if (= (point) (mark t))
3552 (message "Mark popped")) 3554 (message "Mark popped"))
3553 (goto-char (mark t)) 3555 (goto-char (mark t))
3554 (pop-mark))) 3556 (pop-mark)))
3555 3557
3556 (defun push-mark-command (arg &optional nomsg) 3558 (defun push-mark-command (arg &optional nomsg)
3557 "Set mark at where point is. 3559 "Set mark at where point is.
3558 If no prefix arg and mark is already set there, just activate it. 3560 If no prefix ARG and mark is already set there, just activate it.
3559 Display `Mark set' unless the optional second arg NOMSG is non-nil." 3561 Display `Mark set' unless the optional second arg NOMSG is non-nil."
3560 (interactive "P") 3562 (interactive "P")
3561 (let ((mark (marker-position (mark-marker)))) 3563 (let ((mark (marker-position (mark-marker))))
3562 (if (or arg (null mark) (/= mark (point))) 3564 (if (or arg (null mark) (/= mark (point)))
3563 (push-mark nil nomsg t) 3565 (push-mark nil nomsg t)
3688 (defun exchange-point-and-mark (&optional arg) 3690 (defun exchange-point-and-mark (&optional arg)
3689 "Put the mark where point is now, and point where the mark is now. 3691 "Put the mark where point is now, and point where the mark is now.
3690 This command works even when the mark is not active, 3692 This command works even when the mark is not active,
3691 and it reactivates the mark. 3693 and it reactivates the mark.
3692 3694
3693 If Transient Mark mode is on, a prefix arg deactivates the mark 3695 If Transient Mark mode is on, a prefix ARG deactivates the mark
3694 if it is active, and otherwise avoids reactivating it. If 3696 if it is active, and otherwise avoids reactivating it. If
3695 Transient Mark mode is off, a prefix arg enables Transient Mark 3697 Transient Mark mode is off, a prefix ARG enables Transient Mark
3696 mode temporarily." 3698 mode temporarily."
3697 (interactive "P") 3699 (interactive "P")
3698 (let ((omark (mark t)) 3700 (let ((omark (mark t))
3699 (temp-highlight (eq (car-safe transient-mark-mode) 'only))) 3701 (temp-highlight (eq (car-safe transient-mark-mode) 'only)))
3700 (if (null omark) 3702 (if (null omark)
4356 4358
4357 (defun set-goal-column (arg) 4359 (defun set-goal-column (arg)
4358 "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line]. 4360 "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
4359 Those commands will move to this position in the line moved to 4361 Those commands will move to this position in the line moved to
4360 rather than trying to keep the same horizontal position. 4362 rather than trying to keep the same horizontal position.
4361 With a non-nil argument, clears out the goal column 4363 With a non-nil argument ARG, clears out the goal column
4362 so that \\[next-line] and \\[previous-line] resume vertical motion. 4364 so that \\[next-line] and \\[previous-line] resume vertical motion.
4363 The goal column is stored in the variable `goal-column'." 4365 The goal column is stored in the variable `goal-column'."
4364 (interactive "P") 4366 (interactive "P")
4365 (if arg 4367 (if arg
4366 (progn 4368 (progn
4410 (defun kill-visual-line (&optional arg) 4412 (defun kill-visual-line (&optional arg)
4411 "Kill the rest of the visual line. 4413 "Kill the rest of the visual line.
4412 If there are only whitespace characters there, kill through the 4414 If there are only whitespace characters there, kill through the
4413 newline as well. 4415 newline as well.
4414 4416
4415 With prefix argument, kill that many lines from point. 4417 With prefix argument ARG, kill that many lines from point.
4416 Negative arguments kill lines backward. 4418 Negative arguments kill lines backward.
4417 With zero argument, kill the text before point on the current line. 4419 With zero argument, kill the text before point on the current line.
4418 4420
4419 When calling from a program, nil means \"no arg\", 4421 When calling from a program, nil means \"no arg\",
4420 a number counts as a prefix arg. 4422 a number counts as a prefix arg.
4722 (goto-char (car pos1)) 4724 (goto-char (car pos1))
4723 (insert word2)))) 4725 (insert word2))))
4724 4726
4725 (defun backward-word (&optional arg) 4727 (defun backward-word (&optional arg)
4726 "Move backward until encountering the beginning of a word. 4728 "Move backward until encountering the beginning of a word.
4727 With argument, do this that many times." 4729 With argument ARG, do this that many times."
4728 (interactive "^p") 4730 (interactive "^p")
4729 (forward-word (- (or arg 1)))) 4731 (forward-word (- (or arg 1))))
4730 4732
4731 (defun mark-word (&optional arg allow-extend) 4733 (defun mark-word (&optional arg allow-extend)
4732 "Set mark ARG words away from point. 4734 "Set mark ARG words away from point.
4753 (point)) 4755 (point))
4754 nil t)))) 4756 nil t))))
4755 4757
4756 (defun kill-word (arg) 4758 (defun kill-word (arg)
4757 "Kill characters forward until encountering the end of a word. 4759 "Kill characters forward until encountering the end of a word.
4758 With argument, do this that many times." 4760 With argument ARG, do this that many times."
4759 (interactive "p") 4761 (interactive "p")
4760 (kill-region (point) (progn (forward-word arg) (point)))) 4762 (kill-region (point) (progn (forward-word arg) (point))))
4761 4763
4762 (defun backward-kill-word (arg) 4764 (defun backward-kill-word (arg)
4763 "Kill characters backward until encountering the beginning of a word. 4765 "Kill characters backward until encountering the beginning of a word.
4764 With argument, do this that many times." 4766 With argument ARG, do this that many times."
4765 (interactive "p") 4767 (interactive "p")
4766 (kill-word (- arg))) 4768 (kill-word (- arg)))
4767 4769
4768 (defun current-word (&optional strict really-word) 4770 (defun current-word (&optional strict really-word)
4769 "Return the symbol or word that point is on (or a nearby one) as a string. 4771 "Return the symbol or word that point is on (or a nearby one) as a string.