Mercurial > emacs
annotate src/editfns.c @ 102873:b6ee4b011032
* vc-bzr.el (vc-bzr-log-view-mode): Tweak log-view-message-re (Bug#2872).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Tue, 07 Apr 2009 01:49:40 +0000 |
parents | ec3ec7f5d54e |
children | e99216139fa1 |
rev | line source |
---|---|
305 | 1 /* Lisp functions pertaining to editing. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996, |
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
100951 | 4 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
305 | 5 |
6 This file is part of GNU Emacs. | |
7 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93921
diff
changeset
|
8 GNU Emacs is free software: you can redistribute it and/or modify |
305 | 9 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93921
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93921
diff
changeset
|
11 (at your option) any later version. |
305 | 12 |
13 GNU Emacs is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93921
diff
changeset
|
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
305 | 20 |
21 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
22 #include <config.h> |
2962
79314d830f7d
* editfns.c: #include <sys/types.h>, to get time_t for Eggert's
Jim Blandy <jimb@redhat.com>
parents:
2921
diff
changeset
|
23 #include <sys/types.h> |
58029
46a652255057
Move #include "systime.h" before <sys/resource.h>.
Eli Zaretskii <eliz@gnu.org>
parents:
58011
diff
changeset
|
24 #include <stdio.h> |
2962
79314d830f7d
* editfns.c: #include <sys/types.h>, to get time_t for Eggert's
Jim Blandy <jimb@redhat.com>
parents:
2921
diff
changeset
|
25 |
61700
8a54ce1fae6a
Remove reference to defunct vms-pwd.h.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
61017
diff
changeset
|
26 #ifdef HAVE_PWD_H |
305 | 27 #include <pwd.h> |
372 | 28 #endif |
29 | |
21514 | 30 #ifdef HAVE_UNISTD_H |
31 #include <unistd.h> | |
32 #endif | |
33 | |
59644
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
34 #ifdef HAVE_SYS_UTSNAME_H |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
35 #include <sys/utsname.h> |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
36 #endif |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
37 |
65763
1a50ac5aaa75
Move systime.h include after lisp.h.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
65739
diff
changeset
|
38 #include "lisp.h" |
1a50ac5aaa75
Move systime.h include after lisp.h.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
65739
diff
changeset
|
39 |
58029
46a652255057
Move #include "systime.h" before <sys/resource.h>.
Eli Zaretskii <eliz@gnu.org>
parents:
58011
diff
changeset
|
40 /* systime.h includes <sys/time.h> which, on some systems, is required |
46a652255057
Move #include "systime.h" before <sys/resource.h>.
Eli Zaretskii <eliz@gnu.org>
parents:
58011
diff
changeset
|
41 for <sys/resource.h>; thus systime.h must be included before |
46a652255057
Move #include "systime.h" before <sys/resource.h>.
Eli Zaretskii <eliz@gnu.org>
parents:
58011
diff
changeset
|
42 <sys/resource.h> */ |
46a652255057
Move #include "systime.h" before <sys/resource.h>.
Eli Zaretskii <eliz@gnu.org>
parents:
58011
diff
changeset
|
43 #include "systime.h" |
58011
79614f2016d5
editfns.c: Adding in better patch
Steven Tamm <steventamm@mac.com>
parents:
58010
diff
changeset
|
44 |
79614f2016d5
editfns.c: Adding in better patch
Steven Tamm <steventamm@mac.com>
parents:
58010
diff
changeset
|
45 #if defined HAVE_SYS_RESOURCE_H |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
46 #include <sys/resource.h> |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
47 #endif |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
48 |
40699
d51d2fa675d0
Move the include of ctype.h after unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
49 #include <ctype.h> |
d51d2fa675d0
Move the include of ctype.h after unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
50 |
1285
d50533e23dff
* editfns.c (make_buffer_string): Call copy_intervals_to_string().
Joseph Arceneaux <jla@gnu.org>
parents:
1254
diff
changeset
|
51 #include "intervals.h" |
305 | 52 #include "buffer.h" |
88372
7d0adc8c7f07
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
43042
diff
changeset
|
53 #include "character.h" |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
54 #include "coding.h" |
38059
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
55 #include "frame.h" |
305 | 56 #include "window.h" |
71817
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
57 #include "blockinput.h" |
305 | 58 |
38519
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
59 #ifdef STDC_HEADERS |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
60 #include <float.h> |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
61 #define MAX_10_EXP DBL_MAX_10_EXP |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
62 #else |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
63 #define MAX_10_EXP 310 |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
64 #endif |
200c049178cc
(toplevel) [STDC_HEADERS]: Include float.h.
Gerd Moellmann <gerd@gnu.org>
parents:
38059
diff
changeset
|
65 |
19441
2e2b54ae9b9d
(NULL): Define, if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
19416
diff
changeset
|
66 #ifndef NULL |
2e2b54ae9b9d
(NULL): Define, if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
19416
diff
changeset
|
67 #define NULL 0 |
2e2b54ae9b9d
(NULL): Define, if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
19416
diff
changeset
|
68 #endif |
2e2b54ae9b9d
(NULL): Define, if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
19416
diff
changeset
|
69 |
97655
287457e9bac1
(USER_FULL_NAME): Define to pw->pw_gecos if undefined.
Eli Zaretskii <eliz@gnu.org>
parents:
96718
diff
changeset
|
70 #ifndef USER_FULL_NAME |
287457e9bac1
(USER_FULL_NAME): Define to pw->pw_gecos if undefined.
Eli Zaretskii <eliz@gnu.org>
parents:
96718
diff
changeset
|
71 #define USER_FULL_NAME pw->pw_gecos |
287457e9bac1
(USER_FULL_NAME): Define to pw->pw_gecos if undefined.
Eli Zaretskii <eliz@gnu.org>
parents:
96718
diff
changeset
|
72 #endif |
287457e9bac1
(USER_FULL_NAME): Define to pw->pw_gecos if undefined.
Eli Zaretskii <eliz@gnu.org>
parents:
96718
diff
changeset
|
73 |
31095
e19d38e14720
[USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents:
31016
diff
changeset
|
74 #ifndef USE_CRT_DLL |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
75 extern char **environ; |
31095
e19d38e14720
[USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents:
31016
diff
changeset
|
76 #endif |
e19d38e14720
[USE_CRT_DLL]: Remove unnecessary extern, which screws
Andrew Innes <andrewi@gnu.org>
parents:
31016
diff
changeset
|
77 |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
78 #define TM_YEAR_BASE 1900 |
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
79 |
69790
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
80 /* Nonzero if TM_YEAR is a struct tm's tm_year value that causes |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
81 asctime to have well-defined behavior. */ |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
82 #ifndef TM_YEAR_IN_ASCTIME_RANGE |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
83 # define TM_YEAR_IN_ASCTIME_RANGE(tm_year) \ |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
84 (1000 - TM_YEAR_BASE <= (tm_year) && (tm_year) <= 9999 - TM_YEAR_BASE) |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
85 #endif |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
86 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
87 extern size_t emacs_strftimeu P_ ((char *, size_t, const char *, |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
88 const struct tm *, int)); |
81422
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
89 |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
90 #ifdef WINDOWSNT |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
91 extern Lisp_Object w32_get_internal_run_time (); |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
92 #endif |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
93 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
94 static int tm_diff P_ ((struct tm *, struct tm *)); |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
95 static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *)); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
96 static void update_buffer_properties P_ ((int, int)); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
97 static Lisp_Object region_limit P_ ((int)); |
55193
1b09eb24ab02
(lisp_time_argument): Provide externally.
Eli Zaretskii <eliz@gnu.org>
parents:
54846
diff
changeset
|
98 int lisp_time_argument P_ ((Lisp_Object, time_t *, int *)); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
99 static size_t emacs_memftimeu P_ ((char *, size_t, const char *, |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
100 size_t, const struct tm *, int)); |
102759
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
101 static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
102 void (*) (Lisp_Object, EMACS_INT, |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
103 EMACS_INT, EMACS_INT, |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
104 EMACS_INT, int), |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
105 int, int, Lisp_Object *); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
106 static Lisp_Object subst_char_in_region_unwind P_ ((Lisp_Object)); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
107 static Lisp_Object subst_char_in_region_unwind_1 P_ ((Lisp_Object)); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
108 static void transpose_markers P_ ((int, int, int, int, int, int, int, int)); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
109 |
31336 | 110 #ifdef HAVE_INDEX |
111 extern char *index P_ ((const char *, int)); | |
112 #endif | |
113 | |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
114 Lisp_Object Vbuffer_access_fontify_functions; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
115 Lisp_Object Qbuffer_access_fontify_functions; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
116 Lisp_Object Vbuffer_access_fontified_property; |
9657
0fc126c193e7
(Finsert_buffer_substring): Use insert_from_buffer instead of insert.
Karl Heuer <kwzh@gnu.org>
parents:
9572
diff
changeset
|
117 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
118 Lisp_Object Fuser_full_name P_ ((Lisp_Object)); |
17829
2d98572c57ab
Declare Fuser_full_name as Lisp_Object in advance to
Kenichi Handa <handa@m17n.org>
parents:
17115
diff
changeset
|
119 |
27077
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
120 /* Non-nil means don't stop at field boundary in text motion commands. */ |
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
121 |
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
122 Lisp_Object Vinhibit_field_text_motion; |
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
123 |
305 | 124 /* Some static data, and a function to initialize it for each run */ |
125 | |
126 Lisp_Object Vsystem_name; | |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
127 Lisp_Object Vuser_real_login_name; /* login name of current user ID */ |
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
128 Lisp_Object Vuser_full_name; /* full name of current user */ |
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
129 Lisp_Object Vuser_login_name; /* user name from LOGNAME or USER */ |
59644
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
130 Lisp_Object Voperating_system_release; /* Operating System Release */ |
305 | 131 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
132 /* Symbol for the text property used to mark fields. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
133 |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
134 Lisp_Object Qfield; |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
135 |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
136 /* A special value for Qfield properties. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
137 |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
138 Lisp_Object Qboundary; |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
139 |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
140 |
305 | 141 void |
142 init_editfns () | |
143 { | |
330 | 144 char *user_name; |
25782
8f59abd3a02b
(init_editfns): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25662
diff
changeset
|
145 register unsigned char *p; |
305 | 146 struct passwd *pw; /* password entry for the current user */ |
147 Lisp_Object tem; | |
148 | |
149 /* Set up system_name even when dumping. */ | |
7907
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
150 init_system_name (); |
305 | 151 |
152 #ifndef CANNOT_DUMP | |
153 /* Don't bother with this on initial start when just dumping out */ | |
154 if (!initialized) | |
155 return; | |
156 #endif /* not CANNOT_DUMP */ | |
157 | |
158 pw = (struct passwd *) getpwuid (getuid ()); | |
9572 | 159 #ifdef MSDOS |
160 /* We let the real user name default to "root" because that's quite | |
161 accurate on MSDOG and because it lets Emacs find the init file. | |
162 (The DVX libraries override the Djgpp libraries here.) */ | |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
163 Vuser_real_login_name = build_string (pw ? pw->pw_name : "root"); |
9572 | 164 #else |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
165 Vuser_real_login_name = build_string (pw ? pw->pw_name : "unknown"); |
9572 | 166 #endif |
305 | 167 |
330 | 168 /* Get the effective user name, by consulting environment variables, |
169 or the effective uid if those are unset. */ | |
5907
5fdb226fe9a4
(init_editfns): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents:
5884
diff
changeset
|
170 user_name = (char *) getenv ("LOGNAME"); |
330 | 171 if (!user_name) |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
172 #ifdef WINDOWSNT |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
173 user_name = (char *) getenv ("USERNAME"); /* it's USERNAME on NT */ |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
174 #else /* WINDOWSNT */ |
5907
5fdb226fe9a4
(init_editfns): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents:
5884
diff
changeset
|
175 user_name = (char *) getenv ("USER"); |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
176 #endif /* WINDOWSNT */ |
305 | 177 if (!user_name) |
330 | 178 { |
179 pw = (struct passwd *) getpwuid (geteuid ()); | |
180 user_name = (char *) (pw ? pw->pw_name : "unknown"); | |
181 } | |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
182 Vuser_login_name = build_string (user_name); |
305 | 183 |
330 | 184 /* If the user name claimed in the environment vars differs from |
185 the real uid, use the claimed name to find the full name. */ | |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
186 tem = Fstring_equal (Vuser_login_name, Vuser_real_login_name); |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
187 Vuser_full_name = Fuser_full_name (NILP (tem)? make_number (geteuid()) |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
188 : Vuser_login_name); |
30480 | 189 |
11447
d51e912495be
(init_editfns): Add casts.
Richard M. Stallman <rms@gnu.org>
parents:
11433
diff
changeset
|
190 p = (unsigned char *) getenv ("NAME"); |
11135
9ab21ef32537
(init_editfns): Use NAME envvar to init user-full-name.
Richard M. Stallman <rms@gnu.org>
parents:
10480
diff
changeset
|
191 if (p) |
9ab21ef32537
(init_editfns): Use NAME envvar to init user-full-name.
Richard M. Stallman <rms@gnu.org>
parents:
10480
diff
changeset
|
192 Vuser_full_name = build_string (p); |
16683
6802dbd07a80
(Fuser_full_name): Return nil if the specified user doesn't exist.
Richard M. Stallman <rms@gnu.org>
parents:
16648
diff
changeset
|
193 else if (NILP (Vuser_full_name)) |
6802dbd07a80
(Fuser_full_name): Return nil if the specified user doesn't exist.
Richard M. Stallman <rms@gnu.org>
parents:
16648
diff
changeset
|
194 Vuser_full_name = build_string ("unknown"); |
59644
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
195 |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
196 #ifdef HAVE_SYS_UTSNAME_H |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
197 { |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
198 struct utsname uts; |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
199 uname (&uts); |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
200 Voperating_system_release = build_string (uts.release); |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
201 } |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
202 #else |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
203 Voperating_system_release = Qnil; |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
204 #endif |
305 | 205 } |
206 | |
207 DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0, | |
40203
9d2aeb5c05b4
(char-to-string): Fix argument names (use CHAR instead of C) and usage.
Pavel Janík <Pavel@Janik.cz>
parents:
40140
diff
changeset
|
208 doc: /* Convert arg CHAR to a string containing that character. |
9d2aeb5c05b4
(char-to-string): Fix argument names (use CHAR instead of C) and usage.
Pavel Janík <Pavel@Janik.cz>
parents:
40140
diff
changeset
|
209 usage: (char-to-string CHAR) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
210 (character) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
211 Lisp_Object character; |
305 | 212 { |
17031 | 213 int len; |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
214 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
17031 | 215 |
90800
37b19435acef
(Fchar_to_string): Use CHARACTERP, not INTEGERP.
Kenichi Handa <handa@m17n.org>
parents:
90796
diff
changeset
|
216 CHECK_CHARACTER (character); |
305 | 217 |
88372
7d0adc8c7f07
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
43042
diff
changeset
|
218 len = CHAR_STRING (XFASTINT (character), str); |
21257
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
219 return make_string_from_bytes (str, 1, len); |
305 | 220 } |
221 | |
222 DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
223 doc: /* Convert arg STRING to a character, the first character of that string. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
224 A multibyte character is handled correctly. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
225 (string) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
226 register Lisp_Object string; |
305 | 227 { |
228 register Lisp_Object val; | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
229 CHECK_STRING (string); |
46443
b612fecce4cc
(Fstring_to_char): Use string macros instead of Lisp_String fields.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
230 if (SCHARS (string)) |
23650
3cc42e65f25b
(Fstring_to_char): Don't return a multibyte character
Kenichi Handa <handa@m17n.org>
parents:
23596
diff
changeset
|
231 { |
3cc42e65f25b
(Fstring_to_char): Don't return a multibyte character
Kenichi Handa <handa@m17n.org>
parents:
23596
diff
changeset
|
232 if (STRING_MULTIBYTE (string)) |
46443
b612fecce4cc
(Fstring_to_char): Use string macros instead of Lisp_String fields.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
233 XSETFASTINT (val, STRING_CHAR (SDATA (string), SBYTES (string))); |
23650
3cc42e65f25b
(Fstring_to_char): Don't return a multibyte character
Kenichi Handa <handa@m17n.org>
parents:
23596
diff
changeset
|
234 else |
46443
b612fecce4cc
(Fstring_to_char): Use string macros instead of Lisp_String fields.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
235 XSETFASTINT (val, SREF (string, 0)); |
23650
3cc42e65f25b
(Fstring_to_char): Don't return a multibyte character
Kenichi Handa <handa@m17n.org>
parents:
23596
diff
changeset
|
236 } |
305 | 237 else |
9305
ac077e2a75f1
(Fstring_to_char, Fpoint, Fbufsize, Fpoint_min, Fpoint_max, Ffollowing_char,
Karl Heuer <kwzh@gnu.org>
parents:
9265
diff
changeset
|
238 XSETFASTINT (val, 0); |
305 | 239 return val; |
240 } | |
241 | |
242 static Lisp_Object | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
243 buildmark (charpos, bytepos) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
244 int charpos, bytepos; |
305 | 245 { |
246 register Lisp_Object mark; | |
247 mark = Fmake_marker (); | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
248 set_marker_both (mark, Qnil, charpos, bytepos); |
305 | 249 return mark; |
250 } | |
251 | |
252 DEFUN ("point", Fpoint, Spoint, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
253 doc: /* Return value of point, as an integer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
254 Beginning of buffer is position (point-min). */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
255 () |
305 | 256 { |
257 Lisp_Object temp; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
258 XSETFASTINT (temp, PT); |
305 | 259 return temp; |
260 } | |
261 | |
262 DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
263 doc: /* Return value of point, as a marker object. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
264 () |
305 | 265 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
266 return buildmark (PT, PT_BYTE); |
305 | 267 } |
268 | |
269 int | |
270 clip_to_bounds (lower, num, upper) | |
271 int lower, num, upper; | |
272 { | |
273 if (num < lower) | |
274 return lower; | |
275 else if (num > upper) | |
276 return upper; | |
277 else | |
278 return num; | |
279 } | |
280 | |
281 DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ", | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
282 doc: /* Set point to POSITION, a number or marker. |
76709 | 283 Beginning of buffer is position (point-min), end is (point-max). |
284 | |
285 The return value is POSITION. */) | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
286 (position) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
287 register Lisp_Object position; |
305 | 288 { |
17031 | 289 int pos; |
290 | |
21226
c8d0df2cbd3d
(Fgoto_char): If POSITION is a marker pointing a
Richard M. Stallman <rms@gnu.org>
parents:
21225
diff
changeset
|
291 if (MARKERP (position) |
c8d0df2cbd3d
(Fgoto_char): If POSITION is a marker pointing a
Richard M. Stallman <rms@gnu.org>
parents:
21225
diff
changeset
|
292 && current_buffer == XMARKER (position)->buffer) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
293 { |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
294 pos = marker_position (position); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
295 if (pos < BEGV) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
296 SET_PT_BOTH (BEGV, BEGV_BYTE); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
297 else if (pos > ZV) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
298 SET_PT_BOTH (ZV, ZV_BYTE); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
299 else |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
300 SET_PT_BOTH (pos, marker_byte_position (position)); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
301 |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
302 return position; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
303 } |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
304 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
305 CHECK_NUMBER_COERCE_MARKER (position); |
305 | 306 |
17031 | 307 pos = clip_to_bounds (BEGV, XINT (position), ZV); |
308 SET_PT (pos); | |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
309 return position; |
305 | 310 } |
311 | |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
312 |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
313 /* Return the start or end position of the region. |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
314 BEGINNINGP non-zero means return the start. |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
315 If there is no region active, signal an error. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
316 |
305 | 317 static Lisp_Object |
318 region_limit (beginningp) | |
319 int beginningp; | |
320 { | |
4047
e950abdc9ed2
(region_limit): Declare Vmark_even_if_inactive.
Roland McGrath <roland@gnu.org>
parents:
4038
diff
changeset
|
321 extern Lisp_Object Vmark_even_if_inactive; /* Defined in callint.c. */ |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
322 Lisp_Object m; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
323 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
324 if (!NILP (Vtransient_mark_mode) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
325 && NILP (Vmark_even_if_inactive) |
4038
03a4c3912c13
(region_limit): Don't error if Vmark_even_if_inactive is set. When the
Roland McGrath <roland@gnu.org>
parents:
4019
diff
changeset
|
326 && NILP (current_buffer->mark_active)) |
71975
6d29dff081c5
(region_limit, Fget_internal_run_time): Use xsignal0.
Kim F. Storm <storm@cua.dk>
parents:
71865
diff
changeset
|
327 xsignal0 (Qmark_inactive); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
328 |
305 | 329 m = Fmarker_position (current_buffer->mark); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
330 if (NILP (m)) |
43042
63639e690611
(region_limit): Nicer error message.
Richard M. Stallman <rms@gnu.org>
parents:
42484
diff
changeset
|
331 error ("The mark is not set now, so there is no region"); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
332 |
52451
c7860e5cc982
(region_limit): Support any non-zero value of BEGINNINGP.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
333 if ((PT < XFASTINT (m)) == (beginningp != 0)) |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
334 m = make_number (PT); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
335 return m; |
305 | 336 } |
337 | |
338 DEFUN ("region-beginning", Fregion_beginning, Sregion_beginning, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
339 doc: /* Return position of beginning of region, as an integer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
340 () |
305 | 341 { |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
342 return region_limit (1); |
305 | 343 } |
344 | |
345 DEFUN ("region-end", Fregion_end, Sregion_end, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
346 doc: /* Return position of end of region, as an integer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
347 () |
305 | 348 { |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
349 return region_limit (0); |
305 | 350 } |
351 | |
352 DEFUN ("mark-marker", Fmark_marker, Smark_marker, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
353 doc: /* Return this buffer's mark, as a marker object. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
354 Watch out! Moving this marker changes the mark position. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
355 If you set the marker not to point anywhere, the buffer will have no mark. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
356 () |
305 | 357 { |
358 return current_buffer->mark; | |
359 } | |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
360 |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
361 |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
362 /* Find all the overlays in the current buffer that touch position POS. |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
363 Return the number found, and store them in a vector in VEC |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
364 of length LEN. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
365 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
366 static int |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
367 overlays_around (pos, vec, len) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
368 int pos; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
369 Lisp_Object *vec; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
370 int len; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
371 { |
51841
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
372 Lisp_Object overlay, start, end; |
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
373 struct Lisp_Overlay *tail; |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
374 int startpos, endpos; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
375 int idx = 0; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
376 |
51841
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
377 for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
378 { |
51841
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
379 XSETMISC (overlay, tail); |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
380 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
381 end = OVERLAY_END (overlay); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
382 endpos = OVERLAY_POSITION (end); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
383 if (endpos < pos) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
384 break; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
385 start = OVERLAY_START (overlay); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
386 startpos = OVERLAY_POSITION (start); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
387 if (startpos <= pos) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
388 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
389 if (idx < len) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
390 vec[idx] = overlay; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
391 /* Keep counting overlays even if we can't return them all. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
392 idx++; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
393 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
394 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
395 |
51841
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
396 for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
397 { |
51841
59ba1f5d0a16
(overlays_around): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51670
diff
changeset
|
398 XSETMISC (overlay, tail); |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
399 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
400 start = OVERLAY_START (overlay); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
401 startpos = OVERLAY_POSITION (start); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
402 if (pos < startpos) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
403 break; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
404 end = OVERLAY_END (overlay); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
405 endpos = OVERLAY_POSITION (end); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
406 if (pos <= endpos) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
407 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
408 if (idx < len) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
409 vec[idx] = overlay; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
410 idx++; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
411 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
412 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
413 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
414 return idx; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
415 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
416 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
417 /* Return the value of property PROP, in OBJECT at POSITION. |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
418 It's the value of PROP that a char inserted at POSITION would get. |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
419 OBJECT is optional and defaults to the current buffer. |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
420 If OBJECT is a buffer, then overlay properties are considered as well as |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
421 text properties. |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
422 If OBJECT is a window, then that window's buffer is used, but |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
423 window-specific overlays are considered only if they are associated |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
424 with OBJECT. */ |
48134
ef2b87569c38
(get_pos_property): Don't hardcode Qfield.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48115
diff
changeset
|
425 Lisp_Object |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
426 get_pos_property (position, prop, object) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
427 Lisp_Object position, object; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
428 register Lisp_Object prop; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
429 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
430 CHECK_NUMBER_COERCE_MARKER (position); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
431 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
432 if (NILP (object)) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
433 XSETBUFFER (object, current_buffer); |
51042
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
434 else if (WINDOWP (object)) |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
435 object = XWINDOW (object)->buffer; |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
436 |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
437 if (!BUFFERP (object)) |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
438 /* pos-property only makes sense in buffers right now, since strings |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
439 have no overlays and no notion of insertion for which stickiness |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
440 could be obeyed. */ |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
441 return Fget_text_property (position, prop, object); |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
442 else |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
443 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
444 int posn = XINT (position); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
445 int noverlays; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
446 Lisp_Object *overlay_vec, tem; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
447 struct buffer *obuf = current_buffer; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
448 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
449 set_buffer_temp (XBUFFER (object)); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
450 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
451 /* First try with room for 40 overlays. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
452 noverlays = 40; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
453 overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof (Lisp_Object)); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
454 noverlays = overlays_around (posn, overlay_vec, noverlays); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
455 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
456 /* If there are more than 40, |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
457 make enough space for all, and try again. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
458 if (noverlays > 40) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
459 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
460 overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof (Lisp_Object)); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
461 noverlays = overlays_around (posn, overlay_vec, noverlays); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
462 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
463 noverlays = sort_overlays (overlay_vec, noverlays, NULL); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
464 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
465 set_buffer_temp (obuf); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
466 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
467 /* Now check the overlays in order of decreasing priority. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
468 while (--noverlays >= 0) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
469 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
470 Lisp_Object ol = overlay_vec[noverlays]; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
471 tem = Foverlay_get (ol, prop); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
472 if (!NILP (tem)) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
473 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
474 /* Check the overlay is indeed active at point. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
475 Lisp_Object start = OVERLAY_START (ol), finish = OVERLAY_END (ol); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
476 if ((OVERLAY_POSITION (start) == posn |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
477 && XMARKER (start)->insertion_type == 1) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
478 || (OVERLAY_POSITION (finish) == posn |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
479 && XMARKER (finish)->insertion_type == 0)) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
480 ; /* The overlay will not cover a char inserted at point. */ |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
481 else |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
482 { |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
483 return tem; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
484 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
485 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
486 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
487 |
93921
f7d6d03d8ceb
(Ffield_string_no_properties): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
93038
diff
changeset
|
488 { /* Now check the text properties. */ |
51042
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
489 int stickiness = text_property_stickiness (prop, position, object); |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
490 if (stickiness > 0) |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
491 return Fget_text_property (position, prop, object); |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
492 else if (stickiness < 0 |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
493 && XINT (position) > BUF_BEGV (XBUFFER (object))) |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
494 return Fget_text_property (make_number (XINT (position) - 1), |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
495 prop, object); |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
496 else |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
497 return Qnil; |
edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50746
diff
changeset
|
498 } |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
499 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
500 } |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
501 |
26389
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
502 /* Find the field surrounding POS in *BEG and *END. If POS is nil, |
70188 | 503 the value of point is used instead. If BEG or END is null, |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
504 means don't store the beginning or end of the field. |
26389
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
505 |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
506 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
507 results; they do not effect boundary behavior. |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
508 |
70213
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
509 If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
510 position of a field, then the beginning of the previous field is |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
511 returned instead of the beginning of POS's field (since the end of a |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
512 field is actually also the beginning of the next input field, this |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
513 behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
514 true case, if two fields are separated by a field with the special |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
515 value `boundary', and POS lies within it, then the two separated |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
516 fields are considered to be adjacent, and POS between them, when |
70213
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
517 finding the beginning and ending of the "merged" field. |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
518 |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
519 Either BEG or END may be 0, in which case the corresponding value |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
520 is not stored. */ |
26389
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
521 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
522 static void |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
523 find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
524 Lisp_Object pos; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
525 Lisp_Object merge_at_boundary; |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
526 Lisp_Object beg_limit, end_limit; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
527 int *beg, *end; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
528 { |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
529 /* Fields right before and after the point. */ |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
530 Lisp_Object before_field, after_field; |
26389
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
531 /* 1 if POS counts as the start of a field. */ |
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
532 int at_field_start = 0; |
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
533 /* 1 if POS counts as the end of a field. */ |
e2acf63b5403
(Fline_beginning_position): If N is not 1,
Richard M. Stallman <rms@gnu.org>
parents:
26372
diff
changeset
|
534 int at_field_end = 0; |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
535 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
536 if (NILP (pos)) |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
537 XSETFASTINT (pos, PT); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
538 else |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
539 CHECK_NUMBER_COERCE_MARKER (pos); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
540 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
541 after_field |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
542 = get_char_property_and_overlay (pos, Qfield, Qnil, NULL); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
543 before_field |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
544 = (XFASTINT (pos) > BEGV |
32850 | 545 ? get_char_property_and_overlay (make_number (XINT (pos) - 1), |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
546 Qfield, Qnil, NULL) |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
547 /* Using nil here would be a more obvious choice, but it would |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
548 fail when the buffer starts with a non-sticky field. */ |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
549 : after_field); |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
550 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
551 /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
552 and POS is at beginning of a field, which can also be interpreted |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
553 as the end of the previous field. Note that the case where if |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
554 MERGE_AT_BOUNDARY is non-nil (see function comment) is actually the |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
555 more natural one; then we avoid treating the beginning of a field |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
556 specially. */ |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
557 if (NILP (merge_at_boundary)) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
558 { |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
559 Lisp_Object field = get_pos_property (pos, Qfield, Qnil); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
560 if (!EQ (field, after_field)) |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
561 at_field_end = 1; |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
562 if (!EQ (field, before_field)) |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
563 at_field_start = 1; |
48111
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
564 if (NILP (field) && at_field_start && at_field_end) |
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
565 /* If an inserted char would have a nil field while the surrounding |
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
566 text is non-nil, we're probably not looking at a |
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
567 zero-length field, but instead at a non-nil field that's |
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
568 not intended for editing (such as comint's prompts). */ |
7103ad01172d
(find_field): Make an exception for nil fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48094
diff
changeset
|
569 at_field_end = at_field_start = 0; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
570 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
571 |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
572 /* Note about special `boundary' fields: |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
573 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
574 Consider the case where the point (`.') is between the fields `x' and `y': |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
575 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
576 xxxx.yyyy |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
577 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
578 In this situation, if merge_at_boundary is true, we consider the |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
579 `x' and `y' fields as forming one big merged field, and so the end |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
580 of the field is the end of `y'. |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
581 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
582 However, if `x' and `y' are separated by a special `boundary' field |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
583 (a field with a `field' char-property of 'boundary), then we ignore |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
584 this special field when merging adjacent fields. Here's the same |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
585 situation, but with a `boundary' field between the `x' and `y' fields: |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
586 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
587 xxx.BBBByyyy |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
588 |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
589 Here, if point is at the end of `x', the beginning of `y', or |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
590 anywhere in-between (within the `boundary' field), we merge all |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
591 three fields and consider the beginning as being the beginning of |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
592 the `x' field, and the end as being the end of the `y' field. */ |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
593 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
594 if (beg) |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
595 { |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
596 if (at_field_start) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
597 /* POS is at the edge of a field, and we should consider it as |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
598 the beginning of the following field. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
599 *beg = XFASTINT (pos); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
600 else |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
601 /* Find the previous field boundary. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
602 { |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
603 Lisp_Object p = pos; |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
604 if (!NILP (merge_at_boundary) && EQ (before_field, Qboundary)) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
605 /* Skip a `boundary' field. */ |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
606 p = Fprevious_single_char_property_change (p, Qfield, Qnil, |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
607 beg_limit); |
48094
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
608 |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
609 p = Fprevious_single_char_property_change (p, Qfield, Qnil, |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
610 beg_limit); |
2a8ba962e34d
(overlays_around, get_pos_property): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48020
diff
changeset
|
611 *beg = NILP (p) ? BEGV : XFASTINT (p); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
612 } |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
613 } |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
614 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
615 if (end) |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
616 { |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
617 if (at_field_end) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
618 /* POS is at the edge of a field, and we should consider it as |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
619 the end of the previous field. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
620 *end = XFASTINT (pos); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
621 else |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
622 /* Find the next field boundary. */ |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
623 { |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
624 if (!NILP (merge_at_boundary) && EQ (after_field, Qboundary)) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
625 /* Skip a `boundary' field. */ |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
626 pos = Fnext_single_char_property_change (pos, Qfield, Qnil, |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
627 end_limit); |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
628 |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
629 pos = Fnext_single_char_property_change (pos, Qfield, Qnil, |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
630 end_limit); |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
631 *end = NILP (pos) ? ZV : XFASTINT (pos); |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
632 } |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
633 } |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
634 } |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
635 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
636 |
26629
05dcbc266797
(Fdelete_field): Make it noninteractive. Return nil.
Richard M. Stallman <rms@gnu.org>
parents:
26526
diff
changeset
|
637 DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
638 doc: /* Delete the field surrounding POS. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
639 A field is a region of text with the same `field' property. |
72194
06ca00cbd2ca
Undo 2006-06-28 change.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71975
diff
changeset
|
640 If POS is nil, the value of point is used for POS. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
641 (pos) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
642 Lisp_Object pos; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
643 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
644 int beg, end; |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
645 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
646 if (beg != end) |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
647 del_range (beg, end); |
26629
05dcbc266797
(Fdelete_field): Make it noninteractive. Return nil.
Richard M. Stallman <rms@gnu.org>
parents:
26526
diff
changeset
|
648 return Qnil; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
649 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
650 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
651 DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
652 doc: /* Return the contents of the field surrounding POS as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
653 A field is a region of text with the same `field' property. |
72194
06ca00cbd2ca
Undo 2006-06-28 change.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71975
diff
changeset
|
654 If POS is nil, the value of point is used for POS. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
655 (pos) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
656 Lisp_Object pos; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
657 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
658 int beg, end; |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
659 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
660 return make_buffer_string (beg, end, 1); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
661 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
662 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
663 DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0, |
93921
f7d6d03d8ceb
(Ffield_string_no_properties): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
93038
diff
changeset
|
664 doc: /* Return the contents of the field around POS, without text properties. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
665 A field is a region of text with the same `field' property. |
72194
06ca00cbd2ca
Undo 2006-06-28 change.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71975
diff
changeset
|
666 If POS is nil, the value of point is used for POS. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
667 (pos) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
668 Lisp_Object pos; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
669 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
670 int beg, end; |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
671 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
672 return make_buffer_string (beg, end, 0); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
673 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
674 |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
675 DEFUN ("field-beginning", Ffield_beginning, Sfield_beginning, 0, 3, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
676 doc: /* Return the beginning of the field surrounding POS. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
677 A field is a region of text with the same `field' property. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
678 If POS is nil, the value of point is used for POS. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
679 If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
680 field, then the beginning of the *previous* field is returned. |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
681 If LIMIT is non-nil, it is a buffer position; if the beginning of the field |
72194
06ca00cbd2ca
Undo 2006-06-28 change.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71975
diff
changeset
|
682 is before LIMIT, then LIMIT will be returned instead. */) |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
683 (pos, escape_from_edge, limit) |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
684 Lisp_Object pos, escape_from_edge, limit; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
685 { |
70213
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
686 int beg; |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
687 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0); |
e9ea7c53ddc7
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-245
Miles Bader <miles@gnu.org>
parents:
70188
diff
changeset
|
688 return make_number (beg); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
689 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
690 |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
691 DEFUN ("field-end", Ffield_end, Sfield_end, 0, 3, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
692 doc: /* Return the end of the field surrounding POS. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
693 A field is a region of text with the same `field' property. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
694 If POS is nil, the value of point is used for POS. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
695 If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
696 then the end of the *following* field is returned. |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
697 If LIMIT is non-nil, it is a buffer position; if the end of the field |
72194
06ca00cbd2ca
Undo 2006-06-28 change.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71975
diff
changeset
|
698 is after LIMIT, then LIMIT will be returned instead. */) |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
699 (pos, escape_from_edge, limit) |
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
700 Lisp_Object pos, escape_from_edge, limit; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
701 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
702 int end; |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
703 find_field (pos, escape_from_edge, Qnil, 0, limit, &end); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
704 return make_number (end); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
705 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
706 |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
707 DEFUN ("constrain-to-field", Fconstrain_to_field, Sconstrain_to_field, 2, 5, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
708 doc: /* Return the position closest to NEW-POS that is in the same field as OLD-POS. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
709 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
710 A field is a region of text with the same `field' property. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
711 If NEW-POS is nil, then the current point is used instead, and set to the |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
712 constrained position if that is different. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
713 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
714 If OLD-POS is at the boundary of two fields, then the allowable |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
715 positions for NEW-POS depends on the value of the optional argument |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
716 ESCAPE-FROM-EDGE: If ESCAPE-FROM-EDGE is nil, then NEW-POS is |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
717 constrained to the field that has the same `field' char-property |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
718 as any new characters inserted at OLD-POS, whereas if ESCAPE-FROM-EDGE |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
719 is non-nil, NEW-POS is constrained to the union of the two adjacent |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
720 fields. Additionally, if two fields are separated by another field with |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
721 the special value `boundary', then any point within this special field is |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
722 also considered to be `on the boundary'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
723 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
724 If the optional argument ONLY-IN-LINE is non-nil and constraining |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
725 NEW-POS would move it to a different line, NEW-POS is returned |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
726 unconstrained. This useful for commands that move by line, like |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
727 \\[next-line] or \\[beginning-of-line], which should generally respect field boundaries |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
728 only in the case where they can still move to the right line. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
729 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
730 If the optional argument INHIBIT-CAPTURE-PROPERTY is non-nil, and OLD-POS has |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
731 a non-nil property of that name, then any field boundaries are ignored. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
732 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
733 Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
734 (new_pos, old_pos, escape_from_edge, only_in_line, inhibit_capture_property) |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
735 Lisp_Object new_pos, old_pos; |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
736 Lisp_Object escape_from_edge, only_in_line, inhibit_capture_property; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
737 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
738 /* If non-zero, then the original point, before re-positioning. */ |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
739 int orig_point = 0; |
68626
ee9f9dd4337d
(Fconstrain_to_field): Fix int/Lisp_Object mixup.
Ken Raeburn <raeburn@raeburn.org>
parents:
68394
diff
changeset
|
740 int fwd; |
ee9f9dd4337d
(Fconstrain_to_field): Fix int/Lisp_Object mixup.
Ken Raeburn <raeburn@raeburn.org>
parents:
68394
diff
changeset
|
741 Lisp_Object prev_old, prev_new; |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
742 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
743 if (NILP (new_pos)) |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
744 /* Use the current point, and afterwards, set it. */ |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
745 { |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
746 orig_point = PT; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
747 XSETFASTINT (new_pos, PT); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
748 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
749 |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
750 CHECK_NUMBER_COERCE_MARKER (new_pos); |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
751 CHECK_NUMBER_COERCE_MARKER (old_pos); |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
752 |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
753 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos)); |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
754 |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
755 prev_old = make_number (XFASTINT (old_pos) - 1); |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
756 prev_new = make_number (XFASTINT (new_pos) - 1); |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
757 |
27081
f068649f1c28
(Fconstrain_to_field): Don't constrain if
Gerd Moellmann <gerd@gnu.org>
parents:
27077
diff
changeset
|
758 if (NILP (Vinhibit_field_text_motion) |
f068649f1c28
(Fconstrain_to_field): Don't constrain if
Gerd Moellmann <gerd@gnu.org>
parents:
27077
diff
changeset
|
759 && !EQ (new_pos, old_pos) |
68669
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
760 && (!NILP (Fget_char_property (new_pos, Qfield, Qnil)) |
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
761 || !NILP (Fget_char_property (old_pos, Qfield, Qnil)) |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
762 /* To recognize field boundaries, we must also look at the |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
763 previous positions; we could use `get_pos_property' |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
764 instead, but in itself that would fail inside non-sticky |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
765 fields (like comint prompts). */ |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
766 || (XFASTINT (new_pos) > BEGV |
68669
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
767 && !NILP (Fget_char_property (prev_new, Qfield, Qnil))) |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
768 || (XFASTINT (old_pos) > BEGV |
68669
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
769 && !NILP (Fget_char_property (prev_old, Qfield, Qnil)))) |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
770 && (NILP (inhibit_capture_property) |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
771 /* Field boundaries are again a problem; but now we must |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
772 decide the case exactly, so we need to call |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
773 `get_pos_property' as well. */ |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
774 || (NILP (get_pos_property (old_pos, inhibit_capture_property, Qnil)) |
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
775 && (XFASTINT (old_pos) <= BEGV |
68669
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
776 || NILP (Fget_char_property (old_pos, inhibit_capture_property, Qnil)) |
82590f3df577
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-51
Miles Bader <miles@gnu.org>
parents:
68651
diff
changeset
|
777 || NILP (Fget_char_property (prev_old, inhibit_capture_property, Qnil)))))) |
68392
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
778 /* It is possible that NEW_POS is not within the same field as |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
779 OLD_POS; try to move NEW_POS so that it is. */ |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
780 { |
68394
0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
Károly Lőrentey <lorentey@elte.hu>
parents:
68392
diff
changeset
|
781 int shortage; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
782 Lisp_Object field_bound; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
783 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
784 if (fwd) |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
785 field_bound = Ffield_end (old_pos, escape_from_edge, new_pos); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
786 else |
41065
af0215d05281
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
Miles Bader <miles@gnu.org>
parents:
41062
diff
changeset
|
787 field_bound = Ffield_beginning (old_pos, escape_from_edge, new_pos); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
788 |
30550
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
789 if (/* See if ESCAPE_FROM_EDGE caused FIELD_BOUND to jump to the |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
790 other side of NEW_POS, which would mean that NEW_POS is |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
791 already acceptable, and it's not necessary to constrain it |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
792 to FIELD_BOUND. */ |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
793 ((XFASTINT (field_bound) < XFASTINT (new_pos)) ? fwd : !fwd) |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
794 /* NEW_POS should be constrained, but only if either |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
795 ONLY_IN_LINE is nil (in which case any constraint is OK), |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
796 or NEW_POS and FIELD_BOUND are on the same line (in which |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
797 case the constraint is OK even if ONLY_IN_LINE is non-nil). */ |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
798 && (NILP (only_in_line) |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
799 /* This is the ONLY_IN_LINE case, check that NEW_POS and |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
800 FIELD_BOUND are on the same line by seeing whether |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
801 there's an intervening newline or not. */ |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
802 || (scan_buffer ('\n', |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
803 XFASTINT (new_pos), XFASTINT (field_bound), |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
804 fwd ? -1 : 1, &shortage, 1), |
73040724e653
(Fconstrain_to_field): Fix the conditions for deciding when to constrain
Miles Bader <miles@gnu.org>
parents:
30503
diff
changeset
|
805 shortage != 0))) |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
806 /* Constrain NEW_POS to FIELD_BOUND. */ |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
807 new_pos = field_bound; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
808 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
809 if (orig_point && XFASTINT (new_pos) != orig_point) |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
810 /* The NEW_POS argument was originally nil, so automatically set PT. */ |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
811 SET_PT (XFASTINT (new_pos)); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
812 } |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
813 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
814 return new_pos; |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
815 } |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
816 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
817 |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
818 DEFUN ("line-beginning-position", |
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
819 Fline_beginning_position, Sline_beginning_position, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
820 doc: /* Return the character position of the first character on the current line. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
821 With argument N not nil or 1, move forward N - 1 lines first. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
822 If scan reaches end of buffer, return that position. |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
823 |
68392
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
824 This function constrains the returned position to the current field |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
825 unless that would be on a different line than the original, |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
826 unconstrained result. If N is nil or 1, and a front-sticky field |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
827 starts at point, the scan stops as soon as it starts. To ignore field |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
828 boundaries bind `inhibit-field-text-motion' to t. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
829 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
830 This function does not move point. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
831 (n) |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
832 Lisp_Object n; |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
833 { |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
834 int orig, orig_byte, end; |
70619
f5917c21d187
* intervals.c (set_point_both): Fix mixup before before and after
Chong Yidong <cyd@stupidchicken.com>
parents:
70213
diff
changeset
|
835 int count = SPECPDL_INDEX (); |
f5917c21d187
* intervals.c (set_point_both): Fix mixup before before and after
Chong Yidong <cyd@stupidchicken.com>
parents:
70213
diff
changeset
|
836 specbind (Qinhibit_point_motion_hooks, Qt); |
305 | 837 |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
838 if (NILP (n)) |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
839 XSETFASTINT (n, 1); |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
840 else |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
841 CHECK_NUMBER (n); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
842 |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
843 orig = PT; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
844 orig_byte = PT_BYTE; |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
845 Fforward_line (make_number (XINT (n) - 1)); |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
846 end = PT; |
25647
947cb0e32a1d
(Fline_beginning_position): Handle minibuffer prompt here.
Richard M. Stallman <rms@gnu.org>
parents:
25609
diff
changeset
|
847 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
848 SET_PT_BOTH (orig, orig_byte); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
849 |
70619
f5917c21d187
* intervals.c (set_point_both): Fix mixup before before and after
Chong Yidong <cyd@stupidchicken.com>
parents:
70213
diff
changeset
|
850 unbind_to (count, Qnil); |
f5917c21d187
* intervals.c (set_point_both): Fix mixup before before and after
Chong Yidong <cyd@stupidchicken.com>
parents:
70213
diff
changeset
|
851 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
852 /* Return END constrained to the current input field. */ |
27081
f068649f1c28
(Fconstrain_to_field): Don't constrain if
Gerd Moellmann <gerd@gnu.org>
parents:
27077
diff
changeset
|
853 return Fconstrain_to_field (make_number (end), make_number (orig), |
f068649f1c28
(Fconstrain_to_field): Don't constrain if
Gerd Moellmann <gerd@gnu.org>
parents:
27077
diff
changeset
|
854 XINT (n) != 1 ? Qt : Qnil, |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
855 Qt, Qnil); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
856 } |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
857 |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
858 DEFUN ("line-end-position", Fline_end_position, Sline_end_position, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
859 doc: /* Return the character position of the last character on the current line. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
860 With argument N not nil or 1, move forward N - 1 lines first. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
861 If scan reaches end of buffer, return that position. |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
862 |
68392
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
863 This function constrains the returned position to the current field |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
864 unless that would be on a different line than the original, |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
865 unconstrained result. If N is nil or 1, and a rear-sticky field ends |
a0208539b9a3
(Fconstrain_to_field): Use get_pos_property, not Fget_char_property,
Károly Lőrentey <lorentey@elte.hu>
parents:
66500
diff
changeset
|
866 at point, the scan stops as soon as it starts. To ignore field |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
867 boundaries bind `inhibit-field-text-motion' to t. |
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
868 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
869 This function does not move point. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
870 (n) |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
871 Lisp_Object n; |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
872 { |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
873 int end_pos; |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
874 int orig = PT; |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
875 |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
876 if (NILP (n)) |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
877 XSETFASTINT (n, 1); |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
878 else |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
879 CHECK_NUMBER (n); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
880 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
881 end_pos = find_before_next_newline (orig, 0, XINT (n) - (XINT (n) <= 0)); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
882 |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
883 /* Return END_POS constrained to the current input field. */ |
27081
f068649f1c28
(Fconstrain_to_field): Don't constrain if
Gerd Moellmann <gerd@gnu.org>
parents:
27077
diff
changeset
|
884 return Fconstrain_to_field (make_number (end_pos), make_number (orig), |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
885 Qnil, Qt, Qnil); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
886 } |
40042
c9ad5da1f79d
(Fline_beginning_position, Fline_end_position): Clarify documentation.
Miles Bader <miles@gnu.org>
parents:
39988
diff
changeset
|
887 |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
888 |
305 | 889 Lisp_Object |
890 save_excursion_save () | |
891 { | |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
892 int visible = (XBUFFER (XWINDOW (selected_window)->buffer) |
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
893 == current_buffer); |
305 | 894 |
895 return Fcons (Fpoint_marker (), | |
12982
385a67ad96c3
(save_excursion_save): Pass the new arg to Fcopy_marker.
Richard M. Stallman <rms@gnu.org>
parents:
12973
diff
changeset
|
896 Fcons (Fcopy_marker (current_buffer->mark, Qnil), |
2049
a358c97a23e4
(save_excursion_save): Save mark_active of buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1916
diff
changeset
|
897 Fcons (visible ? Qt : Qnil, |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
898 Fcons (current_buffer->mark_active, |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
899 selected_window)))); |
305 | 900 } |
901 | |
902 Lisp_Object | |
903 save_excursion_restore (info) | |
15075
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
904 Lisp_Object info; |
305 | 905 { |
15075
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
906 Lisp_Object tem, tem1, omark, nmark; |
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
907 struct gcpro gcpro1, gcpro2, gcpro3; |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
908 int visible_p; |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
909 |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
910 tem = Fmarker_buffer (XCAR (info)); |
305 | 911 /* If buffer being returned to is now deleted, avoid error */ |
912 /* Otherwise could get error here while unwinding to top level | |
913 and crash */ | |
914 /* In that case, Fmarker_buffer returns nil now. */ | |
488 | 915 if (NILP (tem)) |
305 | 916 return Qnil; |
15075
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
917 |
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
918 omark = nmark = Qnil; |
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
919 GCPRO3 (info, omark, nmark); |
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
920 |
305 | 921 Fset_buffer (tem); |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
922 |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
923 /* Point marker. */ |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
924 tem = XCAR (info); |
305 | 925 Fgoto_char (tem); |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
926 unchain_marker (XMARKER (tem)); |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
927 |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
928 /* Mark marker. */ |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
929 info = XCDR (info); |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
930 tem = XCAR (info); |
7485
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
931 omark = Fmarker_position (current_buffer->mark); |
305 | 932 Fset_marker (current_buffer->mark, tem, Fcurrent_buffer ()); |
7485
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
933 nmark = Fmarker_position (tem); |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
934 unchain_marker (XMARKER (tem)); |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
935 |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
936 /* visible */ |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
937 info = XCDR (info); |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
938 visible_p = !NILP (XCAR (info)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
939 |
4420
8113d9ba472e
(save_excursion_restore): Never make the buffer visible.
Richard M. Stallman <rms@gnu.org>
parents:
4358
diff
changeset
|
940 #if 0 /* We used to make the current buffer visible in the selected window |
8113d9ba472e
(save_excursion_restore): Never make the buffer visible.
Richard M. Stallman <rms@gnu.org>
parents:
4358
diff
changeset
|
941 if that was true previously. That avoids some anomalies. |
8113d9ba472e
(save_excursion_restore): Never make the buffer visible.
Richard M. Stallman <rms@gnu.org>
parents:
4358
diff
changeset
|
942 But it creates others, and it wasn't documented, and it is simpler |
8113d9ba472e
(save_excursion_restore): Never make the buffer visible.
Richard M. Stallman <rms@gnu.org>
parents:
4358
diff
changeset
|
943 and cleaner never to alter the window/buffer connections. */ |
2049
a358c97a23e4
(save_excursion_save): Save mark_active of buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1916
diff
changeset
|
944 tem1 = Fcar (tem); |
a358c97a23e4
(save_excursion_save): Save mark_active of buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1916
diff
changeset
|
945 if (!NILP (tem1) |
1254
c7e7e3438711
* editfns.c (save_excursion_save, save_excursion_restore):
Jim Blandy <jimb@redhat.com>
parents:
1117
diff
changeset
|
946 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) |
305 | 947 Fswitch_to_buffer (Fcurrent_buffer (), Qnil); |
4420
8113d9ba472e
(save_excursion_restore): Never make the buffer visible.
Richard M. Stallman <rms@gnu.org>
parents:
4358
diff
changeset
|
948 #endif /* 0 */ |
2049
a358c97a23e4
(save_excursion_save): Save mark_active of buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1916
diff
changeset
|
949 |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
950 /* Mark active */ |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
951 info = XCDR (info); |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
952 tem = XCAR (info); |
2049
a358c97a23e4
(save_excursion_save): Save mark_active of buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1916
diff
changeset
|
953 tem1 = current_buffer->mark_active; |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
954 current_buffer->mark_active = tem; |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
955 |
6206
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
956 if (!NILP (Vrun_hooks)) |
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
957 { |
7485
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
958 /* If mark is active now, and either was not active |
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
959 or was at a different place, run the activate hook. */ |
6206
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
960 if (! NILP (current_buffer->mark_active)) |
7485
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
961 { |
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
962 if (! EQ (omark, nmark)) |
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
963 call1 (Vrun_hooks, intern ("activate-mark-hook")); |
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
964 } |
a1b7f72e0ea2
(save_excursion_restore): Don't run activate-mark-hook
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
965 /* If mark has ceased to be active, run deactivate hook. */ |
6206
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
966 else if (! NILP (tem1)) |
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
967 call1 (Vrun_hooks, intern ("deactivate-mark-hook")); |
67c608b0e2f7
(save_excursion_restore): Don't call Vrun_hooks if nil.
Richard M. Stallman <rms@gnu.org>
parents:
5915
diff
changeset
|
968 } |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
969 |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
970 /* If buffer was visible in a window, and a different window was |
34165
3b3a64fbcb05
(save_excursion_restore): Don't move point
Gerd Moellmann <gerd@gnu.org>
parents:
32857
diff
changeset
|
971 selected, and the old selected window is still showing this |
3b3a64fbcb05
(save_excursion_restore): Don't move point
Gerd Moellmann <gerd@gnu.org>
parents:
32857
diff
changeset
|
972 buffer, restore point in that window. */ |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
973 tem = XCDR (info); |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
974 if (visible_p |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
975 && !EQ (tem, selected_window) |
37492
b9cea35cf91f
(save_excursion_restore): Don't use XBUFFER on
Gerd Moellmann <gerd@gnu.org>
parents:
37217
diff
changeset
|
976 && (tem1 = XWINDOW (tem)->buffer, |
b9cea35cf91f
(save_excursion_restore): Don't use XBUFFER on
Gerd Moellmann <gerd@gnu.org>
parents:
37217
diff
changeset
|
977 (/* Window is live... */ |
b9cea35cf91f
(save_excursion_restore): Don't use XBUFFER on
Gerd Moellmann <gerd@gnu.org>
parents:
37217
diff
changeset
|
978 BUFFERP (tem1) |
b9cea35cf91f
(save_excursion_restore): Don't use XBUFFER on
Gerd Moellmann <gerd@gnu.org>
parents:
37217
diff
changeset
|
979 /* ...and it shows the current buffer. */ |
b9cea35cf91f
(save_excursion_restore): Don't use XBUFFER on
Gerd Moellmann <gerd@gnu.org>
parents:
37217
diff
changeset
|
980 && XBUFFER (tem1) == current_buffer))) |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
981 Fset_window_point (tem, make_number (PT)); |
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
982 |
15075
e8613675066c
(save_excursion_restore): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
15015
diff
changeset
|
983 UNGCPRO; |
305 | 984 return Qnil; |
985 } | |
986 | |
987 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
988 doc: /* Save point, mark, and current buffer; execute BODY; restore those things. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
989 Executes BODY just like `progn'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
990 The values of point, mark and the current buffer are restored |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
991 even in case of abnormal exit (throw or error). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
992 The state of activation of the mark is also restored. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
993 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
994 This construct does not save `deactivate-mark', and therefore |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
995 functions that change the buffer will still cause deactivation |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
996 of the mark at the end of the command. To prevent that, bind |
40140
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
997 `deactivate-mark' with `let'. |
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
998 |
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
999 usage: (save-excursion &rest BODY) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1000 (args) |
305 | 1001 Lisp_Object args; |
1002 { | |
1003 register Lisp_Object val; | |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45398
diff
changeset
|
1004 int count = SPECPDL_INDEX (); |
305 | 1005 |
1006 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
16298
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1007 |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1008 val = Fprogn (args); |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1009 return unbind_to (count, val); |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1010 } |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1011 |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1012 DEFUN ("save-current-buffer", Fsave_current_buffer, Ssave_current_buffer, 0, UNEVALLED, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1013 doc: /* Save the current buffer; execute BODY; restore the current buffer. |
40140
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
1014 Executes BODY just like `progn'. |
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
1015 usage: (save-current-buffer &rest BODY) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1016 (args) |
16298
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1017 Lisp_Object args; |
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1018 { |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
1019 Lisp_Object val; |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45398
diff
changeset
|
1020 int count = SPECPDL_INDEX (); |
16298
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1021 |
20696
cdbe4824e7f1
(Fsave_current_buffer): Use set_buffer_if_live.
Richard M. Stallman <rms@gnu.org>
parents:
20688
diff
changeset
|
1022 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); |
16298
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
1023 |
305 | 1024 val = Fprogn (args); |
1025 return unbind_to (count, val); | |
1026 } | |
1027 | |
25608
1cdab17df2b3
(Fbufsize): Accept an extra BUFFER parameter.
Richard M. Stallman <rms@gnu.org>
parents:
25507
diff
changeset
|
1028 DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1029 doc: /* Return the number of characters in the current buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1030 If BUFFER, return the number of characters in that buffer instead. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1031 (buffer) |
25608
1cdab17df2b3
(Fbufsize): Accept an extra BUFFER parameter.
Richard M. Stallman <rms@gnu.org>
parents:
25507
diff
changeset
|
1032 Lisp_Object buffer; |
305 | 1033 { |
25608
1cdab17df2b3
(Fbufsize): Accept an extra BUFFER parameter.
Richard M. Stallman <rms@gnu.org>
parents:
25507
diff
changeset
|
1034 if (NILP (buffer)) |
1cdab17df2b3
(Fbufsize): Accept an extra BUFFER parameter.
Richard M. Stallman <rms@gnu.org>
parents:
25507
diff
changeset
|
1035 return make_number (Z - BEG); |
25609
157f0e91232e
Clear up previous change.
Richard M. Stallman <rms@gnu.org>
parents:
25608
diff
changeset
|
1036 else |
157f0e91232e
Clear up previous change.
Richard M. Stallman <rms@gnu.org>
parents:
25608
diff
changeset
|
1037 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1038 CHECK_BUFFER (buffer); |
25609
157f0e91232e
Clear up previous change.
Richard M. Stallman <rms@gnu.org>
parents:
25608
diff
changeset
|
1039 return make_number (BUF_Z (XBUFFER (buffer)) |
157f0e91232e
Clear up previous change.
Richard M. Stallman <rms@gnu.org>
parents:
25608
diff
changeset
|
1040 - BUF_BEG (XBUFFER (buffer))); |
157f0e91232e
Clear up previous change.
Richard M. Stallman <rms@gnu.org>
parents:
25608
diff
changeset
|
1041 } |
305 | 1042 } |
1043 | |
1044 DEFUN ("point-min", Fpoint_min, Spoint_min, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1045 doc: /* Return the minimum permissible value of point in the current buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1046 This is 1, unless narrowing (a buffer restriction) is in effect. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1047 () |
305 | 1048 { |
1049 Lisp_Object temp; | |
9305
ac077e2a75f1
(Fstring_to_char, Fpoint, Fbufsize, Fpoint_min, Fpoint_max, Ffollowing_char,
Karl Heuer <kwzh@gnu.org>
parents:
9265
diff
changeset
|
1050 XSETFASTINT (temp, BEGV); |
305 | 1051 return temp; |
1052 } | |
1053 | |
1054 DEFUN ("point-min-marker", Fpoint_min_marker, Spoint_min_marker, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1055 doc: /* Return a marker to the minimum permissible value of point in this buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1056 This is the beginning, unless narrowing (a buffer restriction) is in effect. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1057 () |
305 | 1058 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1059 return buildmark (BEGV, BEGV_BYTE); |
305 | 1060 } |
1061 | |
1062 DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1063 doc: /* Return the maximum permissible value of point in the current buffer. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1064 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1065 is in effect, in which case it is less. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1066 () |
305 | 1067 { |
1068 Lisp_Object temp; | |
9305
ac077e2a75f1
(Fstring_to_char, Fpoint, Fbufsize, Fpoint_min, Fpoint_max, Ffollowing_char,
Karl Heuer <kwzh@gnu.org>
parents:
9265
diff
changeset
|
1069 XSETFASTINT (temp, ZV); |
305 | 1070 return temp; |
1071 } | |
1072 | |
1073 DEFUN ("point-max-marker", Fpoint_max_marker, Spoint_max_marker, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1074 doc: /* Return a marker to the maximum permissible value of point in this buffer. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1075 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1076 is in effect, in which case it is less. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1077 () |
305 | 1078 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1079 return buildmark (ZV, ZV_BYTE); |
305 | 1080 } |
1081 | |
21821
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1082 DEFUN ("gap-position", Fgap_position, Sgap_position, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1083 doc: /* Return the position of the gap, in the current buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1084 See also `gap-size'. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1085 () |
21821
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1086 { |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1087 Lisp_Object temp; |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1088 XSETFASTINT (temp, GPT); |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1089 return temp; |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1090 } |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1091 |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1092 DEFUN ("gap-size", Fgap_size, Sgap_size, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1093 doc: /* Return the size of the current buffer's gap. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1094 See also `gap-position'. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1095 () |
21821
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1096 { |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1097 Lisp_Object temp; |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1098 XSETFASTINT (temp, GAP_SIZE); |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1099 return temp; |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1100 } |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
1101 |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
1102 DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1103 doc: /* Return the byte position for character position POSITION. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1104 If POSITION is out of range, the value is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1105 (position) |
20879
64d2baa47498
(Fposition_bytes): Declare arg POSITION as Lips_Object.
Kenichi Handa <handa@m17n.org>
parents:
20878
diff
changeset
|
1106 Lisp_Object position; |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
1107 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1108 CHECK_NUMBER_COERCE_MARKER (position); |
23132
1c8e0e09aea1
(Fposition_bytes): If the arg POSITION is out of
Kenichi Handa <handa@m17n.org>
parents:
23063
diff
changeset
|
1109 if (XINT (position) < BEG || XINT (position) > Z) |
1c8e0e09aea1
(Fposition_bytes): If the arg POSITION is out of
Kenichi Handa <handa@m17n.org>
parents:
23063
diff
changeset
|
1110 return Qnil; |
20878
34e0c8eb49eb
(Fposition_bytes): Allow marker as arg POSITION. Use
Kenichi Handa <handa@m17n.org>
parents:
20861
diff
changeset
|
1111 return make_number (CHAR_TO_BYTE (XINT (position))); |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
1112 } |
22645
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1113 |
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1114 DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1115 doc: /* Return the character position for byte position BYTEPOS. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1116 If BYTEPOS is out of range, the value is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1117 (bytepos) |
22645
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1118 Lisp_Object bytepos; |
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1119 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1120 CHECK_NUMBER (bytepos); |
23132
1c8e0e09aea1
(Fposition_bytes): If the arg POSITION is out of
Kenichi Handa <handa@m17n.org>
parents:
23063
diff
changeset
|
1121 if (XINT (bytepos) < BEG_BYTE || XINT (bytepos) > Z_BYTE) |
1c8e0e09aea1
(Fposition_bytes): If the arg POSITION is out of
Kenichi Handa <handa@m17n.org>
parents:
23063
diff
changeset
|
1122 return Qnil; |
22645
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1123 return make_number (BYTE_TO_CHAR (XINT (bytepos))); |
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
1124 } |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
1125 |
512 | 1126 DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1127 doc: /* Return the character following point, as a number. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1128 At the end of the buffer or accessible region, return 0. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1129 () |
305 | 1130 { |
1131 Lisp_Object temp; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
1132 if (PT >= ZV) |
9305
ac077e2a75f1
(Fstring_to_char, Fpoint, Fbufsize, Fpoint_min, Fpoint_max, Ffollowing_char,
Karl Heuer <kwzh@gnu.org>
parents:
9265
diff
changeset
|
1133 XSETFASTINT (temp, 0); |
512 | 1134 else |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1135 XSETFASTINT (temp, FETCH_CHAR (PT_BYTE)); |
305 | 1136 return temp; |
1137 } | |
1138 | |
512 | 1139 DEFUN ("preceding-char", Fprevious_char, Sprevious_char, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1140 doc: /* Return the character preceding point, as a number. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1141 At the beginning of the buffer or accessible region, return 0. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1142 () |
305 | 1143 { |
1144 Lisp_Object temp; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
1145 if (PT <= BEGV) |
9305
ac077e2a75f1
(Fstring_to_char, Fpoint, Fbufsize, Fpoint_min, Fpoint_max, Ffollowing_char,
Karl Heuer <kwzh@gnu.org>
parents:
9265
diff
changeset
|
1146 XSETFASTINT (temp, 0); |
17031 | 1147 else if (!NILP (current_buffer->enable_multibyte_characters)) |
1148 { | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1149 int pos = PT_BYTE; |
17031 | 1150 DEC_POS (pos); |
1151 XSETFASTINT (temp, FETCH_CHAR (pos)); | |
1152 } | |
305 | 1153 else |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1154 XSETFASTINT (temp, FETCH_BYTE (PT_BYTE - 1)); |
305 | 1155 return temp; |
1156 } | |
1157 | |
1158 DEFUN ("bobp", Fbobp, Sbobp, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1159 doc: /* Return t if point is at the beginning of the buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1160 If the buffer is narrowed, this means the beginning of the narrowed part. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1161 () |
305 | 1162 { |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
1163 if (PT == BEGV) |
305 | 1164 return Qt; |
1165 return Qnil; | |
1166 } | |
1167 | |
1168 DEFUN ("eobp", Feobp, Seobp, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1169 doc: /* Return t if point is at the end of the buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1170 If the buffer is narrowed, this means the end of the narrowed part. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1171 () |
305 | 1172 { |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
1173 if (PT == ZV) |
305 | 1174 return Qt; |
1175 return Qnil; | |
1176 } | |
1177 | |
1178 DEFUN ("bolp", Fbolp, Sbolp, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1179 doc: /* Return t if point is at the beginning of a line. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1180 () |
305 | 1181 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1182 if (PT == BEGV || FETCH_BYTE (PT_BYTE - 1) == '\n') |
305 | 1183 return Qt; |
1184 return Qnil; | |
1185 } | |
1186 | |
1187 DEFUN ("eolp", Feolp, Seolp, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1188 doc: /* Return t if point is at the end of a line. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1189 `End of a line' includes point being at the end of the buffer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1190 () |
305 | 1191 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1192 if (PT == ZV || FETCH_BYTE (PT_BYTE) == '\n') |
305 | 1193 return Qt; |
1194 return Qnil; | |
1195 } | |
1196 | |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1197 DEFUN ("char-after", Fchar_after, Schar_after, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1198 doc: /* Return character in current buffer at position POS. |
53819
a3fe35a8b56b
(Fchar_after, Fchar_before): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
53687
diff
changeset
|
1199 POS is an integer or a marker and defaults to point. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1200 If POS is out of range, the value is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1201 (pos) |
305 | 1202 Lisp_Object pos; |
1203 { | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1204 register int pos_byte; |
305 | 1205 |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1206 if (NILP (pos)) |
22199
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1207 { |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1208 pos_byte = PT_BYTE; |
23577
36cccf1ba0a9
(Fchar_after): Fix type clashes.
Andreas Schwab <schwab@suse.de>
parents:
23565
diff
changeset
|
1209 XSETFASTINT (pos, PT); |
22199
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1210 } |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1211 |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1212 if (MARKERP (pos)) |
21200
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1213 { |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1214 pos_byte = marker_byte_position (pos); |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1215 if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE) |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1216 return Qnil; |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1217 } |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1218 else |
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1219 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1220 CHECK_NUMBER_COERCE_MARKER (pos); |
21521
354a7085f1d7
(Fchar_after, Fchar_before): Fix mixing of Lisp_Object
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
1221 if (XINT (pos) < BEGV || XINT (pos) >= ZV) |
21200
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1222 return Qnil; |
30480 | 1223 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1224 pos_byte = CHAR_TO_BYTE (XINT (pos)); |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1225 } |
305 | 1226 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1227 return make_number (FETCH_CHAR (pos_byte)); |
305 | 1228 } |
17031 | 1229 |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1230 DEFUN ("char-before", Fchar_before, Schar_before, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1231 doc: /* Return character in current buffer preceding position POS. |
53819
a3fe35a8b56b
(Fchar_after, Fchar_before): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
53687
diff
changeset
|
1232 POS is an integer or a marker and defaults to point. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1233 If POS is out of range, the value is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1234 (pos) |
17031 | 1235 Lisp_Object pos; |
1236 { | |
1237 register Lisp_Object val; | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1238 register int pos_byte; |
17031 | 1239 |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1240 if (NILP (pos)) |
22199
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1241 { |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1242 pos_byte = PT_BYTE; |
23577
36cccf1ba0a9
(Fchar_after): Fix type clashes.
Andreas Schwab <schwab@suse.de>
parents:
23565
diff
changeset
|
1243 XSETFASTINT (pos, PT); |
22199
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1244 } |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1245 |
edca9002c740
(Fchar_after): Make nil fully equivalent to (point) as arg.
Richard M. Stallman <rms@gnu.org>
parents:
21914
diff
changeset
|
1246 if (MARKERP (pos)) |
21200
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1247 { |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1248 pos_byte = marker_byte_position (pos); |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1249 |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1250 if (pos_byte <= BEGV_BYTE || pos_byte > ZV_BYTE) |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1251 return Qnil; |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1252 } |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1253 else |
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1254 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1255 CHECK_NUMBER_COERCE_MARKER (pos); |
17031 | 1256 |
21521
354a7085f1d7
(Fchar_after, Fchar_before): Fix mixing of Lisp_Object
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
1257 if (XINT (pos) <= BEGV || XINT (pos) > ZV) |
21200
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1258 return Qnil; |
ea520c42a342
(Fchar_after, Fchar_before): Properly check arg type
Richard M. Stallman <rms@gnu.org>
parents:
21064
diff
changeset
|
1259 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1260 pos_byte = CHAR_TO_BYTE (XINT (pos)); |
18252
9c4fb902b6eb
(Fchar_after, Fchar_before): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
18240
diff
changeset
|
1261 } |
17031 | 1262 |
1263 if (!NILP (current_buffer->enable_multibyte_characters)) | |
1264 { | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1265 DEC_POS (pos_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1266 XSETFASTINT (val, FETCH_CHAR (pos_byte)); |
17031 | 1267 } |
1268 else | |
1269 { | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1270 pos_byte--; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
1271 XSETFASTINT (val, FETCH_BYTE (pos_byte)); |
17031 | 1272 } |
1273 return val; | |
1274 } | |
305 | 1275 |
9572 | 1276 DEFUN ("user-login-name", Fuser_login_name, Suser_login_name, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1277 doc: /* Return the name under which the user logged in, as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1278 This is based on the effective uid, not the real uid. |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
1279 Also, if the environment variables LOGNAME or USER are set, |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1280 that determines the value of this function. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1281 |
102631
f13c449487ad
(Fuser_login_name): Support float arguments. Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
1282 If optional argument UID is an integer or a float, return the login name |
f13c449487ad
(Fuser_login_name): Support float arguments. Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
1283 of the user with that uid, or nil if there is no such user. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1284 (uid) |
9572 | 1285 Lisp_Object uid; |
305 | 1286 { |
9572 | 1287 struct passwd *pw; |
102631
f13c449487ad
(Fuser_login_name): Support float arguments. Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
1288 uid_t id; |
9572 | 1289 |
9520
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1290 /* Set up the user name info if we didn't do it before. |
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1291 (That can happen if Emacs is dumpable |
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1292 but you decide to run `temacs -l loadup' and not dump. */ |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
1293 if (INTEGERP (Vuser_login_name)) |
9520
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1294 init_editfns (); |
9572 | 1295 |
1296 if (NILP (uid)) | |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
1297 return Vuser_login_name; |
9572 | 1298 |
102631
f13c449487ad
(Fuser_login_name): Support float arguments. Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
1299 id = (uid_t)XFLOATINT (uid); |
71817
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1300 BLOCK_INPUT; |
102631
f13c449487ad
(Fuser_login_name): Support float arguments. Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
1301 pw = (struct passwd *) getpwuid (id); |
71817
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1302 UNBLOCK_INPUT; |
9572 | 1303 return (pw ? build_string (pw->pw_name) : Qnil); |
305 | 1304 } |
1305 | |
1306 DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name, | |
40981
fee88c193206
(Fuser_real_login_name): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents:
40699
diff
changeset
|
1307 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1308 doc: /* Return the name of the user's real uid, as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1309 This ignores the environment variables LOGNAME and USER, so it differs from |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1310 `user-login-name' when running under `su'. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1311 () |
305 | 1312 { |
9520
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1313 /* Set up the user name info if we didn't do it before. |
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1314 (That can happen if Emacs is dumpable |
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1315 but you decide to run `temacs -l loadup' and not dump. */ |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
1316 if (INTEGERP (Vuser_login_name)) |
9520
5187a4159d16
(Fuser_login_name, Fuser_real_login_name):
Richard M. Stallman <rms@gnu.org>
parents:
9305
diff
changeset
|
1317 init_editfns (); |
12026
505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
Karl Heuer <kwzh@gnu.org>
parents:
11912
diff
changeset
|
1318 return Vuser_real_login_name; |
305 | 1319 } |
1320 | |
1321 DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1322 doc: /* Return the effective uid of Emacs. |
102662
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1323 Value is an integer or a float, depending on the value. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1324 () |
305 | 1325 { |
75217
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1326 /* Assignment to EMACS_INT stops GCC whining about limited range of |
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1327 data type. */ |
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1328 EMACS_INT euid = geteuid (); |
102662
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1329 |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1330 /* Make sure we don't produce a negative UID due to signed integer |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1331 overflow. */ |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1332 if (euid < 0) |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1333 return make_float ((double)geteuid ()); |
75217
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1334 return make_fixnum_or_float (euid); |
305 | 1335 } |
1336 | |
1337 DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1338 doc: /* Return the real uid of Emacs. |
102662
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1339 Value is an integer or a float, depending on the value. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1340 () |
305 | 1341 { |
75217
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1342 /* Assignment to EMACS_INT stops GCC whining about limited range of |
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1343 data type. */ |
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1344 EMACS_INT uid = getuid (); |
102662
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1345 |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1346 /* Make sure we don't produce a negative UID due to signed integer |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1347 overflow. */ |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1348 if (uid < 0) |
aa16e7d76321
(Fuser_uid, Fuser_real_uid): If UID as EMACS_INT is negative, produce
Eli Zaretskii <eliz@gnu.org>
parents:
102631
diff
changeset
|
1349 return make_float ((double)getuid ()); |
75217
9e5c071deb9f
(Fuser_uid, Fuser_real_uid): Copy values returned by geteuid and getuid
Eli Zaretskii <eliz@gnu.org>
parents:
75181
diff
changeset
|
1350 return make_fixnum_or_float (uid); |
305 | 1351 } |
1352 | |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1353 DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1354 doc: /* Return the full name of the user logged in, as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1355 If the full name corresponding to Emacs's userid is not known, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1356 return "unknown". |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1357 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1358 If optional argument UID is an integer or float, return the full name |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1359 of the user with that uid, or nil if there is no such user. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1360 If UID is a string, return the full name of the user with that login |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1361 name, or nil if there is no such user. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1362 (uid) |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1363 Lisp_Object uid; |
305 | 1364 { |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1365 struct passwd *pw; |
18661
537522d5e6d8
(Fuser_full_name): Declare p, q and r as unsigned char *.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
1366 register unsigned char *p, *q; |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1367 Lisp_Object full; |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1368 |
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1369 if (NILP (uid)) |
30480 | 1370 return Vuser_full_name; |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1371 else if (NUMBERP (uid)) |
71817
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1372 { |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1373 BLOCK_INPUT; |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1374 pw = (struct passwd *) getpwuid ((uid_t) XFLOATINT (uid)); |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1375 UNBLOCK_INPUT; |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1376 } |
30480 | 1377 else if (STRINGP (uid)) |
71817
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1378 { |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1379 BLOCK_INPUT; |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1380 pw = (struct passwd *) getpwnam (SDATA (uid)); |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1381 UNBLOCK_INPUT; |
fb57c1830788
Include blockinput.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71498
diff
changeset
|
1382 } |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1383 else |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1384 error ("Invalid UID specification"); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
1385 |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1386 if (!pw) |
16683
6802dbd07a80
(Fuser_full_name): Return nil if the specified user doesn't exist.
Richard M. Stallman <rms@gnu.org>
parents:
16648
diff
changeset
|
1387 return Qnil; |
30480 | 1388 |
97655
287457e9bac1
(USER_FULL_NAME): Define to pw->pw_gecos if undefined.
Eli Zaretskii <eliz@gnu.org>
parents:
96718
diff
changeset
|
1389 p = (unsigned char *) USER_FULL_NAME; |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1390 /* Chop off everything after the first comma. */ |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1391 q = (unsigned char *) index (p, ','); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1392 full = make_string (p, q ? q - p : strlen (p)); |
30480 | 1393 |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1394 #ifdef AMPERSAND_FULL_NAME |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1395 p = SDATA (full); |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1396 q = (unsigned char *) index (p, '&'); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1397 /* Substitute the login name for the &, upcasing the first character. */ |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1398 if (q) |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1399 { |
18661
537522d5e6d8
(Fuser_full_name): Declare p, q and r as unsigned char *.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
1400 register unsigned char *r; |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1401 Lisp_Object login; |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1402 |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1403 login = Fuser_login_name (make_number (pw->pw_uid)); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1404 r = (unsigned char *) alloca (strlen (p) + SCHARS (login) + 1); |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1405 bcopy (p, r, q - p); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1406 r[q - p] = 0; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1407 strcat (r, SDATA (login)); |
16641
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1408 r[q - p] = UPCASE (r[q - p]); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1409 strcat (r, q + 1); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1410 full = build_string (r); |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1411 } |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1412 #endif /* AMPERSAND_FULL_NAME */ |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1413 |
2103a88cc61f
(Fuser_full_name): Accept a string (the login name) as
Richard M. Stallman <rms@gnu.org>
parents:
16639
diff
changeset
|
1414 return full; |
305 | 1415 } |
1416 | |
1417 DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, | |
72751
9128a4531448
(Fsystem_name): Mention "host" in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
72669
diff
changeset
|
1418 doc: /* Return the host name of the machine you are running on, as a string. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1419 () |
305 | 1420 { |
1421 return Vsystem_name; | |
1422 } | |
1423 | |
7907
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1424 /* For the benefit of callers who don't want to include lisp.h */ |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
1425 |
7907
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1426 char * |
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1427 get_system_name () |
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1428 { |
18756
751f531e5a20
(get_system_name): Don't crash if Vsystem_name does not contain a string.
Richard M. Stallman <rms@gnu.org>
parents:
18745
diff
changeset
|
1429 if (STRINGP (Vsystem_name)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1430 return (char *) SDATA (Vsystem_name); |
18756
751f531e5a20
(get_system_name): Don't crash if Vsystem_name does not contain a string.
Richard M. Stallman <rms@gnu.org>
parents:
18745
diff
changeset
|
1431 else |
751f531e5a20
(get_system_name): Don't crash if Vsystem_name does not contain a string.
Richard M. Stallman <rms@gnu.org>
parents:
18745
diff
changeset
|
1432 return ""; |
7907
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1433 } |
148ad20d6774
(init_editfns): Call init_system_name instead of get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7862
diff
changeset
|
1434 |
59658
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1435 char * |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1436 get_operating_system_release() |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1437 { |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1438 if (STRINGP (Voperating_system_release)) |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1439 return (char *) SDATA (Voperating_system_release); |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1440 else |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1441 return ""; |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1442 } |
45074d913d23
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
59644
diff
changeset
|
1443 |
5373
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
1444 DEFUN ("emacs-pid", Femacs_pid, Semacs_pid, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1445 doc: /* Return the process ID of Emacs, as an integer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1446 () |
5373
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
1447 { |
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
1448 return make_number (getpid ()); |
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
1449 } |
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
1450 |
448 | 1451 DEFUN ("current-time", Fcurrent_time, Scurrent_time, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1452 doc: /* Return the current time, as the number of seconds since 1970-01-01 00:00:00. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1453 The time is returned as a list of three integers. The first has the |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1454 most significant 16 bits of the seconds, while the second has the |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1455 least significant 16 bits. The third integer gives the microsecond |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1456 count. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1457 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1458 The microsecond count is zero on systems that do not provide |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1459 resolution finer than a second. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1460 () |
448 | 1461 { |
577 | 1462 EMACS_TIME t; |
1463 | |
1464 EMACS_GET_TIME (t); | |
72531
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1465 return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff), |
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1466 make_number ((EMACS_SECS (t) >> 0) & 0xffff), |
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1467 make_number (EMACS_USECS (t))); |
448 | 1468 } |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1469 |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1470 DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1471 0, 0, 0, |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1472 doc: /* Return the current run time used by Emacs. |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1473 The time is returned as a list of three integers. The first has the |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1474 most significant 16 bits of the seconds, while the second has the |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1475 least significant 16 bits. The third integer gives the microsecond |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1476 count. |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1477 |
75387
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
1478 On systems that can't determine the run time, `get-internal-run-time' |
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
1479 does the same thing as `current-time'. The microsecond count is zero |
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
1480 on systems that do not provide resolution finer than a second. */) |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1481 () |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1482 { |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1483 #ifdef HAVE_GETRUSAGE |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1484 struct rusage usage; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1485 int secs, usecs; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1486 |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1487 if (getrusage (RUSAGE_SELF, &usage) < 0) |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1488 /* This shouldn't happen. What action is appropriate? */ |
71975
6d29dff081c5
(region_limit, Fget_internal_run_time): Use xsignal0.
Kim F. Storm <storm@cua.dk>
parents:
71865
diff
changeset
|
1489 xsignal0 (Qerror); |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1490 |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1491 /* Sum up user time and system time. */ |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1492 secs = usage.ru_utime.tv_sec + usage.ru_stime.tv_sec; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1493 usecs = usage.ru_utime.tv_usec + usage.ru_stime.tv_usec; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1494 if (usecs >= 1000000) |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1495 { |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1496 usecs -= 1000000; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1497 secs++; |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1498 } |
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1499 |
72531
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1500 return list3 (make_number ((secs >> 16) & 0xffff), |
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1501 make_number ((secs >> 0) & 0xffff), |
90bdf0a2ff4c
(Fcurrent_time, Fget_internal_run_time): Simplify; use list3.
Kim F. Storm <storm@cua.dk>
parents:
72272
diff
changeset
|
1502 make_number (usecs)); |
81422
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
1503 #else /* ! HAVE_GETRUSAGE */ |
96348
ecd6143014da
Remove unneeded -Defines in the compiler command line (MinGW and MSVC).
Juanma Barranquero <lekktu@gmail.com>
parents:
95479
diff
changeset
|
1504 #ifdef WINDOWSNT |
81422
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
1505 return w32_get_internal_run_time (); |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
1506 #else /* ! WINDOWSNT */ |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1507 return Fcurrent_time (); |
81422
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
1508 #endif /* WINDOWSNT */ |
9086f0548bdc
(Fget_internal_run_time) [WINDOWSNT]: Use w32_get_internal_run_time.
Jason Rumney <jasonr@gnu.org>
parents:
81286
diff
changeset
|
1509 #endif /* HAVE_GETRUSAGE */ |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
1510 } |
448 | 1511 |
1512 | |
55193
1b09eb24ab02
(lisp_time_argument): Provide externally.
Eli Zaretskii <eliz@gnu.org>
parents:
54846
diff
changeset
|
1513 int |
30480 | 1514 lisp_time_argument (specified_time, result, usec) |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1515 Lisp_Object specified_time; |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1516 time_t *result; |
30480 | 1517 int *usec; |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1518 { |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1519 if (NILP (specified_time)) |
30480 | 1520 { |
1521 if (usec) | |
1522 { | |
1523 EMACS_TIME t; | |
1524 | |
30503
fef49230e1aa
(lisp_time_argument): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
30480
diff
changeset
|
1525 EMACS_GET_TIME (t); |
30480 | 1526 *usec = EMACS_USECS (t); |
1527 *result = EMACS_SECS (t); | |
1528 return 1; | |
1529 } | |
1530 else | |
1531 return time (result) != -1; | |
1532 } | |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1533 else |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1534 { |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1535 Lisp_Object high, low; |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1536 high = Fcar (specified_time); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1537 CHECK_NUMBER (high); |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1538 low = Fcdr (specified_time); |
9163
41fe5f636879
(lisp_time_argument, Finsert, Finsert_and_inherit, Finsert_before_markers,
Karl Heuer <kwzh@gnu.org>
parents:
9154
diff
changeset
|
1539 if (CONSP (low)) |
30480 | 1540 { |
1541 if (usec) | |
1542 { | |
1543 Lisp_Object usec_l = Fcdr (low); | |
1544 if (CONSP (usec_l)) | |
1545 usec_l = Fcar (usec_l); | |
1546 if (NILP (usec_l)) | |
1547 *usec = 0; | |
1548 else | |
1549 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1550 CHECK_NUMBER (usec_l); |
30480 | 1551 *usec = XINT (usec_l); |
1552 } | |
1553 } | |
1554 low = Fcar (low); | |
1555 } | |
1556 else if (usec) | |
1557 *usec = 0; | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1558 CHECK_NUMBER (low); |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1559 *result = (XINT (high) << 16) + (XINT (low) & 0xffff); |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1560 return *result >> 16 == XINT (high); |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1561 } |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1562 } |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1563 |
30480 | 1564 DEFUN ("float-time", Ffloat_time, Sfloat_time, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1565 doc: /* Return the current time, as a float number of seconds since the epoch. |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
1566 If SPECIFIED-TIME is given, it is the time to convert to float |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1567 instead of the current time. The argument should have the form |
102724
5dfe0cbf0e1b
(Ffloat_time): Doc fix (Bug#2768).
Chong Yidong <cyd@stupidchicken.com>
parents:
102662
diff
changeset
|
1568 (HIGH LOW) or (HIGH LOW USEC). Thus, you can use times obtained from |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1569 `current-time' and from `file-attributes'. SPECIFIED-TIME can also |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1570 have the form (HIGH . LOW), but this is considered obsolete. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1571 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1572 WARNING: Since the result is floating point, it may not be exact. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1573 Do not use this function if precise time stamps are required. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1574 (specified_time) |
30480 | 1575 Lisp_Object specified_time; |
1576 { | |
1577 time_t sec; | |
1578 int usec; | |
1579 | |
1580 if (! lisp_time_argument (specified_time, &sec, &usec)) | |
1581 error ("Invalid time specification"); | |
1582 | |
37046
a9b2639dd045
(Ffloat_time): Fix off-by-factor-of-10 bug in the
Gerd Moellmann <gerd@gnu.org>
parents:
36479
diff
changeset
|
1583 return make_float ((sec * 1e6 + usec) / 1e6); |
30480 | 1584 } |
1585 | |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1586 /* Write information into buffer S of size MAXSIZE, according to the |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1587 FORMAT of length FORMAT_LEN, using time information taken from *TP. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1588 Default to Universal Time if UT is nonzero, local time otherwise. |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1589 Return the number of bytes written, not including the terminating |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1590 '\0'. If S is NULL, nothing will be written anywhere; so to |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1591 determine how many bytes would be written, use NULL for S and |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1592 ((size_t) -1) for MAXSIZE. |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1593 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1594 This function behaves like emacs_strftimeu, except it allows null |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1595 bytes in FORMAT. */ |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1596 static size_t |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1597 emacs_memftimeu (s, maxsize, format, format_len, tp, ut) |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1598 char *s; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1599 size_t maxsize; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1600 const char *format; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1601 size_t format_len; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1602 const struct tm *tp; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1603 int ut; |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1604 { |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1605 size_t total = 0; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1606 |
23218
90e5d916ebd9
Add a comment to emacs_memftime, explaining why it needs to loop.
Paul Eggert <eggert@twinsun.com>
parents:
23213
diff
changeset
|
1607 /* Loop through all the null-terminated strings in the format |
90e5d916ebd9
Add a comment to emacs_memftime, explaining why it needs to loop.
Paul Eggert <eggert@twinsun.com>
parents:
23213
diff
changeset
|
1608 argument. Normally there's just one null-terminated string, but |
90e5d916ebd9
Add a comment to emacs_memftime, explaining why it needs to loop.
Paul Eggert <eggert@twinsun.com>
parents:
23213
diff
changeset
|
1609 there can be arbitrarily many, concatenated together, if the |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1610 format contains '\0' bytes. emacs_strftimeu stops at the first |
23218
90e5d916ebd9
Add a comment to emacs_memftime, explaining why it needs to loop.
Paul Eggert <eggert@twinsun.com>
parents:
23213
diff
changeset
|
1611 '\0' byte so we must invoke it separately for each such string. */ |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1612 for (;;) |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1613 { |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1614 size_t len; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1615 size_t result; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1616 |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1617 if (s) |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1618 s[0] = '\1'; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1619 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1620 result = emacs_strftimeu (s, maxsize, format, tp, ut); |
23213
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1621 |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1622 if (s) |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1623 { |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1624 if (result == 0 && s[0] != '\0') |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1625 return 0; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1626 s += result + 1; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1627 } |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1628 |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1629 maxsize -= result + 1; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1630 total += result; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1631 len = strlen (format); |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1632 if (len == format_len) |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1633 return total; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1634 total++; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1635 format += len + 1; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1636 format_len -= len + 1; |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1637 } |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1638 } |
3bfc1e9b0377
(emacs_memftime): New function.
Paul Eggert <eggert@twinsun.com>
parents:
23211
diff
changeset
|
1639 |
17907
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1640 DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1641 doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1642 TIME is specified as (HIGH LOW . IGNORED), as returned by |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1643 `current-time' or `file-attributes'. The obsolete form (HIGH . LOW) |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1644 is also still accepted. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1645 The third, optional, argument UNIVERSAL, if non-nil, means describe TIME |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1646 as Universal Time; nil means describe TIME in the local time zone. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1647 The value is a copy of FORMAT-STRING, but with certain constructs replaced |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1648 by text that describes the specified date and time in TIME: |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1649 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1650 %Y is the year, %y within the century, %C the century. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1651 %G is the year corresponding to the ISO week, %g within the century. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1652 %m is the numeric month. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1653 %b and %h are the locale's abbreviated month name, %B the full name. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1654 %d is the day of the month, zero-padded, %e is blank-padded. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1655 %u is the numeric day of week from 1 (Monday) to 7, %w from 0 (Sunday) to 6. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1656 %a is the locale's abbreviated name of the day of week, %A the full name. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1657 %U is the week number starting on Sunday, %W starting on Monday, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1658 %V according to ISO 8601. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1659 %j is the day of the year. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1660 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1661 %H is the hour on a 24-hour clock, %I is on a 12-hour clock, %k is like %H |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1662 only blank-padded, %l is like %I blank-padded. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1663 %p is the locale's equivalent of either AM or PM. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1664 %M is the minute. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1665 %S is the second. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1666 %Z is the time zone name, %z is the numeric form. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1667 %s is the number of seconds since 1970-01-01 00:00:00 +0000. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1668 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1669 %c is the locale's date and time format. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1670 %x is the locale's "preferred" date format. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1671 %D is like "%m/%d/%y". |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1672 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1673 %R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p". |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1674 %X is the locale's "preferred" time format. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1675 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1676 Finally, %n is a newline, %t is a tab, %% is a literal %. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1677 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1678 Certain flags and modifiers are available with some format controls. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1679 The flags are `_', `-', `^' and `#'. For certain characters X, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1680 %_X is like %X, but padded with blanks; %-X is like %X, |
47763
da8405c812f2
(Fformat_time_string): Doc fix.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
46921
diff
changeset
|
1681 but without padding. %^X is like %X, but with all textual |
da8405c812f2
(Fformat_time_string): Doc fix.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
46921
diff
changeset
|
1682 characters up-cased; %#X is like %X, but with letter-case of |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1683 all textual characters reversed. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1684 %NX (where N stands for an integer) is like %X, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1685 but takes up at least N (a number) positions. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1686 The modifiers are `E' and `O'. For certain characters X, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1687 %EX is a locale's alternative version of %X; |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1688 %OX is like %X, but uses the locale's number symbols. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1689 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1690 For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1691 (format_string, time, universal) |
17907
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1692 Lisp_Object format_string, time, universal; |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1693 { |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1694 time_t value; |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1695 int size; |
23198
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1696 struct tm *tm; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1697 int ut = ! NILP (universal); |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1698 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1699 CHECK_STRING (format_string); |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1700 |
30480 | 1701 if (! lisp_time_argument (time, &value, NULL)) |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1702 error ("Invalid time specification"); |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1703 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1704 format_string = code_convert_string_norecord (format_string, |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1705 Vlocale_coding_system, 1); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1706 |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1707 /* This is probably enough. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1708 size = SBYTES (format_string) * 6 + 50; |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1709 |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1710 BLOCK_INPUT; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1711 tm = ut ? gmtime (&value) : localtime (&value); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1712 UNBLOCK_INPUT; |
23198
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1713 if (! tm) |
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1714 error ("Specified time is not representable"); |
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1715 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26415
diff
changeset
|
1716 synchronize_system_time_locale (); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1717 |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1718 while (1) |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1719 { |
17907
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1720 char *buf = (char *) alloca (size + 1); |
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1721 int result; |
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1722 |
19032
84ae0a03a643
(Fformat_time_string): Don't hang if strftime produces
Richard M. Stallman <rms@gnu.org>
parents:
18937
diff
changeset
|
1723 buf[0] = '\1'; |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1724 BLOCK_INPUT; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1725 result = emacs_memftimeu (buf, size, SDATA (format_string), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1726 SBYTES (format_string), |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1727 tm, ut); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1728 UNBLOCK_INPUT; |
19032
84ae0a03a643
(Fformat_time_string): Don't hang if strftime produces
Richard M. Stallman <rms@gnu.org>
parents:
18937
diff
changeset
|
1729 if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) |
72669
d8f99fba05ca
(Fformat_time_string): Use make_unibyte_string to make
Kenichi Handa <handa@m17n.org>
parents:
72592
diff
changeset
|
1730 return code_convert_string_norecord (make_unibyte_string (buf, result), |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1731 Vlocale_coding_system, 0); |
17907
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1732 |
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1733 /* If buffer was too small, make it bigger and try again. */ |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1734 BLOCK_INPUT; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1735 result = emacs_memftimeu (NULL, (size_t) -1, |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1736 SDATA (format_string), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1737 SBYTES (format_string), |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26058
diff
changeset
|
1738 tm, ut); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1739 UNBLOCK_INPUT; |
17907
a1f8ff84f3f1
(Fformat_time_string): Doc update.
Richard M. Stallman <rms@gnu.org>
parents:
17829
diff
changeset
|
1740 size = result + 1; |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1741 } |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1742 } |
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
1743 |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1744 DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1745 doc: /* Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST ZONE). |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1746 The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED), |
75387
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
1747 as from `current-time' and `file-attributes', or nil to use the |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1748 current time. The obsolete form (HIGH . LOW) is also still accepted. |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1749 The list has the following nine members: SEC is an integer between 0 |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1750 and 60; SEC is 60 for a leap second, which only some operating systems |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1751 support. MINUTE is an integer between 0 and 59. HOUR is an integer |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1752 between 0 and 23. DAY is an integer between 1 and 31. MONTH is an |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1753 integer between 1 and 12. YEAR is an integer indicating the |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1754 four-digit year. DOW is the day of week, an integer between 0 and 6, |
76509 | 1755 where 0 is Sunday. DST is t if daylight saving time is in effect, |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1756 otherwise nil. ZONE is an integer indicating the number of seconds |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1757 east of Greenwich. (Note that Common Lisp has different meanings for |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1758 DOW and ZONE.) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1759 (specified_time) |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1760 Lisp_Object specified_time; |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1761 { |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1762 time_t time_spec; |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1763 struct tm save_tm; |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1764 struct tm *decoded_time; |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1765 Lisp_Object list_args[9]; |
30480 | 1766 |
1767 if (! lisp_time_argument (specified_time, &time_spec, NULL)) | |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1768 error ("Invalid time specification"); |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1769 |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1770 BLOCK_INPUT; |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1771 decoded_time = localtime (&time_spec); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1772 UNBLOCK_INPUT; |
23198
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1773 if (! decoded_time) |
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1774 error ("Specified time is not representable"); |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1775 XSETFASTINT (list_args[0], decoded_time->tm_sec); |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1776 XSETFASTINT (list_args[1], decoded_time->tm_min); |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1777 XSETFASTINT (list_args[2], decoded_time->tm_hour); |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1778 XSETFASTINT (list_args[3], decoded_time->tm_mday); |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1779 XSETFASTINT (list_args[4], decoded_time->tm_mon + 1); |
69673
23a81b585dd1
Move explanations from ChangeLog to the source.
Eli Zaretskii <eliz@gnu.org>
parents:
69664
diff
changeset
|
1780 /* On 64-bit machines an int is narrower than EMACS_INT, thus the |
23a81b585dd1
Move explanations from ChangeLog to the source.
Eli Zaretskii <eliz@gnu.org>
parents:
69664
diff
changeset
|
1781 cast below avoids overflow in int arithmetics. */ |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1782 XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year); |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1783 XSETFASTINT (list_args[6], decoded_time->tm_wday); |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1784 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1785 |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1786 /* Make a copy, in case gmtime modifies the struct. */ |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1787 save_tm = *decoded_time; |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1788 BLOCK_INPUT; |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1789 decoded_time = gmtime (&time_spec); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1790 UNBLOCK_INPUT; |
9812
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1791 if (decoded_time == 0) |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1792 list_args[8] = Qnil; |
bc352c8f079c
(Fdecode_time): Fix Lisp_Object vs. integer problems.
Karl Heuer <kwzh@gnu.org>
parents:
9809
diff
changeset
|
1793 else |
16269
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1794 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1795 return Flist (9, list_args); |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1796 } |
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
1797 |
15180
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1798 DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1799 doc: /* Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1800 This is the reverse operation of `decode-time', which see. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1801 ZONE defaults to the current time zone rule. This can |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1802 be a string or t (as from `set-time-zone-rule'), or it can be a list |
40044
7a0668d72687
(text_property_stickiness): Non-rear-non-stickiness doesn't take
Miles Bader <miles@gnu.org>
parents:
40042
diff
changeset
|
1803 \(as from `current-time-zone') or an integer (as from `decode-time') |
76498
741577a048ed
(Fdecode_time, Fencode_time): "daylight savings" -> "daylight saving"
Chong Yidong <cyd@stupidchicken.com>
parents:
75949
diff
changeset
|
1804 applied without consideration for daylight saving time. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1805 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1806 You can pass more than 7 arguments; then the first six arguments |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1807 are used as SECOND through YEAR, and the *last* argument is used as ZONE. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1808 The intervening arguments are ignored. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1809 This feature lets (apply 'encode-time (decode-time ...)) work. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1810 |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
1811 Out-of-range values for SECOND, MINUTE, HOUR, DAY, or MONTH are allowed; |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1812 for example, a DAY of 0 means the day preceding the given month. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1813 Year numbers less than 100 are treated just like other year numbers. |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
1814 If you want them to stand for years in this century, you must do that yourself. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
1815 |
52211
a057bd074729
(Fencode_time): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51841
diff
changeset
|
1816 Years before 1970 are not guaranteed to work. On some systems, |
a057bd074729
(Fencode_time): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51841
diff
changeset
|
1817 year values as low as 1901 do work. |
a057bd074729
(Fencode_time): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51841
diff
changeset
|
1818 |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
1819 usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1820 (nargs, args) |
15180
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1821 int nargs; |
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1822 register Lisp_Object *args; |
11402
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
1823 { |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1824 time_t time; |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1825 struct tm tm; |
16874 | 1826 Lisp_Object zone = (nargs > 6 ? args[nargs - 1] : Qnil); |
11402
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
1827 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1828 CHECK_NUMBER (args[0]); /* second */ |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1829 CHECK_NUMBER (args[1]); /* minute */ |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1830 CHECK_NUMBER (args[2]); /* hour */ |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1831 CHECK_NUMBER (args[3]); /* day */ |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1832 CHECK_NUMBER (args[4]); /* month */ |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
1833 CHECK_NUMBER (args[5]); /* year */ |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1834 |
15180
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1835 tm.tm_sec = XINT (args[0]); |
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1836 tm.tm_min = XINT (args[1]); |
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1837 tm.tm_hour = XINT (args[2]); |
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1838 tm.tm_mday = XINT (args[3]); |
9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
Richard M. Stallman <rms@gnu.org>
parents:
15075
diff
changeset
|
1839 tm.tm_mon = XINT (args[4]) - 1; |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1840 tm.tm_year = XINT (args[5]) - TM_YEAR_BASE; |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1841 tm.tm_isdst = -1; |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1842 |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1843 if (CONSP (zone)) |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1844 zone = Fcar (zone); |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1845 if (NILP (zone)) |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1846 { |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1847 BLOCK_INPUT; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1848 time = mktime (&tm); |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1849 UNBLOCK_INPUT; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1850 } |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1851 else |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1852 { |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1853 char tzbuf[100]; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1854 char *tzstring; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1855 char **oldenv = environ, **newenv; |
30480 | 1856 |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18605
diff
changeset
|
1857 if (EQ (zone, Qt)) |
15910
8cd4f2fd5525
(Fencode_time, Fset_time_zone_rule): Use UTC if the zone is t.
Erik Naggum <erik@naggum.no>
parents:
15841
diff
changeset
|
1858 tzstring = "UTC0"; |
8cd4f2fd5525
(Fencode_time, Fset_time_zone_rule): Use UTC if the zone is t.
Erik Naggum <erik@naggum.no>
parents:
15841
diff
changeset
|
1859 else if (STRINGP (zone)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
1860 tzstring = (char *) SDATA (zone); |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1861 else if (INTEGERP (zone)) |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1862 { |
85253 | 1863 int abszone = eabs (XINT (zone)); |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1864 sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0), |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1865 abszone / (60*60), (abszone/60) % 60, abszone % 60); |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1866 tzstring = tzbuf; |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1867 } |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1868 else |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1869 error ("Invalid time zone specification"); |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1870 |
30480 | 1871 /* Set TZ before calling mktime; merely adjusting mktime's returned |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1872 value doesn't suffice, since that would mishandle leap seconds. */ |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1873 set_time_zone_rule (tzstring); |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1874 |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1875 BLOCK_INPUT; |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1876 time = mktime (&tm); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1877 UNBLOCK_INPUT; |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1878 |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1879 /* Restore TZ to previous value. */ |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1880 newenv = environ; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1881 environ = oldenv; |
16521
fe9cc0d392dd
(Fencode_time): Use xfree, not free.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1882 xfree (newenv); |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1883 #ifdef LOCALTIME_CACHE |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1884 tzset (); |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1885 #endif |
11468
772f49d1969d
(Fencode_time): Rewrite by Naggum.
Richard M. Stallman <rms@gnu.org>
parents:
11451
diff
changeset
|
1886 } |
11402
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
1887 |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1888 if (time == (time_t) -1) |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1889 error ("Specified time is not representable"); |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1890 |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
1891 return make_time (time); |
11402
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
1892 } |
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
1893 |
2154
69c58e548ca5
(Fcurrent_time_string): Optional arg specifies time.
Richard M. Stallman <rms@gnu.org>
parents:
2049
diff
changeset
|
1894 DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1895 doc: /* Return the current time, as a human-readable string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1896 Programs can use this function to decode a time, |
69790
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1897 since the number of columns in each field is fixed |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1898 if the year is in the range 1000-9999. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1899 The format is `Sun Sep 16 01:03:52 1973'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1900 However, see also the functions `decode-time' and `format-time-string' |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1901 which provide a much more powerful and general facility. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1902 |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1903 If SPECIFIED-TIME is given, it is a time to format instead of the |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1904 current time. The argument should have the form (HIGH LOW . IGNORED). |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1905 Thus, you can use times obtained from `current-time' and from |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1906 `file-attributes'. SPECIFIED-TIME can also have the form (HIGH . LOW), |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1907 but this is considered obsolete. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1908 (specified_time) |
2154
69c58e548ca5
(Fcurrent_time_string): Optional arg specifies time.
Richard M. Stallman <rms@gnu.org>
parents:
2049
diff
changeset
|
1909 Lisp_Object specified_time; |
305 | 1910 { |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1911 time_t value; |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1912 struct tm *tm; |
2154
69c58e548ca5
(Fcurrent_time_string): Optional arg specifies time.
Richard M. Stallman <rms@gnu.org>
parents:
2049
diff
changeset
|
1913 register char *tem; |
69c58e548ca5
(Fcurrent_time_string): Optional arg specifies time.
Richard M. Stallman <rms@gnu.org>
parents:
2049
diff
changeset
|
1914 |
30480 | 1915 if (! lisp_time_argument (specified_time, &value, NULL)) |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1916 error ("Invalid time specification"); |
69790
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1917 |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1918 /* Convert to a string, checking for out-of-range time stamps. |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1919 Don't use 'ctime', as that might dump core if VALUE is out of |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1920 range. */ |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1921 BLOCK_INPUT; |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1922 tm = localtime (&value); |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1923 UNBLOCK_INPUT; |
69790
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1924 if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) |
69664
55e66496ae1a
* editfns.c: (TM_YEAR_BASE): Move up.
Paul Eggert <eggert@twinsun.com>
parents:
68669
diff
changeset
|
1925 error ("Specified time is not representable"); |
69790
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1926 |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1927 /* Remove the trailing newline. */ |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1928 tem[strlen (tem) - 1] = '\0'; |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1929 |
1e68e7f3b824
* lib-src/b2m.c (main): Don't include <limits.h>.
Paul Eggert <eggert@twinsun.com>
parents:
69673
diff
changeset
|
1930 return build_string (tem); |
305 | 1931 } |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
1932 |
16269
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1933 /* Yield A - B, measured in seconds. |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1934 This function is copied from the GNU C Library. */ |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1935 static int |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1936 tm_diff (a, b) |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1937 struct tm *a, *b; |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1938 { |
16269
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1939 /* Compute intervening leap days correctly even if year is negative. |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1940 Take care to avoid int overflow in leap day calculations, |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1941 but it's OK to assume that A and B are close to each other. */ |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1942 int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1943 int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1944 int a100 = a4 / 25 - (a4 % 25 < 0); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1945 int b100 = b4 / 25 - (b4 % 25 < 0); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1946 int a400 = a100 >> 2; |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1947 int b400 = b100 >> 2; |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1948 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1949 int years = a->tm_year - b->tm_year; |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1950 int days = (365 * years + intervening_leap_days |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1951 + (a->tm_yday - b->tm_yday)); |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1952 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) |
79e6c47054c5
(tm_diff): Renamed from difftm. Yield int, not long.
Paul Eggert <eggert@twinsun.com>
parents:
16134
diff
changeset
|
1953 + (a->tm_min - b->tm_min)) |
5882 | 1954 + (a->tm_sec - b->tm_sec)); |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1955 } |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1956 |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1957 DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1958 doc: /* Return the offset and name for the local time zone. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1959 This returns a list of the form (OFFSET NAME). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1960 OFFSET is an integer number of seconds ahead of UTC (east of Greenwich). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1961 A negative value means west of Greenwich. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1962 NAME is a string giving the name of the time zone. |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
1963 If SPECIFIED-TIME is given, the time zone offset is determined from it |
56386
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1964 instead of using the current time. The argument should have the form |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1965 (HIGH LOW . IGNORED). Thus, you can use times obtained from |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1966 `current-time' and from `file-attributes'. SPECIFIED-TIME can also |
4f00fbfe3c1e
(Ffloat_time, Fformat_time_string, Fdecode_time)
Luc Teirlinck <teirllm@auburn.edu>
parents:
56194
diff
changeset
|
1967 have the form (HIGH . LOW), but this is considered obsolete. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1968 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1969 Some operating systems cannot provide all this information to Emacs; |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
1970 in this case, `current-time-zone' returns a list containing nil for |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1971 the data it can't find. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
1972 (specified_time) |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1973 Lisp_Object specified_time; |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
1974 { |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1975 time_t value; |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1976 struct tm *t; |
23198
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1977 struct tm gmt; |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
1978 |
75096
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1979 if (!lisp_time_argument (specified_time, &value, NULL)) |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1980 t = NULL; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1981 else |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1982 { |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1983 BLOCK_INPUT; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1984 t = gmtime (&value); |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1985 if (t) |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1986 { |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1987 gmt = *t; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1988 t = localtime (&value); |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1989 } |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1990 UNBLOCK_INPUT; |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1991 } |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1992 |
ca95b6ba52a9
(Fformat_time_string, Fdecode_time, Fencode_time)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
73950
diff
changeset
|
1993 if (t) |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1994 { |
23198
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1995 int offset = tm_diff (t, &gmt); |
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1996 char *s = 0; |
dddce768cf7a
(Fformat_time_string, Fdecode_time, Fcurrent_time_zone):
Paul Eggert <eggert@twinsun.com>
parents:
23197
diff
changeset
|
1997 char buf[6]; |
81259
d2bd034ded27
(Fcurrent_time_zone): Remove hack for Japanese Windows.
Jason Rumney <jasonr@gnu.org>
parents:
77661
diff
changeset
|
1998 |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
1999 #ifdef HAVE_TM_ZONE |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2000 if (t->tm_zone) |
7506
9fa47d36798a
(Fcurrent_time_zone): Add cast.
Richard M. Stallman <rms@gnu.org>
parents:
7485
diff
changeset
|
2001 s = (char *)t->tm_zone; |
3522
dc9f7a107e28
(Fcurrent_time_zone): Add alternative for !HAVE_TM_ZONE.
Richard M. Stallman <rms@gnu.org>
parents:
2994
diff
changeset
|
2002 #else /* not HAVE_TM_ZONE */ |
dc9f7a107e28
(Fcurrent_time_zone): Add alternative for !HAVE_TM_ZONE.
Richard M. Stallman <rms@gnu.org>
parents:
2994
diff
changeset
|
2003 #ifdef HAVE_TZNAME |
dc9f7a107e28
(Fcurrent_time_zone): Add alternative for !HAVE_TM_ZONE.
Richard M. Stallman <rms@gnu.org>
parents:
2994
diff
changeset
|
2004 if (t->tm_isdst == 0 || t->tm_isdst == 1) |
dc9f7a107e28
(Fcurrent_time_zone): Add alternative for !HAVE_TM_ZONE.
Richard M. Stallman <rms@gnu.org>
parents:
2994
diff
changeset
|
2005 s = tzname[t->tm_isdst]; |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
2006 #endif |
3522
dc9f7a107e28
(Fcurrent_time_zone): Add alternative for !HAVE_TM_ZONE.
Richard M. Stallman <rms@gnu.org>
parents:
2994
diff
changeset
|
2007 #endif /* not HAVE_TM_ZONE */ |
36479
ac3ee681e8f9
(Fcurrent_time_zone) [HAVE_TM_ZONE || HAVE_TZNAME]:
Gerd Moellmann <gerd@gnu.org>
parents:
35998
diff
changeset
|
2008 |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2009 if (!s) |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2010 { |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2011 /* No local time zone name is available; use "+-NNNN" instead. */ |
2994
b087b4fd6066
(Fcurrent_time_zone): Make `am' an int, not long.
Richard M. Stallman <rms@gnu.org>
parents:
2976
diff
changeset
|
2012 int am = (offset < 0 ? -offset : offset) / 60; |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2013 sprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, am%60); |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2014 s = buf; |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2015 } |
81259
d2bd034ded27
(Fcurrent_time_zone): Remove hack for Japanese Windows.
Jason Rumney <jasonr@gnu.org>
parents:
77661
diff
changeset
|
2016 |
2921
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2017 return Fcons (make_number (offset), Fcons (build_string (s), Qnil)); |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2018 } |
37503f466755
Some time-handling patches from Paul Eggert:
Jim Blandy <jimb@redhat.com>
parents:
2783
diff
changeset
|
2019 else |
18745
192b3ebd108e
(Fcurrent_time_zone): Convert Fmake_list argument to Lisp_Integer.
Richard M. Stallman <rms@gnu.org>
parents:
18661
diff
changeset
|
2020 return Fmake_list (make_number (2), Qnil); |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
2021 } |
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
2022 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2023 /* This holds the value of `environ' produced by the previous |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2024 call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2025 has never been called. */ |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2026 static char **environbuf; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2027 |
92954
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2028 /* This holds the startup value of the TZ environment variable so it |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2029 can be restored if the user calls set-time-zone-rule with a nil |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2030 argument. */ |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2031 static char *initial_tz; |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2032 |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2033 DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2034 doc: /* Set the local time zone using TZ, a string specifying a time zone rule. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2035 If TZ is nil, use implementation-defined default time zone information. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2036 If TZ is t, use Universal Time. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2037 (tz) |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2038 Lisp_Object tz; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2039 { |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2040 char *tzstring; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2041 |
92954
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2042 /* When called for the first time, save the original TZ. */ |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2043 if (!environbuf) |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2044 initial_tz = (char *) getenv ("TZ"); |
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2045 |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2046 if (NILP (tz)) |
92954
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
2047 tzstring = initial_tz; |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18605
diff
changeset
|
2048 else if (EQ (tz, Qt)) |
15910
8cd4f2fd5525
(Fencode_time, Fset_time_zone_rule): Use UTC if the zone is t.
Erik Naggum <erik@naggum.no>
parents:
15841
diff
changeset
|
2049 tzstring = "UTC0"; |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2050 else |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2051 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2052 CHECK_STRING (tz); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
2053 tzstring = (char *) SDATA (tz); |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2054 } |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2055 |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2056 set_time_zone_rule (tzstring); |
95479
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
94963
diff
changeset
|
2057 free (environbuf); |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2058 environbuf = environ; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2059 |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2060 return Qnil; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2061 } |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2062 |
16918
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2063 #ifdef LOCALTIME_CACHE |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2064 |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2065 /* These two values are known to load tz files in buggy implementations, |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2066 i.e. Solaris 1 executables running under either Solaris 1 or Solaris 2. |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2067 Their values shouldn't matter in non-buggy implementations. |
30480 | 2068 We don't use string literals for these strings, |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2069 since if a string in the environment is in readonly |
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2070 storage, it runs afoul of bugs in SVR4 and Solaris 2.3. |
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2071 See Sun bugs 1113095 and 1114114, ``Timezone routines |
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2072 improperly modify environment''. */ |
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2073 |
16918
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2074 static char set_time_zone_rule_tz1[] = "TZ=GMT+0"; |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2075 static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2076 |
ab49512bcdff
(set_time_zone_rule_tz1, set_time_zone_rule_tz2):
Paul Eggert <eggert@twinsun.com>
parents:
16874
diff
changeset
|
2077 #endif |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2078 |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2079 /* Set the local time zone rule to TZSTRING. |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2080 This allocates memory into `environ', which it is the caller's |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2081 responsibility to free. */ |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
2082 |
14201
ff372902386d
(set_time_zone_rule): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
14126
diff
changeset
|
2083 void |
13025
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2084 set_time_zone_rule (tzstring) |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2085 char *tzstring; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2086 { |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2087 int envptrs; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2088 char **from, **to, **newenv; |
1eab52043f10
(Fencode_time): Use mktime to do the real work;
Paul Eggert <eggert@twinsun.com>
parents:
13019
diff
changeset
|
2089 |
15334 | 2090 /* Make the ENVIRON vector longer with room for TZSTRING. */ |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2091 for (from = environ; *from; from++) |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2092 continue; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2093 envptrs = from - environ + 2; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2094 newenv = to = (char **) xmalloc (envptrs * sizeof (char *) |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2095 + (tzstring ? strlen (tzstring) + 4 : 0)); |
15334 | 2096 |
2097 /* Add TZSTRING to the end of environ, as a value for TZ. */ | |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2098 if (tzstring) |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2099 { |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2100 char *t = (char *) (to + envptrs); |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2101 strcpy (t, "TZ="); |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2102 strcat (t, tzstring); |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2103 *to++ = t; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2104 } |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2105 |
15334 | 2106 /* Copy the old environ vector elements into NEWENV, |
2107 but don't copy the TZ variable. | |
2108 So we have only one definition of TZ, which came from TZSTRING. */ | |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2109 for (from = environ; *from; from++) |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2110 if (strncmp (*from, "TZ=", 3) != 0) |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2111 *to++ = *from; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2112 *to = 0; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2113 |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2114 environ = newenv; |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2115 |
15334 | 2116 /* If we do have a TZSTRING, NEWENV points to the vector slot where |
2117 the TZ variable is stored. If we do not have a TZSTRING, | |
2118 TO points to the vector slot which has the terminating null. */ | |
2119 | |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2120 #ifdef LOCALTIME_CACHE |
15334 | 2121 { |
2122 /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like | |
2123 "US/Pacific" that loads a tz file, then changes to a value like | |
2124 "XXX0" that does not load a tz file, and then changes back to | |
2125 its original value, the last change is (incorrectly) ignored. | |
2126 Also, if TZ changes twice in succession to values that do | |
2127 not load a tz file, tzset can dump core (see Sun bug#1225179). | |
2128 The following code works around these bugs. */ | |
2129 | |
2130 if (tzstring) | |
2131 { | |
2132 /* Temporarily set TZ to a value that loads a tz file | |
2133 and that differs from tzstring. */ | |
2134 char *tz = *newenv; | |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2135 *newenv = (strcmp (tzstring, set_time_zone_rule_tz1 + 3) == 0 |
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2136 ? set_time_zone_rule_tz2 : set_time_zone_rule_tz1); |
15334 | 2137 tzset (); |
2138 *newenv = tz; | |
2139 } | |
2140 else | |
2141 { | |
2142 /* The implied tzstring is unknown, so temporarily set TZ to | |
2143 two different values that each load a tz file. */ | |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2144 *to = set_time_zone_rule_tz1; |
15334 | 2145 to[1] = 0; |
2146 tzset (); | |
15841
80a852988718
(set_time_zone_rule): Don't put a string literal
Richard M. Stallman <rms@gnu.org>
parents:
15779
diff
changeset
|
2147 *to = set_time_zone_rule_tz2; |
15334 | 2148 tzset (); |
2149 *to = 0; | |
2150 } | |
2151 | |
2152 /* Now TZ has the desired value, and tzset can be invoked safely. */ | |
2153 } | |
2154 | |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2155 tzset (); |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2156 #endif |
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
2157 } |
305 | 2158 |
17031 | 2159 /* Insert NARGS Lisp objects in the array ARGS by calling INSERT_FUNC |
2160 (if a type of object is Lisp_Int) or INSERT_FROM_STRING_FUNC (if a | |
2161 type of object is Lisp_String). INHERIT is passed to | |
2162 INSERT_FROM_STRING_FUNC as the last argument. */ | |
2163 | |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
2164 static void |
102759
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2165 general_insert_function (void (*insert_func) |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2166 (const unsigned char *, EMACS_INT), |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2167 void (*insert_from_string_func) |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2168 (Lisp_Object, EMACS_INT, EMACS_INT, |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2169 EMACS_INT, EMACS_INT, int), |
ec3ec7f5d54e
* editfns.c (general_insert_function): Adjust to insdel.c changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102724
diff
changeset
|
2170 int inherit, int nargs, Lisp_Object *args) |
17031 | 2171 { |
2172 register int argnum; | |
2173 register Lisp_Object val; | |
2174 | |
2175 for (argnum = 0; argnum < nargs; argnum++) | |
2176 { | |
2177 val = args[argnum]; | |
90800
37b19435acef
(Fchar_to_string): Use CHARACTERP, not INTEGERP.
Kenichi Handa <handa@m17n.org>
parents:
90796
diff
changeset
|
2178 if (CHARACTERP (val)) |
17031 | 2179 { |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2180 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
17031 | 2181 int len; |
2182 | |
2183 if (!NILP (current_buffer->enable_multibyte_characters)) | |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2184 len = CHAR_STRING (XFASTINT (val), str); |
17031 | 2185 else |
22929
6dda0a4b882f
(general_insert_function): If enable-multibyte-characters is
Kenichi Handa <handa@m17n.org>
parents:
22895
diff
changeset
|
2186 { |
89209
3903a3ae19cb
(general_insert_function): Check VAL by ASCII_CHAR_P,
Kenichi Handa <handa@m17n.org>
parents:
89034
diff
changeset
|
2187 str[0] = (ASCII_CHAR_P (XINT (val)) |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2188 ? XINT (val) |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2189 : multibyte_char_to_unibyte (XINT (val), Qnil)); |
22929
6dda0a4b882f
(general_insert_function): If enable-multibyte-characters is
Kenichi Handa <handa@m17n.org>
parents:
22895
diff
changeset
|
2190 len = 1; |
6dda0a4b882f
(general_insert_function): If enable-multibyte-characters is
Kenichi Handa <handa@m17n.org>
parents:
22895
diff
changeset
|
2191 } |
17031 | 2192 (*insert_func) (str, len); |
2193 } | |
2194 else if (STRINGP (val)) | |
2195 { | |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
2196 (*insert_from_string_func) (val, 0, 0, |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
2197 SCHARS (val), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
2198 SBYTES (val), |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
2199 inherit); |
17031 | 2200 } |
2201 else | |
71832
e891eb992cb2
(general_insert_function): Remove loop around wrong_type_argument.
Kim F. Storm <storm@cua.dk>
parents:
71817
diff
changeset
|
2202 wrong_type_argument (Qchar_or_string_p, val); |
17031 | 2203 } |
2204 } | |
2205 | |
305 | 2206 void |
2207 insert1 (arg) | |
2208 Lisp_Object arg; | |
2209 { | |
2210 Finsert (1, &arg); | |
2211 } | |
2212 | |
330 | 2213 |
2214 /* Callers passing one argument to Finsert need not gcpro the | |
2215 argument "array", since the only element of the array will | |
2216 not be used after calling insert or insert_from_string, so | |
2217 we don't care if it gets trashed. */ | |
2218 | |
305 | 2219 DEFUN ("insert", Finsert, Sinsert, 0, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2220 doc: /* Insert the arguments, either strings or characters, at point. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2221 Point and before-insertion markers move forward to end up |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2222 after the inserted text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2223 Any other markers at the point of insertion remain before the text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2224 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2225 If the current buffer is multibyte, unibyte strings are converted |
49293
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2226 to multibyte for insertion (see `string-make-multibyte'). |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2227 If the current buffer is unibyte, multibyte strings are converted |
49293
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2228 to unibyte for insertion (see `string-make-unibyte'). |
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2229 |
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2230 When operating on binary data, it may be necessary to preserve the |
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2231 original bytes of a unibyte string when inserting it into a multibyte |
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2232 buffer; to accomplish this, apply `string-as-multibyte' to the string |
41213ea7b9d6
(Finsert): Mention `string-make-multibyte' and
Kim F. Storm <storm@cua.dk>
parents:
49285
diff
changeset
|
2233 and insert the result. |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2234 |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2235 usage: (insert &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2236 (nargs, args) |
305 | 2237 int nargs; |
2238 register Lisp_Object *args; | |
2239 { | |
17031 | 2240 general_insert_function (insert, insert_from_string, 0, nargs, args); |
4714
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2241 return Qnil; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2242 } |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2243 |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2244 DEFUN ("insert-and-inherit", Finsert_and_inherit, Sinsert_and_inherit, |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2245 0, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2246 doc: /* Insert the arguments at point, inheriting properties from adjoining text. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2247 Point and before-insertion markers move forward to end up |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2248 after the inserted text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2249 Any other markers at the point of insertion remain before the text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2250 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2251 If the current buffer is multibyte, unibyte strings are converted |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2252 to multibyte for insertion (see `unibyte-char-to-multibyte'). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2253 If the current buffer is unibyte, multibyte strings are converted |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2254 to unibyte for insertion. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2255 |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2256 usage: (insert-and-inherit &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2257 (nargs, args) |
4714
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2258 int nargs; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2259 register Lisp_Object *args; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2260 { |
17031 | 2261 general_insert_function (insert_and_inherit, insert_from_string, 1, |
2262 nargs, args); | |
305 | 2263 return Qnil; |
2264 } | |
2265 | |
2266 DEFUN ("insert-before-markers", Finsert_before_markers, Sinsert_before_markers, 0, MANY, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2267 doc: /* Insert strings or characters at point, relocating markers after the text. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2268 Point and markers move forward to end up after the inserted text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2269 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2270 If the current buffer is multibyte, unibyte strings are converted |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2271 to multibyte for insertion (see `unibyte-char-to-multibyte'). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2272 If the current buffer is unibyte, multibyte strings are converted |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2273 to unibyte for insertion. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2274 |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2275 usage: (insert-before-markers &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2276 (nargs, args) |
305 | 2277 int nargs; |
2278 register Lisp_Object *args; | |
2279 { | |
17031 | 2280 general_insert_function (insert_before_markers, |
2281 insert_from_string_before_markers, 0, | |
2282 nargs, args); | |
4714
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2283 return Qnil; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2284 } |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2285 |
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16298
diff
changeset
|
2286 DEFUN ("insert-before-markers-and-inherit", Finsert_and_inherit_before_markers, |
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16298
diff
changeset
|
2287 Sinsert_and_inherit_before_markers, 0, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2288 doc: /* Insert text at point, relocating markers and inheriting properties. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2289 Point and markers move forward to end up after the inserted text. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2290 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2291 If the current buffer is multibyte, unibyte strings are converted |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2292 to multibyte for insertion (see `unibyte-char-to-multibyte'). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2293 If the current buffer is unibyte, multibyte strings are converted |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2294 to unibyte for insertion. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2295 |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
2296 usage: (insert-before-markers-and-inherit &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2297 (nargs, args) |
4714
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2298 int nargs; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2299 register Lisp_Object *args; |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2300 { |
17031 | 2301 general_insert_function (insert_before_markers_and_inherit, |
2302 insert_from_string_before_markers, 1, | |
2303 nargs, args); | |
305 | 2304 return Qnil; |
2305 } | |
2306 | |
8646
0f05e3e89f87
(Finsert_char): New arg INHERIT.
Richard M. Stallman <rms@gnu.org>
parents:
8333
diff
changeset
|
2307 DEFUN ("insert-char", Finsert_char, Sinsert_char, 2, 3, 0, |
75387
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
2308 doc: /* Insert COUNT copies of CHARACTER. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2309 Point, and before-insertion markers, are relocated as in the function `insert'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2310 The optional third arg INHERIT, if non-nil, says to inherit text properties |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2311 from adjoining text, if those properties are sticky. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2312 (character, count, inherit) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2313 Lisp_Object character, count, inherit; |
305 | 2314 { |
2315 register unsigned char *string; | |
2316 register int strlen; | |
2317 register int i, n; | |
17031 | 2318 int len; |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2319 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
305 | 2320 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2321 CHECK_NUMBER (character); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2322 CHECK_NUMBER (count); |
305 | 2323 |
17031 | 2324 if (!NILP (current_buffer->enable_multibyte_characters)) |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2325 len = CHAR_STRING (XFASTINT (character), str); |
17031 | 2326 else |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2327 str[0] = XFASTINT (character), len = 1; |
17031 | 2328 n = XINT (count) * len; |
305 | 2329 if (n <= 0) |
2330 return Qnil; | |
17031 | 2331 strlen = min (n, 256 * len); |
305 | 2332 string = (unsigned char *) alloca (strlen); |
2333 for (i = 0; i < strlen; i++) | |
17031 | 2334 string[i] = str[i % len]; |
305 | 2335 while (n >= strlen) |
2336 { | |
18194
c291aa915b85
(Finsert_char): Check QUIT.
Richard M. Stallman <rms@gnu.org>
parents:
18106
diff
changeset
|
2337 QUIT; |
8646
0f05e3e89f87
(Finsert_char): New arg INHERIT.
Richard M. Stallman <rms@gnu.org>
parents:
8333
diff
changeset
|
2338 if (!NILP (inherit)) |
0f05e3e89f87
(Finsert_char): New arg INHERIT.
Richard M. Stallman <rms@gnu.org>
parents:
8333
diff
changeset
|
2339 insert_and_inherit (string, strlen); |
0f05e3e89f87
(Finsert_char): New arg INHERIT.
Richard M. Stallman <rms@gnu.org>
parents:
8333
diff
changeset
|
2340 else |
0f05e3e89f87
(Finsert_char): New arg INHERIT.
Richard M. Stallman <rms@gnu.org>
parents:
8333
diff
changeset
|
2341 insert (string, strlen); |
305 | 2342 n -= strlen; |
2343 } | |
2344 if (n > 0) | |
10382
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2345 { |
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2346 if (!NILP (inherit)) |
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2347 insert_and_inherit (string, n); |
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2348 else |
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2349 insert (string, n); |
9738aad59697
(Finsert_char): Check inherit flag for long strings too.
Karl Heuer <kwzh@gnu.org>
parents:
10308
diff
changeset
|
2350 } |
305 | 2351 return Qnil; |
2352 } | |
2353 | |
89034
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2354 DEFUN ("insert-byte", Finsert_byte, Sinsert_byte, 2, 3, 0, |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2355 doc: /* Insert COUNT (second arg) copies of BYTE (first arg). |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2356 Both arguments are required. |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2357 BYTE is a number of the range 0..255. |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2358 |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2359 If BYTE is 128..255 and the current buffer is multibyte, the |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2360 corresponding eight-bit character is inserted. |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2361 |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2362 Point, and before-insertion markers, are relocated as in the function `insert'. |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2363 The optional third arg INHERIT, if non-nil, says to inherit text properties |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2364 from adjoining text, if those properties are sticky. */) |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2365 (byte, count, inherit) |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2366 Lisp_Object byte, count, inherit; |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2367 { |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2368 CHECK_NUMBER (byte); |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2369 if (XINT (byte) < 0 || XINT (byte) > 255) |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2370 args_out_of_range_3 (byte, make_number (0), make_number (255)); |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2371 if (XINT (byte) >= 128 |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2372 && ! NILP (current_buffer->enable_multibyte_characters)) |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2373 XSETFASTINT (byte, BYTE8_TO_CHAR (XINT (byte))); |
89217
d0650cc0038f
(Finsert_byte): Return a proper value.
Dave Love <fx@gnu.org>
parents:
89209
diff
changeset
|
2374 return Finsert_char (byte, count, inherit); |
89034
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2375 } |
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
2376 |
305 | 2377 |
648 | 2378 /* Making strings from buffer contents. */ |
2379 | |
2380 /* Return a Lisp_String containing the text of the current buffer from | |
1285
d50533e23dff
* editfns.c (make_buffer_string): Call copy_intervals_to_string().
Joseph Arceneaux <jla@gnu.org>
parents:
1254
diff
changeset
|
2381 START to END. If text properties are in use and the current buffer |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3522
diff
changeset
|
2382 has properties in the range specified, the resulting string will also |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2383 have them, if PROPS is nonzero. |
648 | 2384 |
2385 We don't want to use plain old make_string here, because it calls | |
2386 make_uninit_string, which can cause the buffer arena to be | |
2387 compacted. make_string has no way of knowing that the data has | |
2388 been moved, and thus copies the wrong data into the string. This | |
2389 doesn't effect most of the other users of make_string, so it should | |
2390 be left as is. But we should use this function when conjuring | |
2391 buffer substrings. */ | |
1285
d50533e23dff
* editfns.c (make_buffer_string): Call copy_intervals_to_string().
Joseph Arceneaux <jla@gnu.org>
parents:
1254
diff
changeset
|
2392 |
648 | 2393 Lisp_Object |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2394 make_buffer_string (start, end, props) |
648 | 2395 int start, end; |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2396 int props; |
648 | 2397 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2398 int start_byte = CHAR_TO_BYTE (start); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2399 int end_byte = CHAR_TO_BYTE (end); |
648 | 2400 |
21235
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2401 return make_buffer_string_both (start, start_byte, end, end_byte, props); |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2402 } |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2403 |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2404 /* Return a Lisp_String containing the text of the current buffer from |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2405 START / START_BYTE to END / END_BYTE. |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2406 |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2407 If text properties are in use and the current buffer |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2408 has properties in the range specified, the resulting string will also |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2409 have them, if PROPS is nonzero. |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2410 |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2411 We don't want to use plain old make_string here, because it calls |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2412 make_uninit_string, which can cause the buffer arena to be |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2413 compacted. make_string has no way of knowing that the data has |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2414 been moved, and thus copies the wrong data into the string. This |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2415 doesn't effect most of the other users of make_string, so it should |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2416 be left as is. But we should use this function when conjuring |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2417 buffer substrings. */ |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2418 |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2419 Lisp_Object |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2420 make_buffer_string_both (start, start_byte, end, end_byte, props) |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2421 int start, start_byte, end, end_byte; |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2422 int props; |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2423 { |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2424 Lisp_Object result, tem, tem1; |
eba3d61855d0
(make_buffer_string_both): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21226
diff
changeset
|
2425 |
648 | 2426 if (start < GPT && GPT < end) |
2427 move_gap (start); | |
2428 | |
21257
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
2429 if (! NILP (current_buffer->enable_multibyte_characters)) |
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
2430 result = make_uninit_multibyte_string (end - start, end_byte - start_byte); |
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
2431 else |
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
2432 result = make_uninit_string (end - start); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
2433 bcopy (BYTE_POS_ADDR (start_byte), SDATA (result), |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2434 end_byte - start_byte); |
648 | 2435 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2436 /* If desired, update and copy the text properties. */ |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2437 if (props) |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2438 { |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2439 update_buffer_properties (start, end); |
5130
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2440 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2441 tem = Fnext_property_change (make_number (start), Qnil, make_number (end)); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2442 tem1 = Ftext_properties_at (make_number (start), Qnil); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2443 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2444 if (XINT (tem) != end || !NILP (tem1)) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2445 copy_intervals_to_string (result, current_buffer, start, |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2446 end - start); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2447 } |
1285
d50533e23dff
* editfns.c (make_buffer_string): Call copy_intervals_to_string().
Joseph Arceneaux <jla@gnu.org>
parents:
1254
diff
changeset
|
2448 |
648 | 2449 return result; |
2450 } | |
305 | 2451 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2452 /* Call Vbuffer_access_fontify_functions for the range START ... END |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2453 in the current buffer, if necessary. */ |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2454 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2455 static void |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2456 update_buffer_properties (start, end) |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2457 int start, end; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2458 { |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2459 /* If this buffer has some access functions, |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2460 call them, specifying the range of the buffer being accessed. */ |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2461 if (!NILP (Vbuffer_access_fontify_functions)) |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2462 { |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2463 Lisp_Object args[3]; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2464 Lisp_Object tem; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2465 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2466 args[0] = Qbuffer_access_fontify_functions; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2467 XSETINT (args[1], start); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2468 XSETINT (args[2], end); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2469 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2470 /* But don't call them if we can tell that the work |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2471 has already been done. */ |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2472 if (!NILP (Vbuffer_access_fontified_property)) |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2473 { |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2474 tem = Ftext_property_any (args[1], args[2], |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2475 Vbuffer_access_fontified_property, |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2476 Qnil, Qnil); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2477 if (! NILP (tem)) |
14126
edc94b82c3b3
(update_buffer_properties): Delete superfluous &'s.
Karl Heuer <kwzh@gnu.org>
parents:
14071
diff
changeset
|
2478 Frun_hook_with_args (3, args); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2479 } |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2480 else |
14126
edc94b82c3b3
(update_buffer_properties): Delete superfluous &'s.
Karl Heuer <kwzh@gnu.org>
parents:
14071
diff
changeset
|
2481 Frun_hook_with_args (3, args); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2482 } |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2483 } |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2484 |
305 | 2485 DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2486 doc: /* Return the contents of part of the current buffer as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2487 The two arguments START and END are character positions; |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2488 they can be in either order. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2489 The string returned is multibyte if the buffer is multibyte. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2490 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2491 This function copies the text properties of that part of the buffer |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2492 into the result string; if you don't want the text properties, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2493 use `buffer-substring-no-properties' instead. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2494 (start, end) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2495 Lisp_Object start, end; |
305 | 2496 { |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2497 register int b, e; |
305 | 2498 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2499 validate_region (&start, &end); |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2500 b = XINT (start); |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2501 e = XINT (end); |
305 | 2502 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2503 return make_buffer_string (b, e, 1); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2504 } |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2505 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2506 DEFUN ("buffer-substring-no-properties", Fbuffer_substring_no_properties, |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2507 Sbuffer_substring_no_properties, 2, 2, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2508 doc: /* Return the characters of part of the buffer, without the text properties. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2509 The two arguments START and END are character positions; |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2510 they can be in either order. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2511 (start, end) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2512 Lisp_Object start, end; |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2513 { |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2514 register int b, e; |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2515 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2516 validate_region (&start, &end); |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2517 b = XINT (start); |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2518 e = XINT (end); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2519 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2520 return make_buffer_string (b, e, 0); |
305 | 2521 } |
2522 | |
2523 DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2524 doc: /* Return the contents of the current buffer as a string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2525 If narrowing is in effect, this function returns only the visible part |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2526 of the buffer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2527 () |
305 | 2528 { |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
2529 return make_buffer_string (BEGV, ZV, 1); |
305 | 2530 } |
2531 | |
2532 DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, | |
40981
fee88c193206
(Fuser_real_login_name): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents:
40699
diff
changeset
|
2533 1, 3, 0, |
55424
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2534 doc: /* Insert before point a substring of the contents of BUFFER. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2535 BUFFER may be a buffer or a buffer name. |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
2536 Arguments START and END are character positions specifying the substring. |
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
2537 They default to the values of (point-min) and (point-max) in BUFFER. */) |
55424
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2538 (buffer, start, end) |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2539 Lisp_Object buffer, start, end; |
305 | 2540 { |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2541 register int b, e, temp; |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2542 register struct buffer *bp, *obuf; |
55424
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2543 Lisp_Object buf; |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2544 |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2545 buf = Fget_buffer (buffer); |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2546 if (NILP (buf)) |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2547 nsberror (buffer); |
04990cada43d
(Finsert_buffer_substring): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55193
diff
changeset
|
2548 bp = XBUFFER (buf); |
16134
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2549 if (NILP (bp->name)) |
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2550 error ("Selecting deleted buffer"); |
305 | 2551 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2552 if (NILP (start)) |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2553 b = BUF_BEGV (bp); |
305 | 2554 else |
2555 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2556 CHECK_NUMBER_COERCE_MARKER (start); |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2557 b = XINT (start); |
305 | 2558 } |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2559 if (NILP (end)) |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2560 e = BUF_ZV (bp); |
305 | 2561 else |
2562 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2563 CHECK_NUMBER_COERCE_MARKER (end); |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2564 e = XINT (end); |
305 | 2565 } |
2566 | |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2567 if (b > e) |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2568 temp = b, b = e, e = temp; |
305 | 2569 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2570 if (!(BUF_BEGV (bp) <= b && e <= BUF_ZV (bp))) |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2571 args_out_of_range (start, end); |
305 | 2572 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2573 obuf = current_buffer; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2574 set_buffer_internal_1 (bp); |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2575 update_buffer_properties (b, e); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2576 set_buffer_internal_1 (obuf); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
2577 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
2578 insert_from_buffer (bp, b, e - b, 0); |
305 | 2579 return Qnil; |
2580 } | |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2581 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2582 DEFUN ("compare-buffer-substrings", Fcompare_buffer_substrings, Scompare_buffer_substrings, |
40981
fee88c193206
(Fuser_real_login_name): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents:
40699
diff
changeset
|
2583 6, 6, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2584 doc: /* Compare two substrings of two buffers; return result as number. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2585 the value is -N if first string is less after N-1 chars, |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2586 +N if first string is greater after N-1 chars, or 0 if strings match. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2587 Each substring is represented as three arguments: BUFFER, START and END. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2588 That makes six args in all, three for each substring. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2589 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2590 The value of `case-fold-search' in the current buffer |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2591 determines whether case is significant or ignored. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2592 (buffer1, start1, end1, buffer2, start2, end2) |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2593 Lisp_Object buffer1, start1, end1, buffer2, start2, end2; |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2594 { |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2595 register int begp1, endp1, begp2, endp2, temp; |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2596 register struct buffer *bp1, *bp2; |
66367
a80af18dfc7e
(Fcompare_buffer_substrings): Handle multibyte chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65763
diff
changeset
|
2597 register Lisp_Object trt |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2598 = (!NILP (current_buffer->case_fold_search) |
66379
48a5d83a7c9d
(Fcompare_buffer_substrings): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
66367
diff
changeset
|
2599 ? current_buffer->case_canon_table : Qnil); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2600 int chars = 0; |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2601 int i1, i2, i1_byte, i2_byte; |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2602 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2603 /* Find the first buffer and its substring. */ |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2604 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2605 if (NILP (buffer1)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2606 bp1 = current_buffer; |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2607 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2608 { |
1854
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2609 Lisp_Object buf1; |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2610 buf1 = Fget_buffer (buffer1); |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2611 if (NILP (buf1)) |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2612 nsberror (buffer1); |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2613 bp1 = XBUFFER (buf1); |
16134
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2614 if (NILP (bp1->name)) |
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2615 error ("Selecting deleted buffer"); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2616 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2617 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2618 if (NILP (start1)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2619 begp1 = BUF_BEGV (bp1); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2620 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2621 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2622 CHECK_NUMBER_COERCE_MARKER (start1); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2623 begp1 = XINT (start1); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2624 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2625 if (NILP (end1)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2626 endp1 = BUF_ZV (bp1); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2627 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2628 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2629 CHECK_NUMBER_COERCE_MARKER (end1); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2630 endp1 = XINT (end1); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2631 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2632 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2633 if (begp1 > endp1) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2634 temp = begp1, begp1 = endp1, endp1 = temp; |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2635 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2636 if (!(BUF_BEGV (bp1) <= begp1 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2637 && begp1 <= endp1 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2638 && endp1 <= BUF_ZV (bp1))) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2639 args_out_of_range (start1, end1); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2640 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2641 /* Likewise for second substring. */ |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2642 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2643 if (NILP (buffer2)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2644 bp2 = current_buffer; |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2645 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2646 { |
1854
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2647 Lisp_Object buf2; |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2648 buf2 = Fget_buffer (buffer2); |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2649 if (NILP (buf2)) |
5a18c36181fa
(Finsert_buffer_substring): Proper error for non-ex buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1853
diff
changeset
|
2650 nsberror (buffer2); |
15015
8f8d48ab0a53
(Fcompare_buffer_substrings): Fix dumb bug handling buffer name as second arg.
Richard M. Stallman <rms@gnu.org>
parents:
15004
diff
changeset
|
2651 bp2 = XBUFFER (buf2); |
16134
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2652 if (NILP (bp2->name)) |
7558d82368f9
(Finsert_buffer_substring): Check for deleted buffer.
Karl Heuer <kwzh@gnu.org>
parents:
16097
diff
changeset
|
2653 error ("Selecting deleted buffer"); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2654 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2655 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2656 if (NILP (start2)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2657 begp2 = BUF_BEGV (bp2); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2658 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2659 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2660 CHECK_NUMBER_COERCE_MARKER (start2); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2661 begp2 = XINT (start2); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2662 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2663 if (NILP (end2)) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2664 endp2 = BUF_ZV (bp2); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2665 else |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2666 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2667 CHECK_NUMBER_COERCE_MARKER (end2); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2668 endp2 = XINT (end2); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2669 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2670 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2671 if (begp2 > endp2) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2672 temp = begp2, begp2 = endp2, endp2 = temp; |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2673 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2674 if (!(BUF_BEGV (bp2) <= begp2 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2675 && begp2 <= endp2 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2676 && endp2 <= BUF_ZV (bp2))) |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2677 args_out_of_range (start2, end2); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2678 |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2679 i1 = begp1; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2680 i2 = begp2; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2681 i1_byte = buf_charpos_to_bytepos (bp1, i1); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2682 i2_byte = buf_charpos_to_bytepos (bp2, i2); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2683 |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2684 while (i1 < endp1 && i2 < endp2) |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2685 { |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2686 /* When we find a mismatch, we must compare the |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2687 characters, not just the bytes. */ |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2688 int c1, c2; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2689 |
42116
37b724c77b98
(Fcompare_buffer_substrings): Add QUIT to main loop.
Richard M. Stallman <rms@gnu.org>
parents:
41065
diff
changeset
|
2690 QUIT; |
37b724c77b98
(Fcompare_buffer_substrings): Add QUIT to main loop.
Richard M. Stallman <rms@gnu.org>
parents:
41065
diff
changeset
|
2691 |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2692 if (! NILP (bp1->enable_multibyte_characters)) |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2693 { |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2694 c1 = BUF_FETCH_MULTIBYTE_CHAR (bp1, i1_byte); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2695 BUF_INC_POS (bp1, i1_byte); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2696 i1++; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2697 } |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2698 else |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2699 { |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2700 c1 = BUF_FETCH_BYTE (bp1, i1); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2701 c1 = unibyte_char_to_multibyte (c1); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2702 i1++; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2703 } |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2704 |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2705 if (! NILP (bp2->enable_multibyte_characters)) |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2706 { |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2707 c2 = BUF_FETCH_MULTIBYTE_CHAR (bp2, i2_byte); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2708 BUF_INC_POS (bp2, i2_byte); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2709 i2++; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2710 } |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2711 else |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2712 { |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2713 c2 = BUF_FETCH_BYTE (bp2, i2); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2714 c2 = unibyte_char_to_multibyte (c2); |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2715 i2++; |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2716 } |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2717 |
66367
a80af18dfc7e
(Fcompare_buffer_substrings): Handle multibyte chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65763
diff
changeset
|
2718 if (!NILP (trt)) |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2719 { |
66367
a80af18dfc7e
(Fcompare_buffer_substrings): Handle multibyte chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65763
diff
changeset
|
2720 c1 = CHAR_TABLE_TRANSLATE (trt, c1); |
a80af18dfc7e
(Fcompare_buffer_substrings): Handle multibyte chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65763
diff
changeset
|
2721 c2 = CHAR_TABLE_TRANSLATE (trt, c2); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2722 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2723 if (c1 < c2) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2724 return make_number (- 1 - chars); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2725 if (c1 > c2) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2726 return make_number (chars + 1); |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2727 |
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2728 chars++; |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2729 } |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2730 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2731 /* The strings match as far as they go. |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2732 If one is shorter, that one is less. */ |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2733 if (chars < endp1 - begp1) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2734 return make_number (chars + 1); |
21837
ea78758c282e
(Fcompare_buffer_substrings): Rewrite to loop by chars.
Richard M. Stallman <rms@gnu.org>
parents:
21821
diff
changeset
|
2735 else if (chars < endp2 - begp2) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2736 return make_number (- chars - 1); |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2737 |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2738 /* Same length too => they are equal. */ |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2739 return make_number (0); |
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
2740 } |
305 | 2741 |
10480
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2742 static Lisp_Object |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2743 subst_char_in_region_unwind (arg) |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2744 Lisp_Object arg; |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2745 { |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2746 return current_buffer->undo_list = arg; |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2747 } |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2748 |
12622
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2749 static Lisp_Object |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2750 subst_char_in_region_unwind_1 (arg) |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2751 Lisp_Object arg; |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2752 { |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2753 return current_buffer->filename = arg; |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2754 } |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2755 |
305 | 2756 DEFUN ("subst-char-in-region", Fsubst_char_in_region, |
40981
fee88c193206
(Fuser_real_login_name): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents:
40699
diff
changeset
|
2757 Ssubst_char_in_region, 4, 5, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2758 doc: /* From START to END, replace FROMCHAR with TOCHAR each time it occurs. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2759 If optional arg NOUNDO is non-nil, don't record this change for undo |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
2760 and don't mark the buffer as really changed. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2761 Both characters must have the same length of multi-byte form. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
2762 (start, end, fromchar, tochar, noundo) |
305 | 2763 Lisp_Object start, end, fromchar, tochar, noundo; |
2764 { | |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2765 register int pos, pos_byte, stop, i, len, end_byte; |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2766 /* Keep track of the first change in the buffer: |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2767 if 0 we haven't found it yet. |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2768 if < 0 we've found it and we've run the before-change-function. |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2769 if > 0 we've actually performed it and the value is its position. */ |
5130
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2770 int changed = 0; |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2771 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2772 unsigned char *p; |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45398
diff
changeset
|
2773 int count = SPECPDL_INDEX (); |
25507
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2774 #define COMBINING_NO 0 |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2775 #define COMBINING_BEFORE 1 |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2776 #define COMBINING_AFTER 2 |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2777 #define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2778 int maybe_byte_combining = COMBINING_NO; |
32420
40df6727225a
(save_excursion_save): Additionally record the
Gerd Moellmann <gerd@gnu.org>
parents:
31774
diff
changeset
|
2779 int last_changed = 0; |
28358
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2780 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
305 | 2781 |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2782 restart: |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2783 |
305 | 2784 validate_region (&start, &end); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2785 CHECK_NUMBER (fromchar); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
2786 CHECK_NUMBER (tochar); |
305 | 2787 |
28358
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2788 if (multibyte_p) |
17031 | 2789 { |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2790 len = CHAR_STRING (XFASTINT (fromchar), fromstr); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2791 if (CHAR_STRING (XFASTINT (tochar), tostr) != len) |
63696
43b9742ef102
(Fsubst_char_in_region): Follow error conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
62662
diff
changeset
|
2792 error ("Characters in `subst-char-in-region' have different byte-lengths"); |
25507
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2793 if (!ASCII_BYTE_P (*tostr)) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2794 { |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2795 /* If *TOSTR is in the range 0x80..0x9F and TOCHAR is not a |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2796 complete multibyte character, it may be combined with the |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2797 after bytes. If it is in the range 0xA0..0xFF, it may be |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2798 combined with the before and after bytes. */ |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2799 if (!CHAR_HEAD_P (*tostr)) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2800 maybe_byte_combining = COMBINING_BOTH; |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2801 else if (BYTES_BY_CHAR_HEAD (*tostr) > len) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2802 maybe_byte_combining = COMBINING_AFTER; |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2803 } |
17031 | 2804 } |
2805 else | |
2806 { | |
2807 len = 1; | |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2808 fromstr[0] = XFASTINT (fromchar); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2809 tostr[0] = XFASTINT (tochar); |
17031 | 2810 } |
2811 | |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2812 pos = XINT (start); |
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2813 pos_byte = CHAR_TO_BYTE (pos); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2814 stop = CHAR_TO_BYTE (XINT (end)); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2815 end_byte = stop; |
305 | 2816 |
10480
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2817 /* If we don't want undo, turn off putting stuff on the list. |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2818 That's faster than getting rid of things, |
12622
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2819 and it prevents even the entry for a first change. |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2820 Also inhibit locking the file. */ |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2821 if (!changed && !NILP (noundo)) |
10480
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2822 { |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2823 record_unwind_protect (subst_char_in_region_unwind, |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2824 current_buffer->undo_list); |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2825 current_buffer->undo_list = Qt; |
12622
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2826 /* Don't do file-locking. */ |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2827 record_unwind_protect (subst_char_in_region_unwind_1, |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2828 current_buffer->filename); |
205232bb7efe
(Fsubst_char_in_region): Bind buffer-file-name to nil if NOUNDO is true.
Richard M. Stallman <rms@gnu.org>
parents:
12603
diff
changeset
|
2829 current_buffer->filename = Qnil; |
10480
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2830 } |
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2831 |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2832 if (pos_byte < GPT_BYTE) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2833 stop = min (stop, GPT_BYTE); |
17031 | 2834 while (1) |
305 | 2835 { |
23554
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2836 int pos_byte_next = pos_byte; |
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2837 |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2838 if (pos_byte >= stop) |
17031 | 2839 { |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2840 if (pos_byte >= end_byte) break; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
2841 stop = end_byte; |
17031 | 2842 } |
20834
95a80c1e06c3
(Fsubst_char_in_region): Handle character-base
Kenichi Handa <handa@m17n.org>
parents:
20826
diff
changeset
|
2843 p = BYTE_POS_ADDR (pos_byte); |
28358
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2844 if (multibyte_p) |
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2845 INC_POS (pos_byte_next); |
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2846 else |
7ae3851c0a19
(Fsubst_char_in_region): Don't use INC_POS in unibyte
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2847 ++pos_byte_next; |
23554
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2848 if (pos_byte_next - pos_byte == len |
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2849 && p[0] == fromstr[0] |
17031 | 2850 && (len == 1 |
2851 || (p[1] == fromstr[1] | |
2852 && (len == 2 || (p[2] == fromstr[2] | |
2853 && (len == 3 || p[3] == fromstr[3])))))) | |
305 | 2854 { |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2855 if (changed < 0) |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2856 /* We've already seen this and run the before-change-function; |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2857 this time we only need to record the actual position. */ |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2858 changed = pos; |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2859 else if (!changed) |
5130
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2860 { |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2861 changed = -1; |
72592
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
2862 modify_region (current_buffer, pos, XINT (end), 0); |
5242
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2863 |
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2864 if (! NILP (noundo)) |
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2865 { |
10308
90784ed0416f
Use SAVE_MODIFF and BUF_SAVE_MODIFF
Richard M. Stallman <rms@gnu.org>
parents:
9812
diff
changeset
|
2866 if (MODIFF - 1 == SAVE_MODIFF) |
90784ed0416f
Use SAVE_MODIFF and BUF_SAVE_MODIFF
Richard M. Stallman <rms@gnu.org>
parents:
9812
diff
changeset
|
2867 SAVE_MODIFF++; |
5242
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2868 if (MODIFF - 1 == current_buffer->auto_save_modified) |
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2869 current_buffer->auto_save_modified++; |
0e99ea9941e2
(Fmessage): Use message2.
Richard M. Stallman <rms@gnu.org>
parents:
5130
diff
changeset
|
2870 } |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2871 |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2872 /* The before-change-function may have moved the gap |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2873 or even modified the buffer so we should start over. */ |
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2874 goto restart; |
5130
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2875 } |
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2876 |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2877 /* Take care of the case where the new character |
30480 | 2878 combines with neighboring bytes. */ |
23554
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2879 if (maybe_byte_combining |
25507
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2880 && (maybe_byte_combining == COMBINING_AFTER |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2881 ? (pos_byte_next < Z_BYTE |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2882 && ! CHAR_HEAD_P (FETCH_BYTE (pos_byte_next))) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2883 : ((pos_byte_next < Z_BYTE |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2884 && ! CHAR_HEAD_P (FETCH_BYTE (pos_byte_next))) |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2885 || (pos_byte > BEG_BYTE |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2886 && ! ASCII_BYTE_P (FETCH_BYTE (pos_byte - 1)))))) |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2887 { |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2888 Lisp_Object tem, string; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2889 |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2890 struct gcpro gcpro1; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2891 |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2892 tem = current_buffer->undo_list; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2893 GCPRO1 (tem); |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2894 |
25507
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2895 /* Make a multibyte string containing this single character. */ |
b9b4581adf36
(Fsubst_char_in_region): Adjust the way to check byte-combining
Kenichi Handa <handa@m17n.org>
parents:
25346
diff
changeset
|
2896 string = make_multibyte_string (tostr, 1, len); |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2897 /* replace_range is less efficient, because it moves the gap, |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2898 but it handles combining correctly. */ |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2899 replace_range (pos, pos + 1, string, |
23211
d7bd20e02b1d
(Fsubst_char_in_region): Call replace_range with the
Kenichi Handa <handa@m17n.org>
parents:
23198
diff
changeset
|
2900 0, 0, 1); |
23554
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2901 pos_byte_next = CHAR_TO_BYTE (pos); |
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2902 if (pos_byte_next > pos_byte) |
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2903 /* Before combining happened. We should not increment |
23565
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2904 POS. So, to cancel the later increment of POS, |
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2905 decrease it now. */ |
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2906 pos--; |
23554
e06e84c477fa
(Fsubst_char_in_region): Correctly handle the case
Kenichi Handa <handa@m17n.org>
parents:
23553
diff
changeset
|
2907 else |
23565
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2908 INC_POS (pos_byte_next); |
30480 | 2909 |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2910 if (! NILP (noundo)) |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2911 current_buffer->undo_list = tem; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2912 |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2913 UNGCPRO; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2914 } |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2915 else |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2916 { |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2917 if (NILP (noundo)) |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2918 record_change (pos, 1); |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2919 for (i = 0; i < len; i++) *p++ = tostr[i]; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
2920 } |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2921 last_changed = pos + 1; |
305 | 2922 } |
23565
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2923 pos_byte = pos_byte_next; |
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
2924 pos++; |
305 | 2925 } |
2926 | |
72272
f3b2e3e20e3b
(Fsubst_char_in_region): Redo the setup work after running
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72194
diff
changeset
|
2927 if (changed > 0) |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2928 { |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2929 signal_after_change (changed, |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2930 last_changed - changed, last_changed - changed); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2931 update_compositions (changed, last_changed, CHECK_ALL); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
2932 } |
5130
ddee29e260d2
(make_buffer_string): Don't copy intervals
Richard M. Stallman <rms@gnu.org>
parents:
4943
diff
changeset
|
2933 |
10480
fbb254882b9f
(subst_char_in_region_unwind): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10383
diff
changeset
|
2934 unbind_to (count, Qnil); |
305 | 2935 return Qnil; |
2936 } | |
2937 | |
89878 | 2938 |
2939 static Lisp_Object check_translation P_ ((int, int, int, Lisp_Object)); | |
2940 | |
2941 /* Helper function for Ftranslate_region_internal. | |
2942 | |
2943 Check if a character sequence at POS (POS_BYTE) matches an element | |
2944 of VAL. VAL is a list (([FROM-CHAR ...] . TO) ...). If a matching | |
2945 element is found, return it. Otherwise return Qnil. */ | |
2946 | |
2947 static Lisp_Object | |
2948 check_translation (pos, pos_byte, end, val) | |
2949 int pos, pos_byte, end; | |
2950 Lisp_Object val; | |
2951 { | |
2952 int buf_size = 16, buf_used = 0; | |
2953 int *buf = alloca (sizeof (int) * buf_size); | |
2954 | |
2955 for (; CONSP (val); val = XCDR (val)) | |
2956 { | |
2957 Lisp_Object elt; | |
2958 int len, i; | |
2959 | |
2960 elt = XCAR (val); | |
2961 if (! CONSP (elt)) | |
2962 continue; | |
2963 elt = XCAR (elt); | |
2964 if (! VECTORP (elt)) | |
2965 continue; | |
2966 len = ASIZE (elt); | |
2967 if (len <= end - pos) | |
2968 { | |
2969 for (i = 0; i < len; i++) | |
2970 { | |
2971 if (buf_used <= i) | |
2972 { | |
2973 unsigned char *p = BYTE_POS_ADDR (pos_byte); | |
2974 int len; | |
2975 | |
2976 if (buf_used == buf_size) | |
2977 { | |
2978 int *newbuf; | |
2979 | |
2980 buf_size += 16; | |
2981 newbuf = alloca (sizeof (int) * buf_size); | |
2982 memcpy (newbuf, buf, sizeof (int) * buf_used); | |
2983 buf = newbuf; | |
2984 } | |
2985 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, 0, len); | |
2986 pos_byte += len; | |
2987 } | |
2988 if (XINT (AREF (elt, i)) != buf[i]) | |
2989 break; | |
2990 } | |
2991 if (i == len) | |
2992 return XCAR (val); | |
2993 } | |
2994 } | |
2995 return Qnil; | |
2996 } | |
2997 | |
2998 | |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
2999 DEFUN ("translate-region-internal", Ftranslate_region_internal, |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3000 Stranslate_region_internal, 3, 3, 0, |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3001 doc: /* Internal use only. |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3002 From START to END, translate characters according to TABLE. |
89878 | 3003 TABLE is a string or a char-table; the Nth character in it is the |
3004 mapping for the character with code N. | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3005 It returns the number of characters changed. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3006 (start, end, table) |
305 | 3007 Lisp_Object start; |
3008 Lisp_Object end; | |
3009 register Lisp_Object table; | |
3010 { | |
3011 register unsigned char *tt; /* Trans table. */ | |
3012 register int nc; /* New character. */ | |
3013 int cnt; /* Number of changes made. */ | |
3014 int size; /* Size of translate table. */ | |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3015 int pos, pos_byte, end_pos; |
26415
bda6a3a2bf96
(Ftranslate_region): Check the buffer multibyteness.
Kenichi Handa <handa@m17n.org>
parents:
26389
diff
changeset
|
3016 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3017 int string_multibyte; |
89840
c49eea8699c8
(Ftranslate_region_internal): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
89601
diff
changeset
|
3018 Lisp_Object val; |
305 | 3019 |
3020 validate_region (&start, &end); | |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3021 if (CHAR_TABLE_P (table)) |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3022 { |
89878 | 3023 if (! EQ (XCHAR_TABLE (table)->purpose, Qtranslation_table)) |
3024 error ("Not a translation table"); | |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3025 size = MAX_CHAR; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3026 tt = NULL; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3027 } |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3028 else |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3029 { |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3030 CHECK_STRING (table); |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3031 |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3032 if (! multibyte && (SCHARS (table) < SBYTES (table))) |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3033 table = string_make_unibyte (table); |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3034 string_multibyte = SCHARS (table) < SBYTES (table); |
89840
c49eea8699c8
(Ftranslate_region_internal): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
89601
diff
changeset
|
3035 size = SBYTES (table); |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3036 tt = SDATA (table); |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3037 } |
305 | 3038 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3039 pos = XINT (start); |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3040 pos_byte = CHAR_TO_BYTE (pos); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3041 end_pos = XINT (end); |
90599 | 3042 modify_region (current_buffer, pos, end_pos, 0); |
305 | 3043 |
3044 cnt = 0; | |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3045 for (; pos < end_pos; ) |
305 | 3046 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3047 register unsigned char *p = BYTE_POS_ADDR (pos_byte); |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3048 unsigned char *str, buf[MAX_MULTIBYTE_LENGTH]; |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3049 int len, str_len; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3050 int oc; |
89878 | 3051 Lisp_Object val; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3052 |
26415
bda6a3a2bf96
(Ftranslate_region): Check the buffer multibyteness.
Kenichi Handa <handa@m17n.org>
parents:
26389
diff
changeset
|
3053 if (multibyte) |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3054 oc = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, len); |
26415
bda6a3a2bf96
(Ftranslate_region): Check the buffer multibyteness.
Kenichi Handa <handa@m17n.org>
parents:
26389
diff
changeset
|
3055 else |
bda6a3a2bf96
(Ftranslate_region): Check the buffer multibyteness.
Kenichi Handa <handa@m17n.org>
parents:
26389
diff
changeset
|
3056 oc = *p, len = 1; |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3057 if (oc < size) |
305 | 3058 { |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3059 if (tt) |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3060 { |
65455
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3061 /* Reload as signal_after_change in last iteration may GC. */ |
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3062 tt = SDATA (table); |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3063 if (string_multibyte) |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3064 { |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3065 str = tt + string_char_to_byte (table, oc); |
93921
f7d6d03d8ceb
(Ffield_string_no_properties): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
93038
diff
changeset
|
3066 nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH, |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3067 str_len); |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3068 } |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3069 else |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3070 { |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3071 nc = tt[oc]; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3072 if (! ASCII_BYTE_P (nc) && multibyte) |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3073 { |
90050
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3074 str_len = BYTE8_STRING (nc, buf); |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3075 str = buf; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3076 } |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3077 else |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3078 { |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3079 str_len = 1; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3080 str = tt + oc; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3081 } |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3082 } |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3083 } |
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3084 else |
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3085 { |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3086 int c; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3087 |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3088 nc = oc; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3089 val = CHAR_TABLE_REF (table, oc); |
90050
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3090 if (CHARACTERP (val) |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3091 && (c = XINT (val), CHAR_VALID_P (c, 0))) |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3092 { |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3093 nc = c; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3094 str_len = CHAR_STRING (nc, buf); |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3095 str = buf; |
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3096 } |
90050
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3097 else if (VECTORP (val) || (CONSP (val))) |
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3098 { |
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3099 /* VAL is [TO_CHAR ...] or (([FROM-CHAR ...] . TO) ...) |
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3100 where TO is TO-CHAR or [TO-CHAR ...]. */ |
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3101 nc = -1; |
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3102 } |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3103 } |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
3104 |
90050
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3105 if (nc != oc && nc >= 0) |
305 | 3106 { |
89878 | 3107 /* Simple one char to one char translation. */ |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3108 if (len != str_len) |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3109 { |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3110 Lisp_Object string; |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3111 |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3112 /* This is less efficient, because it moves the gap, |
89878 | 3113 but it should handle multibyte characters correctly. */ |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3114 string = make_multibyte_string (str, 1, str_len); |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3115 replace_range (pos, pos + 1, string, 1, 0, 1); |
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3116 len = str_len; |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3117 } |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3118 else |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3119 { |
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3120 record_change (pos, 1); |
54213
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3121 while (str_len-- > 0) |
29d4d158e5eb
(Ftranslate_region): Handle multibyte chars in the arg
Kenichi Handa <handa@m17n.org>
parents:
53819
diff
changeset
|
3122 *p++ = *str++; |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3123 signal_after_change (pos, 1, 1); |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
3124 update_compositions (pos, pos + 1, CHECK_BORDER); |
22895
9f800ebc6091
(Fsubst_char_in_region): Use replace_range in the case
Richard M. Stallman <rms@gnu.org>
parents:
22712
diff
changeset
|
3125 } |
305 | 3126 ++cnt; |
3127 } | |
90050
1df66cb75f66
(Ftranslate_region_internal): Don't convert unibyte
Kenichi Handa <handa@m17n.org>
parents:
90044
diff
changeset
|
3128 else if (nc < 0) |
89840
c49eea8699c8
(Ftranslate_region_internal): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
89601
diff
changeset
|
3129 { |
89878 | 3130 Lisp_Object string; |
3131 | |
3132 if (CONSP (val)) | |
3133 { | |
3134 val = check_translation (pos, pos_byte, end_pos, val); | |
3135 if (NILP (val)) | |
3136 { | |
3137 pos_byte += len; | |
3138 pos++; | |
3139 continue; | |
3140 } | |
3141 /* VAL is ([FROM-CHAR ...] . TO). */ | |
3142 len = ASIZE (XCAR (val)); | |
3143 val = XCDR (val); | |
3144 } | |
3145 else | |
3146 len = 1; | |
3147 | |
3148 if (VECTORP (val)) | |
3149 { | |
3150 int i; | |
3151 | |
3152 string = Fmake_string (make_number (ASIZE (val)), | |
3153 AREF (val, 0)); | |
3154 for (i = 1; i < ASIZE (val); i++) | |
3155 Faset (string, make_number (i), AREF (val, i)); | |
3156 } | |
3157 else | |
3158 { | |
3159 string = Fmake_string (make_number (1), val); | |
3160 } | |
3161 replace_range (pos, pos + len, string, 1, 0, 1); | |
3162 pos_byte += SBYTES (string); | |
3163 pos += SCHARS (string); | |
3164 cnt += SCHARS (string); | |
3165 end_pos += SCHARS (string) - len; | |
3166 continue; | |
89840
c49eea8699c8
(Ftranslate_region_internal): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
89601
diff
changeset
|
3167 } |
305 | 3168 } |
54214
a2f5ab3b6d1b
(Ftranslate_region): Fix previous change
Kenichi Handa <handa@m17n.org>
parents:
54213
diff
changeset
|
3169 pos_byte += len; |
23565
077655e1e014
(Fsubst_char_in_region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
23554
diff
changeset
|
3170 pos++; |
305 | 3171 } |
3172 | |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3173 return make_number (cnt); |
305 | 3174 } |
3175 | |
3176 DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 2, "r", | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3177 doc: /* Delete the text between point and mark. |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
3178 |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3179 When called from a program, expects two arguments, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3180 positions (integers or markers) specifying the stretch to be deleted. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3181 (start, end) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3182 Lisp_Object start, end; |
305 | 3183 { |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3184 validate_region (&start, &end); |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3185 del_range (XINT (start), XINT (end)); |
305 | 3186 return Qnil; |
3187 } | |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3188 |
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3189 DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, |
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3190 Sdelete_and_extract_region, 2, 2, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3191 doc: /* Delete the text between START and END and return it. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3192 (start, end) |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3193 Lisp_Object start, end; |
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3194 { |
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3195 validate_region (&start, &end); |
57606
6a526f57129e
(Fdelete_and_extract_region): If region is empty, return null string.
Richard M. Stallman <rms@gnu.org>
parents:
57076
diff
changeset
|
3196 if (XINT (start) == XINT (end)) |
81286
6194f2677500
(Fdelete_and_extract_region): Use empty_unibyte_string.
Juanma Barranquero <lekktu@gmail.com>
parents:
81259
diff
changeset
|
3197 return empty_unibyte_string; |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3198 return del_range_1 (XINT (start), XINT (end), 1, 1); |
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
3199 } |
305 | 3200 |
3201 DEFUN ("widen", Fwiden, Swiden, 0, 0, "", | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3202 doc: /* Remove restrictions (narrowing) from current buffer. |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3203 This allows the buffer's full text to be seen and edited. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3204 () |
305 | 3205 { |
19207
be370e94fb42
(Fwiden, Fnarrow_to_region, save_restriction_restore):
Richard M. Stallman <rms@gnu.org>
parents:
19032
diff
changeset
|
3206 if (BEG != BEGV || Z != ZV) |
be370e94fb42
(Fwiden, Fnarrow_to_region, save_restriction_restore):
Richard M. Stallman <rms@gnu.org>
parents:
19032
diff
changeset
|
3207 current_buffer->clip_changed = 1; |
305 | 3208 BEGV = BEG; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3209 BEGV_BYTE = BEG_BYTE; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3210 SET_BUF_ZV_BOTH (current_buffer, Z, Z_BYTE); |
330 | 3211 /* Changing the buffer bounds invalidates any recorded current column. */ |
3212 invalidate_current_column (); | |
305 | 3213 return Qnil; |
3214 } | |
3215 | |
3216 DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 2, "r", | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3217 doc: /* Restrict editing in this buffer to the current region. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3218 The rest of the text becomes temporarily invisible and untouchable |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3219 but is not deleted; if you save the buffer in a file, the invisible |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3220 text is included in the file. \\[widen] makes all visible again. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3221 See also `save-restriction'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3222 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3223 When calling from a program, pass two arguments; positions (integers |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3224 or markers) bounding the text that should remain visible. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3225 (start, end) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3226 register Lisp_Object start, end; |
305 | 3227 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
3228 CHECK_NUMBER_COERCE_MARKER (start); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
3229 CHECK_NUMBER_COERCE_MARKER (end); |
305 | 3230 |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3231 if (XINT (start) > XINT (end)) |
305 | 3232 { |
10383
a7fe0fb11314
(Fnarrow_to_region): Swap using temp Lisp_Object, not int.
Karl Heuer <kwzh@gnu.org>
parents:
10382
diff
changeset
|
3233 Lisp_Object tem; |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3234 tem = start; start = end; end = tem; |
305 | 3235 } |
3236 | |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3237 if (!(BEG <= XINT (start) && XINT (start) <= XINT (end) && XINT (end) <= Z)) |
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3238 args_out_of_range (start, end); |
305 | 3239 |
19207
be370e94fb42
(Fwiden, Fnarrow_to_region, save_restriction_restore):
Richard M. Stallman <rms@gnu.org>
parents:
19032
diff
changeset
|
3240 if (BEGV != XFASTINT (start) || ZV != XFASTINT (end)) |
be370e94fb42
(Fwiden, Fnarrow_to_region, save_restriction_restore):
Richard M. Stallman <rms@gnu.org>
parents:
19032
diff
changeset
|
3241 current_buffer->clip_changed = 1; |
be370e94fb42
(Fwiden, Fnarrow_to_region, save_restriction_restore):
Richard M. Stallman <rms@gnu.org>
parents:
19032
diff
changeset
|
3242 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
3243 SET_BUF_BEGV (current_buffer, XFASTINT (start)); |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3244 SET_BUF_ZV (current_buffer, XFASTINT (end)); |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
3245 if (PT < XFASTINT (start)) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3246 SET_PT (XFASTINT (start)); |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15910
diff
changeset
|
3247 if (PT > XFASTINT (end)) |
14071
59906ecd9b92
(Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, Finsert_char,
Erik Naggum <erik@naggum.no>
parents:
13878
diff
changeset
|
3248 SET_PT (XFASTINT (end)); |
330 | 3249 /* Changing the buffer bounds invalidates any recorded current column. */ |
3250 invalidate_current_column (); | |
305 | 3251 return Qnil; |
3252 } | |
3253 | |
3254 Lisp_Object | |
3255 save_restriction_save () | |
3256 { | |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3257 if (BEGV == BEG && ZV == Z) |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3258 /* The common case that the buffer isn't narrowed. |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3259 We return just the buffer object, which save_restriction_restore |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3260 recognizes as meaning `no restriction'. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3261 return Fcurrent_buffer (); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3262 else |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3263 /* We have to save a restriction, so return a pair of markers, one |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3264 for the beginning and one for the end. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3265 { |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3266 Lisp_Object beg, end; |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3267 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3268 beg = buildmark (BEGV, BEGV_BYTE); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3269 end = buildmark (ZV, ZV_BYTE); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3270 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3271 /* END must move forward if text is inserted at its exact location. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3272 XMARKER(end)->insertion_type = 1; |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3273 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3274 return Fcons (beg, end); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3275 } |
305 | 3276 } |
3277 | |
3278 Lisp_Object | |
3279 save_restriction_restore (data) | |
3280 Lisp_Object data; | |
3281 { | |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3282 if (CONSP (data)) |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3283 /* A pair of marks bounding a saved restriction. */ |
305 | 3284 { |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3285 struct Lisp_Marker *beg = XMARKER (XCAR (data)); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3286 struct Lisp_Marker *end = XMARKER (XCDR (data)); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3287 struct buffer *buf = beg->buffer; /* END should have the same buffer. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3288 |
46921
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3289 if (buf /* Verify marker still points to a buffer. */ |
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3290 && (beg->charpos != BUF_BEGV (buf) || end->charpos != BUF_ZV (buf))) |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3291 /* The restriction has changed from the saved one, so restore |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3292 the saved restriction. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3293 { |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3294 int pt = BUF_PT (buf); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3295 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3296 SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3297 SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3298 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3299 if (pt < beg->charpos || pt > end->charpos) |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3300 /* The point is outside the new visible range, move it inside. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3301 SET_BUF_PT_BOTH (buf, |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3302 clip_to_bounds (beg->charpos, pt, end->charpos), |
46921
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3303 clip_to_bounds (beg->bytepos, BUF_PT_BYTE (buf), |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3304 end->bytepos)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49472
diff
changeset
|
3305 |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3306 buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3307 } |
305 | 3308 } |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3309 else |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3310 /* A buffer, which means that there was no old restriction. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3311 { |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3312 struct buffer *buf = XBUFFER (data); |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3313 |
46921
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3314 if (buf /* Verify marker still points to a buffer. */ |
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3315 && (BUF_BEGV (buf) != BUF_BEG (buf) || BUF_ZV (buf) != BUF_Z (buf))) |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3316 /* The buffer has been narrowed, get rid of the narrowing. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3317 { |
46921
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3318 SET_BUF_BEGV_BOTH (buf, BUF_BEG (buf), BUF_BEG_BYTE (buf)); |
40c8bb63c063
(save_restriction_restore): Defend from unchained marker.
Richard M. Stallman <rms@gnu.org>
parents:
46639
diff
changeset
|
3319 SET_BUF_ZV_BOTH (buf, BUF_Z (buf), BUF_Z_BYTE (buf)); |
30931
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3320 |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3321 buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3322 } |
35428eaf59e3
(save_restriction_save): Rewrite to use markers.
Miles Bader <miles@gnu.org>
parents:
30677
diff
changeset
|
3323 } |
305 | 3324 |
3325 return Qnil; | |
3326 } | |
3327 | |
3328 DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3329 doc: /* Execute BODY, saving and restoring current buffer's restrictions. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3330 The buffer's restrictions make parts of the beginning and end invisible. |
75387
41b2aae64f85
(Finsert_char): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75217
diff
changeset
|
3331 \(They are set up with `narrow-to-region' and eliminated with `widen'.) |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3332 This special form, `save-restriction', saves the current buffer's restrictions |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3333 when it is entered, and restores them when it is exited. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3334 So any `narrow-to-region' within BODY lasts only until the end of the form. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3335 The old restrictions settings are restored |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3336 even in case of abnormal exit (throw or error). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3337 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3338 The value returned is the value of the last form in BODY. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3339 |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3340 Note: if you are using both `save-excursion' and `save-restriction', |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3341 use `save-excursion' outermost: |
40140
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
3342 (save-excursion (save-restriction ...)) |
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
3343 |
9bf80d5fff41
(Fsave_excursion, Fsave_current_buffer)
Miles Bader <miles@gnu.org>
parents:
40131
diff
changeset
|
3344 usage: (save-restriction &rest BODY) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3345 (body) |
305 | 3346 Lisp_Object body; |
3347 { | |
3348 register Lisp_Object val; | |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45398
diff
changeset
|
3349 int count = SPECPDL_INDEX (); |
305 | 3350 |
3351 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
3352 val = Fprogn (body); | |
3353 return unbind_to (count, val); | |
3354 } | |
3355 | |
38059
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3356 /* Buffer for the most recent text displayed by Fmessage_box. */ |
5884
d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Karl Heuer <kwzh@gnu.org>
parents:
5882
diff
changeset
|
3357 static char *message_text; |
d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Karl Heuer <kwzh@gnu.org>
parents:
5882
diff
changeset
|
3358 |
d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Karl Heuer <kwzh@gnu.org>
parents:
5882
diff
changeset
|
3359 /* Allocated length of that buffer. */ |
d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Karl Heuer <kwzh@gnu.org>
parents:
5882
diff
changeset
|
3360 static int message_length; |
d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Karl Heuer <kwzh@gnu.org>
parents:
5882
diff
changeset
|
3361 |
305 | 3362 DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, |
73950
5229e2ae0b0e
(Fmessage): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
72801
diff
changeset
|
3363 doc: /* Display a message at the bottom of the screen. |
57736 | 3364 The message also goes into the `*Messages*' buffer. |
3365 \(In keyboard macros, that's all it does.) | |
73950
5229e2ae0b0e
(Fmessage): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
72801
diff
changeset
|
3366 Return the message. |
57736 | 3367 |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3368 The first argument is a format control string, and the rest are data |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3369 to be formatted under control of the string. See `format' for details. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3370 |
72801
861a71881b6a
(Fmessage): Recommend using (message "%s" ...).
Kim F. Storm <storm@cua.dk>
parents:
72751
diff
changeset
|
3371 Note: Use (message "%s" VALUE) to print the value of expressions and |
861a71881b6a
(Fmessage): Recommend using (message "%s" ...).
Kim F. Storm <storm@cua.dk>
parents:
72751
diff
changeset
|
3372 variables to avoid accidentally interpreting `%' as format specifiers. |
861a71881b6a
(Fmessage): Recommend using (message "%s" ...).
Kim F. Storm <storm@cua.dk>
parents:
72751
diff
changeset
|
3373 |
65455
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3374 If the first argument is nil or the empty string, the function clears |
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3375 any existing message; this lets the minibuffer contents show. See |
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3376 also `current-message'. |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3377 |
65739
83ce839858fb
(Fmessage, Fmessage_box, Fmessage_or_box):
Juri Linkov <juri@jurta.org>
parents:
65659
diff
changeset
|
3378 usage: (message FORMAT-STRING &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3379 (nargs, args) |
305 | 3380 int nargs; |
3381 Lisp_Object *args; | |
3382 { | |
46639
8587dd21917c
(Fmessage): Treat "" like nil.
Richard M. Stallman <rms@gnu.org>
parents:
46464
diff
changeset
|
3383 if (NILP (args[0]) |
8587dd21917c
(Fmessage): Treat "" like nil.
Richard M. Stallman <rms@gnu.org>
parents:
46464
diff
changeset
|
3384 || (STRINGP (args[0]) |
8587dd21917c
(Fmessage): Treat "" like nil.
Richard M. Stallman <rms@gnu.org>
parents:
46464
diff
changeset
|
3385 && SBYTES (args[0]) == 0)) |
1916
e21c1f3e37cb
* editfns.c (Fmessage): Don't forget to return a value when
Jim Blandy <jimb@redhat.com>
parents:
1854
diff
changeset
|
3386 { |
e21c1f3e37cb
* editfns.c (Fmessage): Don't forget to return a value when
Jim Blandy <jimb@redhat.com>
parents:
1854
diff
changeset
|
3387 message (0); |
59662
c140948a6044
(Fmessage): If arg is "", return "" (as before).
Richard M. Stallman <rms@gnu.org>
parents:
59658
diff
changeset
|
3388 return args[0]; |
1916
e21c1f3e37cb
* editfns.c (Fmessage): Don't forget to return a value when
Jim Blandy <jimb@redhat.com>
parents:
1854
diff
changeset
|
3389 } |
1426
67fd35416ba3
* * editfns.c (Fmessage): With no arguments, clear any active
Jim Blandy <jimb@redhat.com>
parents:
1285
diff
changeset
|
3390 else |
67fd35416ba3
* * editfns.c (Fmessage): With no arguments, clear any active
Jim Blandy <jimb@redhat.com>
parents:
1285
diff
changeset
|
3391 { |
67fd35416ba3
* * editfns.c (Fmessage): With no arguments, clear any active
Jim Blandy <jimb@redhat.com>
parents:
1285
diff
changeset
|
3392 register Lisp_Object val; |
48115
72f8d789f551
(Fmessage): Revert last change to properly handle %% format.
Andreas Schwab <schwab@suse.de>
parents:
48111
diff
changeset
|
3393 val = Fformat (nargs, args); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3394 message3 (val, SBYTES (val), STRING_MULTIBYTE (val)); |
1426
67fd35416ba3
* * editfns.c (Fmessage): With no arguments, clear any active
Jim Blandy <jimb@redhat.com>
parents:
1285
diff
changeset
|
3395 return val; |
67fd35416ba3
* * editfns.c (Fmessage): With no arguments, clear any active
Jim Blandy <jimb@redhat.com>
parents:
1285
diff
changeset
|
3396 } |
305 | 3397 } |
3398 | |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3399 DEFUN ("message-box", Fmessage_box, Smessage_box, 1, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3400 doc: /* Display a message, in a dialog box if possible. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3401 If a dialog box is not available, use the echo area. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3402 The first argument is a format control string, and the rest are data |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3403 to be formatted under control of the string. See `format' for details. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3404 |
65455
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3405 If the first argument is nil or the empty string, clear any existing |
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3406 message; let the minibuffer contents show. |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3407 |
65739
83ce839858fb
(Fmessage, Fmessage_box, Fmessage_or_box):
Juri Linkov <juri@jurta.org>
parents:
65659
diff
changeset
|
3408 usage: (message-box FORMAT-STRING &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3409 (nargs, args) |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3410 int nargs; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3411 Lisp_Object *args; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3412 { |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3413 if (NILP (args[0])) |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3414 { |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3415 message (0); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3416 return Qnil; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3417 } |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3418 else |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3419 { |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3420 register Lisp_Object val; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3421 val = Fformat (nargs, args); |
13878
2a71500dfb93
(Fmessage_box, Fmessage_or_box):
Richard M. Stallman <rms@gnu.org>
parents:
13767
diff
changeset
|
3422 #ifdef HAVE_MENUS |
38059
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3423 /* The MS-DOS frames support popup menus even though they are |
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3424 not FRAME_WINDOW_P. */ |
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3425 if (FRAME_WINDOW_P (XFRAME (selected_frame)) |
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3426 || FRAME_MSDOS_P (XFRAME (selected_frame))) |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3427 { |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3428 Lisp_Object pane, menu, obj; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3429 struct gcpro gcpro1; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3430 pane = Fcons (Fcons (build_string ("OK"), Qt), Qnil); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3431 GCPRO1 (pane); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3432 menu = Fcons (val, pane); |
62662
9733e98a93e4
(Fmessage_box): Use "Information" for frame title.
Nick Roberts <nickrob@snap.net.nz>
parents:
61700
diff
changeset
|
3433 obj = Fx_popup_dialog (Qt, menu, Qt); |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3434 UNGCPRO; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3435 return val; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3436 } |
38059
0b34b024286d
(Fmessage_box): If the frame is not under a window
Eli Zaretskii <eliz@gnu.org>
parents:
37916
diff
changeset
|
3437 #endif /* HAVE_MENUS */ |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3438 /* Copy the data so that it won't move when we GC. */ |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3439 if (! message_text) |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3440 { |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3441 message_text = (char *)xmalloc (80); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3442 message_length = 80; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3443 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3444 if (SBYTES (val) > message_length) |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3445 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3446 message_length = SBYTES (val); |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3447 message_text = (char *)xrealloc (message_text, message_length); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3448 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3449 bcopy (SDATA (val), message_text, SBYTES (val)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3450 message2 (message_text, SBYTES (val), |
21358
e9f7d8708bae
(Fmessage_box): Pass the missing third argument
Richard M. Stallman <rms@gnu.org>
parents:
21257
diff
changeset
|
3451 STRING_MULTIBYTE (val)); |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3452 return val; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3453 } |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3454 } |
13878
2a71500dfb93
(Fmessage_box, Fmessage_or_box):
Richard M. Stallman <rms@gnu.org>
parents:
13767
diff
changeset
|
3455 #ifdef HAVE_MENUS |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3456 extern Lisp_Object last_nonmenu_event; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3457 #endif |
13878
2a71500dfb93
(Fmessage_box, Fmessage_or_box):
Richard M. Stallman <rms@gnu.org>
parents:
13767
diff
changeset
|
3458 |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3459 DEFUN ("message-or-box", Fmessage_or_box, Smessage_or_box, 1, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3460 doc: /* Display a message in a dialog box or in the echo area. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3461 If this command was invoked with the mouse, use a dialog box if |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3462 `use-dialog-box' is non-nil. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3463 Otherwise, use the echo area. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3464 The first argument is a format control string, and the rest are data |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3465 to be formatted under control of the string. See `format' for details. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3466 |
65455
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3467 If the first argument is nil or the empty string, clear any existing |
51d3a3f03a8a
(Ftranslate_region_internal): Reload `tt' after
Kim F. Storm <storm@cua.dk>
parents:
65324
diff
changeset
|
3468 message; let the minibuffer contents show. |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3469 |
65739
83ce839858fb
(Fmessage, Fmessage_box, Fmessage_or_box):
Juri Linkov <juri@jurta.org>
parents:
65659
diff
changeset
|
3470 usage: (message-or-box FORMAT-STRING &rest ARGS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3471 (nargs, args) |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3472 int nargs; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3473 Lisp_Object *args; |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3474 { |
13878
2a71500dfb93
(Fmessage_box, Fmessage_or_box):
Richard M. Stallman <rms@gnu.org>
parents:
13767
diff
changeset
|
3475 #ifdef HAVE_MENUS |
26699
ed4ab9d24450
(Fmessage_or_box): Use use_dialog_box.
Dave Love <fx@gnu.org>
parents:
26629
diff
changeset
|
3476 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) |
28470
93996c44b23a
* editfns.c (text_property_stickiness, Fmessage_or_box): Use NILP to test
Ken Raeburn <raeburn@raeburn.org>
parents:
28358
diff
changeset
|
3477 && use_dialog_box) |
8981
6e1a5ff3d795
(Fmessage_or_box): Use Fmessage_box with new name.
Richard M. Stallman <rms@gnu.org>
parents:
8975
diff
changeset
|
3478 return Fmessage_box (nargs, args); |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3479 #endif |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3480 return Fmessage (nargs, args); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3481 } |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
3482 |
18937
ddb91108a9d2
(Fcurrent_message): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18756
diff
changeset
|
3483 DEFUN ("current-message", Fcurrent_message, Scurrent_message, 0, 0, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3484 doc: /* Return the string currently displayed in the echo area, or nil if none. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3485 () |
18937
ddb91108a9d2
(Fcurrent_message): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18756
diff
changeset
|
3486 { |
25346
15ec35852b48
Remove conditional compilation on NO_PROMPT_IN_BUFFER.
Gerd Moellmann <gerd@gnu.org>
parents:
25018
diff
changeset
|
3487 return current_message (); |
18937
ddb91108a9d2
(Fcurrent_message): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18756
diff
changeset
|
3488 } |
ddb91108a9d2
(Fcurrent_message): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18756
diff
changeset
|
3489 |
25815 | 3490 |
41062
07a4ff5f0909
(Fpropertize): Allow call with 1 arg.
Richard M. Stallman <rms@gnu.org>
parents:
40981
diff
changeset
|
3491 DEFUN ("propertize", Fpropertize, Spropertize, 1, MANY, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3492 doc: /* Return a copy of STRING with text properties added. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3493 First argument is the string to copy. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3494 Remaining arguments form a sequence of PROPERTY VALUE pairs for text |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3495 properties to add to the result. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3496 usage: (propertize STRING &rest PROPERTIES) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3497 (nargs, args) |
25815 | 3498 int nargs; |
3499 Lisp_Object *args; | |
3500 { | |
3501 Lisp_Object properties, string; | |
3502 struct gcpro gcpro1, gcpro2; | |
3503 int i; | |
3504 | |
3505 /* Number of args must be odd. */ | |
41062
07a4ff5f0909
(Fpropertize): Allow call with 1 arg.
Richard M. Stallman <rms@gnu.org>
parents:
40981
diff
changeset
|
3506 if ((nargs & 1) == 0 || nargs < 1) |
25815 | 3507 error ("Wrong number of arguments"); |
3508 | |
3509 properties = string = Qnil; | |
3510 GCPRO2 (properties, string); | |
30480 | 3511 |
25815 | 3512 /* First argument must be a string. */ |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
3513 CHECK_STRING (args[0]); |
25815 | 3514 string = Fcopy_sequence (args[0]); |
3515 | |
3516 for (i = 1; i < nargs; i += 2) | |
65324
3c228c69b2e5
(Fpropertize): Don't insist that properties be symbols.
Richard M. Stallman <rms@gnu.org>
parents:
64770
diff
changeset
|
3517 properties = Fcons (args[i], Fcons (args[i + 1], properties)); |
25815 | 3518 |
3519 Fadd_text_properties (make_number (0), | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3520 make_number (SCHARS (string)), |
25815 | 3521 properties, string); |
3522 RETURN_UNGCPRO (string); | |
3523 } | |
3524 | |
3525 | |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3526 /* Number of bytes that STRING will occupy when put into the result. |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3527 MULTIBYTE is nonzero if the result should be multibyte. */ |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3528 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3529 #define CONVERTED_BYTE_SIZE(MULTIBYTE, STRING) \ |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3530 (((MULTIBYTE) && ! STRING_MULTIBYTE (STRING)) \ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3531 ? count_size_as_multibyte (SDATA (STRING), SBYTES (STRING)) \ |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3532 : SBYTES (STRING)) |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3533 |
305 | 3534 DEFUN ("format", Fformat, Sformat, 1, MANY, 0, |
65739
83ce839858fb
(Fmessage, Fmessage_box, Fmessage_or_box):
Juri Linkov <juri@jurta.org>
parents:
65659
diff
changeset
|
3535 doc: /* Format a string out of a format-string and arguments. |
83ce839858fb
(Fmessage, Fmessage_box, Fmessage_or_box):
Juri Linkov <juri@jurta.org>
parents:
65659
diff
changeset
|
3536 The first argument is a format control string. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3537 The other arguments are substituted into it to make the result, a string. |
92236 | 3538 |
3539 The format control string may contain %-sequences meaning to substitute | |
3540 the next available argument: | |
3541 | |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3542 %s means print a string argument. Actually, prints any object, with `princ'. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3543 %d means print as number in decimal (%o octal, %x hex). |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3544 %X is like %x, but uses upper case. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3545 %e means print a number in exponential notation. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3546 %f means print a number in decimal-point notation. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3547 %g means print a number in exponential notation |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3548 or decimal-point notation, whichever uses fewer characters. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3549 %c means print a number as a single character. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
3550 %S means print any object as an s-expression (using `prin1'). |
92236 | 3551 |
3552 The argument used for %d, %o, %x, %e, %f, %g or %c must be a number. | |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3553 Use %% to put a single % into the output. |
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3554 |
92236 | 3555 A %-sequence may contain optional flag, width, and precision |
3556 specifiers, as follows: | |
3557 | |
3558 %<flags><width><precision>character | |
3559 | |
3560 where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+ | |
3561 | |
3562 The + flag character inserts a + before any positive number, while a | |
3563 space inserts a space before any positive number; these flags only | |
3564 affect %d, %e, %f, and %g sequences, and the + flag takes precedence. | |
3565 The # flag means to use an alternate display form for %o, %x, %X, %e, | |
3566 %f, and %g sequences. The - and 0 flags affect the width specifier, | |
3567 as described below. | |
3568 | |
3569 The width specifier supplies a lower limit for the length of the | |
3570 printed representation. The padding, if any, normally goes on the | |
3571 left, but it goes on the right if the - flag is present. The padding | |
3572 character is normally a space, but it is 0 if the 0 flag is present. | |
3573 The - flag takes precedence over the 0 flag. | |
3574 | |
3575 For %e, %f, and %g sequences, the number after the "." in the | |
3576 precision specifier says how many decimal places to show; if zero, the | |
3577 decimal point itself is omitted. For %s and %S, the precision | |
3578 specifier truncates the string to the given width. | |
53687
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3579 |
40131
de086e415fa2
(Finsert, Finsert_and_inherit, Finsert_before_markers, Fmessage)
Miles Bader <miles@gnu.org>
parents:
40046
diff
changeset
|
3580 usage: (format STRING &rest OBJECTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
3581 (nargs, args) |
305 | 3582 int nargs; |
3583 register Lisp_Object *args; | |
3584 { | |
3585 register int n; /* The number of the next arg to substitute */ | |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3586 register int total; /* An estimate of the final length */ |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3587 char *buf, *p; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3588 register unsigned char *format, *end, *format_start; |
25782
8f59abd3a02b
(init_editfns): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25662
diff
changeset
|
3589 int nchars; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3590 /* Nonzero if the output should be a multibyte string, |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3591 which is true if any of the inputs is one. */ |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3592 int multibyte = 0; |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3593 /* When we make a multibyte string, we must pay attention to the |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3594 byte combining problem, i.e., a byte may be combined with a |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3595 multibyte charcter of the previous string. This flag tells if we |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3596 must consider such a situation or not. */ |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3597 int maybe_combine_byte; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3598 unsigned char *this_format; |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3599 /* Precision for each spec, or -1, a flag value meaning no precision |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3600 was given in that spec. Element 0, corresonding to the format |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3601 string itself, will not be used. Element NARGS, corresponding to |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3602 no argument, *will* be assigned to in the case that a `%' and `.' |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3603 occur after the final format specifier. */ |
54846
e8865bfda38b
(Fformat): Fix allocation size of precision array.
Kim F. Storm <storm@cua.dk>
parents:
54655
diff
changeset
|
3604 int *precision = (int *) (alloca((nargs + 1) * sizeof (int))); |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3605 int longest_format; |
20804
14fa73136e64
(CONVERTED_BYTE_SIZE): Fix the logic.
Kenichi Handa <handa@m17n.org>
parents:
20706
diff
changeset
|
3606 Lisp_Object val; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3607 int arg_intervals = 0; |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
3608 USE_SAFE_ALLOCA; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3609 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3610 /* discarded[I] is 1 if byte I of the format |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3611 string was not copied into the output. |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3612 It is 2 if byte I was not the first byte of its character. */ |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3613 char *discarded = 0; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3614 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3615 /* Each element records, for one argument, |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3616 the start and end bytepos in the output string, |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3617 and whether the argument is a string with intervals. |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3618 info[0] is unused. Unused elements have -1 for start. */ |
25018 | 3619 struct info |
3620 { | |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3621 int start, end, intervals; |
25018 | 3622 } *info = 0; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3623 |
305 | 3624 /* It should not be necessary to GCPRO ARGS, because |
3625 the caller in the interpreter should take care of that. */ | |
3626 | |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3627 /* Try to determine whether the result should be multibyte. |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3628 This is not always right; sometimes the result needs to be multibyte |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3629 because of an object that we will pass through prin1, |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3630 and in that case, we won't know it here. */ |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3631 for (n = 0; n < nargs; n++) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3632 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3633 if (STRINGP (args[n]) && STRING_MULTIBYTE (args[n])) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3634 multibyte = 1; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3635 /* Piggyback on this loop to initialize precision[N]. */ |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3636 precision[n] = -1; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3637 } |
56560
1a84eb100ef3
(Fformat): Allocated extra (dummy) element in info.
Kim F. Storm <storm@cua.dk>
parents:
56386
diff
changeset
|
3638 precision[nargs] = -1; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3639 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40287
diff
changeset
|
3640 CHECK_STRING (args[0]); |
50430
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3641 /* We may have to change "%S" to "%s". */ |
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3642 args[0] = Fcopy_sequence (args[0]); |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3643 |
50746
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3644 /* GC should never happen here, so abort if it does. */ |
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3645 abort_on_gc++; |
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3646 |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3647 /* If we start out planning a unibyte result, |
50746
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3648 then discover it has to be multibyte, we jump back to retry. |
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3649 That can only happen from the first large while loop below. */ |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3650 retry: |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3651 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3652 format = SDATA (args[0]); |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3653 format_start = format; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3654 end = format + SBYTES (args[0]); |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3655 longest_format = 0; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3656 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3657 /* Make room in result for all the non-%-codes in the control string. */ |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
3658 total = 5 + CONVERTED_BYTE_SIZE (multibyte, args[0]) + 1; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3659 |
54846
e8865bfda38b
(Fformat): Fix allocation size of precision array.
Kim F. Storm <storm@cua.dk>
parents:
54655
diff
changeset
|
3660 /* Allocate the info and discarded tables. */ |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3661 { |
56560
1a84eb100ef3
(Fformat): Allocated extra (dummy) element in info.
Kim F. Storm <storm@cua.dk>
parents:
56386
diff
changeset
|
3662 int nbytes = (nargs+1) * sizeof *info; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3663 int i; |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3664 if (!info) |
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3665 info = (struct info *) alloca (nbytes); |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3666 bzero (info, nbytes); |
56560
1a84eb100ef3
(Fformat): Allocated extra (dummy) element in info.
Kim F. Storm <storm@cua.dk>
parents:
56386
diff
changeset
|
3667 for (i = 0; i <= nargs; i++) |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3668 info[i].start = -1; |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3669 if (!discarded) |
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
3670 SAFE_ALLOCA (discarded, char *, SBYTES (args[0])); |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3671 bzero (discarded, SBYTES (args[0])); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3672 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3673 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3674 /* Add to TOTAL enough space to hold the converted arguments. */ |
305 | 3675 |
3676 n = 0; | |
3677 while (format != end) | |
3678 if (*format++ == '%') | |
3679 { | |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3680 int thissize = 0; |
42484
717eee813b2c
(Fformat): Update thissize from field_width
Richard M. Stallman <rms@gnu.org>
parents:
42116
diff
changeset
|
3681 int actual_width = 0; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3682 unsigned char *this_format_start = format - 1; |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3683 int field_width = 0; |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3684 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3685 /* General format specifications look like |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3686 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3687 '%' [flags] [field-width] [precision] format |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3688 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3689 where |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3690 |
75949
d420b7899f20
(Fformat): Add support for '+' flag.
Andreas Schwab <schwab@suse.de>
parents:
75387
diff
changeset
|
3691 flags ::= [-+ #0]+ |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3692 field-width ::= [0-9]+ |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3693 precision ::= '.' [0-9]* |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3694 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3695 If a field-width is specified, it specifies to which width |
78501 | 3696 the output should be padded with blanks, if the output |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3697 string is shorter than field-width. |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3698 |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3699 If precision is specified, it specifies the number of |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3700 digits to print after the '.' for floats, or the max. |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3701 number of chars to print from a string. */ |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3702 |
65659
71ea8ba70056
(Fformat): Explicitly test for end of format string and don't use `index'.
Richard M. Stallman <rms@gnu.org>
parents:
65608
diff
changeset
|
3703 while (format != end |
71ea8ba70056
(Fformat): Explicitly test for end of format string and don't use `index'.
Richard M. Stallman <rms@gnu.org>
parents:
65608
diff
changeset
|
3704 && (*format == '-' || *format == '0' || *format == '#' |
75949
d420b7899f20
(Fformat): Add support for '+' flag.
Andreas Schwab <schwab@suse.de>
parents:
75387
diff
changeset
|
3705 || * format == ' ' || *format == '+')) |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3706 ++format; |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3707 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3708 if (*format >= '0' && *format <= '9') |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3709 { |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3710 for (field_width = 0; *format >= '0' && *format <= '9'; ++format) |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3711 field_width = 10 * field_width + *format - '0'; |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3712 } |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3713 |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3714 /* N is not incremented for another few lines below, so refer to |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3715 element N+1 (which might be precision[NARGS]). */ |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3716 if (*format == '.') |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3717 { |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3718 ++format; |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3719 for (precision[n+1] = 0; *format >= '0' && *format <= '9'; ++format) |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3720 precision[n+1] = 10 * precision[n+1] + *format - '0'; |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3721 } |
305 | 3722 |
79424 | 3723 /* Extra +1 for 'l' that we may need to insert into the |
3724 format. */ | |
3725 if (format - this_format_start + 2 > longest_format) | |
3726 longest_format = format - this_format_start + 2; | |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3727 |
23197
0d3baa5514b7
(Fformat): Detect incomplete format spec at string's end.
Karl Heuer <kwzh@gnu.org>
parents:
23166
diff
changeset
|
3728 if (format == end) |
0d3baa5514b7
(Fformat): Detect incomplete format spec at string's end.
Karl Heuer <kwzh@gnu.org>
parents:
23166
diff
changeset
|
3729 error ("Format string ends in middle of format specifier"); |
305 | 3730 if (*format == '%') |
3731 format++; | |
3732 else if (++n >= nargs) | |
12831
3917c5d131d3
(Fformat): Limit minlen to avoid stack overflow.
Richard M. Stallman <rms@gnu.org>
parents:
12623
diff
changeset
|
3733 error ("Not enough arguments for format string"); |
305 | 3734 else if (*format == 'S') |
3735 { | |
3736 /* For `S', prin1 the argument and then treat like a string. */ | |
3737 register Lisp_Object tem; | |
3738 tem = Fprin1_to_string (args[n], Qnil); | |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3739 if (STRING_MULTIBYTE (tem) && ! multibyte) |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3740 { |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3741 multibyte = 1; |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3742 goto retry; |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3743 } |
305 | 3744 args[n] = tem; |
50430
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3745 /* If we restart the loop, we should not come here again |
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3746 because args[n] is now a string and calling |
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3747 Fprin1_to_string on it produces superflous double |
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3748 quotes. So, change "%S" to "%s" now. */ |
4d74ea083bd2
(Fformat): Use a copy of FORMAT string so that we can
Kenichi Handa <handa@m17n.org>
parents:
49600
diff
changeset
|
3749 *format = 's'; |
305 | 3750 goto string; |
3751 } | |
9163
41fe5f636879
(lisp_time_argument, Finsert, Finsert_and_inherit, Finsert_before_markers,
Karl Heuer <kwzh@gnu.org>
parents:
9154
diff
changeset
|
3752 else if (SYMBOLP (args[n])) |
305 | 3753 { |
46447
8e01c92219ab
(Fstring_to_char): Don't use XSTRING/XSETSTRING to copy a lisp value.
Ken Raeburn <raeburn@raeburn.org>
parents:
46443
diff
changeset
|
3754 args[n] = SYMBOL_NAME (args[n]); |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
3755 if (STRING_MULTIBYTE (args[n]) && ! multibyte) |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
3756 { |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
3757 multibyte = 1; |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
3758 goto retry; |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
3759 } |
305 | 3760 goto string; |
3761 } | |
9163
41fe5f636879
(lisp_time_argument, Finsert, Finsert_and_inherit, Finsert_before_markers,
Karl Heuer <kwzh@gnu.org>
parents:
9154
diff
changeset
|
3762 else if (STRINGP (args[n])) |
305 | 3763 { |
3764 string: | |
6528
d0f6a386b7cb
(Fformat): Validate number and type of arguments.
Karl Heuer <kwzh@gnu.org>
parents:
6206
diff
changeset
|
3765 if (*format != 's' && *format != 'S') |
23197
0d3baa5514b7
(Fformat): Detect incomplete format spec at string's end.
Karl Heuer <kwzh@gnu.org>
parents:
23166
diff
changeset
|
3766 error ("Format specifier doesn't match argument type"); |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3767 /* In the case (PRECISION[N] > 0), THISSIZE may not need |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3768 to be as large as is calculated here. Easy check for |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3769 the case PRECISION = 0. */ |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3770 thissize = precision[n] ? CONVERTED_BYTE_SIZE (multibyte, args[n]) : 0; |
42484
717eee813b2c
(Fformat): Update thissize from field_width
Richard M. Stallman <rms@gnu.org>
parents:
42116
diff
changeset
|
3771 actual_width = lisp_string_width (args[n], -1, NULL, NULL); |
305 | 3772 } |
3773 /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ | |
9163
41fe5f636879
(lisp_time_argument, Finsert, Finsert_and_inherit, Finsert_before_markers,
Karl Heuer <kwzh@gnu.org>
parents:
9154
diff
changeset
|
3774 else if (INTEGERP (args[n]) && *format != 's') |
305 | 3775 { |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3522
diff
changeset
|
3776 /* The following loop assumes the Lisp type indicates |
305 | 3777 the proper way to pass the argument. |
3778 So make sure we have a flonum if the argument should | |
3779 be a double. */ | |
3780 if (*format == 'e' || *format == 'f' || *format == 'g') | |
79428
576665ace786
*** empty log message ***
Andreas Schwab <schwab@suse.de>
parents:
79427
diff
changeset
|
3781 args[n] = Ffloat (args[n]); |
23326
df3f641c9ca1
(Fformat): Check format control characters.
Kenichi Handa <handa@m17n.org>
parents:
23292
diff
changeset
|
3782 else |
df3f641c9ca1
(Fformat): Check format control characters.
Kenichi Handa <handa@m17n.org>
parents:
23292
diff
changeset
|
3783 if (*format != 'd' && *format != 'o' && *format != 'x' |
24505 | 3784 && *format != 'i' && *format != 'X' && *format != 'c') |
23326
df3f641c9ca1
(Fformat): Check format control characters.
Kenichi Handa <handa@m17n.org>
parents:
23292
diff
changeset
|
3785 error ("Invalid format operation %%%c", *format); |
df3f641c9ca1
(Fformat): Check format control characters.
Kenichi Handa <handa@m17n.org>
parents:
23292
diff
changeset
|
3786 |
79427
cc15c80eebe7
Always take precision into account.
Andreas Schwab <schwab@suse.de>
parents:
79425
diff
changeset
|
3787 thissize = 30 + (precision[n] > 0 ? precision[n] : 0); |
49285
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3788 if (*format == 'c') |
21064
90bdbe2754c8
(Fformat): Format multibyte characters by "%c"
Kenichi Handa <handa@m17n.org>
parents:
21052
diff
changeset
|
3789 { |
89483 | 3790 if (! ASCII_CHAR_P (XINT (args[n])) |
49472
3fd3c5521557
(Fformat): Add comment about the treatment of 0 as a multibyte
Kenichi Handa <handa@m17n.org>
parents:
49443
diff
changeset
|
3791 /* Note: No one can remeber why we have to treat |
3fd3c5521557
(Fformat): Add comment about the treatment of 0 as a multibyte
Kenichi Handa <handa@m17n.org>
parents:
49443
diff
changeset
|
3792 the character 0 as a multibyte character here. |
3fd3c5521557
(Fformat): Add comment about the treatment of 0 as a multibyte
Kenichi Handa <handa@m17n.org>
parents:
49443
diff
changeset
|
3793 But, until it causes a real problem, let's |
3fd3c5521557
(Fformat): Add comment about the treatment of 0 as a multibyte
Kenichi Handa <handa@m17n.org>
parents:
49443
diff
changeset
|
3794 don't change it. */ |
49285
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3795 || XINT (args[n]) == 0) |
21064
90bdbe2754c8
(Fformat): Format multibyte characters by "%c"
Kenichi Handa <handa@m17n.org>
parents:
21052
diff
changeset
|
3796 { |
49285
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3797 if (! multibyte) |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3798 { |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3799 multibyte = 1; |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3800 goto retry; |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3801 } |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3802 args[n] = Fchar_to_string (args[n]); |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3803 thissize = SBYTES (args[n]); |
21064
90bdbe2754c8
(Fformat): Format multibyte characters by "%c"
Kenichi Handa <handa@m17n.org>
parents:
21052
diff
changeset
|
3804 } |
49285
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3805 else if (! ASCII_BYTE_P (XINT (args[n])) && multibyte) |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3806 { |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3807 args[n] |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3808 = Fchar_to_string (Funibyte_char_to_multibyte (args[n])); |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3809 thissize = SBYTES (args[n]); |
7ec1335b6d36
(Fformat): Convert an unibyte char argument that is
Kenichi Handa <handa@m17n.org>
parents:
48908
diff
changeset
|
3810 } |
21064
90bdbe2754c8
(Fformat): Format multibyte characters by "%c"
Kenichi Handa <handa@m17n.org>
parents:
21052
diff
changeset
|
3811 } |
305 | 3812 } |
9163
41fe5f636879
(lisp_time_argument, Finsert, Finsert_and_inherit, Finsert_before_markers,
Karl Heuer <kwzh@gnu.org>
parents:
9154
diff
changeset
|
3813 else if (FLOATP (args[n]) && *format != 's') |
305 | 3814 { |
3815 if (! (*format == 'e' || *format == 'f' || *format == 'g')) | |
48020
7ac7ca5ac550
(Fformat): Detect invalid format letters for floats.
Richard M. Stallman <rms@gnu.org>
parents:
47763
diff
changeset
|
3816 { |
7ac7ca5ac550
(Fformat): Detect invalid format letters for floats.
Richard M. Stallman <rms@gnu.org>
parents:
47763
diff
changeset
|
3817 if (*format != 'd' && *format != 'o' && *format != 'x' |
7ac7ca5ac550
(Fformat): Detect invalid format letters for floats.
Richard M. Stallman <rms@gnu.org>
parents:
47763
diff
changeset
|
3818 && *format != 'i' && *format != 'X' && *format != 'c') |
7ac7ca5ac550
(Fformat): Detect invalid format letters for floats.
Richard M. Stallman <rms@gnu.org>
parents:
47763
diff
changeset
|
3819 error ("Invalid format operation %%%c", *format); |
75181
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3820 /* This fails unnecessarily if args[n] is bigger than |
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3821 most-positive-fixnum but smaller than MAXINT. |
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3822 These cases are important because we sometimes use floats |
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3823 to represent such integer values (typically such values |
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3824 come from UIDs or PIDs). */ |
ea255892b6fd
(Fformat): Allow integer-format to work with floats of size
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75096
diff
changeset
|
3825 /* args[n] = Ftruncate (args[n], Qnil); */ |
48020
7ac7ca5ac550
(Fformat): Detect invalid format letters for floats.
Richard M. Stallman <rms@gnu.org>
parents:
47763
diff
changeset
|
3826 } |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3827 |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3828 /* Note that we're using sprintf to print floats, |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3829 so we have to take into account what that function |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
3830 prints. */ |
48782
b02bdb795a5c
(Fformat): Use alloca, not _alloca.
Juanma Barranquero <lekktu@gmail.com>
parents:
48781
diff
changeset
|
3831 /* Filter out flag value of -1. */ |
48908 | 3832 thissize = (MAX_10_EXP + 100 |
3833 + (precision[n] > 0 ? precision[n] : 0)); | |
305 | 3834 } |
3835 else | |
3836 { | |
3837 /* Anything but a string, convert to a string using princ. */ | |
3838 register Lisp_Object tem; | |
3839 tem = Fprin1_to_string (args[n], Qt); | |
53541
41ceb9298a4e
(Fformat): Fix '&' to '&&'.
Kenichi Handa <handa@m17n.org>
parents:
52451
diff
changeset
|
3840 if (STRING_MULTIBYTE (tem) && ! multibyte) |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3841 { |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3842 multibyte = 1; |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3843 goto retry; |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3844 } |
305 | 3845 args[n] = tem; |
3846 goto string; | |
3847 } | |
30480 | 3848 |
42484
717eee813b2c
(Fformat): Update thissize from field_width
Richard M. Stallman <rms@gnu.org>
parents:
42116
diff
changeset
|
3849 thissize += max (0, field_width - actual_width); |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3850 total += thissize + 4; |
305 | 3851 } |
3852 | |
50746
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3853 abort_on_gc--; |
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3854 |
20826
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3855 /* Now we can no longer jump to retry. |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3856 TOTAL and LONGEST_FORMAT are known for certain. */ |
cbaa9e50b013
(Fformat): If MULTIBYTE is changed to 1
Richard M. Stallman <rms@gnu.org>
parents:
20804
diff
changeset
|
3857 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3858 this_format = (unsigned char *) alloca (longest_format + 1); |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3859 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3860 /* Allocate the space for the result. |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3861 Note that TOTAL is an overestimate. */ |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
3862 SAFE_ALLOCA (buf, char *, total); |
4019
0463aae99f4e
* editfns.c (Fformat): Since floats occupy two elements in the
Jim Blandy <jimb@redhat.com>
parents:
3776
diff
changeset
|
3863 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3864 p = buf; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3865 nchars = 0; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3866 n = 0; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3867 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3868 /* Scan the format and store result in BUF. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3869 format = SDATA (args[0]); |
50746
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3870 format_start = format; |
2a57a6e6b390
(Fformat): Set abort_on_gc during first scan of format.
Richard M. Stallman <rms@gnu.org>
parents:
50555
diff
changeset
|
3871 end = format + SBYTES (args[0]); |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3872 maybe_combine_byte = 0; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3873 while (format != end) |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3874 { |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3875 if (*format == '%') |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3876 { |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3877 int minlen; |
21225
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3878 int negative = 0; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3879 unsigned char *this_format_start = format; |
305 | 3880 |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3881 discarded[format - format_start] = 1; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3882 format++; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3883 |
75949
d420b7899f20
(Fformat): Add support for '+' flag.
Andreas Schwab <schwab@suse.de>
parents:
75387
diff
changeset
|
3884 while (index("-+0# ", *format)) |
53687
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3885 { |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3886 if (*format == '-') |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3887 { |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3888 negative = 1; |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3889 } |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3890 discarded[format - format_start] = 1; |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3891 ++format; |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3892 } |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3893 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3894 minlen = atoi (format); |
53687
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3895 |
4f06a8a0e7a6
For `format', make source and documentation match.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53541
diff
changeset
|
3896 while ((*format >= '0' && *format <= '9') || *format == '.') |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3897 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3898 discarded[format - format_start] = 1; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3899 format++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3900 } |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3901 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3902 if (*format++ == '%') |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3903 { |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3904 *p++ = '%'; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3905 nchars++; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3906 continue; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3907 } |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3908 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3909 ++n; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3910 |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3911 discarded[format - format_start - 1] = 1; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3912 info[n].start = nchars; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3913 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3914 if (STRINGP (args[n])) |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3915 { |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3916 /* handle case (precision[n] >= 0) */ |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3917 |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3918 int width, padding; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3919 int nbytes, start, end; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3920 int nchars_string; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3921 |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3922 /* lisp_string_width ignores a precision of 0, but GNU |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3923 libc functions print 0 characters when the precision |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3924 is 0. Imitate libc behavior here. Changing |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3925 lisp_string_width is the right thing, and will be |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3926 done, but meanwhile we work with it. */ |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3927 |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3928 if (precision[n] == 0) |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3929 width = nchars_string = nbytes = 0; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3930 else if (precision[n] > 0) |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3931 width = lisp_string_width (args[n], precision[n], &nchars_string, &nbytes); |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3932 else |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3933 { /* no precision spec given for this argument */ |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3934 width = lisp_string_width (args[n], -1, NULL, NULL); |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3935 nbytes = SBYTES (args[n]); |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3936 nchars_string = SCHARS (args[n]); |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3937 } |
21225
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3938 |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3939 /* If spec requires it, pad on right with spaces. */ |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3940 padding = minlen - width; |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3941 if (! negative) |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3942 while (padding-- > 0) |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3943 { |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3944 *p++ = ' '; |
35461
f0f0e9179ed6
(Fformat): Don't extend text properties from arguments
Gerd Moellmann <gerd@gnu.org>
parents:
35440
diff
changeset
|
3945 ++nchars; |
21225
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3946 } |
305 | 3947 |
66500
8392b2926dd8
(Fformat): Don't include string padding
Richard M. Stallman <rms@gnu.org>
parents:
66379
diff
changeset
|
3948 info[n].start = start = nchars; |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3949 nchars += nchars_string; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3950 end = nchars; |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3951 |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3952 if (p > buf |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3953 && multibyte |
22712
6f129ed55108
(Fformat): Replace explicit numeric constants with proper macros.
Kenichi Handa <handa@m17n.org>
parents:
22698
diff
changeset
|
3954 && !ASCII_BYTE_P (*((unsigned char *) p - 1)) |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3955 && STRING_MULTIBYTE (args[n]) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3956 && !CHAR_HEAD_P (SREF (args[n], 0))) |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
3957 maybe_combine_byte = 1; |
48764
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3958 |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3959 p += copy_text (SDATA (args[n]), p, |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3960 nbytes, |
4a69081f2ff4
(Fformat): Handle precision in string conversion specifiers like libc
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
48134
diff
changeset
|
3961 STRING_MULTIBYTE (args[n]), multibyte); |
305 | 3962 |
66500
8392b2926dd8
(Fformat): Don't include string padding
Richard M. Stallman <rms@gnu.org>
parents:
66379
diff
changeset
|
3963 info[n].end = nchars; |
8392b2926dd8
(Fformat): Don't include string padding
Richard M. Stallman <rms@gnu.org>
parents:
66379
diff
changeset
|
3964 |
21225
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3965 if (negative) |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3966 while (padding-- > 0) |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3967 { |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3968 *p++ = ' '; |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3969 nchars++; |
47e189a470d2
(Fformat): Handle padding before or after, for %s etc.
Richard M. Stallman <rms@gnu.org>
parents:
21202
diff
changeset
|
3970 } |
25018 | 3971 |
3972 /* If this argument has text properties, record where | |
3973 in the result string it appears. */ | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
3974 if (STRING_INTERVALS (args[n])) |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
3975 info[n].intervals = arg_intervals = 1; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3976 } |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3977 else if (INTEGERP (args[n]) || FLOATP (args[n])) |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3978 { |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3979 int this_nchars; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3980 |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3981 bcopy (this_format_start, this_format, |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3982 format - this_format_start); |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3983 this_format[format - this_format_start] = 0; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
3984 |
79422
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3985 if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3986 sprintf (p, this_format, XFLOAT_DATA (args[n])); |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3987 else |
72584
ad48859287a7
(Fformat): Don't sign-extend for %o or %x.
Richard M. Stallman <rms@gnu.org>
parents:
72531
diff
changeset
|
3988 { |
79472
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
3989 if (sizeof (EMACS_INT) > sizeof (int) |
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
3990 && format[-1] != 'c') |
79422
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3991 { |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3992 /* Insert 'l' before format spec. */ |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3993 this_format[format - this_format_start] |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3994 = this_format[format - this_format_start - 1]; |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3995 this_format[format - this_format_start - 1] = 'l'; |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3996 this_format[format - this_format_start + 1] = 0; |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3997 } |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3998 |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
3999 if (INTEGERP (args[n])) |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4000 { |
79472
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
4001 if (format[-1] == 'c') |
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
4002 sprintf (p, this_format, (int) XINT (args[n])); |
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
4003 else if (format[-1] == 'd') |
79422
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4004 sprintf (p, this_format, XINT (args[n])); |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4005 /* Don't sign-extend for octal or hex printing. */ |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4006 else |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4007 sprintf (p, this_format, XUINT (args[n])); |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4008 } |
79472
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
4009 else if (format[-1] == 'c') |
daa9b2b4d89d
(Fformat): Handle %c specially since it requires the
Andreas Schwab <schwab@suse.de>
parents:
79428
diff
changeset
|
4010 sprintf (p, this_format, (int) XFLOAT_DATA (args[n])); |
79422
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4011 else if (format[-1] == 'd') |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4012 /* Maybe we should use "%1.0f" instead so it also works |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4013 for values larger than MAXINT. */ |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4014 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); |
72584
ad48859287a7
(Fformat): Don't sign-extend for %o or %x.
Richard M. Stallman <rms@gnu.org>
parents:
72531
diff
changeset
|
4015 else |
79422
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4016 /* Don't sign-extend for octal or hex printing. */ |
45618be84af9
(Fformat): Correctly format EMACS_INT values.
Andreas Schwab <schwab@suse.de>
parents:
78501
diff
changeset
|
4017 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); |
72584
ad48859287a7
(Fformat): Don't sign-extend for %o or %x.
Richard M. Stallman <rms@gnu.org>
parents:
72531
diff
changeset
|
4018 } |
12603
6d033c8501d4
(Fformat): Increment total for size of control string.
Richard M. Stallman <rms@gnu.org>
parents:
12602
diff
changeset
|
4019 |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4020 if (p > buf |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4021 && multibyte |
22712
6f129ed55108
(Fformat): Replace explicit numeric constants with proper macros.
Kenichi Handa <handa@m17n.org>
parents:
22698
diff
changeset
|
4022 && !ASCII_BYTE_P (*((unsigned char *) p - 1)) |
6f129ed55108
(Fformat): Replace explicit numeric constants with proper macros.
Kenichi Handa <handa@m17n.org>
parents:
22698
diff
changeset
|
4023 && !CHAR_HEAD_P (*((unsigned char *) p))) |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4024 maybe_combine_byte = 1; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4025 this_nchars = strlen (p); |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4026 if (multibyte) |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4027 p += str_to_multibyte (p, buf + total - 1 - p, this_nchars); |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4028 else |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4029 p += this_nchars; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4030 nchars += this_nchars; |
66500
8392b2926dd8
(Fformat): Don't include string padding
Richard M. Stallman <rms@gnu.org>
parents:
66379
diff
changeset
|
4031 info[n].end = nchars; |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4032 } |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4033 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4034 } |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4035 else if (STRING_MULTIBYTE (args[0])) |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4036 { |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4037 /* Copy a whole multibyte character. */ |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4038 if (p > buf |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4039 && multibyte |
22712
6f129ed55108
(Fformat): Replace explicit numeric constants with proper macros.
Kenichi Handa <handa@m17n.org>
parents:
22698
diff
changeset
|
4040 && !ASCII_BYTE_P (*((unsigned char *) p - 1)) |
6f129ed55108
(Fformat): Replace explicit numeric constants with proper macros.
Kenichi Handa <handa@m17n.org>
parents:
22698
diff
changeset
|
4041 && !CHAR_HEAD_P (*format)) |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4042 maybe_combine_byte = 1; |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4043 *p++ = *format++; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4044 while (! CHAR_HEAD_P (*format)) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4045 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4046 discarded[format - format_start] = 2; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4047 *p++ = *format++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4048 } |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4049 nchars++; |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4050 } |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4051 else if (multibyte) |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4052 { |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4053 /* Convert a single-byte character to multibyte. */ |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4054 int len = copy_text (format, p, 1, 0, 1); |
305 | 4055 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4056 p += len; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4057 format++; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4058 nchars++; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4059 } |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4060 else |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4061 *p++ = *format++, nchars++; |
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4062 } |
305 | 4063 |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4064 if (p > buf + total) |
34566
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
4065 abort (); |
0370af7597d2
(Fformat): Prevent a buffer overrun when the format
Gerd Moellmann <gerd@gnu.org>
parents:
34165
diff
changeset
|
4066 |
22698
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4067 if (maybe_combine_byte) |
ea6ef56295b4
(Fformat): Pay attention to the byte combining problem.
Kenichi Handa <handa@m17n.org>
parents:
22669
diff
changeset
|
4068 nchars = multibyte_chars_in_text (buf, p - buf); |
21257
205a5aa4aa2f
(Fchar_to_string): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21245
diff
changeset
|
4069 val = make_specified_string (buf, nchars, p - buf, multibyte); |
20804
14fa73136e64
(CONVERTED_BYTE_SIZE): Fix the logic.
Kenichi Handa <handa@m17n.org>
parents:
20706
diff
changeset
|
4070 |
20606
9331e7e88cf5
(Fformat): Do all the work directly--don't use doprnt.
Richard M. Stallman <rms@gnu.org>
parents:
20564
diff
changeset
|
4071 /* If we allocated BUF with malloc, free it too. */ |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4072 SAFE_FREE (); |
305 | 4073 |
25018 | 4074 /* If the format string has text properties, or any of the string |
4075 arguments has text properties, set up text properties of the | |
4076 result string. */ | |
30480 | 4077 |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4078 if (STRING_INTERVALS (args[0]) || arg_intervals) |
25018 | 4079 { |
4080 Lisp_Object len, new_len, props; | |
4081 struct gcpro gcpro1; | |
30480 | 4082 |
25018 | 4083 /* Add text properties from the format string. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
4084 len = make_number (SCHARS (args[0])); |
25018 | 4085 props = text_property_list (args[0], make_number (0), len, Qnil); |
4086 GCPRO1 (props); | |
30480 | 4087 |
25018 | 4088 if (CONSP (props)) |
4089 { | |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4090 int bytepos = 0, position = 0, translated = 0, argn = 1; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4091 Lisp_Object list; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4092 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4093 /* Adjust the bounds of each text property |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4094 to the proper start and end in the output string. */ |
57076
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4095 |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4096 /* Put the positions in PROPS in increasing order, so that |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4097 we can do (effectively) one scan through the position |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4098 space of the format string. */ |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4099 props = Fnreverse (props); |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4100 |
d2baef38bbd7
(Fformat): Handle format strings with multiple text
Kim F. Storm <storm@cua.dk>
parents:
56560
diff
changeset
|
4101 /* BYTEPOS is the byte position in the format string, |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4102 POSITION is the untranslated char position in it, |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4103 TRANSLATED is the translated char position in BUF, |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4104 and ARGN is the number of the next arg we will come to. */ |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4105 for (list = props; CONSP (list); list = XCDR (list)) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4106 { |
50555
37d227b879ad
(Fformat): Lisp_Object/int mixup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50499
diff
changeset
|
4107 Lisp_Object item; |
37d227b879ad
(Fformat): Lisp_Object/int mixup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50499
diff
changeset
|
4108 int pos; |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4109 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4110 item = XCAR (list); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4111 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4112 /* First adjust the property start position. */ |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4113 pos = XINT (XCAR (item)); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4114 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4115 /* Advance BYTEPOS, POSITION, TRANSLATED and ARGN |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4116 up to this position. */ |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4117 for (; position < pos; bytepos++) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4118 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4119 if (! discarded[bytepos]) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4120 position++, translated++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4121 else if (discarded[bytepos] == 1) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4122 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4123 position++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4124 if (translated == info[argn].start) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4125 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4126 translated += info[argn].end - info[argn].start; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4127 argn++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4128 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4129 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4130 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4131 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4132 XSETCAR (item, make_number (translated)); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4133 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4134 /* Likewise adjust the property end position. */ |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4135 pos = XINT (XCAR (XCDR (item))); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4136 |
71865
47930f9fbcdf
(Fformat): Fix calculation of text property positions
Kenichi Handa <handa@m17n.org>
parents:
71832
diff
changeset
|
4137 for (; position < pos; bytepos++) |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4138 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4139 if (! discarded[bytepos]) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4140 position++, translated++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4141 else if (discarded[bytepos] == 1) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4142 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4143 position++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4144 if (translated == info[argn].start) |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4145 { |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4146 translated += info[argn].end - info[argn].start; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4147 argn++; |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4148 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4149 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4150 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4151 |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4152 XSETCAR (XCDR (item), make_number (translated)); |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4153 } |
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4154 |
25018 | 4155 add_text_properties_from_list (val, props, make_number (0)); |
4156 } | |
4157 | |
4158 /* Add text properties from arguments. */ | |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4159 if (arg_intervals) |
25018 | 4160 for (n = 1; n < nargs; ++n) |
50499
0abd4951c0fb
(Fformat): Translate positions of text properties
Richard M. Stallman <rms@gnu.org>
parents:
50430
diff
changeset
|
4161 if (info[n].intervals) |
25018 | 4162 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46293
diff
changeset
|
4163 len = make_number (SCHARS (args[n])); |
25018 | 4164 new_len = make_number (info[n].end - info[n].start); |
4165 props = text_property_list (args[n], make_number (0), len, Qnil); | |
4166 extend_property_ranges (props, len, new_len); | |
30023
ec25786e4705
(Fformat): While copying text properties, make each composition
Kenichi Handa <handa@m17n.org>
parents:
29008
diff
changeset
|
4167 /* If successive arguments have properites, be sure that |
ec25786e4705
(Fformat): While copying text properties, make each composition
Kenichi Handa <handa@m17n.org>
parents:
29008
diff
changeset
|
4168 the value of `composition' property be the copy. */ |
ec25786e4705
(Fformat): While copying text properties, make each composition
Kenichi Handa <handa@m17n.org>
parents:
29008
diff
changeset
|
4169 if (n > 1 && info[n - 1].end) |
ec25786e4705
(Fformat): While copying text properties, make each composition
Kenichi Handa <handa@m17n.org>
parents:
29008
diff
changeset
|
4170 make_composition_value_copy (props); |
25018 | 4171 add_text_properties_from_list (val, props, |
4172 make_number (info[n].start)); | |
4173 } | |
4174 | |
4175 UNGCPRO; | |
4176 } | |
4177 | |
20804
14fa73136e64
(CONVERTED_BYTE_SIZE): Fix the logic.
Kenichi Handa <handa@m17n.org>
parents:
20706
diff
changeset
|
4178 return val; |
305 | 4179 } |
4180 | |
4181 Lisp_Object | |
49443
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4182 format2 (string1, arg0, arg1) |
305 | 4183 char *string1; |
49443
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4184 Lisp_Object arg0, arg1; |
305 | 4185 { |
49443
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4186 Lisp_Object args[3]; |
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4187 args[0] = build_string (string1); |
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4188 args[1] = arg0; |
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4189 args[2] = arg1; |
f9f7612c767a
(format2): New function, replaces format1
Richard M. Stallman <rms@gnu.org>
parents:
49293
diff
changeset
|
4190 return Fformat (3, args); |
305 | 4191 } |
4192 | |
4193 DEFUN ("char-equal", Fchar_equal, Schar_equal, 2, 2, 0, | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4194 doc: /* Return t if two characters match, optionally ignoring case. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4195 Both arguments must be characters (i.e. integers). |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4196 Case is ignored if `case-fold-search' is non-nil in the current buffer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4197 (c1, c2) |
305 | 4198 register Lisp_Object c1, c2; |
4199 { | |
20688
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4200 int i1, i2; |
93038
a2c4bffe2b59
(Fchar_equal): Check they are valid characters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92954
diff
changeset
|
4201 /* Check they're chars, not just integers, otherwise we could get array |
a2c4bffe2b59
(Fchar_equal): Check they are valid characters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92954
diff
changeset
|
4202 bounds violations in DOWNCASE. */ |
a2c4bffe2b59
(Fchar_equal): Check they are valid characters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92954
diff
changeset
|
4203 CHECK_CHARACTER (c1); |
a2c4bffe2b59
(Fchar_equal): Check they are valid characters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92954
diff
changeset
|
4204 CHECK_CHARACTER (c2); |
305 | 4205 |
20688
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4206 if (XINT (c1) == XINT (c2)) |
305 | 4207 return Qt; |
20688
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4208 if (NILP (current_buffer->case_fold_search)) |
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4209 return Qnil; |
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4210 |
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4211 /* Do these in separate statements, |
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4212 then compare the variables. |
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4213 because of the way DOWNCASE uses temp variables. */ |
89025
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4214 i1 = XFASTINT (c1); |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4215 if (NILP (current_buffer->enable_multibyte_characters) |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4216 && ! ASCII_CHAR_P (i1)) |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4217 { |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4218 MAKE_CHAR_MULTIBYTE (i1); |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4219 } |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4220 i2 = XFASTINT (c2); |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4221 if (NILP (current_buffer->enable_multibyte_characters) |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4222 && ! ASCII_CHAR_P (i2)) |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4223 { |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4224 MAKE_CHAR_MULTIBYTE (i2); |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4225 } |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4226 i1 = DOWNCASE (i1); |
1c45126c0974
(Fchar_equal): Fix for the unibyte case.
Kenichi Handa <handa@m17n.org>
parents:
89009
diff
changeset
|
4227 i2 = DOWNCASE (i2); |
20688
16c458803c32
(Fchar_equal): Fix case-conversion code.
Richard M. Stallman <rms@gnu.org>
parents:
20606
diff
changeset
|
4228 return (i1 == i2 ? Qt : Qnil); |
305 | 4229 } |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4230 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4231 /* Transpose the markers in two regions of the current buffer, and |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4232 adjust the ones between them if necessary (i.e.: if the regions |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4233 differ in size). |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4234 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4235 START1, END1 are the character positions of the first region. |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4236 START1_BYTE, END1_BYTE are the byte positions. |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4237 START2, END2 are the character positions of the second region. |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4238 START2_BYTE, END2_BYTE are the byte positions. |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4239 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4240 Traverses the entire marker list of the buffer to do so, adding an |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4241 appropriate amount to some, subtracting from some, and leaving the |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4242 rest untouched. Most of this is copied from adjust_markers in insdel.c. |
30480 | 4243 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4244 It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */ |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4245 |
31016
b26ac1565dd4
(find_field): Formatting changes.
Gerd Moellmann <gerd@gnu.org>
parents:
30931
diff
changeset
|
4246 static void |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4247 transpose_markers (start1, end1, start2, end2, |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4248 start1_byte, end1_byte, start2_byte, end2_byte) |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4249 register int start1, end1, start2, end2; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4250 register int start1_byte, end1_byte, start2_byte, end2_byte; |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4251 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4252 register int amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos; |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4253 register struct Lisp_Marker *marker; |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4254 |
7862
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4255 /* Update point as if it were a marker. */ |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4256 if (PT < start1) |
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4257 ; |
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4258 else if (PT < end1) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4259 TEMP_SET_PT_BOTH (PT + (end2 - end1), |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4260 PT_BYTE + (end2_byte - end1_byte)); |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4261 else if (PT < start2) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4262 TEMP_SET_PT_BOTH (PT + (end2 - start2) - (end1 - start1), |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4263 (PT_BYTE + (end2_byte - start2_byte) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4264 - (end1_byte - start1_byte))); |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4265 else if (PT < end2) |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4266 TEMP_SET_PT_BOTH (PT - (start2 - start1), |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4267 PT_BYTE - (start2_byte - start1_byte)); |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4268 |
7862
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4269 /* We used to adjust the endpoints here to account for the gap, but that |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4270 isn't good enough. Even if we assume the caller has tried to move the |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4271 gap out of our way, it might still be at start1 exactly, for example; |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4272 and that places it `inside' the interval, for our purposes. The amount |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4273 of adjustment is nontrivial if there's a `denormalized' marker whose |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4274 position is between GPT and GPT + GAP_SIZE, so it's simpler to leave |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4275 the dirty work to Fmarker_position, below. */ |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4276 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4277 /* The difference between the region's lengths */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4278 diff = (end2 - start2) - (end1 - start1); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4279 diff_byte = (end2_byte - start2_byte) - (end1_byte - start1_byte); |
30480 | 4280 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4281 /* For shifting each marker in a region by the length of the other |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4282 region plus the distance between the regions. */ |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4283 amt1 = (end2 - start2) + (start2 - end1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4284 amt2 = (end1 - start1) + (start2 - end1); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4285 amt1_byte = (end2_byte - start2_byte) + (start2_byte - end1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4286 amt2_byte = (end1_byte - start1_byte) + (start2_byte - end1_byte); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4287 |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4288 for (marker = BUF_MARKERS (current_buffer); marker; marker = marker->next) |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4289 { |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4290 mpos = marker->bytepos; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4291 if (mpos >= start1_byte && mpos < end2_byte) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4292 { |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4293 if (mpos < end1_byte) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4294 mpos += amt1_byte; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4295 else if (mpos < start2_byte) |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4296 mpos += diff_byte; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4297 else |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4298 mpos -= amt2_byte; |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4299 marker->bytepos = mpos; |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4300 } |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4301 mpos = marker->charpos; |
7862
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4302 if (mpos >= start1 && mpos < end2) |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4303 { |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4304 if (mpos < end1) |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4305 mpos += amt1; |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4306 else if (mpos < start2) |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4307 mpos += diff; |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4308 else |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4309 mpos -= amt2; |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4310 } |
51670
beceb827c1ce
(save_excursion_restore, transpose_markers): Update for new types.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51042
diff
changeset
|
4311 marker->charpos = mpos; |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4312 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4313 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4314 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4315 DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0, |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
4316 doc: /* Transpose region STARTR1 to ENDR1 with STARTR2 to ENDR2. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4317 The regions may not be overlapping, because the size of the buffer is |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4318 never changed in a transposition. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4319 |
55972
db2480202623
(Fuser_login_name, Ffloat_time, Fencode_time, Fcurrent_time_string)
Juanma Barranquero <lekktu@gmail.com>
parents:
55424
diff
changeset
|
4320 Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4321 any markers that happen to be located in the regions. |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4322 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4323 Transposing beyond buffer boundaries is an error. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4324 (startr1, endr1, startr2, endr2, leave_markers) |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4325 Lisp_Object startr1, endr1, startr2, endr2, leave_markers; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4326 { |
81793
935816f951c9
(Ftranspose_regions): Use EMACS_INT for positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81422
diff
changeset
|
4327 register EMACS_INT start1, end1, start2, end2; |
935816f951c9
(Ftranspose_regions): Use EMACS_INT for positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81422
diff
changeset
|
4328 EMACS_INT start1_byte, start2_byte, len1_byte, len2_byte; |
935816f951c9
(Ftranspose_regions): Use EMACS_INT for positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81422
diff
changeset
|
4329 EMACS_INT gap, len1, len_mid, len2; |
7250
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4330 unsigned char *start1_addr, *start2_addr, *temp; |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4331 |
77017
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4332 INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2, tmp_interval3; |
76703
556faea8ff02
(Ftranspose_regions): Use set_text_properties_1 instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
76509
diff
changeset
|
4333 Lisp_Object buf; |
556faea8ff02
(Ftranspose_regions): Use set_text_properties_1 instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
76509
diff
changeset
|
4334 |
556faea8ff02
(Ftranspose_regions): Use set_text_properties_1 instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
76509
diff
changeset
|
4335 XSETBUFFER (buf, current_buffer); |
10308
90784ed0416f
Use SAVE_MODIFF and BUF_SAVE_MODIFF
Richard M. Stallman <rms@gnu.org>
parents:
9812
diff
changeset
|
4336 cur_intv = BUF_INTERVALS (current_buffer); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4337 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4338 validate_region (&startr1, &endr1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4339 validate_region (&startr2, &endr2); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4340 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4341 start1 = XFASTINT (startr1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4342 end1 = XFASTINT (endr1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4343 start2 = XFASTINT (startr2); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4344 end2 = XFASTINT (endr2); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4345 gap = GPT; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4346 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4347 /* Swap the regions if they're reversed. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4348 if (start2 < end1) |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4349 { |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4350 register int glumph = start1; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4351 start1 = start2; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4352 start2 = glumph; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4353 glumph = end1; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4354 end1 = end2; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4355 end2 = glumph; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4356 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4357 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4358 len1 = end1 - start1; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4359 len2 = end2 - start2; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4360 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4361 if (start2 < end1) |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4362 error ("Transposed regions overlap"); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4363 else if (start1 == end1 || start2 == end2) |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4364 error ("Transposed region has length 0"); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4365 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4366 /* The possibilities are: |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4367 1. Adjacent (contiguous) regions, or separate but equal regions |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4368 (no, really equal, in this case!), or |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4369 2. Separate regions of unequal size. |
30480 | 4370 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4371 The worst case is usually No. 2. It means that (aside from |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4372 potential need for getting the gap out of the way), there also |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4373 needs to be a shifting of the text between the two regions. So |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4374 if they are spread far apart, we are that much slower... sigh. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4375 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4376 /* It must be pointed out that the really studly thing to do would |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4377 be not to move the gap at all, but to leave it in place and work |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4378 around it if necessary. This would be extremely efficient, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4379 especially considering that people are likely to do |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4380 transpositions near where they are working interactively, which |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4381 is exactly where the gap would be found. However, such code |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4382 would be much harder to write and to read. So, if you are |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4383 reading this comment and are feeling squirrely, by all means have |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4384 a go! I just didn't feel like doing it, so I will simply move |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4385 the gap the minimum distance to get it out of the way, and then |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4386 deal with an unbroken array. */ |
7250
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4387 |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4388 /* Make sure the gap won't interfere, by moving it out of the text |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4389 we will operate on. */ |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4390 if (start1 < gap && gap < end2) |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4391 { |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4392 if (gap - start1 < end2 - gap) |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4393 move_gap (start1); |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4394 else |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4395 move_gap (end2); |
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4396 } |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4397 |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4398 start1_byte = CHAR_TO_BYTE (start1); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4399 start2_byte = CHAR_TO_BYTE (start2); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4400 len1_byte = CHAR_TO_BYTE (end1) - start1_byte; |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4401 len2_byte = CHAR_TO_BYTE (end2) - start2_byte; |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4402 |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4403 #ifdef BYTE_COMBINING_DEBUG |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4404 if (end1 == start2) |
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4405 { |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4406 if (count_combining_before (BYTE_POS_ADDR (start2_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4407 len2_byte, start1, start1_byte) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4408 || count_combining_before (BYTE_POS_ADDR (start1_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4409 len1_byte, end2, start2_byte + len2_byte) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4410 || count_combining_after (BYTE_POS_ADDR (start1_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4411 len1_byte, end2, start2_byte + len2_byte)) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4412 abort (); |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4413 } |
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4414 else |
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4415 { |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4416 if (count_combining_before (BYTE_POS_ADDR (start2_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4417 len2_byte, start1, start1_byte) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4418 || count_combining_before (BYTE_POS_ADDR (start1_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4419 len1_byte, start2, start2_byte) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4420 || count_combining_after (BYTE_POS_ADDR (start2_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4421 len2_byte, end1, start1_byte + len1_byte) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4422 || count_combining_after (BYTE_POS_ADDR (start1_byte), |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4423 len1_byte, end2, start2_byte + len2_byte)) |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4424 abort (); |
21245
6cde55b7c9de
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21235
diff
changeset
|
4425 } |
29008
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4426 #endif |
939760ef7379
(Fformat): Be sure to convert 8-bit characters to
Kenichi Handa <handa@m17n.org>
parents:
28545
diff
changeset
|
4427 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4428 /* Hmmm... how about checking to see if the gap is large |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4429 enough to use as the temporary storage? That would avoid an |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4430 allocation... interesting. Later, don't fool with it now. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4431 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4432 /* Working without memmove, for portability (sigh), so must be |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4433 careful of overlapping subsections of the array... */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4434 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4435 if (end1 == start2) /* adjacent regions */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4436 { |
72592
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
4437 modify_region (current_buffer, start1, end2, 0); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4438 record_change (start1, len1 + len2); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4439 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4440 tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4441 tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
76703
556faea8ff02
(Ftranspose_regions): Use set_text_properties_1 instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
76509
diff
changeset
|
4442 /* Don't use Fset_text_properties: that can cause GC, which can |
556faea8ff02
(Ftranspose_regions): Use set_text_properties_1 instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
76509
diff
changeset
|
4443 clobber objects stored in the tmp_intervals. */ |
77017
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4444 tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4445 if (!NULL_INTERVAL_P (tmp_interval3)) |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4446 set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4447 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4448 /* First region smaller than second. */ |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4449 if (len1_byte < len2_byte) |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4450 { |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4451 USE_SAFE_ALLOCA; |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4452 |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4453 SAFE_ALLOCA (temp, unsigned char *, len2_byte); |
7862
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4454 |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4455 /* Don't precompute these addresses. We have to compute them |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4456 at the last minute, because the relocating allocator might |
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4457 have moved the buffer around during the xmalloc. */ |
23166
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4458 start1_addr = BYTE_POS_ADDR (start1_byte); |
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4459 start2_addr = BYTE_POS_ADDR (start2_byte); |
7862
0b6f46029ea2
(transpose_markers): Allow for gap at start of region.
Karl Heuer <kwzh@gnu.org>
parents:
7710
diff
changeset
|
4460 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4461 bcopy (start2_addr, temp, len2_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4462 bcopy (start1_addr, start1_addr + len2_byte, len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4463 bcopy (temp, start1_addr, len2_byte); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4464 SAFE_FREE (); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4465 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4466 else |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4467 /* First region not smaller than second. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4468 { |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4469 USE_SAFE_ALLOCA; |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4470 |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4471 SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
23166
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4472 start1_addr = BYTE_POS_ADDR (start1_byte); |
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4473 start2_addr = BYTE_POS_ADDR (start2_byte); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4474 bcopy (start1_addr, temp, len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4475 bcopy (start2_addr, start1_addr, len2_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4476 bcopy (temp, start1_addr + len2_byte, len1_byte); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4477 SAFE_FREE (); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4478 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4479 graft_intervals_into_buffer (tmp_interval1, start1 + len2, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4480 len1, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4481 graft_intervals_into_buffer (tmp_interval2, start1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4482 len2, current_buffer, 0); |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
4483 update_compositions (start1, start1 + len2, CHECK_BORDER); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
4484 update_compositions (start1 + len2, end2, CHECK_TAIL); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4485 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4486 /* Non-adjacent regions, because end1 != start2, bleagh... */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4487 else |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4488 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4489 len_mid = start2_byte - (start1_byte + len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4490 |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4491 if (len1_byte == len2_byte) |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4492 /* Regions are same size, though, how nice. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4493 { |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4494 USE_SAFE_ALLOCA; |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4495 |
72592
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
4496 modify_region (current_buffer, start1, end1, 0); |
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
4497 modify_region (current_buffer, start2, end2, 0); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4498 record_change (start1, len1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4499 record_change (start2, len2); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4500 tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4501 tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
77017
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4502 |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4503 tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4504 if (!NULL_INTERVAL_P (tmp_interval3)) |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4505 set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4506 |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4507 tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4508 if (!NULL_INTERVAL_P (tmp_interval3)) |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4509 set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4510 |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4511 SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
23166
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4512 start1_addr = BYTE_POS_ADDR (start1_byte); |
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4513 start2_addr = BYTE_POS_ADDR (start2_byte); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4514 bcopy (start1_addr, temp, len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4515 bcopy (start2_addr, start1_addr, len2_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4516 bcopy (temp, start2_addr, len1_byte); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4517 SAFE_FREE (); |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4518 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4519 graft_intervals_into_buffer (tmp_interval1, start2, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4520 len1, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4521 graft_intervals_into_buffer (tmp_interval2, start1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4522 len2, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4523 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4524 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4525 else if (len1_byte < len2_byte) /* Second region larger than first */ |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4526 /* Non-adjacent & unequal size, area between must also be shifted. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4527 { |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4528 USE_SAFE_ALLOCA; |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4529 |
72592
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
4530 modify_region (current_buffer, start1, end2, 0); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4531 record_change (start1, (end2 - start1)); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4532 tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4533 tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4534 tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
77017
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4535 |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4536 tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4537 if (!NULL_INTERVAL_P (tmp_interval3)) |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4538 set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4539 |
7250
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4540 /* holds region 2 */ |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4541 SAFE_ALLOCA (temp, unsigned char *, len2_byte); |
23166
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4542 start1_addr = BYTE_POS_ADDR (start1_byte); |
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4543 start2_addr = BYTE_POS_ADDR (start2_byte); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4544 bcopy (start2_addr, temp, len2_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4545 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4546 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4547 bcopy (temp, start1_addr, len2_byte); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4548 SAFE_FREE (); |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4549 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4550 graft_intervals_into_buffer (tmp_interval1, end2 - len1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4551 len1, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4552 graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4553 len_mid, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4554 graft_intervals_into_buffer (tmp_interval2, start1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4555 len2, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4556 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4557 else |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4558 /* Second region smaller than first. */ |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4559 { |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4560 USE_SAFE_ALLOCA; |
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4561 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4562 record_change (start1, (end2 - start1)); |
72592
f6de516bbb4b
* buffer.h (struct buffer_text): New field chars_modiff.
Chong Yidong <cyd@stupidchicken.com>
parents:
72584
diff
changeset
|
4563 modify_region (current_buffer, start1, end2, 0); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4564 |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4565 tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4566 tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4567 tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
77017
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4568 |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4569 tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4570 if (!NULL_INTERVAL_P (tmp_interval3)) |
484daf850d1e
(Ftranspose_regions): Validate interval before setting text
Chong Yidong <cyd@stupidchicken.com>
parents:
76709
diff
changeset
|
4571 set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4572 |
7250
67bb3bb1b62d
(Ftranspose_regions): Take addresses only after move gap.
Richard M. Stallman <rms@gnu.org>
parents:
7207
diff
changeset
|
4573 /* holds region 1 */ |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4574 SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
23166
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4575 start1_addr = BYTE_POS_ADDR (start1_byte); |
6072f28afec9
(Ftranspose_regions): Use BYTE_POS_ADDR to get an
Kenichi Handa <handa@m17n.org>
parents:
23132
diff
changeset
|
4576 start2_addr = BYTE_POS_ADDR (start2_byte); |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4577 bcopy (start1_addr, temp, len1_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4578 bcopy (start2_addr, start1_addr, len2_byte); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4579 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4580 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); |
57725
c0675c413aa3
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
57644
diff
changeset
|
4581 SAFE_FREE (); |
56194
e1f0d4beb4ba
(Fformat, Ftranspose_regions): Use SAFE_ALLOCA.
Kim F. Storm <storm@cua.dk>
parents:
55972
diff
changeset
|
4582 |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4583 graft_intervals_into_buffer (tmp_interval1, end2 - len1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4584 len1, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4585 graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4586 len_mid, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4587 graft_intervals_into_buffer (tmp_interval2, start1, |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4588 len2, current_buffer, 0); |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4589 } |
26853
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
4590 |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
4591 update_compositions (start1, start1 + len2, CHECK_BORDER); |
bf700e4957ec
(Fchar_to_string): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
26742
diff
changeset
|
4592 update_compositions (end2 - len1, end2, CHECK_BORDER); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4593 } |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4594 |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4595 /* When doing multiple transpositions, it might be nice |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4596 to optimize this. Perhaps the markers in any one buffer |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4597 should be organized in some sorted data tree. */ |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4598 if (NILP (leave_markers)) |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4599 { |
20558
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4600 transpose_markers (start1, end1, start2, end2, |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4601 start1_byte, start1_byte + len1_byte, |
d19346dc4453
(Fgoto_char): When arg is a marker, copy char and byte
Richard M. Stallman <rms@gnu.org>
parents:
20338
diff
changeset
|
4602 start2_byte, start2_byte + len2_byte); |
54555
b136a4512609
* insdel.c (adjust_markers_for_insert): Call fix_start_end_in_overlays.
Masatake YAMATO <jet@gyve.org>
parents:
54242
diff
changeset
|
4603 fix_start_end_in_overlays (start1, end2); |
7519
987ab382275c
(Ftranspose_regions): Fix overlays after moving markers.
Karl Heuer <kwzh@gnu.org>
parents:
7506
diff
changeset
|
4604 } |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4605 |
77661
6634ebb68050
(Ftranspose_regions): Yet another int/Lisp_Object mixup (YAILOM)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77017
diff
changeset
|
4606 signal_after_change (start1, end2 - start1, end2 - start1); |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4607 return Qnil; |
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4608 } |
305 | 4609 |
4610 | |
4611 void | |
4612 syms_of_editfns () | |
4613 { | |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4614 environbuf = 0; |
92954
f0f1c359cd43
(initial_tz): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
92236
diff
changeset
|
4615 initial_tz = 0; |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4616 |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4617 Qbuffer_access_fontify_functions |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4618 = intern ("buffer-access-fontify-functions"); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4619 staticpro (&Qbuffer_access_fontify_functions); |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4620 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4621 DEFVAR_LISP ("inhibit-field-text-motion", &Vinhibit_field_text_motion, |
43862
7263004fcb03
(syms_of_editfns): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
43042
diff
changeset
|
4622 doc: /* Non-nil means text motion commands don't notice fields. */); |
27077
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
4623 Vinhibit_field_text_motion = Qnil; |
19a664c654ab
(Vinhibit_field_text_motion): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
26853
diff
changeset
|
4624 |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4625 DEFVAR_LISP ("buffer-access-fontify-functions", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4626 &Vbuffer_access_fontify_functions, |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4627 doc: /* List of functions called by `buffer-substring' to fontify if necessary. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4628 Each function is called with two arguments which specify the range |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4629 of the buffer being accessed. */); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4630 Vbuffer_access_fontify_functions = Qnil; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4631 |
14440
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4632 { |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4633 Lisp_Object obuf; |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4634 extern Lisp_Object Vprin1_to_string_buffer; |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4635 obuf = Fcurrent_buffer (); |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4636 /* Do this here, because init_buffer_once is too early--it won't work. */ |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4637 Fset_buffer (Vprin1_to_string_buffer); |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4638 /* Make sure buffer-access-fontify-functions is nil in this buffer. */ |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4639 Fset (Fmake_local_variable (intern ("buffer-access-fontify-functions")), |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4640 Qnil); |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4641 Fset_buffer (obuf); |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4642 } |
e99b3302c154
(syms_of_editfns): Make buffer-access-fontify-functions
Richard M. Stallman <rms@gnu.org>
parents:
14391
diff
changeset
|
4643 |
14220 | 4644 DEFVAR_LISP ("buffer-access-fontified-property", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4645 &Vbuffer_access_fontified_property, |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4646 doc: /* Property which (if non-nil) indicates text has been fontified. |
39966
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4647 `buffer-substring' need not call the `buffer-access-fontify-functions' |
1c2d486200f3
Put doc strings in comments.
Pavel Janík <Pavel@Janik.cz>
parents:
39962
diff
changeset
|
4648 functions if all the text being accessed has this property. */); |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4649 Vbuffer_access_fontified_property = Qnil; |
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4650 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4651 DEFVAR_LISP ("system-name", &Vsystem_name, |
72751
9128a4531448
(Fsystem_name): Mention "host" in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
72669
diff
changeset
|
4652 doc: /* The host name of the machine Emacs is running on. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4653 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4654 DEFVAR_LISP ("user-full-name", &Vuser_full_name, |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4655 doc: /* The full name of the user logged in. */); |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4656 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4657 DEFVAR_LISP ("user-login-name", &Vuser_login_name, |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4658 doc: /* The user's name, taken from environment variables if possible. */); |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4659 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4660 DEFVAR_LISP ("user-real-login-name", &Vuser_real_login_name, |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39966
diff
changeset
|
4661 doc: /* The user's name, based upon the real uid only. */); |
305 | 4662 |
59644
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
4663 DEFVAR_LISP ("operating-system-release", &Voperating_system_release, |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
4664 doc: /* The release of the operating system Emacs is running on. */); |
d8d85276ffed
* editfns.c (Voperating_system_release): Added.
Steven Tamm <steventamm@mac.com>
parents:
58029
diff
changeset
|
4665 |
25833
65cab65c4a28
(Fpropertize): Renamed from Fproperties.
Gerd Moellmann <gerd@gnu.org>
parents:
25815
diff
changeset
|
4666 defsubr (&Spropertize); |
305 | 4667 defsubr (&Schar_equal); |
4668 defsubr (&Sgoto_char); | |
4669 defsubr (&Sstring_to_char); | |
4670 defsubr (&Schar_to_string); | |
4671 defsubr (&Sbuffer_substring); | |
13767
862fff660446
(Fset_time_zone_rule): Move static var environbuf
Karl Heuer <kwzh@gnu.org>
parents:
13618
diff
changeset
|
4672 defsubr (&Sbuffer_substring_no_properties); |
305 | 4673 defsubr (&Sbuffer_string); |
4674 | |
4675 defsubr (&Spoint_marker); | |
4676 defsubr (&Smark_marker); | |
4677 defsubr (&Spoint); | |
4678 defsubr (&Sregion_beginning); | |
4679 defsubr (&Sregion_end); | |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4680 |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4681 staticpro (&Qfield); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4682 Qfield = intern ("field"); |
30439
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
4683 staticpro (&Qboundary); |
c084f49c2a7f
(find_field): Honor special `boundary' fields.
Miles Bader <miles@gnu.org>
parents:
30244
diff
changeset
|
4684 Qboundary = intern ("boundary"); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4685 defsubr (&Sfield_beginning); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4686 defsubr (&Sfield_end); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4687 defsubr (&Sfield_string); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4688 defsubr (&Sfield_string_no_properties); |
26347
7fd9f4ecdd29
(Fdelete_field): Renamed from Ferase_field.
Gerd Moellmann <gerd@gnu.org>
parents:
26088
diff
changeset
|
4689 defsubr (&Sdelete_field); |
26058
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4690 defsubr (&Sconstrain_to_field); |
c11f0832a7c5
(Fconstrain_to_field): Make sure we don't violate the
Gerd Moellmann <gerd@gnu.org>
parents:
25833
diff
changeset
|
4691 |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4692 defsubr (&Sline_beginning_position); |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4693 defsubr (&Sline_end_position); |
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4694 |
305 | 4695 /* defsubr (&Smark); */ |
4696 /* defsubr (&Sset_mark); */ | |
4697 defsubr (&Ssave_excursion); | |
16298
17304eb73f97
(Fsave_current_buffer): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16269
diff
changeset
|
4698 defsubr (&Ssave_current_buffer); |
305 | 4699 |
4700 defsubr (&Sbufsize); | |
4701 defsubr (&Spoint_max); | |
4702 defsubr (&Spoint_min); | |
4703 defsubr (&Spoint_min_marker); | |
4704 defsubr (&Spoint_max_marker); | |
21821
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
4705 defsubr (&Sgap_position); |
9e82920b194d
(Fgap_position, Fgap_size): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
21717
diff
changeset
|
4706 defsubr (&Sgap_size); |
20861
9f9937a74050
(Fformat): Handle a symbol of which name contains
Richard M. Stallman <rms@gnu.org>
parents:
20834
diff
changeset
|
4707 defsubr (&Sposition_bytes); |
22645
e5b201634497
(Fbyte_to_position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22199
diff
changeset
|
4708 defsubr (&Sbyte_to_position); |
16639
b6ba5d371c1c
(Fline_beginning_position, Fline_end_position): New fns.
Richard M. Stallman <rms@gnu.org>
parents:
16526
diff
changeset
|
4709 |
305 | 4710 defsubr (&Sbobp); |
4711 defsubr (&Seobp); | |
4712 defsubr (&Sbolp); | |
4713 defsubr (&Seolp); | |
512 | 4714 defsubr (&Sfollowing_char); |
4715 defsubr (&Sprevious_char); | |
305 | 4716 defsubr (&Schar_after); |
17031 | 4717 defsubr (&Schar_before); |
305 | 4718 defsubr (&Sinsert); |
4719 defsubr (&Sinsert_before_markers); | |
4714
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
4720 defsubr (&Sinsert_and_inherit); |
350231e38e68
(Finsert_and_inherit): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
4721 defsubr (&Sinsert_and_inherit_before_markers); |
305 | 4722 defsubr (&Sinsert_char); |
89034
63f566c131d7
(Finsert_byte): New function.
Kenichi Handa <handa@m17n.org>
parents:
89025
diff
changeset
|
4723 defsubr (&Sinsert_byte); |
305 | 4724 |
4725 defsubr (&Suser_login_name); | |
4726 defsubr (&Suser_real_login_name); | |
4727 defsubr (&Suser_uid); | |
4728 defsubr (&Suser_real_uid); | |
4729 defsubr (&Suser_full_name); | |
5373
a70b89d2d6bb
(Femacs_pid): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5242
diff
changeset
|
4730 defsubr (&Semacs_pid); |
448 | 4731 defsubr (&Scurrent_time); |
57987
db8c9a3a77cd
(Fget_internal_run_time): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
57736
diff
changeset
|
4732 defsubr (&Sget_internal_run_time); |
9154
b4739bcefc44
(Fformat_time_string): Mostly rewritten, to handle
Richard M. Stallman <rms@gnu.org>
parents:
8981
diff
changeset
|
4733 defsubr (&Sformat_time_string); |
30480 | 4734 defsubr (&Sfloat_time); |
9801
7003b5184aec
(init_editfns): Get the username from the environment
Richard M. Stallman <rms@gnu.org>
parents:
9657
diff
changeset
|
4735 defsubr (&Sdecode_time); |
11402
66d935214d8e
(Fencode_time): Use XINT to examine `zone'.
Richard M. Stallman <rms@gnu.org>
parents:
11263
diff
changeset
|
4736 defsubr (&Sencode_time); |
305 | 4737 defsubr (&Scurrent_time_string); |
962
3533821d6edc
* editfns.c (Fcurrent_time_zone): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
690
diff
changeset
|
4738 defsubr (&Scurrent_time_zone); |
13019
5381e2022370
(Fset_time_zone_rule): New function.
Richard M. Stallman <rms@gnu.org>
parents:
13013
diff
changeset
|
4739 defsubr (&Sset_time_zone_rule); |
305 | 4740 defsubr (&Ssystem_name); |
4741 defsubr (&Smessage); | |
8975
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
4742 defsubr (&Smessage_box); |
e8a4c71251cb
(Fmessage_box): Renamed from Fbox_message.
Richard M. Stallman <rms@gnu.org>
parents:
8824
diff
changeset
|
4743 defsubr (&Smessage_or_box); |
18937
ddb91108a9d2
(Fcurrent_message): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18756
diff
changeset
|
4744 defsubr (&Scurrent_message); |
305 | 4745 defsubr (&Sformat); |
4746 | |
4747 defsubr (&Sinsert_buffer_substring); | |
1853
8866e36c0ed5
(Fcompare_buffer_substrings): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1748
diff
changeset
|
4748 defsubr (&Scompare_buffer_substrings); |
305 | 4749 defsubr (&Ssubst_char_in_region); |
57644
c0f2bdd90b5d
(Ftranslate_region_internal): New function.
Kenichi Handa <handa@m17n.org>
parents:
57606
diff
changeset
|
4750 defsubr (&Stranslate_region_internal); |
305 | 4751 defsubr (&Sdelete_region); |
26742
936b39bd05b4
* editfns.c (Fdelete_and_extract_region): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26699
diff
changeset
|
4752 defsubr (&Sdelete_and_extract_region); |
305 | 4753 defsubr (&Swiden); |
4754 defsubr (&Snarrow_to_region); | |
4755 defsubr (&Ssave_restriction); | |
7207
c83b161fe62c
(Ftranspose_regions): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6878
diff
changeset
|
4756 defsubr (&Stranspose_regions); |
305 | 4757 } |
52401 | 4758 |
4759 /* arch-tag: fc3827d8-6f60-4067-b11e-c3218031b018 | |
4760 (do not change this comment) */ |