1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-08 20:50:52 -08:00
Commit graph

39555 commits

Author SHA1 Message Date
Paul Eggert
cef90102cb SCHARS and STRING_BYTES are nonnegative
Tell the compiler that SCHARS and STRING_BYTES are nonnegative, in
the hopes that this will optimize a bit better.  Also, check this
at runtime if ENABLE_CHECKING.
* src/lisp.h (SCHARS, STRING_BYTES):
eassume that these functions return nonnegative values.
(STRING_SET_CHARS) [ENABLE_CHECKING]:
eassert that newsize is nonnegative.
2017-06-04 23:53:47 -07:00
Philipp Stephani
2aa8b1564e Remove an unused error symbol
* src/emacs-module.c (syms_of_module): Remove unused error symbol
'invalid-module-call'.
2017-06-04 19:50:52 +02:00
Philipp Stephani
66da3f4afa Support quitting in modules
The idea is that modules should call env->should_quit from time to
time and return as quickly as possible if it returns true.

* src/emacs-module.c (module_should_quit): New module function.
(initialize_environment): Use it.
(funcall_module): Process potential pending quit.

* src/eval.c (maybe_quit): Add reference to module_should_quit.
2017-06-04 19:50:52 +02:00
Philipp Stephani
d37201722e Use more specific errors for module load failure
* src/emacs-module.c (syms_of_module): Add more specific error
symbols.
(Fmodule_load): Use them.
2017-06-04 19:50:51 +02:00
Philipp Stephani
27445a82f0 Remove an unneeded assertion
* src/emacs-module.c (module_copy_string_contents): Remove unneeded
assertion.  If this assertion triggers, we raise an error anyway.
2017-06-04 19:50:51 +02:00
Philipp Stephani
a8a93b11cf Guard against signed integer overflows
* src/emacs-module.c (module_extract_integer)
(module_copy_string_contents, module_make_string): Guard against
signed integer overflows.
2017-06-04 19:50:51 +02:00
Philipp Stephani
549706241e Add a couple more assertions to the module code
These can help module authors debug crashes.

* emacs-module.c (module_non_local_exit_check)
(module_non_local_exit_clear, module_non_local_exit_get)
(module_non_local_exit_signal, module_non_local_exit_throw)
(module_copy_string_contents, module_make_string)
(funcall_module, initialize_environment): Add assertions
2017-06-04 19:50:51 +02:00
Philipp Stephani
fb3a9fd318 ; Grammar fix 2017-06-04 19:50:50 +02:00
Philipp Stephani
034275ebe8 ; Small comment fix
* emacs-module.c (MODULE_FUNCTION_BEGIN): Don't say that the error
value should be a sentinel value, because in almost all cases it
isn't.
2017-06-04 19:50:50 +02:00
Philipp Stephani
9be8b2bf1d Use ATTRIBUTE_MAY_ALIAS where alias violations are likely
In particular, alias violations are likely for the return values of
dlsym(3), which get cast around arbitrarily.

* src/emacs-module.c (Fmodule_load): Use ATTRIBUTE_MAY_ALIAS.
2017-06-04 19:50:50 +02:00
Philipp Stephani
366e25a6d1 Simplify interface of dynlib_attr.
Instead of returning bool, set the argument pointers to NULL if the
information is not available.

* src/dynlib.c (dynlib_addr): Don't return bool.
2017-06-04 19:50:50 +02:00
Philipp Stephani
045d21c20a Rationalize environment lifetime management functions
* src/emacs-module.c (Fmodule_load, funcall_module): Adapt callers.
(finalize_environment): Add parameter for public part of the
environment, like 'initialize_environment'.  Add assertions.
2017-06-04 19:50:50 +02:00
Philipp Stephani
3b0080de52 Rework printing of module functions
Fix a FIXME in emacs-module.c.  Put the printing into print.c, like
other types.

* src/print.c (print_vectorlike): Add code to print module functions.

* src/emacs-module.c (funcall_module): Stop calling
'module_format_fun_env'.  Now that module functions are first-class
objects, they can be added to signal data directly.
(module_handle_signal): Remove now-unused function
'module_format_fun_env'.

* test/src/emacs-module-tests.el (mod-test-sum-test): Adapt unit test.

