João Távora [Tue, 19 Jun 2018 01:18:43 +0000 (02:18 +0100)]
Electric-pair-mode lets modes choose how to skip whitespace
cc-mode.el-based major-modes with stricter syntax for invalid
NL-terminated strings might choose to have electric-pair-mode skip
some of whitespace into non-string-syntax regions, for the sake of
letting electric-pair-mode chomp that whitespace and make the string
valid again.
* lisp/elec-pair.el (electric-pair-post-self-insert-function): Call it.
(electric-pair-skip-whitespace-function): New buffer-local variable.
Noam Postavsky [Tue, 12 Jun 2018 00:41:07 +0000 (20:41 -0400)]
Stop assuming .git is a directory in gitmerge.el
* admin/gitmerge.el (gitmerge-maybe-resume): Use 'git rev-parse
--git-dir' to find the git directory rather than assuming it is
.git/ (that assumption fails for separated worktrees).
Move tls.el and starttls.el to lisp/obsolete/ (Bug#31457)
* lisp/obsolete/tls.el: Moved from lisp/net/tls.el.
* lisp/gnus/nnimap.el:
* lisp/url/url-http.el: Don't require tls, since it's obsolete.
* lisp/net/network-stream.el: Only require tls if we actually try to
use it (i.e., when (gnutls-available-p) returns nil). Declare some
functions to fix compilation warnings.
* lisp/obsolete/starttls.el: Moved from lisp/net/starttls.el.
* lisp/net/sieve-manage.el:
* lisp/net/network-stream.el: Don't require `starttls' at the
top-level, declare the variables and functions used instead.
(network-stream-open-starttls): Only require `starttls' if
needed (i.e., gnutls-available-p fails).
Glenn Morris [Mon, 18 Jun 2018 19:14:25 +0000 (12:14 -0700)]
Merge from origin/emacs-26
63ba73a Fix documentation of ':propertize' in mode-line-format 22aa665 Reject invalid 5-byte sequences when detecting UTF-8 encoding 0d3c358 Fix 'replace-buffer-contents' in multibyte buffers c79a627 Update etc/NEWS for mail-source-movemail-program change 63f1dc4 Improve movemail default 0b1a2ae Delete description of deleted Customize functions fcd66d0 Keep vc-print-log from putting point at buffer end (Bug#31764)
* doc/emacs/misc.texi (Shell Ring): Fix a typo in the name of
'comint-insert-previous-argument'. Document
'comint-insert-previous-argument-from-end'. (Bug#25271)
* etc/NEWS: Reformat and rephrase the entry for recent Comint
changes.
Dima Kogan [Sun, 25 Dec 2016 19:49:44 +0000 (11:49 -0800)]
comint-insert-previous-argument doesn't detect and ignore trailing &
This function is invoked in shell-mode by the user, and is meant to
emulate what M-. does in zsh and bash: it inserts an argument from a
previous command. Neither zsh nor bash treat a trailing & specially:
M-. simply inserts it if it is encountered. Emacs DID have extra
logic to detect and discard trailing &, but this logic was buggy, and
a && anywhere in the sequence would confuse it. This patch simply
removes that logic to fix the bug and to emulate zsh and bash more
closely
Dima Kogan [Sun, 25 Dec 2016 19:35:26 +0000 (11:35 -0800)]
comint-insert-previous-argument counts args from start or from end
This function is invoked in shell-mode by the user, and is meant to
emulate what M-. does in zsh and bash: it inserts an argument from a
previous command. Without a prefix argument, it inserts the last arg
from the previous command; with an argument INDEX, it inserts the
INDEX-th argument. bash counts from the start, while zsh counts from
the end. This patch adds a variable
`comint-insert-previous-argument-from-end' that emulates the zsh
behavior if non-nil.
* lisp/comint.el (comint-arguments): can take in negative arguments to count
from the end, same as indexing in python.
(comint-insert-previous-argument): if
comint-insert-previous-argument-from-end is non-nil, INDEX counts
arguments from the end; if nil, from the beginning
(Bug#25271)
* etc/NEWS: Document this.
* lisp/emacs-lisp/pcase.el (\`): Extend semantics of QPATS to all
numbers. Add a comment explaining why we disallow some atoms as
QPATS.
* doc/lispref/control.texi (Backquote Patterns): Update the paragraph
explaining QPATS. Remove a sentence suggesting an analogy between
QPATS to self-quoting objects.
Aaron Jensen [Thu, 24 May 2018 10:45:03 +0000 (03:45 -0700)]
Prevent errant scroll on mouse click (Bug#31546)
* src/nsterm.m (ns_mouse_position): Use correct frame when determining
mouse position.
* lisp/mouse.el (mouse-drag-track): Only account for mode-line height
if `mode-line-format' is non-nil.
Tino Calancha [Sun, 17 Jun 2018 09:28:34 +0000 (18:28 +0900)]
Add new macro dolist-with-progress-reporter
* lisp/subr.el (dolist-with-progress-reporter): New macro (Bug#31697).
* lisp/cus-edit.el (custom-group-value-create): Use it.
* lisp/dabbrev.el (dabbrev--progress-reporter): Delete variable.
(dabbrev--find-expansion): Use dotimes-with-progress-reporter.
* doc/lispref/display.texi: Document the macro.
; * etc/NEWS: Announce it.
* lisp/subr.el (dotimes-with-progress-reporter): Allow 2nd arg to be
a string or a progress reporter (Bug#31696).
* doc/lispref/display.texi (node Progress): Update manual.
Theme settings now generally aren't actually applied until a call to
`enable-theme-, either one made explicitly or implicitly through
`load-theme' with NO-ENABLE nil. This change has the effect of not
applying theme changes just because we load a lisp file containing a
theme specification. The previous behavior is preserved for the
special case of the `user' theme, which is frequently used for
ad-hoc customization.
* lisp/cus-face.el (custom-theme-set-faces): Call
`custom--should-apply-setting' to decide whether to apply
a setting.
* lisp/custom.el (custom--should-apply-setting): New function.
(custom--inhibit-theme-enable): Add `apply-only-user' option;
default to it.
(custom-push-theme, custom-theme-set-variables): Call
`custom--should-apply-setting' to decide whether to apply
a setting.
Noam Postavsky [Thu, 7 Jun 2018 23:58:47 +0000 (19:58 -0400)]
Don't forget to analyze args of lambda lifted functions (Bug#30872)
* lisp/emacs-lisp/cconv.el (cconv--convert-funcbody): New function.
(cconv--convert-function): Extracted from here.
(cconv-convert): Also use it here, in the lambda lifted case, so that
mutated args are properly accounted for.
* test/lisp/emacs-lisp/cconv-tests.el: New test.
Noam Postavsky [Sat, 2 Jun 2018 20:22:17 +0000 (16:22 -0400)]
Fix off by one error in python-mode assertion (Bug#30964)
* lisp/progmodes/python.el (python-nav-end-of-statement): Don't assert
that string-start is strictly greater than last-string-end, because
the string end is a position outside of the string and may therefore
be the same as the following string's start.
* test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-2):
New test.
Make regex matching reentrant; update syntax during match
* src/lisp.h (compile_pattern): Remove prototype of
now-internal function.
* src/regex.c (POS_AS_IN_BUFFER): Consult gl_state instead of
re_match_object: the latter can change in Lisp.
(re_match_2_internal): Switch back to UPDATE_SYNTAX_* FROM
UPDATE_SYNTAX_FAST*, allowing calls into Lisp.
* src/search.c (struct regexp_cache): Add `busy' field.
(thaw_buffer_relocation): Delete; rely on unbind.
(compile_pattern_1): Assert pattern isn't busy.
(shrink_regexp_cache): Don't shrink busy patterns.
(clear_regexp_cache): Don't nuke busy patterns.
(unfreeze_pattern, freeze_pattern): New functions.
(compile_pattern): Return a regexp_cache pointer instead of the
re_pattern_buffer, allowing callers to use `freeze_pattern' if
needed. Do not consider busy patterns as cache hit candidates;
error if we run out of non-busy cache entries.
(looking_at_1, fast_looking_at): Snapshot
Vinhibit_changing_match_data; mark pattern busy while we're
matching it; unbind.
(string_match_1, fast_string_match_internal)
(fast_c_string_match_ignore_case): Adjust for compile_pattern
return type.
(search_buffer_re): Regex code from old search_buffer moved here;
snapshot Vinhibit_changing_match_data; mark pattern busy while
we're matching it; unbind.
(search_buffer_non_re): Non-regex code from old search_buffer
moved here.
(search_buffer): Split into search_buffer_re,
search_buffer_non_re.
(syms_of_search): Staticpro re_match_object, even though we really
shouldn't have to.
Paul Eggert [Sat, 16 Jun 2018 14:44:58 +0000 (07:44 -0700)]
Fix byte compilation of (eq foo 'default)
Backport from master.
Do not use the symbol ‘default’ as a special marker.
Instead, use a value that cannot appear in the program,
improving on a patch proposed by Robert Cochran (Bug#31718#14).
* lisp/emacs-lisp/bytecomp.el (byte-compile--default-val):
New constant.
(byte-compile-cond-jump-table-info)
(byte-compile-cond-jump-table): Use it instead of 'default.
* test/lisp/emacs-lisp/bytecomp-tests.el:
(byte-opt-testsuite-arith-data): Add a test for the bug.
Paul Eggert [Sat, 16 Jun 2018 15:11:37 +0000 (08:11 -0700)]
Rewrite memory-limit in Lisp
Have it return Emacs virtual memory size, not the sbrk value
which is often useless newadays.
* doc/lispref/internals.texi (Garbage Collection):
* etc/NEWS: Document this.
* lisp/subr.el (memory-limit): New implementation in Lisp,
written in terms of process-attributes, and which returns
virtual memory size.
* src/alloc.c (Fmemory_limit): Remove C implementation.
Paul Eggert [Sat, 16 Jun 2018 14:44:58 +0000 (07:44 -0700)]
Fix byte compilation of (eq foo 'default)
Do not use the symbol ‘default’ as a special marker.
Instead, use a value that cannot appear in the program,
improving on a patch proposed by Robert Cochran (Bug#31718#14).
* lisp/emacs-lisp/bytecomp.el (byte-compile--default-val):
New constant.
(byte-compile-cond-jump-table-info)
(byte-compile-cond-jump-table): Use it instead of 'default.
* test/lisp/emacs-lisp/bytecomp-tests.el:
(byte-opt-testsuite-arith-data): Add a test for the bug.
Eli Zaretskii [Sat, 16 Jun 2018 10:10:52 +0000 (13:10 +0300)]
Improve documentation of several recent changes
* src/xfaces.c (merge_face_ref): Fix a typo in the commentary.
(evaluate_face_filter, filter_face_ref): Minor copyedits in
the commentary.
* doc/lispref/display.texi (Face Remapping):
* doc/lispref/text.texi (Special Properties): Document the
':filter' face specs and their effects. Document
'face-filters-always-match'.
* doc/emacs/files.texi (Visiting): Document the new
possibility to visit large files literally in response to
question asked by Emacs.
* etc/NEWS: Mention the new possibility to visit large files
literally.
* lisp/files.el (files--ask-user-about-large-file): Use
"literally" instead of "raw", for consistency with
find-file-literally.
* doc/lispref/frames.texi (Input Focus): Tell explicitly that
focus-change events are sometimes supported on TTY frames.
Eli Zaretskii [Sat, 16 Jun 2018 08:25:01 +0000 (11:25 +0300)]
Prevent QUIT to top level inside 'while-no-input'
* lisp/subr.el (while-no-input): Handle the case when BODY
never tests quit-flag, and runs to completion even though
input arrives while BODY executes. (Bug#31692)
Paul Eggert [Fri, 15 Jun 2018 22:51:39 +0000 (15:51 -0700)]
Minor CANNOT_DUMP cleanups
Mostly, this avoids munging executables when CANNOT_DUMP = yes,
as the munging is needed only for unexec.
* configure.ac (PAXCTL_dumped, PAXCTL_notdumped) [CANNOT_DUMP]:
Leave these empty.
(LD_SWITCH_SYSTEM_TEMACS) [CANNOT_DUMP]:
Do not append -no-pie or -nopie.
* src/alloc.c (my_heap_start) [CANNOT_DUMP]: Omit; not used.
Paul Eggert [Fri, 15 Jun 2018 21:37:39 +0000 (14:37 -0700)]
Remove old combreloc hack
It has not been needed for many years and gets in the way of
portable dumping, address sanitization, etc. See:
https://lists.gnu.org/r/emacs-devel/2016-12/msg00147.html
* configure.ac (LDFLAGS_NOCOMBRELOC, emacs_cv_znocombreloc):
Remove. All uses removed.
* etc/PROBLEMS: Remove discussion of combreloc problems.
Paul Eggert [Fri, 15 Jun 2018 16:06:13 +0000 (09:06 -0700)]
Restore macfont.m casts to void *
* src/macfont.m (macfont_set_family_cache): Restore casts
to void * that were mistakenly removed in my recent change.
The types in question are pointer-to-const. Problem
reported by Clemens Schüller.
Eli Zaretskii [Fri, 15 Jun 2018 14:45:27 +0000 (17:45 +0300)]
Fix building --without-x and similar
* src/keyboard.c (make_lispy_focus_out): Compile it
unconditionally, as it is now supported on TTYs as well.
Reported by Filipp Gunbin <fgunbin@fastmail.fm>.
Eli Zaretskii [Fri, 15 Jun 2018 14:39:34 +0000 (17:39 +0300)]
Reject invalid 5-byte sequences when detecting UTF-8 encoding
* src/coding.c (detect_coding_utf_8): Reject multibyte sequences
whose leading byte is greater than MAX_MULTIBYTE_LEADING_CODE.
(Bug#31829)
* src/character.h (MAX_MULTIBYTE_LEADING_CODE): Add commentary
about the connection between the value of this macro and MAX_CHAR.
Robert Pluim [Fri, 15 Jun 2018 07:40:53 +0000 (00:40 -0700)]
Improve movemail default
* lisp/gnus/mail-source.el (mail-source-movemail-program):
Change default to "movemail".
(mail-source-movemail): Pass just mail-source-movemail-program to
call-process instead of fully specifying it relative to
exec-directory. Ensures that we will find Mailutils movemail if
it is installed. (Bug#31737)
Eli Zaretskii [Fri, 15 Jun 2018 07:32:45 +0000 (10:32 +0300)]
Delete description of deleted Customize functions
* doc/lispref/customize.texi (Variable Definitions): Remove the
description of 'custom-initialize-safe-set' and
'custom-initialize-safe-default', which were deleted in Emacs
23.2, and replace with the description of
'custom-initialize-delay'.
Paul Eggert [Fri, 8 Jun 2018 02:12:28 +0000 (19:12 -0700)]
New type Lisp_Misc_Ptr
This is a streamlined version of Lisp_Save_Value, which contains just
a pointer, as that is all Lisp_Save_Values are used for any more.
With the previous changes, these objects are not primarily used as
save values, so just call them "Misc" rather than "Save".
* src/alloc.c (make_misc_ptr): New function.
(mark_object): Mark Lisp_Misc_Ptr too.
* src/lisp.h (Lisp_Misc_Ptr): New constant.
(struct Lisp_Misc_Ptr): New type.
(make_mint_ptr, mint_ptrp, xmint_pointer):
Use Lisp_Misc_Ptr, not Lisp_Save_Value.
(union Lisp_Misc): Add Lisp_Misc_Ptr.
* src/print.c (print_object): Print Lisp_Misc_Ptr.
Paul Eggert [Fri, 8 Jun 2018 02:12:28 +0000 (19:12 -0700)]
Avoid allocating Lisp_Save_Value for arrays
* src/alloc.c (mark_maybe_objects): New function.
* src/eval.c (default_toplevel_binding)
(backtrace_eval_unrewind, Fbacktrace__locals):
Treat array unwindings like other miscellaneous pdl types.
(record_unwind_protect_array): New function.
(do_one_unbind): Free the array while unwinding.
(mark_specpdl): Mark arrays directly.
* src/lisp.h (SPECPDL_UNWIND_ARRAY): New constant.
(union specbinding): New member unwind_array.
(SAFE_ALLOCA_LISP_EXTRA): Use record_unwind_protect_array
instead of make_save_memory + record_unwind_protect.
Paul Eggert [Thu, 14 Jun 2018 22:59:09 +0000 (15:59 -0700)]
Avoid allocating Lisp_Save_Value for excursions
* src/editfns.c (save_excursion_save): New arg PDL,
specifying where to save the state. All uses changed.
(save_excursion_restore): Args are now the marker and info
rather than a pointer to a Lisp_Save_Value containing them.
All uses changed.
* src/eval.c (default_toplevel_binding, Fbacktrace__locals):
Treat excursions like other miscellaneous pdl types.
(record_unwind_protect_excursion): Save data directly
into the pdl rather than creating an object on the heap.
This avoids the need to allocate and free an object.
(do_one_unbind, backtrace_eval_unrewind):
Unwind excursions directly.
(mark_specpdl): Mark excursions directly.
* src/lisp.h (SPECPDL_UNWIND_EXCURSION): New constant.
(union specbinding): New member unwind_excursion.
Paul Eggert [Thu, 14 Jun 2018 22:59:09 +0000 (15:59 -0700)]
Just use cons in macfont_descriptor_entity
* src/macfont.m (macfont_descriptor_entity): Use cons instead
of make_save_ptr_int, as this avoids the need for a special
type and function for this one-off.
Paul Eggert [Thu, 14 Jun 2018 22:59:08 +0000 (15:59 -0700)]
Avoid allocating a Lisp_Save_Value in ftfont.c
* src/ftfont.c (struct ftfont_cache_data): New member face_refcount.
(ftfont_lookup_cache): Clear it when initializing.
Use make_mint_ptr, since this typically avoids the need to
allocate a Lisp_Save_Value as refcount is now stored elsewhere.
(ftfont_open2, ftfont_close): Manipulate the reference
count in the struct, not in the save object.
Paul Eggert [Thu, 14 Jun 2018 22:59:08 +0000 (15:59 -0700)]
Use record_unwind_protect_ptr to avoid allocation
* src/term.c (struct tty_pop_down_menu): New type.
(tty_pop_down_menu, tty_menu_show): Use it, along with
record_unwind_protect_ptr, to avoid allocating a Lisp_Misc.
* src/xmenu.c (struct pop_down_menu): New type.
(pop_down_menu, x_menu_show): Use it, likewise.
* src/xterm.c (x_cr_destroy, x_cr_export_frames):
Use record_unwind_protect_pointer to avoid possibly allocating
a Lisp_Misc.
Paul Eggert [Thu, 14 Jun 2018 22:59:08 +0000 (15:59 -0700)]
Avoid Lisp_Misc allocation if C stack suffices
* src/fileio.c (union read_non_regular): New type.
(read_non_regular, Finsert_file_contents):
Use it to avoid allocating a Lisp_Misc.
* src/keymap.c (union map_keymap): New type.
(map_keymap_char_table_item, map_keymap_internal):
Use it to avoid allocating a Lisp_Misc.
Paul Eggert [Thu, 14 Jun 2018 22:59:08 +0000 (15:59 -0700)]
Simplify init_module_assertions
* src/emacs-module.c (init_module_assertions): Just use NULL
instead of allocating a dummy on the stack and then using
eassert. Practical platforms check for null pointer
dereferencing nowadays, so this is good enough.
João Távora [Fri, 8 Jun 2018 01:35:50 +0000 (02:35 +0100)]
Also allow custom false and null when serializing to JSON
* doc/lispref/text.texi (Parsing JSON): Describe new arguments of
json-serialize and json-insert.
* src/json.c (enum json_object_type, struct json_configuration):
Move up in file before first usage.
(lisp_to_json_toplevel, lisp_to_json_toplevel_1, lisp_to_json):
Accept a struct json_configuration*.
(Fjson_serialize, Fjson_insert): Accept multiple args.
(json_parse_args): Accept new boolean configure_object_type.
João Távora [Thu, 7 Jun 2018 16:41:19 +0000 (17:41 +0100)]
Support custom null and false objects when parsing JSON
* doc/lispref/text.texi (Parsing JSON): Describe new :null-object
and :false-object kwargs to json-parse-string and
json-parse-buffer.
* src/json.c
(struct json_configuration): New type.
(json_to_lisp): Accept a struct json_configuration* param.
(json_parse_args): Rename from json_parse_object_type.
(Fjson_parse_string): Rework docstring.
(Fjson_parse_string, Fjson_parse_buffer): Update call to
json_to_lisp.
(syms_of_json): Two new syms, QCnull_object and QCfalse_object.
* test/src/json-tests.el
(json-parse-with-custom-null-and-false-objects): New test.
Paul Eggert [Sat, 26 May 2018 20:29:06 +0000 (13:29 -0700)]
Don’t set EMACS=t if Bash is 4.4 or newer
(Backport from master.)
(Thanks to Stefan Monnier for improvements to this patch.)
* lisp/term.el (term--bash-needs-EMACS-status): New var.
(term--bash-needs-EMACSp): New function.
(term-exec-1): Use it instead of always setting EMACS.
Eli Zaretskii [Thu, 14 Jun 2018 13:54:08 +0000 (16:54 +0300)]
Improve commentary in info.el
* lisp/info.el: Explain in commentary why some commands start with
"info-" and others with "Info-". See also
http://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00482.html.
Damien Cassou [Sat, 19 May 2018 06:36:32 +0000 (08:36 +0200)]
Fix pretty-printing empty objects as null
* lisp/json.el (json-pretty-print): Force distinction between empty
objects and null.
(json-encode-list): Remove responsibility to print "null" as this
value is not a list.
(json-encode): Give higher precedence to lists so that an empty list
is printed as an empty object, not as "null".
* test/lisp/json-tests.el (test-json-encode): Add many tests to check
the behavior of pretty-printing.
Paul Eggert [Wed, 13 Jun 2018 20:30:29 +0000 (13:30 -0700)]
Remove some wrong 8-byte alignment assumptions
Do not assume that 8-byte alignment suffices for all C objects,
as some platforms require 16-byte alignment for some objects,
and this will start to bite us as time goes on (e.g., if an
Emacs module ever uses an object containing a long
double, which requires 16-byte alignment on x86-64).
Conversely, on !USE_LSB_TAG platforms, do not insist on
aligning Lisp objects to a multiple of 8, as this is not
needed for high-order tag bits.
* src/alloc.c (LISP_ALIGNMENT, MALLOC_IS_LISP_ALIGNED):
New constants.
(XMALLOC_BASE_ALIGNMENT, XMALLOC_HEADER_ALIGNMENT):
Removed. All uses replaced by LISP_ALIGNMENT.
(aligned_alloc, laligned, lmalloc, lrealloc, union aligned_Lisp_Misc)
(maybe_lisp_pointer, pure_alloc):
Use LISP_ALIGNMENT rather than GCALIGNMENT.
(aligned_alloc): Do not worry about an alignment of
LISP_ALIGNMENT when MALLOC_IS_LISP_ALIGNED, as the code never
uses aligned_alloc with alignment == LISP_ALIGNMENT in that case.
(__alignof__): Remove. All uses removed.
(MALLOC_IS_GC_ALIGNED): Remove.
All uses replaced with MALLOC_IS_LISP_ALIGNED.
(vector_alignment): Remove.
All uses replaced with LISP_ALIGNMENT.
* src/alloc.c (mark_maybe_pointer):
* src/emacs-module.c (value_to_lisp_bits):
Do not assume GCALIGNMENT == 1 << GCTYPEBITS, as GCALIGNMENT
is 1 on !USE_LSB_TAG platforms now.
* src/lisp.h (GCALIGNMENT) [!USE_LSB_TAG]: Now 1.
(struct Lisp_Symbol, union vectorlike_header, struct Lisp_Cons)
(struct Lisp_String): Simplify test for verifying alignment.