1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-12 22:40:46 -08:00
Commit graph

38121 commits

Author SHA1 Message Date
Paul Eggert
36649e0150 Spelling and grammar fixes 2015-11-29 21:52:17 -08:00
Philipp Stephani
c217802b0f Simplify the prologue of emacs-module.c functions
* emacs-module.c (MODULE_FUNCTION_BEGIN): New macro.
(module_make_global_ref)
(module_free_global_ref, module_make_function, module_funcall)
(module_intern, module_type_of, module_extract_integer)
(module_make_integer, module_extract_float, module_make_float)
(module_copy_string_contents, module_make_string)
(module_make_user_ptr, module_get_user_ptr, module_set_user_ptr)
(module_get_user_finalizer, module_set_user_finalizer)
(module_vec_set, module_vec_get, module_vec_size): Use new helper
macro MODULE_FUNCTION_BEGIN.
2015-11-28 14:08:21 +02:00
Eli Zaretskii
a63d1eca8d Don't reject module calls with no arguments
* src/emacs-module.c (Finternal_module_call): Allow ARGLIST be nil.
2015-11-28 13:59:12 +02:00
Philipp Stephani
b527d609d9 Make module-call be visible from Lisp
* src/emacs-module.c (module_make_function): Use internal--module-call.
(Finternal_module_call): Renamed from Fmodule_call.  Add safety
checks.
(syms_of_module): DEFSYM save-value-p and save-pointer-p.  Do
defsubr internal--module-call.
2015-11-28 13:53:32 +02:00
Paul Eggert
f32c79dd0e Fix minor problems found by static checking
* src/undo.c (prepare_record): Add proper prototype for C.
2015-11-27 22:09:11 -08:00
Stefan Monnier
60d8c804cf * src/emacs-module.c (struct env_storage): Delete
(struct emacs_runtime_private): Keep an emacs_env instead.
(Fmodule_load, Fmodule_call): Declare emacs_env_private separately.
(initialize_environment): Split the arg in two.	 Adjust all callers.
Only store the private part in Vmodule_environments.
(finalize_environment): Change the arg to only be the private env.
Adjust all callers.
2015-11-27 15:18:29 -05:00
Eli Zaretskii
1ed316d275 Improve handling of signals and 'throw' in modules
* src/emacs-module.c: Add commentary explaining how to write
functions in this file.
(module_make_global_ref, module_free_global_ref)
(module_non_local_exit_signal, module_non_local_exit_throw)
(module_make_function, module_funcall, module_intern)
(module_type_of, module_is_not_nil, module_eq)
(module_extract_integer, module_make_integer)
(module_extract_float, module_make_float)
(module_copy_string_contents, module_make_string)
(module_make_user_ptr, module_get_user_ptr, module_set_user_ptr)
(module_get_user_finalizer, module_set_user_finalizer)
(module_vec_set, module_vec_get, module_vec_size)
(module_non_local_exit_signal_1, module_non_local_exit_throw_1):
Do nothing and return with failure indication immediately, if some
previous module call signaled an error or wants to throw.  See
http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02133.html
for the relevant discussions.
2015-11-27 12:51:52 +02:00
Eli Zaretskii
3f42061bb6 Improve documentation of 'eval-buffer' and 'eval-region'
* src/lread.c (Feval_buffer, Feval_region): Doc fixes.  (Bug#22023)

* doc/lispref/eval.texi (Eval): Mention narrowing to clarify
"accessible portion of buffer".
2015-11-27 12:07:08 +02:00
Eli Zaretskii
33460000f9 Unbreak the Cygwin w32 build
* src/emacs.c (main): Call w32_init_main_thread in the Cygwin w32
build as well.  Reported by Andy Moreton <andrewjmoreton@gmail.com>.
2015-11-27 10:01:40 +02:00
Eli Zaretskii
3f042f6588 Improve commentary of prepare_to_modify_buffer_1
* src/insdel.c (prepare_to_modify_buffer_1): Mention in commentary
that this function runs Lisp.  Suggested by Richard Stallman
<rms@gnu.org>.
2015-11-26 22:08:54 +02:00
Phillip Lord
ae18cc20f8 Merge branch 'emacs-25' of git.sv.gnu.org:/srv/git/emacs into emacs-25 2015-11-26 18:09:15 +00:00
Phillip Lord
13a03c9083 Fix regression after merge.
* undo.c (prepare_record): Remove call to run_undoable_change.
2015-11-26 18:02:29 +00:00
Phillip Lord
7592cb9d2a After delete, record point location in undo.
Addresses Bug #21968.

	* lisp/simple.el (undo-auto--add-boundary): Clean up code to
	better support intercalating calls.
	* src/keyboard.c,src/keyboard.h (command_loop_1): Store value of
	point and current buffer before each command.
	* src/undo.c (record_point): Now only record the point.
	* src/undo.c (prepare_record): Functionality removed form
	record_point.
	* src/undo.c (record_delete): Check if point needs recording.
	* src/undo.c (undo-boundary): Record value of point before each
	boundary.
	* test/automated/simple-test.el: New tests.

Conflicts:
	src/undo.c
2015-11-26 17:57:11 +00:00
Eli Zaretskii
6f5f62b3c7 Fix compiler warnings in w32.c
* src/w32.c (sys_socket): In case of error, use -1 as return
value, not INVALID_SOCKET, which causes compiler warnings.
(maybe_load_unicows_dll): Cast the return value of GetProcAddress
to the appropriate function signature, to avoid compiler errors.
Reported by Andy Moreton <andrewjmoreton@gmail.com>.  (Bug#21953)
2015-11-26 19:53:47 +02:00
Paul Eggert
54e8c7bd3a * src/undo.c (record_property_change): Remove now-unused local. 2015-11-25 16:14:53 -08:00
Phillip Lord
957b05c615 run_undoable_changes now called from insdel.
The original calls from inside undo.c are not always at a safe position
to call lisp, as they originate in varied positions within insdel.c.
Calling them directly from prepare_to_modify_buffer_1 ensures that they
are always run at the same point.

 * undo.c (run_undoable_changes,syms_of_undo): Remove function
 and symbol used.
 * insdel.c (run_undoable_changes): Add function and symbol.
2015-11-25 21:39:49 +00:00
Paul Eggert
d8143fa89b Fix module_format_fun_env when dynlib_addr fails
* src/emacs-module.c (module_format_fun_env):
exprintf doesn’t support %p, so use %x.  Reported by Eli Zaretskii in:
http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02122.html
2015-11-24 23:44:10 -08:00
Eli Zaretskii
146f361a13 Implement dynlib_addr for MS-Windows
* src/dynlib.c [WINDOWSNT]: Include w32common.h.
<g_b_init_get_module_handle_ex> [WINDOWSNT]: New static variable.
(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) [WINDOWSNT]: Define
if undefined.
(dynlib_reset_last_error): Reset g_b_init_get_module_handle_ex to
zero.
(dynlib_addr) [WINDOWSNT]: Non-trivial implementation to report
the full file name of the module for a given address.
2015-11-24 21:04:56 +02:00
Eli Zaretskii
d5fdffecdf Fix crash at startup related to GC of font entities
* src/font.h (GC_FONT_SPEC_P, GC_FONT_ENTITY_P)
(GC_FONT_OBJECT_P, GC_XFONT_SPEC, GC_XFONT_ENTITY)
(GC_XFONT_OBJECT): New macros, for use in garbage collector.
* src/alloc.c (compact_font_cache_entry, compact_font_caches):
Don't ifdef away font cache compaction on NT_GUI, as the problems
which led to that seem to have been solved.
(compact_font_cache_entry): Use GC_FONT_SPEC_P, GC_XFONT_SPEC,
GC_XFONT_ENTITY, and GC_XFONT_OBJECT, instead of their non-GC_
cousins.  (Bug#21999)
2015-11-24 18:08:39 +02:00
Ken Raeburn
cb1bd34965 Fix kbd_buffer iteration loop in readable_events
* src/keyboard.c (readable_events): Wrap the event pointer back to the
start of the kbd_buffer array inside the top of the loop instead of
right before checking the loop condition, since kbd_fetch_ptr and
kbd_store_ptr point past the end of the array to mean that element 0
is next. (bug#21935)
2015-11-24 03:51:13 -05:00
Paul Eggert
946ea4184c Improve text-quoting-style doc 2015-11-23 19:23:06 -08:00
Paul Eggert
004f4fc9d4 Simplify module_make_function
* src/emacs-module.c (module_make_function):
Simplify by calling build_unibyte_string.
2015-11-23 19:01:51 -08:00
Paul Eggert
da8c7ca264 Port better to FreeBSD’s dlfunc vs dlsym
This avoids warnings when converting between void * and
function pointers, which strict C11 does not allow.
* configure.ac (dlfunc): Check for existence.
* src/dynlib.c (dlfunc) [!HAVE_DLFUNC]: New macro.
(dynlib_func): New function.
* src/dynlib.h (dynlib_function_ptr, dynlib_func): New decls.
* src/emacs-module.c (Fmodule_load): Use dynlib_func, not
dynlib_sym, for function pointers.
2015-11-23 19:01:51 -08:00
Paul Eggert
ceaca7bec6 Simplify use of emacs_finalizer_function type
* src/emacs-module.h (emacs_finalizer_function):
Now EMACS_NOEXCEPT.  All users simplified to omit EMACS_NOEXCEPT.
(struct emacs_env_25): Use emacs_finalizer_function where applicable.
2015-11-23 19:01:51 -08:00
Paul Eggert
4f10c3cdef module_format_fun_env fixes
* src/doprnt.c (exprintf) [HAVE_MODULES]: Also define in this case.
* src/emacs-module.c (module_format_fun_env):
Convert path and sym to UTF-8.
Don’t use VLAs, as the C11 standard says they’re optional,
and anyway they can cause core dumps with large allocations.
Use exprintf rather than snprintf, as exprintf handles arbitrarily
long strings.  Simplify the code a bit.
2015-11-23 15:46:11 -08:00
Anders Lindgren
345a9c8cd0 New visible-bell for NextStep (OS X El Capitan compatible).
Instead of inverting a rectangle in the middle of the frame, use
the standard NextStep image "caution", represented using an
warning sign with an exclamation mark.  (Bug#21662)

Implemented based on a suggestion drafted by Mustafa Kocaturk.

* src/nsterm.m (EmacsBell): New class for managing the caution
image.  Support multiple active bells, the image is removed once
all bells have timed out.
(ns_timeout): Removed, no longer used.
(ns_ring_bell): Reimplemented to use EmacsBell.
2015-11-23 22:09:06 +01:00
Eli Zaretskii
345bc61796 Improve how non-ASCII strings are accepted from modules
* src/emacs-module.c (module_make_function, module_make_string):
Build a unibyte Lisp string and then decode it by UTF-8, instead
of building a multibyte string without decoding.  This is more
tolerant to deviations from UTF-8.
2015-11-23 20:08:01 +02:00
Paul Eggert
3322360514 Port recent module changes to pickier compilers
* src/emacs-module.c (module_make_function)
(module_make_string): Add casts to fix pointer signedness issues.
2015-11-23 09:53:36 -08:00
Philipp Stephani
ccc16061ac Fix how strings are accepted from modules
* emacs-module.c (module_make_function, module_make_string): Use
make_multibyte_string.
(module_copy_string_contents): Encode before reading the byte
size.  Return false if and only if an error occurred.
2015-11-23 19:46:17 +02:00
Martin Rudalics
a5749550dd Move setting FRAME_WINDOW_SIZES_CHANGED to resize_frame_windows.
* src/frame.c (adjust_frame_size): Don't set
FRAME_WINDOW_SIZES_CHANGED here ...
* src/window.c (resize_frame_windows): ... but here, as suggested
by Stefan Monnier.  Also remove some dead code along the way.
2015-11-23 18:39:18 +01:00
John Wiegley
12ad79c23e Add a note about a questionable use of bool in xdisp.c 2015-11-23 06:42:56 -08:00
Alan Mackenzie
2b8154f2bc Signal an error when `setq' has an odd number of arguments. Fixes bug#20241.
* src/eval.c (Fsetq): Signal an error on an odd number of arguments.
(syms_of_eval): Add a DEFSYM for Qsetq.
2015-11-23 13:56:37 +00:00
Martin Rudalics
dc57bb4d46 * src/frame.c (adjust_frame_size): Set FRAME_WINDOW_SIZES_CHANGED (Bug#21975). 2015-11-23 08:19:58 +01:00
Eli Zaretskii
40ed767ba0 Allow loading modules by 'load-file'
* src/lread.c (Fload): Call 'unbind_to' with 'Fmodule_load' as the
2nd arg, to avoid the "binding stack not balanced" error.
(syms_of_lread) <module-file-suffix>: New Lisp variable.

* lisp/files.el (module-file-suffix): Declare.
(load-file): Remove 'module-file-suffix' from
'completion-ignored-extensions', to allow completion on modules.

* etc/NEWS: Mention 'module-file-suffix'.
2015-11-22 20:38:51 +02:00
Eli Zaretskii
9f0d19f24c Fix unoptimized builds
* src/lisp.h (XTYPE): Move before XSYMBOL, to fix unoptimized
builds.
2015-11-22 20:19:13 +02:00
Stefan Monnier
702d76dbee Unrevert most of regexp reentrancy abort patch
The problem was in:
  * src/syntax.c (update_syntax_table_forward): Propertize even when truncated
which is hence not unreverted.
The rest is:
* src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
(UPDATE_SYNTAX_TABLE_FAST): Re-introduce.
All callers in regex.c changed back to the _FAST versions.

* test/automated/message-mode-tests.el: Tweak the test to rely on auto
propertization in backward-sexp.
2015-11-21 22:05:28 -05:00
Paul Eggert
8e84823f3f Revert regexp reentrancy abort patch
Although the patch does fix Bug#21688 and prevents a core dump,
it also makes the message-mode-propertize test fail; see:
http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg01667.html
Perhaps someone else can come up with a better fix some day.
* src/syntax.c (update_syntax_table_forward):
Propertize even when truncated.
* src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
(UPDATE_SYNTAX_TABLE_FAST): Remove.
All callers changed back to the non-_FAST versions.
2015-11-21 14:15:53 -08:00
Paul Eggert
8afaa1321f Add a few safety checks when ENABLE_CHECKING
This was motivated by the recent addition of module code,
which added some ENABLE_CHECKING-enabled checks that are
useful elsewhere too.
* src/alloc.c (compact_font_cache_entry):
* src/fns.c (sweep_weak_table):
* src/lread.c (oblookup):
Use gc_asize rather than doing it by hand.
* src/emacs-module.c (module_make_global_ref)
(module_free_global_ref, module_vec_size):
Omit assertions that lisp.h now checks.
* src/lisp.h (XFASTINT, ASIZE): In functional implementations,
check that the result is nonnegative.  Use eassume, as this
info can help a bit when optimizing production code.
(XSYMBOL) [!USE_LSB_TAG]: Assert that argument is a symbol,
to be consistent with the USE_LSB_TAG case.
(gc_asize): New function, when ASIZE is needed in the gc.
(gc_aset): Use it.
(HASH_TABLE_P): Move definition up, so that it can be used ...
(XHASH_TABLE): ... here, to assert that the arg is a hash table.
2015-11-21 10:44:04 -08:00
Eli Zaretskii
d696d62fea Simplify recording of main thread's ID on MS-Windows
* src/w32term.c (w32_initialize):
* src/w32console.c (initialize_w32_display):
* src/w32fns.c (globals_of_w32fns): Don't record the main thread
ID independently for each type of session (GUI, TTY, batch).
* src/w32term.c (w32_init_main_thread): New function, records the
main thread's thread ID.
* src/w32term.h: Add prototype for w32_init_main_thread.
* src/emacs.c (main) [WINDOWSNT]: Call w32_init_main_thread.

* src/emacs-module.c [WINDOWSNT]: Rename main_thread_id to
main_thread, for consistency with other threading libraries.  All
users changed.  Include w32term.h.
(check_main_thread) [WINDOWSNT]: Simplify the test: no need to
make sure the main thread is alive, as we hold a handle on it
opened by w32_init_main_thread.
(module_init) [WINDOWSNT]: Reuse the thread ID recorded by
w32_init_main_thread, instead of calling the requisite APIs once
more.
2015-11-21 19:44:02 +02:00
Eli Zaretskii
3c407d2919 ; * src/lread.c (Fload): Fix last change. 2015-11-21 14:01:25 +02:00
Eli Zaretskii
3ca44a1ad4 Call 'window-size-change-functions' for mini-windows
* src/window.c (grow_mini_window, shrink_mini_window): Set the
frame's 'window_sizes_changed' flag.
* src/xdisp.c (redisplay_internal): Call the hooks on
'window-size-change-functions' if the call to 'echo_area_display'
sets the frame's 'window_sizes_changed' flag.
(syms_of_xdisp) <window-size-change-functions>:
Update doc string to indicate the mini-window resizes trigger a
call to the hooks, and don't promise that will happen "before
redisplay".  (Bug#19576, Bug#21333)

* doc/lispref/windows.texi (Window Hooks): Update the description
of 'window-size-change-functions'.
2015-11-21 13:30:30 +02:00
Eli Zaretskii
3858b7949f Improve documentation of dynamic modules
* src/fns.c (Frequire): Doc fix to include the dynamic module
support.
* src/lread.c (Fload, Vload_suffixes): Doc fixes to include the
dynamic module support.
(Fload): Treat the module suffix the same as '*.el' and '*.elc'
wrt the MUST-SUFFIX argument.

* etc/NEWS: Expand documentation of dynamically loaded modules.
2015-11-21 12:49:57 +02:00
Paul Eggert
033811ceec Fix double-decrement bug when freeing global refs
* src/emacs-module.c (module_free_global_ref): Add a FIXME
comment about error reporting.  Fix a recently-introduced typo
that double-decremented the refcount.
2015-11-20 13:49:16 -08:00
Paul Eggert
d0e07e0e22 Declare emacs_module_init in the module API
* src/emacs-module.h (emacs_module_init): New decl.
Without it, GCC might complain about a module that defines
emacs_module_init without using it.  This also checks the
API better.
2015-11-20 12:21:18 -08:00
Paul Eggert
95f69f2c59 Fix reindent-introduced typo in module code
* src/emacs-module.c (MODULE_SETJMP_1): Fix typo that I
introduced while reindenting the code earlier, and add a
comment explaining the unusual use of do-while here.
2015-11-20 12:15:53 -08:00
Paul Eggert
e61f1c3c8b Module function arg counts are ptrdiff_t, not int
* src/emacs-module.c (struct module_fun_env)
(module_make_function, module_funcall, Fmodule_call):
* src/emacs-module.h (struct emacs_runtime, struct emacs_env_25):
Use ptrdiff_t, not int, for arg counts.
* src/emacs-module.c (module_make_function): Don’t bother
checking arity against MOST_POSITIVE_FIXNUM, as that’s
unnecessary here.  Make the checking clearer by negating it.
(module_make_function, Fmodule_call): No need to use xzalloc
since the storage doesn’t need to be cleared.
(module_funcall): Don’t use VLA, since C11 doesn’t guarantee support
for it, and many implementations are buggy with large VLAs anyway.
Use SAFE_ALLOCA_LISP instead.
(module_vec_set): Don’t crash if i < 0.
(module_vec_get): Don’t crash if i < MOST_NEGATIVE_FIXNUM.
(module_vec_set, module_vec_get): Do fixnum checks only when
i is out of array bounds, for efficiency in the usual case.
(Fmodule_load): Simplify fixnum range check.
(Fmodule_call): Simplify arity check.  Use xnmalloc to detect
integer overflow in array allocation size.
2015-11-20 08:51:42 -08:00
Eli Zaretskii
24be1c8460 Improve MS-Windows implementation in dynlib.c
* src/dynlib.c [WINDOWSNT]: Include errno.h, lisp.h, and w32.h.
No need to include windows.h, as w32.h already does that.
<dynlib_last_err>: New static variable.
(dynlib_reset_last_error): New function.
(dynlib_open): Convert forward slashes to backslashes.  Convert
file names from UTF-8 to either UTF-16 or the current ANSI
codepage, and call either LoadLibraryW or LoadLibraryA.  If the
argument is NULL, return a handle to the main module, like
'dlopen' does.  Record the error, if any, for use by dynlib_error.
(dynlib_sym): Check the handle for validity. Record the error, if
any, for use by dynlib_error.
(dynlib_error): Call w32_strerror to produce the error string, and
zero out the last error code, like dlerror does.
(dynlib_close): Check the handle for validity.  Record the error,
if any, for use by dynlib_error.  Don't call FreeLibrary with a
handle for the main module.
* src/w32.c (globals_of_w32): Call dynlib_reset_last_error.
2015-11-20 13:34:15 +02:00
Paul Eggert
c69cec404c Include-file tweaks for modules
* src/dynlib.c, src/emacs-module.c: Include <config.h> first.
* src/dynlib.h: Do not include config.h.
It’s every .c file’s responsibility to include config.h first.
* src/emacs-module.c: Include emacs-module.h immediately after
config.h, to test that emacs-module.h doesn’t depend on
include files other than config.h.
2015-11-20 00:41:21 -08:00
Paul Eggert
aa7dac8998 Simplify push_handler and profile its malloc
* src/lisp.h (PUSH_HANDLER): Remove.
All callers changed to use push_handler directly.
* src/eval.c (internal_condition_case)
(internal_condition_case_1, internal_condition_case_2)
(internal_condition_case_n):
Use same pattern as for other invokers of push_handler.
(push_handler, push_handler_nosignal): Use call-by-value
instead of call-by-reference.  All uses changed.
(push_handler): Simplify by rewriting in terms of
push_handler_nosignal.
(push_handler_nosignal): Profile any newly allocated memory.
2015-11-19 20:09:59 -08:00
Paul Eggert
de67fa4258 * src/emacs-module.h: Include stddef.h, not stdlib.h. 2015-11-19 17:51:30 -08:00