diff options
| author | Dmitry Antipov | 2013-08-29 11:03:18 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-29 11:03:18 +0400 |
| commit | d2b368135803170fc2d1f65237b7ef22676f9ecb (patch) | |
| tree | 366956b20df8e76e561878824bd5e96fa5936d85 /src/cmds.c | |
| parent | e8dfd19797fa7224ae726a8be78726fefd260c0e (diff) | |
| download | emacs-d2b368135803170fc2d1f65237b7ef22676f9ecb.tar.gz emacs-d2b368135803170fc2d1f65237b7ef22676f9ecb.zip | |
Hook scanning and indentation functions to find_newline. This helps
to avoid duplicated code and renders more respect to newline cache.
* lisp.h (scan_newline): Prefer ptrdiff_t to EMACS_INT.
* cmds.c (Fforward_line):
* indent.c (scan_for_column, Fcurrent_indentation, indented_beyond_p):
Use find_newline and avoid unnecessary point movements.
* search.c (scan_newline): Implement on top of find_newline.
Diffstat (limited to 'src/cmds.c')
| -rw-r--r-- | src/cmds.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/cmds.c b/src/cmds.c index ce91877f85e..ee3be79a0ab 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -121,9 +121,7 @@ With positive N, a non-empty line at the end counts as one line | |||
| 121 | successfully moved (for the return value). */) | 121 | successfully moved (for the return value). */) |
| 122 | (Lisp_Object n) | 122 | (Lisp_Object n) |
| 123 | { | 123 | { |
| 124 | ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; | 124 | ptrdiff_t opoint = PT, pos, pos_byte, shortage, count; |
| 125 | ptrdiff_t pos, pos_byte; | ||
| 126 | EMACS_INT count, shortage; | ||
| 127 | 125 | ||
| 128 | if (NILP (n)) | 126 | if (NILP (n)) |
| 129 | count = 1; | 127 | count = 1; |
| @@ -134,16 +132,12 @@ successfully moved (for the return value). */) | |||
| 134 | } | 132 | } |
| 135 | 133 | ||
| 136 | if (count <= 0) | 134 | if (count <= 0) |
| 137 | shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1); | 135 | pos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, |
| 136 | &shortage, &pos_byte, 1); | ||
| 138 | else | 137 | else |
| 139 | shortage = scan_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, 1); | 138 | pos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, |
| 140 | 139 | &shortage, &pos_byte, 1); | |
| 141 | /* Since scan_newline does TEMP_SET_PT_BOTH, | 140 | |
| 142 | and we want to set PT "for real", | ||
| 143 | go back to the old point and then come back here. */ | ||
| 144 | pos = PT; | ||
| 145 | pos_byte = PT_BYTE; | ||
| 146 | TEMP_SET_PT_BOTH (opoint, opoint_byte); | ||
| 147 | SET_PT_BOTH (pos, pos_byte); | 141 | SET_PT_BOTH (pos, pos_byte); |
| 148 | 142 | ||
| 149 | if (shortage > 0 | 143 | if (shortage > 0 |