diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/.gdbinit | 6 | ||||
-rw-r--r-- | src/ChangeLog | 321 | ||||
-rw-r--r-- | src/alloc.c | 73 | ||||
-rw-r--r-- | src/buffer.c | 52 | ||||
-rw-r--r-- | src/coding.c | 71 | ||||
-rw-r--r-- | src/dired.c | 8 | ||||
-rw-r--r-- | src/editfns.c | 67 | ||||
-rw-r--r-- | src/fileio.c | 45 | ||||
-rw-r--r-- | src/fns.c | 2 | ||||
-rw-r--r-- | src/frame.c | 13 | ||||
-rw-r--r-- | src/image.c | 2 | ||||
-rw-r--r-- | src/keyboard.c | 245 | ||||
-rw-r--r-- | src/mac.c | 22 | ||||
-rw-r--r-- | src/macfns.c | 98 | ||||
-rw-r--r-- | src/macselect.c | 42 | ||||
-rw-r--r-- | src/macterm.c | 57 | ||||
-rw-r--r-- | src/macterm.h | 17 | ||||
-rw-r--r-- | src/print.c | 9 | ||||
-rw-r--r-- | src/process.c | 16 | ||||
-rw-r--r-- | src/puresize.h | 2 | ||||
-rw-r--r-- | src/w32.c | 22 | ||||
-rw-r--r-- | src/w32.h | 3 | ||||
-rw-r--r-- | src/w32fns.c | 58 | ||||
-rw-r--r-- | src/w32menu.c | 6 | ||||
-rw-r--r-- | src/w32term.c | 40 | ||||
-rw-r--r-- | src/window.c | 15 | ||||
-rw-r--r-- | src/xdisp.c | 62 | ||||
-rw-r--r-- | src/xfaces.c | 6 | ||||
-rw-r--r-- | src/xfns.c | 11 | ||||
-rw-r--r-- | src/xselect.c | 51 | ||||
-rw-r--r-- | src/xterm.c | 64 | ||||
-rw-r--r-- | src/xterm.h | 6 |
32 files changed, 1062 insertions, 450 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index acdb959a869..5dc126f8d36 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -164,6 +164,10 @@ define pitx if ($it->current.pos.charpos != $it->current.pos.bytepos) printf "[%d]", $it->current.pos.bytepos end + printf " pos=%d", $it->position.charpos + if ($it->position.charpos != $it->position.bytepos) + printf "[%d]", $it->position.bytepos + end printf " start=%d", $it->start.pos.charpos if ($it->start.pos.charpos != $it->start.pos.bytepos) printf "[%d]", $it->start.pos.bytepos @@ -218,7 +222,7 @@ define pitx printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent printf "\n" set $i = 0 - while ($i < $it->sp) + while ($i < $it->sp && $i < 4) set $e = $it->stack[$i] printf "stack[%d]: ", $i output $e->method diff --git a/src/ChangeLog b/src/ChangeLog index 79271fe23fa..c7a065c091e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,308 @@ +2006-08-27 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * alloc.c (BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Undo previous + change. Move mutex lock/unlock operations inside BLOCK_INPUT. + + * dired.c (directory_files_internal_unwind, directory_files_internal) + (file_name_completion): Add BLOCK_INPUT around opendir/closedir. + + * image.c [MAC_OS] (image_load_qt_1): Use ComponentResult instead + of OSErr. + + * keyboard.c (in_sighandler): Remove variable. + (Fcurrent_idle_time): Add missing `doc:'. + (input_available_signal, init_keyboard): Undo previous change. + + * keyboard.h (in_sighandler): Remove extern. + + * mac.c (create_apple_event_from_event_ref, select) + (Fmac_get_file_creator, Fmac_get_file_type, Fmac_set_file_creator) + (Fmac_set_file_type, cfstring_create_normalized) + (mac_get_system_locale, select_and_poll_event, sys_select): Use + OSStatus instead of OSErr. + + * macfns.c [TARGET_API_MAC_CARBON] (mac_update_proxy_icon): Don't + use FRAME_FILE_NAME. Use (FS)UpdateAlias. + (Fx_create_frame): Apply 2006-07-03 for xfns.c. + + * macselect.c (get_scrap_from_symbol, clear_scrap, put_scrap_string) + (put_scrap_private_timestamp, scrap_has_target_type, get_scrap_string) + (get_scrap_private_timestamp, get_scrap_target_type_list) + (x_own_selection, x_get_foreign_selection) + (Fx_disown_selection_internal, Fx_selection_owner_p) + (Fx_selection_exists_p): Use OSStatus instead of OSErr. + + * macterm.c (mac_draw_string_common, mac_query_char_extents) + (x_iconify_frame, XLoadQueryFont, install_window_handler) + (mac_handle_command_event, init_command_handler, init_menu_bar): + Use OSStatus instead of OSErr. + (x_free_frame_resources) [TARGET_API_MAC_CARBON]: Don't use + FRAME_FILE_NAME. + (x_query_font): Apply 2006-08-04 change for xterm.c. + (Qhi_command): Rename from Qhicommand. All uses changed. + + * macterm.h (struct mac_output) [TARGET_API_MAC_CARBON]: Remove member + file_name. + (FRAME_FILE_NAME): Remove macro. + (install_window_handler, create_apple_event_from_event_ref): + Return OSStatus instead of OSErr. + +2006-08-26 Kim F. Storm <storm@cua.dk> + + * buffer.c (Fset_buffer_multibyte): + * editfns.c (Fcurrent_time, Fget_internal_run_time): + * macfns.c (Fxw_color_values): + * w32fns.c (Fxw_color_values): + * xfns.c (Fxw_color_values): Simplify; use list3. + + * fileio.c (Fmake_directory_internal, Fdelete_directory) + (Fdelete_file): Simplify; use list1. + (Frename_file, Fadd_name_to_file, Fmake_symbolic_link): + Simplify; remove NO_ARG_ARRAY stuff, use list2. + +2006-08-25 Kim F. Storm <storm@cua.dk> + + * keyboard.c (Fcurrent_idle_time): Simplify. + +2006-08-25 Richard Stallman <rms@gnu.org> + + * fns.c (sxhash_string): Rotate properly; don't lose bits. + +2006-08-24 Francesc Rocher <francesc.rocher@gmail.com> + + * xdisp.c (overline_margin): New variable. + (x_produce_glyphs): Use it. + (syms_of_xdisp): DEFVAR_INT it. + + * xterm.c (x_underline_at_descent_line): New variable. + (syms_of_xterm): DEFVAR_BOOL it. + (x_draw_glyph_string): Use it. + Draw underline and overline up to the end of line if the face + extends to the end of line. + + * macterm.c: Likewise. + + * w32term.c: Likewise. + +2006-08-24 Nick Roberts <nickrob@snap.net.nz> + + * buffer.c (Fswitch_to_buffer): Move buffer to front of + buffer-alist if necessary. + +2006-08-22 Kim F. Storm <storm@cua.dk> + + * xdisp.c (update_tool_bar): Redisplay toolbar also when only + number of items changes. + +2006-08-22 Stefan Monnier <monnier@iro.umontreal.ca> + + * buffer.c (Fset_buffer_multibyte): Record proper undo entry. + +2006-08-21 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * keyboard.c: Clarify difference between in_sighandler and + handling_signal. + +2006-08-21 Kim F. Storm <storm@cua.dk> + + * macterm.c (x_draw_stretch_glyph_string): + * w32term.c (x_draw_stretch_glyph_string): + * xterm.c (x_draw_stretch_glyph_string): It is ok to draw a + stretch glyph in left marginal areas on header and mode lines. + +2006-08-21 Kenichi Handa <handa@m17n.org> + + * keyboard.c (syms_of_keyboard): Docstring of + Vunread_post_input_method_events and Vunread_input_method_events + fixed. + +2006-08-20 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (show_help_echo): Preserve mouse movement flag if + tracking mouse. + +2006-08-20 Richard Stallman <rms@gnu.org> + + * xfaces.c (load_pixmap): Add quotes in error message. + + * keyboard.c (Fcurrent_idle_time): New function. + (syms_of_keyboard): defsubr it. + +2006-08-18 Nick Roberts <nickrob@snap.net.nz> + + * window.c (Fset_window_fringes): Do nothing on a tty. + (Fwindow_fringes): Put ? operator after the line break. + +2006-08-16 Andreas Schwab <schwab@suse.de> + + * print.c (debug_output_compilation_hack): Fix return type. + +2006-08-16 Richard Stallman <rms@gnu.org> + + * print.c (debug_output_compilation_hack): New function. + +2006-08-16 Kenichi Handa <handa@m17n.org> + + * fileio.c (choose_write_coding_system): Use LF for end-of-line + in auto-saving. + +2006-08-15 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (read_char): Don't change idle timer state at all if + end_time is supplied. + +2006-08-15 Kenichi Handa <handa@m17n.org> + + * coding.c (ONE_MORE_BYTE_CHECK_MULTIBYTE): New arg RET. If SRC + is exhausted, return with RET. + (detect_coding_emacs_mule, detect_coding_iso2022) + (detect_coding_sjis, detect_coding_big5, detect_coding_utf_8) + (detect_coding_utf_16, detect_coding_ccl): Adjusted for the above + change. + +2006-08-14 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (read_char): Don't reset idle timers if a time limit + is supplied. + +2006-08-14 Kim F. Storm <storm@cua.dk> + + * .gdbinit (pitx): Print iterator position. + Limit stack dump in case iterator is not initialized. + +2006-08-12 Eli Zaretskii <eliz@gnu.org> + + * frame.c (Fmouse_position, Fmouse_pixel_position) + (Fset_mouse_position, Fset_mouse_pixel_position): Doc fix. + +2006-08-11 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * xselect.c (Fx_register_dnd_atom): New function. + (syms_of_xselect): Defsubr it. + (x_handle_dnd_message): Check that message_type is in + dpyinfo->x_dnd_atoms before generating lisp event. + + * xterm.h (struct x_display_info): Add x_dnd_atoms* to keep track + of drag and drop Atoms. + + * xterm.c (x_term_init): Initialize dpyinfo->x_dnd_atoms* + + +2006-08-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * keyboard.c: Define in_sighandler. + (input_available_signal): Set in_sighandler. + (init_keyboard): Initialize in_sighandler. + + * keyboard.h: Declare in_sighandler. + + * alloc.c (UNBLOCK_INPUT_ALLOC, BLOCK_INPUT_ALLOC): Use in_sighandler + to check if mutex should be locked or not. + +2006-08-09 Richard Stallman <rms@gnu.org> + + * keyboard.c (keyremap_step): No-op if fkey->parent = nil. + (read_key_sequence): Always start fkey.start and fkey.end at 0, + and likewise for keytran. + +2006-08-09 Kenichi Handa <handa@m17n.org> + + * coding.c (syms_of_coding): Improve the docstring + file-coding-system-alist. + +2006-08-07 Andreas Schwab <schwab@suse.de> + + * puresize.h (BASE_PURESIZE): Increase to 1120000. + +2006-08-06 Chong Yidong <cyd@stupidchicken.com> + + * buffer.c (Vchange_major_mode_hook, Qchange_major_mode_hook): New vars. + (Fkill_all_local_variables): Use it. + (syms_of_buffer): Defvar it. + +2006-08-05 Eli Zaretskii <eliz@gnu.org> + + * w32.c (w32_valid_pointer_p): New function. + + * w32.h: Add prototype for w32_valid_pointer_p. + + * alloc.c: Include w32.h. + (valid_lisp_object_p) [WINDOWSNT]: Call w32_valid_pointer_p to do + the job. + + * keyboard.c (kbd_buffer_get_event): Return Qnil when current time + is exactly equal to end_time, not only when it is past that. + +2006-08-04 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (read_char): Rebalance specpdl after receiving jump. + + * process.c: Reapply 2006-08-01 change. + +2006-08-04 Eli Zaretskii <eliz@gnu.org> + + * w32fns.c (w32_query_font): Fix last change: use stricmp. + +2006-08-04 Stefan Monnier <monnier@iro.umontreal.ca> + + * editfns.c (Fsubst_char_in_region): Redo the setup work after running + the before-change-functions since they may have altered the buffer. + +2006-08-04 Ralf Angeli <angeli@caeruleus.net> + + * w32fns.c (w32_createwindow): Handle -geometry command line option + and the geometry settings in the Registry. + +2006-08-04 Kenichi Handa <handa@m17n.org> + + * w32fns.c (w32_query_font): Compare names by ignoring case. + + * xterm.c (x_query_font): Compare names by ignoring case. + +2006-08-03 Jason Rumney <jasonr@gnu.org> + + * w32menu.c (w32_menu_show, w32_dialog_show): Call Fsignal to quit + when no option selected. + +2006-08-03 Chong Yidong <cyd@stupidchicken.com> + + * process.c: Revert last change. + +2006-08-01 Kim F. Storm <storm@cua.dk> + + * process.c (wait_reading_process_output_unwind): New function. + Restores waiting_for_user_input_p to saved value. + (wait_reading_process_output): Unwind protect waiting_for_user_input_p + instead of save/restore old value on stack. + +2006-07-30 Thien-Thi Nguyen <ttn@gnu.org> + + * editfns.c: Undo 2006-06-27 change. + +2006-07-29 Eli Zaretskii <eliz@gnu.org> + + * coding.c (Ffind_operation_coding_system): Revert the change from + 2006-05-29. + + * alloc.c [WINDOWSNT]: Include fcntl.h, to fix last change. + +2006-07-28 Richard Stallman <rms@gnu.org> + + * xfaces.c (lookup_named_face, Fdisplay_supports_face_attributes_p): + Add conditional aborts for clarity. + + * xdisp.c (update_menu_bar): New arg HOOKS_RUN. Callers changed. + Used to avoid running the hooks over and over for each frame. + (prepare_menu_bars): Pass value from update_menu_bar + as HOOKS_RUN of next call. + + * keyboard.c (safe_run_hooks_1): Don't crash if Vrun_hooks is nil. + +2006-07-28 Kim F. Storm <storm@cua.dk> + + * alloc.c (valid_pointer_p): New function (from valid_lisp_object_p). + (valid_lisp_object_p): Use it to check for valid SUBRP obj. + 2006-07-26 Chong Yidong <cyd@stupidchicken.com> * keyboard.c (read_char): New arg END_TIME specifying timeout. @@ -177,6 +482,14 @@ (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel. (x_delete_display): Apply 2006-07-04 change for xterm.c. +2006-07-17 Richard Stallman <rms@gnu.org> + + * keyboard.c (Vcommand_error_function): New variable. + (syms_of_keyboard): Defvar it. + (cmd_error_internal): Simplify, and handle Vcommand_error_function. + + * dispnew.c (init_display): Mention DISPLAY as well as TERM in err msg. + 2006-07-17 Kim F. Storm <storm@cua.dk> * xdisp.c (handle_single_display_spec): Ensure the right value of @@ -617,8 +930,8 @@ 2006-06-14 Chong Yidong <cyd@stupidchicken.com> - * xdisp.c (back_to_previous_visible_line_start): Reset - it->continuation_lines_width. + * xdisp.c (back_to_previous_visible_line_start): + Reset it->continuation_lines_width. 2006-06-14 Richard Stallman <rms@gnu.org> @@ -689,8 +1002,8 @@ 2006-06-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> - * macterm.c [USE_MAC_TSM] (mac_handle_text_input_event): Exclude - 0x7f from ASCII range. + * macterm.c [USE_MAC_TSM] (mac_handle_text_input_event): + Exclude 0x7f from ASCII range. 2006-06-05 Jason Rumney <jasonr@gnu.org> diff --git a/src/alloc.c b/src/alloc.c index e3609292749..5cfcda2e1e0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -78,6 +78,11 @@ extern POINTER_TYPE *sbrk (); #define O_WRONLY 1 #endif +#ifdef WINDOWSNT +#include <fcntl.h> +#include "w32.h" +#endif + #ifdef DOUG_LEA_MALLOC #include <malloc.h> @@ -125,17 +130,17 @@ static pthread_mutex_t alloc_mutex; #define BLOCK_INPUT_ALLOC \ do \ { \ - pthread_mutex_lock (&alloc_mutex); \ - if (pthread_self () == main_thread) \ - BLOCK_INPUT; \ + if (pthread_self () == main_thread) \ + BLOCK_INPUT; \ + pthread_mutex_lock (&alloc_mutex); \ } \ while (0) #define UNBLOCK_INPUT_ALLOC \ do \ { \ - if (pthread_self () == main_thread) \ - UNBLOCK_INPUT; \ - pthread_mutex_unlock (&alloc_mutex); \ + pthread_mutex_unlock (&alloc_mutex); \ + if (pthread_self () == main_thread) \ + UNBLOCK_INPUT; \ } \ while (0) @@ -4608,6 +4613,32 @@ mark_stack () #endif /* GC_MARK_STACK != 0 */ +/* Determine whether it is safe to access memory at address P. */ +int +valid_pointer_p (p) + void *p; +{ +#ifdef WINDOWSNT + return w32_valid_pointer_p (p, 16); +#else + int fd; + + /* Obviously, we cannot just access it (we would SEGV trying), so we + trick the o/s to tell us whether p is a valid pointer. + Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may + not validate p in that case. */ + + if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0) + { + int valid = (emacs_write (fd, (char *)p, 16) == 16); + emacs_close (fd); + unlink ("__Valid__Lisp__Object__"); + return valid; + } + + return -1; +#endif +} /* Return 1 if OBJ is a valid lisp object. Return 0 if OBJ is NOT a valid lisp object. @@ -4620,9 +4651,7 @@ valid_lisp_object_p (obj) Lisp_Object obj; { void *p; -#if !GC_MARK_STACK - int fd; -#else +#if GC_MARK_STACK struct mem_node *m; #endif @@ -4634,26 +4663,22 @@ valid_lisp_object_p (obj) return 1; #if !GC_MARK_STACK - /* We need to determine whether it is safe to access memory at - address P. Obviously, we cannot just access it (we would SEGV - trying), so we trick the o/s to tell us whether p is a valid - pointer. Unfortunately, we cannot use NULL_DEVICE here, as - emacs_write may not validate p in that case. */ - if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0) - { - int valid = (emacs_write (fd, (char *)p, 16) == 16); - emacs_close (fd); - unlink ("__Valid__Lisp__Object__"); - return valid; - } - - return -1; + return valid_pointer_p (p); #else m = mem_find (p); if (m == MEM_NIL) - return 0; + { + int valid = valid_pointer_p (p); + if (valid <= 0) + return valid; + + if (SUBRP (obj)) + return 1; + + return 0; + } switch (m->type) { diff --git a/src/buffer.c b/src/buffer.c index dc6bcd8f6d3..6a11569c85a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -146,6 +146,9 @@ Lisp_Object Vinhibit_read_only; Lisp_Object Vkill_buffer_query_functions; Lisp_Object Qkill_buffer_query_functions; +/* Hook run before changing a major mode. */ +Lisp_Object Vchange_major_mode_hook, Qchange_major_mode_hook; + /* List of functions to call before changing an unmodified buffer. */ Lisp_Object Vfirst_change_hook; @@ -1711,9 +1714,18 @@ the window-buffer correspondences. */) char *err; if (EQ (buffer, Fwindow_buffer (selected_window))) - /* Basically a NOP. Avoid signalling an error if the selected window - is dedicated, or a minibuffer, ... */ - return Fset_buffer (buffer); + { + /* Basically a NOP. Avoid signalling an error in the case where + the selected window is dedicated, or a minibuffer. */ + + /* But do put this buffer at the front of the buffer list, + unless that has been inhibited. Note that even if + BUFFER is at the front of the main buffer-list already, + we still want to move it to the front of the frame's buffer list. */ + if (NILP (norecord)) + record_buffer (buffer); + return Fset_buffer (buffer); + } err = no_switch_window (selected_window); if (err) error (err); @@ -2142,10 +2154,11 @@ current buffer is cleared. */) { struct Lisp_Marker *tail, *markers; struct buffer *other; - int undo_enabled_p = !EQ (current_buffer->undo_list, Qt); int begv, zv; int narrowed = (BEG != BEGV || Z != ZV); int modified_p = !NILP (Fbuffer_modified_p (Qnil)); + Lisp_Object old_undo = current_buffer->undo_list; + struct gcpro gcpro1; if (current_buffer->base_buffer) error ("Cannot do `set-buffer-multibyte' on an indirect buffer"); @@ -2154,10 +2167,11 @@ current buffer is cleared. */) if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters)) return flag; - /* It would be better to update the list, - but this is good enough for now. */ - if (undo_enabled_p) - current_buffer->undo_list = Qt; + GCPRO1 (old_undo); + + /* Don't record these buffer changes. We will put a special undo entry + instead. */ + current_buffer->undo_list = Qt; /* If the cached position is for this buffer, clear it out. */ clear_charpos_cache (current_buffer); @@ -2357,8 +2371,17 @@ current buffer is cleared. */) set_intervals_multibyte (1); } - if (undo_enabled_p) - current_buffer->undo_list = Qnil; + if (!EQ (old_undo, Qt)) + { + /* Represent all the above changes by a special undo entry. */ + extern Lisp_Object Qapply; + current_buffer->undo_list = Fcons (list3 (Qapply, + intern ("set-buffer-multibyte"), + NILP (flag) ? Qt : Qnil), + old_undo); + } + + UNGCPRO; /* Changing the multibyteness of a buffer means that all windows showing that buffer must be updated thoroughly. */ @@ -2416,7 +2439,7 @@ the normal hook `change-major-mode-hook'. */) Lisp_Object oalist; if (!NILP (Vrun_hooks)) - call1 (Vrun_hooks, intern ("change-major-mode-hook")); + call1 (Vrun_hooks, Qchange_major_mode_hook); oalist = current_buffer->local_var_alist; /* Make sure none of the bindings in oalist @@ -6028,6 +6051,13 @@ t means to use hollow box cursor. See `cursor-type' for other values. */); doc: /* List of functions called with no args to query before killing a buffer. */); Vkill_buffer_query_functions = Qnil; + DEFVAR_LISP ("change-major-mode-hook", &Vchange_major_mode_hook, + doc: /* Normal hook run before changing the major mode of a buffer. +The function `kill-all-local-variables' runs this before doing anything else. */); + Vchange_major_mode_hook = Qnil; + Qchange_major_mode_hook = intern ("change-major-mode-hook"); + staticpro (&Qchange_major_mode_hook); + defsubr (&Sbuffer_live_p); defsubr (&Sbuffer_list); defsubr (&Sget_buffer); diff --git a/src/coding.c b/src/coding.c index 5b067b9dd2f..53f37c580de 100644 --- a/src/coding.c +++ b/src/coding.c @@ -219,14 +219,15 @@ encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) /* Like ONE_MORE_BYTE, but 8-bit bytes of data at SRC are in multibyte - form if MULTIBYTEP is nonzero. */ + form if MULTIBYTEP is nonzero. In addition, if SRC is not less + than SRC_END, return with RET. */ -#define ONE_MORE_BYTE_CHECK_MULTIBYTE(c1, multibytep) \ +#define ONE_MORE_BYTE_CHECK_MULTIBYTE(c1, multibytep, ret) \ do { \ if (src >= src_end) \ { \ coding->result = CODING_FINISH_INSUFFICIENT_SRC; \ - goto label_end_of_loop; \ + return ret; \ } \ c1 = *src++; \ if (multibytep && c1 == LEADING_CODE_8_BIT_CONTROL) \ @@ -628,15 +629,15 @@ detect_coding_emacs_mule (src, src_end, multibytep) while (1) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); - + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, + CODING_CATEGORY_MASK_EMACS_MULE); if (composing) { if (c < 0xA0) composing = 0; else if (c == 0xA0) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); c &= 0x7F; } else @@ -665,8 +666,6 @@ detect_coding_emacs_mule (src, src_end, multibytep) } } } - label_end_of_loop: - return CODING_CATEGORY_MASK_EMACS_MULE; } @@ -1421,9 +1420,9 @@ detect_coding_iso2022 (src, src_end, multibytep) Lisp_Object safe_chars; reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1; - while (mask && src < src_end) + while (mask) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); retry: switch (c) { @@ -1431,11 +1430,11 @@ detect_coding_iso2022 (src, src_end, multibytep) if (inhibit_iso_escape_detection) break; single_shifting = 0; - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); if (c >= '(' && c <= '/') { /* Designation sequence for a charset of dimension 1. */ - ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, mask & mask_found); if (c1 < ' ' || c1 >= 0x80 || (charset = iso_charset_table[0][c >= ','][c1]) < 0) /* Invalid designation sequence. Just ignore. */ @@ -1445,13 +1444,14 @@ detect_coding_iso2022 (src, src_end, multibytep) else if (c == '$') { /* Designation sequence for a charset of dimension 2. */ - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, mask & mask_found); if (c >= '@' && c <= 'B') /* Designation for JISX0208.1978, GB2312, or JISX0208. */ reg[0] = charset = iso_charset_table[1][0][c]; else if (c >= '(' && c <= '/') { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, + mask & mask_found); if (c1 < ' ' || c1 >= 0x80 || (charset = iso_charset_table[1][c >= ','][c1]) < 0) /* Invalid designation sequence. Just ignore. */ @@ -1626,7 +1626,8 @@ detect_coding_iso2022 (src, src_end, multibytep) c = -1; while (src < src_end) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, + mask & mask_found); if (c < 0xA0) break; i++; @@ -1644,7 +1645,6 @@ detect_coding_iso2022 (src, src_end, multibytep) break; } } - label_end_of_loop: return (mask & mask_found); } @@ -2915,20 +2915,18 @@ detect_coding_sjis (src, src_end, multibytep) while (1) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_SJIS); if (c < 0x80) continue; if (c == 0x80 || c == 0xA0 || c > 0xEF) return 0; if (c <= 0x9F || c >= 0xE0) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); if (c < 0x40 || c == 0x7F || c > 0xFC) return 0; } } - label_end_of_loop: - return CODING_CATEGORY_MASK_SJIS; } /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". @@ -2947,17 +2945,15 @@ detect_coding_big5 (src, src_end, multibytep) while (1) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_BIG5); if (c < 0x80) continue; if (c < 0xA1 || c > 0xFE) return 0; - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); if (c < 0x40 || (c > 0x7F && c < 0xA1) || c > 0xFE) return 0; } - label_end_of_loop: - return CODING_CATEGORY_MASK_BIG5; } /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". @@ -2985,7 +2981,7 @@ detect_coding_utf_8 (src, src_end, multibytep) while (1) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_UTF_8); if (UTF_8_1_OCTET_P (c)) continue; else if (UTF_8_2_OCTET_LEADING_P (c)) @@ -3003,16 +2999,13 @@ detect_coding_utf_8 (src, src_end, multibytep) do { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, 0); if (!UTF_8_EXTRA_OCTET_P (c)) return 0; seq_maybe_bytes--; } while (seq_maybe_bytes > 0); } - - label_end_of_loop: - return CODING_CATEGORY_MASK_UTF_8; } /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". @@ -3041,15 +3034,13 @@ detect_coding_utf_16 (src, src_end, multibytep) struct coding_system dummy_coding; struct coding_system *coding = &dummy_coding; - ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); - ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep, 0); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep, 0); if ((c1 == 0xFF) && (c2 == 0xFE)) return CODING_CATEGORY_MASK_UTF_16_LE; else if ((c1 == 0xFE) && (c2 == 0xFF)) return CODING_CATEGORY_MASK_UTF_16_BE; - - label_end_of_loop: return 0; } @@ -3318,12 +3309,10 @@ detect_coding_ccl (src, src_end, multibytep) valid = coding_system_table[CODING_CATEGORY_IDX_CCL]->spec.ccl.valid_codes; while (1) { - ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep); + ONE_MORE_BYTE_CHECK_MULTIBYTE (c, multibytep, CODING_CATEGORY_MASK_CCL); if (! valid[c]) return 0; } - label_end_of_loop: - return CODING_CATEGORY_MASK_CCL; } @@ -7547,7 +7536,10 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */) return Fcons (val, val); if (! NILP (Ffboundp (val))) { - val = safe_call1 (val, Flist (nargs, args)); + /* We use call1 rather than safe_call1 + so as to get bug reports about functions called here + which don't handle the current interface. */ + val = call1 (val, Flist (nargs, args)); if (CONSP (val)) return val; if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val))) @@ -7971,8 +7963,9 @@ the file contents. If VAL is a cons of coding systems, the car part is used for decoding, and the cdr part is used for encoding. If VAL is a function symbol, the function must return a coding system -or a cons of coding systems which are used as above. The function gets -the arguments with which `find-operation-coding-system' was called. +or a cons of coding systems which are used as above. The function is +called with an argument that is a list of the arguments with which +`find-operation-coding-system' was called. See also the function `find-operation-coding-system' and the variable `auto-coding-alist'. */); diff --git a/src/dired.c b/src/dired.c index 17a80a3ce4b..b469d682c41 100644 --- a/src/dired.c +++ b/src/dired.c @@ -134,7 +134,9 @@ directory_files_internal_unwind (dh) Lisp_Object dh; { DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; + BLOCK_INPUT; closedir (d); + UNBLOCK_INPUT; return Qnil; } @@ -196,7 +198,9 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) /* Now *bufp is the compiled form of MATCH; don't call anything which might compile a new regexp until we're done with the loop! */ + BLOCK_INPUT; d = opendir (SDATA (dirfilename)); + UNBLOCK_INPUT; if (d == NULL) report_file_error ("Opening directory", Fcons (directory, Qnil)); @@ -321,7 +325,9 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) } } + BLOCK_INPUT; closedir (d); + UNBLOCK_INPUT; /* Discard the unwind protect. */ specpdl_ptr = specpdl + count; @@ -508,7 +514,9 @@ file_name_completion (file, dirname, all_flag, ver_flag) { int inner_count = SPECPDL_INDEX (); + BLOCK_INPUT; d = opendir (SDATA (Fdirectory_file_name (encoded_dir))); + UNBLOCK_INPUT; if (!d) report_file_error ("Opening directory", Fcons (dirname, Qnil)); diff --git a/src/editfns.c b/src/editfns.c index aea044db068..c43528c4863 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -629,10 +629,7 @@ find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end) DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, doc: /* Delete the field surrounding POS. A field is a region of text with the same `field' property. -If POS is nil, the value of point is used for POS. - -An `args-out-of-range' error is signaled if POS is outside the -buffer's accessible portion. */) +If POS is nil, the value of point is used for POS. */) (pos) Lisp_Object pos; { @@ -646,10 +643,7 @@ buffer's accessible portion. */) DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, doc: /* Return the contents of the field surrounding POS as a string. A field is a region of text with the same `field' property. -If POS is nil, the value of point is used for POS. - -An `args-out-of-range' error is signaled if POS is outside the -buffer's accessible portion. */) +If POS is nil, the value of point is used for POS. */) (pos) Lisp_Object pos; { @@ -661,10 +655,7 @@ buffer's accessible portion. */) DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0, doc: /* Return the contents of the field around POS, without text-properties. A field is a region of text with the same `field' property. -If POS is nil, the value of point is used for POS. - -An `args-out-of-range' error is signaled if POS is outside the -buffer's accessible portion. */) +If POS is nil, the value of point is used for POS. */) (pos) Lisp_Object pos; { @@ -680,10 +671,7 @@ If POS is nil, the value of point is used for POS. If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its field, then the beginning of the *previous* field is returned. If LIMIT is non-nil, it is a buffer position; if the beginning of the field -is before LIMIT, then LIMIT will be returned instead. - -An `args-out-of-range' error is signaled if POS is outside the -buffer's accessible portion. */) +is before LIMIT, then LIMIT will be returned instead. */) (pos, escape_from_edge, limit) Lisp_Object pos, escape_from_edge, limit; { @@ -699,10 +687,7 @@ If POS is nil, the value of point is used for POS. If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, then the end of the *following* field is returned. If LIMIT is non-nil, it is a buffer position; if the end of the field -is after LIMIT, then LIMIT will be returned instead. - -An `args-out-of-range' error is signaled if POS is outside the -buffer's accessible portion. */) +is after LIMIT, then LIMIT will be returned instead. */) (pos, escape_from_edge, limit) Lisp_Object pos, escape_from_edge, limit; { @@ -1450,14 +1435,11 @@ resolution finer than a second. */) () { EMACS_TIME t; - Lisp_Object result[3]; EMACS_GET_TIME (t); - XSETINT (result[0], (EMACS_SECS (t) >> 16) & 0xffff); - XSETINT (result[1], (EMACS_SECS (t) >> 0) & 0xffff); - XSETINT (result[2], EMACS_USECS (t)); - - return Flist (3, result); + return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff), + make_number ((EMACS_SECS (t) >> 0) & 0xffff), + make_number (EMACS_USECS (t))); } DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, @@ -1475,7 +1457,6 @@ systems that do not provide resolution finer than a second. */) { #ifdef HAVE_GETRUSAGE struct rusage usage; - Lisp_Object result[3]; int secs, usecs; if (getrusage (RUSAGE_SELF, &usage) < 0) @@ -1491,11 +1472,9 @@ systems that do not provide resolution finer than a second. */) secs++; } - XSETINT (result[0], (secs >> 16) & 0xffff); - XSETINT (result[1], (secs >> 0) & 0xffff); - XSETINT (result[2], usecs); - - return Flist (3, result); + return list3 (make_number ((secs >> 16) & 0xffff), + make_number ((secs >> 0) & 0xffff), + make_number (usecs)); #else return Fcurrent_time (); #endif @@ -2706,6 +2685,10 @@ Both characters must have the same length of multi-byte form. */) Lisp_Object start, end, fromchar, tochar, noundo; { register int pos, pos_byte, stop, i, len, end_byte; + /* Keep track of the first change in the buffer: + if 0 we haven't found it yet. + if < 0 we've found it and we've run the before-change-function. + if > 0 we've actually performed it and the value is its position. */ int changed = 0; unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; unsigned char *p; @@ -2718,6 +2701,8 @@ Both characters must have the same length of multi-byte form. */) int last_changed = 0; int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); + restart: + validate_region (&start, &end); CHECK_NUMBER (fromchar); CHECK_NUMBER (tochar); @@ -2755,7 +2740,7 @@ Both characters must have the same length of multi-byte form. */) That's faster than getting rid of things, and it prevents even the entry for a first change. Also inhibit locking the file. */ - if (!NILP (noundo)) + if (!changed && !NILP (noundo)) { record_unwind_protect (subst_char_in_region_unwind, current_buffer->undo_list); @@ -2789,10 +2774,14 @@ Both characters must have the same length of multi-byte form. */) && (len == 2 || (p[2] == fromstr[2] && (len == 3 || p[3] == fromstr[3])))))) { - if (! changed) + if (changed < 0) + /* We've already seen this and run the before-change-function; + this time we only need to record the actual position. */ + changed = pos; + else if (!changed) { - changed = pos; - modify_region (current_buffer, changed, XINT (end)); + changed = -1; + modify_region (current_buffer, pos, XINT (end)); if (! NILP (noundo)) { @@ -2801,6 +2790,10 @@ Both characters must have the same length of multi-byte form. */) if (MODIFF - 1 == current_buffer->auto_save_modified) current_buffer->auto_save_modified++; } + + /* The before-change-function may have moved the gap + or even modified the buffer so we should start over. */ + goto restart; } /* Take care of the case where the new character @@ -2853,7 +2846,7 @@ Both characters must have the same length of multi-byte form. */) pos++; } - if (changed) + if (changed > 0) { signal_after_change (changed, last_changed - changed, last_changed - changed); diff --git a/src/fileio.c b/src/fileio.c index 8ac528cafb9..62d539dcfca 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2650,7 +2650,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal, #else if (mkdir (dir, 0777) != 0) #endif - report_file_error ("Creating directory", Flist (1, &directory)); + report_file_error ("Creating directory", list1 (directory)); return Qnil; } @@ -2676,7 +2676,7 @@ DEFUN ("delete-directory", Fdelete_directory, Sdelete_directory, 1, 1, "FDelete dir = SDATA (encoded_dir); if (rmdir (dir) != 0) - report_file_error ("Removing directory", Flist (1, &directory)); + report_file_error ("Removing directory", list1 (directory)); return Qnil; } @@ -2707,7 +2707,7 @@ If file has multiple names, it continues to exist with the other names. */) encoded_file = ENCODE_FILE (filename); if (0 > unlink (SDATA (encoded_file))) - report_file_error ("Removing old name", Flist (1, &filename)); + report_file_error ("Removing old name", list1 (filename)); return Qnil; } @@ -2741,9 +2741,6 @@ This is what happens in interactive use with M-x. */) (file, newname, ok_if_already_exists) Lisp_Object file, newname, ok_if_already_exists; { -#ifdef NO_ARG_ARRAY - Lisp_Object args[2]; -#endif Lisp_Object handler; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; Lisp_Object encoded_file, encoded_newname, symlink_target; @@ -2812,15 +2809,7 @@ This is what happens in interactive use with M-x. */) Fdelete_file (file); } else -#ifdef NO_ARG_ARRAY - { - args[0] = file; - args[1] = newname; - report_file_error ("Renaming", Flist (2, args)); - } -#else - report_file_error ("Renaming", Flist (2, &file)); -#endif + report_file_error ("Renaming", list2 (file, newname)); } UNGCPRO; return Qnil; @@ -2836,9 +2825,6 @@ This is what happens in interactive use with M-x. */) (file, newname, ok_if_already_exists) Lisp_Object file, newname, ok_if_already_exists; { -#ifdef NO_ARG_ARRAY - Lisp_Object args[2]; -#endif Lisp_Object handler; Lisp_Object encoded_file, encoded_newname; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -2878,15 +2864,7 @@ This is what happens in interactive use with M-x. */) unlink (SDATA (newname)); if (0 > link (SDATA (encoded_file), SDATA (encoded_newname))) - { -#ifdef NO_ARG_ARRAY - args[0] = file; - args[1] = newname; - report_file_error ("Adding new name", Flist (2, args)); -#else - report_file_error ("Adding new name", Flist (2, &file)); -#endif - } + report_file_error ("Adding new name", list2 (file, newname)); UNGCPRO; return Qnil; @@ -2904,9 +2882,6 @@ This happens for interactive use with M-x. */) (filename, linkname, ok_if_already_exists) Lisp_Object filename, linkname, ok_if_already_exists; { -#ifdef NO_ARG_ARRAY - Lisp_Object args[2]; -#endif Lisp_Object handler; Lisp_Object encoded_filename, encoded_linkname; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -2962,13 +2937,7 @@ This happens for interactive use with M-x. */) } } -#ifdef NO_ARG_ARRAY - args[0] = filename; - args[1] = linkname; - report_file_error ("Making symbolic link", Flist (2, args)); -#else - report_file_error ("Making symbolic link", Flist (2, &filename)); -#endif + report_file_error ("Making symbolic link", list2 (filename, linkname)); } UNGCPRO; return Qnil; @@ -4847,6 +4816,8 @@ choose_write_coding_system (start, end, filename, /* ... but with the special flag to indicate not to strip off leading code of eight-bit-control chars. */ coding->flags = 1; + /* We force LF for end-of-line because that is faster. */ + coding->eol_type = CODING_EOL_LF; goto done_setup_coding; } else if (!NILP (Vcoding_system_for_write)) diff --git a/src/fns.c b/src/fns.c index 0054e6fc998..5fe429fcf8b 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5030,7 +5030,7 @@ sxhash_string (ptr, len) c = *p++; if (c >= 0140) c -= 40; - hash = ((hash << 3) + (hash >> 28) + c); + hash = ((hash << 4) + (hash >> 28) + c); } return hash & INTMASK; diff --git a/src/frame.c b/src/frame.c index fd10c3e273c..021e9bf604f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1679,7 +1679,8 @@ The functions are run with one arg, the frame to be deleted. */) DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. The position is given in character cells, where (0, 0) is the -upper-left corner. +upper-left corner of the frame, X is the horizontal offset, and Y is +the vertical offset. If Emacs is running on a mouseless terminal or hasn't been programmed to read the mouse position, it returns the selected frame for FRAME and nil for X and Y. @@ -1727,7 +1728,8 @@ DEFUN ("mouse-pixel-position", Fmouse_pixel_position, Smouse_pixel_position, 0, 0, 0, doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. The position is given in pixel units, where (0, 0) is the -upper-left corner. +upper-left corner of the frame, X is the horizontal offset, and Y is +the vertical offset. If Emacs is running on a mouseless terminal or hasn't been programmed to read the mouse position, it returns the selected frame for FRAME and nil for X and Y. */) @@ -1760,6 +1762,10 @@ Coordinates are relative to the frame, not a window, so the coordinates of the top left character in the frame may be nonzero due to left-hand scroll bars or the menu bar. +The position is given in character cells, where (0, 0) is the +upper-left corner of the frame, X is the horizontal offset, and Y is +the vertical offset. + This function is a no-op for an X frame that is not visible. If you have just created a frame, you must wait for it to become visible before calling this function on it, like this. @@ -1792,6 +1798,9 @@ before calling this function on it, like this. DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, Sset_mouse_pixel_position, 3, 3, 0, doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME. +The position is given in pixels, where (0, 0) is the upper-left corner +of the frame, X is the horizontal offset, and Y is the vertical offset. + Note, this is a no-op for an X frame that is not visible. If you have just created a frame, you must wait for it to become visible before calling this function on it, like this. diff --git a/src/image.c b/src/image.c index 490ede60e35..a3ae6ceb3ce 100644 --- a/src/image.c +++ b/src/image.c @@ -2398,7 +2398,7 @@ image_load_qt_1 (f, img, type, fss, dh) FSSpec *fss; Handle dh; { - OSErr err; + ComponentResult err; GraphicsImportComponent gi; Rect rect; int width, height; diff --git a/src/keyboard.c b/src/keyboard.c index f1bfea0f18c..681018bbab9 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1458,6 +1458,72 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, return Qnil; } +#ifdef HAVE_MOUSE + +/* Restore mouse tracking enablement. See Ftrack_mouse for the only use + of this function. */ + +static Lisp_Object +tracking_off (old_value) + Lisp_Object old_value; +{ + do_mouse_tracking = old_value; + if (NILP (old_value)) + { + /* Redisplay may have been preempted because there was input + available, and it assumes it will be called again after the + input has been processed. If the only input available was + the sort that we have just disabled, then we need to call + redisplay. */ + if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW)) + { + redisplay_preserve_echo_area (6); + get_input_pending (&input_pending, + READABLE_EVENTS_DO_TIMERS_NOW); + } + } + return Qnil; +} + +DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, + doc: /* Evaluate BODY with mouse movement events enabled. +Within a `track-mouse' form, mouse motion generates input events that +you can read with `read-event'. +Normally, mouse motion is ignored. +usage: (track-mouse BODY ...) */) + (args) + Lisp_Object args; +{ + int count = SPECPDL_INDEX (); + Lisp_Object val; + + record_unwind_protect (tracking_off, do_mouse_tracking); + + do_mouse_tracking = Qt; + + val = Fprogn (args); + return unbind_to (count, val); +} + +/* If mouse has moved on some frame, return one of those frames. + Return 0 otherwise. */ + +static FRAME_PTR +some_mouse_moved () +{ + Lisp_Object tail, frame; + + FOR_EACH_FRAME (tail, frame) + { + if (XFRAME (frame)->mouse_moved) + return XFRAME (frame); + } + + return 0; +} + +#endif /* HAVE_MOUSE */ + /* This is the actual command reading loop, sans error-handling encapsulation. */ @@ -2106,6 +2172,8 @@ static Lisp_Object safe_run_hooks_1 (hook) Lisp_Object hook; { + if (NILP (Vrun_hooks)) + return Qnil; return call1 (Vrun_hooks, Vinhibit_quit); } @@ -2388,7 +2456,17 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo) #ifdef HAVE_MOUSE if (!noninteractive && STRINGP (help)) - help = call1 (Qmouse_fixup_help_message, help); + { + /* The mouse-fixup-help-message Lisp function can call + mouse_position_hook, which resets the mouse_moved flags. + This causes trouble if we are trying to read a mouse motion + event (i.e., if we are inside a `track-mouse' form), so we + restore the mouse_moved flag. */ + FRAME_PTR f = NILP (do_mouse_tracking) ? NULL : some_mouse_moved (); + help = call1 (Qmouse_fixup_help_message, help); + if (f) + f->mouse_moved = 1; + } #endif if (STRINGP (help) || NILP (help)) @@ -2483,7 +2561,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) EMACS_TIME *end_time; { volatile Lisp_Object c; - int count; + int count, jmpcount; jmp_buf local_getcjmp; jmp_buf save_jump; volatile int key_already_recorded = 0; @@ -2714,12 +2792,14 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) around any call to sit_for or kbd_buffer_get_event; it *must not* be in effect when we call redisplay. */ + jmpcount = SPECPDL_INDEX (); if (_setjmp (local_getcjmp)) { /* Handle quits while reading the keyboard. */ /* We must have saved the outer value of getcjmp here, so restore it now. */ restore_getcjmp (save_jump); + unbind_to (jmpcount, Qnil); XSETINT (c, quit_char); internal_last_event_frame = selected_frame; Vlast_event_frame = internal_last_event_frame; @@ -2760,7 +2840,12 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) goto non_reread; } - timer_start_idle (); + /* Start idle timers if no time limit is supplied. We don't do it + if a time limit is supplied to avoid an infinite recursion in the + situation where an idle timer calls `sit-for'. */ + + if (!end_time) + timer_start_idle (); /* If in middle of key sequence and minibuffer not active, start echoing if enough time elapses. */ @@ -2830,7 +2915,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); /* Now that we have read an event, Emacs is not idle. */ - timer_stop_idle (); + if (!end_time) + timer_stop_idle (); goto exit; } @@ -2973,7 +3059,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) /* Actually read a character, waiting if necessary. */ save_getcjmp (save_jump); restore_getcjmp (local_getcjmp); - timer_start_idle (); + if (!end_time) + timer_start_idle (); c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); restore_getcjmp (save_jump); @@ -3025,7 +3112,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) non_reread: - timer_stop_idle (); + if (!end_time) + timer_stop_idle (); RESUME_POLLING; if (NILP (c)) @@ -3063,7 +3151,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) last_input_char = c; Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); - if (CONSP (c) && EQ (XCAR (c), Qselect_window)) + if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) /* We stopped being idle for this event; undo that. This prevents automatic window selection (under mouse_autoselect_window from acting as a real input event, for @@ -3272,7 +3360,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) show_help_echo (help, window, object, position, 0); /* We stopped being idle for this event; undo that. */ - timer_resume_idle (); + if (!end_time) + timer_resume_idle (); goto retry; } @@ -3556,72 +3645,6 @@ restore_getcjmp (temp) bcopy (temp, getcjmp, sizeof getcjmp); } -#ifdef HAVE_MOUSE - -/* Restore mouse tracking enablement. See Ftrack_mouse for the only use - of this function. */ - -static Lisp_Object -tracking_off (old_value) - Lisp_Object old_value; -{ - do_mouse_tracking = old_value; - if (NILP (old_value)) - { - /* Redisplay may have been preempted because there was input - available, and it assumes it will be called again after the - input has been processed. If the only input available was - the sort that we have just disabled, then we need to call - redisplay. */ - if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW)) - { - redisplay_preserve_echo_area (6); - get_input_pending (&input_pending, - READABLE_EVENTS_DO_TIMERS_NOW); - } - } - return Qnil; -} - -DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, - doc: /* Evaluate BODY with mouse movement events enabled. -Within a `track-mouse' form, mouse motion generates input events that -you can read with `read-event'. -Normally, mouse motion is ignored. -usage: (track-mouse BODY ...) */) - (args) - Lisp_Object args; -{ - int count = SPECPDL_INDEX (); - Lisp_Object val; - - record_unwind_protect (tracking_off, do_mouse_tracking); - - do_mouse_tracking = Qt; - - val = Fprogn (args); - return unbind_to (count, val); -} - -/* If mouse has moved on some frame, return one of those frames. - Return 0 otherwise. */ - -static FRAME_PTR -some_mouse_moved () -{ - Lisp_Object tail, frame; - - FOR_EACH_FRAME (tail, frame) - { - if (XFRAME (frame)->mouse_moved) - return XFRAME (frame); - } - - return 0; -} - -#endif /* HAVE_MOUSE */ - /* Low level keyboard/mouse input. kbd_buffer_store_event places events in kbd_buffer, and kbd_buffer_get_event retrieves them. */ @@ -4056,13 +4079,15 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) { EMACS_TIME duration; EMACS_GET_TIME (duration); - EMACS_SUB_TIME (duration, *end_time, duration); - if (EMACS_TIME_NEG_P (duration)) - return Qnil; + if (EMACS_TIME_GE (duration, *end_time)) + return Qnil; /* finished waiting */ else - wait_reading_process_output (EMACS_SECS (duration), - EMACS_USECS (duration), - -1, 1, Qnil, NULL, 0); + { + EMACS_SUB_TIME (duration, *end_time, duration); + wait_reading_process_output (EMACS_SECS (duration), + EMACS_USECS (duration), + -1, 1, Qnil, NULL, 0); + } } else wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); @@ -4635,6 +4660,32 @@ timer_check (do_it_now) UNGCPRO; return nexttime; } + +DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0, + doc: /* Return the current length of Emacs idleness. +The value is returned as a list of three integers. The first has the +most significant 16 bits of the seconds, while the second has the +least significant 16 bits. The third integer gives the microsecond +count. + +The microsecond count is zero on systems that do not provide +resolution finer than a second. */) + () +{ + if (! EMACS_TIME_NEG_P (timer_idleness_start_time)) + { + EMACS_TIME now, idleness_now; + + EMACS_GET_TIME (now); + EMACS_SUB_TIME (idleness_now, now, timer_idleness_start_time); + + return list3 (make_number ((EMACS_SECS (idleness_now) >> 16) & 0xffff), + make_number ((EMACS_SECS (idleness_now) >> 0) & 0xffff), + make_number (EMACS_USECS (idleness_now))); + } + + return Qnil; +} /* Caches for modify_event_symbol. */ static Lisp_Object accent_key_syms; @@ -8565,7 +8616,15 @@ follow_key (key, nmaps, current, defs, next) such as Vfunction_key_map and Vkey_translation_map. */ typedef struct keyremap { - Lisp_Object map, parent; + /* This is the map originally specified for this use. */ + Lisp_Object parent; + /* This is a submap reached by looking up, in PARENT, + the events from START to END. */ + Lisp_Object map; + /* Positions [START, END) in the key sequence buffer + are the key that we have scanned so far. + Those events are the ones that we will replace + if PAREHT maps them into a key sequence. */ int start, end; } keyremap; @@ -8638,7 +8697,11 @@ keyremap_step (keybuf, bufsize, fkey, input, doit, diff, prompt) Lisp_Object next, key; key = keybuf[fkey->end++]; - next = access_keymap_keyremap (fkey->map, key, prompt, doit); + + if (KEYMAPP (fkey->parent)) + next = access_keymap_keyremap (fkey->map, key, prompt, doit); + else + next = Qnil; /* If keybuf[fkey->start..fkey->end] is bound in the map and we're in a position to do the key remapping, replace it with @@ -8878,9 +8941,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, reinitialize fkey and keytran before each replay. */ fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map; keytran.map = keytran.parent = current_kboard->Vlocal_key_translation_map; - /* If there is no translation map, turn off scanning. */ - fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; - keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; + fkey.start = fkey.end = 0; + keytran.start = keytran.end = 0; starting_buffer = current_buffer; first_unbound = bufsize + 1; @@ -9687,8 +9749,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, keybuf[t - 1] = new_key; mock_input = max (t, mock_input); - fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; - keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; + fkey.start = fkey.end = 0; + keytran.start = keytran.end = 0; goto replay_sequence; } @@ -11494,6 +11556,7 @@ syms_of_keyboard () menu_bar_items_vector = Qnil; staticpro (&menu_bar_items_vector); + defsubr (&Scurrent_idle_time); defsubr (&Sevent_convert_list); defsubr (&Sread_key_sequence); defsubr (&Sread_key_sequence_vector); @@ -11555,14 +11618,16 @@ These events are processed first, before actual keyboard input. */); DEFVAR_LISP ("unread-post-input-method-events", &Vunread_post_input_method_events, doc: /* List of events to be processed as input by input methods. -These events are processed after `unread-command-events', but -before actual keyboard input. */); +These events are processed before `unread-command-events' +and actual keyboard input without given to `input-method-function'. */); Vunread_post_input_method_events = Qnil; DEFVAR_LISP ("unread-input-method-events", &Vunread_input_method_events, doc: /* List of events to be processed as input by input methods. These events are processed after `unread-command-events', but -before actual keyboard input. */); +before actual keyboard input. +If there's an active input method, the events are given to +`input-method-function'. */); Vunread_input_method_events = Qnil; DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, diff --git a/src/mac.c b/src/mac.c index 4652757fab3..67fd5e4f5e0 100644 --- a/src/mac.c +++ b/src/mac.c @@ -831,7 +831,7 @@ create_apple_event (class, id, result) return err; } -OSErr +OSStatus create_apple_event_from_event_ref (event, num_params, names, types, result) EventRef event; UInt32 num_params; @@ -839,7 +839,7 @@ create_apple_event_from_event_ref (event, num_params, names, types, result) EventParamType *types; AppleEvent *result; { - OSErr err; + OSStatus err; UInt32 i, size; CFStringRef string; CFDataRef data; @@ -2424,7 +2424,7 @@ select (n, rfds, wfds, efds, timeout) SELECT_TYPE *efds; struct timeval *timeout; { - OSErr err; + OSStatus err; #if TARGET_API_MAC_CARBON EventTimeout timeout_sec = (timeout @@ -4192,7 +4192,7 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, (filename) Lisp_Object filename; { - OSErr status; + OSStatus status; #ifdef MAC_OSX FSRef fref; #else @@ -4246,7 +4246,7 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0, (filename) Lisp_Object filename; { - OSErr status; + OSStatus status; #ifdef MAC_OSX FSRef fref; #else @@ -4302,7 +4302,7 @@ assumed. Return non-nil if successful. */) (filename, code) Lisp_Object filename, code; { - OSErr status; + OSStatus status; #ifdef MAC_OSX FSRef fref; #else @@ -4362,7 +4362,7 @@ CODE must be a 4-character string. Return non-nil if successful. */) (filename, code) Lisp_Object filename, code; { - OSErr status; + OSStatus status; #ifdef MAC_OSX FSRef fref; #else @@ -4775,7 +4775,7 @@ cfstring_create_normalized (str, symbol) UnicodeMapping map; CFIndex length; UniChar *in_text, *buffer = NULL, *out_buf = NULL; - OSErr err = noErr; + OSStatus err = noErr; ByteCount out_read, out_size, out_len; map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, @@ -4910,7 +4910,7 @@ On successful conversion, return the result string, else return nil. */) static Lisp_Object mac_get_system_locale () { - OSErr err; + OSStatus err; LangCode lang; RegionCode region; LocaleRef locale; @@ -4987,7 +4987,7 @@ select_and_poll_event (n, rfds, wfds, efds, timeout) struct timeval *timeout; { int r; - OSErr err; + OSStatus err; r = select (n, rfds, wfds, efds, timeout); if (r != -1) @@ -5017,7 +5017,7 @@ sys_select (n, rfds, wfds, efds, timeout) SELECT_TYPE *efds; struct timeval *timeout; { - OSErr err; + OSStatus err; int i, r; EMACS_TIME select_timeout; diff --git a/src/macfns.c b/src/macfns.c index 8716f072411..2d004be9962 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -1945,63 +1945,80 @@ static void mac_update_proxy_icon (f) struct frame *f; { + OSStatus err; Lisp_Object file_name = XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename; Window w = FRAME_MAC_WINDOW (f); - - if (FRAME_FILE_NAME (f) == NULL && !STRINGP (file_name)) - return; - if (FRAME_FILE_NAME (f) && STRINGP (file_name) - && strcmp (FRAME_FILE_NAME (f), SDATA (file_name)) == 0) - return; - - if (FRAME_FILE_NAME (f)) - { - xfree (FRAME_FILE_NAME (f)); - FRAME_FILE_NAME (f) = NULL; - } + AliasHandle alias = NULL; BLOCK_INPUT; + err = GetWindowProxyAlias (w, &alias); + if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name)) + goto out; + if (STRINGP (file_name)) { - OSStatus err; AEDesc desc; +#ifdef MAC_OSX + FSRef fref; +#else + FSSpec fss; +#endif + Boolean changed; Lisp_Object encoded_file_name = ENCODE_FILE (file_name); -#ifdef MAC_OS8 +#ifdef MAC_OSX + err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name), + SBYTES (encoded_file_name), typeFSRef, &desc); +#else SetPortWindowPort (w); -#endif err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name), - SBYTES (encoded_file_name), typeAlias, &desc); + SBYTES (encoded_file_name), typeFSS, &desc); +#endif if (err == noErr) { - Size size = AEGetDescDataSize (&desc); - AliasHandle alias = (AliasHandle) NewHandle (size); - - if (alias == NULL) - err = memFullErr; - else - { - HLock ((Handle) alias); - err = AEGetDescData (&desc, *alias, size); - HUnlock ((Handle) alias); - if (err == noErr) - err = SetWindowProxyAlias (w, alias); - DisposeHandle ((Handle) alias); - } +#ifdef MAC_OSX + err = AEGetDescData (&desc, &fref, sizeof (FSRef)); +#else + err = AEGetDescData (&desc, &fss, sizeof (FSSpec)); +#endif AEDisposeDesc (&desc); } if (err == noErr) { - FRAME_FILE_NAME (f) = xmalloc (SBYTES (file_name) + 1); - strcpy (FRAME_FILE_NAME (f), SDATA (file_name)); + if (alias) + { +#ifdef MAC_OSX + err = FSUpdateAlias (NULL, &fref, alias, &changed); +#else + err = UpdateAlias (NULL, &fss, alias, &changed); +#endif + } + if (err != noErr || alias == NULL) + { + if (alias) + DisposeHandle ((Handle) alias); +#ifdef MAC_OSX + err = FSNewAliasMinimal (&fref, &alias); +#else + err = NewAliasMinimal (&fss, &alias); +#endif + changed = true; + } } + if (err == noErr) + if (changed) + err = SetWindowProxyAlias (w, alias); } - if (FRAME_FILE_NAME (f) == NULL) + if (alias) + DisposeHandle ((Handle) alias); + + if (err != noErr || !STRINGP (file_name)) RemoveWindowProxy (w); + out: UNBLOCK_INPUT; } #endif @@ -2566,7 +2583,6 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); bzero (f->output_data.mac, sizeof (struct mac_output)); FRAME_FONTSET (f) = -1; - record_unwind_protect (unwind_create_frame, frame); f->icon_name = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING); @@ -2574,6 +2590,9 @@ This function is an internal primitive--use `make-frame' instead. */) f->icon_name = Qnil; /* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */ + + /* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */ + record_unwind_protect (unwind_create_frame, frame); #if GLYPH_DEBUG image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; @@ -2876,14 +2895,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); if (mac_defined_color (f, SDATA (color), &foo, 0)) - { - Lisp_Object rgb[3]; - - rgb[0] = make_number (foo.red); - rgb[1] = make_number (foo.green); - rgb[2] = make_number (foo.blue); - return Flist (3, rgb); - } + return list3 (make_number (foo.red), + make_number (foo.green), + make_number (foo.blue)); else return Qnil; } diff --git a/src/macselect.c b/src/macselect.c index 67a28cf9e64..fd72bd3cb14 100644 --- a/src/macselect.c +++ b/src/macselect.c @@ -31,15 +31,15 @@ typedef int ScrapRef; typedef ResType ScrapFlavorType; #endif /* !TARGET_API_MAC_CARBON */ -static OSErr get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *)); +static OSStatus get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *)); static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object)); static int valid_scrap_target_type_p P_ ((Lisp_Object)); -static OSErr clear_scrap P_ ((ScrapRef *)); -static OSErr put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object)); -static OSErr put_scrap_private_timestamp P_ ((ScrapRef, unsigned long)); +static OSStatus clear_scrap P_ ((ScrapRef *)); +static OSStatus put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object)); +static OSStatus put_scrap_private_timestamp P_ ((ScrapRef, unsigned long)); static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object)); static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object)); -static OSErr get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *)); +static OSStatus get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *)); static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef)); static void x_own_selection P_ ((Lisp_Object, Lisp_Object)); static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int)); @@ -108,13 +108,13 @@ static Lisp_Object Vmac_service_selection; reference is set to *SCRAP, and it becomes NULL if there's no corresponding scrap. Clear the scrap if CLEAR_P is non-zero. */ -static OSErr +static OSStatus get_scrap_from_symbol (sym, clear_p, scrap) Lisp_Object sym; int clear_p; ScrapRef *scrap; { - OSErr err = noErr; + OSStatus err = noErr; Lisp_Object str = Fget (sym, Qmac_scrap_name); if (!STRINGP (str)) @@ -172,7 +172,7 @@ valid_scrap_target_type_p (sym) /* Clear the scrap whose reference is *SCRAP. */ -static INLINE OSErr +static INLINE OSStatus clear_scrap (scrap) ScrapRef *scrap; { @@ -190,7 +190,7 @@ clear_scrap (scrap) /* Put Lisp String STR to the scrap SCRAP. The target type is specified by TYPE. */ -static OSErr +static OSStatus put_scrap_string (scrap, type, str) ScrapRef scrap; Lisp_Object type, str; @@ -211,7 +211,7 @@ put_scrap_string (scrap, type, str) /* Put TIMESTAMP to the scrap SCRAP. The timestamp is used for checking if the scrap is owned by the process. */ -static INLINE OSErr +static INLINE OSStatus put_scrap_private_timestamp (scrap, timestamp) ScrapRef scrap; unsigned long timestamp; @@ -233,7 +233,7 @@ scrap_has_target_type (scrap, type) ScrapRef scrap; Lisp_Object type; { - OSErr err; + OSStatus err; ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type); if (flavor_type) @@ -264,7 +264,7 @@ get_scrap_string (scrap, type) ScrapRef scrap; Lisp_Object type; { - OSErr err; + OSStatus err; Lisp_Object result = Qnil; ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type); #if TARGET_API_MAC_CARBON @@ -310,12 +310,12 @@ get_scrap_string (scrap, type) /* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP. */ -static OSErr +static OSStatus get_scrap_private_timestamp (scrap, timestamp) ScrapRef scrap; unsigned long *timestamp; { - OSErr err = noErr; + OSStatus err = noErr; #if TARGET_API_MAC_CARBON ScrapFlavorFlags flags; @@ -365,7 +365,7 @@ get_scrap_target_type_list (scrap) { Lisp_Object result = Qnil, rest, target_type; #if TARGET_API_MAC_CARBON - OSErr err; + OSStatus err; UInt32 count, i, type; ScrapFlavorInfo *flavor_info = NULL; Lisp_Object strings = Qnil; @@ -425,7 +425,7 @@ static void x_own_selection (selection_name, selection_value) Lisp_Object selection_name, selection_value; { - OSErr err; + OSStatus err; ScrapRef scrap; struct gcpro gcpro1, gcpro2; Lisp_Object rest, handler_fn, value, type; @@ -671,7 +671,7 @@ static Lisp_Object x_get_foreign_selection (selection_symbol, target_type, time_stamp) Lisp_Object selection_symbol, target_type, time_stamp; { - OSErr err; + OSStatus err; ScrapRef scrap; Lisp_Object result = Qnil; @@ -765,7 +765,7 @@ Disowning it means there is no such selection. */) Lisp_Object selection; Lisp_Object time; { - OSErr err; + OSStatus err; ScrapRef scrap; Lisp_Object local_selection_data; @@ -828,7 +828,7 @@ and t is the same as `SECONDARY'. */) (selection) Lisp_Object selection; { - OSErr err; + OSStatus err; ScrapRef scrap; Lisp_Object result = Qnil, local_selection_data; @@ -873,7 +873,7 @@ and t is the same as `SECONDARY'. */) (selection) Lisp_Object selection; { - OSErr err; + OSStatus err; ScrapRef scrap; Lisp_Object result = Qnil, rest; @@ -931,7 +931,7 @@ struct suspended_ae_info struct suspended_ae_info *next; }; -/* List of deferred apple events at the startup time. */ +/* List of apple events deferred at the startup time. */ static struct suspended_ae_info *deferred_apple_events = NULL; /* List of suspended apple events, in order of expiration_tick. */ diff --git a/src/macterm.c b/src/macterm.c index c0128b496d3..76efa80d606 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -902,7 +902,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char) #if USE_ATSUI if (GC_FONT (gc)->mac_style) { - OSErr err; + OSStatus err; ATSUTextLayout text_layout; xassert (bytes_per_char == 2); @@ -1129,7 +1129,7 @@ mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width) the font of the current graphics port. If CG_GLYPH is not NULL, *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */ -static OSErr +static OSStatus mac_query_char_extents (style, c, font_ascent_return, font_descent_return, overall_return, cg_glyph) @@ -1147,7 +1147,7 @@ mac_query_char_extents (style, c, void *cg_glyph; #endif { - OSErr err = noErr; + OSStatus err = noErr; int width; Rect char_bounds; @@ -1193,7 +1193,7 @@ mac_query_char_extents (style, c, #if USE_CG_TEXT_DRAWING if (err == noErr && cg_glyph) { - OSErr err1; + OSStatus err1; ATSUGlyphInfoArray glyph_info_array; ByteCount count = sizeof (ATSUGlyphInfoArray); @@ -3583,7 +3583,9 @@ x_draw_stretch_glyph_string (s) int background_width = s->background_width; int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); - if (x < left_x) + /* Don't draw into left margin, fringe or scrollbar area + except for header line and mode line. */ + if (x < left_x && !s->row->mode_line_p) { background_width -= left_x - x; x = left_x; @@ -3677,14 +3679,14 @@ x_draw_glyph_string (s) if (s->face->underline_defaulted_p) mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); else { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground, &xgcv); XSetForeground (s->display, s->gc, s->face->underline_color); mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); XSetForeground (s->display, s->gc, xgcv.foreground); } } @@ -3696,14 +3698,14 @@ x_draw_glyph_string (s) if (s->face->overline_color_defaulted_p) mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); else { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground, &xgcv); XSetForeground (s->display, s->gc, s->face->overline_color); mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); XSetForeground (s->display, s->gc, xgcv.foreground); } } @@ -6312,7 +6314,7 @@ void x_iconify_frame (f) struct frame *f; { - OSErr err; + OSStatus err; /* A deactivate event does not occur when the last visible frame is iconified. So if we clear the highlight here, it will not be @@ -6376,11 +6378,6 @@ x_free_frame_resources (f) if (FRAME_SIZE_HINTS (f)) xfree (FRAME_SIZE_HINTS (f)); -#if TARGET_API_MAC_CARBON - if (FRAME_FILE_NAME (f)) - xfree (FRAME_FILE_NAME (f)); -#endif - xfree (f->output_data.mac); f->output_data.mac = NULL; @@ -7198,7 +7195,7 @@ init_font_name_table () if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode), text_encoding_info_alist))) { - OSErr err; + OSStatus err; struct Lisp_Hash_Table *h; unsigned hash_code; ItemCount nfonts, i; @@ -7780,7 +7777,7 @@ XLoadQueryFont (Display *dpy, char *fontname) #if USE_ATSUI if (strcmp (charset, "iso10646-1") == 0) /* XXX */ { - OSErr err; + OSStatus err; ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag, kATSUQDBoldfaceTag, kATSUQDItalicTag}; ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), @@ -7863,7 +7860,7 @@ XLoadQueryFont (Display *dpy, char *fontname) #if USE_ATSUI if (font->mac_style) { - OSErr err; + OSStatus err; UniChar c; font->min_byte1 = 0; @@ -8342,8 +8339,8 @@ x_query_font (f, fontname) for (i = 0; i < dpyinfo->n_fonts; i++) if (dpyinfo->font_table[i].name - && (!strcmp (dpyinfo->font_table[i].name, fontname) - || !strcmp (dpyinfo->font_table[i].full_name, fontname))) + && (!xstricmp (dpyinfo->font_table[i].name, fontname) + || !xstricmp (dpyinfo->font_table[i].full_name, fontname))) return (dpyinfo->font_table + i); return NULL; } @@ -8537,7 +8534,7 @@ Point saved_menu_event_location; /* Apple Events */ #if USE_CARBON_EVENTS -static Lisp_Object Qhicommand; +static Lisp_Object Qhi_command; #ifdef MAC_OSX extern Lisp_Object Qwindow; static Lisp_Object Qtoolbar_switch_mode; @@ -8579,7 +8576,7 @@ static Lisp_Object Qservice, Qpaste, Qperform; static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, EventRef, void *); #endif -OSErr install_window_handler (WindowPtr); +OSStatus install_window_handler (WindowPtr); extern void init_emacs_passwd_dir (); extern int emacs_main (int, char **, char **); @@ -9380,15 +9377,15 @@ mac_handle_command_event (next_handler, event, data) if (err != noErr || command.commandID == 0) return eventNotHandledErr; - /* A HICommand event is mapped to an Apple event whose event class - symbol is `hicommand' and event ID is its command ID. */ + /* A HI command event is mapped to an Apple event whose event class + symbol is `hi-command' and event ID is its command ID. */ err = mac_store_event_ref_as_apple_event (0, command.commandID, - Qhicommand, Qnil, + Qhi_command, Qnil, event, num_params, names, types); return err == noErr ? noErr : eventNotHandledErr; } -static OSErr +static OSStatus init_command_handler () { EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; @@ -9889,11 +9886,11 @@ mac_store_service_event (event) #endif /* USE_CARBON_EVENTS */ -OSErr +OSStatus install_window_handler (window) WindowPtr window; { - OSErr err = noErr; + OSStatus err = noErr; #if USE_CARBON_EVENTS EventTypeSpec specs_window[] = {{kEventClassWindow, kEventWindowUpdate}, @@ -11327,7 +11324,7 @@ static void init_menu_bar () { #ifdef MAC_OSX - OSErr err; + OSStatus err; MenuRef menu; MenuItemIndex menu_index; @@ -11511,7 +11508,7 @@ syms_of_macterm () Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); #if USE_CARBON_EVENTS - Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); + Qhi_command = intern ("hi-command"); staticpro (&Qhi_command); #ifdef MAC_OSX Qtoolbar_switch_mode = intern ("toolbar-switch-mode"); staticpro (&Qtoolbar_switch_mode); diff --git a/src/macterm.h b/src/macterm.h index fd71e36d28d..659a13bbb17 100644 --- a/src/macterm.h +++ b/src/macterm.h @@ -335,11 +335,6 @@ struct mac_output { /* Hints for the size and the position of a window. */ XSizeHints *size_hints; -#if TARGET_API_MAC_CARBON - /* File name for the proxy icon of this frame. Might be NULL. */ - char *file_name; -#endif - #if USE_CG_DRAWING /* Quartz 2D graphics context. */ CGContextRef cg_context; @@ -362,8 +357,6 @@ typedef struct mac_output mac_output; #define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints) -#define FRAME_FILE_NAME(f) ((f)->output_data.mac->file_name) - /* This gives the mac_display_info structure for the display F is on. */ #define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info) #define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info) @@ -631,7 +624,7 @@ extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); extern int mac_font_panel_visible_p P_ ((void)); extern OSStatus mac_show_hide_font_panel P_ ((void)); extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int)); -extern OSErr install_window_handler P_ ((WindowPtr)); +extern OSStatus install_window_handler P_ ((WindowPtr)); extern void remove_window_handler P_ ((WindowPtr)); extern void do_menu_choice P_ ((SInt32)); extern OSStatus mac_post_mouse_moved_event P_ ((void)); @@ -672,10 +665,10 @@ extern void mac_clear_font_name_table P_ ((void)); extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *)); extern OSErr mac_ae_put_lisp P_ ((AEDescList *, UInt32, Lisp_Object)); #if TARGET_API_MAC_CARBON -extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32, - EventParamName *, - EventParamType *, - AppleEvent *)); +extern OSStatus create_apple_event_from_event_ref P_ ((EventRef, UInt32, + EventParamName *, + EventParamType *, + AppleEvent *)); extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32, FlavorType *, AppleEvent *)); diff --git a/src/print.c b/src/print.c index 5f42683753d..d5ff1be6b31 100644 --- a/src/print.c +++ b/src/print.c @@ -924,6 +924,15 @@ to make it write to the debugging output. */) return character; } +/* This function is never called. Its purpose is to prevent + print_output_debug_flag from being optimized away. */ + +void +debug_output_compilation_hack (x) + int x; +{ + print_output_debug_flag = x; +} #if defined(GNU_LINUX) diff --git a/src/process.c b/src/process.c index 9dadc1ab4ab..f8ae50e8652 100644 --- a/src/process.c +++ b/src/process.c @@ -4163,6 +4163,14 @@ server_accept_connection (server, channel) when not inside wait_reading_process_output. */ static int waiting_for_user_input_p; +static Lisp_Object +wait_reading_process_output_unwind (data) + Lisp_Object data; +{ + waiting_for_user_input_p = XINT (data); + return Qnil; +} + /* This is here so breakpoints can be put on it. */ static void wait_reading_process_output_1 () @@ -4245,9 +4253,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, EMACS_TIME timeout, end_time; int wait_channel = -1; int got_some_input = 0; - /* Either nil or a cons cell, the car of which is of interest and - may be changed outside of this routine. */ - int saved_waiting_for_user_input_p = waiting_for_user_input_p; + int count = SPECPDL_INDEX (); FD_ZERO (&Available); #ifdef NON_BLOCKING_CONNECT @@ -4258,6 +4264,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (wait_proc != NULL) wait_channel = XINT (wait_proc->infd); + record_unwind_protect (wait_reading_process_output_unwind, + make_number (waiting_for_user_input_p)); waiting_for_user_input_p = read_kbd; /* Since we may need to wait several times, @@ -4884,7 +4892,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, } /* end for each file descriptor */ } /* end while exit conditions not met */ - waiting_for_user_input_p = saved_waiting_for_user_input_p; + unbind_to (count, Qnil); /* If calling from keyboard input, do not quit since we want to return C-g as an input character. diff --git a/src/puresize.h b/src/puresize.h index 5d39be5a541..d5a33e3cda5 100644 --- a/src/puresize.h +++ b/src/puresize.h @@ -43,7 +43,7 @@ Boston, MA 02110-1301, USA. */ #endif #ifndef BASE_PURESIZE -#define BASE_PURESIZE (1126000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) +#define BASE_PURESIZE (1130000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) #endif /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ diff --git a/src/w32.c b/src/w32.c index c093eab599e..0da908ff932 100644 --- a/src/w32.c +++ b/src/w32.c @@ -323,6 +323,28 @@ w32_strerror (int error_no) return buf; } +/* Return 1 if P is a valid pointer to an object of size SIZE. Return + 0 if P is NOT a valid pointer. Return -1 if we cannot validate P. + + This is called from alloc.c:valid_pointer_p. */ +int +w32_valid_pointer_p (void *p, int size) +{ + SIZE_T done; + HANDLE h = OpenProcess (PROCESS_VM_READ, FALSE, GetCurrentProcessId ()); + + if (h) + { + unsigned char *buf = alloca (size); + int retval = ReadProcessMemory (h, p, buf, size, &done); + + CloseHandle (h); + return retval; + } + else + return -1; +} + static char startup_dir[MAXPATHLEN]; /* Get the current working directory. */ diff --git a/src/w32.h b/src/w32.h index 1d5dbee6d40..6ba25a42403 100644 --- a/src/w32.h +++ b/src/w32.h @@ -110,6 +110,9 @@ extern void delete_child (child_process *cp); /* Equivalent of strerror for W32 error codes. */ extern char * w32_strerror (int error_no); +/* Validate a pointer. */ +extern int w32_valid_pointer_p (void *, int); + /* Get long (aka "true") form of file name, if it exists. */ extern BOOL w32_get_long_filename (char * name, char * buf, int size); diff --git a/src/w32fns.c b/src/w32fns.c index 68fcced88c2..8c6a60d47bf 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -2066,7 +2066,8 @@ w32_createwindow (f) { HWND hwnd; RECT rect; - Lisp_Object top, left; + Lisp_Object top = Qunbound; + Lisp_Object left = Qunbound; rect.left = rect.top = 0; rect.right = FRAME_PIXEL_WIDTH (f); @@ -2079,13 +2080,41 @@ w32_createwindow (f) if (!hprevinst) { + Lisp_Object ifa; + w32_init_class (hinst); + + /* Handle the -geometry command line option and the geometry + settings in the registry. They are decoded and put into + initial-frame-alist by w32-win.el:x-handle-geometry. */ + ifa = Fsymbol_value (intern ("initial-frame-alist")); + if (CONSP (ifa)) + { + Lisp_Object lt = Fassq (Qleft, ifa); + Lisp_Object tp = Fassq (Qtop, ifa); + + if (!NILP (lt)) + { + lt = XCDR (lt); + if (INTEGERP (lt)) + left = lt; + } + if (!NILP (tp)) + { + tp = XCDR (tp); + if (INTEGERP (tp)) + top = tp; + } + } } - /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero - for anything that is not a number and is not Qunbound. */ - left = w32_get_arg (Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER); - top = w32_get_arg (Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER); + if (EQ (left, Qunbound) && EQ (top, Qunbound)) + { + /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero + for anything that is not a number and is not Qunbound. */ + left = w32_get_arg (Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER); + top = w32_get_arg (Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER); + } FRAME_W32_WINDOW (f) = hwnd = CreateWindow (EMACS_CLASS, @@ -6207,7 +6236,7 @@ w32_query_font (struct frame *f, char *fontname) for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) { - if (strcmp(pfi->name, fontname) == 0) return pfi; + if (stricmp(pfi->name, fontname) == 0) return pfi; } return NULL; @@ -6326,17 +6355,12 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); if (w32_defined_color (f, SDATA (color), &foo, 0)) - { - Lisp_Object rgb[3]; - - rgb[0] = make_number ((GetRValue (foo.pixel) << 8) - | GetRValue (foo.pixel)); - rgb[1] = make_number ((GetGValue (foo.pixel) << 8) - | GetGValue (foo.pixel)); - rgb[2] = make_number ((GetBValue (foo.pixel) << 8) - | GetBValue (foo.pixel)); - return Flist (3, rgb); - } + return list3 (make_number ((GetRValue (foo.pixel) << 8) + | GetRValue (foo.pixel)), + make_number ((GetGValue (foo.pixel) << 8) + | GetGValue (foo.pixel)), + make_number ((GetBValue (foo.pixel) << 8) + | GetBValue (foo.pixel))); else return Qnil; } diff --git a/src/w32menu.c b/src/w32menu.c index 389e6c5b856..11af1d66b6f 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -1994,6 +1994,9 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) } } } + else if (!for_click) + /* Make "Cancel" equivalent to C-g. */ + Fsignal (Qquit, Qnil); return Qnil; } @@ -2186,6 +2189,9 @@ w32_dialog_show (f, keymaps, title, header, error) } } } + else + /* Make "Cancel" equivalent to C-g. */ + Fsignal (Qquit, Qnil); return Qnil; } diff --git a/src/w32term.c b/src/w32term.c index b564ed3bd2b..2870955b94f 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -91,6 +91,10 @@ static Lisp_Object last_window; (Not yet supported, see TODO in x_draw_glyph_string.) */ int x_use_underline_position_properties; +/* Non-zero means to draw the underline at the same place as the descent line. */ + +int x_underline_at_descent_line; + extern unsigned int msh_mousewheel; extern void free_frame_menubar (); @@ -2418,7 +2422,9 @@ x_draw_stretch_glyph_string (s) int background_width = s->background_width; int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); - if (x < left_x) + /* Don't draw into left margin, fringe or scrollbar area + except for header line and mode line. */ + if (x < left_x && !s->row->mode_line_p) { background_width -= left_x - x; x = left_x; @@ -2507,21 +2513,27 @@ x_draw_glyph_string (s) && (s->font->bdf || !s->font->tm.tmUnderlined)) { unsigned long h = 1; - unsigned long dy = s->height - h; + unsigned long dy = 0; - /* TODO: Use font information for positioning and thickness - of underline. See OUTLINETEXTMETRIC, and xterm.c. - Note: If you make this work, don't forget to change the - doc string of x-use-underline-position-properties below. */ + if (x_underline_at_descent_line) + dy = s->height - h; + else + { + /* TODO: Use font information for positioning and thickness of + underline. See OUTLINETEXTMETRIC, and xterm.c. Note: If + you make this work, don't forget to change the doc string of + x-use-underline-position-properties below. */ + dy = s->height - h; + } if (s->face->underline_defaulted_p) { w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, - s->y + dy, s->width, 1); + s->y + dy, s->background_width, 1); } else { w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, - s->y + dy, s->width, 1); + s->y + dy, s->background_width, 1); } } @@ -2533,12 +2545,12 @@ x_draw_glyph_string (s) if (s->face->overline_color_defaulted_p) { w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, - s->y + dy, s->width, h); + s->y + dy, s->background_width, h); } else { w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x, - s->y + dy, s->width, h); + s->y + dy, s->background_width, h); } } @@ -6509,6 +6521,14 @@ to 4.1, set this to nil. NOTE: Not supported on MS-Windows yet. */); x_use_underline_position_properties = 0; + DEFVAR_BOOL ("x-underline-at-descent-line", + &x_underline_at_descent_line, + doc: /* *Non-nil means to draw the underline at the same place as the descent line. +nil means to draw the underline according to the value of the variable +`x-use-underline-position-properties', which is usually at the baseline +level. The default value is nil. */); + x_underline_at_descent_line = 0; + DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, doc: /* If not nil, Emacs uses toolkit scroll bars. */); Vx_toolkit_scroll_bars = Qt; diff --git a/src/window.c b/src/window.c index 879777d25e1..a3e7b93e878 100644 --- a/src/window.c +++ b/src/window.c @@ -6658,10 +6658,12 @@ display marginal areas and the text area. */) CHECK_NATNUM (left_width); if (!NILP (right_width)) CHECK_NATNUM (right_width); - - if (!EQ (w->left_fringe_width, left_width) - || !EQ (w->right_fringe_width, right_width) - || !EQ (w->fringes_outside_margins, outside_margins)) + + /* Do nothing on a tty. */ + if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) + && (!EQ (w->left_fringe_width, left_width) + || !EQ (w->right_fringe_width, right_width) + || !EQ (w->fringes_outside_margins, outside_margins))) { w->left_fringe_width = left_width; w->right_fringe_width = right_width; @@ -6689,10 +6691,11 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) Lisp_Object window; { struct window *w = decode_window (window); + return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), - Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ? - Qt : Qnil), Qnil))); + Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? Qt : Qnil), Qnil))); } diff --git a/src/xdisp.c b/src/xdisp.c index 76ab430386c..7e65b91fd13 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -701,6 +701,10 @@ Lisp_Object Vresize_mini_windows; struct buffer *displayed_buffer; +/* Space between overline and text. */ + +EMACS_INT overline_margin; + /* Value returned from text property handlers (see below). */ enum prop_handled @@ -887,7 +891,7 @@ static void redisplay_window P_ ((Lisp_Object, int)); static Lisp_Object redisplay_window_error (); static Lisp_Object redisplay_window_0 P_ ((Lisp_Object)); static Lisp_Object redisplay_window_1 P_ ((Lisp_Object)); -static void update_menu_bar P_ ((struct frame *, int)); +static int update_menu_bar P_ ((struct frame *, int, int)); static int try_window_reusing_current_matrix P_ ((struct window *)); static int try_window_id P_ ((struct window *)); static int display_line P_ ((struct it *)); @@ -9038,6 +9042,9 @@ prepare_menu_bars () { Lisp_Object tail, frame; int count = SPECPDL_INDEX (); + /* 1 means that update_menu_bar has run its hooks + so any further calls to update_menu_bar shouldn't do so again. */ + int menu_bar_hooks_run = 0; record_unwind_save_match_data (); @@ -9069,7 +9076,7 @@ prepare_menu_bars () } GCPRO1 (tail); - update_menu_bar (f, 0); + menu_bar_hooks_run = update_menu_bar (f, 0, menu_bar_hooks_run); #ifdef HAVE_WINDOW_SYSTEM update_tool_bar (f, 0); #ifdef MAC_OS @@ -9084,7 +9091,7 @@ prepare_menu_bars () else { struct frame *sf = SELECTED_FRAME (); - update_menu_bar (sf, 1); + update_menu_bar (sf, 1, 0); #ifdef HAVE_WINDOW_SYSTEM update_tool_bar (sf, 1); #ifdef MAC_OS @@ -9105,12 +9112,18 @@ prepare_menu_bars () before we start to fill in any display lines, because it can call eval. - If SAVE_MATCH_DATA is non-zero, we must save and restore it here. */ + If SAVE_MATCH_DATA is non-zero, we must save and restore it here. -static void -update_menu_bar (f, save_match_data) + If HOOKS_RUN is 1, that means a previous call to update_menu_bar + already ran the menu bar hooks for this redisplay, so there + is no need to run them again. The return value is the + updated value of this flag, to pass to the next call. */ + +static int +update_menu_bar (f, save_match_data, hooks_run) struct frame *f; int save_match_data; + int hooks_run; { Lisp_Object window; register struct window *w; @@ -9175,15 +9188,21 @@ update_menu_bar (f, save_match_data) specbind (Qoverriding_local_map, Qnil); } - /* Run the Lucid hook. */ - safe_run_hooks (Qactivate_menubar_hook); + if (!hooks_run) + { + /* Run the Lucid hook. */ + safe_run_hooks (Qactivate_menubar_hook); - /* If it has changed current-menubar from previous value, - really recompute the menu-bar from the value. */ - if (! NILP (Vlucid_menu_bar_dirty_flag)) - call0 (Qrecompute_lucid_menubar); + /* If it has changed current-menubar from previous value, + really recompute the menu-bar from the value. */ + if (! NILP (Vlucid_menu_bar_dirty_flag)) + call0 (Qrecompute_lucid_menubar); + + safe_run_hooks (Qmenu_bar_update_hook); + + hooks_run = 1; + } - safe_run_hooks (Qmenu_bar_update_hook); FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); /* Redisplay the menu bar in case we changed it. */ @@ -9212,6 +9231,8 @@ update_menu_bar (f, save_match_data) set_buffer_internal_1 (prev); } } + + return hooks_run; } @@ -9376,7 +9397,8 @@ update_tool_bar (f, save_match_data) &new_n_tool_bar); /* Redisplay the tool-bar if we changed it. */ - if (NILP (Fequal (new_tool_bar, f->tool_bar_items))) + if (new_n_tool_bar != f->n_tool_bar_items + || NILP (Fequal (new_tool_bar, f->tool_bar_items))) { /* Redisplay that happens asynchronously due to an expose event may access f->tool_bar_items. Make sure we update both @@ -20354,7 +20376,7 @@ x_produce_glyphs (it) /* If face has an overline, add the height of the overline (1 pixel) and a 1 pixel margin to the character height. */ if (face->overline_p) - it->ascent += 2; + it->ascent += overline_margin; if (it->constrain_row_ascent_descent_p) { @@ -20556,7 +20578,7 @@ x_produce_glyphs (it) /* If face has an overline, add the height of the overline (1 pixel) and a 1 pixel margin to the character height. */ if (face->overline_p) - it->ascent += 2; + it->ascent += overline_margin; take_vertical_position_into_account (it); @@ -20831,7 +20853,7 @@ x_produce_glyphs (it) /* If face has an overline, add the height of the overline (1 pixel) and a 1 pixel margin to the character height. */ if (face->overline_p) - it->ascent += 2; + it->ascent += overline_margin; take_vertical_position_into_account (it); @@ -24108,6 +24130,12 @@ whose contents depend on various data. */); doc: /* Inhibit try_cursor_movement display optimization. */); inhibit_try_cursor_movement = 0; #endif /* GLYPH_DEBUG */ + + DEFVAR_INT ("overline-margin", &overline_margin, + doc: /* *Space between overline and text, in pixels. +The default value is 2: the height of the overline (1 pixel) plus 1 pixel +margin to the caracter height. */); + overline_margin = 2; } diff --git a/src/xfaces.c b/src/xfaces.c index 18e5d9a6119..6373100484a 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -1192,7 +1192,7 @@ load_pixmap (f, name, w_ptr, h_ptr) if (bitmap_id < 0) { - add_to_log ("Invalid or undefined bitmap %s", name, Qnil); + add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil); bitmap_id = 0; if (w_ptr) @@ -5734,6 +5734,8 @@ lookup_named_face (f, symbol, c, signal_p) if (!realize_basic_faces (f)) return -1; default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + if (default_face == NULL) + abort (); /* realize_basic_faces must have set it up */ } if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p)) @@ -6238,6 +6240,8 @@ face for italic. */) if (! realize_basic_faces (f)) error ("Cannot realize default face"); def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + if (def_face == NULL) + abort (); /* realize_basic_faces must have set it up */ } /* Dispatch to the appropriate handler. */ diff --git a/src/xfns.c b/src/xfns.c index 3cadc8504f4..d5b8a01cf20 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3495,14 +3495,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); if (x_defined_color (f, SDATA (color), &foo, 0)) - { - Lisp_Object rgb[3]; - - rgb[0] = make_number (foo.red); - rgb[1] = make_number (foo.green); - rgb[2] = make_number (foo.blue); - return Flist (3, rgb); - } + return list3 (make_number (foo.red), + make_number (foo.green), + make_number (foo.blue)); else return Qnil; } diff --git a/src/xselect.c b/src/xselect.c index 211d207bac4..cd49e05171b 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -2709,8 +2709,48 @@ If the value is 0 or the atom is not known, return the empty string. */) return ret; } -/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. - TODO: Check if this client event really is a DND event? */ +DEFUN ("x-register-dnd-atom", Fx_register_dnd_atom, + Sx_register_dnd_atom, 1, 2, 0, + doc: /* Request that dnd events are made for ClientMessages with ATOM. +ATOM can be a symbol or a string. The ATOM is interned on the display that +FRAME is on. If FRAME is nil, the selected frame is used. */) + (atom, frame) + Lisp_Object atom, frame; +{ + Atom x_atom; + struct frame *f = check_x_frame (frame); + size_t i; + struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); + + + if (SYMBOLP (atom)) + x_atom = symbol_to_x_atom (dpyinfo, FRAME_X_DISPLAY (f), atom); + else if (STRINGP (atom)) + { + BLOCK_INPUT; + x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False); + UNBLOCK_INPUT; + } + else + error ("ATOM must be a symbol or a string"); + + for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) + if (dpyinfo->x_dnd_atoms[i] == x_atom) + return Qnil; + + if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size) + { + dpyinfo->x_dnd_atoms_size *= 2; + dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms, + sizeof (*dpyinfo->x_dnd_atoms) + * dpyinfo->x_dnd_atoms_size); + } + + dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom; + return Qnil; +} + +/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ int x_handle_dnd_message (f, event, dpyinfo, bufp) @@ -2726,6 +2766,12 @@ x_handle_dnd_message (f, event, dpyinfo, bufp) int x, y; unsigned char *data = (unsigned char *) event->data.b; int idata[5]; + size_t i; + + for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) + if (dpyinfo->x_dnd_atoms[i] == event->message_type) break; + + if (i == dpyinfo->x_dnd_atoms_length) return 0; XSETFRAME (frame, f); @@ -2899,6 +2945,7 @@ syms_of_xselect () defsubr (&Sx_get_atom_name); defsubr (&Sx_send_client_message); + defsubr (&Sx_register_dnd_atom); reading_selection_reply = Fcons (Qnil, Qnil); staticpro (&reading_selection_reply); diff --git a/src/xterm.c b/src/xterm.c index 5df7896a2b3..466037c75a2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -181,6 +181,10 @@ static Lisp_Object last_window; int x_use_underline_position_properties; +/* Non-zero means to draw the underline at the same place as the descent line. */ + +int x_underline_at_descent_line; + /* This is a chain of structures for all the X displays currently in use. */ @@ -2601,7 +2605,9 @@ x_draw_stretch_glyph_string (s) int background_width = s->background_width; int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); - if (x < left_x) + /* Don't draw into left margin, fringe or scrollbar area + except for header line and mode line. */ + if (x < left_x && !s->row->mode_line_p) { background_width -= left_x - x; x = left_x; @@ -2695,32 +2701,35 @@ x_draw_glyph_string (s) if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) h = 1; - /* Get the underline position. This is the recommended - vertical offset in pixels from the baseline to the top of - the underline. This is a signed value according to the - specs, and its default is - - ROUND ((maximum descent) / 2), with - ROUND(x) = floor (x + 0.5) */ - - if (x_use_underline_position_properties - && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem)) - y = s->ybase + (long) tem; - else if (s->face->font) - y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2; - else + if (x_underline_at_descent_line) y = s->y + s->height - h; + else + { + /* Get the underline position. This is the recommended + vertical offset in pixels from the baseline to the top of + the underline. This is a signed value according to the + specs, and its default is + + ROUND ((maximum descent) / 2), with + ROUND(x) = floor (x + 0.5) */ + + if (x_use_underline_position_properties + && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem)) + y = s->ybase + (long) tem; + else if (s->face->font) + y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2; + } if (s->face->underline_defaulted_p) XFillRectangle (s->display, s->window, s->gc, - s->x, y, s->width, h); + s->x, y, s->background_width, h); else { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground, &xgcv); XSetForeground (s->display, s->gc, s->face->underline_color); XFillRectangle (s->display, s->window, s->gc, - s->x, y, s->width, h); + s->x, y, s->background_width, h); XSetForeground (s->display, s->gc, xgcv.foreground); } } @@ -2732,14 +2741,14 @@ x_draw_glyph_string (s) if (s->face->overline_color_defaulted_p) XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); else { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground, &xgcv); XSetForeground (s->display, s->gc, s->face->overline_color); XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, - s->width, h); + s->background_width, h); XSetForeground (s->display, s->gc, xgcv.foreground); } } @@ -10096,8 +10105,8 @@ x_query_font (f, fontname) for (i = 0; i < dpyinfo->n_fonts; i++) if (dpyinfo->font_table[i].name - && (!strcmp (dpyinfo->font_table[i].name, fontname) - || !strcmp (dpyinfo->font_table[i].full_name, fontname))) + && (!strcasecmp (dpyinfo->font_table[i].name, fontname) + || !strcasecmp (dpyinfo->font_table[i].full_name, fontname))) return (dpyinfo->font_table + i); return NULL; } @@ -10644,6 +10653,11 @@ x_term_init (display_name, xrm_option, resource_name) dpyinfo->cut_buffers_initialized = 0; + dpyinfo->x_dnd_atoms_size = 8; + dpyinfo->x_dnd_atoms_length = 0; + dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) + * dpyinfo->x_dnd_atoms_size); + connection = ConnectionNumber (dpyinfo->display); dpyinfo->connection = connection; @@ -11104,6 +11118,14 @@ UNDERLINE_POSITION font properties, for example 7x13 on XFree prior to 4.1, set this to nil. */); x_use_underline_position_properties = 1; + DEFVAR_BOOL ("x-underline-at-descent-line", + &x_underline_at_descent_line, + doc: /* *Non-nil means to draw the underline at the same place as the descent line. +nil means to draw the underline according to the value of the variable +`x-use-underline-position-properties', which is usually at the baseline +level. The default value is nil. */); + x_underline_at_descent_line = 0; + DEFVAR_BOOL ("x-mouse-click-focus-ignore-position", &x_mouse_click_focus_ignore_position, doc: /* Non-nil means that a mouse click to focus a frame does not move point. diff --git a/src/xterm.h b/src/xterm.h index 6bbcdc6389d..8f7055d95d5 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -389,6 +389,12 @@ struct x_display_info X_WMTYPE_A, X_WMTYPE_B } wm_type; + + + /* Atoms that are drag and drop atoms */ + Atom *x_dnd_atoms; + size_t x_dnd_atoms_size; + size_t x_dnd_atoms_length; }; #ifdef HAVE_X_I18N |