* src/eval.c (funcall_lambda): Adapt call to changed signature of
'funcall_module'.
2017-06-04 19:50:49 +02:00
Philipp Stephani
18396997b3 Define helper macro to reduce code duplication
* src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH): New helper
macro.
(MODULE_FUNCTION_BEGIN, module_type_of, module_is_not_nil, module_eq):
Use it.
2017-06-04 19:50:49 +02:00
Philipp Stephani
db7438426a Remove two FIXMEs that can't be fixed 2017-06-04 19:50:49 +02:00
Paul Eggert
d5fcf9e458 Tune ‘format’ after recent fix
* doc/lispref/strings.texi (Formatting Strings):
* src/editfns.c (Fformat): Format field numbers no longer need
to be unique, reverting the previous doc change since that has
now been fixed.  Also, document that %% should not have modifiers.
* src/editfns.c (styled_format): Improve performance.  Remove
the need for the new prepass over the format string, by using
a typically-more-generous bound for the info array size.
Initialize the info array lazily.  Move string inspection to
the same area to help caching.  Avoid the need for a
converted_to_string bitfield by using EQ.  Cache arg in a
local and avoid some potential aliasing issues to help the
compiler.  Info array is now 0-origin, not 1-origin.
2017-06-04 08:42:53 -07:00
Philipp Stephani
e3b7eeade4 ; Fix off-by-one error 2017-06-03 11:42:07 +02:00
Philipp Stephani
7d413cb4da Fix a bug when using format field numbers
Previously styled_format overwrite the argument vector.  This is no
longer possible because there might be more than one specification per
argument.  Use the existing auxiliary info array instead.

