]> code.delx.au - gnu-emacs/blobdiff - lisp/simple.el
(server-ensure-safe-dir): UIDs may be floats.
[gnu-emacs] / lisp / simple.el
index 3e089d4e1a801cf06c4a3860a2cb5aa5e21710b1..4edff54bf0648b05d1ae86574ad079ae1292d284 100644 (file)
@@ -128,7 +128,7 @@ If no other buffer exists, the buffer `*scratch*' is returned."
   :group 'next-error
   :version "22.1")
 
-(defcustom next-error-highlight 0.1
+(defcustom next-error-highlight 0.5
   "*Highlighting of locations in selected source buffers.
 If number, highlight the locus in `next-error' face for given time in seconds.
 If t, highlight the locus indefinitely until some other locus replaces it.
@@ -141,8 +141,8 @@ If `fringe-arrow', indicate the locus by the fringe arrow."
   :group 'next-error
   :version "22.1")
 
-(defcustom next-error-highlight-no-select 0.1
-  "*Highlighting of locations in non-selected source buffers.
+(defcustom next-error-highlight-no-select 0.5
+  "*Highlighting of locations in `next-error-no-select'.
 If number, highlight the locus in `next-error' face for given time in seconds.
 If t, highlight the locus indefinitely until some other locus replaces it.
 If nil, don't highlight the locus in the source buffer.
@@ -262,10 +262,10 @@ that buffer is rejected."
        (next-error-buffer-p (current-buffer) nil
                             extra-test-inclusive extra-test-exclusive)
        (progn
-         (message "This is the only next-error capable buffer")
+         (message "This is the only buffer with error message locations")
          (current-buffer)))
    ;; 6. Give up.
-   (error "No next-error capable buffer found")))
+   (error "No buffers contain error message locations")))
 
 (defun next-error (&optional arg reset)
   "Visit next `next-error' message and corresponding source code.
