changeset 108904:2bc8bdaafa9a

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 07 Jun 2010 22:49:32 +0000
parents 1f795f817d05 (current diff) bbdc76e1b06c (diff)
children 68c7ddc1af16
files
diffstat 8 files changed, 283 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Jun 06 22:46:17 2010 +0000
+++ b/lisp/ChangeLog	Mon Jun 07 22:49:32 2010 +0000
@@ -1,3 +1,34 @@
+2010-06-07  Martin Pohlack  <mp26@os.inf.tu-dresden.de>
+
+	* iimage.el: Remove images as soon as the underlying text is modified.
+	(iimage-modification-hook): New function.
+	(iimage-mode-buffer): Use it.
+
+2010-06-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/smie.el (smie-indent-offset-rule): Rename from
+	smie-indent-offset-after.  Add :prev case.  Make a bit more generic.
+	(smie-indent-virtual): Remove `virtual' arg.  Update callers.
+	(smie-indent-keyword): Add handling of open-paren keywords.
+	(smie-indent-comment-continue): Don't assume comment-continue.
+
+2010-06-07  Martin Rudalics  <rudalics@gmx.at>
+
+	* window.el (pop-to-buffer): Remove the conditional that
+	compares new-window and old-window, so it will reselect
+	the selected window unconditionally.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00078.html
+
+2010-06-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/smie.el (smie-indent-offset-after)
+	(smie-indent-forward-token, smie-indent-backward-token): New functions.
+	(smie-indent-after-keyword): Use them.
+	(smie-indent-fixindent): Only applies to the indentation of the BOL.
+	(smie-indent-keyword): Tweak the black magic.
+	(smie-indent-comment-continue): Strip comment-continue before use.
+	(smie-indent-functions): Indent comments before keywords.
+
 2010-06-06  Juri Linkov  <juri@jurta.org>
 
 	* isearch.el (isearch-lazy-highlight-search): Fix looping
@@ -4666,8 +4697,8 @@
 
 2009-12-10  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
-	* whitespace.el (whitespace-display-char-on): Ensure
-	`buffer-display-table' is unique when two or more windows are
+	* whitespace.el (whitespace-display-char-on):
+	Ensure `buffer-display-table' is unique when two or more windows are
 	visible.  Reported by Martin Pohlack <mp26@os.inf.tu-dresden.de>.
 	New version 12.1.
 
--- a/lisp/ChangeLog.13	Sun Jun 06 22:46:17 2010 +0000
+++ b/lisp/ChangeLog.13	Mon Jun 07 22:49:32 2010 +0000
@@ -7161,7 +7161,7 @@
 	* doc-view.el (doc-view-search-backward, doc-view-search):
 	Fix assignment to free variable bug.
 
-2007-11-16  Martin Pohlack  <mp26@os.inf.tu-dresden.de>  (tiny change)
+2007-11-16  Martin Pohlack  <mp26@os.inf.tu-dresden.de>
 
 	* emulation/pc-select.el (pc-select-shifted-mark): New var.
 	(ensure-mark): Set it.
--- a/lisp/emacs-lisp/smie.el	Sun Jun 06 22:46:17 2010 +0000
+++ b/lisp/emacs-lisp/smie.el	Mon Jun 07 22:49:32 2010 +0000
@@ -294,7 +294,12 @@
 (defvar smie-op-levels 'unset
   "List of token parsing info.
 Each element is of the form (TOKEN LEFT-LEVEL RIGHT-LEVEL).
-Parsing is done using an operator precedence parser.")
+Parsing is done using an operator precedence parser.
+LEFT-LEVEL and RIGHT-LEVEL can be either numbers or nil, where nil
+means that this operator does not bind on the corresponding side,
+i.e. a LEFT-LEVEL of nil means this is a token that behaves somewhat like
+an open-paren, whereas a RIGHT-LEVEL of nil would correspond to something
+like a close-paren.")
 
 (defvar smie-forward-token-function 'smie-default-forward-token
   "Function to scan forward for the next token.
@@ -495,17 +500,26 @@
   ;; I.e. the indentation after "=" depends on the parent ("structure")
   ;; as well as on the following token ("struct").
   "Rules of the following form.
-\(TOK OFFSET)		how to indent right after TOK.
-\(TOK O1 O2)		how to indent right after TOK:
-			  O1 is the default;
-			  O2 is used if TOK is \"hanging\".
+\((:before . TOK) . OFFSET-RULES)	how to indent TOK itself.
+\(TOK . OFFSET-RULES)	how to indent right after TOK.
 \((T1 . T2) . OFFSET)	how to indent token T2 w.r.t T1.
 \((t . TOK) . OFFSET)	how to indent TOK with respect to its parent.
 \(list-intro . TOKENS)	declare TOKENS as being followed by what may look like
 			  a funcall but is just a sequence of expressions.
 \(t . OFFSET)		basic indentation step.
 \(args . OFFSET)		indentation of arguments.
-A nil offset defaults to `smie-indent-basic'.")
+
+OFFSET-RULES is a list of elements which can each either be:
+
+\(:hanging . OFFSET-RULES)	if TOK is hanging, use OFFSET-RULES.
+\(:parent PARENT . OFFSET-RULES) if TOK's parent is PARENT, use OFFSET-RULES.
+\(:next TOKEN . OFFSET-RULES)	if TOK is followed by TOKEN, use OFFSET-RULES.
+\(:prev TOKEN . OFFSET-RULES)	if TOK is preceded by TOKEN, use OFFSET-RULES.
+a number				the offset to use.
+`point'				align with the token.
+`parent'				align with the parent.
+
+A nil offset for indentation after a token defaults to `smie-indent-basic'.")
 
 (defun smie-indent-hanging-p ()
   ;; A hanging keyword is one that's at the end of a line except it's not at
@@ -526,25 +540,83 @@
       (cdr (assq t smie-indent-rules))
       smie-indent-basic))
 
-(defun smie-indent-virtual (virtual)
+(defun smie-indent-offset-rule (tokinfo &optional after)
+  "Apply the OFFSET-RULES in TOKINFO.
+Point is expected to be right in front of the token corresponding to TOKINFO.
+If computing the indentation after the token, then AFTER is the position
+after the token."
+  (let ((rules (cdr tokinfo))
+        parent next prev
+        offset)
+    (while (consp rules)
+      (let ((rule (pop rules)))
+        (cond
+         ((not (consp rule)) (setq offset rule))
+         ((eq (car rule) :hanging)
+          (when (smie-indent-hanging-p)
+            (setq rules (cdr rule))))
+         ((eq (car rule) :prev)
+          (unless prev
+            (save-excursion
+              (setq prev (smie-indent-backward-token))))
+          (when (equal (car prev) (cadr rule))
+            (setq rules (cddr rule))))
+         ((eq (car rule) :next)
+          (unless next
+            (unless after
+              (error "Can't use :next in :before indentation rules"))
+            (save-excursion
+              (goto-char after)
+              (setq next (smie-indent-forward-token))))
+          (when (equal (car next) (cadr rule))
+            (setq rules (cddr rule))))
+         ((eq (car rule) :parent)
+          (unless parent
+            (save-excursion
+              (if after (goto-char after))
+              (setq parent (smie-backward-sexp 'halfsexp))))
+          (when (equal (nth 2 parent) (cadr rule))
+            (setq rules (cddr rule))))
+         (t (error "Unknown rule %s for indentation of %s"
+                   rule (car tokinfo))))))
+    offset))
+
+(defun smie-indent-forward-token ()
+  "Skip token forward and return it, along with its levels."
+  (let ((tok (funcall smie-forward-token-function)))
+    (cond
+     ((< 0 (length tok)) (assoc tok smie-op-levels))
+     ((looking-at "\\s(")
+      (forward-char 1)
+      (list (buffer-substring (1- (point)) (point)) nil 0)))))
+
+(defun smie-indent-backward-token ()
+  "Skip token backward and return it, along with its levels."
+  (let ((tok (funcall smie-backward-token-function)))
+    (cond
+     ((< 0 (length tok)) (assoc tok smie-op-levels))
+     ;; 4 == Open paren syntax.
+     ((eq 4 (syntax-class (syntax-after (1- (point)))))
+      (forward-char -1)
+      (list (buffer-substring (point) (1+ (point))) nil 0)))))
+
+(defun smie-indent-virtual ()
+  ;; We used to take an optional arg (with value :not-hanging) to specify that
+  ;; we should only use (smie-indent-calculate) if we're looking at a hanging
+  ;; keyword.  This was a bad idea, because the virtual indent of a position
+  ;; should not depend on the caller, since it leads to situations where two
+  ;; dependent indentations get indented differently.
   "Compute the virtual indentation to use for point.
 This is used when we're not trying to indent point but just
 need to compute the column at which point should be indented
-in order to figure out the indentation of some other (further down) point.
-VIRTUAL can take two different values:
-- :bolp: means that the current indentation of point can be trusted
-  to be good only if it follows a line break.
-- :not-hanging: means that the current indentation of point can be
-  trusted to be good except if the following token is hanging."
+in order to figure out the indentation of some other (further down) point."
   ;; Trust pre-existing indentation on other lines.
-  (assert virtual)
-  (if (if (eq virtual :not-hanging) (not (smie-indent-hanging-p)) (smie-bolp))
-      (current-column)
-    (smie-indent-calculate)))
+  (if (smie-bolp) (current-column) (smie-indent-calculate)))
 
 (defun smie-indent-fixindent ()
   ;; Obey the `fixindent' special comment.
