emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111732: * marker.c (set_marker_inter


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111732: * marker.c (set_marker_internal): If desired position is passed
Date: Mon, 11 Feb 2013 14:21:52 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111732
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2013-02-11 14:21:52 +0400
message:
  * marker.c (set_marker_internal): If desired position is passed
  as a marker, avoid call to buf_charpos_to_bytepos.
  * window.c (Fset_window_point): Omit redundant type checking.
  (Fset_window_start): Likewise.  Format comment.
  (window_scroll_pixel_based): Use set_marker_restricted_both
  with character and byte positions obtained from an iterator.
  (Fset_window_configuration): Use set_marker_restricted_both.
  * xdisp.c (message_dolog): Likewise.
modified:
  src/ChangeLog
  src/marker.c
  src/window.c
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-02-10 16:49:09 +0000
+++ b/src/ChangeLog     2013-02-11 10:21:52 +0000
@@ -1,3 +1,14 @@
+2013-02-11  Dmitry Antipov  <address@hidden>
+
+       * marker.c (set_marker_internal): If desired position is passed
+       as a marker, avoid call to buf_charpos_to_bytepos.
+       * window.c (Fset_window_point): Omit redundant type checking.
+       (Fset_window_start): Likewise.  Format comment.
+       (window_scroll_pixel_based): Use set_marker_restricted_both
+       with character and byte positions obtained from an iterator.
+       (Fset_window_configuration): Use set_marker_restricted_both.
+       * xdisp.c (message_dolog): Likewise.
+
 2013-02-10  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (move_it_vertically_backward, move_it_by_lines): When

=== modified file 'src/marker.c'
--- a/src/marker.c      2013-01-02 16:13:04 +0000
+++ b/src/marker.c      2013-02-11 10:21:52 +0000
@@ -499,11 +499,29 @@
     {
       register ptrdiff_t charpos, bytepos;
 
-      CHECK_NUMBER_COERCE_MARKER (position);
-      charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b),
-                               XINT (position),
-                               restricted ? BUF_ZV (b) : BUF_Z (b));
-      bytepos = buf_charpos_to_bytepos (b, charpos);
+      /* Do not use CHECK_NUMBER_COERCE_MARKER because we
+        don't want to call buf_charpos_to_bytepos if POSTION
+        is a marker and so we know the bytepos already.  */
+      if (INTEGERP (position))
+       charpos = XINT (position), bytepos = -1;
+      else if (MARKERP (position))
+       {
+         charpos = XMARKER (position)->charpos;
+         bytepos = XMARKER (position)->bytepos;
+       }
+      else
+       wrong_type_argument (Qinteger_or_marker_p, position);
+
+      charpos = clip_to_bounds
+       (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos,
+        restricted ? BUF_ZV (b) : BUF_Z (b));
+      if (bytepos == -1)
+       bytepos = buf_charpos_to_bytepos (b, charpos);
+      else
+       bytepos = clip_to_bounds
+         (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b),
+          bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b));
+
       attach_marker (m, b, charpos, bytepos);
     }
   return marker;

=== modified file 'src/window.c'
--- a/src/window.c      2013-02-08 05:28:52 +0000
+++ b/src/window.c      2013-02-11 10:21:52 +0000
@@ -1544,7 +1544,7 @@
 {
   register struct window *w = decode_live_window (window);
 
-  CHECK_NUMBER_COERCE_MARKER (pos);
+  /* Type of POS is checked by Fgoto_char or set_marker_restricted ...  */
 
   if (w == XWINDOW (selected_window))
     {
@@ -1554,6 +1554,8 @@
        {
          struct buffer *old_buffer = current_buffer;
 
+         /* ... but here we want to catch type error before buffer change.  */
+         CHECK_NUMBER_COERCE_MARKER (pos);
          set_buffer_internal (XBUFFER (w->buffer));
          Fgoto_char (pos);
          set_buffer_internal (old_buffer);
@@ -1579,9 +1581,8 @@
 {
   register struct window *w = decode_live_window (window);
 
-  CHECK_NUMBER_COERCE_MARKER (pos);
   set_marker_restricted (w->start, pos, w->buffer);
-  /* this is not right, but much easier than doing what is right. */
+  /* This is not right, but much easier than doing what is right.  */
   w->start_at_line_beg = 0;
   if (NILP (noforce))
     w->force_start = 1;
@@ -4615,8 +4616,8 @@
        }
 
       /* Set the window start, and set up the window for redisplay.  */
-      set_marker_restricted (w->start, make_number (pos),
-                            w->buffer);
+      set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it),
+                                 IT_BYTEPOS (it));
       bytepos = marker_byte_position (w->start);
       w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
       w->update_mode_line = 1;
@@ -5795,8 +5796,7 @@
             {
               /* Set window markers at start of visible range.  */
               if (XMARKER (w->start)->buffer == 0)
-                set_marker_restricted (w->start, make_number (0),
-                                       w->buffer);
+                set_marker_restricted_both (w->start, w->buffer, 0, 0);
               if (XMARKER (w->pointm)->buffer == 0)
                 set_marker_restricted_both
                   (w->pointm, w->buffer,
@@ -5814,10 +5814,8 @@
              wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
              /* This will set the markers to beginning of visible
                 range.  */
-             set_marker_restricted (w->start,
-                                    make_number (0), w->buffer);
-             set_marker_restricted (w->pointm,
-                                    make_number (0), w->buffer);
+             set_marker_restricted_both (w->start, w->buffer, 0, 0);
+             set_marker_restricted_both (w->pointm, w->buffer, 0, 0);
              w->start_at_line_beg = 1;
              if (!NILP (w->dedicated))
                /* Record this window as dead.  */

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-02-10 16:49:09 +0000
+++ b/src/xdisp.c       2013-02-11 10:21:52 +0000
@@ -9396,11 +9396,11 @@
       bset_undo_list (current_buffer, Qt);
 
       oldpoint = message_dolog_marker1;
-      set_marker_restricted (oldpoint, make_number (PT), Qnil);
+      set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE);
       oldbegv = message_dolog_marker2;
-      set_marker_restricted (oldbegv, make_number (BEGV), Qnil);
+      set_marker_restricted_both (oldbegv, Qnil, BEGV, BEGV_BYTE);
       oldzv = message_dolog_marker3;
-      set_marker_restricted (oldzv, make_number (ZV), Qnil);
+      set_marker_restricted_both (oldzv, Qnil, ZV, ZV_BYTE);
       GCPRO1 (old_deactivate_mark);
 
       if (PT == Z)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]