/[emacs]/emacs/src/indent.c
ViewVC logotype

Diff of /emacs/src/indent.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.151 by pj, Thu Apr 25 12:13:58 2002 UTC revision 1.152 by ttn, Mon Jun 3 01:52:02 2002 UTC
# Line 47  int indent_tabs_mode; Line 47  int indent_tabs_mode;
47     Some things in set last_known_column_point to -1     Some things in set last_known_column_point to -1
48     to mark the memorized value as invalid.  */     to mark the memorized value as invalid.  */
49    
50  int last_known_column;  float last_known_column;
51    
52  /* Value of point when current_column was called.  */  /* Value of point when current_column was called.  */
53    
# Line 57  int last_known_column_point; Line 57  int last_known_column_point;
57    
58  int last_known_column_modified;  int last_known_column_modified;
59    
60  static int current_column_1 P_ ((void));  static float current_column_1 P_ ((void));
61  static int position_indentation P_ ((int));  static float position_indentation P_ ((int));
62    
63  /* Cache of beginning of line found by the last call of  /* Cache of beginning of line found by the last call of
64     current_column. */     current_column. */
# Line 329  check_composition (pos, pos_byte, point, Line 329  check_composition (pos, pos_byte, point,
329        }                                                                 \        }                                                                 \
330    } while (0)    } while (0)
331    
332    
333  DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0,  DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0,
334         doc: /* Return the horizontal position of point.  Beginning of line is column 0.         doc: /* Return the horizontal position of point.  Beginning of line is column 0.
335  This is calculated by adding together the widths of all the displayed  This is calculated by adding together the widths of all the displayed
# Line 342  however, ^M is treated as end of line wh Line 343  however, ^M is treated as end of line wh
343       ()       ()
344  {  {
345    Lisp_Object temp;    Lisp_Object temp;
346    XSETFASTINT (temp, current_column ());    XSETFASTINT (temp, (int) current_column ()); /* iftc */
347    return temp;    return temp;
348  }  }
349    
# Line 354  invalidate_current_column () Line 355  invalidate_current_column ()
355    last_known_column_point = 0;    last_known_column_point = 0;
356  }  }
357    
358  int  float
359  current_column ()  current_column ()
360  {  {
361    register int col;    register int col;
# Line 401  current_column () Line 402  current_column ()
402      {      {
403        EMACS_INT i, n;        EMACS_INT i, n;
404        Lisp_Object charvec;        Lisp_Object charvec;
405            
406        if (ptr == stop)        if (ptr == stop)
407          {          {
408            /* We stopped either for the beginning of the buffer            /* We stopped either for the beginning of the buffer
409               or for the gap.  */               or for the gap.  */
410            if (ptr == BEGV_ADDR)            if (ptr == BEGV_ADDR)
411              break;              break;
412              
413            /* It was the gap.  Jump back over it.  */            /* It was the gap.  Jump back over it.  */
414            stop = BEGV_ADDR;            stop = BEGV_ADDR;
415            ptr = GPT_ADDR;            ptr = GPT_ADDR;
416              
417            /* Check whether that brings us to beginning of buffer.  */            /* Check whether that brings us to beginning of buffer.  */
418            if (BEGV >= GPT)            if (BEGV >= GPT)
419              break;              break;
420          }          }
421    
422        c = *--ptr;        c = *--ptr;
423          
424        if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c)))        if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c)))
425          {          {
426            charvec = DISP_CHAR_VECTOR (dp, c);            charvec = DISP_CHAR_VECTOR (dp, c);
# Line 430  current_column () Line 431  current_column ()
431            charvec = Qnil;            charvec = Qnil;
432            n = 1;            n = 1;
433          }          }
434                
435        for (i = n - 1; i >= 0; --i)        for (i = n - 1; i >= 0; --i)
436          {          {
437            if (VECTORP (charvec))            if (VECTORP (charvec))
# Line 438  current_column () Line 439  current_column ()
439                /* This should be handled the same as                /* This should be handled the same as
440                   next_element_from_display_vector does it.  */                   next_element_from_display_vector does it.  */
441                Lisp_Object entry = AREF (charvec, i);                Lisp_Object entry = AREF (charvec, i);
442                  
443                if (INTEGERP (entry)                if (INTEGERP (entry)
444                    && GLYPH_CHAR_VALID_P (XFASTINT (entry)))                    && GLYPH_CHAR_VALID_P (XFASTINT (entry)))
445                  c = FAST_GLYPH_CHAR (XFASTINT (entry));                  c = FAST_GLYPH_CHAR (XFASTINT (entry));
446                else                else
447                  c = ' ';                  c = ' ';
448              }              }
449          
450            if (c >= 040 && c < 0177)            if (c >= 040 && c < 0177)
451              col++;              col++;
452            else if (c == '\n'            else if (c == '\n'
# Line 459  current_column () Line 460  current_column ()
460              {              {
461                if (tab_seen)                if (tab_seen)
462                  col = ((col + tab_width) / tab_width) * tab_width;                  col = ((col + tab_width) / tab_width) * tab_width;
463                  
464                post_tab += col;                post_tab += col;
465                col = 0;                col = 0;
466                tab_seen = 1;                tab_seen = 1;
# Line 501  current_column () Line 502  current_column ()
502     This function handles characters that are invisible     This function handles characters that are invisible
503     due to text properties or overlays.  */     due to text properties or overlays.  */
504    
505  static int  static float
506  current_column_1 ()  current_column_1 ()
507  {  {
508    register int tab_width = XINT (current_buffer->tab_width);    register int tab_width = XINT (current_buffer->tab_width);
# Line 615  current_column_1 () Line 616  current_column_1 ()
616              {              {
617                unsigned char *ptr;                unsigned char *ptr;
618                int bytes, width, wide_column;                int bytes, width, wide_column;
619                  
620                ptr = BYTE_POS_ADDR (scan_byte);                ptr = BYTE_POS_ADDR (scan_byte);
621                MULTIBYTE_BYTES_WIDTH (ptr, dp);                MULTIBYTE_BYTES_WIDTH (ptr, dp);
622                scan_byte += bytes;                scan_byte += bytes;
# Line 651  current_column_1 () Line 652  current_column_1 ()
652     If BEG is nil, that stands for the beginning of STRING.     If BEG is nil, that stands for the beginning of STRING.
653     If END is nil, that stands for the end of STRING.  */     If END is nil, that stands for the end of STRING.  */
654    
655  static int  static float
656  string_display_width (string, beg, end)  string_display_width (string, beg, end)
657       Lisp_Object string, beg, end;       Lisp_Object string, beg, end;
658  {  {
# Line 777  even if that goes past COLUMN; by defaul Line 778  even if that goes past COLUMN; by defaul
778  }  }
779    
780    
781  static int position_indentation P_ ((int));  static float position_indentation P_ ((int));
782    
783  DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation,  DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation,
784         0, 0, 0,         0, 0, 0,
# Line 791  following any initial whitespace.  */) Line 792  following any initial whitespace.  */)
792    
793    scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);    scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
794    
795    XSETFASTINT (val, position_indentation (PT_BYTE));    XSETFASTINT (val, (int) position_indentation (PT_BYTE)); /* iftc */
796    SET_PT_BOTH (opoint, opoint_byte);    SET_PT_BOTH (opoint, opoint_byte);
797    return val;    return val;
798  }  }
799    
800  static int  static float
801  position_indentation (pos_byte)  position_indentation (pos_byte)
802       register int pos_byte;       register int pos_byte;
803  {  {
# Line 846  position_indentation (pos_byte) Line 847  position_indentation (pos_byte)
847            /* The -1 and +1 arrange to point at the first byte of gap            /* The -1 and +1 arrange to point at the first byte of gap
848               (if STOP_POS_BYTE is the position of the gap)               (if STOP_POS_BYTE is the position of the gap)
849               rather than at the data after the gap.  */               rather than at the data after the gap.  */
850                
851            stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1;            stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1;
852            p = BYTE_POS_ADDR (pos_byte);            p = BYTE_POS_ADDR (pos_byte);
853          }          }
# Line 888  position_indentation (pos_byte) Line 889  position_indentation (pos_byte)
889    
890  int  int
891  indented_beyond_p (pos, pos_byte, column)  indented_beyond_p (pos, pos_byte, column)
892       int pos, pos_byte, column;       int pos, pos_byte;
893         float column;
894  {  {
895    int val;    float val;
896    int opoint = PT, opoint_byte = PT_BYTE;    int opoint = PT, opoint_byte = PT_BYTE;
897    
898    SET_PT_BOTH (pos, pos_byte);    SET_PT_BOTH (pos, pos_byte);
# Line 899  indented_beyond_p (pos, pos_byte, column Line 901  indented_beyond_p (pos, pos_byte, column
901    
902    val = position_indentation (PT_BYTE);    val = position_indentation (PT_BYTE);
903    SET_PT_BOTH (opoint, opoint_byte);    SET_PT_BOTH (opoint, opoint_byte);
904    return val >= column;    return val >= column;                 /* hmm, float comparison */
905  }  }
906    
907  DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p",  DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p",
# Line 1093  The return value is the current column. Line 1095  The return value is the current column.
1095        goal_pt_byte = PT_BYTE;        goal_pt_byte = PT_BYTE;
1096        Findent_to (make_number (col), Qnil);        Findent_to (make_number (col), Qnil);
1097        SET_PT_BOTH (goal_pt, goal_pt_byte);        SET_PT_BOTH (goal_pt, goal_pt_byte);
1098          
1099        /* Set the last_known... vars consistently.  */        /* Set the last_known... vars consistently.  */
1100        col = goal;        col = goal;
1101      }      }
# Line 1352  compute_motion (from, fromvpos, fromhpos Line 1354  compute_motion (from, fromvpos, fromhpos
1354               W_      ^---- next after the point               W_      ^---- next after the point
1355               ^----  next char. after the point.               ^----  next char. after the point.
1356               ----------               ----------
1357                        In case of wide-column character                        In case of wide-column character
1358    
1359           The problem here is continuation at a wide-column character.           The problem here is continuation at a wide-column character.
1360           In this case, the line may shorter less than WIDTH.           In this case, the line may shorter less than WIDTH.
# Line 1522  compute_motion (from, fromvpos, fromhpos Line 1524  compute_motion (from, fromvpos, fromhpos
1524          {          {
1525            EMACS_INT i, n;            EMACS_INT i, n;
1526            Lisp_Object charvec;            Lisp_Object charvec;
1527              
1528            c = FETCH_BYTE (pos_byte);            c = FETCH_BYTE (pos_byte);
1529    
1530            /* Check composition sequence.  */            /* Check composition sequence.  */
# Line 1588  compute_motion (from, fromvpos, fromhpos Line 1590  compute_motion (from, fromvpos, fromhpos
1590                    /* This should be handled the same as                    /* This should be handled the same as
1591                       next_element_from_display_vector does it.  */                       next_element_from_display_vector does it.  */
1592                    Lisp_Object entry = AREF (charvec, i);                    Lisp_Object entry = AREF (charvec, i);
1593                  
1594                    if (INTEGERP (entry)                    if (INTEGERP (entry)
1595                        && GLYPH_CHAR_VALID_P (XFASTINT (entry)))                        && GLYPH_CHAR_VALID_P (XFASTINT (entry)))
1596                      c = FAST_GLYPH_CHAR (XFASTINT (entry));                      c = FAST_GLYPH_CHAR (XFASTINT (entry));
1597                    else                    else
1598                      c = ' ';                      c = ' ';
1599                  }                  }
1600          
1601                if (c >= 040 && c < 0177)                if (c >= 040 && c < 0177)
1602                  hpos++;                  hpos++;
1603                else if (c == '\t')                else if (c == '\t')
# Line 1609  compute_motion (from, fromvpos, fromhpos Line 1611  compute_motion (from, fromvpos, fromhpos
1611                else if (c == '\n')                else if (c == '\n')
1612                  {                  {
1613                    if (selective > 0                    if (selective > 0
1614                        && indented_beyond_p (pos, pos_byte, selective))                        && indented_beyond_p (pos, pos_byte,
1615                                                (float) selective)) /* iftc */
1616                      {                      {
1617                        /* If (pos == to), we don't have to take care of                        /* If (pos == to), we don't have to take care of
1618                           selective display.  */                           selective display.  */
# Line 1624  compute_motion (from, fromvpos, fromhpos Line 1627  compute_motion (from, fromvpos, fromhpos
1627                                pos_byte = CHAR_TO_BYTE (pos);                                pos_byte = CHAR_TO_BYTE (pos);
1628                              }                              }
1629                            while (pos < to                            while (pos < to
1630                                   && indented_beyond_p (pos, pos_byte, selective));                                   && indented_beyond_p (pos, pos_byte,
1631                                                           (float) selective)); /* iftc */
1632                            /* Allow for the " ..." that is displayed for them. */                            /* Allow for the " ..." that is displayed for them. */
1633                            if (selective_rlen)                            if (selective_rlen)
1634                              {                              {
# Line 1874  vmotion (from, vtarget, w) Line 1878  vmotion (from, vtarget, w)
1878                   && ((selective > 0                   && ((selective > 0
1879                        && indented_beyond_p (XFASTINT (prevline),                        && indented_beyond_p (XFASTINT (prevline),
1880                                              CHAR_TO_BYTE (XFASTINT (prevline)),                                              CHAR_TO_BYTE (XFASTINT (prevline)),
1881                                              selective))                                              (float) selective)) /* iftc */
1882                       /* watch out for newlines with `invisible' property */                       /* watch out for newlines with `invisible' property */
1883                       || (propval = Fget_char_property (prevline,                       || (propval = Fget_char_property (prevline,
1884                                                         Qinvisible,                                                         Qinvisible,
# Line 1887  vmotion (from, vtarget, w) Line 1891  vmotion (from, vtarget, w)
1891                                   lmargin + (XFASTINT (prevline) == BEG                                   lmargin + (XFASTINT (prevline) == BEG
1892                                              ? start_hpos : 0),                                              ? start_hpos : 0),
1893                                   0,                                   0,
1894                                   from,                                   from,
1895                                   /* Don't care for VPOS...  */                                   /* Don't care for VPOS...  */
1896                                   1 << (BITS_PER_SHORT - 1),                                   1 << (BITS_PER_SHORT - 1),
1897                                   /* ... nor HPOS.  */                                   /* ... nor HPOS.  */
# Line 1934  vmotion (from, vtarget, w) Line 1938  vmotion (from, vtarget, w)
1938               && ((selective > 0               && ((selective > 0
1939                    && indented_beyond_p (XFASTINT (prevline),                    && indented_beyond_p (XFASTINT (prevline),
1940                                          CHAR_TO_BYTE (XFASTINT (prevline)),                                          CHAR_TO_BYTE (XFASTINT (prevline)),
1941                                          selective))                                          (float) selective)) /* iftc */
1942                   /* watch out for newlines with `invisible' property */                   /* watch out for newlines with `invisible' property */
1943                   || (propval = Fget_char_property (prevline, Qinvisible,                   || (propval = Fget_char_property (prevline, Qinvisible,
1944                                                     text_prop_object),                                                     text_prop_object),
# Line 1946  vmotion (from, vtarget, w) Line 1950  vmotion (from, vtarget, w)
1950                               lmargin + (XFASTINT (prevline) == BEG                               lmargin + (XFASTINT (prevline) == BEG
1951                                          ? start_hpos : 0),                                          ? start_hpos : 0),
1952                               0,                               0,
1953                               from,                               from,
1954                               /* Don't care for VPOS...  */                               /* Don't care for VPOS...  */
1955                               1 << (BITS_PER_SHORT - 1),                               1 << (BITS_PER_SHORT - 1),
1956                               /* ... nor HPOS.  */                               /* ... nor HPOS.  */
# Line 2015  whether or not it is currently displayed Line 2019  whether or not it is currently displayed
2019        old_buffer = w->buffer;        old_buffer = w->buffer;
2020        XSETBUFFER (w->buffer, current_buffer);        XSETBUFFER (w->buffer, current_buffer);
2021      }      }
2022          
2023    SET_TEXT_POS (pt, PT, PT_BYTE);    SET_TEXT_POS (pt, PT, PT_BYTE);
2024    start_display (&it, w, pt);    start_display (&it, w, pt);
2025    
# Line 2028  whether or not it is currently displayed Line 2032  whether or not it is currently displayed
2032    
2033    if (XINT (lines) != 0)    if (XINT (lines) != 0)
2034      move_it_by_lines (&it, XINT (lines), 0);      move_it_by_lines (&it, XINT (lines), 0);
2035      
2036    SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));    SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
2037    
2038    if (BUFFERP (old_buffer))    if (BUFFERP (old_buffer))
2039      w->buffer = old_buffer;      w->buffer = old_buffer;
2040      
2041    RETURN_UNGCPRO (make_number (it.vpos));    RETURN_UNGCPRO (make_number (it.vpos));
2042  }  }
2043    

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.152

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26