]> code.delx.au - gnu-emacs/commitdiff
* intervals.c (set_point_from_marker): New function.
authorDmitry Antipov <dmantipov@yandex.ru>
Thu, 29 Aug 2013 16:36:54 +0000 (20:36 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Thu, 29 Aug 2013 16:36:54 +0000 (20:36 +0400)
* editfns.c (Fgoto_char):
* process.c (Finternal_default_process_filter):
* window.c (select_window_1): Use it.
* buffer.h (set_point_from_marker): Add prototype.

src/ChangeLog
src/buffer.h
src/editfns.c
src/intervals.c
src/process.c
src/window.c

index 0a24427f683e46818cec6e74591bcce296fabbca..c605c5ec4d38911bd20f5110a291f535aa5334aa 100644 (file)
@@ -1,3 +1,11 @@
+2013-08-29  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * intervals.c (set_point_from_marker): New function.
+       * editfns.c (Fgoto_char):
+       * process.c (Finternal_default_process_filter):
+       * window.c (select_window_1): Use it.
+       * buffer.h (set_point_from_marker): Add prototype.
+
 2013-08-29  Eli Zaretskii  <eliz@gnu.org>
 
        * w32.c (term_winsock): Call release_listen_threads before calling
index bedb7890939eb4deaf5277ce49c5f9bc36016f41..169a15c7d0fa99183102c04bcd098fcf0d7007c9 100644 (file)
@@ -249,6 +249,7 @@ extern void temp_set_point (struct buffer *, ptrdiff_t);
 extern void set_point_both (ptrdiff_t, ptrdiff_t);
 extern void temp_set_point_both (struct buffer *,
                                 ptrdiff_t, ptrdiff_t);
+extern void set_point_from_marker (Lisp_Object);
 extern void enlarge_buffer_text (struct buffer *, ptrdiff_t);
 
 \f
index 9e36655f3d3ae96d09842f787f7baffe763cb425..84a5c8395fcbe735862dd8e5f24321ff6dee12ab 100644 (file)
@@ -233,26 +233,12 @@ Beginning of buffer is position (point-min), end is (point-max).
 The return value is POSITION.  */)
   (register Lisp_Object position)
 {
-  ptrdiff_t pos;
-
-  if (MARKERP (position)
-      && current_buffer == XMARKER (position)->buffer)
-    {
-      pos = marker_position (position);
-      if (pos < BEGV)
-       SET_PT_BOTH (BEGV, BEGV_BYTE);
-      else if (pos > ZV)
-       SET_PT_BOTH (ZV, ZV_BYTE);
-      else
-       SET_PT_BOTH (pos, marker_byte_position (position));
-
-      return position;
-    }
-
-  CHECK_NUMBER_COERCE_MARKER (position);
-
-  pos = clip_to_bounds (BEGV, XINT (position), ZV);
-  SET_PT (pos);
+  if (MARKERP (position))
+    set_point_from_marker (position);
+  else if (INTEGERP (position))
+    SET_PT (clip_to_bounds (BEGV, XINT (position), ZV));
+  else
+    wrong_type_argument (Qinteger_or_marker_p, position);
   return position;
 }
 
index f2ddcd01507727f2ee90bc9f84cad2991ecfe456..671b2a3d527efd7000f85f63023c178bf1d29699 100644 (file)
@@ -1821,6 +1821,18 @@ set_point (ptrdiff_t charpos)
   set_point_both (charpos, buf_charpos_to_bytepos (current_buffer, charpos));
 }
 
+/* Set PT from MARKER's clipped position.  */
+
+void
+set_point_from_marker (Lisp_Object marker)
+{
+  if (XMARKER (marker)->buffer != current_buffer)
+    error ("Marker points into wrong buffer");
+  set_point_both
+    (clip_to_bounds (BEGV, marker_position (marker), ZV),
+     clip_to_bounds (BEGV_BYTE, marker_byte_position (marker), ZV_BYTE));
+}
+
 /* If there's an invisible character at position POS + TEST_OFFS in the
    current buffer, and the invisible property has a `stickiness' such that
    inserting a character at position POS would inherit the property it,
index b52622ec1b671605dc91d5e0330e2eb316cfdb8e..20f84990d6f84a5be55eec5f36fb5161a45aca63 100644 (file)
@@ -5178,15 +5178,10 @@ DEFUN ("internal-default-process-filter", Finternal_default_process_filter,
 
       bset_read_only (current_buffer, Qnil);
 
-      /* Insert new output into buffer
-        at the current end-of-output marker,
-        thus preserving logical ordering of input and output.  */
+      /* Insert new output into buffer at the current end-of-output
+        marker, thus preserving logical ordering of input and output.  */
       if (XMARKER (p->mark)->buffer)
-       SET_PT_BOTH (clip_to_bounds (BEGV,
-                                    marker_position (p->mark), ZV),
-                    clip_to_bounds (BEGV_BYTE,
-                                    marker_byte_position (p->mark),
-                                    ZV_BYTE));
+       set_point_from_marker (p->mark);
       else
        SET_PT_BOTH (ZV, ZV_BYTE);
       before = PT;
index e40572bf13df43b29ba48ab8df3724ff618163bc..d60ee06077fc4a11d518472e0ce51bcd071e5616 100644 (file)
@@ -549,15 +549,7 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap)
      than one window.  It also matters when
      redisplay_window has altered point after scrolling,
      because it makes the change only in the window.  */
-  {
-    register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm);
-    if (new_point < BEGV)
-      SET_PT (BEGV);
-    else if (new_point > ZV)
-      SET_PT (ZV);
-    else
-      SET_PT (new_point);
-  }
+  set_point_from_marker (XWINDOW (window)->pointm);
 }
 
 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,