-  (when (save-excursion
+  (and (smie-bolp)
+       (save-excursion
           (comment-normalize-vars)
           (re-search-forward (concat comment-start-skip
                                      "fixindent"
@@ -569,7 +641,7 @@
       (condition-case nil
           (progn
             (backward-sexp 1)
-            (smie-indent-virtual :not-hanging))
+            (smie-indent-virtual))      ;:not-hanging
         (scan-error nil)))))
 
 (defun smie-indent-keyword ()
@@ -577,36 +649,90 @@
   ;; (e.g. "of" with "case", or "in" with "let").
   (save-excursion
     (let* ((pos (point))
-           (token (funcall smie-forward-token-function))
-           (toklevels (cdr (assoc token smie-op-levels))))
-      (when (car toklevels)
+           (toklevels (smie-indent-forward-token))
+           (token (pop toklevels)))
+      (if (null (car toklevels))
+          ;; Different case:
+          ;; - smie-bolp: "indent according to others".
+          ;; - common hanging: "indent according to others".
+          ;; - SML-let hanging: "indent like parent".
+          ;; - if-after-else: "indent-like parent".
+          ;; - middle-of-line: "trust current position".
+          (cond
+           ((null (cdr toklevels)) nil) ;Not a keyword.
+           ((smie-bolp)
+            ;; For an open-paren-like thingy at BOL, always indent only
+            ;; based on other rules (typically smie-indent-after-keyword).
+            nil)
+           (t
+            (let* ((tokinfo (or (assoc (cons :before token) smie-indent-rules)
+                                ;; By default use point unless we're hanging.
+                                (cons (cons :before token)
+                                      '((:hanging nil) point))))
+                   (after (prog1 (point) (goto-char pos)))
+                   (offset (smie-indent-offset-rule tokinfo)))
+              (cond
+               ((eq offset 'point) (current-column))
+               ((eq offset 'parent)
+                (let ((parent (smie-backward-sexp 'halfsexp)))
+                  (if parent (goto-char (cadr parent))))
+                (smie-indent-virtual))
+               ((eq offset nil) nil)
+               (t (error "Unhandled offset %s in %s"
+                         offset (cons :before token)))))))
+
+        ;; FIXME: This still looks too much like black magic!!
+        ;; FIXME: Rather than a bunch of rules like (PARENT . TOKEN), we
+        ;; want a single rule for TOKEN with different cases for each PARENT.
         (let ((res (smie-backward-sexp 'halfsexp)) tmp)
-          ;; If we didn't move at all, that means we didn't really skip
-          ;; what we wanted.
-          (when (< (point) pos)
-            (cond
-             ((eq (car res) (car toklevels))
-              ;; We bumped into a same-level operator. align with it.
-              (goto-char (cadr res))
-              ;; Don't use (smie-indent-virtual :not-hanging) here, because we
-              ;; want to jump back over a sequence of same-level ops such as
-              ;;    a -> b -> c
-              ;;    -> d
-              ;; So as to align with the earliest appropriate place.
-              (smie-indent-virtual :bolp))
-             ((equal token (save-excursion
-                             (funcall smie-backward-token-function)))
-              ;; in cases such as "fn x => fn y => fn z =>",
-              ;; jump back to the very first fn.
-              ;; FIXME: should we only do that for special tokens like "=>"?
-              (smie-indent-virtual :bolp))
-             ((setq tmp (assoc (cons (caddr res) token)
-                               smie-indent-rules))
-              (goto-char (cadr res))
-              (+ (cdr tmp) (smie-indent-virtual :not-hanging)))
-             (t
-              (+ (or (cdr (assoc (cons t token) smie-indent-rules)) 0)
-                 (current-column))))))))))
+          (cond
+           ((not (or (< (point) pos)
+                     (and (cadr res) (< (cadr res) pos))))
+            ;; If we didn't move at all, that means we didn't really skip
+            ;; what we wanted.
+            nil)
+           ((eq (car res) (car toklevels))
+            ;; We bumped into a same-level operator. align with it.
+            (goto-char (cadr res))
+            ;; Don't use (smie-indent-virtual :not-hanging) here, because we
+            ;; want to jump back over a sequence of same-level ops such as
+            ;;    a -> b -> c
+            ;;    -> d
+            ;; So as to align with the earliest appropriate place.
+            (smie-indent-virtual))
+           ((equal token (save-excursion
+                           (funcall smie-backward-token-function)))
+            ;; in cases such as "fn x => fn y => fn z =>",
+            ;; jump back to the very first fn.
+            ;; FIXME: should we only do that for special tokens like "=>"?
+            (smie-indent-virtual))
+           ((setq tmp (assoc (cons (caddr res) token)
+                             smie-indent-rules))
+            (goto-char (cadr res))
+            (+ (cdr tmp) (smie-indent-virtual))) ;:not-hanging
+           ;; FIXME: The rules ((t . TOK) . OFFSET) either indent
+           ;; relative to "before the parent" or "after the parent",
+           ;; depending on details of the grammar.
+           ((null (car res))
+            (assert (eq (point) (cadr res)))
+            (goto-char (cadr res))
+            (+ (or (cdr (assoc (cons t token) smie-indent-rules)) 0)
+               (smie-indent-virtual)))  ;:not-hanging
+           ((and (= (point) pos) (smie-bolp))
+            ;; Since we started at BOL, we're not computing a virtual
+            ;; indentation, and we're still at the starting point, so the
+            ;; next (default) rule can't be used since it uses `current-column'
+            ;; which would cause. indentation to depend on itself.
+            ;; We could just return nil, but OTOH that's not good enough in
+            ;; some cases.  Instead, we want to combine the offset-rules for
+            ;; the current token with the offset-rules of the previous one.
+            (+ (or (cdr (assoc (cons t token) smie-indent-rules)) 0)
+               ;; FIXME: This is odd.  Can't we make it use
+               ;; smie-indent-(calculate|virtual) somehow?
+               (smie-indent-after-keyword)))
+           (t
+            (+ (or (cdr (assoc (cons t token) smie-indent-rules)) 0)
+               (current-column)))))))))
 
 (defun smie-indent-comment ()
   ;; Indentation of a comment.
@@ -618,53 +744,46 @@
 
 (defun smie-indent-comment-continue ()
   ;; indentation of comment-continue lines.
-  (and (< 0 (length comment-continue))
-       (looking-at (regexp-quote comment-continue)) (nth 4 (syntax-ppss))
+  (let ((continue (and comment-continue
+                       (comment-string-strip comment-continue t t))))
+    (and (< 0 (length continue))
+         (looking-at (regexp-quote continue)) (nth 4 (syntax-ppss))
        (let ((ppss (syntax-ppss)))
          (save-excursion
            (forward-line -1)
            (if (<= (point) (nth 8 ppss))
                (progn (goto-char (1+ (nth 8 ppss))) (current-column))
              (skip-chars-forward " \t")
-             (if (looking-at (regexp-quote comment-continue))
-                 (current-column)))))))
+               (if (looking-at (regexp-quote continue))
+                   (current-column))))))))
 
 (defun smie-indent-after-keyword ()
   ;; Indentation right after a special keyword.
   (save-excursion
-    (let* ((tok (funcall smie-backward-token-function))
-           (tokinfo (assoc tok smie-indent-rules))
-           (toklevel (if (and (zerop (length tok))
-                              ;; 4 == Open paren syntax.
-                              (eq (syntax-class (syntax-after (1- (point))))
-                                  4))
-                         (progn (forward-char -1)
-                                (setq tok (buffer-substring
-                                           (point) (1+ (point))))
-                                (setq tokinfo (assoc tok smie-indent-rules))
-                                (list tok nil 0))
-                       (assoc tok smie-op-levels))))
+    (let* ((pos (point))
+           (toklevel (smie-indent-backward-token))
+           (tok (car toklevel))
+           (tokinfo (assoc tok smie-indent-rules)))
       (if (and toklevel (null (cadr toklevel)) (null tokinfo))
-          (setq tokinfo (list (car toklevel) nil nil)))
-      (if (and tokinfo (null toklevel))
-          (error "Token %S has indent rule but has no parsing info" tok))
+          (setq tokinfo (list (car toklevel))))
+      ;; (if (and tokinfo (null toklevel))
+      ;;     (error "Token %S has indent rule but has no parsing info" tok))
       (when toklevel
-        (let ((default-offset
+        (let ((offset
+               (cond
+                (tokinfo (or (smie-indent-offset-rule tokinfo pos)
+                             (smie-indent-offset t)))
                 ;; The default indentation after a keyword/operator
                 ;; is 0 for infix and t for prefix.
                 ;; Using the BNF syntax, we could come up with
                 ;; better defaults, but we only have the
                 ;; precedence levels here.
-                (if (or tokinfo (null (cadr toklevel)))
-                    (smie-indent-offset t) 0)))
-          ;; For indentation after "(let", we end up accumulating the
-          ;; offset of "(" and the offset of "let", so we use `min'
-          ;; to try and get it right either way.
-          (min
-           (+ (smie-indent-virtual :bolp)
-              (or (caddr tokinfo) (cadr tokinfo) default-offset))
-           (+ (current-column)
-              (or (cadr tokinfo) default-offset))))))))
+                ((null (cadr toklevel)) (smie-indent-offset t))
+                (t 0))))
+          ;; For indentation after "(let" in SML-mode, we end up accumulating
+          ;; the offset of "(" and the offset of "let", so we use `min' to try
+          ;; and get it right either way.
+          (+ (min (smie-indent-virtual) (current-column)) offset))))))
 
 (defun smie-indent-exps ()
   ;; Indentation of sequences of simple expressions without
@@ -713,14 +832,14 @@
         ;; We're the first arg.
         (goto-char (car positions))
         (+ (smie-indent-offset 'args)
-           ;; We used to use (smie-indent-virtual :bolp), but that
+           ;; We used to use (smie-indent-virtual), but that
            ;; doesn't seem right since it might then indent args less than
            ;; the function itself.
            (current-column)))))))
 
 (defvar smie-indent-functions
-  '(smie-indent-fixindent smie-indent-bob smie-indent-close smie-indent-keyword
-    smie-indent-comment smie-indent-comment-continue smie-indent-after-keyword
+  '(smie-indent-fixindent smie-indent-bob smie-indent-close smie-indent-comment
+    smie-indent-comment-continue smie-indent-keyword smie-indent-after-keyword
     smie-indent-exps)
   "Functions to compute the indentation.
 Each function is called with no argument, shouldn't move point, and should
--- a/lisp/iimage.el	Sun Jun 06 22:46:17 2010 +0000
+++ b/lisp/iimage.el	Mon Jun 07 22:49:32 2010 +0000
@@ -101,6 +101,19 @@
   (interactive)
   (iimage-mode 0))
 
+(defun iimage-modification-hook (beg end)
+  "Remove display property if a display region is modified."
+  ;;(debug-print "ii1 begin %d, end %d\n" beg end)
+  (let ((inhibit-modification-hooks t)
+        (beg (previous-single-property-change end 'display
+                                              nil (line-beginning-position)))
+        (end (next-single-property-change     beg 'display
+                                              nil (line-end-position))))
+    (when (and beg end (plist-get (text-properties-at beg) 'display))
+      ;;(debug-print "ii2 begin %d, end %d\n" beg end)
+      (remove-text-properties beg end
+                              '(display nil modification-hooks nil)))))
+
 (defun iimage-mode-buffer (arg)
   "Display images if ARG is non-nil, undisplay them otherwise."
   (let ((image-path (cons default-directory iimage-mode-image-search-path))
@@ -110,16 +123,18 @@
         (goto-char (point-min))
         (dolist (pair iimage-mode-image-regex-alist)
           (while (re-search-forward (car pair) nil t)
-            (if (and (setq file (match-string (cdr pair)))
-                     (setq file (locate-file file image-path)))
-                ;; FIXME: we don't mark our images, so we can't reliably
-                ;; remove them either (we may leave some of ours, and we
-                ;; may remove other packages's display properties).
-                (if arg
-                    (add-text-properties (match-beginning 0) (match-end 0)
-                                         (list 'display (create-image file)))
-                  (remove-text-properties (match-beginning 0) (match-end 0)
-                                          '(display))))))))))
+            (when (and (setq file (match-string (cdr pair)))
+                       (setq file (locate-file file image-path)))
+              ;; FIXME: we don't mark our images, so we can't reliably
+              ;; remove them either (we may leave some of ours, and we
+              ;; may remove other packages's display properties).
+              (if arg
+                  (add-text-properties (match-beginning 0) (match-end 0)
+                                       `(display ,(create-image file)
+                                         modification-hooks
+                                         (iimage-modification-hook)))
+                (remove-text-properties (match-beginning 0) (match-end 0)
+                                        '(display modification-hooks))))))))))
 
 ;;;###autoload
 (define-minor-mode iimage-mode
--- a/lisp/window.el	Sun Jun 06 22:46:17 2010 +0000
+++ b/lisp/window.el	Mon Jun 07 22:49:32 2010 +0000
@@ -1220,19 +1220,16 @@
                (let ((buf (get-buffer-create buffer-or-name)))
                  (set-buffer-major-mode buf)
                  buf))))
-	(old-window (selected-window))
 	(old-frame (selected-frame))
 	new-window new-frame)
     (set-buffer buffer)
     (setq new-window (display-buffer buffer other-window))
-    (unless (eq new-window old-window)
-      ;; `display-buffer' has chosen another window, select it.
-      (select-window new-window norecord)
-      (setq new-frame (window-frame new-window))
-      (unless (eq new-frame old-frame)
-	;; `display-buffer' has chosen another frame, make sure it gets
-	;; input focus and is risen.
-	(select-frame-set-input-focus new-frame)))
+    (select-window new-window norecord)
+    (setq new-frame (window-frame new-window))
+    (unless (eq new-frame old-frame)
+      ;; `display-buffer' has chosen another frame, make sure it gets
+      ;; input focus and is risen.
+      (select-frame-set-input-focus new-frame))
     buffer))
 
 ;; I think this should be the default; I think people will prefer it--rms.
--- a/src/ChangeLog	Sun Jun 06 22:46:17 2010 +0000
+++ b/src/ChangeLog	Mon Jun 07 22:49:32 2010 +0000
@@ -1,3 +1,15 @@
+2010-06-07  Martin Rudalics  <rudalics@gmx.at>
+
+	* window.c (Fselect_window): Move `record_buffer' up to the
+	beginning of this function, so the buffer gets recorded
+	even if the selected window does not change.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00137.html
+
+2010-06-07  Juanma Barranquero  <lekktu@gmail.com>
+
+	* cmds.c (Fforward_char, Fbackward_char): Fix typos in docstrings.
+	(Fforward_line, Fbeginning_of_line): Reflow docstrings.
+
 2010-06-06  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	Remove BSTRING related code, all platforms define it.
--- a/src/cmds.c	Sun Jun 06 22:46:17 2010 +0000
+++ b/src/cmds.c	Mon Jun 07 22:49:32 2010 +0000
@@ -62,7 +62,7 @@
 
 Depending on the bidirectional context, the movement may be to the
 right or to the left on the screen.  This is in contrast with
-\\[right-arrow-command], which see.  */)
+\\[right-char], which see.  */)
      (n)
      Lisp_Object n;
 {
@@ -102,7 +102,7 @@
 
 Depending on the bidirectional context, the movement may be to the
 right or to the left on the screen.  This is in contrast with
-\\[left-arrow-command], which see.  */)
+\\[left-char], which see.  */)
      (n)
      Lisp_Object n;
 {
@@ -122,7 +122,7 @@
 Returns the count of lines left to move.  If moving forward,
 that is N - number of lines moved; if backward, N + number moved.
 With positive N, a non-empty line at the end counts as one line
-  successfully moved (for the return value).  */)
+successfully moved (for the return value).  */)
      (n)
      Lisp_Object n;
 {
@@ -167,8 +167,8 @@
 If point reaches the beginning or end of buffer, it stops there.
 
 This function constrains point to the current field unless this moves
-point to a different line than the original, unconstrained result.  If
-N is nil or 1, and a front-sticky field starts at point, the point
+point to a different line than the original, unconstrained result.
+If N is nil or 1, and a front-sticky field starts at point, the point
 does not move.  To ignore field boundaries bind
 `inhibit-field-text-motion' to t, or use the `forward-line' function
 instead.  For instance, `(forward-line 0)' does the same thing as
--- a/src/window.c	Sun Jun 06 22:46:17 2010 +0000
+++ b/src/window.c	Mon Jun 07 22:49:32 2010 +0000
@@ -3611,6 +3611,7 @@
     {
       ++window_select_count;
       XSETFASTINT (w->use_time, window_select_count);
+      record_buffer (w->buffer);
     }
 
   if (EQ (window, selected_window))
@@ -3646,8 +3647,6 @@
 
   selected_window = window;
 
-  if (NILP (norecord))
-    record_buffer (w->buffer);
   Fset_buffer (w->buffer);
 
   XBUFFER (w->buffer)->last_selected_window = window;