merge trunk
Fix bug #17986 with infloop in redisplay when default-directory is nil.

 src/xdisp.c (decode_mode_spec): Call file-remote-p on the current
 buffer's default-directory only if it is a string.

 lisp/bindings.el (mode-line-remote): If default-directory is not a
 string, don't call file-remote-p on it; instead state in the
 help-echo that it is nil.
Improve behavior of 'bzr up; cd src; make -k'.

* Makefile.in (ACLOCAL_INPUTS): Add all m4/*.m4 files.
* src/Makefile.in (top_srcdir): New var.
(ntsource, lispsource, ALL_CFLAGS, gl-stamp, emacs.res):
Use '$(top_srcdir)' instead of '$(srcdir)/..';
its expansion is a bit shorter.
(../config.status): Actually build config.status instead of
just complaining.
(ACLOCAL_INPUTS, AUTOCONF_INPUTS):
New macros, copied and relocated from ../Makefile.in.
($(top_srcdir)/aclocal.m4, $(top_srcdir)/configure, config.in)
(../config.status, Makefile): New dependencies and rules,
copied with relocation from ../Makefile.in.  This should be more
likely to rebuild the build machinery properly if you do a 'make'
in the src directory.
* make-docfile.c: Simplify a bit, to simplify further refactoring.

(outfile): Remove static var.  All uses changed to use stdout,
since it's always stdout anyway.  While we're at it, prefer
putchar/puts/fputs to printf when there are no format strings.
(main): Use freopen rather than fopen, so that stdout is reused.
Move O_BINARY stuff after the freopen, so it affects the
reopened file.
(write_c_args): Omit first arg, since it's always stdout now.
All uses changed.
* lisp.h (CHECK_VECTOR_OR_STRING): Return number of elements
or characters in string, respectively.  Add comment.
* fringe.c (Fdefine_fringe_bitmap):
* fns.c (Fsubstring, substring_both): Use it.
* keymap.c (Fdefine_key, Flookup_key):
* macros.c (Fstart_kbd_macro): Likewise.  Avoid call to Flength.
* term.c (tty_menu_add_pane, tty_menu_add_selection):
Use menu_item_width.
(tty_menu_show): Simplify because ty_menu_create never return NULL.
src/ChangeLog: Fix a typo in a recently added entry.
* macros.c (Fstart_kbd_macro): Simplify.

This works around a GCC compiler bug when Emacs is configured with
--enable-gcc-warnings.
* macros.c (Fstart_kbd_macro): Avoid need for overflow check.
Use binary-io module, O_BINARY, and "b" flag.

* admin/merge-gnulib (GNULIB_MODULES): Add binary-io.  It was already
present implicitly; this just makes the dependence explicit.
* lib-src/etags.c, lib-src/hexl.c, lib-src/make-docfile.c:
Include binary-io.h instead of fcntl.h and/or io.h.
(main): Use set_binary_mode or SET_BINARY
in place of handcrafted code.
* lib-src/etags.c (main) [DOS_NT]:
* lib-src/movemail.c (main) [WINDOWSNT]:
Don't mess with _fmode.
* lib-src/etags.c (main, process_file_name, analyse_regex):
Use fopen/popen's "b" flag instead.
* lib-src/movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY
instead.
* src/callproc.c (create_temp_file): Use mkostemp's O_BINARY flag.
* src/emacs.c [MSDOS]:
* src/emacs.c (main) [DOS_NT]: Don't mess with _fmode.
(main) [MSDOS]: Use SET_BINARY instead of setmode.
* src/minibuf.c: Include binary-io.h instead of fcntl.h.
(read_minibuf_noninteractive):
Use set_binary_mode instead of handcrafted code.
Don't call emacs_set_tty if emacs_get_tty failed.
* src/sysdep.c, src/systty.h (emacs_get_tty): Return int, not void.
* src/sysdep.c (emacs_open, emacs_pipe): Use O_BINARY.
* src/w32.c (pipe2): Adjust eassert to include O_BINARY.
Tweak earlier vc-log-edit change

* lisp/vc/vc-dispatcher.el (vc-log-edit): Do set up the log buffer
if it was "empty", or used for a different set of files.
Unbreak compilation of derived cc-mode modes

* lisp/progmodes/cc-defs.el (c-lang-defconst-eval-immediately):
Use `macroexpand-all' instead of `cl-macroexpand-all'.

* lisp/progmodes/cc-langs.el: Change comments from `cl-macroexpand-all'
to `macroexpand-all'
* lwlib/lwlib.h (toplevel): Use unsigned int for LWLIB_ID.
* src/xmenu.c (toplevel): Use LWLIB_ID for next_menubar_widget_id.
(pop_down_menu) [USE_X_TOOLKIT]: Accept integer arg.
(create_and_show_popup_menu, create_and_show_dialog) [USE_X_TOOLKIT]:
Use record_unwind_protect_int and avoid consing.
(syms_of_xmenu) [USE_X_TOOLKIT]: Declare WIDGET_ID_TICK_START.
* regex.c (re_search_2): Use ssize_t to avoid integer overflow.
Fix bug #18025 with typos in Emacs Lisp Introduction manual.

 doc/lispintro/emacs-lisp-intro.texi (Variables, Buffer Names, if & or)
 (Symbols as Chest, fwd-para while): Fix typos.
etc/TODO: Minor updates.
Use "b" flag more consistently; avoid "t".

* make-docfile.c (READ_TEXT): Remove; all uses replaced by "r".
(READ_BINARY): Remove; all uses replaced by "rb".
Consolidate XChar2b macros for the X, W32, and NS

Suggested by Jan Djärv in:
https://lists.gnu.org/archive/html/emacs-devel/2014-07/msg00203.html
* w32gui.h (XChar2b, STORE_XCHAR2B, XCHAR2B_BYTE1, XCHAR2B_BYTE2):
Move the fallback definitions to dispextern.h.
* nsgui.h (XChar2b, STORE_XCHAR2B, XCHAR2B_BYTE1, XCHAR2B_BYTE2):
Likewise.  Share the same definition with W32.
* xterm.h (STORE_XCHAR2B, XCHAR2B_BYTE1, XCHAR2B_BYTE2): Move to ...
* dispextern.h (STORE_XCHAR2B, XCHAR2B_BYTE1, XCHAR2B_BYTE2):
... here for the consistency with W32 and NS.
* lisp/desktop.el (after-init-hook): Disable startup frame restoration
in non-graphical situations.
Move back the XChar2b definition to w32gui.h and nsgui.h

Fix the last change.  XChar2b still needs to be defined platform dependently,
to match with the argument types of drawing functions.