Mercurial > hg > xemacs-beta
annotate src/insdel.h @ 5882:bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
lisp/ChangeLog addition:
2015-04-01 Aidan Kehoe <kehoea@parhasard.net>
When calling #'string-match with a REGEXP without regular
expression special characters, call #'search, #'mismatch, #'find,
etc. instead, making our code less likely to side-effect other
functions' match data and a little faster.
* apropos.el (apropos-command):
* apropos.el (apropos):
Call (position ?\n ...) rather than (string-match "\n" ...) here.
* buff-menu.el:
* buff-menu.el (buffers-menu-omit-invisible-buffers):
Don't fire up the regexp engine just to check if a string starts
with a space.
* buff-menu.el (select-buffers-tab-buffers-by-mode):
Don't fire up the regexp engine just to compare mode basenames.
* buff-menu.el (format-buffers-tab-line):
* buff-menu.el (build-buffers-tab-internal): Moved to being a
label within the following.
* buff-menu.el (buffers-tab-items): Use the label.
* bytecomp.el (byte-compile-log-1):
Don't fire up the regexp engine just to look for a newline.
* cus-edit.el (get):
Ditto.
* cus-edit.el (custom-variable-value-create):
Ditto, but for a colon.
* descr-text.el (describe-text-sexp):
Ditto.
* descr-text.el (describe-char-unicode-data):
Use #'split-string-by-char given that we're just looking for a
semicolon.
* descr-text.el (describe-char):
Don't fire up the regexp engine just to look for a newline.
* disass.el (disassemble-internal):
Ditto.
* files.el (file-name-sans-extension):
Implement this using #'position.
* files.el (file-name-extension):
Correct this function's docstring, implement it in terms of
#'position.
* files.el (insert-directory):
Don't fire up the regexp engine to split a string by space; don't
reverse the list of switches, this is actually a longstand bug as
far as I can see.
* gnuserv.el (gnuserv-process-filter):
Use #'position here, instead of consing inside #'split-string
needlessly.
* gtk-file-dialog.el (gtk-file-dialog-update-dropdown):
Use #'split-string-by-char here, don't fire up #'split-string for
directory-sep-char.
* gtk-font-menu.el (hack-font-truename):
Implement this more cheaply in terms of #'find,
#'split-string-by-char, #'equal, rather than #'string-match,
#'split-string, #'string-equal.
* hyper-apropos.el (hyper-apropos-grok-functions):
* hyper-apropos.el (hyper-apropos-grok-variables):
Look for a newline using #'position rather than #'string-match in
these functions.
* info.el (Info-insert-dir):
* info.el (Info-insert-file-contents):
* info.el (Info-follow-reference):
* info.el (Info-extract-menu-node-name):
* info.el (Info-menu):
Look for fixed strings using #'position or #'search as appropriate
in this file.
* ldap.el (ldap-decode-string):
* ldap.el (ldap-encode-string):
#'encode-coding-string, #'decode-coding-string are always
available, don't check if they're fboundp.
* ldap.el (ldap-decode-address):
* ldap.el (ldap-encode-address):
Use #'split-string-by-char in these functions.
* lisp-mnt.el (lm-creation-date):
* lisp-mnt.el (lm-last-modified-date):
Don't fire up the regexp engine just to look for spaces in this file.
* menubar-items.el (default-menubar):
Use (not (mismatch ...)) rather than #'string-match here, for
simple regexp.
Use (search "beta" ...) rather than (string-match "beta" ...)
* menubar-items.el (sort-buffers-menu-alphabetically):
* menubar-items.el (sort-buffers-menu-by-mode-then-alphabetically):
* menubar-items.el (group-buffers-menu-by-mode-then-alphabetically):
Don't fire up the regexp engine to check if a string starts with
a space or an asterisk.
Use the more fine-grained results of #'compare-strings; compare
case-insensitively for the buffer menu.
* menubar-items.el (list-all-buffers):
* menubar-items.el (tutorials-menu-filter):
Use #'equal rather than #'string-equal, which, in this context,
has the drawback of not having a bytecode, and no redeeming
features.
* minibuf.el:
* minibuf.el (un-substitute-in-file-name):
Use #'count, rather than counting the occurences of $ using the
regexp engine.
* minibuf.el (read-file-name-internal-1):
Don't fire up the regexp engine to search for ?=.
* mouse.el (mouse-eval-sexp):
Check for newline with #'find.
* msw-font-menu.el (mswindows-reset-device-font-menus):
Split a string by newline with #'split-string-by-char.
* mule/japanese.el:
* mule/japanese.el ("Japanese"):
Use #'search rather than #'string-match; canoncase before
comparing; fix a bug I had introduced where I had been making case
insensitive comparisons where the case mattered.
* mule/korea-util.el (default-korean-keyboard):
Look for ?3 using #'find, not #'string-march.
* mule/korea-util.el (quail-hangul-switch-hanja):
Search for a fixed string using #'search.
* mule/mule-cmds.el (set-locale-for-language-environment):
#'position, #'substitute rather than #'string-match,
#'replace-in-string.
* newcomment.el (comment-make-extra-lines):
Use #'search rather than #'string-match for a simple string.
* package-get.el (package-get-remote-filename):
Use #'position when looking for ?@
* process.el (setenv):
* process.el (read-envvar-name):
Use #'position when looking for ?=.
* replace.el (map-query-replace-regexp):
Use #'split-string-by-char instead of using an inline
implementation of it.
* select.el (select-convert-from-cf-text):
* select.el (select-convert-from-cf-unicodetext):
Use #'position rather than #'string-match in these functions.
* setup-paths.el (paths-emacs-data-root-p):
Use #'search when looking for simple string.
* sound.el (load-sound-file):
Use #'split-string-by-char rather than an inline reimplementation
of same.
* startup.el (splash-screen-window-body):
* startup.el (splash-screen-tty-body):
Search for simple strings using #'search.
* version.el (emacs-version):
Ditto.
* x-font-menu.el (hack-font-truename):
Implement this more cheaply in terms of #'find,
#'split-string-by-char, #'equal, rather than #'string-match,
#'split-string, #'string-equal.
* x-font-menu.el (x-reset-device-font-menus-core):
Use #'split-string-by-char here.
* x-init.el (x-initialize-keyboard):
Search for a simple string using #'search.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 01 Apr 2015 14:28:20 +0100 |
parents | 77d7b77909c2 |
children |
rev | line source |
---|---|
428 | 1 /* Buffer insertion/deletion and gap motion for XEmacs. |
2 Copyright (C) 1985-1994 Free Software Foundation, Inc. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4953
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
428 | 7 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4953
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4953
diff
changeset
|
9 option) any later version. |
428 | 10 |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4953
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 18 |
19 /* Synched up with: Not in FSF. */ | |
20 | |
21 /* Mostly rewritten by Ben Wing. */ | |
22 | |
440 | 23 #ifndef INCLUDED_insdel_h_ |
24 #define INCLUDED_insdel_h_ | |
428 | 25 |
26 /************************************************************************/ | |
27 /* changing a buffer's text */ | |
28 /************************************************************************/ | |
29 | |
665 | 30 int begin_multiple_change (struct buffer *buf, Charbpos start, Charbpos end); |
428 | 31 void end_multiple_change (struct buffer *buf, int count); |
32 | |
33 /* flags for functions below */ | |
34 | |
35 #define INSDEL_BEFORE_MARKERS 1 | |
36 #define INSDEL_NO_LOCKING 2 | |
37 | |
665 | 38 Charcount buffer_insert_string_1 (struct buffer *buf, Charbpos pos, |
867 | 39 const Ibyte *nonreloc, Lisp_Object reloc, |
428 | 40 Bytecount offset, Bytecount length, |
5776
65d65b52d608
Pass character count from coding systems to buffer insertion code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
41 Charcount clen, int flags); |
665 | 42 Charcount buffer_insert_raw_string_1 (struct buffer *buf, Charbpos pos, |
867 | 43 const Ibyte *nonreloc, |
428 | 44 Bytecount length, int flags); |
665 | 45 Charcount buffer_insert_lisp_string_1 (struct buffer *buf, Charbpos pos, |
428 | 46 Lisp_Object str, int flags); |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
867
diff
changeset
|
47 Charcount buffer_insert_ascstring_1 (struct buffer *buf, Charbpos pos, |
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
867
diff
changeset
|
48 const Ascbyte *s, int flags); |
665 | 49 Charcount buffer_insert_emacs_char_1 (struct buffer *buf, Charbpos pos, |
867 | 50 Ichar ch, int flags); |
665 | 51 Charcount buffer_insert_c_char_1 (struct buffer *buf, Charbpos pos, char c, |
428 | 52 int flags); |
665 | 53 Charcount buffer_insert_from_buffer_1 (struct buffer *buf, Charbpos pos, |
54 struct buffer *buf2, Charbpos pos2, | |
428 | 55 Charcount length, int flags); |
56 | |
57 /* Macros for insertion functions that insert at point after markers. | |
58 All of these can GC. */ | |
59 | |
60 #define buffer_insert_string(buf, nonreloc, reloc, offset, length) \ | |
5776
65d65b52d608
Pass character count from coding systems to buffer insertion code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
61 buffer_insert_string_1 (buf, -1, nonreloc, reloc, offset, length, -1, 0) |
428 | 62 #define buffer_insert_raw_string(buf, string, length) \ |
63 buffer_insert_raw_string_1 (buf, -1, string, length, 0) | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
867
diff
changeset
|
64 #define buffer_insert_ascstring(buf, s) \ |
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
867
diff
changeset
|
65 buffer_insert_ascstring_1 (buf, -1, s, 0) |
428 | 66 #define buffer_insert_lisp_string(buf, str) \ |
67 buffer_insert_lisp_string_1 (buf, -1, str, 0) | |
68 #define buffer_insert_c_char(buf, c) \ | |
69 buffer_insert_c_char_1 (buf, -1, c, 0) | |
70 #define buffer_insert_emacs_char(buf, ch) \ | |
71 buffer_insert_emacs_char_1 (buf, -1, ch, 0) | |
72 #define buffer_insert_from_buffer(buf, b, index, length) \ | |
73 buffer_insert_from_buffer_1 (buf, -1, b, index, length, 0) | |
74 | |
665 | 75 void buffer_delete_range (struct buffer *buf, Charbpos from, Charbpos to, |
428 | 76 int flags); |
867 | 77 void buffer_replace_char (struct buffer *b, Charbpos pos, Ichar ch, |
428 | 78 int not_real_change, int force_lock_check); |
79 | |
80 | |
81 /************************************************************************/ | |
82 /* tracking buffer changes */ | |
83 /************************************************************************/ | |
84 | |
85 /* Split into two parts. One part goes with a buffer's text (possibly | |
86 shared), the other with the buffer itself. */ | |
87 | |
88 struct buffer_text_change_data | |
89 { | |
90 /* multiple change stuff */ | |
91 int in_multiple_change; | |
665 | 92 Charbpos mc_begin, mc_orig_end, mc_new_end; |
428 | 93 int mc_begin_signaled; |
94 }; | |
95 | |
96 struct each_buffer_change_data | |
97 { | |
98 Charcount begin_unchanged, end_unchanged; | |
99 /* redisplay needs to know if a newline was deleted so its | |
100 incremental-redisplay algorithm will fail */ | |
101 int newline_was_deleted; | |
5879
77d7b77909c2
Move extents.c to working in byte positions only; fix a bug, extent_detach()
Aidan Kehoe <kehoea@parhasard.net>
parents:
5776
diff
changeset
|
102 Bytecount begin_extent_unchanged, end_extent_unchanged; |
428 | 103 }; |
104 | |
105 /* Number of characters at the beginning and end of the buffer that | |
106 have not changed since the last call to buffer_reset_changes(). | |
107 If no changes have occurred since then, both values will be -1. | |
108 | |
109 "Changed" means that the text has changed. */ | |
110 | |
111 #define BUF_BEGIN_UNCHANGED(buf) ((buf)->changes->begin_unchanged) | |
112 #define BUF_END_UNCHANGED(buf) ((buf)->changes->end_unchanged) | |
113 | |
5879
77d7b77909c2
Move extents.c to working in byte positions only; fix a bug, extent_detach()
Aidan Kehoe <kehoea@parhasard.net>
parents:
5776
diff
changeset
|
114 /* Number of bytes at the beginning and end of the buffer that |
428 | 115 have not had a covering extent change since the last call to |
116 buffer_reset_changes (). If no changes have occurred since then, | |
117 both values will be -1. | |
118 | |
119 "Changed" means that the extents covering the text have changed. */ | |
120 | |
121 #define BUF_EXTENT_BEGIN_UNCHANGED(buf) \ | |
122 ((buf)->changes->begin_extent_unchanged) | |
123 #define BUF_EXTENT_END_UNCHANGED(buf) \ | |
124 ((buf)->changes->end_extent_unchanged) | |
125 | |
126 #define BUF_NEWLINE_WAS_DELETED(buf) \ | |
127 ((buf)->changes->newline_was_deleted) | |
128 | |
129 void buffer_extent_signal_changed_region (struct buffer *buf, | |
665 | 130 Charbpos start, |
131 Charbpos end); | |
428 | 132 void buffer_reset_changes (struct buffer *buf); |
133 | |
134 | |
135 | |
136 /************************************************************************/ | |
137 /* other related functions */ | |
138 /************************************************************************/ | |
139 | |
665 | 140 Membpos do_marker_adjustment (Membpos mpos, Membpos from, |
141 Membpos to, Bytecount amount); | |
428 | 142 |
867 | 143 void fixup_internal_substring (const Ibyte *nonreloc, |
428 | 144 Lisp_Object reloc, |
145 Bytecount offset, Bytecount *len); | |
146 | |
147 /* In font-lock.c */ | |
148 void font_lock_maybe_update_syntactic_caches (struct buffer *buf, | |
665 | 149 Charbpos start, |
150 Charbpos orig_end, | |
151 Charbpos new_end); | |
428 | 152 void font_lock_buffer_was_killed (struct buffer *buf); |
153 | |
665 | 154 void barf_if_buffer_read_only (struct buffer *buf, Charbpos from, |
155 Charbpos to); | |
428 | 156 |
157 void init_buffer_text (struct buffer *b); | |
158 void uninit_buffer_text (struct buffer *b); | |
159 | |
440 | 160 #endif /* INCLUDED_insdel_h_ */ |