;;; simple.el --- basic editing commands for Emacs
;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
Optional arguments NOT-THIS-WINDOW and FRAME are as for `display-buffer',
and only used if a buffer is displayed."
- (cond ((and (stringp message) (not (string-match "\n" message)))
+ (cond ((and (stringp message)
+ (not (string-match "\n" message))
+ (<= (length message) (frame-width)))
;; Trivial case where we can use the echo area
(message "%s" message))
((and (stringp message)
- (= (string-match "\n" message) (1- (length message))))
+ (= (string-match "\n" message) (1- (length message)))
+ (<= (1- (length message)) (frame-width)))
;; Trivial case where we can just remove single trailing newline
(message "%s" (substring message 0 (1- (length message)))))
(t
(let ((lines
(if (= (buffer-size) 0)
0
- (count-lines (point-min) (point-max)))))
+ (count-screen-lines nil nil nil (minibuffer-window)))))
(cond ((= lines 0))
((and (or (<= lines 1)
(<= lines
"Hook run when the mark becomes inactive.")
(defun mark (&optional force)
- "Return this buffer's mark value as integer; error if mark inactive.
-If optional argument FORCE is non-nil, access the mark value
-even if the mark is not currently active, and return nil
-if there is no mark at all.
+ "Return this buffer's mark value as integer, or nil if never set.
+
+In Transient Mark mode, this function signals an error if
+the mark is not active. However, if `mark-even-if-inactive' is non-nil,
+or the argument FORCE is non-nil, it disregards whether the mark
+is active, and returns an integer or nil in the usual way.
If you are using this in an editing command, you are most likely making
a mistake; see the documentation of `set-mark'."
mark ring\). Use \\[pop-global-mark] to jump to a mark off the global
mark ring \(see `pop-global-mark'\).
-Repeating the \\[set-mark-command] command without the prefix jumps to
-the next position off the local (or global) mark ring.
+If `set-mark-command-repeat-pop' is non-nil, repeating
+the \\[set-mark-command] command with no prefix pops the next position
+off the local (or global) mark ring and jumps there.
With a double \\[universal-argument] prefix argument, e.g. \\[universal-argument] \
\\[universal-argument] \\[set-mark-command], unconditionally
(goto-char (previous-char-property-change (point) line-beg))))))))
(defun move-end-of-line (arg)
- "Move point to end of current line.
+ "Move point to end of current line as displayed.
+\(If there's an image in the line, this disregards newlines
+which are part of the text that the image rests on.)
+
With argument ARG not nil or 1, move forward ARG - 1 lines first.
If point reaches the beginning or end of buffer, it stops there.
-To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
-
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; if ARG is nil or 1, and
-point starts at a field boundary, point does not move. To ignore field
-boundaries bind `inhibit-field-text-motion' to t."
+To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
(interactive "p")
(or arg (setq arg 1))
(let (done)
(setq done t)))))))
(defun move-beginning-of-line (arg)
- "Move point to beginning of current display line.
+ "Move point to beginning of current line as displayed.
+\(If there's an image in the line, this disregards newlines
+which are part of the text that the image rests on.)
+
With argument ARG not nil or 1, move forward ARG - 1 lines first.
If point reaches the beginning or end of buffer, it stops there.
-To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
-
-This command does not move point across a field boundary unless doing so
-would move beyond there to a different line; if ARG is nil or 1, and
-point starts at a field boundary, point does not move. To ignore field
-boundaries bind `inhibit-field-text-motion' to t."
+To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
(interactive "p")
(or arg (setq arg 1))
- (if (/= arg 1)
- (line-move (1- arg) t))
- (beginning-of-line 1)
+
(let ((orig (point)))
- (vertical-motion 0)
- (if (/= orig (point))
- (goto-char (constrain-to-field (point) orig (/= arg 1) t nil)))))
+
+ ;; Move by lines, if ARG is not 1 (the default).
+ (if (/= arg 1)
+ (line-move (1- arg) t))
+
+ ;; Move to beginning-of-line, ignoring fields and invisibles.
+ (skip-chars-backward "^\n")
+ (while (and (not (bobp)) (line-move-invisible-p (1- (point))))
+ (goto-char (previous-char-property-change (point)))
+ (skip-chars-backward "^\n"))
+
+ ;; Take care of fields.
+ (goto-char (constrain-to-field (point) orig
+ (/= arg 1) t nil))))
;;; Many people have said they rarely use this feature, and often type
(insert body))
t)))
-(define-mail-user-agent 'mh-e-user-agent
- 'mh-smail-batch 'mh-send-letter 'mh-fully-kill-draft
- 'mh-before-send-letter-hook)
-
(defun compose-mail (&optional to subject other-headers continue
switch-function yank-action send-actions)
"Start composing a mail message to send.
(goto-char (point-min))
(search-forward "\n\n")
(forward-line 1))))
-
-;; Support keyboard commands to turn on various modifiers.
+\f
+;;; Support keyboard commands to turn on various modifiers.
;; These functions -- which are not commands -- each add one modifier
;; to the following event.
(define-key function-key-map [?\C-x ?@ ?a] 'event-apply-alt-modifier)
(define-key function-key-map [?\C-x ?@ ?S] 'event-apply-shift-modifier)
(define-key function-key-map [?\C-x ?@ ?c] 'event-apply-control-modifier)
-
+\f
;;;; Keypad support.
;;; Make the keypad keys act like ordinary typing keys. If people add
(error "Cannot clone a file-visiting buffer"))
(if (get major-mode 'no-clone)
(error "Cannot clone a buffer in %s mode" mode-name))
- (list (if current-prefix-arg (read-string "Name: "))
+ (list (if current-prefix-arg
+ (read-buffer "Name of new cloned buffer: " (current-buffer)))
t)))
(if buffer-file-name
(error "Cannot clone a file-visiting buffer"))
;; Run any hooks (typically set up by the major mode
;; for cloning to work properly).
(run-hooks 'clone-buffer-hook))
- (if display-flag (pop-to-buffer new))
+ (if display-flag
+ ;; Presumably the current buffer is shown in the selected frame, so
+ ;; we want to display the clone elsewhere.
+ (let ((same-window-regexps nil)
+ (same-window-buffer-names))
+ (pop-to-buffer new)))
new))
(if (get major-mode 'no-clone-indirect)
(error "Cannot indirectly clone a buffer in %s mode" mode-name))
(list (if current-prefix-arg
- (read-string "BName of indirect buffer: "))
+ (read-buffer "Name of indirect buffer: " (current-buffer)))
t)))
(if (get major-mode 'no-clone-indirect)
(error "Cannot indirectly clone a buffer in %s mode" mode-name))
buffer))
-(defun clone-indirect-buffer-other-window (buffer &optional norecord)
- "Create an indirect buffer that is a twin copy of BUFFER.
-Select the new buffer in another window.
-Optional second arg NORECORD non-nil means do not put this buffer at
-the front of the list of recently selected ones."
- (interactive "bClone buffer in other window: ")
+(defun clone-indirect-buffer-other-window (newname display-flag &optional norecord)
+ "Like `clone-indirect-buffer' but display in another window."
+ (interactive
+ (progn
+ (if (get major-mode 'no-clone-indirect)
+ (error "Cannot indirectly clone a buffer in %s mode" mode-name))
+ (list (if current-prefix-arg
+ (read-buffer "Name of indirect buffer: " (current-buffer)))
+ t)))
(let ((pop-up-windows t))
- (set-buffer buffer)
- (clone-indirect-buffer nil t norecord)))
+ (clone-indirect-buffer newname display-flag norecord)))
\f
;;; Handling of Backspace and Delete keys.