diff options
| author | Paul Eggert | 2011-06-06 10:58:07 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-06 10:58:07 -0700 |
| commit | 77984278b977d1ad4d8af78d79adb1563e0b4aa6 (patch) | |
| tree | f9c6300fbd5137050d787d3e1cd71a303ebd50c2 /src | |
| parent | be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434 (diff) | |
| parent | d6d100dd7c48e124ca9ce4bbb761f24b8e052493 (diff) | |
| download | emacs-77984278b977d1ad4d8af78d79adb1563e0b4aa6.tar.gz emacs-77984278b977d1ad4d8af78d79adb1563e0b4aa6.zip | |
Merge from trunk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 72 | ||||
| -rw-r--r-- | src/alloc.c | 15 | ||||
| -rw-r--r-- | src/frame.c | 123 | ||||
| -rw-r--r-- | src/lisp.h | 4 | ||||
| -rw-r--r-- | src/minibuf.c | 9 | ||||
| -rw-r--r-- | src/window.c | 504 | ||||
| -rw-r--r-- | src/window.h | 10 |
7 files changed, 420 insertions, 317 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c9c739dde9a..1d5e3f2ddbd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2011-06-06 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-06-06 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Integer overflow fixes. | ||
| 4 | |||
| 3 | Check for overflow when converting integer to cons and back. | 5 | Check for overflow when converting integer to cons and back. |
| 4 | * charset.c (Fdefine_charset_internal, Fdecode_char): | 6 | * charset.c (Fdefine_charset_internal, Fdecode_char): |
| 5 | Use cons_to_unsigned to catch overflow. | 7 | Use cons_to_unsigned to catch overflow. |
| @@ -75,6 +77,52 @@ | |||
| 75 | (access_keymap): NATNUMP -> INTEGERP, since the integer must be | 77 | (access_keymap): NATNUMP -> INTEGERP, since the integer must be |
| 76 | nonnegative. | 78 | nonnegative. |
| 77 | 79 | ||
| 80 | 2011-06-06 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 81 | |||
| 82 | * window.h (Fwindow_frame): Declare. | ||
| 83 | |||
| 84 | 2011-06-06 Paul Eggert <eggert@cs.ucla.edu> | ||
| 85 | |||
| 86 | * alloc.c: Simplify handling of large-request failures (Bug#8800). | ||
| 87 | (SPARE_MEMORY): Always define. | ||
| 88 | (LARGE_REQUEST): Remove. | ||
| 89 | (memory_full): Use SPARE_MEMORY rather than LARGE_REQUEST. | ||
| 90 | |||
| 91 | 2011-06-06 Martin Rudalics <rudalics@gmx.at> | ||
| 92 | |||
| 93 | * lisp.h: Move EXFUNS for Fframe_root_window, | ||
| 94 | Fframe_first_window and Fset_frame_selected_window to window.h. | ||
| 95 | |||
| 96 | * window.h: Move EXFUNS for Fframe_root_window, | ||
| 97 | Fframe_first_window and Fset_frame_selected_window here from | ||
| 98 | lisp.h. | ||
| 99 | |||
| 100 | * frame.c (Fwindow_frame, Fframe_first_window) | ||
| 101 | (Fframe_root_window, Fframe_selected_window) | ||
| 102 | (Fset_frame_selected_window): Move to window.c. | ||
| 103 | (Factive_minibuffer_window): Move to minibuf.c. | ||
| 104 | (Fother_visible_frames_p): New function. | ||
| 105 | |||
| 106 | * minibuf.c (Factive_minibuffer_window): Move here from frame.c. | ||
| 107 | |||
| 108 | * window.c (decode_window, decode_any_window): Move up in code. | ||
| 109 | (Fwindowp, Fwindow_live_p): Rewrite doc-strings. | ||
| 110 | (inhibit_frame_unsplittable): Remove unused variable. | ||
| 111 | (Fwindow_buffer): Move up and rewrite doc-string. | ||
| 112 | (Fwindow_parent, Fwindow_vchild, Fwindow_hchild, Fwindow_next) | ||
| 113 | (Fwindow_prev): New functions. | ||
| 114 | (Fwindow_frame): Move here from frame.c. Accept any window as | ||
| 115 | argument. | ||
| 116 | (Fframe_root_window, Fframe_first_window) | ||
| 117 | (Fframe_selected_window): Move here from frame.c. Accept frame | ||
| 118 | or arbitrary window as argument. Update doc-strings. | ||
| 119 | (Fminibuffer_window): Move up in code. | ||
| 120 | (Fwindow_minibuffer_p): Move up in code and simplify. | ||
| 121 | (Fset_frame_selected_window): Move here from frame.c. | ||
| 122 | Marginal rewrite. | ||
| 123 | (Fselected_window, select_window, Fselect_window): Move up in | ||
| 124 | code. Minor doc-string fixes. | ||
| 125 | |||
| 78 | 2011-06-06 Paul Eggert <eggert@cs.ucla.edu> | 126 | 2011-06-06 Paul Eggert <eggert@cs.ucla.edu> |
| 79 | 127 | ||
| 80 | * alloc.c (memory_full) [SYSTEM_MALLOC]: Port to MacOS (Bug#8800). | 128 | * alloc.c (memory_full) [SYSTEM_MALLOC]: Port to MacOS (Bug#8800). |
| @@ -110,8 +158,8 @@ | |||
| 110 | 158 | ||
| 111 | * xselect.c (x_clipboard_manager_save): Remove redundant arg. | 159 | * xselect.c (x_clipboard_manager_save): Remove redundant arg. |
| 112 | (x_clipboard_manager_save): Add return value. | 160 | (x_clipboard_manager_save): Add return value. |
| 113 | (x_clipboard_manager_error_1, x_clipboard_manager_error_2): New | 161 | (x_clipboard_manager_error_1, x_clipboard_manager_error_2): |
| 114 | error handlers. | 162 | New error handlers. |
| 115 | (x_clipboard_manager_save_frame, x_clipboard_manager_save_all): | 163 | (x_clipboard_manager_save_frame, x_clipboard_manager_save_all): |
| 116 | Obey Vx_select_enable_clipboard_manager. Catch errors in | 164 | Obey Vx_select_enable_clipboard_manager. Catch errors in |
| 117 | x_clipboard_manager_save (Bug#8779). | 165 | x_clipboard_manager_save (Bug#8779). |
| @@ -139,8 +187,8 @@ | |||
| 139 | (bidi_fetch_char, bidi_fetch_char_advance): New functions. | 187 | (bidi_fetch_char, bidi_fetch_char_advance): New functions. |
| 140 | (bidi_cache_search, bidi_cache_iterator_state) | 188 | (bidi_cache_search, bidi_cache_iterator_state) |
| 141 | (bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak) | 189 | (bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak) |
| 142 | (bidi_level_of_next_char, bidi_move_to_visually_next): Support | 190 | (bidi_level_of_next_char, bidi_move_to_visually_next): |
| 143 | character positions inside a run of characters covered by a | 191 | Support character positions inside a run of characters covered by a |
| 144 | display string. | 192 | display string. |
| 145 | (bidi_paragraph_init, bidi_resolve_explicit_1) | 193 | (bidi_paragraph_init, bidi_resolve_explicit_1) |
| 146 | (bidi_level_of_next_char): Call bidi_fetch_char and | 194 | (bidi_level_of_next_char): Call bidi_fetch_char and |
| @@ -151,8 +199,8 @@ | |||
| 151 | definitions. | 199 | definitions. |
| 152 | (bidi_explicit_dir_char): Lookup character type in bidi_type_table, | 200 | (bidi_explicit_dir_char): Lookup character type in bidi_type_table, |
| 153 | instead of using explicit *_CHAR codes. | 201 | instead of using explicit *_CHAR codes. |
| 154 | (bidi_resolve_explicit, bidi_resolve_weak): Use | 202 | (bidi_resolve_explicit, bidi_resolve_weak): |
| 155 | FETCH_MULTIBYTE_CHAR instead of FETCH_CHAR, as reordering of | 203 | Use FETCH_MULTIBYTE_CHAR instead of FETCH_CHAR, as reordering of |
| 156 | bidirectional text is supported only in multibyte buffers. | 204 | bidirectional text is supported only in multibyte buffers. |
| 157 | (bidi_init_it): Accept additional argument FRAME_WINDOW_P and use | 205 | (bidi_init_it): Accept additional argument FRAME_WINDOW_P and use |
| 158 | it to initialize the frame_window_p member of struct bidi_it. | 206 | it to initialize the frame_window_p member of struct bidi_it. |
| @@ -170,8 +218,8 @@ | |||
| 170 | (single_display_spec_intangible_p): Function deleted. | 218 | (single_display_spec_intangible_p): Function deleted. |
| 171 | (display_prop_intangible_p): Reimplement to call | 219 | (display_prop_intangible_p): Reimplement to call |
| 172 | handle_display_spec instead of single_display_spec_intangible_p. | 220 | handle_display_spec instead of single_display_spec_intangible_p. |
| 173 | Accept 3 additional arguments needed by handle_display_spec. This | 221 | Accept 3 additional arguments needed by handle_display_spec. |
| 174 | fixes incorrect cursor motion across display property with complex | 222 | This fixes incorrect cursor motion across display property with complex |
| 175 | values: lists, `(when COND...)' forms, etc. | 223 | values: lists, `(when COND...)' forms, etc. |
| 176 | (single_display_spec_string_p): Support property values that are | 224 | (single_display_spec_string_p): Support property values that are |
| 177 | lists with the argument STRING its top-level element. | 225 | lists with the argument STRING its top-level element. |
| @@ -188,8 +236,8 @@ | |||
| 188 | the display property will replace the characters it covers. | 236 | the display property will replace the characters it covers. |
| 189 | (Fcurrent_bidi_paragraph_direction): Initialize the nchars and | 237 | (Fcurrent_bidi_paragraph_direction): Initialize the nchars and |
| 190 | frame_window_p members of struct bidi_it. | 238 | frame_window_p members of struct bidi_it. |
| 191 | (compute_display_string_pos, compute_display_string_end): New | 239 | (compute_display_string_pos, compute_display_string_end): |
| 192 | functions. | 240 | New functions. |
| 193 | (push_it): Accept second argument POSITION, where pop_it should | 241 | (push_it): Accept second argument POSITION, where pop_it should |
| 194 | jump to continue iteration. | 242 | jump to continue iteration. |
| 195 | (reseat_1): Initialize bidi_it.disp_pos. | 243 | (reseat_1): Initialize bidi_it.disp_pos. |
| @@ -200,8 +248,8 @@ | |||
| 200 | * dispextern.h (struct bidi_it): New member frame_window_p. | 248 | * dispextern.h (struct bidi_it): New member frame_window_p. |
| 201 | (bidi_init_it): Update prototypes. | 249 | (bidi_init_it): Update prototypes. |
| 202 | (display_prop_intangible_p): Update prototype. | 250 | (display_prop_intangible_p): Update prototype. |
| 203 | (compute_display_string_pos, compute_display_string_end): Declare | 251 | (compute_display_string_pos, compute_display_string_end): |
| 204 | prototypes. | 252 | Declare prototypes. |
| 205 | (struct bidi_it): New members nchars and disp_pos. ch_len is now | 253 | (struct bidi_it): New members nchars and disp_pos. ch_len is now |
| 206 | EMACS_INT. | 254 | EMACS_INT. |
| 207 | 255 | ||
diff --git a/src/alloc.c b/src/alloc.c index d9e00c3aeb4..cfbb79b2e61 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -190,17 +190,10 @@ static int total_free_floats, total_floats; | |||
| 190 | 190 | ||
| 191 | static char *spare_memory[7]; | 191 | static char *spare_memory[7]; |
| 192 | 192 | ||
| 193 | #ifndef SYSTEM_MALLOC | 193 | /* Amount of spare memory to keep in large reserve block, or to see |
| 194 | /* Amount of spare memory to keep in large reserve block. */ | 194 | whether this much is available when malloc fails on a larger request. */ |
| 195 | 195 | ||
| 196 | #define SPARE_MEMORY (1 << 14) | 196 | #define SPARE_MEMORY (1 << 14) |
| 197 | #endif | ||
| 198 | |||
| 199 | #ifdef SYSTEM_MALLOC | ||
| 200 | # define LARGE_REQUEST (1 << 14) | ||
| 201 | #else | ||
| 202 | # define LARGE_REQUEST SPARE_MEMORY | ||
| 203 | #endif | ||
| 204 | 197 | ||
| 205 | /* Number of extra blocks malloc should get when it needs more core. */ | 198 | /* Number of extra blocks malloc should get when it needs more core. */ |
| 206 | 199 | ||
| @@ -3289,9 +3282,9 @@ memory_full (size_t nbytes) | |||
| 3289 | { | 3282 | { |
| 3290 | /* Do not go into hysterics merely because a large request failed. */ | 3283 | /* Do not go into hysterics merely because a large request failed. */ |
| 3291 | int enough_free_memory = 0; | 3284 | int enough_free_memory = 0; |
| 3292 | if (LARGE_REQUEST < nbytes) | 3285 | if (SPARE_MEMORY < nbytes) |
| 3293 | { | 3286 | { |
| 3294 | void *p = malloc (LARGE_REQUEST); | 3287 | void *p = malloc (SPARE_MEMORY); |
| 3295 | if (p) | 3288 | if (p) |
| 3296 | { | 3289 | { |
| 3297 | free (p); | 3290 | free (p); |
diff --git a/src/frame.c b/src/frame.c index 6008ba9567a..68984a68d52 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -904,111 +904,6 @@ DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, | |||
| 904 | return selected_frame; | 904 | return selected_frame; |
| 905 | } | 905 | } |
| 906 | 906 | ||
| 907 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, | ||
| 908 | doc: /* Return the frame object that window WINDOW is on. */) | ||
| 909 | (Lisp_Object window) | ||
| 910 | { | ||
| 911 | CHECK_LIVE_WINDOW (window); | ||
| 912 | return XWINDOW (window)->frame; | ||
| 913 | } | ||
| 914 | |||
| 915 | DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, | ||
| 916 | doc: /* Returns the topmost, leftmost window of FRAME. | ||
| 917 | If omitted, FRAME defaults to the currently selected frame. */) | ||
| 918 | (Lisp_Object frame) | ||
| 919 | { | ||
| 920 | Lisp_Object w; | ||
| 921 | |||
| 922 | if (NILP (frame)) | ||
| 923 | w = SELECTED_FRAME ()->root_window; | ||
| 924 | else | ||
| 925 | { | ||
| 926 | CHECK_LIVE_FRAME (frame); | ||
| 927 | w = XFRAME (frame)->root_window; | ||
| 928 | } | ||
| 929 | while (NILP (XWINDOW (w)->buffer)) | ||
| 930 | { | ||
| 931 | if (! NILP (XWINDOW (w)->hchild)) | ||
| 932 | w = XWINDOW (w)->hchild; | ||
| 933 | else if (! NILP (XWINDOW (w)->vchild)) | ||
| 934 | w = XWINDOW (w)->vchild; | ||
| 935 | else | ||
| 936 | abort (); | ||
| 937 | } | ||
| 938 | return w; | ||
| 939 | } | ||
| 940 | |||
| 941 | DEFUN ("active-minibuffer-window", Factive_minibuffer_window, | ||
| 942 | Sactive_minibuffer_window, 0, 0, 0, | ||
| 943 | doc: /* Return the currently active minibuffer window, or nil if none. */) | ||
| 944 | (void) | ||
| 945 | { | ||
| 946 | return minibuf_level ? minibuf_window : Qnil; | ||
| 947 | } | ||
| 948 | |||
| 949 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, | ||
| 950 | doc: /* Returns the root-window of FRAME. | ||
| 951 | If omitted, FRAME defaults to the currently selected frame. */) | ||
| 952 | (Lisp_Object frame) | ||
| 953 | { | ||
| 954 | Lisp_Object window; | ||
| 955 | |||
| 956 | if (NILP (frame)) | ||
| 957 | window = SELECTED_FRAME ()->root_window; | ||
| 958 | else | ||
| 959 | { | ||
| 960 | CHECK_LIVE_FRAME (frame); | ||
| 961 | window = XFRAME (frame)->root_window; | ||
| 962 | } | ||
| 963 | |||
| 964 | return window; | ||
| 965 | } | ||
| 966 | |||
| 967 | DEFUN ("frame-selected-window", Fframe_selected_window, | ||
| 968 | Sframe_selected_window, 0, 1, 0, | ||
| 969 | doc: /* Return the selected window of FRAME. | ||
| 970 | FRAME defaults to the currently selected frame. */) | ||
| 971 | (Lisp_Object frame) | ||
| 972 | { | ||
| 973 | Lisp_Object window; | ||
| 974 | |||
| 975 | if (NILP (frame)) | ||
| 976 | window = SELECTED_FRAME ()->selected_window; | ||
| 977 | else | ||
| 978 | { | ||
| 979 | CHECK_LIVE_FRAME (frame); | ||
| 980 | window = XFRAME (frame)->selected_window; | ||
| 981 | } | ||
| 982 | |||
| 983 | return window; | ||
| 984 | } | ||
| 985 | |||
| 986 | DEFUN ("set-frame-selected-window", Fset_frame_selected_window, | ||
| 987 | Sset_frame_selected_window, 2, 3, 0, | ||
| 988 | doc: /* Set selected window of FRAME to WINDOW. | ||
| 989 | If FRAME is nil, use the selected frame. If FRAME is the | ||
| 990 | selected frame, this makes WINDOW the selected window. | ||
| 991 | Optional argument NORECORD non-nil means to neither change the | ||
| 992 | order of recently selected windows nor the buffer list. | ||
| 993 | Return WINDOW. */) | ||
| 994 | (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord) | ||
| 995 | { | ||
| 996 | if (NILP (frame)) | ||
| 997 | frame = selected_frame; | ||
| 998 | |||
| 999 | CHECK_LIVE_FRAME (frame); | ||
| 1000 | CHECK_LIVE_WINDOW (window); | ||
| 1001 | |||
| 1002 | if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) | ||
| 1003 | error ("In `set-frame-selected-window', WINDOW is not on FRAME"); | ||
| 1004 | |||
| 1005 | if (EQ (frame, selected_frame)) | ||
| 1006 | return Fselect_window (window, norecord); | ||
| 1007 | |||
| 1008 | return XFRAME (frame)->selected_window = window; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | |||
| 1012 | DEFUN ("frame-list", Fframe_list, Sframe_list, | 907 | DEFUN ("frame-list", Fframe_list, Sframe_list, |
| 1013 | 0, 0, 0, | 908 | 0, 0, 0, |
| 1014 | doc: /* Return a list of all live frames. */) | 909 | doc: /* Return a list of all live frames. */) |
| @@ -1265,6 +1160,17 @@ other_visible_frames (FRAME_PTR f) | |||
| 1265 | return 1; | 1160 | return 1; |
| 1266 | } | 1161 | } |
| 1267 | 1162 | ||
| 1163 | DEFUN ("other-visible-frames-p", Fother_visible_frames_p, Sother_visible_frames_p, 0, 1, 0, | ||
| 1164 | doc: /* Return t if there are other visible frames beside FRAME. | ||
| 1165 | FRAME defaults to the selected frame. */) | ||
| 1166 | (Lisp_Object frame) | ||
| 1167 | { | ||
| 1168 | if (NILP (frame)) | ||
| 1169 | frame = selected_frame; | ||
| 1170 | CHECK_LIVE_FRAME (frame); | ||
| 1171 | return other_visible_frames (XFRAME (frame)) ? Qt : Qnil; | ||
| 1172 | } | ||
| 1173 | |||
| 1268 | /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME | 1174 | /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME |
| 1269 | unconditionally. x_connection_closed and delete_terminal use | 1175 | unconditionally. x_connection_closed and delete_terminal use |
| 1270 | this. Any other value of FORCE implements the semantics | 1176 | this. Any other value of FORCE implements the semantics |
| @@ -4605,7 +4511,6 @@ automatically. See also `mouse-autoselect-window'. */); | |||
| 4605 | 4511 | ||
| 4606 | staticpro (&Vframe_list); | 4512 | staticpro (&Vframe_list); |
| 4607 | 4513 | ||
| 4608 | defsubr (&Sactive_minibuffer_window); | ||
| 4609 | defsubr (&Sframep); | 4514 | defsubr (&Sframep); |
| 4610 | defsubr (&Sframe_live_p); | 4515 | defsubr (&Sframe_live_p); |
| 4611 | defsubr (&Swindow_system); | 4516 | defsubr (&Swindow_system); |
| @@ -4613,14 +4518,10 @@ automatically. See also `mouse-autoselect-window'. */); | |||
| 4613 | defsubr (&Shandle_switch_frame); | 4518 | defsubr (&Shandle_switch_frame); |
| 4614 | defsubr (&Sselect_frame); | 4519 | defsubr (&Sselect_frame); |
| 4615 | defsubr (&Sselected_frame); | 4520 | defsubr (&Sselected_frame); |
| 4616 | defsubr (&Swindow_frame); | ||
| 4617 | defsubr (&Sframe_root_window); | ||
| 4618 | defsubr (&Sframe_first_window); | ||
| 4619 | defsubr (&Sframe_selected_window); | ||
| 4620 | defsubr (&Sset_frame_selected_window); | ||
| 4621 | defsubr (&Sframe_list); | 4521 | defsubr (&Sframe_list); |
| 4622 | defsubr (&Snext_frame); | 4522 | defsubr (&Snext_frame); |
| 4623 | defsubr (&Sprevious_frame); | 4523 | defsubr (&Sprevious_frame); |
| 4524 | defsubr (&Sother_visible_frames_p); | ||
| 4624 | defsubr (&Sdelete_frame); | 4525 | defsubr (&Sdelete_frame); |
| 4625 | defsubr (&Smouse_position); | 4526 | defsubr (&Smouse_position); |
| 4626 | defsubr (&Smouse_pixel_position); | 4527 | defsubr (&Smouse_pixel_position); |
diff --git a/src/lisp.h b/src/lisp.h index 1c1e3ec3708..c5f810a0746 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3215,16 +3215,12 @@ extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); | |||
| 3215 | extern Lisp_Object frame_buffer_predicate (Lisp_Object); | 3215 | extern Lisp_Object frame_buffer_predicate (Lisp_Object); |
| 3216 | EXFUN (Fselect_frame, 2); | 3216 | EXFUN (Fselect_frame, 2); |
| 3217 | EXFUN (Fselected_frame, 0); | 3217 | EXFUN (Fselected_frame, 0); |
| 3218 | EXFUN (Fwindow_frame, 1); | ||
| 3219 | EXFUN (Fframe_root_window, 1); | ||
| 3220 | EXFUN (Fframe_first_window, 1); | ||
| 3221 | EXFUN (Fmake_frame_visible, 1); | 3218 | EXFUN (Fmake_frame_visible, 1); |
| 3222 | EXFUN (Ficonify_frame, 1); | 3219 | EXFUN (Ficonify_frame, 1); |
| 3223 | EXFUN (Fframe_parameter, 2); | 3220 | EXFUN (Fframe_parameter, 2); |
| 3224 | EXFUN (Fmodify_frame_parameters, 2); | 3221 | EXFUN (Fmodify_frame_parameters, 2); |
| 3225 | EXFUN (Fraise_frame, 1); | 3222 | EXFUN (Fraise_frame, 1); |
| 3226 | EXFUN (Fredirect_frame_focus, 2); | 3223 | EXFUN (Fredirect_frame_focus, 2); |
| 3227 | EXFUN (Fset_frame_selected_window, 3); | ||
| 3228 | extern Lisp_Object frame_buffer_list (Lisp_Object); | 3224 | extern Lisp_Object frame_buffer_list (Lisp_Object); |
| 3229 | extern void frames_discard_buffer (Lisp_Object); | 3225 | extern void frames_discard_buffer (Lisp_Object); |
| 3230 | extern void set_frame_buffer_list (Lisp_Object, Lisp_Object); | 3226 | extern void set_frame_buffer_list (Lisp_Object, Lisp_Object); |
diff --git a/src/minibuf.c b/src/minibuf.c index ba8729bdff2..8f1987298b3 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -143,6 +143,14 @@ choose_minibuf_frame_1 (Lisp_Object ignore) | |||
| 143 | return Qnil; | 143 | return Qnil; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | DEFUN ("active-minibuffer-window", Factive_minibuffer_window, | ||
| 147 | Sactive_minibuffer_window, 0, 0, 0, | ||
| 148 | doc: /* Return the currently active minibuffer window, or nil if none. */) | ||
| 149 | (void) | ||
| 150 | { | ||
| 151 | return minibuf_level ? minibuf_window : Qnil; | ||
| 152 | } | ||
| 153 | |||
| 146 | DEFUN ("set-minibuffer-window", Fset_minibuffer_window, | 154 | DEFUN ("set-minibuffer-window", Fset_minibuffer_window, |
| 147 | Sset_minibuffer_window, 1, 1, 0, | 155 | Sset_minibuffer_window, 1, 1, 0, |
| 148 | doc: /* Specify which minibuffer window to use for the minibuffer. | 156 | doc: /* Specify which minibuffer window to use for the minibuffer. |
| @@ -2181,6 +2189,7 @@ properties. */); | |||
| 2181 | doc: /* Minibuffer keymap used for reading Lisp expressions. */); | 2189 | doc: /* Minibuffer keymap used for reading Lisp expressions. */); |
| 2182 | Vread_expression_map = Qnil; | 2190 | Vread_expression_map = Qnil; |
| 2183 | 2191 | ||
| 2192 | defsubr (&Sactive_minibuffer_window); | ||
| 2184 | defsubr (&Sset_minibuffer_window); | 2193 | defsubr (&Sset_minibuffer_window); |
| 2185 | defsubr (&Sread_from_minibuffer); | 2194 | defsubr (&Sread_from_minibuffer); |
| 2186 | defsubr (&Seval_minibuffer); | 2195 | defsubr (&Seval_minibuffer); |
diff --git a/src/window.c b/src/window.c index bc9f31e03e8..4e8b98a3237 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -94,76 +94,376 @@ static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); | |||
| 94 | 94 | ||
| 95 | This value is always the same as | 95 | This value is always the same as |
| 96 | FRAME_SELECTED_WINDOW (selected_frame). */ | 96 | FRAME_SELECTED_WINDOW (selected_frame). */ |
| 97 | |||
| 98 | Lisp_Object selected_window; | 97 | Lisp_Object selected_window; |
| 99 | 98 | ||
| 100 | /* A list of all windows for use by next_window and Fwindow_list. | 99 | /* A list of all windows for use by next_window and Fwindow_list. |
| 101 | Functions creating or deleting windows should invalidate this cache | 100 | Functions creating or deleting windows should invalidate this cache |
| 102 | by setting it to nil. */ | 101 | by setting it to nil. */ |
| 103 | |||
| 104 | Lisp_Object Vwindow_list; | 102 | Lisp_Object Vwindow_list; |
| 105 | 103 | ||
| 106 | /* The mini-buffer window of the selected frame. | 104 | /* The mini-buffer window of the selected frame. |
| 107 | Note that you cannot test for mini-bufferness of an arbitrary window | 105 | Note that you cannot test for mini-bufferness of an arbitrary window |
| 108 | by comparing against this; but you can test for mini-bufferness of | 106 | by comparing against this; but you can test for mini-bufferness of |
| 109 | the selected window. */ | 107 | the selected window. */ |
| 110 | |||
| 111 | Lisp_Object minibuf_window; | 108 | Lisp_Object minibuf_window; |
| 112 | 109 | ||
| 113 | /* Non-nil means it is the window whose mode line should be | 110 | /* Non-nil means it is the window whose mode line should be |
| 114 | shown as the selected window when the minibuffer is selected. */ | 111 | shown as the selected window when the minibuffer is selected. */ |
| 115 | |||
| 116 | Lisp_Object minibuf_selected_window; | 112 | Lisp_Object minibuf_selected_window; |
| 117 | 113 | ||
| 118 | /* Hook run at end of temp_output_buffer_show. */ | 114 | /* Hook run at end of temp_output_buffer_show. */ |
| 119 | |||
| 120 | static Lisp_Object Qtemp_buffer_show_hook; | 115 | static Lisp_Object Qtemp_buffer_show_hook; |
| 121 | 116 | ||
| 122 | /* Incremented for each window created. */ | 117 | /* Incremented for each window created. */ |
| 123 | |||
| 124 | static int sequence_number; | 118 | static int sequence_number; |
| 125 | 119 | ||
| 126 | /* Nonzero after init_window_once has finished. */ | 120 | /* Nonzero after init_window_once has finished. */ |
| 127 | |||
| 128 | static int window_initialized; | 121 | static int window_initialized; |
| 129 | 122 | ||
| 130 | /* Hook to run when window config changes. */ | 123 | /* Hook to run when window config changes. */ |
| 131 | |||
| 132 | static Lisp_Object Qwindow_configuration_change_hook; | 124 | static Lisp_Object Qwindow_configuration_change_hook; |
| 133 | /* Incremented by 1 whenever a window is deleted. */ | ||
| 134 | 125 | ||
| 126 | /* Incremented by 1 whenever a window is deleted. */ | ||
| 135 | static int window_deletion_count; | 127 | static int window_deletion_count; |
| 136 | 128 | ||
| 137 | /* Used by the function window_scroll_pixel_based */ | 129 | /* Used by the function window_scroll_pixel_based */ |
| 138 | |||
| 139 | static int window_scroll_pixel_based_preserve_x; | 130 | static int window_scroll_pixel_based_preserve_x; |
| 140 | static int window_scroll_pixel_based_preserve_y; | 131 | static int window_scroll_pixel_based_preserve_y; |
| 141 | 132 | ||
| 142 | /* Same for window_scroll_line_based. */ | 133 | /* Same for window_scroll_line_based. */ |
| 143 | |||
| 144 | static int window_scroll_preserve_hpos; | 134 | static int window_scroll_preserve_hpos; |
| 145 | static int window_scroll_preserve_vpos; | 135 | static int window_scroll_preserve_vpos; |
| 136 | |||
| 137 | static struct window * | ||
| 138 | decode_window (register Lisp_Object window) | ||
| 139 | { | ||
| 140 | if (NILP (window)) | ||
| 141 | return XWINDOW (selected_window); | ||
| 146 | 142 | ||
| 147 | #if 0 /* This isn't used anywhere. */ | 143 | CHECK_LIVE_WINDOW (window); |
| 148 | /* Nonzero means we can split a frame even if it is "unsplittable". */ | 144 | return XWINDOW (window); |
| 149 | static int inhibit_frame_unsplittable; | 145 | } |
| 150 | #endif | 146 | |
| 147 | static struct window * | ||
| 148 | decode_any_window (register Lisp_Object window) | ||
| 149 | { | ||
| 150 | if (NILP (window)) | ||
| 151 | return XWINDOW (selected_window); | ||
| 152 | |||
| 153 | CHECK_WINDOW (window); | ||
| 154 | return XWINDOW (window); | ||
| 155 | } | ||
| 151 | 156 | ||
| 152 | |||
| 153 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | 157 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, |
| 154 | doc: /* Return t if OBJECT is a window. */) | 158 | doc: /* Return t if OBJECT is a window and nil otherwise. */) |
| 155 | (Lisp_Object object) | 159 | (Lisp_Object object) |
| 156 | { | 160 | { |
| 157 | return WINDOWP (object) ? Qt : Qnil; | 161 | return WINDOWP (object) ? Qt : Qnil; |
| 158 | } | 162 | } |
| 159 | 163 | ||
| 160 | DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, | 164 | DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, |
| 161 | doc: /* Return t if OBJECT is a window which is currently visible. */) | 165 | doc: /* Return t if OBJECT is a live window and nil otherwise. |
| 166 | A live window is a window that displays a buffer. */) | ||
| 162 | (Lisp_Object object) | 167 | (Lisp_Object object) |
| 163 | { | 168 | { |
| 164 | return WINDOW_LIVE_P (object) ? Qt : Qnil; | 169 | return WINDOW_LIVE_P (object) ? Qt : Qnil; |
| 165 | } | 170 | } |
| 171 | |||
| 172 | /* Frames and windows. */ | ||
| 173 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, | ||
| 174 | doc: /* Return the frame that window WINDOW is on. | ||
| 175 | WINDOW can be any window and defaults to the selected one. */) | ||
| 176 | (Lisp_Object window) | ||
| 177 | { | ||
| 178 | return decode_any_window (window)->frame; | ||
| 179 | } | ||
| 180 | |||
| 181 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, | ||
| 182 | doc: /* Return the root window of FRAME_OR_WINDOW. | ||
| 183 | If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. | ||
| 184 | Else if FRAME_OR_WINDOW denotes any window, return the root window of | ||
| 185 | that window's frame. If FRAME_OR_WINDOW denotes a live frame, return | ||
| 186 | the root window of that frame. */) | ||
| 187 | (Lisp_Object frame_or_window) | ||
| 188 | { | ||
| 189 | Lisp_Object window; | ||
| 190 | |||
| 191 | if (NILP (frame_or_window)) | ||
| 192 | window = SELECTED_FRAME ()->root_window; | ||
| 193 | else if (WINDOWP (frame_or_window)) | ||
| 194 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; | ||
| 195 | else | ||
| 196 | { | ||
| 197 | CHECK_LIVE_FRAME (frame_or_window); | ||
| 198 | window = XFRAME (frame_or_window)->root_window; | ||
| 199 | } | ||
| 200 | |||
| 201 | return window; | ||
| 202 | } | ||
| 203 | |||
| 204 | DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, | ||
| 205 | doc: /* Return the window used now for minibuffers. | ||
| 206 | If the optional argument FRAME is specified, return the minibuffer window | ||
| 207 | used by that frame. */) | ||
| 208 | (Lisp_Object frame) | ||
| 209 | { | ||
| 210 | if (NILP (frame)) | ||
| 211 | frame = selected_frame; | ||
| 212 | CHECK_LIVE_FRAME (frame); | ||
| 213 | return FRAME_MINIBUF_WINDOW (XFRAME (frame)); | ||
| 214 | } | ||
| 215 | |||
| 216 | DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, | ||
| 217 | Swindow_minibuffer_p, 0, 1, 0, | ||
| 218 | doc: /* Return non-nil if WINDOW is a minibuffer window. | ||
| 219 | WINDOW can be any window and defaults to the selected one. */) | ||
| 220 | (Lisp_Object window) | ||
| 221 | { | ||
| 222 | return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; | ||
| 223 | } | ||
| 224 | |||
| 225 | /* Don't move this to window.el - this must be a safe routine. */ | ||
| 226 | DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, | ||
| 227 | doc: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW. | ||
| 228 | If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. | ||
| 229 | Else if FRAME_OR_WINDOW denotes any window, return the first window of | ||
| 230 | that window's frame. If FRAME_OR_WINDOW denotes a live frame, return | ||
| 231 | the first window of that frame. */) | ||
| 232 | (Lisp_Object frame_or_window) | ||
| 233 | { | ||
| 234 | Lisp_Object window; | ||
| 235 | |||
| 236 | if (NILP (frame_or_window)) | ||
| 237 | window = SELECTED_FRAME ()->root_window; | ||
| 238 | else if (WINDOWP (frame_or_window)) | ||
| 239 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; | ||
| 240 | else | ||
| 241 | { | ||
| 242 | CHECK_LIVE_FRAME (frame_or_window); | ||
| 243 | window = XFRAME (frame_or_window)->root_window; | ||
| 244 | } | ||
| 245 | |||
| 246 | while (NILP (XWINDOW (window)->buffer)) | ||
| 247 | { | ||
| 248 | if (! NILP (XWINDOW (window)->hchild)) | ||
| 249 | window = XWINDOW (window)->hchild; | ||
| 250 | else if (! NILP (XWINDOW (window)->vchild)) | ||
| 251 | window = XWINDOW (window)->vchild; | ||
| 252 | else | ||
| 253 | abort (); | ||
| 254 | } | ||
| 255 | |||
| 256 | return window; | ||
| 257 | } | ||
| 258 | |||
| 259 | DEFUN ("frame-selected-window", Fframe_selected_window, | ||
| 260 | Sframe_selected_window, 0, 1, 0, | ||
| 261 | doc: /* Return the selected window of FRAME_OR_WINDOW. | ||
| 262 | If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. | ||
| 263 | Else if FRAME_OR_WINDOW denotes any window, return the selected window | ||
| 264 | of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return | ||
| 265 | the selected window of that frame. */) | ||
| 266 | (Lisp_Object frame_or_window) | ||
| 267 | { | ||
| 268 | Lisp_Object window; | ||
| 269 | |||
| 270 | if (NILP (frame_or_window)) | ||
| 271 | window = SELECTED_FRAME ()->selected_window; | ||
| 272 | else if (WINDOWP (frame_or_window)) | ||
| 273 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window; | ||
| 274 | else | ||
| 275 | { | ||
| 276 | CHECK_LIVE_FRAME (frame_or_window); | ||
| 277 | window = XFRAME (frame_or_window)->selected_window; | ||
| 278 | } | ||
| 279 | |||
| 280 | return window; | ||
| 281 | } | ||
| 282 | |||
| 283 | DEFUN ("set-frame-selected-window", Fset_frame_selected_window, | ||
| 284 | Sset_frame_selected_window, 2, 3, 0, | ||
| 285 | doc: /* Set selected window of FRAME to WINDOW. | ||
| 286 | FRAME must be a live frame and defaults to the selected one. If FRAME | ||
| 287 | is the selected frame, this makes WINDOW the selected window. Optional | ||
| 288 | argument NORECORD non-nil means to neither change the order of recently | ||
| 289 | selected windows nor the buffer list. WINDOW must denote a live window. | ||
| 290 | Return WINDOW. */) | ||
| 291 | (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord) | ||
| 292 | { | ||
| 293 | if (NILP (frame)) | ||
| 294 | frame = selected_frame; | ||
| 295 | |||
| 296 | CHECK_LIVE_FRAME (frame); | ||
| 297 | CHECK_LIVE_WINDOW (window); | ||
| 298 | |||
| 299 | if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) | ||
| 300 | error ("In `set-frame-selected-window', WINDOW is not on FRAME"); | ||
| 301 | |||
| 302 | if (EQ (frame, selected_frame)) | ||
| 303 | return Fselect_window (window, norecord); | ||
| 304 | else | ||
| 305 | return XFRAME (frame)->selected_window = window; | ||
| 306 | } | ||
| 307 | |||
| 308 | DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, | ||
| 309 | doc: /* Return the selected window. | ||
| 310 | The selected window is the window in which the standard cursor for | ||
| 311 | selected windows appears and to which many commands apply. */) | ||
| 312 | (void) | ||
| 313 | { | ||
| 314 | return selected_window; | ||
| 315 | } | ||
| 316 | |||
| 317 | /* If select_window is called with inhibit_point_swap non-zero it will | ||
| 318 | not store point of the old selected window's buffer back into that | ||
| 319 | window's pointm slot. This is needed by Fset_window_configuration to | ||
| 320 | avoid that the display routine is called with selected_window set to | ||
| 321 | Qnil causing a subsequent crash. */ | ||
| 322 | static Lisp_Object | ||
| 323 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | ||
| 324 | { | ||
| 325 | register struct window *w; | ||
| 326 | register struct window *ow; | ||
| 327 | struct frame *sf; | ||
| 328 | |||
| 329 | CHECK_LIVE_WINDOW (window); | ||
| 330 | |||
| 331 | w = XWINDOW (window); | ||
| 332 | w->frozen_window_start_p = 0; | ||
| 333 | |||
| 334 | if (NILP (norecord)) | ||
| 335 | { | ||
| 336 | ++window_select_count; | ||
| 337 | XSETFASTINT (w->use_time, window_select_count); | ||
| 338 | record_buffer (w->buffer); | ||
| 339 | } | ||
| 340 | |||
| 341 | if (EQ (window, selected_window) && !inhibit_point_swap) | ||
| 342 | return window; | ||
| 343 | |||
| 344 | sf = SELECTED_FRAME (); | ||
| 345 | if (XFRAME (WINDOW_FRAME (w)) != sf) | ||
| 346 | { | ||
| 347 | XFRAME (WINDOW_FRAME (w))->selected_window = window; | ||
| 348 | /* Use this rather than Fhandle_switch_frame | ||
| 349 | so that FRAME_FOCUS_FRAME is moved appropriately as we | ||
| 350 | move around in the state where a minibuffer in a separate | ||
| 351 | frame is active. */ | ||
| 352 | Fselect_frame (WINDOW_FRAME (w), norecord); | ||
| 353 | /* Fselect_frame called us back so we've done all the work already. */ | ||
| 354 | eassert (EQ (window, selected_window)); | ||
| 355 | return window; | ||
| 356 | } | ||
| 357 | else | ||
| 358 | sf->selected_window = window; | ||
| 359 | |||
| 360 | /* Store the current buffer's actual point into the | ||
| 361 | old selected window. It belongs to that window, | ||
| 362 | and when the window is not selected, must be in the window. */ | ||
| 363 | if (!inhibit_point_swap) | ||
| 364 | { | ||
| 365 | ow = XWINDOW (selected_window); | ||
| 366 | if (! NILP (ow->buffer)) | ||
| 367 | set_marker_both (ow->pointm, ow->buffer, | ||
| 368 | BUF_PT (XBUFFER (ow->buffer)), | ||
| 369 | BUF_PT_BYTE (XBUFFER (ow->buffer))); | ||
| 370 | } | ||
| 371 | |||
| 372 | selected_window = window; | ||
| 373 | |||
| 374 | Fset_buffer (w->buffer); | ||
| 375 | |||
| 376 | BVAR (XBUFFER (w->buffer), last_selected_window) = window; | ||
| 377 | |||
| 378 | /* Go to the point recorded in the window. | ||
| 379 | This is important when the buffer is in more | ||
| 380 | than one window. It also matters when | ||
| 381 | redisplay_window has altered point after scrolling, | ||
| 382 | because it makes the change only in the window. */ | ||
| 383 | { | ||
| 384 | register EMACS_INT new_point = marker_position (w->pointm); | ||
| 385 | if (new_point < BEGV) | ||
| 386 | SET_PT (BEGV); | ||
| 387 | else if (new_point > ZV) | ||
| 388 | SET_PT (ZV); | ||
| 389 | else | ||
| 390 | SET_PT (new_point); | ||
| 391 | } | ||
| 392 | |||
| 393 | windows_or_buffers_changed++; | ||
| 394 | return window; | ||
| 395 | } | ||
| 396 | |||
| 397 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | ||
| 398 | doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | ||
| 399 | Also make WINDOW's buffer current and make WINDOW the frame's selected | ||
| 400 | window. Return WINDOW. | ||
| 401 | |||
| 402 | Optional second arg NORECORD non-nil means do not put this buffer at the | ||
| 403 | front of the buffer list and do not make this window the most recently | ||
| 404 | selected one. | ||
| 405 | |||
| 406 | Note that the main editor command loop sets the current buffer to the | ||
| 407 | buffer of the selected window before each command. */) | ||
| 408 | (register Lisp_Object window, Lisp_Object norecord) | ||
| 409 | { | ||
| 410 | return select_window (window, norecord, 0); | ||
| 411 | } | ||
| 412 | |||
| 413 | DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, | ||
| 414 | doc: /* Return the buffer that WINDOW is displaying. | ||
| 415 | WINDOW can be any window and defaults to the selected one. | ||
| 416 | If WINDOW is an internal window return nil. */) | ||
| 417 | (Lisp_Object window) | ||
| 418 | { | ||
| 419 | return decode_any_window (window)->buffer; | ||
| 420 | } | ||
| 421 | |||
| 422 | DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, | ||
| 423 | doc: /* Return WINDOW's parent window. | ||
| 424 | WINDOW can be any window and defaults to the selected one. | ||
| 425 | Return nil if WINDOW has no parent. */) | ||
| 426 | (Lisp_Object window) | ||
| 427 | { | ||
| 428 | return decode_any_window (window)->parent; | ||
| 429 | } | ||
| 430 | |||
| 431 | DEFUN ("window-vchild", Fwindow_vchild, Swindow_vchild, 0, 1, 0, | ||
| 432 | doc: /* Return WINDOW's first vertical child window. | ||
| 433 | WINDOW can be any window and defaults to the selected one. | ||
| 434 | Return nil if WINDOW has no vertical child. */) | ||
| 435 | (Lisp_Object window) | ||
| 436 | { | ||
| 437 | return decode_any_window (window)->vchild; | ||
| 438 | } | ||
| 439 | |||
| 440 | DEFUN ("window-hchild", Fwindow_hchild, Swindow_hchild, 0, 1, 0, | ||
| 441 | doc: /* Return WINDOW's first horizontal child window. | ||
| 442 | WINDOW can be any window and defaults to the selected one. | ||
| 443 | Return nil if WINDOW has no horizontal child. */) | ||
| 444 | (Lisp_Object window) | ||
| 445 | { | ||
| 446 | return decode_any_window (window)->hchild; | ||
| 447 | } | ||
| 448 | |||
| 449 | DEFUN ("window-next", Fwindow_next, Swindow_next, 0, 1, 0, | ||
| 450 | doc: /* Return WINDOW's right sibling window. | ||
| 451 | WINDOW can be any window and defaults to the selected one. | ||
| 452 | Return nil if WINDOW has no right sibling. */) | ||
| 453 | (Lisp_Object window) | ||
| 454 | { | ||
| 455 | return decode_any_window (window)->next; | ||
| 456 | } | ||
| 166 | 457 | ||
| 458 | DEFUN ("window-prev", Fwindow_prev, Swindow_prev, 0, 1, 0, | ||
| 459 | doc: /* Return WINDOW's left sibling window. | ||
| 460 | WINDOW can be any window and defaults to the selected one. | ||
| 461 | Return nil if WINDOW has no left sibling. */) | ||
| 462 | (Lisp_Object window) | ||
| 463 | { | ||
| 464 | return decode_any_window (window)->prev; | ||
| 465 | } | ||
| 466 | |||
| 167 | Lisp_Object | 467 | Lisp_Object |
| 168 | make_window (void) | 468 | make_window (void) |
| 169 | { | 469 | { |
| @@ -217,36 +517,6 @@ make_window (void) | |||
| 217 | return val; | 517 | return val; |
| 218 | } | 518 | } |
| 219 | 519 | ||
| 220 | DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, | ||
| 221 | doc: /* Return the window that the cursor now appears in and commands apply to. */) | ||
| 222 | (void) | ||
| 223 | { | ||
| 224 | return selected_window; | ||
| 225 | } | ||
| 226 | |||
| 227 | DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, | ||
| 228 | doc: /* Return the window used now for minibuffers. | ||
| 229 | If the optional argument FRAME is specified, return the minibuffer window | ||
| 230 | used by that frame. */) | ||
| 231 | (Lisp_Object frame) | ||
| 232 | { | ||
| 233 | if (NILP (frame)) | ||
| 234 | frame = selected_frame; | ||
| 235 | CHECK_LIVE_FRAME (frame); | ||
| 236 | return FRAME_MINIBUF_WINDOW (XFRAME (frame)); | ||
| 237 | } | ||
| 238 | |||
| 239 | DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, | ||
| 240 | Swindow_minibuffer_p, 0, 1, 0, | ||
| 241 | doc: /* Return non-nil if WINDOW is a minibuffer window. | ||
| 242 | WINDOW defaults to the selected window. */) | ||
| 243 | (Lisp_Object window) | ||
| 244 | { | ||
| 245 | struct window *w = decode_window (window); | ||
| 246 | return MINI_WINDOW_P (w) ? Qt : Qnil; | ||
| 247 | } | ||
| 248 | |||
| 249 | |||
| 250 | DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, | 520 | DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, |
| 251 | Spos_visible_in_window_p, 0, 3, 0, | 521 | Spos_visible_in_window_p, 0, 3, 0, |
| 252 | doc: /* Return non-nil if position POS is currently on the frame in WINDOW. | 522 | doc: /* Return non-nil if position POS is currently on the frame in WINDOW. |
| @@ -424,34 +694,6 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 424 | 694 | ||
| 425 | 695 | ||
| 426 | 696 | ||
| 427 | static struct window * | ||
| 428 | decode_window (register Lisp_Object window) | ||
| 429 | { | ||
| 430 | if (NILP (window)) | ||
| 431 | return XWINDOW (selected_window); | ||
| 432 | |||
| 433 | CHECK_LIVE_WINDOW (window); | ||
| 434 | return XWINDOW (window); | ||
| 435 | } | ||
| 436 | |||
| 437 | static struct window * | ||
| 438 | decode_any_window (register Lisp_Object window) | ||
| 439 | { | ||
| 440 | if (NILP (window)) | ||
| 441 | return XWINDOW (selected_window); | ||
| 442 | |||
| 443 | CHECK_WINDOW (window); | ||
| 444 | return XWINDOW (window); | ||
| 445 | } | ||
| 446 | |||
| 447 | DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, | ||
| 448 | doc: /* Return the buffer that WINDOW is displaying. | ||
| 449 | WINDOW defaults to the selected window. */) | ||
| 450 | (Lisp_Object window) | ||
| 451 | { | ||
| 452 | return decode_window (window)->buffer; | ||
| 453 | } | ||
| 454 | |||
| 455 | DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0, | 697 | DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0, |
| 456 | doc: /* Return the number of lines in WINDOW. | 698 | doc: /* Return the number of lines in WINDOW. |
| 457 | WINDOW defaults to the selected window. | 699 | WINDOW defaults to the selected window. |
| @@ -3496,106 +3738,6 @@ This function runs `window-scroll-functions' before running | |||
| 3496 | return Qnil; | 3738 | return Qnil; |
| 3497 | } | 3739 | } |
| 3498 | 3740 | ||
| 3499 | /* If select_window is called with inhibit_point_swap non-zero it will | ||
| 3500 | not store point of the old selected window's buffer back into that | ||
| 3501 | window's pointm slot. This is needed by Fset_window_configuration to | ||
| 3502 | avoid that the display routine is called with selected_window set to | ||
| 3503 | Qnil causing a subsequent crash. */ | ||
| 3504 | |||
| 3505 | static Lisp_Object | ||
| 3506 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | ||
| 3507 | { | ||
| 3508 | register struct window *w; | ||
| 3509 | register struct window *ow; | ||
| 3510 | struct frame *sf; | ||
| 3511 | |||
| 3512 | CHECK_LIVE_WINDOW (window); | ||
| 3513 | |||
| 3514 | w = XWINDOW (window); | ||
| 3515 | w->frozen_window_start_p = 0; | ||
| 3516 | |||
| 3517 | if (NILP (norecord)) | ||
| 3518 | { | ||
| 3519 | ++window_select_count; | ||
| 3520 | XSETFASTINT (w->use_time, window_select_count); | ||
| 3521 | record_buffer (w->buffer); | ||
| 3522 | } | ||
| 3523 | |||
| 3524 | if (EQ (window, selected_window) && !inhibit_point_swap) | ||
| 3525 | return window; | ||
| 3526 | |||
| 3527 | sf = SELECTED_FRAME (); | ||
| 3528 | if (XFRAME (WINDOW_FRAME (w)) != sf) | ||
| 3529 | { | ||
| 3530 | XFRAME (WINDOW_FRAME (w))->selected_window = window; | ||
| 3531 | /* Use this rather than Fhandle_switch_frame | ||
| 3532 | so that FRAME_FOCUS_FRAME is moved appropriately as we | ||
| 3533 | move around in the state where a minibuffer in a separate | ||
| 3534 | frame is active. */ | ||
| 3535 | Fselect_frame (WINDOW_FRAME (w), norecord); | ||
| 3536 | /* Fselect_frame called us back so we've done all the work already. */ | ||
| 3537 | eassert (EQ (window, selected_window)); | ||
| 3538 | return window; | ||
| 3539 | } | ||
| 3540 | else | ||
| 3541 | sf->selected_window = window; | ||
| 3542 | |||
| 3543 | /* Store the current buffer's actual point into the | ||
| 3544 | old selected window. It belongs to that window, | ||
| 3545 | and when the window is not selected, must be in the window. */ | ||
| 3546 | if (!inhibit_point_swap) | ||
| 3547 | { | ||
| 3548 | ow = XWINDOW (selected_window); | ||
| 3549 | if (! NILP (ow->buffer)) | ||
| 3550 | set_marker_both (ow->pointm, ow->buffer, | ||
| 3551 | BUF_PT (XBUFFER (ow->buffer)), | ||
| 3552 | BUF_PT_BYTE (XBUFFER (ow->buffer))); | ||
| 3553 | } | ||
| 3554 | |||
| 3555 | selected_window = window; | ||
| 3556 | |||
| 3557 | Fset_buffer (w->buffer); | ||
| 3558 | |||
| 3559 | BVAR (XBUFFER (w->buffer), last_selected_window) = window; | ||
| 3560 | |||
| 3561 | /* Go to the point recorded in the window. | ||
| 3562 | This is important when the buffer is in more | ||
| 3563 | than one window. It also matters when | ||
| 3564 | redisplay_window has altered point after scrolling, | ||
| 3565 | because it makes the change only in the window. */ | ||
| 3566 | { | ||
| 3567 | register EMACS_INT new_point = marker_position (w->pointm); | ||
| 3568 | if (new_point < BEGV) | ||
| 3569 | SET_PT (BEGV); | ||
| 3570 | else if (new_point > ZV) | ||
| 3571 | SET_PT (ZV); | ||
| 3572 | else | ||
| 3573 | SET_PT (new_point); | ||
| 3574 | } | ||
| 3575 | |||
| 3576 | windows_or_buffers_changed++; | ||
| 3577 | return window; | ||
| 3578 | } | ||
| 3579 | |||
| 3580 | |||
| 3581 | /* Note that selected_window can be nil when this is called from | ||
| 3582 | Fset_window_configuration. */ | ||
| 3583 | |||
| 3584 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | ||
| 3585 | doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | ||
| 3586 | If WINDOW is not already selected, make WINDOW's buffer current | ||
| 3587 | and make WINDOW the frame's selected window. Return WINDOW. | ||
| 3588 | Optional second arg NORECORD non-nil means do not put this buffer | ||
| 3589 | at the front of the list of recently selected ones and do not | ||
| 3590 | make this window the most recently selected one. | ||
| 3591 | |||
| 3592 | Note that the main editor command loop selects the buffer of the | ||
| 3593 | selected window before each command. */) | ||
| 3594 | (register Lisp_Object window, Lisp_Object norecord) | ||
| 3595 | { | ||
| 3596 | return select_window (window, norecord, 0); | ||
| 3597 | } | ||
| 3598 | |||
| 3599 | static Lisp_Object | 3741 | static Lisp_Object |
| 3600 | select_window_norecord (Lisp_Object window) | 3742 | select_window_norecord (Lisp_Object window) |
| 3601 | { | 3743 | { |
| @@ -7125,9 +7267,19 @@ frame to be redrawn only if it is a tty frame. */); | |||
| 7125 | defsubr (&Swindow_minibuffer_p); | 7267 | defsubr (&Swindow_minibuffer_p); |
| 7126 | defsubr (&Swindowp); | 7268 | defsubr (&Swindowp); |
| 7127 | defsubr (&Swindow_live_p); | 7269 | defsubr (&Swindow_live_p); |
| 7270 | defsubr (&Swindow_frame); | ||
| 7271 | defsubr (&Sframe_root_window); | ||
| 7272 | defsubr (&Sframe_first_window); | ||
| 7273 | defsubr (&Sframe_selected_window); | ||
| 7274 | defsubr (&Sset_frame_selected_window); | ||
| 7128 | defsubr (&Spos_visible_in_window_p); | 7275 | defsubr (&Spos_visible_in_window_p); |
| 7129 | defsubr (&Swindow_line_height); | 7276 | defsubr (&Swindow_line_height); |
| 7130 | defsubr (&Swindow_buffer); | 7277 | defsubr (&Swindow_buffer); |
| 7278 | defsubr (&Swindow_parent); | ||
| 7279 | defsubr (&Swindow_vchild); | ||
| 7280 | defsubr (&Swindow_hchild); | ||
| 7281 | defsubr (&Swindow_next); | ||
| 7282 | defsubr (&Swindow_prev); | ||
| 7131 | defsubr (&Swindow_height); | 7283 | defsubr (&Swindow_height); |
| 7132 | defsubr (&Swindow_width); | 7284 | defsubr (&Swindow_width); |
| 7133 | defsubr (&Swindow_full_width_p); | 7285 | defsubr (&Swindow_full_width_p); |
diff --git a/src/window.h b/src/window.h index b1f6560445e..96e30d98d24 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -844,11 +844,15 @@ struct glyph *get_phys_cursor_glyph (struct window *w); | |||
| 844 | extern Lisp_Object Qwindowp, Qwindow_live_p; | 844 | extern Lisp_Object Qwindowp, Qwindow_live_p; |
| 845 | extern Lisp_Object Vwindow_list; | 845 | extern Lisp_Object Vwindow_list; |
| 846 | 846 | ||
| 847 | EXFUN (Fselected_window, 0); | ||
| 848 | EXFUN (Fwindow_minibuffer_p, 1); | ||
| 849 | EXFUN (Fdelete_window, 1); | ||
| 850 | EXFUN (Fwindow_buffer, 1); | 847 | EXFUN (Fwindow_buffer, 1); |
| 848 | EXFUN (Fwindow_frame, 1); | ||
| 851 | EXFUN (Fget_buffer_window, 2); | 849 | EXFUN (Fget_buffer_window, 2); |
| 850 | EXFUN (Fwindow_minibuffer_p, 1); | ||
| 851 | EXFUN (Fselected_window, 0); | ||
| 852 | EXFUN (Fframe_root_window, 1); | ||
| 853 | EXFUN (Fframe_first_window, 1); | ||
| 854 | EXFUN (Fset_frame_selected_window, 3); | ||
| 855 | EXFUN (Fdelete_window, 1); | ||
| 852 | EXFUN (Fset_window_configuration, 1); | 856 | EXFUN (Fset_window_configuration, 1); |
| 853 | EXFUN (Fcurrent_window_configuration, 1); | 857 | EXFUN (Fcurrent_window_configuration, 1); |
| 854 | extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); | 858 | extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); |