(setup-8-bit-environment):
[bpt/emacs.git] / lisp / simple.el
index ea2e91d..9e79a11 100644 (file)
@@ -62,6 +62,7 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
                   (not before-change-functions)
                   ;; Make sure there are no markers here.
                   (not (buffer-has-markers-at (1- (point))))
+                  (not (buffer-has-markers-at (point)))
                   ;; Make sure no text properties want to know
                   ;; where the change was.
                   (not (get-char-property (1- (point)) 'modification-hooks))
@@ -93,11 +94,13 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
          (self-insert-command (prefix-numeric-value arg))
        ;; If we get an error in self-insert-command, put point at right place.
        (if flag (forward-char 1))))
-    ;; If we did *not* get an error, cancel that forward-char.
-    (if flag (backward-char 1))
+    ;; Even if we did *not* get an error, keep that forward-char;
+    ;; all further processing should apply to the newline that the user
+    ;; thinks he inserted.
+
     ;; Mark the newline(s) `hard'.
     (if use-hard-newlines
-       (set-hard-newline-properties 
+       (set-hard-newline-properties
         (- (point) (if arg (prefix-numeric-value arg) 1)) (point)))
     ;; If the newline leaves the previous line blank,
     ;; and we have a left margin, delete that from the blank line.
@@ -108,7 +111,6 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
          (and (looking-at "[ \t]$")
               (> (current-left-margin) 0)
               (delete-region (point) (progn (end-of-line) (point))))))
-    (if flag (forward-char 1))
     ;; Indent the line after the newline, except in one case:
     ;; when we added the newline at the beginning of a line
     ;; which starts a page.
@@ -3423,11 +3425,23 @@ The properties used on SYMBOL are `composefunc', `sendfunc',
   (put symbol 'hookvar (or hookvar 'mail-send-hook)))
 
 (defun assoc-ignore-case (key alist)
-  "Like `assoc', but assumes KEY is a string and ignores case when comparing."
-  (setq key (downcase key))
+  "Like `assoc', but ignores differences in case and text representation.
+KEY must be a string.  Upper-case and lower-case letters are treated as equal.
+Unibyte strings are converted to multibyte for comparison."
   (let (element)
     (while (and alist (not element))
-      (if (equal key (downcase (car (car alist))))
+      (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil t))
+         (setq element (car alist)))
+      (setq alist (cdr alist)))
+    element))
+
+(defun assoc-ignore-representation (key alist)
+  "Like `assoc', but ignores differences in text representation.
+KEY must be a string.  
+Unibyte strings are converted to multibyte for comparison."
+  (let (element)
+    (while (and alist (not element))
+      (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil))
          (setq element (car alist)))
       (setq alist (cdr alist)))
     element))
@@ -3436,6 +3450,13 @@ The properties used on SYMBOL are `composefunc', `sendfunc',
   'sendmail-user-agent-compose
   'mail-send-and-exit)
 
+(defun rfc822-goto-eoh ()
+  ;; Go to header delimiter line in a mail message, following RFC822 rules
+  (goto-char (point-min))
+  (while (looking-at "^[^: \n]+:\\|^[ \t]")
+    (forward-line 1))
+  (point))
+
 (defun sendmail-user-agent-compose (&optional to subject other-headers continue
                                              switch-function yank-action
                                              send-actions)
@@ -3451,9 +3472,7 @@ The properties used on SYMBOL are `composefunc', `sendfunc',
        continue
        (error "Message aborted"))
     (save-excursion
-      (goto-char (point-min))
-      (search-forward mail-header-separator)
-      (beginning-of-line)
+      (rfc822-goto-eoh)
       (while other-headers
        (if (not (member (car (car other-headers)) '("in-reply-to" "cc")))
            (insert (car (car other-headers)) ": "