Mercurial > hg > xemacs-beta
comparison src/buffer.c @ 5914:bd4d2c8ef9cc
Use the existing C-level line number cache within #'line-number.
src/ChangeLog addition:
2015-05-15 Aidan Kehoe <kehoea@parhasard.net>
* buffer.c:
* buffer.c (Fline_number): New C implementation, using the line
number cache of line-number.c, with a new optional BUFFER
argument.
* buffer.c (syms_of_buffer):
Make it available to Lisp.
* line-number.c (buffer_line_number):
New argument, RESPECT-NARROWING, describing whether to count from
the beginning of the visible region or from the beginning of the
buffer.
* line-number.h:
* line-number.h (buffer_line_number): Update its declaration.
* redisplay.c (window_line_number): Call it with the new argument.
lisp/ChangeLog addition:
2015-05-15 Aidan Kehoe <kehoea@parhasard.net>
* simple.el:
* simple.el (line-number): Moved to buffer.c; we have an existing
line number cache in C, it's a shame not to have it available.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 15 May 2015 18:11:47 +0100 |
parents | 8139bdf8db04 |
children |
comparison
equal
deleted
inserted
replaced
5913:1b2fdcc3cc5c | 5914:bd4d2c8ef9cc |
---|---|
83 #include "extents.h" | 83 #include "extents.h" |
84 #include "faces.h" | 84 #include "faces.h" |
85 #include "file-coding.h" | 85 #include "file-coding.h" |
86 #include "frame-impl.h" | 86 #include "frame-impl.h" |
87 #include "insdel.h" | 87 #include "insdel.h" |
88 #include "line-number.h" | |
88 #include "lstream.h" | 89 #include "lstream.h" |
89 #include "process.h" /* for kill_buffer_processes */ | 90 #include "process.h" /* for kill_buffer_processes */ |
90 #ifdef REGION_CACHE_NEEDS_WORK | 91 #ifdef REGION_CACHE_NEEDS_WORK |
91 #include "region-cache.h" | 92 #include "region-cache.h" |
92 #endif | 93 #endif |
1744 commands call this function. */ | 1745 commands call this function. */ |
1745 MARK_MODELINE_CHANGED; | 1746 MARK_MODELINE_CHANGED; |
1746 | 1747 |
1747 return Qnil; | 1748 return Qnil; |
1748 } | 1749 } |
1749 | 1750 |
1751 /* It was a shame to have the line number cache around and not used from | |
1752 Lisp, so move this here from simple.el. */ | |
1753 | |
1754 DEFUN ("line-number", Fline_number, 0, 3, 0, /* | |
1755 Return the line number of POSITION within BUFFER. | |
1756 | |
1757 POSITION defaults to point. If RESPECT-NARROWING is non-nil, then the narrowed | |
1758 line number is returned; otherwise, the absolute line number is returned. The | |
1759 returned line can always be given to `goto-line' to get back to the current | |
1760 line. | |
1761 */ | |
1762 (position, respect_narrowing, buffer_)) | |
1763 { | |
1764 struct buffer *buf = decode_buffer (buffer_, 0); | |
1765 Charbpos pos = (NILP (position) ? BUF_PT (buf) : | |
1766 get_buffer_pos_char (buf, position, GB_COERCE_RANGE)); | |
1767 | |
1768 return make_fixnum (buffer_line_number (buf, pos, 1, | |
1769 !NILP (respect_narrowing)) + 1); | |
1770 } | |
1771 | |
1750 #ifdef MEMORY_USAGE_STATS | 1772 #ifdef MEMORY_USAGE_STATS |
1751 | 1773 |
1752 struct buffer_stats | 1774 struct buffer_stats |
1753 { | 1775 { |
1754 struct usage_stats u; | 1776 struct usage_stats u; |
1950 DEFSUBR (Fcurrent_buffer); | 1972 DEFSUBR (Fcurrent_buffer); |
1951 DEFSUBR (Fset_buffer); | 1973 DEFSUBR (Fset_buffer); |
1952 DEFSUBR (Fbarf_if_buffer_read_only); | 1974 DEFSUBR (Fbarf_if_buffer_read_only); |
1953 DEFSUBR (Fbury_buffer); | 1975 DEFSUBR (Fbury_buffer); |
1954 DEFSUBR (Fkill_all_local_variables); | 1976 DEFSUBR (Fkill_all_local_variables); |
1977 DEFSUBR (Fline_number); | |
1955 #if defined (DEBUG_XEMACS) && defined (MULE) | 1978 #if defined (DEBUG_XEMACS) && defined (MULE) |
1956 DEFSUBR (Fbuffer_char_byte_converion_info); | 1979 DEFSUBR (Fbuffer_char_byte_converion_info); |
1957 DEFSUBR (Fstring_char_byte_converion_info); | 1980 DEFSUBR (Fstring_char_byte_converion_info); |
1958 #endif | 1981 #endif |
1959 | 1982 |