* 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.
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'.
* 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.
Paul Eggert [Sun, 4 Jun 2017 15:39:37 +0000 (08:39 -0700)]
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.
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.
Glenn Morris [Sat, 3 Jun 2017 00:06:12 +0000 (20:06 -0400)]
Add watch for password back to inferior python comint filter
It was removed along with other items for speed (bug#16875),
but doesn't seem to have been causing an issue, and it's useful to
have it there (bug#27154).
* lisp/progmodes/python.el (inferior-python-mode):
Add comint-watch-for-password-prompt to comint-output-filter-functions.
Ryan [Sat, 3 Jun 2017 00:00:49 +0000 (20:00 -0400)]
Use completing-read-default in tmm-prompt
tmm uses completing-read, but customizes its behavior so much
that any alternative completing-read-function will almost
certainly break it. For example, both ido-ubiquitous and ivy have
special code to deactivate themselves for tmm.
* lisp/tmm.el (tmm-prompt): Use completing-read-default instead of
completing-read. (Bug#27193)
Paul Eggert [Thu, 1 Jun 2017 23:03:12 +0000 (16:03 -0700)]
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.
Paul Eggert [Thu, 1 Jun 2017 23:03:12 +0000 (16:03 -0700)]
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.
Paul Eggert [Thu, 1 Jun 2017 05:09:39 +0000 (22:09 -0700)]
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.
Philipp Stephani [Wed, 31 May 2017 22:09:43 +0000 (00:09 +0200)]
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.
Limit scope of local overriding-terminal-local-map
The function `binding' may call isearch-done, which globally sets
overriding-terminal-local-map to nil (Bug#23007).
* lisp/isearch.el (isearch-mouse-2): Don't bind
overriding-terminal-local-map around the call to `binding'.
Stephen Berman [Thu, 1 Jun 2017 20:15:50 +0000 (22:15 +0200)]
Correct and isolate the todo-mode test environment
This avoids having to set todo-mode variables globally in the test
file and prevents any exisiting user todo-mode files from influencing
the tests.
* test/lisp/calendar/todo-mode-tests.el:
(with-todo-test): New macro.
(todo-test-todo-quit01, todo-test-todo-quit02)
(todo-test-item-highlighting): Use it.
* 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.
Eli Zaretskii [Thu, 1 Jun 2017 18:12:39 +0000 (21:12 +0300)]
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.
Eli Zaretskii [Thu, 1 Jun 2017 14:55:25 +0000 (17:55 +0300)]
Fix linum under text-scaling when leuven-theme is used
* etc/themes/leuven-theme.el (linum): Make the 'linum' face
inherit from 'default' and 'shadow', so that margins are enlarged
as expected under text-scaling.
Fix memory leak of cwd string in emacsclient (Bug#26628)
* lib-src/emacsclient.c (main): emacsclient retrieves the current
working directory using get_current_dir_name which returns a newly
allocated string. Make sure this string is freed before exiting.
Paul Eggert [Wed, 31 May 2017 23:50:08 +0000 (16:50 -0700)]
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
Eli Zaretskii [Wed, 31 May 2017 16:01:31 +0000 (19:01 +0300)]
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)
Noam Postavsky [Sun, 28 May 2017 21:01:05 +0000 (17:01 -0400)]
cl-print: handle circular objects when `print-circle' is nil (Bug#27117)
* lisp/emacs-lisp/cl-print.el (cl-print--currently-printing): New variable.
(cl-print-object): When `print-circle' is nil, bind it to a list of
objects that are currently printing to avoid printing the same object
endlessly.
* test/lisp/emacs-lisp/cl-print-tests.el (cl-print-circle): New test.
Noam Postavsky [Wed, 31 May 2017 03:31:18 +0000 (23:31 -0400)]
Further simplify test/Makefile, optionally load elc tests
* test/Makefile.in: Use make's error ignoring feature instead of
suppressing test errors with shell. Compile test files in the main
make invocation instead of a recursive 'make' call. Optionally load
.elc test files if TEST_LOAD_EL is set to something other than 'yes'.
Remove obsolete commentary.
Glenn Morris [Wed, 31 May 2017 01:01:56 +0000 (21:01 -0400)]
Avoid subr test failure when source dir has multiple names
* test/lisp/subr-tests.el (subr-tests--this-file):
Use the true name of the file. The following test does a string
comparison of this value with that from method-files, which uses
load-history, which contains true names.
Dmitry Gutov [Tue, 30 May 2017 22:29:34 +0000 (01:29 +0300)]
Extract eldoc--supported-p
* lisp/emacs-lisp/eldoc.el (eldoc--supported-p): New function.
(turn-on-eldoc-mode, eldoc-mode): Use it.
(http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00865.html)
Paul Eggert [Tue, 30 May 2017 16:27:33 +0000 (09:27 -0700)]
Skip .#* temporaries when finding sources
Without this patch, ‘make check’ can fail with the diagnostic
‘invalid syntax in conditional’ if there is an Emacs temporary
file whose name starts with ‘.#’, because the ‘#’ is treated as
the start of a Make comment.
* lisp/Makefile.in (loaddefs, tagsfiles, check-defun-deps):
* test/Makefile.in (ELFILES):
Skip files starting with ‘.’, so that the .#* files do not cause
trouble. (We cannot easily skip just files starting with ‘.#’,
since ‘#’ starts a Make comment!)
Alan Mackenzie [Tue, 30 May 2017 16:21:31 +0000 (16:21 +0000)]
Fix the mouse help/key map on the "%p" part of the mode line.
* lisp/bindings.el (mode-line-percent-position): give it a
`risky-local-variable' property.
(mode-line-position): correct the quoting on the mode-line-percent-position
part of the variable, allowing the properties to be properly recognized.
Alan Mackenzie [Tue, 30 May 2017 16:21:31 +0000 (16:21 +0000)]
Fix the mouse help/key map on the "%p" part of the mode line.
* lisp/bindings.el (mode-line-percent-position): give it a
`risky-local-variable' property.
(mode-line-position): correct the quoting on the mode-line-percent-position
part of the variable, allowing the properties to be properly recognized.
Paul Eggert [Tue, 30 May 2017 00:15:11 +0000 (17:15 -0700)]
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.
Dmitry Gutov [Mon, 29 May 2017 23:55:28 +0000 (02:55 +0300)]
Turn global-eldoc-mode into a globalized minor mode
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode):
Turn into globalized mode (bug#19853).
(turn-on-eldoc-mode): Make it into a wrapper instead of alias.
(eldoc-mode): Only show the message when called interactively.
Stephen Berman [Mon, 29 May 2017 21:49:41 +0000 (23:49 +0200)]
Add initial tests for todo-mode.el
*test/lisp/calendar/todo-mode-tests.el:
*test/lisp/calendar/todo-mode-resources/todo-test-1.toda:
*test/lisp/calendar/todo-mode-resources/todo-test-1.todo: New files.
* .gitattributes: Ignore trailing whitespace in todo-mode test
data files, since it is part of the todo-mode file format.
Stephen Berman [Mon, 29 May 2017 18:26:49 +0000 (20:26 +0200)]
Make `todo-toggle-item-highlighting' work on multiline items (bug#27133)
* lisp/calendar/todo-mode.el (todo-hl-line-range): New named function,
replacing an anonymous function for the sake of `describe-variable'.
(todo-modes-set-2): Use it as buffer-local value of hl-line-range-function
and remove boundp test of this variable, so its value is available on
invoking `todo-toggle-item-highlighting'.
Noam Postavsky [Mon, 22 May 2017 16:36:20 +0000 (12:36 -0400)]
; Fix backslashes in python-tests
* test/lisp/progmodes/python-tests.el (python-indent-after-backslash-1)
(python-indent-after-backslash-2)
(python-indent-after-backslash-3)
(python-indent-after-backslash-4)
(python-indent-after-backslash-5)
(python-nav-beginning-of-statement-1)
(python-nav-end-of-statement-1)
(python-nav-forward-statement-1)
(python-nav-backward-statement-1)
(python-nav-backward-statement-2)
(python-info-statement-starts-block-p-2)
(python-info-statement-ends-block-p-2)
(python-info-beginning-of-statement-p-2)
(python-info-end-of-statement-p-2)
(python-info-beginning-of-block-p-2)
(python-info-end-of-block-p-2)
(python-info-line-ends-backslash-p-1)
(python-info-beginning-of-backslash-1)
(python-info-continuation-line-p-1)
(python-info-block-continuation-line-p-1)
(python-info-assignment-statement-p-1)
(python-info-assignment-continuation-line-p-1): Backslashes in
literals should be doubled only once to produce one backslash in the
buffer. If there backslashes inside a Python string literal in a Lisp
literal, that would need to be doubled twice, but there are no such
cases. Note that `python-tests-looking-at' takes a plain string, not
a regexp.
Jules Tamagnan [Thu, 27 Oct 2016 22:03:31 +0000 (15:03 -0700)]
Comply with pep 8 style guide for backslash in assignment (Bug#24809)
* lisp/progmodes/python.el (python-indent--calculate-indentation):
Increase indent by `python-indent-offset' after
`:after-backslash-assignment-continuation'.
Wilfred Hughes [Mon, 29 May 2017 00:00:05 +0000 (01:00 +0100)]
Ensure button-get works in any buffer
* lisp/button.el (button-get): Previously we assumed that button-get
was called in the buffer containing the button. In other buffers,
button-get always returned nil. Fix this by passing the relevant
buffer from the marker.
Dmitry Gutov [Sun, 28 May 2017 23:55:42 +0000 (02:55 +0300)]
Signal error if find-grep returns a nonzero status
* lisp/progmodes/xref.el (xref-collect-matches): Signal error
if find-grep returns a nonzero status (bug#23451). Remove the
comment: even if some output is present, a non-zero status
means something went wrong and it can't be relied upon.
Stephen Berman [Sun, 28 May 2017 20:52:05 +0000 (22:52 +0200)]
Make sure exiting todo-mode buffer buries it (bug#27121)
This failed due to commit ea3ae33b from 2013-05-16, which prevented
quitting todo-mode buffer after visiting todo-archive buffer from
making the archive buffer current again. Avoid this now by simply
killing the archive buffer, since there's no need to keep it a live
buffer. Consequently, quitting a todo-mode buffer can now use
bury-buffer without an argument, which ensures that is will not
becomes current on quitting the buffer that replaced it in the window.
* lisp/calendar/todo-mode.el (todo-quit): Kill todo-archive-mode
buffer instead of burying it. This now allows exiting the
todo-mode buffer by bury-buffer without an argument, so do that.
Michael Albinus [Sun, 28 May 2017 21:44:10 +0000 (23:44 +0200)]
Some tweaks, almost all for Tramp adb method
* lisp/net/tramp-adb.el (tramp-adb-parse-device-names):
Use `make-tramp-file-name'.
(tramp-adb-get-device): Use `tramp-file-name-port-or-default'.
(tramp-adb-maybe-open-connection): Set "prompt" property.
(tramp-adb-wait-for-output): Use it.
* lisp/net/tramp-cache.el (tramp-cache-print): Use `elt'.
(tramp-dump-connection-properties): Check also that there are
properties to be saved. Don't save "started" property of
"ftp" method.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name):
Use `make-tramp-file-name'.
* lisp/net/tramp.el (tramp-remote-file-name-spec-regexp):
Host could be empty.
(tramp-file-name-port-or-default): New defun.
(tramp-dissect-file-name): Simplify `make-tramp-file-name' call.
(tramp-handle-file-name-case-insensitive-p): Use a progress reporter.
(tramp-call-process, tramp-call-process-region):
Use `make-tramp-file-name'.
* test/lisp/net/tramp-tests.el (tramp-test03-file-name-defaults):
Revert change from 2017-05-24.
(tramp-test05-expand-file-name-relative): Let it also pass for
"adb" method.
Jürgen Hötzel [Sun, 28 May 2017 11:06:53 +0000 (13:06 +0200)]
Fix Tramp for Android 7
* tramp-adb.el (tramp-adb-ls-toolbox-regexp):
Username part of prompt is empty on Android 7.
(tramp-adb-ls-toolbox-regexp):
Ignore addition links column on Android 7.
(tramp-adb-get-ls-command):
Dont use --color=none when using toybox (Android 7). It's not
possible to disable coloring explicitly for toybox ls.
Paul Eggert [Sat, 27 May 2017 17:54:25 +0000 (10:54 -0700)]
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.
Paul Eggert [Sat, 27 May 2017 17:54:25 +0000 (10:54 -0700)]
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.
Paul Eggert [Sat, 27 May 2017 17:54:25 +0000 (10:54 -0700)]
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.
Philipp Stephani [Sat, 27 May 2017 12:39:01 +0000 (14:39 +0200)]
Don't attempt to recover from undefined behavior in some cases
These functions can only be run in batch mode and exit Emacs on
return, so nothing can be recovered. Disable unsafe recover
mechanisms so that we get real failures and good stack traces on
fatal signals.
* lisp/emacs-lisp/bytecomp.el (batch-byte-compile)
(batch-byte-recompile-directory):
* lisp/emacs-lisp/ert.el (ert-run-tests-batch-and-exit)
(ert-summarize-tests-batch-and-exit): Don't attempt to recover
from undefined behavior.
Philipp Stephani [Sat, 27 May 2017 13:26:49 +0000 (15:26 +0200)]
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.