Now on revision 113441. ------------------------------------------------------------ revno: 113441 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 21:37:27 -0700 message: A few more minor file errno-reporting bugs. * callproc.c (Fcall_process): * doc.c (Fsnarf_documentation): * fileio.c (Frename_file, Fadd_name_to_file, Fmake_symbolic_link): * process.c (set_socket_option): Don't let a constructor trash errno. * doc.c: Include . diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 23:29:05 +0000 +++ src/ChangeLog 2013-07-17 04:37:27 +0000 @@ -1,3 +1,13 @@ +2013-07-17 Paul Eggert + + A few more minor file errno-reporting bugs. + * callproc.c (Fcall_process): + * doc.c (Fsnarf_documentation): + * fileio.c (Frename_file, Fadd_name_to_file, Fmake_symbolic_link): + * process.c (set_socket_option): + Don't let a constructor trash errno. + * doc.c: Include . + 2013-07-16 Juanma Barranquero * w32fns.c (unwind_create_tip_frame): Fix declaration. === modified file 'src/callproc.c' --- src/callproc.c 2013-07-16 22:40:17 +0000 +++ src/callproc.c 2013-07-17 04:37:27 +0000 @@ -405,7 +405,11 @@ filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); if (filefd < 0) - report_file_error ("Opening process input file", DECODE_FILE (infile)); + { + int open_errno = errno; + report_file_errno ("Opening process input file", DECODE_FILE (infile), + open_errno); + } if (STRINGP (output_file)) { === modified file 'src/doc.c' --- src/doc.c 2013-07-16 16:39:42 +0000 +++ src/doc.c 2013-07-17 04:37:27 +0000 @@ -21,6 +21,7 @@ #include +#include #include #include /* Must be after sys/types.h for USG. */ #include @@ -609,7 +610,11 @@ fd = emacs_open (name, O_RDONLY, 0); if (fd < 0) - report_file_error ("Opening doc string file", build_string (name)); + { + int open_errno = errno; + report_file_errno ("Opening doc string file", build_string (name), + open_errno); + } Vdoc_file_name = filename; filled = 0; pos = 0; === modified file 'src/fileio.c' --- src/fileio.c 2013-07-16 21:49:32 +0000 +++ src/fileio.c 2013-07-17 04:37:27 +0000 @@ -204,7 +204,9 @@ } /* Signal a file-access failure that set errno. STRING describes the - failure, NAME the file involved. */ + failure, NAME the file involved. When invoking this function, take + care to not use arguments such as build_string ("foo") that involve + side effects that may set errno. */ void report_file_error (char const *string, Lisp_Object name) @@ -2371,7 +2373,8 @@ INTEGERP (ok_if_already_exists), 0, 0); if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) { - if (errno == EXDEV) + int rename_errno = errno; + if (rename_errno == EXDEV) { ptrdiff_t count; symlink_target = Ffile_symlink_p (file); @@ -2397,7 +2400,7 @@ unbind_to (count, Qnil); } else - report_file_error ("Renaming", list2 (file, newname)); + report_file_errno ("Renaming", list2 (file, newname), rename_errno); } UNGCPRO; return Qnil; @@ -2451,7 +2454,10 @@ unlink (SSDATA (newname)); if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) - report_file_error ("Adding new name", list2 (file, newname)); + { + int link_errno = errno; + report_file_errno ("Adding new name", list2 (file, newname), link_errno); + } UNGCPRO; return Qnil; @@ -2510,6 +2516,7 @@ if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) < 0) { /* If we didn't complain already, silently delete existing file. */ + int symlink_errno; if (errno == EEXIST) { unlink (SSDATA (encoded_linkname)); @@ -2527,7 +2534,9 @@ build_string ("Symbolic links are not supported")); } - report_file_error ("Making symbolic link", list2 (filename, linkname)); + symlink_errno = errno; + report_file_errno ("Making symbolic link", list2 (filename, linkname), + symlink_errno); } UNGCPRO; return Qnil; === modified file 'src/process.c' --- src/process.c 2013-07-16 21:35:45 +0000 +++ src/process.c 2013-07-17 04:37:27 +0000 @@ -2321,7 +2321,12 @@ } if (ret < 0) - report_file_error ("Cannot set network option", list2 (opt, val)); + { + int setsockopt_errno = errno; + report_file_errno ("Cannot set network option", list2 (opt, val), + setsockopt_errno); + } + return (1 << sopt->optbit); } ------------------------------------------------------------ revno: 113440 committer: Juanma Barranquero branch nick: trunk timestamp: Wed 2013-07-17 01:29:05 +0200 message: src/w32fns.c (unwind_create_tip_frame): Fix declaration. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 22:40:17 +0000 +++ src/ChangeLog 2013-07-16 23:29:05 +0000 @@ -1,3 +1,7 @@ +2013-07-16 Juanma Barranquero + + * w32fns.c (unwind_create_tip_frame): Fix declaration. + 2013-07-16 Paul Eggert Fix w32 bug with call-process-region (Bug#14885). === modified file 'src/w32fns.c' --- src/w32fns.c 2013-07-16 21:35:45 +0000 +++ src/w32fns.c 2013-07-16 23:29:05 +0000 @@ -318,7 +318,7 @@ static Lisp_Object unwind_create_frame (Lisp_Object); -static Lisp_Object unwind_create_tip_frame (Lisp_Object); +static void unwind_create_tip_frame (Lisp_Object); static void my_create_window (struct frame *); static void my_create_tip_window (struct frame *); ------------------------------------------------------------ revno: 113439 fixes bug: http://debbugs.gnu.org/14885 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 15:40:17 -0700 message: Fix w32 bug with call-process-region. * callproc.c (Fcall_process_region): Pass nil, not "/dev/null", to Fcall_process when the input is empty. This simplifies the code a bit. It makes no difference on POSIXish platforms but apparently it fixes a bug on w32. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 21:49:32 +0000 +++ src/ChangeLog 2013-07-16 22:40:17 +0000 @@ -1,6 +1,12 @@ 2013-07-16 Paul Eggert - Fix bug where Emacs tries to close a file twice (Bug#14839). + Fix w32 bug with call-process-region (Bug#14885). + * callproc.c (Fcall_process_region): Pass nil, not "/dev/null", + to Fcall_process when the input is empty. This simplifies the + code a bit. It makes no difference on POSIXish platforms but + apparently it fixes a bug on w32. + + Fix bug where insert-file-contents closes a file twice. (Bug#14839). * fileio.c (close_file_unwind): Don't close if FD is negative; this can happen when unwinding a zapped file descriptor. (Finsert_file_contents): Unwind-protect the fd before the point marker, === modified file 'src/callproc.c' --- src/callproc.c 2013-07-16 21:35:45 +0000 +++ src/callproc.c 2013-07-16 22:40:17 +0000 @@ -1093,7 +1093,7 @@ (ptrdiff_t nargs, Lisp_Object *args) { struct gcpro gcpro1; - Lisp_Object filename_string; + Lisp_Object infile; ptrdiff_t count = SPECPDL_INDEX (); Lisp_Object start = args[0]; Lisp_Object end = args[1]; @@ -1111,10 +1111,8 @@ empty_input = XINT (start) == XINT (end); } - filename_string = (empty_input - ? build_string (NULL_DEVICE) - : create_temp_file (nargs, args)); - GCPRO1 (filename_string); + infile = empty_input ? Qnil : create_temp_file (nargs, args); + GCPRO1 (infile); if (nargs > 3 && !NILP (args[3])) Fdelete_region (start, end); @@ -1129,7 +1127,7 @@ args[0] = args[2]; nargs = 2; } - args[1] = filename_string; + args[1] = infile; RETURN_UNGCPRO (unbind_to (count, Fcall_process (nargs, args))); } ------------------------------------------------------------ revno: 113438 fixes bug: http://debbugs.gnu.org/14839 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 14:49:32 -0700 message: Fix bug where insert-file-contents closes a file twice. * fileio.c (close_file_unwind): Don't close if FD is negative; this can happen when unwinding a zapped file descriptor. (Finsert_file_contents): Unwind-protect the fd before the point marker, in case Emacs runs out of memory between the two unwind-protects. Don't trash errno when closing FD. Zap the FD in the specpdl when closing it, instead of deferring the removal of the unwind-protect; this fixes a bug where a child function unwinds the stack past us. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 21:35:45 +0000 +++ src/ChangeLog 2013-07-16 21:49:32 +0000 @@ -1,5 +1,15 @@ 2013-07-16 Paul Eggert + Fix bug where Emacs tries to close a file twice (Bug#14839). + * fileio.c (close_file_unwind): Don't close if FD is negative; + this can happen when unwinding a zapped file descriptor. + (Finsert_file_contents): Unwind-protect the fd before the point marker, + in case Emacs runs out of memory between the two unwind-protects. + Don't trash errno when closing FD. + Zap the FD in the specpdl when closing it, instead of deferring + the removal of the unwind-protect; this fixes a bug where a child + function unwinds the stack past us. + New unwind-protect flavors to better type-check C callbacks. This also lessens the need to write wrappers for callbacks, and the need for make_save_pointer. === modified file 'src/fileio.c' --- src/fileio.c 2013-07-16 21:35:45 +0000 +++ src/fileio.c 2013-07-16 21:49:32 +0000 @@ -215,7 +215,8 @@ void close_file_unwind (int fd) { - emacs_close (fd); + if (0 <= fd) + emacs_close (fd); } /* Restore point, having saved it as a marker. */ @@ -3514,7 +3515,7 @@ && BEG == Z); Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark; bool we_locked_file = 0; - bool deferred_remove_unwind_protect = 0; + ptrdiff_t fd_index; if (current_buffer->base_buffer && ! NILP (visit)) error ("Cannot do file visiting in an indirect buffer"); @@ -3565,12 +3566,13 @@ goto notfound; } + fd_index = SPECPDL_INDEX (); + record_unwind_protect_int (close_file_unwind, fd); + /* Replacement should preserve point as it preserves markers. */ if (!NILP (replace)) record_unwind_protect (restore_point_unwind, Fpoint_marker ()); - record_unwind_protect_int (close_file_unwind, fd); - if (fstat (fd, &st) != 0) report_file_error ("Input file status", orig_filename); mtime = get_stat_mtime (&st); @@ -4015,15 +4017,10 @@ memcpy (read_buf, coding.carryover, unprocessed); } UNGCPRO; - emacs_close (fd); - - /* We should remove the unwind_protect calling - close_file_unwind, but other stuff has been added the stack, - so defer the removal till we reach the `handled' label. */ - deferred_remove_unwind_protect = 1; - if (this < 0) report_file_error ("Read error", orig_filename); + emacs_close (fd); + set_unwind_protect_int (fd_index, -1); if (unprocessed > 0) { @@ -4264,9 +4261,7 @@ Vdeactivate_mark = Qt; emacs_close (fd); - - /* Discard the unwind protect for closing the file. */ - specpdl_ptr--; + set_unwind_protect_int (fd_index, -1); if (how_much < 0) report_file_error ("Read error", orig_filename); @@ -4393,11 +4388,6 @@ handled: - if (deferred_remove_unwind_protect) - /* If requested above, discard the unwind protect for closing the - file. */ - specpdl_ptr--; - if (!NILP (visit)) { if (empty_undo_list_p) === modified file 'src/lisp.h' --- src/lisp.h 2013-07-16 21:35:45 +0000 +++ src/lisp.h 2013-07-16 21:49:32 +0000 @@ -2750,6 +2750,12 @@ specpdl[count].unwind_ptr.arg = arg; } +LISP_INLINE void +set_unwind_protect_int (ptrdiff_t count, int arg) +{ + specpdl[count].unwind_int.arg = arg; +} + /* Everything needed to describe an active condition case. Members are volatile if their values need to survive _longjmp when ------------------------------------------------------------ revno: 113437 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 14:35:45 -0700 message: New unwind-protect flavors to better type-check C callbacks. This also lessens the need to write wrappers for callbacks, and the need for make_save_pointer. * alloca.c (free_save_value): * atimer.c (run_all_atimers): Now extern. * alloc.c (safe_alloca_unwind): * atimer.c (unwind_stop_other_atimers): * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]: * menu.c (cleanup_popup_menu) [HAVE_NS]: * minibuf.c (choose_minibuf_frame_1): * process.c (make_serial_process_unwind): * xdisp.h (pop_message_unwind): * xselect.c (queue_selection_requests_unwind): Remove no-longer-needed wrapper. All uses replaced by the wrappee. * alloca.c (record_xmalloc): Prefer record_unwind_protect_ptr to record_unwind_protect with make_save_pointer. * alloca.c (Fgarbage_collect): Prefer record_unwind_protect_void to passing a dummy. * buffer.c (restore_buffer): * window.c (restore_window_configuration): * xfns.c, w32fns.c (do_unwind_create_frame) New wrapper. All record-unwind uses of wrappee changed. * buffer.c (set_buffer_if_live): * callproc.c (call_process_cleanup, delete_temp_file): * coding.c (code_conversion_restore): * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]: * editfns.c (save_excursion_restore) (subst_char_in_region_unwind, subst_char_in_region_unwind_1) (save_restriction_restore): * eval.c (restore_stack_limits, un_autoload): * fns.c (require_unwind): * keyboard.c (recursive_edit_unwind, tracking_off): * lread.c (record_load_unwind, load_warn_old_style_backquotes): * macros.c (pop_kbd_macro, restore_menu_items): * nsfns.m (unwind_create_frame): * print.c (print_unwind): * process.c (start_process_unwind): * search.c (unwind_set_match_data): * window.c (select_window_norecord, select_frame_norecord): * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line) (fast_set_selected_frame): * xfns.c, w32fns.c (unwind_create_tip_frame): Return void, not a dummy Lisp_Object. All uses changed. * buffer.h (set_buffer_if_live): Move decl here from lisp.h. * callproc.c (call_process_kill): * fileio.c (restore_point_unwind, decide_coding_unwind) (build_annotations_unwind): * insdel.c (Fcombine_after_change_execute_1): * keyboard.c (read_char_help_form_unwind): * menu.c (unuse_menu_items): * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind): * sound.c (sound_cleanup): * xdisp.c (unwind_redisplay): * xfns.c (clean_up_dialog): * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind): Accept no args and return void, instead of accepting and returning a dummy Lisp_Object. All uses changed. * cygw32.c (fchdir_unwind): * fileio.c (close_file_unwind): * keyboard.c (restore_kboard_configuration): * lread.c (readevalllop_1): * process.c (wait_reading_process_output_unwind): Accept int and return void, rather than accepting an Emacs integer and returning a dummy object. In some cases this fixes an unlikely bug when the corresponding int is outside Emacs integer range. All uses changed. * dired.c (directory_files_internal_unwind): * fileio.c (do_auto_save_unwind): * gtkutil.c (pop_down_dialog): * insdel.c (reset_var_on_error): * lread.c (load_unwind): * xfns.c (clean_up_file_dialog): * xmenu.c, nsmenu.m (pop_down_menu): * xmenu.c (cleanup_widget_value_tree): * xselect.c (wait_for_property_change_unwind): Accept pointer and return void, rather than accepting an Emacs save value encapsulating the pointer and returning a dummy object. All uses changed. * editfns.c (Fformat): Update the saved pointer directly via set_unwind_protect_ptr rather than indirectly via make_save_pointer. * eval.c (specpdl_func): Remove. All uses replaced by definiens. (unwind_body): New function. (record_unwind_protect): First arg is now a function returning void, not a dummy Lisp_Object. (record_unwind_protect_ptr, record_unwind_protect_int) (record_unwind_protect_void): New functions. (unbind_to): Support SPECPDL_UNWIND_PTR etc. * fileio.c (struct auto_save_unwind): New type. (do_auto_save_unwind): Use it. (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind. * insdel.c (struct rvoe_arg): New type. (reset_var_on_error): Use it. * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID): New constants. (specbinding_func): Remove; there are now several such functions. (union specbinding): New members unwind_ptr, unwind_int, unwind_void. (set_unwind_protect_ptr): New function. * xselect.c: Remove unnecessary forward decls, to simplify maintenance. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 18:30:52 +0000 +++ src/ChangeLog 2013-07-16 21:35:45 +0000 @@ -1,5 +1,106 @@ 2013-07-16 Paul Eggert + New unwind-protect flavors to better type-check C callbacks. + This also lessens the need to write wrappers for callbacks, + and the need for make_save_pointer. + * alloca.c (free_save_value): + * atimer.c (run_all_atimers): + Now extern. + * alloc.c (safe_alloca_unwind): + * atimer.c (unwind_stop_other_atimers): + * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]: + * menu.c (cleanup_popup_menu) [HAVE_NS]: + * minibuf.c (choose_minibuf_frame_1): + * process.c (make_serial_process_unwind): + * xdisp.h (pop_message_unwind): + * xselect.c (queue_selection_requests_unwind): + Remove no-longer-needed wrapper. All uses replaced by the wrappee. + * alloca.c (record_xmalloc): + Prefer record_unwind_protect_ptr to record_unwind_protect with + make_save_pointer. + * alloca.c (Fgarbage_collect): + Prefer record_unwind_protect_void to passing a dummy. + * buffer.c (restore_buffer): + * window.c (restore_window_configuration): + * xfns.c, w32fns.c (do_unwind_create_frame) + New wrapper. All record-unwind uses of wrappee changed. + * buffer.c (set_buffer_if_live): + * callproc.c (call_process_cleanup, delete_temp_file): + * coding.c (code_conversion_restore): + * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]: + * editfns.c (save_excursion_restore) + (subst_char_in_region_unwind, subst_char_in_region_unwind_1) + (save_restriction_restore): + * eval.c (restore_stack_limits, un_autoload): + * fns.c (require_unwind): + * keyboard.c (recursive_edit_unwind, tracking_off): + * lread.c (record_load_unwind, load_warn_old_style_backquotes): + * macros.c (pop_kbd_macro, restore_menu_items): + * nsfns.m (unwind_create_frame): + * print.c (print_unwind): + * process.c (start_process_unwind): + * search.c (unwind_set_match_data): + * window.c (select_window_norecord, select_frame_norecord): + * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line) + (fast_set_selected_frame): + * xfns.c, w32fns.c (unwind_create_tip_frame): + Return void, not a dummy Lisp_Object. All uses changed. + * buffer.h (set_buffer_if_live): Move decl here from lisp.h. + * callproc.c (call_process_kill): + * fileio.c (restore_point_unwind, decide_coding_unwind) + (build_annotations_unwind): + * insdel.c (Fcombine_after_change_execute_1): + * keyboard.c (read_char_help_form_unwind): + * menu.c (unuse_menu_items): + * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind): + * sound.c (sound_cleanup): + * xdisp.c (unwind_redisplay): + * xfns.c (clean_up_dialog): + * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind): + Accept no args and return void, instead of accepting and returning + a dummy Lisp_Object. All uses changed. + * cygw32.c (fchdir_unwind): + * fileio.c (close_file_unwind): + * keyboard.c (restore_kboard_configuration): + * lread.c (readevalllop_1): + * process.c (wait_reading_process_output_unwind): + Accept int and return void, rather than accepting an Emacs integer + and returning a dummy object. In some cases this fixes an + unlikely bug when the corresponding int is outside Emacs integer + range. All uses changed. + * dired.c (directory_files_internal_unwind): + * fileio.c (do_auto_save_unwind): + * gtkutil.c (pop_down_dialog): + * insdel.c (reset_var_on_error): + * lread.c (load_unwind): + * xfns.c (clean_up_file_dialog): + * xmenu.c, nsmenu.m (pop_down_menu): + * xmenu.c (cleanup_widget_value_tree): + * xselect.c (wait_for_property_change_unwind): + Accept pointer and return void, rather than accepting an Emacs + save value encapsulating the pointer and returning a dummy object. + All uses changed. + * editfns.c (Fformat): Update the saved pointer directly via + set_unwind_protect_ptr rather than indirectly via make_save_pointer. + * eval.c (specpdl_func): Remove. All uses replaced by definiens. + (unwind_body): New function. + (record_unwind_protect): First arg is now a function returning void, + not a dummy Lisp_Object. + (record_unwind_protect_ptr, record_unwind_protect_int) + (record_unwind_protect_void): New functions. + (unbind_to): Support SPECPDL_UNWIND_PTR etc. + * fileio.c (struct auto_save_unwind): New type. + (do_auto_save_unwind): Use it. + (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind. + * insdel.c (struct rvoe_arg): New type. + (reset_var_on_error): Use it. + * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID): + New constants. + (specbinding_func): Remove; there are now several such functions. + (union specbinding): New members unwind_ptr, unwind_int, unwind_void. + (set_unwind_protect_ptr): New function. + * xselect.c: Remove unnecessary forward decls, to simplify maintenance. + Be simpler and more consistent about reporting I/O errors. * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region): Say "Read error" and "Write error", rather than "I/O error", or === modified file 'src/alloc.c' --- src/alloc.c 2013-07-16 07:05:41 +0000 +++ src/alloc.c 2013-07-16 21:35:45 +0000 @@ -209,7 +209,6 @@ static Lisp_Object Qpost_gc_hook; -static void free_save_value (Lisp_Object); static void mark_terminals (void); static void gc_sweep (void); static Lisp_Object make_pure_vector (ptrdiff_t); @@ -813,22 +812,13 @@ memory_full (0); } -/* Unwind for SAFE_ALLOCA */ - -Lisp_Object -safe_alloca_unwind (Lisp_Object arg) -{ - free_save_value (arg); - return Qnil; -} - /* Return a newly allocated memory block of SIZE bytes, remembering to free it when unwinding. */ void * record_xmalloc (size_t size) { void *p = xmalloc (size); - record_unwind_protect (safe_alloca_unwind, make_save_pointer (p)); + record_unwind_protect_ptr (xfree, p); return p; } @@ -3397,7 +3387,9 @@ return val; } -/* The most common task it to save just one C pointer. */ +/* Save just one C pointer. record_unwind_protect_ptr is simpler and + faster than combining this with record_unwind_protect, but + occasionally this function is useful for other reasons. */ Lisp_Object make_save_pointer (void *pointer) @@ -3412,7 +3404,7 @@ /* Free a Lisp_Save_Value object. Do not use this function if SAVE contains pointer other than returned by xmalloc. */ -static void +void free_save_value (Lisp_Object save) { xfree (XSAVE_POINTER (save, 0)); @@ -5227,7 +5219,7 @@ /* Save what's currently displayed in the echo area. */ message_p = push_message (); - record_unwind_protect (pop_message_unwind, Qnil); + record_unwind_protect_void (pop_message_unwind); /* Save a copy of the contents of the stack, for debugging. */ #if MAX_SAVE_STACK > 0 === modified file 'src/atimer.c' --- src/atimer.c 2013-07-10 06:26:23 +0000 +++ src/atimer.c 2013-07-16 21:35:45 +0000 @@ -250,7 +250,7 @@ /* Run all timers again, if some have been stopped with a call to stop_other_atimers. */ -static void +void run_all_atimers (void) { if (stopped_atimers) @@ -274,16 +274,6 @@ } -/* A version of run_all_atimers suitable for a record_unwind_protect. */ - -Lisp_Object -unwind_stop_other_atimers (Lisp_Object dummy) -{ - run_all_atimers (); - return Qnil; -} - - /* Arrange for a SIGALRM to arrive when the next timer is ripe. */ static void === modified file 'src/atimer.h' --- src/atimer.h 2013-01-01 09:11:05 +0000 +++ src/atimer.h 2013-07-16 21:35:45 +0000 @@ -77,6 +77,6 @@ void init_atimer (void); void turn_on_atimers (bool); void stop_other_atimers (struct atimer *); -Lisp_Object unwind_stop_other_atimers (Lisp_Object); +void run_all_atimers (void); #endif /* EMACS_ATIMER_H */ === modified file 'src/buffer.c' --- src/buffer.c 2013-07-16 06:39:49 +0000 +++ src/buffer.c 2013-07-16 21:35:45 +0000 @@ -2206,14 +2206,19 @@ return buffer; } +void +restore_buffer (Lisp_Object buffer_or_name) +{ + Fset_buffer (buffer_or_name); +} + /* Set the current buffer to BUFFER provided if it is alive. */ -Lisp_Object +void set_buffer_if_live (Lisp_Object buffer) { if (BUFFER_LIVE_P (XBUFFER (buffer))) set_buffer_internal (XBUFFER (buffer)); - return Qnil; } DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only, === modified file 'src/buffer.h' --- src/buffer.h 2013-01-17 05:52:13 +0000 +++ src/buffer.h 2013-07-16 21:35:45 +0000 @@ -1073,6 +1073,8 @@ extern void record_buffer (Lisp_Object); extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); extern void mmap_set_vars (bool); +extern void restore_buffer (Lisp_Object); +extern void set_buffer_if_live (Lisp_Object); /* Set the current buffer to B. === modified file 'src/bytecode.c' --- src/bytecode.c 2013-07-16 06:39:49 +0000 +++ src/bytecode.c 2013-07-16 21:35:45 +0000 @@ -1063,8 +1063,8 @@ CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ { - register ptrdiff_t count1 = SPECPDL_INDEX (); - record_unwind_protect (Fset_window_configuration, + ptrdiff_t count1 = SPECPDL_INDEX (); + record_unwind_protect (restore_window_configuration, Fcurrent_window_configuration (Qnil)); BEFORE_POTENTIAL_GC (); TOP = Fprogn (TOP); @@ -1089,7 +1089,7 @@ } CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ - record_unwind_protect (Fprogn, POP); + record_unwind_protect (unwind_body, POP); NEXT; CASE (Bcondition_case): /* FIXME: ill-suited for lexbind. */ === modified file 'src/callproc.c' --- src/callproc.c 2013-07-16 16:39:42 +0000 +++ src/callproc.c 2013-07-16 21:35:45 +0000 @@ -123,8 +123,8 @@ /* Clean up when exiting call_process_cleanup. */ -static Lisp_Object -call_process_kill (Lisp_Object ignored) +static void +call_process_kill (void) { if (synch_process_fd >= 0) emacs_close (synch_process_fd); @@ -136,15 +136,13 @@ proc.pid = synch_process_pid; record_kill_process (&proc); } - - return Qnil; } /* Clean up when exiting Fcall_process. On MSDOS, delete the temporary file on any kind of termination. On Unix, kill the process and any children on termination by signal. */ -static Lisp_Object +static void call_process_cleanup (Lisp_Object arg) { #ifdef MSDOS @@ -162,7 +160,7 @@ { ptrdiff_t count = SPECPDL_INDEX (); kill (-synch_process_pid, SIGINT); - record_unwind_protect (call_process_kill, make_number (0)); + record_unwind_protect_void (call_process_kill); message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); immediate_quit = 1; QUIT; @@ -183,8 +181,6 @@ if (!(strcmp (SDATA (file), NULL_DEVICE) == 0 || SREF (file, 0) == '\0')) unlink (SDATA (file)); #endif - - return Qnil; } #ifdef DOS_NT @@ -931,7 +927,7 @@ return make_number (WEXITSTATUS (status)); } -static Lisp_Object +static void delete_temp_file (Lisp_Object name) { /* Suppress jka-compr handling, etc. */ @@ -953,7 +949,6 @@ internal_delete_file (name); #endif unbind_to (count, Qnil); - return Qnil; } /* Create a temporary file suitable for storing the input data of === modified file 'src/coding.c' --- src/coding.c 2013-07-16 06:39:49 +0000 +++ src/coding.c 2013-07-16 21:35:45 +0000 @@ -7791,7 +7791,7 @@ } -static Lisp_Object +static void code_conversion_restore (Lisp_Object arg) { Lisp_Object current, workbuf; @@ -7809,7 +7809,6 @@ } set_buffer_internal (XBUFFER (current)); UNGCPRO; - return Qnil; } Lisp_Object === modified file 'src/cygw32.c' --- src/cygw32.c 2013-07-06 02:40:50 +0000 +++ src/cygw32.c 2013-07-16 21:35:45 +0000 @@ -23,12 +23,11 @@ #include #include -static Lisp_Object -fchdir_unwind (Lisp_Object dir_fd) +static void +fchdir_unwind (int dir_fd) { - (void) fchdir (XFASTINT (dir_fd)); - (void) close (XFASTINT (dir_fd)); - return Qnil; + (void) fchdir (dir_fd); + (void) close (dir_fd); } static void @@ -40,7 +39,7 @@ if (old_cwd_fd == -1) error ("could not open current directory: %s", strerror (errno)); - record_unwind_protect (fchdir_unwind, make_number (old_cwd_fd)); + record_unwind_protect_int (fchdir_unwind, old_cwd_fd); new_cwd = Funhandled_file_name_directory ( Fexpand_file_name (build_string ("."), Qnil)); === modified file 'src/dired.c' --- src/dired.c 2013-07-16 16:39:42 +0000 +++ src/dired.c 2013-07-16 21:35:45 +0000 @@ -107,22 +107,20 @@ } #ifdef WINDOWSNT -Lisp_Object +void directory_files_internal_w32_unwind (Lisp_Object arg) { Vw32_get_true_file_attributes = arg; - return Qnil; } #endif -static Lisp_Object -directory_files_internal_unwind (Lisp_Object dh) +static void +directory_files_internal_unwind (void *dh) { - DIR *d = XSAVE_POINTER (dh, 0); + DIR *d = dh; block_input (); closedir (d); unblock_input (); - return Qnil; } /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. @@ -190,8 +188,7 @@ /* Unfortunately, we can now invoke expand-file-name and file-attributes on filenames, both of which can throw, so we must do a proper unwind-protect. */ - record_unwind_protect (directory_files_internal_unwind, - make_save_pointer (d)); + record_unwind_protect_ptr (directory_files_internal_unwind, d); #ifdef WINDOWSNT if (attrs) @@ -490,8 +487,7 @@ if (!d) report_file_error ("Opening directory", dirname); - record_unwind_protect (directory_files_internal_unwind, - make_save_pointer (d)); + record_unwind_protect_ptr (directory_files_internal_unwind, d); /* Loop reading blocks */ /* (att3b compiler bug requires do a null comparison this way) */ === modified file 'src/editfns.c' --- src/editfns.c 2013-07-16 06:39:49 +0000 +++ src/editfns.c 2013-07-16 21:35:45 +0000 @@ -853,7 +853,7 @@ /* Restore saved buffer before leaving `save-excursion' special form. */ -Lisp_Object +void save_excursion_restore (Lisp_Object info) { Lisp_Object tem, tem1, omark, nmark; @@ -927,7 +927,6 @@ out: free_misc (info); - return Qnil; } DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, @@ -2809,18 +2808,16 @@ return make_number (0); } -static Lisp_Object +static void subst_char_in_region_unwind (Lisp_Object arg) { bset_undo_list (current_buffer, arg); - return arg; } -static Lisp_Object +static void subst_char_in_region_unwind_1 (Lisp_Object arg) { bset_filename (current_buffer, arg); - return arg; } DEFUN ("subst-char-in-region", Fsubst_char_in_region, @@ -3331,7 +3328,7 @@ } } -Lisp_Object +void save_restriction_restore (Lisp_Object data) { struct buffer *cur = NULL; @@ -3398,8 +3395,6 @@ if (cur) set_buffer_internal (cur); - - return Qnil; } DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0, @@ -3627,7 +3622,7 @@ ptrdiff_t bufsize = sizeof initial_buffer; ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1; char *p; - Lisp_Object buf_save_value IF_LINT (= {0}); + ptrdiff_t buf_save_value_index IF_LINT (= 0); char *format, *end, *format_start; ptrdiff_t formatlen, nchars; /* True if the format is multibyte. */ @@ -4236,14 +4231,14 @@ { buf = xmalloc (bufsize); sa_must_free = 1; - buf_save_value = make_save_pointer (buf); - record_unwind_protect (safe_alloca_unwind, buf_save_value); + buf_save_value_index = SPECPDL_INDEX (); + record_unwind_protect_ptr (xfree, buf); memcpy (buf, initial_buffer, used); } else { buf = xrealloc (buf, bufsize); - set_save_pointer (buf_save_value, 0, buf); + set_unwind_protect_ptr (buf_save_value_index, buf); } p = buf + used; === modified file 'src/eval.c' --- src/eval.c 2013-07-16 06:39:49 +0000 +++ src/eval.c 2013-07-16 21:35:45 +0000 @@ -152,13 +152,6 @@ return pdl->unwind.arg; } -static specbinding_func -specpdl_func (union specbinding *pdl) -{ - eassert (pdl->kind == SPECPDL_UNWIND); - return pdl->unwind.func; -} - Lisp_Object backtrace_function (union specbinding *pdl) { @@ -267,12 +260,11 @@ /* Unwind-protect function used by call_debugger. */ -static Lisp_Object +static void restore_stack_limits (Lisp_Object data) { max_specpdl_size = XINT (XCAR (data)); max_lisp_eval_depth = XINT (XCDR (data)); - return Qnil; } /* Call the Lisp debugger, giving it argument ARG. */ @@ -450,23 +442,32 @@ DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, doc: /* Eval BODY forms sequentially and return value of last one. usage: (progn BODY...) */) - (Lisp_Object args) + (Lisp_Object body) { - register Lisp_Object val = Qnil; + Lisp_Object val = Qnil; struct gcpro gcpro1; - GCPRO1 (args); + GCPRO1 (body); - while (CONSP (args)) + while (CONSP (body)) { - val = eval_sub (XCAR (args)); - args = XCDR (args); + val = eval_sub (XCAR (body)); + body = XCDR (body); } UNGCPRO; return val; } +/* Evaluate BODY sequentually, discarding its value. Suitable for + record_unwind_protect. */ + +void +unwind_body (Lisp_Object body) +{ + Fprogn (body); +} + DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, doc: /* Eval FIRST and BODY sequentially; return value from FIRST. The value of FIRST is saved during the evaluation of the remaining args, @@ -1149,7 +1150,7 @@ Lisp_Object val; ptrdiff_t count = SPECPDL_INDEX (); - record_unwind_protect (Fprogn, Fcdr (args)); + record_unwind_protect (unwind_body, Fcdr (args)); val = eval_sub (Fcar (args)); return unbind_to (count, val); } @@ -1890,10 +1891,10 @@ Qnil); } -Lisp_Object +void un_autoload (Lisp_Object oldqueue) { - register Lisp_Object queue, first, second; + Lisp_Object queue, first, second; /* Queue to unwind is current value of Vautoload_queue. oldqueue is the shadowed value to leave in Vautoload_queue. */ @@ -1910,7 +1911,6 @@ Ffset (first, second); queue = XCDR (queue); } - return Qnil; } /* Load an autoloaded function. @@ -3191,7 +3191,7 @@ } void -record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) +record_unwind_protect (void (*function) (Lisp_Object), Lisp_Object arg) { specpdl_ptr->unwind.kind = SPECPDL_UNWIND; specpdl_ptr->unwind.func = function; @@ -3199,6 +3199,32 @@ grow_specpdl (); } +void +record_unwind_protect_ptr (void (*function) (void *), void *arg) +{ + specpdl_ptr->unwind_ptr.kind = SPECPDL_UNWIND_PTR; + specpdl_ptr->unwind_ptr.func = function; + specpdl_ptr->unwind_ptr.arg = arg; + grow_specpdl (); +} + +void +record_unwind_protect_int (void (*function) (int), int arg) +{ + specpdl_ptr->unwind_int.kind = SPECPDL_UNWIND_INT; + specpdl_ptr->unwind_int.func = function; + specpdl_ptr->unwind_int.arg = arg; + grow_specpdl (); +} + +void +record_unwind_protect_void (void (*function) (void)) +{ + specpdl_ptr->unwind_void.kind = SPECPDL_UNWIND_VOID; + specpdl_ptr->unwind_void.func = function; + grow_specpdl (); +} + Lisp_Object unbind_to (ptrdiff_t count, Lisp_Object value) { @@ -3220,7 +3246,16 @@ switch (specpdl_ptr->kind) { case SPECPDL_UNWIND: - specpdl_func (specpdl_ptr) (specpdl_arg (specpdl_ptr)); + specpdl_ptr->unwind.func (specpdl_ptr->unwind.arg); + break; + case SPECPDL_UNWIND_PTR: + specpdl_ptr->unwind_ptr.func (specpdl_ptr->unwind_ptr.arg); + break; + case SPECPDL_UNWIND_INT: + specpdl_ptr->unwind_int.func (specpdl_ptr->unwind_int.arg); + break; + case SPECPDL_UNWIND_VOID: + specpdl_ptr->unwind_void.func (); break; case SPECPDL_LET: /* If variable has a trivial value (no forwarding), we can === modified file 'src/fileio.c' --- src/fileio.c 2013-07-16 18:30:52 +0000 +++ src/fileio.c 2013-07-16 21:35:45 +0000 @@ -212,21 +212,19 @@ report_file_errno (string, name, errno); } -Lisp_Object -close_file_unwind (Lisp_Object fd) +void +close_file_unwind (int fd) { - emacs_close (XFASTINT (fd)); - return Qnil; + emacs_close (fd); } /* Restore point, having saved it as a marker. */ -Lisp_Object +void restore_point_unwind (Lisp_Object location) { Fgoto_char (location); Fset_marker (location, Qnil, Qnil); - return Qnil; } @@ -2078,7 +2076,7 @@ if (ifd < 0) report_file_error ("Opening input file", file); - record_unwind_protect (close_file_unwind, make_number (ifd)); + record_unwind_protect_int (close_file_unwind, ifd); if (fstat (ifd, &st) != 0) report_file_error ("Input file status", file); @@ -2119,7 +2117,7 @@ if (ofd < 0) report_file_error ("Opening output file", newname); - record_unwind_protect (close_file_unwind, make_number (ofd)); + record_unwind_protect_int (close_file_unwind, ofd); immediate_quit = 1; QUIT; @@ -3377,7 +3375,7 @@ o remove all text properties. o set back the buffer multibyteness. */ -static Lisp_Object +static void decide_coding_unwind (Lisp_Object unwind_data) { Lisp_Object multibyte, undo_list, buffer; @@ -3396,8 +3394,6 @@ /* Now we are safe to change the buffer's multibyteness directly. */ bset_enable_multibyte_characters (current_buffer, multibyte); bset_undo_list (current_buffer, undo_list); - - return Qnil; } /* Read from a non-regular file. STATE is a Lisp_Save_Value @@ -3573,7 +3569,7 @@ if (!NILP (replace)) record_unwind_protect (restore_point_unwind, Fpoint_marker ()); - record_unwind_protect (close_file_unwind, make_number (fd)); + record_unwind_protect_int (close_file_unwind, fd); if (fstat (fd, &st) != 0) report_file_error ("Input file status", orig_filename); @@ -4587,11 +4583,10 @@ static Lisp_Object build_annotations (Lisp_Object, Lisp_Object); -static Lisp_Object +static void build_annotations_unwind (Lisp_Object arg) { Vwrite_region_annotation_buffers = arg; - return Qnil; } /* Decide the coding-system to encode the data with. */ @@ -4901,7 +4896,7 @@ report_file_errno ("Opening output file", filename, open_errno); } - record_unwind_protect (close_file_unwind, make_number (desc)); + record_unwind_protect_int (close_file_unwind, desc); if (NUMBERP (append)) { @@ -5492,11 +5487,18 @@ Qnil, Qnil); } -static Lisp_Object -do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */ +struct auto_save_unwind +{ + FILE *stream; + bool auto_raise; +}; +static void +do_auto_save_unwind (void *arg) { - FILE *stream = XSAVE_POINTER (arg, 0); + struct auto_save_unwind *p = arg; + FILE *stream = p->stream; + minibuffer_auto_raise = p->auto_raise; auto_saving = 0; if (stream != NULL) { @@ -5504,15 +5506,6 @@ fclose (stream); unblock_input (); } - return Qnil; -} - -static Lisp_Object -do_auto_save_unwind_1 (Lisp_Object value) /* used as unwind-protect function */ - -{ - minibuffer_auto_raise = XINT (value); - return Qnil; } static Lisp_Object @@ -5555,6 +5548,7 @@ ptrdiff_t count = SPECPDL_INDEX (); bool orig_minibuffer_auto_raise = minibuffer_auto_raise; bool old_message_p = 0; + struct auto_save_unwind auto_save_unwind; struct gcpro gcpro1, gcpro2; if (max_specpdl_size < specpdl_size + 40) @@ -5566,7 +5560,7 @@ if (NILP (no_message)) { old_message_p = push_message (); - record_unwind_protect (pop_message_unwind, Qnil); + record_unwind_protect_void (pop_message_unwind); } /* Ordinarily don't quit within this function, @@ -5605,10 +5599,9 @@ stream = emacs_fopen (SSDATA (listfile), "w"); } - record_unwind_protect (do_auto_save_unwind, - make_save_pointer (stream)); - record_unwind_protect (do_auto_save_unwind_1, - make_number (minibuffer_auto_raise)); + auto_save_unwind.stream = stream; + auto_save_unwind.auto_raise = minibuffer_auto_raise; + record_unwind_protect_ptr (do_auto_save_unwind, &auto_save_unwind); minibuffer_auto_raise = 0; auto_saving = 1; auto_save_error_occurred = 0; === modified file 'src/fns.c' --- src/fns.c 2013-07-16 06:39:49 +0000 +++ src/fns.c 2013-07-16 21:35:45 +0000 @@ -2585,10 +2585,10 @@ static Lisp_Object require_nesting_list; -static Lisp_Object +static void require_unwind (Lisp_Object old_value) { - return require_nesting_list = old_value; + require_nesting_list = old_value; } DEFUN ("require", Frequire, Srequire, 1, 3, 0, === modified file 'src/gtkutil.c' --- src/gtkutil.c 2013-05-09 14:49:56 +0000 +++ src/gtkutil.c 2013-07-16 21:35:45 +0000 @@ -1650,10 +1650,10 @@ /* Destroy the dialog. This makes it pop down. */ -static Lisp_Object -pop_down_dialog (Lisp_Object arg) +static void +pop_down_dialog (void *arg) { - struct xg_dialog_data *dd = XSAVE_POINTER (arg, 0); + struct xg_dialog_data *dd = arg; block_input (); if (dd->w) gtk_widget_destroy (dd->w); @@ -1663,8 +1663,6 @@ g_main_loop_unref (dd->loop); unblock_input (); - - return Qnil; } /* If there are any emacs timers pending, add a timeout to main loop in DATA. @@ -1719,7 +1717,7 @@ g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL); gtk_widget_show (w); - record_unwind_protect (pop_down_dialog, make_save_pointer (&dd)); + record_unwind_protect_ptr (pop_down_dialog, &dd); (void) xg_maybe_add_timer (&dd); g_main_loop_run (dd.loop); === modified file 'src/insdel.c' --- src/insdel.c 2013-05-16 19:15:32 +0000 +++ src/insdel.c 2013-07-16 21:35:45 +0000 @@ -1913,12 +1913,18 @@ VARIABLE is the variable to maybe set to nil. NO-ERROR-FLAG is nil if there was an error, anything else meaning no error (so this function does nothing). */ -static Lisp_Object -reset_var_on_error (Lisp_Object val) -{ - if (NILP (XCDR (val))) - Fset (XCAR (val), Qnil); - return Qnil; +struct rvoe_arg +{ + Lisp_Object *location; + bool errorp; +}; + +static void +reset_var_on_error (void *ptr) +{ + struct rvoe_arg *p = ptr; + if (p->errorp) + *p->location = Qnil; } /* Signal a change to the buffer immediately before it happens. @@ -1936,6 +1942,7 @@ Lisp_Object preserve_marker; struct gcpro gcpro1, gcpro2, gcpro3; ptrdiff_t count = SPECPDL_INDEX (); + struct rvoe_arg rvoe_arg; if (inhibit_modification_hooks) return; @@ -1963,13 +1970,14 @@ if (!NILP (Vbefore_change_functions)) { Lisp_Object args[3]; - Lisp_Object rvoe_arg = Fcons (Qbefore_change_functions, Qnil); + rvoe_arg.location = &Vbefore_change_functions; + rvoe_arg.errorp = 1; PRESERVE_VALUE; PRESERVE_START_END; /* Mark before-change-functions to be reset to nil in case of error. */ - record_unwind_protect (reset_var_on_error, rvoe_arg); + record_unwind_protect_ptr (reset_var_on_error, &rvoe_arg); /* Actually run the hook functions. */ args[0] = Qbefore_change_functions; @@ -1978,7 +1986,7 @@ Frun_hook_with_args (3, args); /* There was no error: unarm the reset_on_error. */ - XSETCDR (rvoe_arg, Qt); + rvoe_arg.errorp = 0; } if (buffer_has_overlays ()) @@ -2009,6 +2017,8 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) { ptrdiff_t count = SPECPDL_INDEX (); + struct rvoe_arg rvoe_arg; + if (inhibit_modification_hooks) return; @@ -2042,10 +2052,11 @@ if (!NILP (Vafter_change_functions)) { Lisp_Object args[4]; - Lisp_Object rvoe_arg = Fcons (Qafter_change_functions, Qnil); + rvoe_arg.location = &Vafter_change_functions; + rvoe_arg.errorp = 1; /* Mark after-change-functions to be reset to nil in case of error. */ - record_unwind_protect (reset_var_on_error, rvoe_arg); + record_unwind_protect_ptr (reset_var_on_error, &rvoe_arg); /* Actually run the hook functions. */ args[0] = Qafter_change_functions; @@ -2055,7 +2066,7 @@ Frun_hook_with_args (4, args); /* There was no error: unarm the reset_on_error. */ - XSETCDR (rvoe_arg, Qt); + rvoe_arg.errorp = 0; } if (buffer_has_overlays ()) @@ -2075,11 +2086,10 @@ unbind_to (count, Qnil); } -static Lisp_Object +static void Fcombine_after_change_execute_1 (Lisp_Object val) { Vcombine_after_change_calls = val; - return val; } DEFUN ("combine-after-change-execute", Fcombine_after_change_execute, === modified file 'src/keyboard.c' --- src/keyboard.c 2013-07-16 16:39:42 +0000 +++ src/keyboard.c 2013-07-16 21:35:45 +0000 @@ -357,7 +357,7 @@ static Lisp_Object Qvertical_scroll_bar; Lisp_Object Qmenu_bar; -static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); +static void recursive_edit_unwind (Lisp_Object buffer); static Lisp_Object command_loop (void); static Lisp_Object Qcommand_execute; EMACS_TIME timer_check (void); @@ -428,7 +428,7 @@ static void restore_getcjmp (sys_jmp_buf); static Lisp_Object apply_modifiers (int, Lisp_Object); static void clear_event (struct input_event *); -static Lisp_Object restore_kboard_configuration (Lisp_Object); +static void restore_kboard_configuration (int); #ifdef USABLE_SIGIO static void deliver_input_available_signal (int signo); #endif @@ -844,7 +844,7 @@ return unbind_to (count, Qnil); } -Lisp_Object +void recursive_edit_unwind (Lisp_Object buffer) { if (BUFFERP (buffer)) @@ -852,7 +852,6 @@ command_loop_level--; update_mode_lines = 1; - return Qnil; } @@ -949,7 +948,7 @@ from which further input is accepted. If F is non-nil, set its KBOARD as the current keyboard. - This function uses record_unwind_protect to return to the previous + This function uses record_unwind_protect_int to return to the previous state later. If Emacs is already in single_kboard mode, and F's keyboard is @@ -980,8 +979,7 @@ else if (f != NULL) current_kboard = FRAME_KBOARD (f); single_kboard = 1; - record_unwind_protect (restore_kboard_configuration, - (was_locked ? Qt : Qnil)); + record_unwind_protect_int (restore_kboard_configuration, was_locked); } #if 0 /* This function is not needed anymore. */ @@ -990,26 +988,22 @@ { if (single_kboard) push_kboard (current_kboard); - record_unwind_protect (restore_kboard_configuration, - (single_kboard ? Qt : Qnil)); + record_unwind_protect_int (restore_kboard_configuration, single_kboard); } #endif -static Lisp_Object -restore_kboard_configuration (Lisp_Object was_locked) +static void +restore_kboard_configuration (int was_locked) { - if (NILP (was_locked)) - single_kboard = 0; - else + single_kboard = was_locked; + if (was_locked) { struct kboard *prev = current_kboard; - single_kboard = 1; pop_kboard (); /* The pop should not change the kboard. */ if (single_kboard && current_kboard != prev) emacs_abort (); } - return Qnil; } @@ -1237,7 +1231,7 @@ /* Restore mouse tracking enablement. See Ftrack_mouse for the only use of this function. */ -static Lisp_Object +static void tracking_off (Lisp_Object old_value) { do_mouse_tracking = old_value; @@ -1254,7 +1248,6 @@ get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW); } } - return Qnil; } DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0, @@ -1317,17 +1310,6 @@ void safe_run_hooks (Lisp_Object); static void adjust_point_for_property (ptrdiff_t, bool); -/* Cancel hourglass from protect_unwind. - ARG is not used. */ -#ifdef HAVE_WINDOW_SYSTEM -static Lisp_Object -cancel_hourglass_unwind (Lisp_Object arg) -{ - cancel_hourglass (); - return Qnil; -} -#endif - /* The last boundary auto-added to buffer-undo-list. */ Lisp_Object last_undo_boundary; @@ -1562,7 +1544,7 @@ if (display_hourglass_p && NILP (Vexecuting_kbd_macro)) { - record_unwind_protect (cancel_hourglass_unwind, Qnil); + record_unwind_protect_void (cancel_hourglass); start_hourglass (); } #endif @@ -2204,14 +2186,13 @@ static void record_char (Lisp_Object c); static Lisp_Object help_form_saved_window_configs; -static Lisp_Object -read_char_help_form_unwind (Lisp_Object arg) +static void +read_char_help_form_unwind (void) { Lisp_Object window_config = XCAR (help_form_saved_window_configs); help_form_saved_window_configs = XCDR (help_form_saved_window_configs); if (!NILP (window_config)) Fset_window_configuration (window_config); - return Qnil; } #define STOP_POLLING \ @@ -3199,7 +3180,7 @@ help_form_saved_window_configs = Fcons (Fcurrent_window_configuration (Qnil), help_form_saved_window_configs); - record_unwind_protect (read_char_help_form_unwind, Qnil); + record_unwind_protect_void (read_char_help_form_unwind); call0 (Qhelp_form_show); cancel_echoing (); @@ -10193,8 +10174,7 @@ reset_all_sys_modes (); /* sys_suspend can get an error if it tries to fork a subshell and the system resources aren't available for that. */ - record_unwind_protect ((Lisp_Object (*) (Lisp_Object)) init_all_sys_modes, - Qnil); + record_unwind_protect_void (init_all_sys_modes); stuff_buffered_input (stuffstring); if (cannot_suspend) sys_subshell (); === modified file 'src/keyboard.h' --- src/keyboard.h 2013-03-09 04:15:53 +0000 +++ src/keyboard.h 2013-07-16 21:35:45 +0000 @@ -341,7 +341,7 @@ MENU_ITEMS_ITEM_LENGTH }; -extern Lisp_Object unuse_menu_items (Lisp_Object dummy); +extern void unuse_menu_items (void); /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU isn't defined. The use of HAVE_MULTILINGUAL_MENU could probably be === modified file 'src/lisp.h' --- src/lisp.h 2013-07-16 07:05:41 +0000 +++ src/lisp.h 2013-07-16 21:35:45 +0000 @@ -1814,23 +1814,8 @@ /* Special object used to hold a different values for later use. This is mostly used to package C integers and pointers to call - record_unwind_protect. A typical task is to pass just one C object - pointer to the unwind function. You should pack an object pointer with - make_save_pointer and then get it back with XSAVE_POINTER, e.g.: - - ... - struct my_data *md = get_my_data (); - record_unwind_protect (my_unwind, make_save_pointer (md)); - ... - - Lisp_Object my_unwind (Lisp_Object arg) - { - struct my_data *md = XSAVE_POINTER (arg, 0); - ... - } - - If you need to pass something else you can use make_save_value, - which allows you to pack up to SAVE_VALUE_SLOTS integers, pointers, + record_unwind_protect when two or more values need to be saved. + make_save_value lets you pack up to SAVE_VALUE_SLOTS integers, pointers, function pointers or Lisp_Objects and conveniently get them back with XSAVE_INTEGER, XSAVE_POINTER, XSAVE_FUNCPOINTER, and XSAVE_OBJECT macros: @@ -2701,10 +2686,11 @@ used all over the place, needs to be fast, and needs to know the size of union specbinding. But only eval.c should access it. */ -typedef Lisp_Object (*specbinding_func) (Lisp_Object); - enum specbind_tag { - SPECPDL_UNWIND, /* An unwind_protect function. */ + SPECPDL_UNWIND, /* An unwind_protect function on Lisp_Object. */ + SPECPDL_UNWIND_PTR, /* Likewise, on void *. */ + SPECPDL_UNWIND_INT, /* Likewise, on int. */ + SPECPDL_UNWIND_VOID, /* Likewise, with no arg. */ SPECPDL_BACKTRACE, /* An element of the backtrace. */ SPECPDL_LET, /* A plain and simple dynamic let-binding. */ /* Tags greater than SPECPDL_LET must be "subkinds" of LET. */ @@ -2717,11 +2703,25 @@ ENUM_BF (specbind_tag) kind : CHAR_BIT; struct { ENUM_BF (specbind_tag) kind : CHAR_BIT; + void (*func) (Lisp_Object); Lisp_Object arg; - specbinding_func func; } unwind; struct { ENUM_BF (specbind_tag) kind : CHAR_BIT; + void (*func) (void *); + void *arg; + } unwind_ptr; + struct { + ENUM_BF (specbind_tag) kind : CHAR_BIT; + void (*func) (int); + int arg; + } unwind_int; + struct { + ENUM_BF (specbind_tag) kind : CHAR_BIT; + void (*func) (void); + } unwind_void; + struct { + ENUM_BF (specbind_tag) kind : CHAR_BIT; /* `where' is not used in the case of SPECPDL_LET. */ Lisp_Object symbol, old_value, where; } let; @@ -2744,6 +2744,12 @@ return specpdl_ptr - specpdl; } +LISP_INLINE void +set_unwind_protect_ptr (ptrdiff_t count, void *arg) +{ + specpdl[count].unwind_ptr.arg = arg; +} + /* Everything needed to describe an active condition case. Members are volatile if their values need to survive _longjmp when @@ -3418,7 +3424,7 @@ extern void check_message_stack (void); extern void setup_echo_area_for_printing (int); extern bool push_message (void); -extern Lisp_Object pop_message_unwind (Lisp_Object); +extern void pop_message_unwind (void); extern Lisp_Object restore_message_unwind (Lisp_Object); extern void restore_message (void); extern Lisp_Object current_message (void); @@ -3582,6 +3588,7 @@ extern ptrdiff_t inhibit_garbage_collection (void); extern Lisp_Object make_save_value (enum Lisp_Save_Type, ...); extern Lisp_Object make_save_pointer (void *); +extern void free_save_value (Lisp_Object); extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); extern void free_marker (Lisp_Object); extern void free_cons (struct Lisp_Cons *); @@ -3738,12 +3745,15 @@ (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *)); extern void specbind (Lisp_Object, Lisp_Object); -extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); +extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object); +extern void record_unwind_protect_int (void (*) (int), int); +extern void record_unwind_protect_ptr (void (*) (void *), void *); +extern void record_unwind_protect_void (void (*) (void)); extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); extern _Noreturn void verror (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0); -extern Lisp_Object un_autoload (Lisp_Object); +extern void un_autoload (Lisp_Object); extern Lisp_Object call_debugger (Lisp_Object arg); extern void init_eval_once (void); extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); @@ -3751,6 +3761,7 @@ extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); extern void init_eval (void); extern void syms_of_eval (void); +extern void unwind_body (Lisp_Object); extern void record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs); extern void mark_specpdl (void); @@ -3766,8 +3777,8 @@ extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); extern Lisp_Object save_excursion_save (void); extern Lisp_Object save_restriction_save (void); -extern Lisp_Object save_excursion_restore (Lisp_Object); -extern Lisp_Object save_restriction_restore (Lisp_Object); +extern void save_excursion_restore (Lisp_Object); +extern void save_restriction_restore (Lisp_Object); extern _Noreturn void time_overflow (void); extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, @@ -3786,7 +3797,6 @@ Lisp_Object, Lisp_Object, Lisp_Object); extern bool overlay_touches_p (ptrdiff_t); extern Lisp_Object Vbuffer_alist; -extern Lisp_Object set_buffer_if_live (Lisp_Object); extern Lisp_Object other_buffer_safely (Lisp_Object); extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; extern Lisp_Object get_truename_buffer (Lisp_Object); @@ -3820,8 +3830,8 @@ extern Lisp_Object Qfile_name_history; extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ -extern Lisp_Object close_file_unwind (Lisp_Object); -extern Lisp_Object restore_point_unwind (Lisp_Object); +extern void close_file_unwind (int); +extern void restore_point_unwind (Lisp_Object); extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); extern _Noreturn void report_file_error (const char *, Lisp_Object); extern bool internal_delete_file (Lisp_Object); @@ -4258,7 +4268,6 @@ enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; -extern Lisp_Object safe_alloca_unwind (Lisp_Object); extern void *record_xmalloc (size_t); #define USE_SAFE_ALLOCA \ @@ -4282,8 +4291,7 @@ { \ (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ sa_must_free = 1; \ - record_unwind_protect (safe_alloca_unwind, \ - make_save_pointer (buf)); \ + record_unwind_protect_ptr (xfree, buf); \ } \ } while (0) @@ -4310,7 +4318,7 @@ buf = xmalloc ((nelt) * word_size); \ arg_ = make_save_value (SAVE_TYPE_MEMORY, buf, nelt); \ sa_must_free = 1; \ - record_unwind_protect (safe_alloca_unwind, arg_); \ + record_unwind_protect (free_save_value, arg_); \ } \ else \ memory_full (SIZE_MAX); \ === modified file 'src/lread.c' --- src/lread.c 2013-07-16 06:39:49 +0000 +++ src/lread.c 2013-07-16 21:35:45 +0000 @@ -145,7 +145,7 @@ static void readevalloop (Lisp_Object, FILE *, Lisp_Object, bool, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); -static Lisp_Object load_unwind (Lisp_Object); +static void load_unwind (void *); /* Functions that read one byte from the current source READCHARFUN or unreads one byte. If the integer argument C is -1, it returns @@ -952,10 +952,10 @@ /* Callback for record_unwind_protect. Restore the old load list OLD, after loading a file successfully. */ -static Lisp_Object +static void record_load_unwind (Lisp_Object old) { - return Vloads_in_progress = old; + Vloads_in_progress = old; } /* This handler function is used via internal_condition_case_1. */ @@ -966,7 +966,7 @@ return Qnil; } -static Lisp_Object +static void load_warn_old_style_backquotes (Lisp_Object file) { if (!NILP (Vold_style_backquotes)) @@ -976,7 +976,6 @@ args[1] = file; Fmessage (2, args); } - return Qnil; } DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0, @@ -1323,7 +1322,7 @@ message_with_string ("Loading %s...", file, 1); } - record_unwind_protect (load_unwind, make_save_pointer (stream)); + record_unwind_protect_ptr (load_unwind, stream); specbind (Qload_file_name, found); specbind (Qinhibit_file_name_operation, Qnil); specbind (Qload_in_progress, Qt); @@ -1376,17 +1375,16 @@ return Qt; } -static Lisp_Object -load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */ +static void +load_unwind (void *arg) { - FILE *stream = XSAVE_POINTER (arg, 0); + FILE *stream = arg; if (stream != NULL) { block_input (); fclose (stream); unblock_input (); } - return Qnil; } static bool @@ -1682,11 +1680,10 @@ Vload_history); } -static Lisp_Object -readevalloop_1 (Lisp_Object old) +static void +readevalloop_1 (int old) { - load_convert_to_unibyte = ! NILP (old); - return Qnil; + load_convert_to_unibyte = old; } /* Signal an `end-of-file' error, if possible with file name @@ -1756,7 +1753,7 @@ specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */ specbind (Qcurrent_load_list, Qnil); - record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil); + record_unwind_protect_int (readevalloop_1, load_convert_to_unibyte); load_convert_to_unibyte = !NILP (unibyte); /* If lexical binding is active (either because it was specified in === modified file 'src/macros.c' --- src/macros.c 2013-02-27 07:42:43 +0000 +++ src/macros.c 2013-07-16 21:35:45 +0000 @@ -279,7 +279,7 @@ /* Restore Vexecuting_kbd_macro and executing_kbd_macro_index. Called when the unwind-protect in Fexecute_kbd_macro gets invoked. */ -static Lisp_Object +static void pop_kbd_macro (Lisp_Object info) { Lisp_Object tem; @@ -288,7 +288,6 @@ executing_kbd_macro_index = XINT (XCAR (tem)); Vreal_this_command = XCDR (tem); Frun_hooks (1, &Qkbd_macro_termination_hook); - return Qnil; } DEFUN ("execute-kbd-macro", Fexecute_kbd_macro, Sexecute_kbd_macro, 1, 3, 0, === modified file 'src/menu.c' --- src/menu.c 2013-07-16 06:39:49 +0000 +++ src/menu.c 2013-07-16 21:35:45 +0000 @@ -102,10 +102,10 @@ { } -Lisp_Object -unuse_menu_items (Lisp_Object dummy) +void +unuse_menu_items (void) { - return menu_items_inuse = Qnil; + menu_items_inuse = Qnil; } /* Call when finished using the data for the current menu @@ -124,19 +124,10 @@ eassert (NILP (menu_items_inuse)); } -#ifdef HAVE_NS -static Lisp_Object -cleanup_popup_menu (Lisp_Object arg) -{ - discard_menu_items (); - return Qnil; -} -#endif - /* This undoes save_menu_items, and it is called by the specpdl unwind mechanism. */ -static Lisp_Object +static void restore_menu_items (Lisp_Object saved) { menu_items = XCAR (saved); @@ -148,7 +139,6 @@ menu_items_n_panes = XINT (XCAR (saved)); saved = XCDR (saved); menu_items_submenu_depth = XINT (XCAR (saved)); - return Qnil; } /* Push the whole state of menu_items processing onto the specpdl. @@ -1213,7 +1203,7 @@ #endif /* HAVE_MENUS */ /* Now parse the lisp menus. */ - record_unwind_protect (unuse_menu_items, Qnil); + record_unwind_protect_void (unuse_menu_items); title = Qnil; GCPRO1 (title); @@ -1315,7 +1305,7 @@ #endif #ifdef HAVE_NS /* FIXME: ns-specific, why? --Stef */ - record_unwind_protect (cleanup_popup_menu, Qnil); + record_unwind_protect_void (discard_menu_items); #endif /* Display them in a menu. */ === modified file 'src/minibuf.c' --- src/minibuf.c 2013-07-16 06:39:49 +0000 +++ src/minibuf.c 2013-07-16 21:35:45 +0000 @@ -137,13 +137,6 @@ } } -static Lisp_Object -choose_minibuf_frame_1 (Lisp_Object ignore) -{ - choose_minibuf_frame (); - return Qnil; -} - DEFUN ("active-minibuffer-window", Factive_minibuffer_window, Sactive_minibuffer_window, 0, 0, 0, doc: /* Return the currently active minibuffer window, or nil if none. */) @@ -171,8 +164,8 @@ /* Actual minibuffer invocation. */ -static Lisp_Object read_minibuf_unwind (Lisp_Object); -static Lisp_Object run_exit_minibuf_hook (Lisp_Object); +static void read_minibuf_unwind (void); +static void run_exit_minibuf_hook (void); /* Read a Lisp object from VAL and return it. If VAL is an empty @@ -474,20 +467,20 @@ /* Prepare for restoring the current buffer since choose_minibuf_frame calling Fset_frame_selected_window may change it (Bug#12766). */ - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + record_unwind_protect (restore_buffer, Fcurrent_buffer ()); choose_minibuf_frame (); - record_unwind_protect (choose_minibuf_frame_1, Qnil); + record_unwind_protect_void (choose_minibuf_frame); - record_unwind_protect (Fset_window_configuration, + record_unwind_protect (restore_window_configuration, Fcurrent_window_configuration (Qnil)); /* If the minibuffer window is on a different frame, save that frame's configuration too. */ mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); if (!EQ (mini_frame, selected_frame)) - record_unwind_protect (Fset_window_configuration, + record_unwind_protect (restore_window_configuration, Fcurrent_window_configuration (mini_frame)); /* If the minibuffer is on an iconified or invisible frame, @@ -518,14 +511,14 @@ Fcons (Vminibuffer_history_variable, minibuf_save_list)))))); - record_unwind_protect (read_minibuf_unwind, Qnil); + record_unwind_protect_void (read_minibuf_unwind); minibuf_level++; /* We are exiting the minibuffer one way or the other, so run the hook. It should be run before unwinding the minibuf settings. Do it separately from read_minibuf_unwind because we need to make sure that read_minibuf_unwind is fully executed even if exit-minibuffer-hook signals an error. --Stef */ - record_unwind_protect (run_exit_minibuf_hook, Qnil); + record_unwind_protect_void (run_exit_minibuf_hook); /* Now that we can restore all those variables, start changing them. */ @@ -821,18 +814,17 @@ return buf; } -static Lisp_Object -run_exit_minibuf_hook (Lisp_Object data) +static void +run_exit_minibuf_hook (void) { safe_run_hooks (Qminibuffer_exit_hook); - return Qnil; } /* This function is called on exiting minibuffer, whether normally or not, and it restores the current window, buffer, etc. */ -static Lisp_Object -read_minibuf_unwind (Lisp_Object data) +static void +read_minibuf_unwind (void) { Lisp_Object old_deactivate_mark; Lisp_Object window; @@ -895,7 +887,6 @@ to make sure we don't leave around bindings and stuff which only made sense during the read_minibuf invocation. */ call0 (intern ("minibuffer-inactive-mode")); - return Qnil; } === modified file 'src/nsfns.m' --- src/nsfns.m 2013-07-16 06:39:49 +0000 +++ src/nsfns.m 2013-07-16 21:35:45 +0000 @@ -981,7 +981,7 @@ /* Handler for signals raised during x_create_frame. FRAME is the frame which is partially constructed. */ -static Lisp_Object +static void unwind_create_frame (Lisp_Object frame) { struct frame *f = XFRAME (frame); @@ -990,7 +990,7 @@ display is disconnected after the frame has become official, but before x_create_frame removes the unwind protect. */ if (!FRAME_LIVE_P (f)) - return Qnil; + return; /* If frame is ``official'', nothing to do. */ if (NILP (Fmemq (frame, Vframe_list))) @@ -1006,10 +1006,7 @@ /* Check that reference counts are indeed correct. */ eassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount); #endif - return Qt; } - - return Qnil; } /* === modified file 'src/nsmenu.m' --- src/nsmenu.m 2013-07-16 06:39:49 +0000 +++ src/nsmenu.m 2013-07-16 21:35:45 +0000 @@ -1410,10 +1410,10 @@ EmacsDialogPanel *dialog; }; -static Lisp_Object -pop_down_menu (Lisp_Object arg) +static void +pop_down_menu (void *arg) { - struct Popdown_data *unwind_data = XSAVE_POINTER (arg, 0); + struct Popdown_data *unwind_data = arg; block_input (); if (popup_activated_flag) @@ -1427,8 +1427,6 @@ xfree (unwind_data); unblock_input (); - - return Qnil; } @@ -1506,7 +1504,7 @@ unwind_data->pool = pool; unwind_data->dialog = dialog; - record_unwind_protect (pop_down_menu, make_save_pointer (unwind_data)); + record_unwind_protect_ptr (pop_down_menu, unwind_data); popup_activated_flag = 1; tem = [dialog runDialogAt: p]; unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ === modified file 'src/print.c' --- src/print.c 2013-07-16 16:39:42 +0000 +++ src/print.c 2013-07-16 21:35:45 +0000 @@ -199,11 +199,10 @@ /* This is used to restore the saved contents of print_buffer when there is a recursive call to print. */ -static Lisp_Object +static void print_unwind (Lisp_Object saved_text) { memcpy (print_buffer, SDATA (saved_text), SCHARS (saved_text)); - return Qnil; } === modified file 'src/process.c' --- src/process.c 2013-07-16 18:30:52 +0000 +++ src/process.c 2013-07-16 21:35:45 +0000 @@ -1341,7 +1341,7 @@ /* Starting asynchronous inferior processes. */ -static Lisp_Object start_process_unwind (Lisp_Object proc); +static void start_process_unwind (Lisp_Object proc); DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, doc: /* Start a program in a subprocess. Return the process object for it. @@ -1590,7 +1590,7 @@ PROC doesn't have its pid set, then we know someone has signaled an error and the process wasn't started successfully, so we should remove it from the process list. */ -static Lisp_Object +static void start_process_unwind (Lisp_Object proc) { if (!PROCESSP (proc)) @@ -1600,8 +1600,6 @@ -2 is used for a pty with no process, eg for gdb. */ if (XPROCESS (proc)->pid <= 0 && XPROCESS (proc)->pid != -2) remove_process (proc); - - return Qnil; } static void @@ -2455,16 +2453,6 @@ return Qnil; } -/* Used by make-serial-process to recover from errors. */ -static Lisp_Object -make_serial_process_unwind (Lisp_Object proc) -{ - if (!PROCESSP (proc)) - emacs_abort (); - remove_process (proc); - return Qnil; -} - DEFUN ("make-serial-process", Fmake_serial_process, Smake_serial_process, 0, MANY, 0, doc: /* Create and return a serial port process. @@ -2570,7 +2558,7 @@ CHECK_STRING (name); proc = make_process (name); specpdl_count = SPECPDL_INDEX (); - record_unwind_protect (make_serial_process_unwind, proc); + record_unwind_protect (remove_process, proc); p = XPROCESS (proc); fd = serial_open (port); @@ -3006,7 +2994,7 @@ #ifdef POLL_FOR_INPUT if (socktype != SOCK_DGRAM) { - record_unwind_protect (unwind_stop_other_atimers, Qnil); + record_unwind_protect_void (run_all_atimers); bind_polling_period (10); } #endif @@ -3166,7 +3154,7 @@ #endif /* Make us close S if quit. */ - record_unwind_protect (close_file_unwind, make_number (s)); + record_unwind_protect_int (close_file_unwind, s); /* Parse network options in the arg list. We simply ignore anything which isn't a known option (including other keywords). @@ -4176,11 +4164,10 @@ when not inside wait_reading_process_output. */ static int waiting_for_user_input_p; -static Lisp_Object -wait_reading_process_output_unwind (Lisp_Object data) +static void +wait_reading_process_output_unwind (int data) { - waiting_for_user_input_p = XINT (data); - return Qnil; + waiting_for_user_input_p = data; } /* This is here so breakpoints can be put on it. */ @@ -4258,8 +4245,8 @@ if (wait_proc != NULL) wait_channel = wait_proc->infd; - record_unwind_protect (wait_reading_process_output_unwind, - make_number (waiting_for_user_input_p)); + record_unwind_protect_int (wait_reading_process_output_unwind, + waiting_for_user_input_p); waiting_for_user_input_p = read_kbd; if (time_limit < 0) === modified file 'src/search.c' --- src/search.c 2013-07-10 16:11:09 +0000 +++ src/search.c 2013-07-16 21:35:45 +0000 @@ -3016,11 +3016,11 @@ } } -static Lisp_Object +static void unwind_set_match_data (Lisp_Object list) { /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */ - return Fset_match_data (list, Qt); + Fset_match_data (list, Qt); } /* Called to unwind protect the match data. */ === modified file 'src/sound.c' --- src/sound.c 2013-07-16 06:39:49 +0000 +++ src/sound.c 2013-07-16 21:35:45 +0000 @@ -437,10 +437,10 @@ } -/* Function installed by play-sound-internal with record_unwind_protect. */ +/* Function installed by play-sound-internal with record_unwind_protect_void. */ -static Lisp_Object -sound_cleanup (Lisp_Object arg) +static void +sound_cleanup (void) { if (current_sound_device->close) current_sound_device->close (current_sound_device); @@ -448,8 +448,6 @@ emacs_close (current_sound->fd); xfree (current_sound_device); xfree (current_sound); - - return Qnil; } /*********************************************************************** @@ -1346,7 +1344,7 @@ GCPRO2 (sound, file); current_sound_device = xzalloc (sizeof *current_sound_device); current_sound = xzalloc (sizeof *current_sound); - record_unwind_protect (sound_cleanup, Qnil); + record_unwind_protect_void (sound_cleanup); current_sound->header = alloca (MAX_SOUND_HEADER_BYTES); if (STRINGP (attrs[SOUND_FILE])) === modified file 'src/w32fns.c' --- src/w32fns.c 2013-07-04 10:25:54 +0000 +++ src/w32fns.c 2013-07-16 21:35:45 +0000 @@ -4259,6 +4259,12 @@ } static void +do_unwind_create_frame (Lisp_Object frame) +{ + unwind_create_frame (frame); +} + +static void x_default_font_parameter (struct frame *f, Lisp_Object parms) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); @@ -4398,7 +4404,7 @@ /* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */ /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ - record_unwind_protect (unwind_create_frame, frame); + record_unwind_protect (do_unwind_create_frame, frame); #ifdef GLYPH_DEBUG image_cache_refcount = FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; @@ -5585,7 +5591,7 @@ Lisp_Object last_show_tip_args; -static Lisp_Object +static void unwind_create_tip_frame (Lisp_Object frame) { Lisp_Object deleted; @@ -5596,8 +5602,6 @@ tip_window = NULL; tip_frame = Qnil; } - - return deleted; } === modified file 'src/window.c' --- src/window.c 2013-07-06 10:41:38 +0000 +++ src/window.c 2013-07-16 21:35:45 +0000 @@ -3086,18 +3086,18 @@ call0 (XCAR (funs)); } -static Lisp_Object +static void select_window_norecord (Lisp_Object window) { - return WINDOW_LIVE_P (window) - ? Fselect_window (window, Qt) : selected_window; + if (WINDOW_LIVE_P (window)) + Fselect_window (window, Qt); } -static Lisp_Object +static void select_frame_norecord (Lisp_Object frame) { - return FRAME_LIVE_P (XFRAME (frame)) - ? Fselect_frame (frame, Qt) : selected_frame; + if (FRAME_LIVE_P (XFRAME (frame))) + Fselect_frame (frame, Qt); } void @@ -3410,7 +3410,7 @@ Note: Both Fselect_window and select_window_norecord may set-buffer to the buffer displayed in the window, so we need to save the current buffer. --stef */ - record_unwind_protect (Fset_buffer, prev_buffer); + record_unwind_protect (restore_buffer, prev_buffer); record_unwind_protect (select_window_norecord, prev_window); Fselect_window (window, Qt); Fset_buffer (w->contents); @@ -5873,6 +5873,12 @@ return (FRAME_LIVE_P (f) ? Qt : Qnil); } +void +restore_window_configuration (Lisp_Object configuration) +{ + Fset_window_configuration (configuration); +} + /* If WINDOW is an internal window, recursively delete all child windows reachable via the next and contents slots of WINDOW. Otherwise setup === modified file 'src/window.h' --- src/window.h 2013-06-17 06:03:19 +0000 +++ src/window.h 2013-07-16 21:35:45 +0000 @@ -886,6 +886,7 @@ extern Lisp_Object window_from_coordinates (struct frame *, int, int, enum window_part *, bool); extern void resize_frame_windows (struct frame *, int, bool); +extern void restore_window_configuration (Lisp_Object); extern void delete_all_child_windows (Lisp_Object); extern void freeze_window_starts (struct frame *, bool); extern void grow_mini_window (struct window *, int); === modified file 'src/xdisp.c' --- src/xdisp.c 2013-07-16 06:39:49 +0000 +++ src/xdisp.c 2013-07-16 21:35:45 +0000 @@ -813,21 +813,20 @@ static void handle_stop_backwards (struct it *, ptrdiff_t); static void vmessage (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0); static void ensure_echo_area_buffers (void); -static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object); +static void unwind_with_echo_area_buffer (Lisp_Object); static Lisp_Object with_echo_area_buffer_unwind_data (struct window *); static int with_echo_area_buffer (struct window *, int, int (*) (ptrdiff_t, Lisp_Object), ptrdiff_t, Lisp_Object); static void clear_garbaged_frames (void); static int current_message_1 (ptrdiff_t, Lisp_Object); -static void pop_message (void); static int truncate_message_1 (ptrdiff_t, Lisp_Object); static void set_message (Lisp_Object); static int set_message_1 (ptrdiff_t, Lisp_Object); static int display_echo_area (struct window *); static int display_echo_area_1 (ptrdiff_t, Lisp_Object); static int resize_mini_window_1 (ptrdiff_t, Lisp_Object); -static Lisp_Object unwind_redisplay (Lisp_Object); +static void unwind_redisplay (void); static int string_char_and_length (const unsigned char *, int *); static struct text_pos display_prop_end (struct it *, Lisp_Object, struct text_pos); @@ -10146,7 +10145,7 @@ /* Restore global state from VECTOR which was created by with_echo_area_buffer_unwind_data. */ -static Lisp_Object +static void unwind_with_echo_area_buffer (Lisp_Object vector) { set_buffer_internal_1 (XBUFFER (AREF (vector, 0))); @@ -10171,7 +10170,6 @@ } Vwith_echo_area_save_vector = vector; - return Qnil; } @@ -10570,20 +10568,12 @@ } -/* Handler for record_unwind_protect calling pop_message. */ - -Lisp_Object -pop_message_unwind (Lisp_Object dummy) -{ - pop_message (); - return Qnil; -} - -/* Pop the top-most entry off Vmessage_stack. */ - -static void -pop_message (void) -{ +/* Handler for unwind-protect calling pop_message. */ + +void +pop_message_unwind (void) +{ + /* Pop the top-most entry off Vmessage_stack. */ eassert (CONSP (Vmessage_stack)); Vmessage_stack = XCDR (Vmessage_stack); } @@ -10979,7 +10969,7 @@ return vector; } -static Lisp_Object +static void unwind_format_mode_line (Lisp_Object vector) { Lisp_Object old_window = AREF (vector, 7); @@ -11022,7 +11012,6 @@ } Vmode_line_unwind_vector = vector; - return Qnil; } @@ -11471,7 +11460,7 @@ do_switch_frame. FIXME: Maybe do_switch_frame should be trimmed down similarly when `norecord' is set. */ -static Lisp_Object +static void fast_set_selected_frame (Lisp_Object frame) { if (!EQ (selected_frame, frame)) @@ -11479,7 +11468,6 @@ selected_frame = frame; selected_window = XFRAME (frame)->selected_window; } - return Qnil; } /* Update the tool-bar item list for frame F. This has to be done @@ -12980,7 +12968,7 @@ /* Record a function that clears redisplaying_p when we leave this function. */ count = SPECPDL_INDEX (); - record_unwind_protect (unwind_redisplay, selected_frame); + record_unwind_protect_void (unwind_redisplay); redisplaying_p = 1; specbind (Qinhibit_free_realized_faces, Qnil); @@ -13660,14 +13648,12 @@ } -/* Function registered with record_unwind_protect in redisplay_internal. - Clear redisplaying_p. Also select the previously selected frame. */ +/* Function registered with record_unwind_protect in redisplay_internal. */ -static Lisp_Object -unwind_redisplay (Lisp_Object old_frame) +static void +unwind_redisplay (void) { redisplaying_p = 0; - return Qnil; } === modified file 'src/xfns.c' --- src/xfns.c 2013-07-16 06:39:49 +0000 +++ src/xfns.c 2013-07-16 21:35:45 +0000 @@ -2883,11 +2883,16 @@ return Qnil; } -static Lisp_Object +static void +do_unwind_create_frame (Lisp_Object frame) +{ + unwind_create_frame (frame); +} + +static void unwind_create_frame_1 (Lisp_Object val) { inhibit_lisp_code = val; - return Qnil; } static void @@ -3090,7 +3095,7 @@ FRAME_X_DISPLAY_INFO (f) = dpyinfo; /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ - record_unwind_protect (unwind_create_frame, frame); + record_unwind_protect (do_unwind_create_frame, frame); /* These colors will be set anyway later, but it's important to get the color reference counts right, so initialize them! */ @@ -4975,7 +4980,7 @@ static Lisp_Object last_show_tip_args; -static Lisp_Object +static void unwind_create_tip_frame (Lisp_Object frame) { Lisp_Object deleted; @@ -4986,8 +4991,6 @@ tip_window = None; tip_frame = Qnil; } - - return deleted; } @@ -5764,10 +5767,10 @@ *result = XmCR_CANCEL; } -static Lisp_Object -clean_up_file_dialog (Lisp_Object arg) +static void +clean_up_file_dialog (void *arg) { - Widget dialog = XSAVE_POINTER (arg, 0); + Widget dialog = arg; /* Clean up. */ block_input (); @@ -5775,8 +5778,6 @@ XtDestroyWidget (dialog); x_menu_set_in_use (0); unblock_input (); - - return Qnil; } @@ -5891,7 +5892,7 @@ XmStringFree (default_xmstring); } - record_unwind_protect (clean_up_file_dialog, make_save_pointer (dialog)); + record_unwind_protect_ptr (clean_up_file_dialog, dialog); /* Process events until the user presses Cancel or OK. */ x_menu_set_in_use (1); @@ -5945,12 +5946,10 @@ #ifdef USE_GTK -static Lisp_Object -clean_up_dialog (Lisp_Object arg) +static void +clean_up_dialog (void) { x_menu_set_in_use (0); - - return Qnil; } DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, @@ -5984,7 +5983,7 @@ /* Prevent redisplay. */ specbind (Qinhibit_redisplay, Qt); - record_unwind_protect (clean_up_dialog, Qnil); + record_unwind_protect_void (clean_up_dialog); block_input (); @@ -6039,7 +6038,7 @@ /* Prevent redisplay. */ specbind (Qinhibit_redisplay, Qt); - record_unwind_protect (clean_up_dialog, Qnil); + record_unwind_protect_void (clean_up_dialog); block_input (); === modified file 'src/xmenu.c' --- src/xmenu.c 2013-07-16 06:39:49 +0000 +++ src/xmenu.c 2013-07-16 21:35:45 +0000 @@ -311,7 +311,7 @@ /* Decode the dialog items from what was specified. */ title = Fcar (contents); CHECK_STRING (title); - record_unwind_protect (unuse_menu_items, Qnil); + record_unwind_protect_void (unuse_menu_items); if (NILP (Fcar (Fcdr (contents)))) /* No buttons specified, add an "Ok" button so users can pop down @@ -1405,14 +1405,13 @@ if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data; } -static Lisp_Object -pop_down_menu (Lisp_Object arg) +static void +pop_down_menu (void *arg) { popup_activated_flag = 0; block_input (); - gtk_widget_destroy (GTK_WIDGET (XSAVE_POINTER (arg, 0))); + gtk_widget_destroy (GTK_WIDGET (arg)); unblock_input (); - return Qnil; } /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the @@ -1474,7 +1473,7 @@ gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, timestamp ? timestamp : gtk_get_current_event_time ()); - record_unwind_protect (pop_down_menu, make_save_pointer (menu)); + record_unwind_protect_ptr (pop_down_menu, menu); if (gtk_widget_get_mapped (menu)) { @@ -1513,7 +1512,7 @@ /* ARG is the LWLIB ID of the dialog box, represented as a Lisp object as (HIGHPART . LOWPART). */ -static Lisp_Object +static void pop_down_menu (Lisp_Object arg) { LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) @@ -1523,8 +1522,6 @@ lw_destroy_all_widgets (id); unblock_input (); popup_activated_flag = 0; - - return Qnil; } /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the @@ -1604,11 +1601,10 @@ #endif /* not USE_GTK */ -static Lisp_Object -cleanup_widget_value_tree (Lisp_Object arg) +static void +cleanup_widget_value_tree (void *arg) { - free_menubar_widget_value_tree (XSAVE_POINTER (arg, 0)); - return Qnil; + free_menubar_widget_value_tree (arg); } Lisp_Object @@ -1822,8 +1818,7 @@ /* Make sure to free the widget_value objects we used to specify the contents even with longjmp. */ - record_unwind_protect (cleanup_widget_value_tree, - make_save_pointer (first_wv)); + record_unwind_protect_ptr (cleanup_widget_value_tree, first_wv); /* Actually create and show the menu until popped down. */ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp); @@ -1922,7 +1917,7 @@ if (menu) { ptrdiff_t specpdl_count = SPECPDL_INDEX (); - record_unwind_protect (pop_down_menu, make_save_pointer (menu)); + record_unwind_protect_ptr (pop_down_menu, menu); /* Display the menu. */ gtk_widget_show_all (menu); @@ -2132,8 +2127,7 @@ /* Make sure to free the widget_value objects we used to specify the contents even with longjmp. */ - record_unwind_protect (cleanup_widget_value_tree, - make_save_pointer (first_wv)); + record_unwind_protect_ptr (cleanup_widget_value_tree, first_wv); /* Actually create and show the dialog. */ create_and_show_dialog (f, first_wv); @@ -2228,7 +2222,7 @@ Qnil, menu_object, make_number (item)); } -static Lisp_Object +static void pop_down_menu (Lisp_Object arg) { FRAME_PTR f = XSAVE_POINTER (arg, 0); @@ -2255,8 +2249,6 @@ #endif /* HAVE_X_WINDOWS */ unblock_input (); - - return Qnil; } === modified file 'src/xselect.c' --- src/xselect.c 2013-04-07 04:41:19 +0000 +++ src/xselect.c 2013-07-16 21:35:45 +0000 @@ -45,26 +45,14 @@ struct prop_location; struct selection_data; -static Lisp_Object x_atom_to_symbol (Display *dpy, Atom atom); -static Atom symbol_to_x_atom (struct x_display_info *, Lisp_Object); -static void x_own_selection (Lisp_Object, Lisp_Object, Lisp_Object); -static Lisp_Object x_get_local_selection (Lisp_Object, Lisp_Object, int, - struct x_display_info *); static void x_decline_selection_request (struct input_event *); -static Lisp_Object x_selection_request_lisp_error (Lisp_Object); -static Lisp_Object queue_selection_requests_unwind (Lisp_Object); -static Lisp_Object x_catch_errors_unwind (Lisp_Object); -static void x_reply_selection_request (struct input_event *, struct x_display_info *); static int x_convert_selection (struct input_event *, Lisp_Object, Lisp_Object, Atom, int, struct x_display_info *); static int waiting_for_other_props_on_window (Display *, Window); static struct prop_location *expect_property_change (Display *, Window, Atom, int); static void unexpect_property_change (struct prop_location *); -static Lisp_Object wait_for_property_change_unwind (Lisp_Object); static void wait_for_property_change (struct prop_location *); -static Lisp_Object x_get_foreign_selection (Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object); static Lisp_Object x_get_window_property_as_lisp_data (Display *, Window, Atom, Lisp_Object, Atom); @@ -74,7 +62,6 @@ static void lisp_data_to_selection_data (Display *, Lisp_Object, unsigned char **, Atom *, ptrdiff_t *, int *, int *); -static Lisp_Object clean_local_selection_data (Lisp_Object); /* Printing traces to stderr. */ @@ -513,8 +500,8 @@ an error, we tell the requestor that we were unable to do what they wanted before we throw to top-level or go into the debugger or whatever. */ -static Lisp_Object -x_selection_request_lisp_error (Lisp_Object ignore) +static void +x_selection_request_lisp_error (void) { struct selection_data *cs, *next; @@ -530,16 +517,14 @@ if (x_selection_current_request != 0 && selection_request_dpyinfo->display) x_decline_selection_request (x_selection_current_request); - return Qnil; } -static Lisp_Object -x_catch_errors_unwind (Lisp_Object dummy) +static void +x_catch_errors_unwind (void) { block_input (); x_uncatch_errors (); unblock_input (); - return Qnil; } @@ -560,11 +545,6 @@ struct prop_location *next; }; -static struct prop_location *expect_property_change (Display *display, Window window, Atom property, int state); -static void wait_for_property_change (struct prop_location *location); -static void unexpect_property_change (struct prop_location *location); -static int waiting_for_other_props_on_window (Display *display, Window window); - static int prop_location_identifier; static Lisp_Object property_change_reply; @@ -573,13 +553,6 @@ static struct prop_location *property_change_wait_list; -static Lisp_Object -queue_selection_requests_unwind (Lisp_Object tem) -{ - x_stop_queuing_selection_requests (); - return Qnil; -} - /* Send the reply to a selection request event EVENT. */ @@ -614,7 +587,7 @@ /* The protected block contains wait_for_property_change, which can run random lisp code (process handlers) or signal. Therefore, we put the x_uncatch_errors call in an unwind. */ - record_unwind_protect (x_catch_errors_unwind, Qnil); + record_unwind_protect_void (x_catch_errors_unwind); x_catch_errors (display); /* Loop over converted selections, storing them in the requested @@ -805,12 +778,12 @@ x_selection_current_request = event; selection_request_dpyinfo = dpyinfo; - record_unwind_protect (x_selection_request_lisp_error, Qnil); + record_unwind_protect_void (x_selection_request_lisp_error); /* We might be able to handle nested x_handle_selection_requests, but this is difficult to test, and seems unimportant. */ x_start_queuing_selection_requests (); - record_unwind_protect (queue_selection_requests_unwind, Qnil); + record_unwind_protect_void (x_stop_queuing_selection_requests); TRACE2 ("x_handle_selection_request: selection=%s, target=%s", SDATA (SYMBOL_NAME (selection_symbol)), @@ -1117,15 +1090,14 @@ /* Remove the property change expectation element for IDENTIFIER. */ -static Lisp_Object -wait_for_property_change_unwind (Lisp_Object loc) +static void +wait_for_property_change_unwind (void *loc) { - struct prop_location *location = XSAVE_POINTER (loc, 0); + struct prop_location *location = loc; unexpect_property_change (location); if (location == property_change_reply_object) property_change_reply_object = 0; - return Qnil; } /* Actually wait for a property change. @@ -1140,8 +1112,7 @@ emacs_abort (); /* Make sure to do unexpect_property_change if we quit or err. */ - record_unwind_protect (wait_for_property_change_unwind, - make_save_pointer (location)); + record_unwind_protect_ptr (wait_for_property_change_unwind, location); XSETCAR (property_change_reply, Qnil); property_change_reply_object = location; @@ -1254,7 +1225,7 @@ SelectionNotify. */ #if 0 x_start_queuing_selection_requests (); - record_unwind_protect (queue_selection_requests_unwind, Qnil); + record_unwind_protect_void (x_stop_queuing_selection_requests); #endif unblock_input (); ------------------------------------------------------------ revno: 113436 committer: Dmitry Gutov branch nick: trunk timestamp: Tue 2013-07-16 23:16:51 +0400 message: * lisp/progmodes/ruby-mode.el (ruby-block-beg-keywords): Inline. (ruby-font-lock-keyword-beg-re): Extract from `ruby-font-lock-keywords'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-16 14:47:23 +0000 +++ lisp/ChangeLog 2013-07-16 19:16:51 +0000 @@ -2,6 +2,9 @@ * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not highlight question marks in the method names as strings. + (ruby-block-beg-keywords): Inline. + (ruby-font-lock-keyword-beg-re): Extract from + `ruby-font-lock-keywords'. 2013-07-16 Jan Djärv === modified file 'lisp/progmodes/ruby-mode.el' --- lisp/progmodes/ruby-mode.el 2013-07-16 14:47:23 +0000 +++ lisp/progmodes/ruby-mode.el 2013-07-16 19:16:51 +0000 @@ -46,11 +46,6 @@ :prefix "ruby-" :group 'languages) -(defconst ruby-keyword-end-re - (if (string-match "\\_>" "ruby") - "\\_>" - "\\>")) - (defconst ruby-block-beg-keywords '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do") "Keywords at the beginning of blocks.") @@ -60,7 +55,7 @@ "Regexp to match the beginning of blocks.") (defconst ruby-non-block-do-re - (concat (regexp-opt '("while" "until" "for" "rescue") t) ruby-keyword-end-re) + (regexp-opt '("while" "until" "for" "rescue") 'symbols) "Regexp to match keywords that nest without blocks.") (defconst ruby-indent-beg-re @@ -696,7 +691,7 @@ ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) (and (save-match-data - (or (not (looking-at (concat "do" ruby-keyword-end-re))) + (or (not (looking-at "do\\_>")) (save-excursion (back-to-indentation) (not (looking-at ruby-non-block-do-re))))) @@ -1718,14 +1713,16 @@ "The syntax table to use for fontifying Ruby mode buffers. See `font-lock-syntax-table'.") +(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)") + (defconst ruby-font-lock-keywords (list ;; functions '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" 1 font-lock-function-name-face) + ;; keywords (list (concat - "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" - ;; keywords + ruby-font-lock-keyword-beg-re (regexp-opt '("alias" "and" @@ -1760,11 +1757,14 @@ "when" "while" "yield") - 'symbols) - "\\|" + 'symbols)) + 1 'font-lock-keyword-face) + ;; some core methods + (list (concat + ruby-font-lock-keyword-beg-re (regexp-opt - ;; built-in methods on Kernel - '("__callee__" + '(;; built-in methods on Kernel + "__callee__" "__dir__" "__method__" "abort" @@ -1823,20 +1823,17 @@ "public" "refine" "using") - 'symbols) - "\\)") - 2 - '(if (match-beginning 4) - font-lock-builtin-face - font-lock-keyword-face)) + 'symbols)) + 1 'font-lock-builtin-face) ;; Perl-ish keywords "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" ;; here-doc beginnings `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 'font-lock-string-face)) ;; variables - '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>" - 2 font-lock-variable-name-face) + `(,(concat ruby-font-lock-keyword-beg-re + "\\_<\\(nil\\|self\\|true\\|false\\)\\>") + 1 font-lock-variable-name-face) ;; keywords that evaluate to certain values '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face) ;; symbols @@ -1852,7 +1849,7 @@ 1 (unless (eq ?\( (char-after)) font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) ;; conversion methods on Kernel - (list (concat "\\(?:^\\|[^.@$]\\|\\.\\.\\)" + (list (concat ruby-font-lock-keyword-beg-re (regexp-opt '("Array" "Complex" "Float" "Hash" "Integer" "Rational" "String") 'symbols)) 1 font-lock-builtin-face) ------------------------------------------------------------ revno: 113435 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 11:30:52 -0700 message: Be simpler and more consistent about reporting I/O errors. * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region): Say "Read error" and "Write error", rather than "I/O error", or "IO error reading", or "IO error writing", when a read or write error occurs. * process.c (Fmake_network_process, wait_reading_process_output) (send_process, Fprocess_send_eof, wait_reading_process_output): Capitalize diagnostics consistently. Put "failed foo" at the start of the diagnostic, so that we don't capitalize the function name "foo". Consistently say "failed" for such diagnostics. * sysdep.c, w32.c (serial_open): Now accepts Lisp string, not C string. All callers changed. This is so it can use report_file_error. * sysdep.c (serial_open, serial_configure): Capitalize I/O diagnostics consistently as above. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 16:39:42 +0000 +++ src/ChangeLog 2013-07-16 18:30:52 +0000 @@ -1,5 +1,21 @@ 2013-07-16 Paul Eggert + Be simpler and more consistent about reporting I/O errors. + * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region): + Say "Read error" and "Write error", rather than "I/O error", or + "IO error reading", or "IO error writing", when a read or write + error occurs. + * process.c (Fmake_network_process, wait_reading_process_output) + (send_process, Fprocess_send_eof, wait_reading_process_output): + Capitalize diagnostics consistently. Put "failed foo" at the + start of the diagnostic, so that we don't capitalize the + function name "foo". Consistently say "failed" for such + diagnostics. + * sysdep.c, w32.c (serial_open): Now accepts Lisp string, not C string. + All callers changed. This is so it can use report_file_error. + * sysdep.c (serial_open, serial_configure): Capitalize I/O + diagnostics consistently as above. + * fileio.c (report_file_errno): Fix errno reporting bug. If the file name is neither null nor a pair, package it up as a singleton list. All callers changed, both to this function and to === modified file 'src/fileio.c' --- src/fileio.c 2013-07-16 16:39:42 +0000 +++ src/fileio.c 2013-07-16 18:30:52 +0000 @@ -2125,7 +2125,7 @@ QUIT; while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) if (emacs_write_sig (ofd, buf, n) != n) - report_file_error ("I/O error", newname); + report_file_error ("Write error", newname); immediate_quit = 0; #ifndef MSDOS @@ -2182,7 +2182,7 @@ } if (emacs_close (ofd) < 0) - report_file_error ("I/O error", newname); + report_file_error ("Write error", newname); emacs_close (ifd); @@ -3697,8 +3697,7 @@ } if (nread < 0) - error ("IO error reading %s: %s", - SDATA (orig_filename), emacs_strerror (errno)); + report_file_error ("Read error", orig_filename); else if (nread > 0) { struct buffer *prev = current_buffer; @@ -3813,8 +3812,7 @@ nread = emacs_read (fd, read_buf, sizeof read_buf); if (nread < 0) - error ("IO error reading %s: %s", - SSDATA (orig_filename), emacs_strerror (errno)); + report_file_error ("Read error", orig_filename); else if (nread == 0) break; @@ -3879,8 +3877,7 @@ { nread = emacs_read (fd, read_buf + total_read, trial - total_read); if (nread < 0) - error ("IO error reading %s: %s", - SDATA (orig_filename), emacs_strerror (errno)); + report_file_error ("Read error", orig_filename); else if (nread == 0) break; total_read += nread; @@ -4030,8 +4027,7 @@ deferred_remove_unwind_protect = 1; if (this < 0) - error ("IO error reading %s: %s", - SDATA (orig_filename), emacs_strerror (errno)); + report_file_error ("Read error", orig_filename); if (unprocessed > 0) { @@ -4277,8 +4273,7 @@ specpdl_ptr--; if (how_much < 0) - error ("IO error reading %s: %s", - SDATA (orig_filename), emacs_strerror (errno)); + report_file_error ("Read error", orig_filename); /* Make the text read part of the buffer. */ GAP_SIZE -= inserted; @@ -5071,8 +5066,7 @@ } if (! ok) - error ("IO error writing %s: %s", SDATA (filename), - emacs_strerror (save_errno)); + report_file_errno ("Write error", filename, save_errno); if (visiting) { === modified file 'src/process.c' --- src/process.c 2013-07-16 16:39:42 +0000 +++ src/process.c 2013-07-16 18:30:52 +0000 @@ -2573,7 +2573,7 @@ record_unwind_protect (make_serial_process_unwind, proc); p = XPROCESS (proc); - fd = serial_open (SSDATA (port)); + fd = serial_open (port); p->infd = fd; p->outfd = fd; if (fd > max_process_desc) @@ -3257,16 +3257,16 @@ if (errno == EINTR) goto retry_select; else - report_file_error ("select failed", Qnil); + report_file_error ("Failed select", Qnil); } eassert (sc > 0); len = sizeof xerrno; eassert (FD_ISSET (s, &fdset)); if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0) - report_file_error ("getsockopt failed", Qnil); + report_file_error ("Failed getsockopt", Qnil); if (xerrno) - report_file_errno ("error during connect", Qnil, xerrno); + report_file_errno ("Failed connect", Qnil, xerrno); break; } #endif /* !WINDOWSNT */ @@ -4624,7 +4624,7 @@ else if (xerrno == EBADF) emacs_abort (); else - error ("select error: %s", emacs_strerror (xerrno)); + report_file_errno ("Failed select", Qnil, xerrno); } if (no_avail) @@ -5466,7 +5466,7 @@ if (rv >= 0) written = rv; else if (errno == EMSGSIZE) - report_file_error ("sending datagram", proc); + report_file_error ("Sending datagram", proc); } else #endif @@ -5543,7 +5543,7 @@ } else /* This is a real error. */ - report_file_error ("writing to process", proc); + report_file_error ("Writing to process", proc); } cur_buf += written; cur_len -= written; @@ -6037,7 +6037,7 @@ { #ifndef WINDOWSNT if (tcdrain (XPROCESS (proc)->outfd) != 0) - error ("tcdrain() failed: %s", emacs_strerror (errno)); + report_file_error ("Failed tcdrain", Qnil); #endif /* not WINDOWSNT */ /* Do nothing on Windows because writes are blocking. */ } @@ -6733,7 +6733,7 @@ if (xerrno == EINTR) FD_ZERO (&waitchannels); else - error ("select error: %s", emacs_strerror (xerrno)); + report_file_errno ("Failed select", Qnil, xerrno); } /* Check for keyboard input */ === modified file 'src/sysdep.c' --- src/sysdep.c 2013-07-16 07:05:41 +0000 +++ src/sysdep.c 2013-07-16 18:30:52 +0000 @@ -2436,14 +2436,11 @@ #ifndef DOS_NT /* For make-serial-process */ int -serial_open (char *port) +serial_open (Lisp_Object port) { - int fd = emacs_open (port, O_RDWR | O_NOCTTY | O_NONBLOCK, 0); + int fd = emacs_open (SSDATA (port), O_RDWR | O_NOCTTY | O_NONBLOCK, 0); if (fd < 0) - { - error ("Could not open %s: %s", - port, emacs_strerror (errno)); - } + report_file_error ("Opening serial port", port); #ifdef TIOCEXCL ioctl (fd, TIOCEXCL, (char *) 0); #endif @@ -2491,7 +2488,7 @@ /* Read port attributes and prepare default configuration. */ err = tcgetattr (p->outfd, &attr); if (err != 0) - error ("tcgetattr() failed: %s", emacs_strerror (errno)); + report_file_error ("Failed tcgetattr", Qnil); cfmakeraw (&attr); #if defined (CLOCAL) attr.c_cflag |= CLOCAL; @@ -2508,8 +2505,7 @@ CHECK_NUMBER (tem); err = cfsetspeed (&attr, XINT (tem)); if (err != 0) - error ("cfsetspeed(%"pI"d) failed: %s", XINT (tem), - emacs_strerror (errno)); + report_file_error ("Failed cfsetspeed", tem); childp2 = Fplist_put (childp2, QCspeed, tem); /* Configure bytesize. */ @@ -2631,7 +2627,7 @@ /* Activate configuration. */ err = tcsetattr (p->outfd, TCSANOW, &attr); if (err != 0) - error ("tcsetattr() failed: %s", emacs_strerror (errno)); + report_file_error ("Failed tcsetattr", Qnil); childp2 = Fplist_put (childp2, QCsummary, build_string (summary)); pset_childp (p, childp2); === modified file 'src/systty.h' --- src/systty.h 2013-01-02 16:13:04 +0000 +++ src/systty.h 2013-07-16 18:30:52 +0000 @@ -79,5 +79,5 @@ }; /* From sysdep.c or w32.c */ -extern int serial_open (char *); +extern int serial_open (Lisp_Object); extern void serial_configure (struct Lisp_Process *, Lisp_Object); === modified file 'src/w32.c' --- src/w32.c 2013-07-07 18:48:16 +0000 +++ src/w32.c 2013-07-16 18:30:52 +0000 @@ -7707,8 +7707,9 @@ /* For make-serial-process */ int -serial_open (char *port) +serial_open (Lisp_Object port_obj) { + char *port = SSDATA (port_obj); HANDLE hnd; child_process *cp; int fd = -1; ------------------------------------------------------------ revno: 113434 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 09:39:42 -0700 message: * fileio.c (report_file_errno): Fix errno reporting bug. If the file name is neither null nor a pair, package it up as a singleton list. All callers changed, both to this function and to report_file_error. This fixes a bug where the memory allocator invoked by list1 set errno so that the immediately following report_file_error reported the wrong errno value. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 14:52:22 +0000 +++ src/ChangeLog 2013-07-16 16:39:42 +0000 @@ -1,5 +1,12 @@ 2013-07-16 Paul Eggert + * fileio.c (report_file_errno): Fix errno reporting bug. + If the file name is neither null nor a pair, package it up as a + singleton list. All callers changed, both to this function and to + report_file_error. This fixes a bug where the memory allocator + invoked by list1 set errno so that the immediately following + report_file_error reported the wrong errno value. + Fix minor problems found by --enable-gcc-warnings. * frame.c (Fhandle_focus_in, Fhandle_focus_out): Return a value. * keyboard.c (kbd_buffer_get_event): Remove unused local. === modified file 'src/callproc.c' --- src/callproc.c 2013-07-16 07:05:41 +0000 +++ src/callproc.c 2013-07-16 16:39:42 +0000 @@ -392,7 +392,7 @@ if (NILP (Ffile_accessible_directory_p (current_dir))) report_file_error ("Setting current directory", - list1 (BVAR (current_buffer, directory))); + BVAR (current_buffer, directory)); if (STRING_MULTIBYTE (infile)) infile = ENCODE_FILE (infile); @@ -409,8 +409,7 @@ filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); if (filefd < 0) - report_file_error ("Opening process input file", - list1 (DECODE_FILE (infile))); + report_file_error ("Opening process input file", DECODE_FILE (infile)); if (STRINGP (output_file)) { @@ -422,7 +421,7 @@ int open_errno = errno; output_file = DECODE_FILE (output_file); report_file_errno ("Opening process output file", - list1 (output_file), open_errno); + output_file, open_errno); } if (STRINGP (error_file) || NILP (error_file)) output_to_buffer = 0; @@ -440,8 +439,7 @@ { int openp_errno = errno; emacs_close (filefd); - report_file_errno ("Searching for program", - list1 (args[0]), openp_errno); + report_file_errno ("Searching for program", args[0], openp_errno); } } @@ -506,7 +504,7 @@ int open_errno = errno; emacs_close (filefd); report_file_errno ("Opening process output file", - list1 (build_string (tempfile)), open_errno); + build_string (tempfile), open_errno); } } else @@ -563,8 +561,7 @@ error_file = build_string (NULL_DEVICE); else if (STRINGP (error_file)) error_file = DECODE_FILE (error_file); - report_file_errno ("Cannot redirect stderr", - list1 (error_file), open_errno); + report_file_errno ("Cannot redirect stderr", error_file, open_errno); } #ifdef MSDOS /* MW, July 1993 */ @@ -596,7 +593,7 @@ unlink (tempfile); emacs_close (filefd); report_file_errno ("Cannot re-open temporary file", - list1 (build_string (tempfile)), open_errno); + build_string (tempfile), open_errno); } } else @@ -1027,7 +1024,7 @@ #endif if (fd < 0) report_file_error ("Failed to open temporary file using pattern", - list1 (pattern)); + pattern); emacs_close (fd); } === modified file 'src/dired.c' --- src/dired.c 2013-07-16 06:39:49 +0000 +++ src/dired.c 2013-07-16 16:39:42 +0000 @@ -185,7 +185,7 @@ d = open_directory (SSDATA (dirfilename), &fd); if (d == NULL) - report_file_error ("Opening directory", list1 (directory)); + report_file_error ("Opening directory", directory); /* Unfortunately, we can now invoke expand-file-name and file-attributes on filenames, both of which can throw, so we must @@ -488,7 +488,7 @@ d = open_directory (SSDATA (encoded_dir), &fd); if (!d) - report_file_error ("Opening directory", list1 (dirname)); + report_file_error ("Opening directory", dirname); record_unwind_protect (directory_files_internal_unwind, make_save_pointer (d)); === modified file 'src/dispnew.c' --- src/dispnew.c 2013-07-16 06:39:49 +0000 +++ src/dispnew.c 2013-07-16 16:39:42 +0000 @@ -5619,7 +5619,7 @@ file = Fexpand_file_name (file, Qnil); tty->termscript = emacs_fopen (SSDATA (file), "w"); if (tty->termscript == 0) - report_file_error ("Opening termscript", list1 (file)); + report_file_error ("Opening termscript", file); } return Qnil; } === modified file 'src/doc.c' --- src/doc.c 2013-07-16 06:39:49 +0000 +++ src/doc.c 2013-07-16 16:39:42 +0000 @@ -609,7 +609,7 @@ fd = emacs_open (name, O_RDONLY, 0); if (fd < 0) - report_file_error ("Opening doc string file", list1 (build_string (name))); + report_file_error ("Opening doc string file", build_string (name)); Vdoc_file_name = filename; filled = 0; pos = 0; === modified file 'src/fileio.c' --- src/fileio.c 2013-07-16 06:39:49 +0000 +++ src/fileio.c 2013-07-16 16:39:42 +0000 @@ -160,11 +160,16 @@ /* Signal a file-access failure. STRING describes the failure, - DATA the file that was involved, and ERRORNO the errno value. */ + NAME the file involved, and ERRORNO the errno value. + + If NAME is neither null nor a pair, package it up as a singleton + list before reporting it; this saves report_file_errno's caller the + trouble of preserving errno before calling list1. */ void -report_file_errno (char const *string, Lisp_Object data, int errorno) +report_file_errno (char const *string, Lisp_Object name, int errorno) { + Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); Lisp_Object errstring; char *str; @@ -198,10 +203,13 @@ } } +/* Signal a file-access failure that set errno. STRING describes the + failure, NAME the file involved. */ + void -report_file_error (char const *string, Lisp_Object data) +report_file_error (char const *string, Lisp_Object name) { - report_file_errno (string, data, errno); + report_file_errno (string, name, errno); } Lisp_Object @@ -749,7 +757,7 @@ dog-slow, but also useless since eventually nil would have to be returned anyway. */ report_file_error ("Cannot create temporary name for prefix", - list1 (prefix)); + prefix); /* not reached */ } } @@ -2019,7 +2027,7 @@ { acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); if (acl == NULL && acl_errno_valid (errno)) - report_file_error ("Getting ACL", list1 (file)); + report_file_error ("Getting ACL", file); } if (!CopyFile (SDATA (encoded_file), SDATA (encoded_newname), @@ -2058,7 +2066,7 @@ bool fail = acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; if (fail && acl_errno_valid (errno)) - report_file_error ("Setting ACL", list1 (newname)); + report_file_error ("Setting ACL", newname); acl_free (acl); } @@ -2068,12 +2076,12 @@ immediate_quit = 0; if (ifd < 0) - report_file_error ("Opening input file", list1 (file)); + report_file_error ("Opening input file", file); record_unwind_protect (close_file_unwind, make_number (ifd)); if (fstat (ifd, &st) != 0) - report_file_error ("Input file status", list1 (file)); + report_file_error ("Input file status", file); if (!NILP (preserve_extended_attributes)) { @@ -2082,7 +2090,7 @@ { conlength = fgetfilecon (ifd, &con); if (conlength == -1) - report_file_error ("Doing fgetfilecon", list1 (file)); + report_file_error ("Doing fgetfilecon", file); } #endif } @@ -2094,7 +2102,7 @@ /* We can copy only regular files. */ if (!S_ISREG (st.st_mode)) - report_file_errno ("Non-regular file", list1 (file), + report_file_errno ("Non-regular file", file, S_ISDIR (st.st_mode) ? EISDIR : EINVAL); { @@ -2109,7 +2117,7 @@ new_mask); } if (ofd < 0) - report_file_error ("Opening output file", list1 (newname)); + report_file_error ("Opening output file", newname); record_unwind_protect (close_file_unwind, make_number (ofd)); @@ -2117,7 +2125,7 @@ QUIT; while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) if (emacs_write_sig (ofd, buf, n) != n) - report_file_error ("I/O error", list1 (newname)); + report_file_error ("I/O error", newname); immediate_quit = 0; #ifndef MSDOS @@ -2145,8 +2153,8 @@ st.st_mode & mode_mask) : fchmod (ofd, st.st_mode & mode_mask)) { - case -2: report_file_error ("Copying permissions from", list1 (file)); - case -1: report_file_error ("Copying permissions to", list1 (newname)); + case -2: report_file_error ("Copying permissions from", file); + case -1: report_file_error ("Copying permissions to", newname); } } #endif /* not MSDOS */ @@ -2158,7 +2166,7 @@ bool fail = fsetfilecon (ofd, con) != 0; /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ if (fail && errno != ENOTSUP) - report_file_error ("Doing fsetfilecon", list1 (newname)); + report_file_error ("Doing fsetfilecon", newname); freecon (con); } @@ -2174,7 +2182,7 @@ } if (emacs_close (ofd) < 0) - report_file_error ("I/O error", list1 (newname)); + report_file_error ("I/O error", newname); emacs_close (ifd); @@ -2220,7 +2228,7 @@ #else if (mkdir (dir, 0777 & ~auto_saving_dir_umask) != 0) #endif - report_file_error ("Creating directory", list1 (directory)); + report_file_error ("Creating directory", directory); return Qnil; } @@ -2239,7 +2247,7 @@ dir = SSDATA (encoded_dir); if (rmdir (dir) != 0) - report_file_error ("Removing directory", list1 (directory)); + report_file_error ("Removing directory", directory); return Qnil; } @@ -2282,7 +2290,7 @@ encoded_file = ENCODE_FILE (filename); if (unlink (SSDATA (encoded_file)) < 0) - report_file_error ("Removing old name", list1 (filename)); + report_file_error ("Removing old name", filename); return Qnil; } @@ -2719,7 +2727,7 @@ encoded_filename = ENCODE_FILE (absname); if (faccessat (AT_FDCWD, SSDATA (encoded_filename), R_OK, AT_EACCESS) != 0) - report_file_error (SSDATA (string), list1 (filename)); + report_file_error (SSDATA (string), filename); return Qnil; } @@ -3054,14 +3062,14 @@ != 0); /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ if (fail && errno != ENOTSUP) - report_file_error ("Doing lsetfilecon", list1 (absname)); + report_file_error ("Doing lsetfilecon", absname); context_free (parsed_con); freecon (con); return fail ? Qnil : Qt; } else - report_file_error ("Doing lgetfilecon", list1 (absname)); + report_file_error ("Doing lgetfilecon", absname); } #endif @@ -3151,7 +3159,7 @@ acl = acl_from_text (SSDATA (acl_string)); if (acl == NULL) { - report_file_error ("Converting ACL", list1 (absname)); + report_file_error ("Converting ACL", absname); return Qnil; } @@ -3161,7 +3169,7 @@ acl) != 0); if (fail && acl_errno_valid (errno)) - report_file_error ("Setting ACL", list1 (absname)); + report_file_error ("Setting ACL", absname); acl_free (acl); return fail ? Qnil : Qt; @@ -3221,7 +3229,7 @@ encoded_absname = ENCODE_FILE (absname); if (chmod (SSDATA (encoded_absname), XINT (mode) & 07777) < 0) - report_file_error ("Doing chmod", list1 (absname)); + report_file_error ("Doing chmod", absname); return Qnil; } @@ -3287,7 +3295,7 @@ if (file_directory_p (SSDATA (encoded_absname))) return Qnil; #endif - report_file_error ("Setting file times", list1 (absname)); + report_file_error ("Setting file times", absname); } } @@ -3553,7 +3561,7 @@ { save_errno = errno; if (NILP (visit)) - report_file_error ("Opening input file", list1 (orig_filename)); + report_file_error ("Opening input file", orig_filename); mtime = time_error_value (save_errno); st.st_size = -1; if (!NILP (Vcoding_system_for_read)) @@ -3568,7 +3576,7 @@ record_unwind_protect (close_file_unwind, make_number (fd)); if (fstat (fd, &st) != 0) - report_file_error ("Input file status", list1 (orig_filename)); + report_file_error ("Input file status", orig_filename); mtime = get_stat_mtime (&st); /* This code will need to be changed in order to work on named @@ -3682,7 +3690,7 @@ int ntail; if (lseek (fd, - (1024 * 3), SEEK_END) < 0) report_file_error ("Setting file position", - list1 (orig_filename)); + orig_filename); ntail = emacs_read (fd, read_buf + nread, 1024 * 3); nread = ntail < 0 ? ntail : nread + ntail; } @@ -3726,8 +3734,7 @@ /* Rewind the file for the actual read done later. */ if (lseek (fd, 0, SEEK_SET) < 0) - report_file_error ("Setting file position", - list1 (orig_filename)); + report_file_error ("Setting file position", orig_filename); } } @@ -3793,8 +3800,7 @@ if (beg_offset != 0) { if (lseek (fd, beg_offset, SEEK_SET) < 0) - report_file_error ("Setting file position", - list1 (orig_filename)); + report_file_error ("Setting file position", orig_filename); } immediate_quit = 1; @@ -3866,8 +3872,7 @@ /* How much can we scan in the next step? */ trial = min (curpos, sizeof read_buf); if (lseek (fd, curpos - trial, SEEK_SET) < 0) - report_file_error ("Setting file position", - list1 (orig_filename)); + report_file_error ("Setting file position", orig_filename); total_read = nread = 0; while (total_read < trial) @@ -3987,8 +3992,7 @@ CONVERSION_BUFFER. */ if (lseek (fd, beg_offset, SEEK_SET) < 0) - report_file_error ("Setting file position", - list1 (orig_filename)); + report_file_error ("Setting file position", orig_filename); inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ unprocessed = 0; /* Bytes not processed in previous loop. */ @@ -4168,8 +4172,7 @@ if (beg_offset != 0 || !NILP (replace)) { if (lseek (fd, beg_offset, SEEK_SET) < 0) - report_file_error ("Setting file position", - list1 (orig_filename)); + report_file_error ("Setting file position", orig_filename); } /* In the following loop, HOW_MUCH contains the total bytes read so @@ -4574,8 +4577,7 @@ && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) { /* If visiting nonexistent file, return nil. */ - report_file_errno ("Opening input file", list1 (orig_filename), - save_errno); + report_file_errno ("Opening input file", orig_filename, save_errno); } if (read_quit) @@ -4901,8 +4903,7 @@ if (!auto_saving) unlock_file (lockname); #endif /* CLASH_DETECTION */ UNGCPRO; - report_file_errno ("Opening output file", list1 (filename), - open_errno); + report_file_errno ("Opening output file", filename, open_errno); } record_unwind_protect (close_file_unwind, make_number (desc)); @@ -4917,8 +4918,7 @@ if (!auto_saving) unlock_file (lockname); #endif /* CLASH_DETECTION */ UNGCPRO; - report_file_errno ("Lseek error", list1 (filename), - lseek_errno); + report_file_errno ("Lseek error", filename, lseek_errno); } } === modified file 'src/gfilenotify.c' --- src/gfilenotify.c 2013-07-16 04:39:23 +0000 +++ src/gfilenotify.c 2013-07-16 16:39:42 +0000 @@ -173,7 +173,7 @@ CHECK_STRING (file); file = Fdirectory_file_name (Fexpand_file_name (file, Qnil)); if (NILP (Ffile_exists_p (file))) - report_file_error ("File does not exist", list1 (file)); + report_file_error ("File does not exist", file); CHECK_LIST (flags); === modified file 'src/keyboard.c' --- src/keyboard.c 2013-07-16 14:52:22 +0000 +++ src/keyboard.c 2013-07-16 16:39:42 +0000 @@ -10128,7 +10128,7 @@ file = Fexpand_file_name (file, Qnil); dribble = emacs_fopen (SSDATA (file), "w"); if (dribble == 0) - report_file_error ("Opening dribble", list1 (file)); + report_file_error ("Opening dribble", file); } return Qnil; } === modified file 'src/print.c' --- src/print.c 2013-07-16 06:39:49 +0000 +++ src/print.c 2013-07-16 16:39:42 +0000 @@ -770,8 +770,7 @@ { stderr = initial_stderr_stream; initial_stderr_stream = NULL; - report_file_error ("Cannot open debugging output stream", - list1 (file)); + report_file_error ("Cannot open debugging output stream", file); } } return Qnil; === modified file 'src/process.c' --- src/process.c 2013-07-16 07:05:41 +0000 +++ src/process.c 2013-07-16 16:39:42 +0000 @@ -1397,7 +1397,7 @@ current_dir = expand_and_dir_to_file (current_dir, Qnil); if (NILP (Ffile_accessible_directory_p (current_dir))) report_file_error ("Setting current directory", - list1 (BVAR (current_buffer, directory))); + BVAR (current_buffer, directory)); UNGCPRO; } @@ -1519,7 +1519,7 @@ openp (Vexec_path, program, Vexec_suffixes, &tem, make_number (X_OK)); UNGCPRO; if (NILP (tem)) - report_file_error ("Searching for program", list1 (program)); + report_file_error ("Searching for program", program); tem = Fexpand_file_name (tem, Qnil); } else @@ -5466,7 +5466,7 @@ if (rv >= 0) written = rv; else if (errno == EMSGSIZE) - report_file_error ("sending datagram", list1 (proc)); + report_file_error ("sending datagram", proc); } else #endif @@ -5543,7 +5543,7 @@ } else /* This is a real error. */ - report_file_error ("writing to process", list1 (proc)); + report_file_error ("writing to process", proc); } cur_buf += written; cur_len -= written; === modified file 'src/unexaix.c' --- src/unexaix.c 2013-07-16 06:39:49 +0000 +++ src/unexaix.c 2013-07-16 16:39:42 +0000 @@ -97,7 +97,7 @@ int err = errno; if (fd) emacs_close (fd); - report_file_errno ("Cannot unexec", list1 (build_string (file)), err); + report_file_errno ("Cannot unexec", build_string (file), err); } #define ERROR0(msg) report_error_1 (new, msg) === modified file 'src/unexcoff.c' --- src/unexcoff.c 2013-07-16 06:39:49 +0000 +++ src/unexcoff.c 2013-07-16 16:39:42 +0000 @@ -130,7 +130,7 @@ int err = errno; if (fd) emacs_close (fd); - report_file_errno ("Cannot unexec", list1 (build_string (file)), err); + report_file_errno ("Cannot unexec", build_string (file), err); } #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 ------------------------------------------------------------ revno: 113433 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 07:52:22 -0700 message: Fix minor problems found by --enable-gcc-warnings. * frame.c (Fhandle_focus_in, Fhandle_focus_out): Return a value. * keyboard.c (kbd_buffer_get_event): Remove unused local. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 11:41:06 +0000 +++ src/ChangeLog 2013-07-16 14:52:22 +0000 @@ -1,3 +1,9 @@ +2013-07-16 Paul Eggert + + Fix minor problems found by --enable-gcc-warnings. + * frame.c (Fhandle_focus_in, Fhandle_focus_out): Return a value. + * keyboard.c (kbd_buffer_get_event): Remove unused local. + 2013-07-16 Jan Djärv * xterm.c (x_focus_changed): Always generate FOCUS_IN_EVENT. === modified file 'src/frame.c' --- src/frame.c 2013-07-16 11:41:06 +0000 +++ src/frame.c 2013-07-16 14:52:22 +0000 @@ -895,7 +895,7 @@ This function checks if blink-cursor timers should be turned on again. */) (Lisp_Object event) { - call0 (intern ("blink-cursor-check")); + return call0 (intern ("blink-cursor-check")); } DEFUN ("handle-focus-out", Fhandle_focus_out, Shandle_focus_out, 1, 1, "e", @@ -905,7 +905,7 @@ This function checks if blink-cursor timers should be turned off. */) (Lisp_Object event) { - call0 (intern ("blink-cursor-suspend")); + return call0 (intern ("blink-cursor-suspend")); } DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e", === modified file 'src/keyboard.c' --- src/keyboard.c 2013-07-16 11:41:06 +0000 +++ src/keyboard.c 2013-07-16 14:52:22 +0000 @@ -4092,7 +4092,7 @@ #else struct x_display_info *di; #endif - Lisp_Object rest, frame = event->frame_or_window; + Lisp_Object frame = event->frame_or_window; bool focused = false; for (di = x_display_list; di && ! focused; di = di->next) ------------------------------------------------------------ revno: 113432 committer: Dmitry Gutov branch nick: trunk timestamp: Tue 2013-07-16 18:47:23 +0400 message: * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not highlight question marks in the method names as strings. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-16 11:41:06 +0000 +++ lisp/ChangeLog 2013-07-16 14:47:23 +0000 @@ -1,3 +1,8 @@ +2013-07-16 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not + highlight question marks in the method names as strings. + 2013-07-16 Jan Djärv * frame.el (blink-cursor-blinks): New defcustom. === modified file 'lisp/progmodes/ruby-mode.el' --- lisp/progmodes/ruby-mode.el 2013-07-13 19:10:19 +0000 +++ lisp/progmodes/ruby-mode.el 2013-07-16 14:47:23 +0000 @@ -1864,7 +1864,7 @@ 1 font-lock-negation-char-face) ;; character literals ;; FIXME: Support longer escape sequences. - '("\\?\\\\?\\S " 0 font-lock-string-face) + '("\\_<\\?\\\\?\\S " 0 font-lock-string-face) ) "Additional expressions to highlight in Ruby mode.") ------------------------------------------------------------ revno: 113431 committer: Jan D. branch nick: trunk timestamp: Tue 2013-07-16 13:41:06 +0200 message: Stop cursor blink after blink-cursor-blinks (10), stop timers when not blinking. * etc/NEWS: Document blink-cursor-blinks and blink timers stopped. * lisp/frame.el (blink-cursor-blinks): New defcustom. (blink-cursor-blinks-done): New defvar. (blink-cursor-start): Set blink-cursor-blinks-done to 1. (blink-cursor-timer-function): Check if number of blinks has been done on X and NS. (blink-cursor-suspend, blink-cursor-check): New defuns. * src/frame.c (Fhandle_focus_in, Fhandle_focus_out): New functions. (Fhandle_switch_frame): Call Fhandle_focus_in. (syms_of_frame): defsubr handle-focus-in/out. * src/keyboard.c (Qfocus_in, Qfocus_out): New static objects. (make_lispy_focus_in, make_lispy_focus_out): Declare and define. (kbd_buffer_get_event): For FOCUS_IN, make a focus_in event if no switch frame event is made. Check ! NILP (event->arg) if X11 (moved from xterm.c). Make focus_out event for FOCUS_OUT_EVENT if NS or X11 and there is a focused frame. (head_table): Add focus-in and focus-out. (keys_of_keyboard): Add focus-in and focus-out to Vspecial_event_map, bind to handle-focus-in/out. * src/nsterm.m (windowDidResignKey): If this is the focused frame, generate FOCUS_OUT_EVENT. * src/termhooks.h (enum event_kind): Add FOCUS_OUT_EVENT. * src/xterm.c (x_focus_changed): Always generate FOCUS_IN_EVENT. Set event->arg to Qt if switch-event shall be generated. Generate FOCUS_OUT_EVENT for FocusOut if this is the focused frame. diff: === modified file 'etc/ChangeLog' --- etc/ChangeLog 2013-07-13 10:55:21 +0000 +++ etc/ChangeLog 2013-07-16 11:41:06 +0000 @@ -1,3 +1,7 @@ +2013-07-16 Jan Djärv + + * NEWS: Document blink-cursor-blinks and blink timers stopped. + 2013-07-13 Eli Zaretskii * NEWS: Document prefer-utf-8 and the new attributes === modified file 'etc/NEWS' --- etc/NEWS 2013-07-15 02:33:54 +0000 +++ etc/NEWS 2013-07-16 11:41:06 +0000 @@ -122,6 +122,11 @@ Generic commands are interactive functions whose implementation can be selected among several alternatives, as a matter of user preference. +** The blink cursor stops blinking after 10 blinks (default) on X and NS. +You can change the default by customizing the variable blink-cursor-blinks. +Also timers for blinking are stopped when no blinking is done, so Emacs does +not consume CPU cycles. + * Editing Changes in Emacs 24.4 === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-15 19:45:22 +0000 +++ lisp/ChangeLog 2013-07-16 11:41:06 +0000 @@ -1,3 +1,12 @@ +2013-07-16 Jan Djärv + + * frame.el (blink-cursor-blinks): New defcustom. + (blink-cursor-blinks-done): New defvar. + (blink-cursor-start): Set blink-cursor-blinks-done to 1. + (blink-cursor-timer-function): Check if number of blinks has been + done on X and NS. + (blink-cursor-suspend, blink-cursor-check): New defuns. + 2013-07-15 Glenn Morris * edmacro.el (edmacro-format-keys): Fix previous change. === modified file 'lisp/frame.el' --- lisp/frame.el 2013-07-04 10:25:54 +0000 +++ lisp/frame.el 2013-07-16 11:41:06 +0000 @@ -1671,6 +1671,16 @@ :type 'number :group 'cursor) +(defcustom blink-cursor-blinks 10 + "How many times to blink before using a solid cursor on NS and X. +Use 0 or negative value to blink forever." + :version "24.4" + :type 'integer + :group 'cursor) + +(defvar blink-cursor-blinks-done 1 + "Number of blinks done since we started blinking on NS and X") + (defvar blink-cursor-idle-timer nil "Timer started after `blink-cursor-delay' seconds of Emacs idle time. The function `blink-cursor-start' is called when the timer fires.") @@ -1688,6 +1698,7 @@ (when (null blink-cursor-timer) ;; Set up the timer first, so that if this signals an error, ;; blink-cursor-end is not added to pre-command-hook. + (setq blink-cursor-blinks-done 1) (setq blink-cursor-timer (run-with-timer blink-cursor-interval blink-cursor-interval 'blink-cursor-timer-function)) @@ -1696,7 +1707,15 @@ (defun blink-cursor-timer-function () "Timer function of timer `blink-cursor-timer'." - (internal-show-cursor nil (not (internal-show-cursor-p)))) + (internal-show-cursor nil (not (internal-show-cursor-p))) + ;; Each blink is two calls to this function. + (when (memq window-system '(x ns)) + (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done)) + (when (and (> blink-cursor-blinks 0) + (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done)) + (blink-cursor-suspend) + (add-hook 'post-command-hook 'blink-cursor-check)))) + (defun blink-cursor-end () "Stop cursor blinking. @@ -1709,6 +1728,29 @@ (cancel-timer blink-cursor-timer) (setq blink-cursor-timer nil))) +(defun blink-cursor-suspend () + "Suspend cursor blinking on NS and X. +This is called when no frame has focus and timers can be suspended. +Timers are restarted by `blink-cursor-check', which is called when a +frame receives focus." + (when (memq window-system '(x ns)) + (blink-cursor-end) + (when blink-cursor-idle-timer + (cancel-timer blink-cursor-idle-timer) + (setq blink-cursor-idle-timer nil)))) + +(defun blink-cursor-check () + "Check if cursot blinking shall be restarted. +This is done when a frame gets focus. Blink timers may be stopped by +`blink-cursor-suspend'." + (when (and blink-cursor-mode + (not blink-cursor-idle-timer)) + (remove-hook 'post-command-hook 'blink-cursor-check) + (setq blink-cursor-idle-timer + (run-with-idle-timer blink-cursor-delay + blink-cursor-delay + 'blink-cursor-start)))) + (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1") (define-minor-mode blink-cursor-mode === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 07:05:41 +0000 +++ src/ChangeLog 2013-07-16 11:41:06 +0000 @@ -1,3 +1,28 @@ +2013-07-16 Jan Djärv + + * xterm.c (x_focus_changed): Always generate FOCUS_IN_EVENT. + Set event->arg to Qt if switch-event shall be generated. + Generate FOCUS_OUT_EVENT for FocusOut if this is the focused frame. + + * termhooks.h (enum event_kind): Add FOCUS_OUT_EVENT. + + * nsterm.m (windowDidResignKey): If this is the focused frame, generate + FOCUS_OUT_EVENT. + + * keyboard.c (Qfocus_in, Qfocus_out): New static objects. + (make_lispy_focus_in, make_lispy_focus_out): Declare and define. + (kbd_buffer_get_event): For FOCUS_IN, make a focus_in event if no + switch frame event is made. Check ! NILP (event->arg) if X11 (moved + from xterm.c). Make focus_out event for FOCUS_OUT_EVENT if NS or X11 + and there is a focused frame. + (head_table): Add focus-in and focus-out. + (keys_of_keyboard): Add focus-in and focus-out to Vspecial_event_map, + bind to handle-focus-in/out. + + * frame.c (Fhandle_focus_in, Fhandle_focus_out): New functions. + (Fhandle_switch_frame): Call Fhandle_focus_in. + (syms_of_frame): defsubr handle-focus-in/out. + 2013-07-16 Paul Eggert Fix porting bug to older POSIXish platforms (Bug#14862). === modified file 'src/frame.c' --- src/frame.c 2013-07-16 06:39:49 +0000 +++ src/frame.c 2013-07-16 11:41:06 +0000 @@ -887,6 +887,26 @@ return do_switch_frame (frame, 1, 0, norecord); } +DEFUN ("handle-focus-in", Fhandle_focus_in, Shandle_focus_in, 1, 1, "e", + doc: /* Handle a focus-in event. +Focus in events are usually bound to this function. +Focus in events occur when a frame has focus, but a switch-frame event +is not generated. +This function checks if blink-cursor timers should be turned on again. */) + (Lisp_Object event) +{ + call0 (intern ("blink-cursor-check")); +} + +DEFUN ("handle-focus-out", Fhandle_focus_out, Shandle_focus_out, 1, 1, "e", + doc: /* Handle a focus-out event. +Focus out events are usually bound to this function. +Focus out events occur when no frame has focus. +This function checks if blink-cursor timers should be turned off. */) + (Lisp_Object event) +{ + call0 (intern ("blink-cursor-suspend")); +} DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e", doc: /* Handle a switch-frame event EVENT. @@ -902,6 +922,7 @@ /* Preserve prefix arg that the command loop just cleared. */ kset_prefix_arg (current_kboard, Vcurrent_prefix_arg); Frun_hooks (1, &Qmouse_leave_buffer_hook); + Fhandle_focus_in (event); // switch-frame implies a focus in. return do_switch_frame (event, 0, 0, Qnil); } @@ -4449,6 +4470,8 @@ defsubr (&Swindow_system); defsubr (&Smake_terminal_frame); defsubr (&Shandle_switch_frame); + defsubr (&Shandle_focus_in); + defsubr (&Shandle_focus_out); defsubr (&Sselect_frame); defsubr (&Sselected_frame); defsubr (&Sframe_list); === modified file 'src/keyboard.c' --- src/keyboard.c 2013-07-16 06:39:49 +0000 +++ src/keyboard.c 2013-07-16 11:41:06 +0000 @@ -295,6 +295,7 @@ static Lisp_Object Qmouse_movement; static Lisp_Object Qscroll_bar_movement; Lisp_Object Qswitch_frame; +static Lisp_Object Qfocus_in, Qfocus_out; static Lisp_Object Qdelete_frame; static Lisp_Object Qiconify_frame; static Lisp_Object Qmake_frame_visible; @@ -420,6 +421,8 @@ Lisp_Object, const char *const *, Lisp_Object *, ptrdiff_t); static Lisp_Object make_lispy_switch_frame (Lisp_Object); +static Lisp_Object make_lispy_focus_in (Lisp_Object); +static Lisp_Object make_lispy_focus_out (Lisp_Object); static bool help_char_p (Lisp_Object); static void save_getcjmp (sys_jmp_buf); static void restore_getcjmp (sys_jmp_buf); @@ -4061,17 +4064,45 @@ switch-frame event if necessary. */ Lisp_Object frame, focus; - frame = event->frame_or_window; - focus = FRAME_FOCUS_FRAME (XFRAME (frame)); - if (FRAMEP (focus)) - frame = focus; - - if (!EQ (frame, internal_last_event_frame) - && !EQ (frame, selected_frame)) - obj = make_lispy_switch_frame (frame); - internal_last_event_frame = frame; - kbd_fetch_ptr = event + 1; - } + frame = event->frame_or_window; + focus = FRAME_FOCUS_FRAME (XFRAME (frame)); + if (FRAMEP (focus)) + frame = focus; + + if ( +#ifdef HAVE_X11 + ! NILP (event->arg) + && +#endif + !EQ (frame, internal_last_event_frame) + && !EQ (frame, selected_frame)) + obj = make_lispy_switch_frame (frame); + else + obj = make_lispy_focus_in (frame); + + internal_last_event_frame = frame; + kbd_fetch_ptr = event + 1; + } + else if (event->kind == FOCUS_OUT_EVENT) + { +#if defined(HAVE_NS) || defined (HAVE_X11) + +#ifdef HAVE_NS + struct ns_display_info *di; +#else + struct x_display_info *di; +#endif + Lisp_Object rest, frame = event->frame_or_window; + bool focused = false; + + for (di = x_display_list; di && ! focused; di = di->next) + focused = di->x_highlight_frame != 0; + + if (! focused) obj = make_lispy_focus_out (frame); +#endif /* HAVE_NS || HAVE_X11 */ + + kbd_fetch_ptr = event + 1; + } #ifdef HAVE_DBUS else if (event->kind == DBUS_EVENT) { @@ -6052,6 +6083,17 @@ { return list2 (Qswitch_frame, frame); } + +static Lisp_Object +make_lispy_focus_in (Lisp_Object frame) +{ + return list2 (Qfocus_in, frame); +} +static Lisp_Object +make_lispy_focus_out (Lisp_Object frame) +{ + return list2 (Qfocus_out, frame); +} /* Manipulating modifiers. */ @@ -10911,6 +10953,8 @@ {&Qmouse_movement, "mouse-movement", &Qmouse_movement}, {&Qscroll_bar_movement, "scroll-bar-movement", &Qmouse_movement}, {&Qswitch_frame, "switch-frame", &Qswitch_frame}, + {&Qfocus_in, "focus-in", &Qfocus_in}, + {&Qfocus_out, "focus-out", &Qfocus_out}, {&Qdelete_frame, "delete-frame", &Qdelete_frame}, {&Qiconify_frame, "iconify-frame", &Qiconify_frame}, {&Qmake_frame_visible, "make-frame-visible", &Qmake_frame_visible}, @@ -11725,6 +11769,10 @@ initial_define_lispy_key (Vspecial_event_map, "language-change", "ignore"); #endif + initial_define_lispy_key (Vspecial_event_map, "focus-in", + "handle-focus-in"); + initial_define_lispy_key (Vspecial_event_map, "focus-out", + "handle-focus-out"); } /* Mark the pointers in the kboard objects. === modified file 'src/nsterm.m' --- src/nsterm.m 2013-07-16 07:05:41 +0000 +++ src/nsterm.m 2013-07-16 11:41:06 +0000 @@ -5746,9 +5746,10 @@ /* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */ { struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); + BOOL is_focus_frame = dpyinfo->x_focus_frame == emacsframe; NSTRACE (windowDidResignKey); - if (dpyinfo->x_focus_frame == emacsframe) + if (is_focus_frame) dpyinfo->x_focus_frame = 0; ns_frame_rehighlight (emacsframe); @@ -5761,10 +5762,10 @@ x_set_frame_alpha (emacsframe); } - if (emacs_event) + if (emacs_event && is_focus_frame) { [self deleteWorkingText]; - emacs_event->kind = FOCUS_IN_EVENT; + emacs_event->kind = FOCUS_OUT_EVENT; EV_TRAILER ((id)nil); } } === modified file 'src/termhooks.h' --- src/termhooks.h 2013-07-11 02:17:47 +0000 +++ src/termhooks.h 2013-07-16 11:41:06 +0000 @@ -172,6 +172,8 @@ `switch-frame' events in kbd_buffer_get_event, if necessary. */ FOCUS_IN_EVENT, + FOCUS_OUT_EVENT, + /* Generated when mouse moves over window not currently selected. */ SELECT_WINDOW_EVENT, === modified file 'src/xterm.c' --- src/xterm.c 2013-07-16 06:39:49 +0000 +++ src/xterm.c 2013-07-16 11:41:06 +0000 @@ -3439,9 +3439,15 @@ && CONSP (Vframe_list) && !NILP (XCDR (Vframe_list))) { - bufp->kind = FOCUS_IN_EVENT; - XSETFRAME (bufp->frame_or_window, frame); - } + bufp->arg = Qt; + } + else + { + bufp->arg = Qnil; + } + + bufp->kind = FOCUS_IN_EVENT; + XSETFRAME (bufp->frame_or_window, frame); } frame->output_data.x->focus_state |= state; @@ -3459,6 +3465,9 @@ { dpyinfo->x_focus_event_frame = 0; x_new_focus_frame (dpyinfo, 0); + + bufp->kind = FOCUS_OUT_EVENT; + XSETFRAME (bufp->frame_or_window, frame); } #ifdef HAVE_X_I18N ------------------------------------------------------------ revno: 113430 fixes bug: http://debbugs.gnu.org/14862 committer: Paul Eggert branch nick: trunk timestamp: Tue 2013-07-16 00:05:41 -0700 message: Fix porting bug to older POSIXish platforms. * sysdep.c (emacs_pipe): New function, that implements pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC. This should port better to CentOS 5 and to Mac OS X 10.6. All calls to pipe2 changed. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-16 06:39:49 +0000 +++ src/ChangeLog 2013-07-16 07:05:41 +0000 @@ -1,5 +1,11 @@ 2013-07-16 Paul Eggert + Fix porting bug to older POSIXish platforms (Bug#14862). + * sysdep.c (emacs_pipe): New function, that implements + pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC. + This should port better to CentOS 5 and to Mac OS X 10.6. + All calls to pipe2 changed. + Prefer list1 (X) to Fcons (X, Qnil) when building lists. This makes the code easier to read and the executable a bit smaller. Do not replace all calls to Fcons that happen to create lists, === modified file 'src/alloc.c' --- src/alloc.c 2013-07-07 18:00:14 +0000 +++ src/alloc.c 2013-07-16 07:05:41 +0000 @@ -4741,7 +4741,7 @@ Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may not validate p in that case. */ - if (pipe2 (fd, O_CLOEXEC) == 0) + if (emacs_pipe (fd) == 0) { bool valid = emacs_write (fd[1], (char *) p, 16) == 16; emacs_close (fd[1]); === modified file 'src/callproc.c' --- src/callproc.c 2013-07-16 06:39:49 +0000 +++ src/callproc.c 2013-07-16 07:05:41 +0000 @@ -524,7 +524,7 @@ { #ifndef MSDOS int fd[2]; - if (pipe2 (fd, O_CLOEXEC) != 0) + if (emacs_pipe (fd) != 0) { int pipe_errno = errno; emacs_close (filefd); === modified file 'src/emacs.c' --- src/emacs.c 2013-07-16 06:39:49 +0000 +++ src/emacs.c 2013-07-16 07:05:41 +0000 @@ -985,7 +985,7 @@ use a pipe for synchronization. The parent waits for the child to close its end of the pipe (using `daemon-initialized') before exiting. */ - if (pipe2 (daemon_pipe, O_CLOEXEC) != 0) + if (emacs_pipe (daemon_pipe) != 0) { fprintf (stderr, "Cannot pipe!\n"); exit (1); === modified file 'src/lisp.h' --- src/lisp.h 2013-07-12 17:30:48 +0000 +++ src/lisp.h 2013-07-16 07:05:41 +0000 @@ -4094,6 +4094,7 @@ extern void emacs_backtrace (int); extern _Noreturn void emacs_abort (void) NO_INLINE; extern int emacs_open (const char *, int, int); +extern int emacs_pipe (int[2]); extern int emacs_close (int); extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); === modified file 'src/nsterm.m' --- src/nsterm.m 2013-07-16 06:39:49 +0000 +++ src/nsterm.m 2013-07-16 07:05:41 +0000 @@ -4142,7 +4142,7 @@ if (selfds[0] == -1) { - if (pipe2 (selfds, O_CLOEXEC) != 0) + if (emacs_pipe (selfds) != 0) { fprintf (stderr, "Failed to create pipe: %s\n", emacs_strerror (errno)); === modified file 'src/process.c' --- src/process.c 2013-07-16 06:39:49 +0000 +++ src/process.c 2013-07-16 07:05:41 +0000 @@ -1651,11 +1651,11 @@ else #endif /* HAVE_PTYS */ { - if (pipe2 (sv, O_CLOEXEC) != 0) + if (emacs_pipe (sv) != 0) report_file_error ("Creating pipe", Qnil); inchannel = sv[0]; forkout = sv[1]; - if (pipe2 (sv, O_CLOEXEC) != 0) + if (emacs_pipe (sv) != 0) { int pipe_errno = errno; emacs_close (inchannel); @@ -1667,7 +1667,7 @@ } #ifndef WINDOWSNT - if (pipe2 (wait_child_setup, O_CLOEXEC) != 0) + if (emacs_pipe (wait_child_setup) != 0) report_file_error ("Creating pipe", Qnil); #endif === modified file 'src/sysdep.c' --- src/sysdep.c 2013-07-12 14:31:42 +0000 +++ src/sysdep.c 2013-07-16 07:05:41 +0000 @@ -2201,6 +2201,20 @@ return fd < 0 ? 0 : fdopen (fd, mode); } +/* Create a pipe for Emacs use. */ + +int +emacs_pipe (int fd[2]) +{ + int result = pipe2 (fd, O_CLOEXEC); + if (! O_CLOEXEC && result == 0) + { + fcntl (fd[0], F_SETFD, FD_CLOEXEC); + fcntl (fd[1], F_SETFD, FD_CLOEXEC); + } + return result; +} + /* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs. For the background behind this mess, please see Austin Group defect 529 . */ ------------------------------------------------------------ revno: 113429 committer: Xue Fuqiao branch nick: trunk timestamp: Tue 2013-07-16 14:45:01 +0800 message: Fix the introduction of `set-frame-selected-window''s arguments. * doc/lispref/windows.texi (Selecting Windows): Fix the introduction of `set-frame-selected-window''s arguments. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2013-07-10 06:26:23 +0000 +++ doc/lispref/ChangeLog 2013-07-16 06:45:01 +0000 @@ -1,3 +1,8 @@ +2013-07-16 Xue Fuqiao + + * windows.texi (Selecting Windows): Fix the introduction of + `set-frame-selected-window''s arguments. + 2013-07-10 Paul Eggert Timestamp fixes for undo (Bug#14824). === modified file 'doc/lispref/windows.texi' --- doc/lispref/windows.texi 2013-04-13 14:37:20 +0000 +++ doc/lispref/windows.texi 2013-07-16 06:45:01 +0000 @@ -1355,10 +1355,9 @@ @defun set-frame-selected-window frame window &optional norecord This function makes @var{window} the window selected within the frame -@var{frame}. @var{frame} should be a live frame; if omitted or -@code{nil}, it defaults to the selected frame. @var{window} should be -a live window; if omitted or @code{nil}, it defaults to the selected -window. +@var{frame}. @var{frame} should be a live frame; if @code{nil}, it +defaults to the selected frame. @var{window} should be a live window; +if @code{nil}, it defaults to the selected window. If @var{frame} is the selected frame, this makes @var{window} the selected window.