* src/editfns.c (styled_format): Record arguments in the info
structure instead of overwriting them.
* test/src/editfns-tests.el (format-with-field): Add unit test.
2017-06-03 11:19:02 +02:00
Paul Eggert
0147cdd4d9 Document uniqueness limitation of ‘format’
* doc/lispref/strings.texi (Formatting Strings):
* src/editfns.c (Fformat):
Document that field numbers should be unique within a format.
2017-06-03 01:31:52 -07:00
Eli Zaretskii
5e6481bdc5 Fix cursor position in Dired buffers after dired-sort-toggle
* src/xdisp.c (display_and_set_cursor): Record cursor coordinates
even if the frame is marked as garbaged.  (Bug#27187)
2017-06-02 12:53:57 +03:00
Paul Eggert
8de2581a64 Limit format fields to more POSIX-like spec
* doc/lispref/strings.texi (Formatting Strings):
Don’t allow mixing numbered with unnumbered format specs.
* src/editfns.c (styled_format): Don’t bother checking for field 0,
since it doesn’t crash and the behavior is not specified.
* test/src/editfns-tests.el (format-with-field): Adjust tests to
match current doc.  Add more tests for out-of-range fields.
2017-06-01 16:06:38 -07:00
Paul Eggert
178d0cb5f5 Improve performance by avoiding strtoumax
This made (string-to-number "10") 20% faster on my old desktop,
an AMD Phenom II X4 910e running Fedora 25 x86-64.
* admin/merge-gnulib (GNULIB_MODULES): Remove strtoumax.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/strtoul.c, lib/strtoull.c, lib/strtoumax.c, m4/strtoull.m4:
* m4/strtoumax.m4: Remove.
* src/editfns.c (str2num): New function.
(styled_format): Use it instead of strtoumax.  Use ptrdiff_t
instead of uintmax_t.  Check for integer overflow.
* src/lread.c (LEAD_INT, DOT_CHAR, TRAIL_INT, E_EXP):
Move to private scope and make them enums.
(string_to_number): Compute integer value directly during
first pass instead of revisiting it with strtoumax later.
2017-06-01 16:06:38 -07:00
Paul Eggert
5324710841 Minor improvements to format field numbers
* src/editfns.c (styled_format): Allow field numbers in a %% spec.
No need for a special diagnostic for field numbers greater than
PTRDIFF_MAX.  Reword diagnostic for field 0.
* test/src/editfns-tests.el (format-with-field): Adjust to match.
2017-06-02 00:25:48 +02:00
Philipp Stephani
0dd1bbb0bb Implement field numbers in format strings
A field number explicitly specifies the argument to be formatted.
This is especially important for potential localization work, since
grammars of various languages dictate different word orders.

* src/editfns.c (Fformat): Update documentation.
(styled_format): Implement field numbers.

* doc/lispref/strings.texi (Formatting Strings): Document field numbers.

* lisp/emacs-lisp/bytecomp.el (byte-compile-format-warn): Adapt.

* test/src/editfns-tests.el (format-with-field): New unit test.
2017-06-02 00:22:13 +02:00
Alan Third
6cd374085c Fix build errors on macOS 10.6 (bug#27059)
* src/nsfns.m (compute_tip_xy): Don't use CGRectContainsPoint.
2017-06-01 20:50:44 +01:00
Vasilij Schneidermann
cb9aa3515a Add customizable to display raw bytes as hex
* src/xdisp.c (get_next_display_element): Dispatch used format string
for unprintables based on new display-raw-bytes-as-hex variable.
(display-raw-bytes-as-hex): New variable.  (Bug#27122)

* lisp/cus-start.el: Add defcustom form for display-raw-bytes-as-hex.

* doc/emacs/display.texi: Document the new variable.
* etc/NEWS: Mention display-raw-bytes-as-hex.

* test/manual/redisplay-testsuite.el (test-redisplay-5-toggle)
(test-redisplay-5): New tests.
(test-redisplay): Call test-redisplay-5.
2017-06-01 21:25:58 +03:00
Eli Zaretskii
e5de79992a Revert "Add customizable to display raw bytes as hex"
This reverts commit 7c9ac111c5.
2017-06-01 21:24:15 +03:00
Eli Zaretskii
7c9ac111c5 Add customizable to display raw bytes as hex
* src/xdisp.c (get_next_display_element): Dispatch used format string
for unprintables based on new display-raw-bytes-as-hex variable.
(display-raw-bytes-as-hex): New variable.  (Bug#27122)

* lisp/cus-start.el: Add defcustom form for display-raw-bytes-as-hex.

* doc/emacs/display.texi: Document the new variable.
* etc/NEWS: Mention display-raw-bytes-as-hex.

* test/manual/redisplay-testsuite.el (test-redisplay-5-toggle)
(test-redisplay-5): New tests.
(test-redisplay): Call test-redisplay-5.
2017-06-01 21:12:39 +03:00
Glenn Morris
6aacd4fb09 Use true names for invocation- and source-directory
* src/emacs.c (init_cmdargs) <Vinvocation_directory>:
* src/lread.c (init_lread) <Vsource_directory>: Use true names.
2017-05-31 21:13:40 -04:00
Paul Eggert
32fd876809 Fix bug with "%%" in error format
* src/doprnt.c (doprnt): Format "%%" correctly.
Problem reported by Philipp Stephani in:
http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00901.html
2017-05-31 16:50:24 -07:00
Paul Eggert
9c748b27c0 * src/editfns.c (Fmessage): Improve doc string (Bug#23425#130). 2017-05-31 16:23:47 -07:00
Eli Zaretskii
140ddc321b Support lower bound on hscrolling when only current line scrolls
* doc/emacs/display.texi (Horizontal Scrolling): Document the new
mode of auto-hscrolling only the current line.

* src/xdisp.c (init_iterator): When hscrolling only the
current line, apply the	window's min_hscroll here, so that
non-current lines will be hscrolled by that minimum.
Suggested by Stephen Berman <stephen.berman@gmx.net>.
(hscroll_window_tree): Account for window's min_hscroll when
deciding whether to recompute the hscroll.
(display_line): Subtract window's min_hscroll from x_incr, as that
was already accounted for in init_iterator.  (Bug#27008)
2017-05-31 19:01:31 +03:00
Eli Zaretskii
7b4a0e2884 Avoid inflooping in redisplay due to Spacemacs and linum-mode
* src/xdisp.c (redisplay_internal): Limit the number of redisplay
retries when a frame becomes garbaged as result of redisplaying
it.  (Bug#27115)
2017-05-31 12:05:06 +03:00
Tino Calancha
a20c799653 * src/editfns.c (decode-time): Fix docstring. 2017-05-31 10:15:20 +09:00
Alan Mackenzie
f8f58fe37e Mode line "%q" construct: Just use one number when both would be the same.
* src/xdisp (decode_mode_spec): recode the "%q" bit appropriately.
2017-05-30 17:42:52 +00:00
Noam Postavsky
75b8492946 Rename '--new-daemon' to 'fg-daemon' and '--old-daemon' to '--bg-daemon'
* doc/emacs/cmdargs.texi (Initial Options):
* doc/lispref/os.texi (Startup Summary):
* etc/NEWS:
* etc/emacs.service:
* src/emacs.c (main):
* src/lisp.h: Rename '--new-daemon' to 'fg-daemon' and '--old-daemon' to
'--bg-daemon'.
2017-05-29 22:18:55 -04:00
Paul Eggert
2a22a65fe1 Improve .gdbinit Lisp value pretty-printing
* src/.gdbinit (to_string): Use an unsigned representation for
Lisp values, as requested by Eli Zaretskii (Bug#27098).
Also, use "make_number(N)" for Lisp integers.
2017-05-29 17:15:38 -07:00
Alan Third
c503188f80 Fix build error on macOS 10.6
* src/nsfns.m (compute_tip_xy): Cast NSRect to CGRect and NSPoint to
CGPoint.
2017-05-29 17:03:30 +01:00
Paul Eggert
d387305062 Depromiscuify inotify with IN_MASK_ADD
Use IN_MASK_ADD instead of using a no-longer-promiscuous-enough
mask.  This simplifies the code and restores the ability to
use IN_ACCESS, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE, and IN_OPEN
in some cases (Bug#26973).
* src/inotify.c (INOTIFY_DEFAULT_MASK): Remove.
(Finotify_add_watch): Use IN_MASK_ADD instead.
2017-05-27 11:14:30 -07:00
Paul Eggert
ad656a726f Restore inotify onlydir support
There was no need to remove it in the 2017-03-26 inotify change,
as it is like IN_DONT_FOLLOW and does not affect other watchers
for the same file.
* src/inotify.c (symbol_to_inotifymask, Finotify_add_watch)
(syms_of_inotify): Bring back onlydir.
2017-05-27 11:14:30 -07:00
Paul Eggert
8f59ff2461 Simplify computation of inotify mask
* src/inotify.c (add_watch): Accept uint32_t imask instead
of Lisp_Object aspect.  Caller changed.
(Finotify_add_watch): Use aspect_to_inotifymask earlier, to
simplify the code.
2017-05-27 11:14:30 -07:00
Philipp Stephani
a3a3ea0762 Avoid another compiler warning on macOS
When configured with --without-ns, HAVE_NS is not defined on macOS,
thus 'memory-limit' calls the deprecated sbrk(2) function.  Avoid that
by using the pre-defined __APPLE__ preprocessor macro.

* src/alloc.c (Fmemory_limit): Never use sbrk(2) on macOS.
2017-05-27 15:29:46 +02:00
Martin Rudalics
704fea97e4 Minor doc and doc-string fixes (Bug#27091)
* src/window.c (Fset_window_scroll_bars): Fix doc-string.

* doc/lispref/display.texi (Fringe Size/Pos, Scroll Bars)
(Display Margins): Mention that `set-window-buffer' may override
settings made by `set-window-fringes', `set-window-scroll-bars'
and `set-window-margins'.
* doc/lispref/windows.texi (Buffers and Windows): Fix doc of
`set-window-buffer'.
2017-05-27 15:14:52 +02:00
Eli Zaretskii
3fc36f427a Avoid args-out-of-range errors on fringe clicks after "C-h k"
* src/keyboard.c (echo_truncate): Don't call Ftruncate if the echo
message is already shorter than NCHARS.  (Bug#27040)
2017-05-27 15:57:38 +03:00
Alan Third
0d676deba4 Check if instancetype supported in ObjC
* configure.ac: Add check for instancetype.
* src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
2017-05-27 00:46:23 +01:00
Paul Eggert
4681fbac90 * src/inotify.c: Add FIXME comments. 2017-05-26 10:53:35 -07:00
Andreas Politz
d02e8ab6d6 Fix Bug#26973
* src/inotify.c (INOTIFY_DEFAULT_MASK): Removing ACCESS, OPEN
and CLOSE events on order do let other processes also reading
from their descriptors.  (Bug#26973).
2017-05-26 16:42:43 +02:00
Alan Third
2ea4b84f5e Fix NS tooltips showing in the wrong place (bug#27053)
* src/nsfns.m (compute_tip_xy): Get current mouse position instead of
last recorded position.
2017-05-25 21:50:49 +01:00
Paul Eggert
d7284da858 Port ATTRIBUTE_MAY_ALIAS to recent icc
* src/conf_post.h (ATTRIBUTE_MAY_ALIAS) [__ICC]:
Define to empty.  Otherwise, icc (ICC) 17.0.4 20170411 says
“warning #2621: attribute "__may_alias__" does not apply here”
for constructs like ‘struct sockaddr *sa = (whatever);
struct sockaddr_in __attribute__ ((__may_alias__)) *sin
= (struct sockaddr_in *) sa;’.
2017-05-25 00:25:09 -07:00
Alan Third
ad8b60ee74 Raise version of macOS we define instancetype for (bug#27059)
* src/nsterm.m: Increase supported version number.
2017-05-24 20:18:52 +01:00