@@ -706,8 +706,8 @@ Leave one space or none, according to the context."
 
 (defun delete-horizontal-space (&optional backward-only)
   "Delete all spaces and tabs around point.
-If BACKWARD-ONLY is non-nil, only delete spaces before point."
-  (interactive "*")
+If BACKWARD-ONLY is non-nil, only delete them before point."
+  (interactive "*P")
   (let ((orig-pos (point)))
     (delete-region
      (if backward-only
@@ -997,12 +997,11 @@ in *Help* buffer.  See also the command `describe-char'."
                     (single-key-description char))
                   encoding-msg pos total percent col hscroll))))))
 \f
-(defvar read-expression-map
-  (let ((m (make-sparse-keymap)))
-    (define-key m "\M-\t" 'lisp-complete-symbol)
-    (set-keymap-parent m minibuffer-local-map)
-    m)
-  "Minibuffer keymap used for reading Lisp expressions.")
+;; Initialize read-expression-map.  It is defined at C level.
+(let ((m (make-sparse-keymap)))
+  (define-key m "\M-\t" 'lisp-complete-symbol)
+  (set-keymap-parent m minibuffer-local-map)
+  (setq read-expression-map m))
 
 (defvar read-expression-history nil)
 
@@ -1501,8 +1500,7 @@ Call `undo-start' to get ready to undo recent changes,
 then call `undo-more' one or more times to undo them."
   (or (listp pending-undo-list)
       (error (concat "No further undo information"
-                     (and transient-mark-mode mark-active
-                          " for region"))))
+                    (and undo-in-region " for region"))))
   (let ((undo-in-progress t))
     (setq pending-undo-list (primitive-undo n pending-undo-list))
     (if (null pending-undo-list)
@@ -1649,12 +1647,12 @@ is not *inside* the region START...END."
        ((null (car undo-elt))
         ;; (nil PROPERTY VALUE BEG . END)
         (let ((tail (nthcdr 3 undo-elt)))
-          (not (or (< (car tail) end)
-                   (> (cdr tail) start)))))
+          (and (< (car tail) end)
+               (> (cdr tail) start))))
        ((integerp (car undo-elt))
         ;; (BEGIN . END)
-        (not (or (< (car undo-elt) end)
-                 (> (cdr undo-elt) start))))))
+        (and (< (car undo-elt) end)
+             (> (cdr undo-elt) start)))))
 
 ;; Return the first affected buffer position and the delta for an undo element
 ;; delta is defined as the change in subsequent buffer positions if we *did*
@@ -1676,7 +1674,7 @@ is not *inside* the region START...END."
 Normally, Emacs discards the undo info for the current command if
 it exceeds `undo-outer-limit'.  But if you set this option
 non-nil, it asks in the echo area whether to discard the info.
-If you answer no, there a slight risk that Emacs might crash, so
+If you answer no, there is a slight risk that Emacs might crash, so
 only do it if you really want to undo the command.
 
 This option is mainly intended for debugging.  You have to be
@@ -2659,7 +2657,7 @@ The argument is used for internal purposes; do not supply one."
 ;; This is actually used in subr.el but defcustom does not work there.
 (defcustom yank-excluded-properties
   '(read-only invisible intangible field mouse-face help-echo local-map keymap
-    yank-handler follow-link)
+    yank-handler follow-link fontified)
   "*Text properties to discard when yanking.
 The value should be a list of text properties to discard or t,
 which means to discard all text properties."
@@ -2727,7 +2725,7 @@ When this command inserts killed text into the buffer, it honors
 `yank-excluded-properties' and `yank-handler' as described in the
 doc string for `insert-for-yank-1', which see.
 
-See also the command \\[yank-pop]."
+See also the command `yank-pop' (\\[yank-pop])."
   (interactive "*P")
   (setq yank-window-start (window-start))
   ;; If we don't get all the way thru, make last-command indicate that
@@ -3487,49 +3485,51 @@ Outline mode sets this."
          (set-window-vscroll nil (- vs (frame-char-height)) t)))
 
     ;; Move forward (down).
-    (let ((wvis (window-line-visibility)))
-      (when (or (null wvis)
-               (and (consp wvis)
-                    (or (>= (car wvis) (frame-char-height))
-                        (>= (cdr wvis) (frame-char-height)))))
-       (let* ((wend (window-end nil t))
-              (evis (or (pos-visible-in-window-p wend nil t)
-                        (pos-visible-in-window-p (1- wend) nil t)))
-              (rbot (nth 3 evis))
-              (vpos (nth 5 evis))
-              ppos py vs)
-         (cond
-          ;; Last window line should be visible - fail if not.
-          ((null evis)
-           nil)
-          ;; If last line of window is fully visible, move forward.
-          ((null rbot)
-           nil)
-          ;; If cursor is not in the bottom scroll margin, move forward.
-          ((< (setq ppos (posn-at-point)
-                    py (cdr (or (posn-actual-col-row ppos)
-                                (posn-col-row ppos))))
-              (min (- (window-text-height) scroll-margin 1) (1- vpos)))
-           nil)
-          ;; When already vscrolled, we vscroll some more if we can,
-          ;; or clear vscroll and move forward at end of tall image.
-          ((> (setq vs (window-vscroll nil t)) 0)
-           (when (> rbot 0)
-             (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t)))
-          ;; If cursor just entered the bottom scroll margin, move forward,
-          ;; but also vscroll one line so redisplay wont recenter.
-          ((= py (min (- (window-text-height) scroll-margin 1)
-                      (1- vpos)))
-           (set-window-vscroll nil (frame-char-height) t)
-           (line-move-1 arg noerror to-end)
-           t)
-          ;; If there are lines above the last line, scroll-up one line.
-          ((> vpos 0)
-           (scroll-up 1)
-           t)
-          ;; Finally, start vscroll.
-          (t
-           (set-window-vscroll nil (frame-char-height) t))))))))
+    (let* ((lh (window-line-height -1))
+          (vpos (nth 1 lh))
+          (ypos (nth 2 lh))
+          (rbot (nth 3 lh))
+          ppos py vs)
+      (when (or (null lh)
+               (>= rbot (frame-char-height))
+               (<= ypos (- (frame-char-height))))
+       (unless lh
+         (let ((wend (pos-visible-in-window-p t nil t)))
+           (setq rbot (nth 3 wend)
+                 vpos (nth 5 wend))))
+       (cond
+        ;; If last line of window is fully visible, move forward.
+        ((or (null rbot) (= rbot 0))
+         nil)
+        ;; If cursor is not in the bottom scroll margin, move forward.
+        ((and (> vpos 0)
+              (< (setq py
+                       (or (nth 1 (window-line-height))
+                           (let ((ppos (posn-at-point)))
+                             (cdr (or (posn-actual-col-row ppos)
+                                      (posn-col-row ppos))))))
+                 (min (- (window-text-height) scroll-margin 1) (1- vpos))))
+         nil)
+        ;; When already vscrolled, we vscroll some more if we can,
+        ;; or clear vscroll and move forward at end of tall image.
+        ((> (setq vs (window-vscroll nil t)) 0)
+         (when (> rbot 0)
+           (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t)))
+        ;; If cursor just entered the bottom scroll margin, move forward,
+        ;; but also vscroll one line so redisplay wont recenter.
+        ((and (> vpos 0)
+              (= py (min (- (window-text-height) scroll-margin 1)
+                         (1- vpos))))
+         (set-window-vscroll nil (frame-char-height) t)
+         (line-move-1 arg noerror to-end)
+         t)
+        ;; If there are lines above the last line, scroll-up one line.
+        ((> vpos 0)
+         (scroll-up 1)
+         t)
+        ;; Finally, start vscroll.
+        (t
+         (set-window-vscroll nil (frame-char-height) t)))))))
 
 
 ;; This is like line-move-1 except that it also performs
@@ -3557,7 +3557,7 @@ Outline mode sets this."
   ;; for intermediate positions.
   (let ((inhibit-point-motion-hooks t)
        (opoint (point))
-       (forward (> arg 0)))
+       (orig-arg arg))
     (unwind-protect
        (progn
          (if (not (memq last-command '(next-line previous-line)))
@@ -3590,14 +3590,18 @@ Outline mode sets this."
                              'end-of-buffer)
                            nil)))
            ;; Move by arg lines, but ignore invisible ones.
-           (let (done)
+           (let (done line-end)
              (while (and (> arg 0) (not done))
                ;; If the following character is currently invisible,
                ;; skip all characters with that same `invisible' property value.
                (while (and (not (eobp)) (line-move-invisible-p (point)))
                  (goto-char (next-char-property-change (point))))
-               ;; Now move a line.
-               (end-of-line)
+               ;; Move a line.
+               ;; We don't use `end-of-line', since we want to escape
+               ;; from field boundaries ocurring exactly at point.
+               (let ((inhibit-field-text-motion t))
+                 (setq line-end (line-end-position)))
+               (goto-char (constrain-to-field line-end (point) t t))
                ;; If there's no invisibility here, move over the newline.
                (cond
                 ((eobp)
@@ -3620,7 +3624,14 @@ Outline mode sets this."
              ;; The logic of this is the same as the loop above,
              ;; it just goes in the other direction.
              (while (and (< arg 0) (not done))
-               (beginning-of-line)
+               ;; For completely consistency with the forward-motion
+               ;; case, we should call beginning-of-line here.
+               ;; However, if point is inside a field and on a
+               ;; continued line, the call to (vertical-motion -1)
+               ;; below won't move us back far enough; then we return
+               ;; to the same column in line-move-finish, and point
+               ;; gets stuck -- cyd
+               (forward-line 0)
                (cond
                 ((bobp)
                  (if (not noerror)
@@ -3655,7 +3666,7 @@ Outline mode sets this."
             (beginning-of-line))
            (t
             (line-move-finish (or goal-column temporary-goal-column)
-                              opoint forward))))))
+                              opoint (> orig-arg 0)))))))
 
 (defun line-move-finish (column opoint forward)
   (let ((repeat t))
@@ -3664,6 +3675,7 @@ Outline mode sets this."
       (setq repeat nil)
 
       (let (new
+           (old (point))
            (line-beg (save-excursion (beginning-of-line) (point)))
            (line-end
             ;; Compute the end of the line
@@ -3678,6 +3690,17 @@ Outline mode sets this."
 
        ;; Move to the desired column.
        (line-move-to-column column)
+
+       ;; Corner case: suppose we start out in a field boundary in
+       ;; the middle of a continued line.  When we get to
+       ;; line-move-finish, point is at the start of a new *screen*
+       ;; line but the same text line; then line-move-to-column would
+       ;; move us backwards. Test using C-n with point on the "x" in
+       ;;   (insert "a" (propertize "x" 'field t) (make-string 89 ?y))
+       (and forward
+            (< (point) old)
+            (goto-char old))
+
        (setq new (point))
 
        ;; Process intangibility within a line.
@@ -3717,8 +3740,15 @@ Outline mode sets this."
        (goto-char opoint)
        (let ((inhibit-point-motion-hooks nil))
          (goto-char
-          (constrain-to-field new opoint nil t
-                              'inhibit-line-move-field-capture)))
+          ;; Ignore field boundaries if the initial and final
+          ;; positions have the same `field' property, even if the
+          ;; fields are non-contiguous.  This seems to be "nicer"
+          ;; behavior in many situations.
+          (if (eq (get-char-property new 'field)
+                  (get-char-property opoint 'field))
+              new
+            (constrain-to-field new opoint t t
+                                'inhibit-line-move-field-capture))))
 
        ;; If all this moved us to a different line,
        ;; retry everything within that new line.
@@ -4066,7 +4096,7 @@ With argument, do this that many times."
   (kill-region (point) (progn (forward-word arg) (point))))
 
 (defun backward-kill-word (arg)
-  "Kill characters backward until encountering the end of a word.
+  "Kill characters backward until encountering the beginning of a word.
 With argument, do this that many times."
   (interactive "p")
   (kill-word (- arg)))
@@ -4299,7 +4329,7 @@ The variable `selective-display' has a separate value for each buffer."
 (defvaralias 'default-indicate-unused-lines 'default-indicate-empty-lines)
 
 (defun toggle-truncate-lines (&optional arg)
-  "Toggle whether to fold or truncate long lines on the screen.
+  "Toggle whether to fold or truncate long lines for the current buffer.
 With arg, truncate long lines iff arg is positive.
 Note that in side-by-side windows, truncation is always enabled."
   (interactive "P")