emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] xwidget_mvp 7d143ea 1/2: merge master


From: Joakim Verona
Subject: [Emacs-diffs] xwidget_mvp 7d143ea 1/2: merge master
Date: Mon, 09 Feb 2015 14:24:09 +0000

branch: xwidget_mvp
commit 7d143ea4db0021a9fb3f6148adc8a177822e98a7
Merge: 131f0f2 7d631aa
Author: Joakim Verona <address@hidden>
Commit: Joakim Verona <address@hidden>

    merge master
---
 ChangeLog                       |    5 +
 configure.ac                    |   13 +--
 doc/lispref/ChangeLog           |   10 ++
 doc/lispref/display.texi        |    9 +-
 doc/lispref/sequences.texi      |   47 ++++++-
 doc/misc/ChangeLog              |   17 +++
 doc/misc/auth.texi              |   22 +++
 doc/misc/gnus.texi              |   24 ++++
 etc/ChangeLog                   |    4 +
 etc/GNUS-NEWS                   |    2 +
 etc/NEWS                        |    8 +-
 lisp/ChangeLog                  |  202 +++++++++++++++++++++++++++-
 lisp/bindings.el                |    1 +
 lisp/delsel.el                  |   17 +--
 lisp/doc-view.el                |   17 ++-
 lisp/emacs-lisp/bytecomp.el     |   59 +++++---
 lisp/emacs-lisp/cconv.el        |   31 +++-
 lisp/emacs-lisp/eieio-base.el   |    3 +-
 lisp/emacs-lisp/eieio-compat.el |    7 +-
 lisp/emacs-lisp/eieio-core.el   |   43 +++---
 lisp/emacs-lisp/package.el      |   60 ++++++++-
 lisp/emacs-lisp/seq.el          |   55 ++++++--
 lisp/emulation/viper-cmd.el     |    4 +-
 lisp/emulation/viper-keym.el    |    8 +-
 lisp/faces.el                   |    3 +-
 lisp/frame.el                   |   23 +++-
 lisp/gnus/ChangeLog             |   30 ++++
 lisp/gnus/gnus-int.el           |    2 +-
 lisp/gnus/gnus-start.el         |   34 ++---
 lisp/gnus/gnus-sum.el           |    6 +-
 lisp/gnus/mail-source.el        |   15 ++-
 lisp/gnus/nnimap.el             |   65 +++++-----
 lisp/help-fns.el                |   31 ++++
 lisp/help-mode.el               |    9 +-
 lisp/help.el                    |    2 +
 lisp/image-mode.el              |    6 +
 lisp/json.el                    |    6 +-
 lisp/net/ldap.el                |    4 +-
 lisp/net/network-stream.el      |    6 +-
 lisp/newcomment.el              |   32 +++++
 lisp/outline.el                 |    7 +-
 lisp/play/gamegrid.el           |   20 ++--
 lisp/progmodes/python.el        |  288 ++++++++++++++++++++++-----------------
 lisp/subr.el                    |    7 +-
 lisp/textmodes/css-mode.el      |   11 +-
 lisp/vc/vc-cvs.el               |    2 +-
 src/ChangeLog                   |  126 ++++++++++++++++-
 src/data.c                      |    5 -
 src/dispnew.c                   |  135 ++++++++-----------
 src/eval.c                      |   22 +++-
 src/frame.c                     |  208 ++++++++++++++++++++---------
 src/frame.h                     |   13 +-
 src/gtkutil.c                   |  118 ++++++++++++----
 src/w32fns.c                    |   18 ++-
 src/w32term.c                   |  217 ++++++++++++-----------------
 src/widget.c                    |   39 ++----
 src/window.c                    |    2 +-
 src/xdisp.c                     |   39 ++----
 src/xfns.c                      |   16 ++-
 src/xterm.c                     |  214 +++++++++++++++++++++++------
 test/ChangeLog                  |   36 +++++-
 test/automated/package-test.el  |   28 ++++-
 test/automated/python-tests.el  |  255 ++++++++++++++++++++++++++++------
 test/automated/seq-tests.el     |   26 ++++-
 test/automated/vc-tests.el      |   14 +-
 65 files changed, 1985 insertions(+), 823 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ca9f44a..908ffe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-08  Ulrich Müller  <address@hidden>
+
+       * configure.ac (--with-gameuser): Default to 'games' group instead
+       of 'games' user.
+
 2015-02-04  Paul Eggert  <address@hidden>
 
        * .gitattributes: Ignore blanks at EOL in texinfo.tex.
diff --git a/configure.ac b/configure.ac
index a679bd0..3874cf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -399,17 +399,12 @@ AC_ARG_WITH(gameuser,dnl
                An argument prefixed by ':' specifies a group instead.])])
 gameuser=
 gamegroup=
+# We don't test if we can actually chown/chgrp here, because configure
+# may run without root privileges.  lib-src/Makefile.in will handle
+# any errors due to missing user/group gracefully.
 case ${with_gameuser} in
   no) ;;
-  "" | yes)
-    AC_MSG_CHECKING([whether a 'games' user exists])
-    if id -u games >/dev/null 2>&1; then
-      AC_MSG_RESULT([yes])
-      gameuser=games
-    else
-      AC_MSG_RESULT([no])
-    fi
-    ;;
+  "" | yes) gamegroup=games ;;
   :*) gamegroup=`echo "${with_gameuser}" | sed -e "s/://"` ;;
   *) gameuser=${with_gameuser} ;;
 esac
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index aa4d320..3fe3d6f 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,13 @@
+2015-02-06  Nicolas Petton <address@hidden>
+
+       * sequences.texi (Sequence Functions): Add documentation for
+       seq-mapcat, seq-partition and seq-group-by.
+
+2015-02-05  Martin Rudalics  <address@hidden>
+
+       * display.texi (Size of Displayed Text): Remove description of
+       optional argument BUFFER of `window-text-pixel-size'.
+
 2015-02-01  Martin Rudalics  <address@hidden>
 
        * display.texi (Size of Displayed Text): Describe optional
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 10b17a3..b09b82a 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1880,7 +1880,7 @@ displayed in a given window.  This function is used by
 @code{fit-frame-to-buffer} (@pxref{Size and Position}) to make a window
 exactly as large as the text it contains.
 
address@hidden window-text-pixel-size &optional window from to x-limit y-limit 
mode-and-header-line buffer
address@hidden window-text-pixel-size &optional window from to x-limit y-limit 
mode-and-header-line
 This function returns the size of the text of @var{window}'s buffer in
 pixels.  @var{window} must be a live window and defaults to the selected
 one.  The return value is a cons of the maximum pixel-width of any text
@@ -1919,13 +1919,6 @@ means to not include the height of the mode- or 
header-line of
 @code{mode-line} or @code{header-line}, include only the height of that
 line, if present, in the return value.  If it is @code{t}, include the
 height of both, if present, in the return value.
-
-The optional argument @var{buffer} allows to specify an alternate buffer
-whose text size will be calculated.  If @var{buffer} is @code{nil} or
-omitted, then operate on the buffer of @var{window}.  If it is @code{t},
-then operate on the current buffer as if it were displayed in
address@hidden  If it specifies a live buffer, then operate on that
-buffer as if it were displayed in @var{window}.
 @end defun
 
 
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index f82c496..f268c0d 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -695,9 +695,54 @@ concatenation of @var{sequences}.  @var{type} may be: 
@code{vector},
 @end example
 @end defun
 
address@hidden seq-mapcat function sequence &optional type
+  This function returns the result of applying @code{seq-concatenate}
+to the result of applying @var{function} to each element of
address@hidden  The result is a sequence of type @var{type}, or a
+list if @var{type} is @code{nil}.
+
address@hidden
address@hidden
+(seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)))
address@hidden (1 2 3 4 5 6)
address@hidden group
address@hidden example
address@hidden defun
+
address@hidden seq-partition sequence n
+  This function returns a list of the elements of @var{sequence}
+grouped into sub-sequences of length @var{n}.  The last sequence may
+contain less elements than @var{n}.  @var{n} must be an integer.  If
address@hidden is a negative integer or 0, nil is returned.
+
address@hidden
address@hidden
+(seq-partition '(0 1 2 3 4 5 6 7) 3)
address@hidden ((0 1 2) (3 4 5) (6 7))
address@hidden group
address@hidden example
address@hidden defun
+
address@hidden seq-group-by function sequence
+  This function separates the elements of @var{sequence} into an alist
+whose keys are the result of applying @var{function} to each element
+of @var{sequence}.  Keys are compared using @code{equal}.
+
address@hidden
address@hidden
+(seq-group-by #'integerp '(1 2.1 3 2 3.2))
address@hidden ((t 2 3 1) (nil 3.2 2.1))
address@hidden group
address@hidden
+(seq-group-by #'car '((a 1) (b 2) (a 3) (c 4)))
address@hidden ((a (a 3) (a 1)) (b (b 2)) (c (c 4)))
address@hidden group
address@hidden example
address@hidden defun
+
 @defmac seq-doseq (var sequence [result]) address@hidden
 @cindex sequence iteration
-This macro is like @code{dolist}, except that @var{sequence} can be a list,
+  This macro is like @code{dolist}, except that @var{sequence} can be a list,
 vector or string (@pxref{Iteration} for more information about the
 @code{dolist} macro).  This is primarily useful for side-effects.
 @end defmac
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 534dd10..bc22b67 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,20 @@
+2015-02-05  Glenn Morris  <address@hidden>
+
+       * auth.texi (Multiple GMail accounts with Gnus): Markup fix.
+
+2015-02-05  Teodor Zlatanov  <address@hidden>
+
+       * auth.texi (Multiple GMail accounts with Gnus): Add FAQ.
+
+2015-02-05  Lars Ingebrigtsen  <address@hidden>
+
+       * gnus.texi (Using IMAP): Fix menu node name.
+
+2015-02-05  Trevor Murphy  <address@hidden>
+
+       * gnus.texi (Support for IMAP Extensions): Document the Gmail label
+       extension.
+
 2015-02-04  Paul Eggert  <address@hidden>
 
        * texinfo.tex: Update from gnulib.
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi
index 44fcad8..7c0254a 100644
--- a/doc/misc/auth.texi
+++ b/doc/misc/auth.texi
@@ -59,6 +59,7 @@ It is a way for multiple applications to share a single 
configuration
 @menu
 * Overview::                    Overview of the auth-source library.
 * Help for users::
+* Multiple GMail accounts with Gnus::
 * Secret Service API::
 * Help for developers::
 * GnuPG and EasyPG Assistant Configuration::
@@ -229,6 +230,27 @@ don't use a port entry, you match any Tramp method, as 
explained
 earlier.  Since Tramp has about 88 connection methods, this may be
 necessary if you have an unusual (see earlier comment on those) setup.
 
address@hidden Multiple GMail accounts with Gnus
address@hidden Multiple GMail accounts with Gnus
+
+For multiple GMail accounts with Gnus, you have to make two nnimap
+entries in your @code{gnus-secondary-select-methods} with distinct
+names:
+
address@hidden
+(setq gnus-secondary-select-methods '((nnimap "gmail"
+                                         (nnimap-address "imap.gmail.com"))
+                                      (nnimap "gmail2"
+                                         (nnimap-address "imap.gmail.com"))))
address@hidden example
+
+Your netrc entries will then be:
+
address@hidden
+machine gmail login account@@gmail.com password "accountpassword" port imap
+machine gmail2 login account2@@gmail.com password "account2password" port imap
address@hidden example
+
 @node Secret Service API
 @chapter Secret Service API
 
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index cb80874..d714656 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -14182,6 +14182,7 @@ from different locations, or with different user agents.
 * Connecting to an IMAP Server::     Getting started with @acronym{IMAP}.
 * Customizing the IMAP Connection::  Variables for @acronym{IMAP} connection.
 * Client-Side IMAP Splitting::       Put mail in the correct mail box.
+* Support for IMAP Extensions::      Getting extensions and labels from 
servers.
 @end menu
 
 
@@ -14328,6 +14329,29 @@ Here's a complete example @code{nnimap} backend with a 
client-side
 @end example
 
 
address@hidden Support for IMAP Extensions
address@hidden Support for IMAP Extensions
+
address@hidden Gmail
address@hidden X-GM-LABELS
address@hidden IMAP labels
+
+If you're using Google's Gmail, you may want to see your Gmail labels
+when reading your mail.  Gnus can give you this information if you ask
+for @samp{X-GM-LABELS} in the variable @code{gnus-extra-headers}. For
+example:
+
address@hidden
+(setq gnus-extra-headers
+      '(To Newsgroups X-GM-LABELS))
address@hidden example
+
+This will result in Gnus storing your labels in message header
+structures for later use.  The content is always a parenthesized
+(possible empty) list.
+
+
+
 @node Getting Mail
 @section Getting Mail
 @cindex reading mail
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 3703189..1fcea54 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-08  Artur Malabarba  <address@hidden>
+
+       * NEWS: Document `comment-line'.
+
 2015-02-03  Artur Malabarba  <address@hidden>
 
        * NEWS: Document package.el's improved dependency-handling.
diff --git a/etc/GNUS-NEWS b/etc/GNUS-NEWS
index 4f311e3..ee3584f 100644
--- a/etc/GNUS-NEWS
+++ b/etc/GNUS-NEWS
@@ -9,6 +9,8 @@ For older news, see Gnus info node "New Features".
 
 * New features
 
+** nnimap can request and use the Gmail "X-GM-LABELS".
+
 ** New package `gnus-notifications.el' can send notifications when you
    receive new messages.
 
diff --git a/etc/NEWS b/etc/NEWS
index 72e2356..4c7160e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -53,7 +53,7 @@ build with 'make V=1'.
 group instead of a user if its argument is prefixed by ':' (a colon).
 This will cause the game score files in ${localstatedir}/games/emacs
 to be owned by that group, and the helper program for updating them to
-be installed setgid.
+be installed setgid.  The option now defaults to the 'games' group.
 
 ---
 ** The `grep-changelog' script (and its manual page) are no longer included.
@@ -66,6 +66,8 @@ so if you want to use it, you can always take a copy from an 
older Emacs.
 
 * Changes in Emacs 25.1
 
+** New command `comment-line' bound to `C-x C-;'.
+
 ** New function `custom-prompt-customize-unsaved-options' checks for
 unsaved customizations and prompts user to customize (if found).
 
@@ -599,6 +601,10 @@ in languages like German where downcasing rules depend on 
grammar.
 
 * Lisp Changes in Emacs 25.1
 
+** lexical closures can use (:documentation <form>) to build their docstring.
+It should be placed right where the docstring would be, and <form> is then
+evaluated (and should return a string) when the closure is built.
+
 ** define-inline provides a new way to define inlinable functions.
 
 ** New function macroexpand-1 to perform a single step of macroexpansion.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9e473e2..ad4f3b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,200 @@
+2015-02-08  Artur Malabarba  <address@hidden>
+
+       * newcomment.el (comment-line): Fix missing paren.
+
+2015-02-08  Ulrich Müller  <address@hidden>
+
+       * play/gamegrid.el: Update comment to reflect that the
+       'update-game-score' helper program is now setgid by default.
+
+2015-02-08  David Kastrup  <address@hidden>
+
+       * subr.el (apply-partially): Use lexical binding here.
+
+2015-02-08  Artur Malabarba  <address@hidden>
+
+       * newcomment.el (comment-line): New command.
+
+       * bindings.el (ctl-x-map): Bind to `C-x C-;'.
+
+2015-02-08  Oleh Krehel  <address@hidden>
+
+       * outline.el (outline-show-entry): Fix one invisible char for the
+       file's last outline.  Fixes Bug#19493.
+
+2015-02-08  Stefan Monnier  <address@hidden>
+
+       * subr.el (indirect-function): Change advertised calling convention.
+
+2015-02-08  Fabián Ezequiel Gallina  <address@hidden>
+
+       python.el: Fix completion-at-point.  (Bug#19667)
+
+       * progmodes/python.el
+       (python-shell-completion-native-get-completions): Force process buffer.
+       (python-shell-completion-at-point): Handle case where call is not
+       in a shell buffer.
+
+2015-02-08  Fabián Ezequiel Gallina  <address@hidden>
+
+       python.el: Fix shell font-lock multiline input.  (Bug#19744)
+
+       * progmodes/python.el
+       (python-shell-font-lock-post-command-hook): Handle multiline input.
+
+2015-02-08  Fabián Ezequiel Gallina  <address@hidden>
+
+       python.el: Make shell font-lock respect markers.  (Bug#19650)
+
+       * progmodes/python.el (python-shell-font-lock-cleanup-buffer):
+       Use `erase-buffer`.
+       (python-shell-font-lock-comint-output-filter-function):
+       Handle newlines.
+       (python-shell-font-lock-post-command-hook): Respect markers on
+       text fontification.
+
+2015-02-07  Fabián Ezequiel Gallina  <address@hidden>
+
+       python.el: Keep eldoc visible while typing args.  (Bug#19637)
+
+       * progmodes/python.el (python-eldoc--get-symbol-at-point):
+       New function based on Carlos Pita <address@hidden> patch.
+       (python-eldoc--get-doc-at-point, python-eldoc-at-point): Use it.
+
+2015-02-07  Fabián Ezequiel Gallina  <address@hidden>
+
+       Fix hideshow integration.  (Bug#19761)
+
+       * progmodes/python.el
+       (python-hideshow-forward-sexp-function): New function based on
+       Carlos Pita <address@hidden> patch.
+       (python-mode): Make `hs-special-modes-alist` use it and initialize
+       the end regexp with the empty string to avoid skipping parens.
+
+2015-02-07  Fabián Ezequiel Gallina  <address@hidden>
+
+       * progmodes/python.el (python-check-custom-command): Do not use
+       defvar-local for compat with Emacs<24.3.
+
+2015-02-07  Martin Rudalics  <address@hidden>
+
+       * frame.el (frame-notice-user-settings):
+       Update `frame-size-history'.
+       (make-frame): Update `frame-size-history'.
+       Call `frame-after-make-frame'.
+       * faces.el (face-set-after-frame-default): Remove call to
+       frame-can-run-window-configuration-change-hook.
+
+2015-02-06  Dmitry Gutov  <address@hidden>
+
+       * vc/vc-cvs.el (vc-cvs-dir-status-files): Don't pass DIR to
+       `vc-cvs-command' (bug#19732).
+
+2015-02-06  Nicolas Petton <address@hidden>
+
+       * emacs-lisp/seq.el (seq-mapcat, seq-partition, seq-group-by): New 
functions.
+       * emacs-lisp/seq.el (seq-drop-while, seq-take-while, seq-count)
+       (seq--drop-list, seq--take-list, seq--take-while-list): Better 
docstring.
+
+2015-02-06  Artur Malabarba  <address@hidden>
+
+       * doc-view.el (doc-view-kill-proc-and-buffer): Obsolete. Use
+       `image-kill-buffer' instead.
+
+2015-02-06  Thomas Fitzsimmons  <address@hidden>
+
+       * net/ldap.el (ldap-search-internal): Fix docstring.
+
+2015-02-06  Lars Ingebrigtsen  <address@hidden>
+
+       * subr.el (define-error): The error conditions may be constant
+       lists, so use `append' to concatenate them.
+
+2015-02-06  Wolfgang Jenkner  <address@hidden>
+
+       * net/network-stream.el (network-stream-open-tls): Respect the
+       :end-of-capability setting.
+
+2015-02-05  Artur Malabarba  <address@hidden>
+
+       * emacs-lisp/package.el (package--sort-by-dependence):
+       New function.  Return PACKAGE-LIST sorted by dependencies.
+       (package-menu-execute): Use it to delete packages in order.
+       (package--sort-deps-in-alist): New function.
+       (package-menu-mark-install): Can mark dependencies.
+       (package--newest-p): New function.
+       (package-delete): Don't delesect when deleting an older version of
+       an upgraded package.
+
+       * emacs-lisp/package.el: Add missing (require 'subr-x)
+
+2015-02-05  Stefan Monnier  <address@hidden>
+
+       * textmodes/css-mode.el (scss-smie--not-interpolation-p): Vars can be
+       hyphenated (bug#19263).
+
+       * textmodes/css-mode.el (css-fill-paragraph): Fix filling in presence
+       of variable interpolation (bug#19751).
+
+2015-02-05  Era Eriksson  <address@hidden>
+
+       * json.el (json-end-of-file): New error (bug#19768).
+       (json-pop, json-read): Use it.
+
+2015-02-05  Kelly Dean <address@hidden>
+
+       * help-mode.el (help-xref-interned): Pass BUFFER and FRAME to
+       `describe-variable'.
+
+       * help-fns.el (describe-function-or-variable): New function.
+
+       * help.el (help-map): Bind `describe-function-or-variable' to o.
+       (help-for-help-internal): Document o key.
+
+2015-02-05  Stefan Monnier  <address@hidden>
+
+       * emacs-lisp/eieio-compat.el (eieio--defmethod): Use new
+       special (:documentation ...) feature.
+       * emacs-lisp/eieio-core.el (eieio-make-class-predicate)
+       (eieio-make-child-predicate): Same.
+       (eieio-copy-parents-into-subclass): Remove unused arg.
+       (eieio-defclass-internal): Adjust call accordingly and remove redundant
+       `pname' var.
+       (eieio--slot-name-index): Remove unused arg `obj' and adjust all
+       callers accordingly.
+
+       * emacs-lisp/cconv.el (cconv--convert-function):
+       Add `docstring' argument.
+       (cconv-convert): Use it to handle the new (:documentation ...) form.
+       (cconv-analyze-form): Handle the new (:documentation ...) form.
+
+       * emacs-lisp/bytecomp.el:
+       (byte-compile-initial-macro-environment): Use macroexp-progn.
+       (byte-compile-cl-warn): Don't silence use of cl-macroexpand-all.
+       (byte-compile-file-form-defvar-function): Rename from
+       byte-compile-file-form-define-abbrev-table.
+       (defvaralias, byte-compile-file-form-custom-declare-variable): Use it.
+       (byte-compile): Use byte-compile-top-level rather than
+       byte-compile-lambda so we can compile non-values.
+       (byte-compile-form): Add warnings for failed uses of lexical vars via
+       quoted symbols.
+       (byte-compile-unfold-bcf): Improve message for failed inlining.
+       (byte-compile-make-closure): Handle new format of internal-make-closure
+       for dynamically-generated docstrings.
+
+       * delsel.el: Deprecate the `kill' option.  Use lexical-binding.
+       (open-line): Delete like all other commands, instead of killing.
+       (delete-active-region): Don't define any return any value.
+
+       * progmodes/python.el: Try to preserve compatibility with Emacs-24.
+       (python-mode): Don't assume eldoc-documentation-function has a non-nil
+       default.
+
+2015-02-04  Sam Steingold  <address@hidden>
+
+       * progmodes/python.el (python-indent-calculate-indentation):
+       Avoid the error when computing top-level indentation.
+
 2015-02-04  Stefan Monnier  <address@hidden>
 
        * emacs-lisp/cl-generic.el (cl--generic-member-method): Fix paren typo.
@@ -14,6 +211,9 @@
 
 2015-02-04  Artur Malabarba  <address@hidden>
 
+       * image-mode.el (image-kill-buffer): New command.
+       (image-mode-map): Bind it to k.
+
        * emacs-lisp/package.el (package-delete): Remove package from
        `package-selected-packages' even if it can't be deleted.
        (package-installed-p): Accept package-desc objects.
@@ -14330,7 +14530,7 @@
        Change default to "# encoding: %s" to differentiate it from the
        default Ruby encoding comment template.
 
-2013-11-20  era eriksson  <address@hidden>
+2013-11-20  Era Eriksson  <address@hidden>
 
        * ses.el (ses-mode): Doc fix.  (Bug#14748)
 
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 883914e..4cc9f6a 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1130,6 +1130,7 @@ if `inhibit-field-text-motion' is non-nil."
 (define-key esc-map "j" 'indent-new-comment-line)
 (define-key esc-map "\C-j" 'indent-new-comment-line)
 (define-key ctl-x-map ";" 'comment-set-column)
+(define-key ctl-x-map "C-;" 'comment-line)
 (define-key ctl-x-map "f" 'set-fill-column)
 (define-key ctl-x-map "$" 'set-selective-display)
 
diff --git a/lisp/delsel.el b/lisp/delsel.el
index e6bb3b9..740b603 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -1,4 +1,4 @@
-;;; delsel.el --- delete selection if you insert
+;;; delsel.el --- delete selection if you insert  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1992, 1997-1998, 2001-2015 Free Software Foundation,
 ;; Inc.
@@ -35,16 +35,12 @@
 ;; property on their symbols; commands which insert text but don't
 ;; have this property won't delete the selection.  It can be one of
 ;; the values:
-;;  'yank
+;;  `yank'
 ;;      For commands which do a yank; ensures the region about to be
 ;;      deleted isn't yanked.
-;;  'supersede
+;;  `supersede'
 ;;      Delete the active region and ignore the current command,
 ;;      i.e. the command will just delete the region.
-;;  'kill
-;;      `kill-region' is used on the selection, rather than
-;;      `delete-region'.  (Text selected with the mouse will typically
-;;      be yankable anyhow.)
 ;;  t
 ;;      The normal case: delete the active region prior to executing
 ;;      the command which will insert replacement text.
@@ -93,8 +89,7 @@ If KILLP in not-nil, the active region is killed instead of 
deleted."
           (cons (current-buffer)
                 (and (consp buffer-undo-list) (car buffer-undo-list)))))
    (t
-    (funcall region-extract-function 'delete-only)))
-  t)
+    (funcall region-extract-function 'delete-only))))
 
 (defun delete-selection-repeat-replace-region (arg)
   "Repeat replacing text of highlighted region with typed text.
@@ -167,7 +162,7 @@ With ARG, repeat that many times.  `C-u' means until end of 
buffer."
      For commands which need to dynamically determine this behavior.
      FUNCTION should take no argument and return one of the above values or 
nil."
   (condition-case data
-      (cond ((eq type 'kill)
+      (cond ((eq type 'kill)            ;Deprecated, backward compatibility.
             (delete-active-region t)
             (if (and overwrite-mode
                      (eq this-command 'self-insert-command))
@@ -255,7 +250,7 @@ See `delete-selection-helper'."
 (put 'newline-and-indent 'delete-selection t)
 (put 'newline 'delete-selection t)
 (put 'electric-newline-and-maybe-indent 'delete-selection t)
-(put 'open-line 'delete-selection 'kill)
+(put 'open-line 'delete-selection t)
 
 ;; This is very useful for canceling a selection in the minibuffer without
 ;; aborting the minibuffer.
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 0e63d37..5f1c94a 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -415,7 +415,6 @@ Typically \"page-%s.png\".")
     (define-key map "H"               'doc-view-fit-height-to-window)
     (define-key map "P"               'doc-view-fit-page-to-window)
     ;; Killing the buffer (and the process)
-    (define-key map (kbd "k")         'doc-view-kill-proc-and-buffer)
     (define-key map (kbd "K")         'doc-view-kill-proc)
     ;; Slicing the image
     (define-key map (kbd "s s")       'doc-view-set-slice)
@@ -645,12 +644,8 @@ at the top edge of the page moves to the previous page."
     (setq doc-view--current-timer nil))
   (setq mode-line-process nil))
 
-(defun doc-view-kill-proc-and-buffer ()
-  "Kill the current converter process and buffer."
-  (interactive)
-  (doc-view-kill-proc)
-  (when (eq major-mode 'doc-view-mode)
-    (kill-buffer (current-buffer))))
+(define-obsolete-function-alias 'doc-view-kill-proc-and-buffer
+  #'image-kill-buffer "25.1")
 
 (defun doc-view-make-safe-dir (dir)
   (condition-case nil
@@ -1685,6 +1680,9 @@ If BACKWARD is non-nil, jump to the previous match."
 ;; desktop.el integration
 
 (defun doc-view-desktop-save-buffer (_desktop-dirname)
+  ;; FIXME: This is wrong, since this info is per-window but we only do it once
+  ;; here for the buffer.  IOW it should be saved via something like
+  ;; `window-persistent-parameters'.
   `((page . ,(doc-view-current-page))
     (slice . ,(doc-view-current-slice))))
 
@@ -1695,8 +1693,13 @@ If BACKWARD is non-nil, jump to the previous match."
   (let ((page  (cdr (assq 'page misc)))
        (slice (cdr (assq 'slice misc))))
     (desktop-restore-file-buffer file name misc)
+    ;; FIXME: We need to run this code after displaying the buffer.
     (with-selected-window (or (get-buffer-window (current-buffer) 0)
                              (selected-window))
+      ;; FIXME: This should be done for all windows restored that show
+      ;; this buffer.  Basically, the page/slice should be saved as
+      ;; window-parameters in the window-state(s) and then restoring this
+      ;; window-state should call us back (to interpret/use those parameters).
       (doc-view-goto-page page)
       (when slice (apply 'doc-view-set-slice slice)))))
 
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 2bd8d07..548aaa9 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -31,6 +31,10 @@
 ;; faster.  [`LAP' == `Lisp Assembly Program'.]
 ;; The user entry points are byte-compile-file and byte-recompile-directory.
 
+;;; Todo:
+
+;; - Turn "not bound at runtime" functions into autoloads.
+
 ;;; Code:
 
 ;; ========================================================================
@@ -450,7 +454,7 @@ Return the compile-time value of FORM."
     (eval-when-compile . ,(lambda (&rest body)
                             (let ((result nil))
                               (byte-compile-recurse-toplevel
-                               (cons 'progn body)
+                               (macroexp-progn body)
                                (lambda (form)
                                  (setf result
                                        (byte-compile-eval
@@ -459,7 +463,7 @@ Return the compile-time value of FORM."
                               (list 'quote result))))
     (eval-and-compile . ,(lambda (&rest body)
                            (byte-compile-recurse-toplevel
-                            (cons 'progn body)
+                            (macroexp-progn body)
                             (lambda (form)
                               ;; Don't compile here, since we don't know
                               ;; whether to compile as byte-compile-form
@@ -1458,7 +1462,7 @@ extra args."
                          ;; These would sometimes be warned about
                          ;; but such warnings are never useful,
                          ;; so don't warn about them.
-                         macroexpand cl-macroexpand-all
+                         macroexpand
                          cl--compiling-file))))
        (byte-compile-warn "function `%s' from cl package called at runtime"
                           func)))
@@ -2319,10 +2323,12 @@ list that represents a doc string reference.
     form))
 
 (put 'define-abbrev-table 'byte-hunk-handler
-     'byte-compile-file-form-define-abbrev-table)
-(defun byte-compile-file-form-define-abbrev-table (form)
-  (if (eq 'quote (car-safe (car-safe (cdr form))))
-      (byte-compile--declare-var (car-safe (cdr (cadr form)))))
+     'byte-compile-file-form-defvar-function)
+(put 'defvaralias 'byte-hunk-handler 'byte-compile-file-form-defvar-function)
+
+(defun byte-compile-file-form-defvar-function (form)
+  (pcase-let (((or `',name (let name nil)) (nth 1 form)))
+    (if name (byte-compile--declare-var name)))
   (byte-compile-keep-pending form))
 
 (put 'custom-declare-variable 'byte-hunk-handler
@@ -2330,8 +2336,7 @@ list that represents a doc string reference.
 (defun byte-compile-file-form-custom-declare-variable (form)
   (when (byte-compile-warning-enabled-p 'callargs)
     (byte-compile-nogroup-warn form))
-  (byte-compile--declare-var (nth 1 (nth 1 form)))
-  (byte-compile-keep-pending form))
+  (byte-compile-file-form-defvar-function form))
 
 (put 'require 'byte-hunk-handler 'byte-compile-file-form-require)
 (defun byte-compile-file-form-require (form)
@@ -2580,17 +2585,11 @@ If FORM is a lambda or a macro, byte-compile it as a 
function."
         fun)
        (t
         (when (symbolp form)
-          (unless (memq (car-safe fun) '(closure lambda))
-            (error "Don't know how to compile %S" fun))
           (setq lexical-binding (eq (car fun) 'closure))
           (setq fun (byte-compile--reify-function fun)))
-        (unless (eq (car-safe fun) 'lambda)
-          (error "Don't know how to compile %S" fun))
         ;; Expand macros.
         (setq fun (byte-compile-preprocess fun))
-        ;; Get rid of the `function' quote added by the `lambda' macro.
-        (if (eq (car-safe fun) 'function) (setq fun (cadr fun)))
-        (setq fun (byte-compile-lambda fun))
+        (setq fun (byte-compile-top-level fun nil 'eval))
         (if macro (push 'macro fun))
         (if (symbolp form)
             (fset form fun)
@@ -2966,6 +2965,16 @@ for symbols generated by the byte compiler itself."
             (interactive-only
              (or (get fn 'interactive-only)
                  (memq fn byte-compile-interactive-only-functions))))
+        (when (memq fn '(set symbol-value run-hooks ;; add-to-list
+                             add-hook remove-hook run-hook-with-args
+                             run-hook-with-args-until-success
+                             run-hook-with-args-until-failure))
+          (pcase (cdr form)
+            (`(',var . ,_)
+             (when (assq var byte-compile-lexical-variables)
+               (byte-compile-log-warning
+                (format "%s cannot use lexical var `%s'" fn var)
+                nil :error)))))
         (when (macroexp--const-symbol-p fn)
           (byte-compile-warn "`%s' called as a function" fn))
        (when (and (byte-compile-warning-enabled-p 'interactive-only)
@@ -3079,8 +3088,9 @@ for symbols generated by the byte compiler itself."
       (dotimes (_ (- (/ (1+ fmax2) 2) alen))
         (byte-compile-push-constant nil)))
      ((zerop (logand fmax2 1))
-      (byte-compile-log-warning "Too many arguments for inlined function"
-                                nil :error)
+      (byte-compile-log-warning
+       (format "Too many arguments for inlined function %S" form)
+       nil :error)
       (byte-compile-discard (- alen (/ fmax2 2))))
      (t
       ;; Turn &rest args into a list.
@@ -3453,15 +3463,22 @@ discarding."
   (if byte-compile--for-effect (setq byte-compile--for-effect nil)
     (let* ((vars (nth 1 form))
            (env (nth 2 form))
-           (body (nthcdr 3 form))
+           (docstring-exp (nth 3 form))
+           (body (nthcdr 4 form))
            (fun
             (byte-compile-lambda `(lambda ,vars . ,body) nil (length env))))
-      (cl-assert (> (length env) 0))       ;Otherwise, we don't need a closure.
+      (cl-assert (or (> (length env) 0)
+                    docstring-exp))    ;Otherwise, we don't need a closure.
       (cl-assert (byte-code-function-p fun))
       (byte-compile-form `(make-byte-code
                            ',(aref fun 0) ',(aref fun 1)
                            (vconcat (vector . ,env) ',(aref fun 2))
-                           ,@(nthcdr 3 (mapcar (lambda (x) `',x) fun)))))))
+                           ,@(let ((rest (nthcdr 3 (mapcar (lambda (x) `',x) 
fun))))
+                               (if docstring-exp
+                                   `(,(car rest)
+                                     ,docstring-exp
+                                     ,@(cddr rest))
+                                 rest)))))))
 
 (defun byte-compile-get-closed-var (form)
   "Byte-compile the special `internal-get-closed-var' form."
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index e9d33e6..fa82407 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -48,7 +48,7 @@
 ;; if the function is suitable for lambda lifting (if all calls are known)
 ;;
 ;; (lambda (v0 ...) ... fv0 .. fv1 ...)  =>
-;; (internal-make-closure (v0 ...) (fv1 ...)
+;; (internal-make-closure (v0 ...) (fv0 ...) <doc>
 ;;   ... (internal-get-closed-var 0) ...  (internal-get-closed-var 1) ...)
 ;;
 ;; If the function has no free variables, we don't do anything.
@@ -65,6 +65,14 @@
 ;;
 ;;; Code:
 
+;; PROBLEM cases found during conversion to lexical binding.
+;; We should try and detect and warn about those cases, even
+;; for lexical-binding==nil to help prepare the migration.
+;; - Uses of run-hooks, and friends.
+;; - Cases where we want to apply the same code to different vars depending on
+;;   some test.  These sometimes use a (let ((foo (if bar 'a 'b)))
+;;   ... (symbol-value foo) ... (set foo ...)).
+
 ;; TODO: (not just for cconv but also for the lexbind changes in general)
 ;; - let (e)debug find the value of lexical variables from the stack.
 ;; - make eval-region do the eval-sexp-add-defvars dance.
@@ -87,9 +95,8 @@
 ;;   the bytecomp only compiles it once.
 ;; - Since we know here when a variable is not mutated, we could pass that
 ;;   info to the byte-compiler, e.g. by using a new `immutable-let'.
-;; - add tail-calls to bytecode.c and the byte compiler.
 ;; - call known non-escaping functions with `goto' rather than `call'.
-;; - optimize mapcar to a while loop.
+;; - optimize mapc to a dolist loop.
 
 ;; (defmacro dlet (binders &rest body)
 ;;   ;; Works in both lexical and non-lexical mode.
@@ -195,7 +202,7 @@ Returns a form where all lambdas don't have any free 
variables."
       (unless (memq (car b) s) (push b res)))
     (nreverse res)))
 
-(defun cconv--convert-function (args body env parentform)
+(defun cconv--convert-function (args body env parentform &optional docstring)
   (cl-assert (equal body (caar cconv-freevars-alist)))
   (let* ((fvs (cdr (pop cconv-freevars-alist)))
          (body-new '())
@@ -240,11 +247,11 @@ Returns a form where all lambdas don't have any free 
variables."
               `(,@(nreverse special-forms) (let ,letbind . ,body-new)))))
 
     (cond
-     ((null envector)                   ;if no freevars - do nothing
+     ((not (or envector docstring))     ;If no freevars - do nothing.
       `(function (lambda ,args . ,body-new)))
      (t
       `(internal-make-closure
-        ,args ,envector . ,body-new)))))
+        ,args ,envector ,docstring . ,body-new)))))
 
 (defun cconv-convert (form env extend)
   ;; This function actually rewrites the tree.
@@ -407,7 +414,9 @@ places where they originally did not directly appear."
                        cond-forms)))
 
     (`(function (lambda ,args . ,body) . ,_)
-     (cconv--convert-function args body env form))
+     (let ((docstring (if (eq :documentation (car-safe (car body)))
+                          (cconv-convert (cadr (pop body)) env extend))))
+       (cconv--convert-function args body env form docstring)))
 
     (`(internal-make-closure . ,_)
      (byte-compile-report-error
@@ -533,7 +542,7 @@ FORM is the parent form that binds this var."
   ;; use = `(,binder ,read ,mutated ,captured ,called)
   (pcase vardata
     (`(,_ nil nil nil nil) nil)
-    (`((,(and (pred (lambda (var) (eq ?_ (aref (symbol-name var) 0)))) var) . 
,_)
+    (`((,(and var (guard (eq ?_ (aref (symbol-name var) 0)))) . ,_)
        ,_ ,_ ,_ ,_)
      (byte-compile-log-warning
       (format "%s `%S' not left unused" varkind var))))
@@ -643,6 +652,8 @@ and updates the data stored in ENV."
          (cconv--analyze-use vardata form "variable"))))
 
     (`(function (lambda ,vrs . ,body-forms))
+     (when (eq :documentation (car-safe (car body-forms)))
+       (cconv-analyze-form (cadr (pop body-forms)) env))
      (cconv--analyze-function vrs body-forms env form))
 
     (`(setq . ,forms)
@@ -665,6 +676,10 @@ and updates the data stored in ENV."
      (dolist (forms cond-forms)
        (dolist (form forms) (cconv-analyze-form form env))))
 
+    ;; ((and `(quote ,v . ,_) (guard (assq v env)))
+    ;;  (byte-compile-log-warning
+    ;;   (format "Possible confusion variable/symbol for `%S'" v)))
+
     (`(quote . ,_) nil)                 ; quote form
     (`(function . ,_) nil)              ; same as quote
 
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 46585ee..fcf02b9 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -290,8 +290,7 @@ constructor functions are considered valid.
 Second, any text properties will be stripped from strings."
   (cond ((consp proposed-value)
         ;; Lists with something in them need special treatment.
-        (let ((slot-idx (eieio--slot-name-index class
-                                                 nil slot))
+        (let ((slot-idx (eieio--slot-name-index class slot))
               (type nil)
               (classtype nil))
           (setq slot-idx (- slot-idx
diff --git a/lisp/emacs-lisp/eieio-compat.el b/lisp/emacs-lisp/eieio-compat.el
index fcca99d..7468c04 100644
--- a/lisp/emacs-lisp/eieio-compat.el
+++ b/lisp/emacs-lisp/eieio-compat.el
@@ -188,11 +188,10 @@ Summary:
                 (args (help-function-arglist code 'preserve-names))
                 (doc-only (if docstring
                               (let ((split (help-split-fundoc docstring nil)))
-                                (if split (cdr split) docstring))))
-                (new-docstring (help-add-fundoc-usage doc-only
-                                                      (cons 'cl-cnm args))))
-           ;; FIXME: ¡Add new-docstring to those closures!
+                                (if split (cdr split) docstring)))))
            (lambda (cnm &rest args)
+             (:documentation
+              (help-add-fundoc-usage doc-only (cons 'cl-cnm args)))
              (cl-letf (((symbol-function 'call-next-method) cnm)
                        ((symbol-function 'next-method-p)
                         (lambda () (cl--generic-isnot-nnm-p cnm))))
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 77d8c01..fa8fefa 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -288,16 +288,17 @@ It creates an autoload function for CNAME's constructor."
 
 (defun eieio-make-class-predicate (class)
   (lambda (obj)
-    ;; (:docstring (format "Test OBJ to see if it's an object of type %S."
-    ;;                     class))
+    (:documentation
+     (format "Return non-nil if OBJ is an object of type `%S'.\n\n(fn OBJ)"
+             class))
     (and (eieio-object-p obj)
          (same-class-p obj class))))
 
 (defun eieio-make-child-predicate (class)
   (lambda (obj)
-    ;; (:docstring (format
-    ;;              "Test OBJ to see if it's an object is a child of type %S."
-    ;;              class))
+    (:documentation
+     (format "Return non-nil if OBJ is an object of type `%S' or a subclass.
+\n(fn OBJ)" class))
     (and (eieio-object-p obj)
          (object-of-class-p obj class))))
 
@@ -312,8 +313,7 @@ See `defclass' for more information."
   (run-hooks 'eieio-hook)
   (setq eieio-hook nil)
 
-  (let* ((pname superclasses)
-        (oldc (let ((c (eieio--class-v cname))) (if (eieio--class-p c) c)))
+  (let* ((oldc (let ((c (eieio--class-v cname))) (if (eieio--class-p c) c)))
         (newc (if (and oldc (not (eieio--class-default-object-cache oldc)))
                    ;; The oldc class is a stub setup by 
eieio-defclass-autoload.
                    ;; Reuse it instead of creating a new one, so that existing
@@ -338,9 +338,9 @@ See `defclass' for more information."
           (setf (eieio--class-children newc) children)
          (remhash cname eieio-defclass-autoload-map))))
 
-    (if pname
+    (if superclasses
        (progn
-         (dolist (p pname)
+         (dolist (p superclasses)
            (if (not (and p (symbolp p)))
                (error "Invalid parent class %S" p)
               (let ((c (eieio--class-v p)))
@@ -396,7 +396,7 @@ See `defclass' for more information."
 
     ;; Before adding new slots, let's add all the methods and classes
     ;; in from the parent class.
-    (eieio-copy-parents-into-subclass newc superclasses)
+    (eieio-copy-parents-into-subclass newc)
 
     ;; Store the new class vector definition into the symbol.  We need to
     ;; do this first so that we can call defmethod for the accessor.
@@ -784,7 +784,7 @@ if default value is nil."
        ))
     ))
 
-(defun eieio-copy-parents-into-subclass (newc _parents)
+(defun eieio-copy-parents-into-subclass (newc)
   "Copy into NEWC the slots of PARENTS.
 Follow the rules of not overwriting early parents when applying to
 the new child class."
@@ -911,7 +911,7 @@ Argument FN is the function calling this verifier."
                          (if (eieio--class-p c) (eieio-class-un-autoload obj))
                          c))
                       (t (eieio--object-class-object obj))))
-        (c (eieio--slot-name-index class obj slot)))
+        (c (eieio--slot-name-index class slot)))
     (if (not c)
        ;; It might be missing because it is a :class allocated slot.
        ;; Let's check that info out.
@@ -935,7 +935,7 @@ Fills in OBJ's SLOT with its default value."
   (cl-check-type slot symbol)
   (let* ((cl (cond ((symbolp obj) (eieio--class-v obj))
                    (t (eieio--object-class-object obj))))
-        (c (eieio--slot-name-index cl obj slot)))
+        (c (eieio--slot-name-index cl slot)))
     (if (not c)
        ;; It might be missing because it is a :class allocated slot.
        ;; Let's check that info out.
@@ -973,7 +973,7 @@ Fills in OBJ's SLOT with VALUE."
   (cl-check-type obj eieio-object)
   (cl-check-type slot symbol)
   (let* ((class (eieio--object-class-object obj))
-         (c (eieio--slot-name-index class obj slot)))
+         (c (eieio--slot-name-index class slot)))
     (if (not c)
        ;; It might be missing because it is a :class allocated slot.
        ;; Let's check that info out.
@@ -997,7 +997,7 @@ Fills in the default value in CLASS' in SLOT with VALUE."
   (setq class (eieio--class-object class))
   (cl-check-type class eieio--class)
   (cl-check-type slot symbol)
-  (let* ((c (eieio--slot-name-index class nil slot)))
+  (let* ((c (eieio--slot-name-index class slot)))
     (if (not c)
         ;; It might be missing because it is a :class allocated slot.
         ;; Let's check that info out.
@@ -1021,12 +1021,9 @@ Fills in the default value in CLASS' in SLOT with VALUE."
 
 ;;; EIEIO internal search functions
 ;;
-(defun eieio--slot-name-index (class obj slot)
-  "In CLASS for OBJ find the index of the named SLOT.
-The slot is a symbol which is installed in CLASS by the `defclass'
-call.  OBJ can be nil, but if it is an object, and the slot in question
-is protected, access will be allowed if OBJ is a child of the currently
-scoped class.
+(defun eieio--slot-name-index (class slot)
+  "In CLASS find the index of the named SLOT.
+The slot is a symbol which is installed in CLASS by the `defclass' call.
 If SLOT is the value created with :initarg instead,
 reverse-lookup that name, and recurse with the associated slot value."
   ;; Removed checks to outside this call
@@ -1035,7 +1032,7 @@ reverse-lookup that name, and recurse with the associated 
slot value."
     (if (integerp fsi)
         (+ (eval-when-compile eieio--object-num-slots) fsi)
       (let ((fn (eieio--initarg-to-attribute class slot)))
-       (if fn (eieio--slot-name-index class obj fn) nil)))))
+       (if fn (eieio--slot-name-index class fn) nil)))))
 
 (defun eieio--class-slot-name-index (class slot)
   "In CLASS find the index of the named SLOT.
@@ -1255,7 +1252,7 @@ method invocation orders of the involved classes."
             (eieio--class-precedence-list tag))))
 
 
-;;;### (autoloads nil "eieio-compat" "eieio-compat.el" 
"b568ffb3c90ed5d0ae673f0051d608ee")
+;;;### (autoloads nil "eieio-compat" "eieio-compat.el" 
"5b04c9a8fff2bd3f3d3ac54aba0f65b7")
 ;;; Generated autoloads from eieio-compat.el
 
 (autoload 'eieio--defalias "eieio-compat" "\
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 67cd44d..c3a2061 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -161,6 +161,7 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'subr-x))
 (eval-when-compile (require 'cl-lib))
 (eval-when-compile (require 'epg))      ;For setf accessors.
 
@@ -1510,6 +1511,11 @@ with PKG-DESC entry removed."
                (and (memq pkg (mapcar #'car (package-desc-reqs (cadr p))))
                     (car p))))))
 
+(defun package--newest-p (pkg)
+  "Return t if PKG is the newest package with its name."
+  (equal (cadr (assq (package-desc-name pkg) package-alist))
+         pkg))
+
 (defun package-delete (pkg-desc &optional force nosave)
   "Delete package PKG-DESC.
 
@@ -1527,7 +1533,10 @@ If NOSAVE is non-nil, the package is not removed from
     ;; don't want it marked as selected, so we remove it from
     ;; `package-selected-packages' even if it can't be deleted.
     (when (and (null nosave)
-               (package--user-selected-p name))
+               (package--user-selected-p name)
+               ;; Don't delesect if this is an older version of an
+               ;; upgraded package.
+               (package--newest-p pkg-desc))
       (customize-save-variable
        'package-selected-packages (remove name package-selected-packages)))
     (cond ((not (string-prefix-p (file-name-as-directory
@@ -2262,7 +2271,7 @@ If optional arg BUTTON is non-nil, describe its 
associated package."
 (defun package-menu-mark-install (&optional _num)
   "Mark a package for installation and move to the next line."
   (interactive "p")
-  (if (member (package-menu-get-status) '("available" "new"))
+  (if (member (package-menu-get-status) '("available" "new" "dependency"))
       (tabulated-list-put-tag "I" t)
     (forward-line)))
 
@@ -2351,6 +2360,40 @@ call will upgrade the package."
                (length upgrades)
                (if (= (length upgrades) 1) "" "s")))))
 
+(defun package--sort-deps-in-alist (package only)
+  "Return a list of dependencies for PACKAGE sorted by dependency.
+PACKAGE is included as the first element of the returned list.
+ONLY is an alist associating package names to package objects.
+Only these packages will be in the return value an their cdrs are
+destructively set to nil in ONLY."
+  (let ((out))
+    (dolist (dep (package-desc-reqs package))
+      (when-let ((cell (assq (car dep) only))
+                 (dep-package (cdr-safe cell)))
+        (setcdr cell nil)
+        (setq out (append (package--sort-deps-in-alist dep-package only)
+                          out))))
+    (cons package out)))
+
+(defun package--sort-by-dependence (package-list)
+  "Return PACKAGE-LIST sorted by dependence.
+That is, any element of the returned list is guaranteed to not
+directly depend on any elements that come before it.
+
+PACKAGE-LIST is a list of package-desc objects.
+Indirect dependencies are guaranteed to be returned in order only
+if all the in-between dependencies are also in PACKAGE-LIST."
+  (let ((alist (mapcar (lambda (p) (cons (package-desc-name p) p)) 
package-list))
+        out-list)
+    (dolist (cell alist out-list)
+      ;; `package--sort-deps-in-alist' destructively changes alist, so
+      ;; some cells might already be empty.  We check this here.
+      (when-let ((pkg-desc (cdr cell)))
+        (setcdr cell nil)
+        (setq out-list
+              (append (package--sort-deps-in-alist pkg-desc alist)
+                      out-list))))))
+
 (defun package-menu-execute (&optional noquery)
   "Perform marked Package Menu actions.
 Packages marked for installation are downloaded and installed;
@@ -2384,7 +2427,13 @@ Optional argument NOQUERY non-nil means do not ask the 
user to confirm."
                       (mapconcat #'package-desc-full-name
                                  install-list ", ")))))
           (mapc (lambda (p)
-                  (package-install p (null (package-installed-p p))))
+                  ;; Mark as selected if it's the exact version of a
+                  ;; package that's already installed, or if it's not
+                  ;; installed at all.  Don't mark if it's a new
+                  ;; version of an installed package.
+                  (package-install p (or (package-installed-p p)
+                                         (not (package-installed-p
+                                               (package-desc-name p))))))
                 install-list)))
     ;; Delete packages, prompting if necessary.
     (when delete-list
@@ -2398,7 +2447,7 @@ Optional argument NOQUERY non-nil means do not ask the 
user to confirm."
                      (length delete-list)
                      (mapconcat #'package-desc-full-name
                                 delete-list ", ")))))
-          (dolist (elt delete-list)
+          (dolist (elt (package--sort-by-dependence delete-list))
             (condition-case-unless-debug err
                 (package-delete elt)
               (error (message (cadr err)))))
@@ -2412,7 +2461,8 @@ Optional argument NOQUERY non-nil means do not ask the 
user to confirm."
                       (format "These %d packages are no longer needed, delete 
them (%s)? "
                               (length removable)
                               (mapconcat #'symbol-name removable ", "))))
-            (mapc (lambda (p) (package-delete (cadr (assq p package-alist))))
+            ;; We know these are removable, so we can use force instead of 
sorting them.
+            (mapc (lambda (p) (package-delete (cadr (assq p package-alist)) 
'force 'nosave))
                   removable))))
       (package-menu--generate t t))))
 
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index b28153b..025d94e 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -2,9 +2,9 @@
 
 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
 
-;; Author: Nicolas Petton <address@hidden>
+;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: sequences
-;; Version: 1.0
+;; Version: 1.1
 
 ;; Maintainer: address@hidden
 
@@ -92,14 +92,14 @@ returned."
     (seq-subseq seq 0 (min (max n 0) (seq-length seq)))))
 
 (defun seq-drop-while (pred seq)
-  "Return a sequence, from the first element for which (PRED element) is nil, 
of SEQ.
+  "Return a sequence from the first element for which (PRED element) is nil in 
SEQ.
 The result is a sequence of the same type as SEQ."
   (if (listp seq)
       (seq--drop-while-list pred seq)
     (seq-drop seq (seq--count-successive pred seq))))
 
 (defun seq-take-while (pred seq)
-  "Return a sequence of the successive elements for which (PRED element) is 
non-nil in SEQ.
+  "Return the successive elements for which (PRED element) is non-nil in SEQ.
 The result is a sequence of the same type as SEQ."
   (if (listp seq)
       (seq--take-while-list pred seq)
@@ -152,7 +152,7 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not 
called."
     t))
 
 (defun seq-count (pred seq)
-  "Return the number of elements for which (PRED element) returns non-nil in 
seq."
+  "Return the number of elements for which (PRED element) is non-nil in SEQ."
   (let ((count 0))
     (seq-doseq (elt seq)
       (when (funcall pred elt)
@@ -224,15 +224,50 @@ TYPE must be one of following symbols: vector, string or 
list.
     (`list (apply #'append (append seqs '(nil))))
     (t (error "Not a sequence type name: %s" type))))
 
+(defun seq-mapcat (function seq &optional type)
+  "Concatenate the result of applying FUNCTION to each element of SEQ.
+The result is a sequence of type TYPE, or a list if TYPE is nil."
+  (apply #'seq-concatenate (or type 'list)
+         (seq-map function seq)))
+
+(defun seq-partition (seq n)
+  "Return a list of the elements of SEQ grouped into sub-sequences of length N.
+The last sequence may contain less than N elements.  If N is a
+negative integer or 0, nil is returned."
+  (unless (< n 1)
+    (let ((result '()))
+      (while (not (seq-empty-p seq))
+        (push (seq-take seq n) result)
+        (setq seq (seq-drop seq n)))
+      (nreverse result))))
+
+(defun seq-group-by (function seq)
+  "Apply FUNCTION to each element of SEQ.
+Separate the elements of SEQ into an alist using the results as
+keys.  Keys are compared using `equal'."
+  (nreverse
+   (seq-reduce
+    (lambda (acc elt)
+      (let* ((key (funcall function elt))
+             (cell (assoc key acc)))
+        (if cell
+            (setcdr cell (push elt (cdr cell)))
+          (push (list key elt) acc))
+        acc))
+    seq
+    nil)))
+
 (defun seq--drop-list (list n)
-  "Optimized version of `seq-drop' for lists."
+  "Return a list from LIST without its first N elements.
+This is an optimization for lists in `seq-drop'."
   (while (and list (> n 0))
     (setq list (cdr list)
           n (1- n)))
   list)
 
 (defun seq--take-list (list n)
-  "Optimized version of `seq-take' for lists."
+  "Return a list from LIST made of its first N elements.
+This is an optimization for lists in `seq-take'."
   (let ((result '()))
     (while (and list (> n 0))
       (setq n (1- n))
@@ -240,13 +275,15 @@ TYPE must be one of following symbols: vector, string or 
list.
     (nreverse result)))
 
 (defun seq--drop-while-list (pred list)
-  "Optimized version of `seq-drop-while' for lists."
+  "Return a list from the first element for which (PRED element) is nil in 
LIST.
+This is an optimization for lists in `seq-drop-while'."
   (while (and list (funcall pred (car list)))
     (setq list (cdr list)))
   list)
 
 (defun seq--take-while-list (pred list)
-  "Optimized version of `seq-take-while' for lists."
+  "Return the successive elements for which (PRED element) is non-nil in LIST.
+This is an optimization for lists in `seq-take-while'."
   (let ((result '()))
     (while (and list (funcall pred (car list)))
       (push (pop list) result))
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index e41109a..bd03a87 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -961,11 +961,11 @@ Suffixes such as .el or .elc should be stripped."
 (defun viper-ESC (arg)
   "Emulate ESC key in Emacs.
 Prevents multiple escape keystrokes if viper-no-multiple-ESC is true.
-If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
+If `viper-no-multiple-ESC' is `twice' double ESC would ding in vi-state.
 Other ESC sequences are emulated via the current Emacs's major mode
 keymap.  This is more convenient on TTYs, since this won't block
 function keys such as up, down, etc.  ESC will also will also work as
-a Meta key in this case.  When viper-no-multiple-ESC is nil, ESC works
+a Meta key in this case.  When `viper-no-multiple-ESC' is nil, ESC works
 as a Meta key and any number of multiple escapes are allowed."
   (interactive "P")
   (let (char)
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 179ae16..250c292 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -60,13 +60,13 @@ Full Vi compatibility is not recommended for power use of 
Viper."
   :group 'viper)
 
 (defcustom viper-no-multiple-ESC  t
-  "If true, multiple ESC in Vi mode will cause bell to ring.
-This is set to t on a windowing terminal and to 'twice on a dumb
+  "If non-nil, multiple ESC in Vi mode will cause bell to ring.
+This is set to t on a windowing terminal and to `twice' on a dumb
 terminal (unless the user level is 1, 2, or 5).  On a dumb terminal, this
 enables cursor keys and is generally more convenient, as terminals usually
 don't have a convenient Meta key.
-Setting viper-no-multiple-ESC to nil will allow as many multiple ESC,
-as is allowed by the major mode in effect."
+Setting it to nil will allow as many multiple ESC, as is allowed by the
+major mode in effect."
   :type 'boolean
   :group 'viper)
 
diff --git a/lisp/faces.el b/lisp/faces.el
index 22bf262..ce74c72 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2092,8 +2092,7 @@ frame parameters in PARAMETERS."
             (value (cdr (assq param-name parameters))))
        (if value
            (set-face-attribute (nth 1 param) frame
-                               (nth 2 param) value))))
-    (frame-can-run-window-configuration-change-hook frame t)))
+                               (nth 2 param) value))))))
 
 (defun tty-handle-reverse-video (frame parameters)
   "Handle the reverse-video frame parameter for terminal frames."
diff --git a/lisp/frame.el b/lisp/frame.el
index 1d5bbf2..ecb433e 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -465,6 +465,16 @@ there (in decreasing order of priority)."
                (frame-set-background-mode frame-initial-frame))
              (face-set-after-frame-default frame-initial-frame)
              (setq newparms (delq new-bg newparms)))
+
+           (when (numberp (car frame-size-history))
+             (setq frame-size-history
+                   (cons (1- (car frame-size-history))
+                         (cons
+                          (list frame-initial-frame
+                                "frame-notice-user-settings"
+                                nil newparms)
+                          (cdr frame-size-history)))))
+
            (modify-frame-parameters frame-initial-frame newparms)))))
 
     ;; Restore the original buffer.
@@ -686,7 +696,7 @@ the new frame according to its own rules."
     ;; Now make the frame.
     (run-hooks 'before-make-frame-hook)
 
-;;     (setq frame-adjust-size-history '(t))
+;;     (setq frame-size-history '(1000))
 
     (setq frame
           (funcall (gui-method frame-creation-function w) params))
@@ -697,11 +707,14 @@ the new frame according to its own rules."
         (let ((val (frame-parameter oldframe param)))
           (when val (set-frame-parameter frame param val)))))
 
-    (when (eq (car frame-adjust-size-history) t)
-      (setq frame-adjust-size-history
-           (cons t (cons (list "Frame made")
-                         (cdr frame-adjust-size-history)))))
+    (when (numberp (car frame-size-history))
+      (setq frame-size-history
+           (cons (1- (car frame-size-history))
+                 (cons (list frame "make-frame")
+                       (cdr frame-size-history)))))
 
+    ;; We can run `window-configuration-change-hook' for this frame now.
+    (frame-after-make-frame frame t)
     (run-hook-with-args 'after-make-frame-functions frame)
     frame))
 
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 841cff5..32d3f08 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,33 @@
+2015-02-05  Teodor Zlatanov  <address@hidden>
+
+       * gnus-start.el (gnus-save-newsrc-file-check-timestamp): Remove
+       variable; always check the newrc timestamp.
+       (gnus-save-newsrc-file): Always check timestamp.
+
+2015-02-05  Timo Lilja  <address@hidden>  (tiny change)
+
+       * mail-source.el (mail-source-call-script): If scripts exit with an
+       error, pop up an error buffer.
+
+2015-02-05  Lars Ingebrigtsen  <address@hidden>
+
+       * gnus-sum.el (gnus-extra-headers): Add the popular Gmail X-GM-LABELS
+       as a default.
+
+       * nnimap.el (nnimap-request-group-scan): Ensure that we've selected the
+       correct server.
+
+2015-02-05  Vincent Bernat  <address@hidden>  (tiny change)
+
+       * nnimap.el (nnimap-request-group-scan): Fix the function name.
+
+       * gnus-int.el (gnus-request-group-scan): Use the correct function name.
+
+2015-02-05  Lars Ingebrigtsen  <address@hidden>
+
+       * gnus-sum.el (gnus-select-newsgroup): Pass the group info along so
+       that nnimap works for non-activated backends.
+
 2015-02-04  Stefan Monnier  <address@hidden>
 
        * mm-util.el (mm-with-unibyte-current-buffer): Don't emit a warning
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el
index dd938ce..4e870bb 100644
--- a/lisp/gnus/gnus-int.el
+++ b/lisp/gnus/gnus-int.el
@@ -442,7 +442,7 @@ If it is down, start it up (again)."
 (defun gnus-request-group-scan (group info)
   "Request that GROUP get a complete rescan."
   (let ((gnus-command-method (gnus-find-method-for-group group))
-       (func 'request-group-description))
+       (func 'request-group-scan))
     (when (gnus-check-backend-function func group)
       (funcall (gnus-get-function gnus-command-method func)
               (gnus-group-real-name group) (nth 1 gnus-command-method) info))))
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index aa2568d..0c0246a 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -442,15 +442,6 @@ See also `gnus-before-startup-hook'."
   :group 'gnus-newsrc
   :type 'hook)
 
-(defcustom gnus-save-newsrc-file-check-timestamp nil
-  "Check the modification time of the newsrc.eld file before saving it.
-When the newsrc.eld file is updated by multiple machines,
-checking the file's modification time is a good way to avoid
-overwriting updated data."
-  :version "25.1"
-  :group 'gnus-newsrc
-  :type 'boolean)
-
 (defcustom gnus-save-newsrc-hook nil
   "A hook called before saving any of the newsrc files."
   :group 'gnus-newsrc
@@ -2833,19 +2824,18 @@ If FORCE is non-nil, the .newsrc file is read."
 
           ;; check timestamp of `gnus-current-startup-file'.eld against
           ;; `gnus-save-newsrc-file-last-timestamp'
-          (when gnus-save-newsrc-file-check-timestamp
-            (let* ((checkfile (concat gnus-current-startup-file ".eld"))
-                   (mtime (nth 5 (file-attributes checkfile))))
-              (when (and gnus-save-newsrc-file-last-timestamp
-                         (time-less-p gnus-save-newsrc-file-last-timestamp
-                                      mtime))
-                (unless (y-or-n-p
-                         (format "%s was updated externally after %s, save?"
-                                 checkfile
-                                 (format-time-string
-                                  "%c"
-                                  gnus-save-newsrc-file-last-timestamp)))
-                (error "Couldn't save %s: updated externally" checkfile)))))
+          (let* ((checkfile (concat gnus-current-startup-file ".eld"))
+                 (mtime (nth 5 (file-attributes checkfile))))
+            (when (and gnus-save-newsrc-file-last-timestamp
+                       (time-less-p gnus-save-newsrc-file-last-timestamp
+                                    mtime))
+              (unless (y-or-n-p
+                       (format "%s was updated externally after %s, save?"
+                               checkfile
+                               (format-time-string
+                                "%c"
+                                gnus-save-newsrc-file-last-timestamp)))
+                (error "Couldn't save %s: updated externally" checkfile))))
 
           (if gnus-save-startup-file-via-temp-buffer
               (let ((coding-system-for-write gnus-ding-file-coding-system)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index efe7a4d..66b1050 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -1160,9 +1160,9 @@ which it may alter in any way."
   'mail-decode-encoded-address-string
   "Function used to decode addresses with encoded words.")
 
-(defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
+(defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
   "*Extra headers to parse."
-  :version "24.1"                       ; added Cc Keywords Gcc
+  :version "25.1"
   :group 'gnus-summary
   :type '(repeat symbol))
 
@@ -5620,7 +5620,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
           (mm-decode-coding-string group charset)
           (mm-decode-coding-string (gnus-status-message group) charset))))
 
-    (unless (gnus-request-group group t)
+    (unless (gnus-request-group group t nil (gnus-get-info group))
       (when (derived-mode-p 'gnus-summary-mode)
        (gnus-kill-buffer (current-buffer)))
       (error "Couldn't request group %s: %s"
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index eb05d71..94c8950 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -750,13 +750,16 @@ Deleting old (> %s day(s)) incoming mail file `%s'." diff 
bfile)
       (setq script (substring script 0 (match-beginning 0))
            background 0))
     (setq result
-         (call-process shell-file-name nil background nil
+         (call-process shell-file-name nil stderr nil
                        shell-command-switch script))
-    (when (and result
-              (not (zerop result)))
-      (set-buffer stderr)
-      (message "Mail source error: %s" (buffer-string)))
-    (kill-buffer stderr)))
+    (if (and result
+             (not (zerop result)))
+        (progn
+          (split-window-vertically)
+          (other-window 1)
+          (switch-to-buffer stderr)
+          (message "Mail source error: %s " (buffer-string)))
+      (kill-buffer stderr))))
 
 ;;;
 ;;; Different fetchers
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index e619c0f..e7f91b7 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -820,39 +820,40 @@ textual parts.")
                        group))
        t))))
 
-(deffoo nnimap-request-scan-group (group &optional server info)
+(deffoo nnimap-request-group-scan (group &optional server info)
   (setq group (nnimap-decode-gnus-group group))
-  (let (marks high low)
-    (with-current-buffer (nnimap-buffer)
-      (erase-buffer)
-      (let ((group-sequence
-            (nnimap-send-command "SELECT %S" (utf7-encode group t)))
-           (flag-sequence
-            (nnimap-send-command "UID FETCH 1:* FLAGS")))
-       (setf (nnimap-group nnimap-object) group)
-       (nnimap-wait-for-response flag-sequence)
-       (setq marks
-             (nnimap-flags-to-marks
-              (nnimap-parse-flags
-               (list (list group-sequence flag-sequence
-                           1 group "SELECT")))))
-       (when (and info
-                  marks)
-         (nnimap-update-infos marks (list info))
-         (nnimap-store-info info (gnus-active (gnus-info-group info))))
-       (goto-char (point-max))
-       (let ((uidnext (nth 5 (car marks))))
-         (setq high (or (if uidnext
-                            (1- uidnext)
-                          (nth 3 (car marks)))
-                        0)
-               low (or (nth 4 (car marks)) uidnext 1)))))
-    (with-current-buffer nntp-server-buffer
-      (erase-buffer)
-      (insert
-       (format
-       "211 %d %d %d %S\n" (1+ (- high low)) low high group))
-      t)))
+  (when (nnimap-change-group nil server)
+    (let (marks high low)
+      (with-current-buffer (nnimap-buffer)
+       (erase-buffer)
+       (let ((group-sequence
+              (nnimap-send-command "SELECT %S" (utf7-encode group t)))
+             (flag-sequence
+              (nnimap-send-command "UID FETCH 1:* FLAGS")))
+         (setf (nnimap-group nnimap-object) group)
+         (nnimap-wait-for-response flag-sequence)
+         (setq marks
+               (nnimap-flags-to-marks
+                (nnimap-parse-flags
+                 (list (list group-sequence flag-sequence
+                             1 group "SELECT")))))
+         (when (and info
+                    marks)
+           (nnimap-update-infos marks (list info))
+           (nnimap-store-info info (gnus-active (gnus-info-group info))))
+         (goto-char (point-max))
+         (let ((uidnext (nth 5 (car marks))))
+           (setq high (or (if uidnext
+                              (1- uidnext)
+                            (nth 3 (car marks)))
+                          0)
+                 low (or (nth 4 (car marks)) uidnext 1)))))
+      (with-current-buffer nntp-server-buffer
+       (erase-buffer)
+       (insert
+        (format
+         "211 %d %d %d %S\n" (1+ (- high low)) low high group))
+       t))))
 
 (deffoo nnimap-request-create-group (group &optional server args)
   (setq group (nnimap-decode-gnus-group group))
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index c0d6393..61e8d54 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -930,6 +930,37 @@ file-local variable.\n")
 
 
 ;;;###autoload
+(defun describe-function-or-variable (symbol &optional buffer frame)
+  "Display the full documentation of the function or variable SYMBOL.
+If SYMBOL is a variable and has a buffer-local value in BUFFER or FRAME
+\(default to the current buffer and current frame), it is displayed along
+with the global value."
+  (interactive
+   (let* ((v-or-f (variable-at-point))
+          (found (symbolp v-or-f))
+          (v-or-f (if found v-or-f (function-called-at-point)))
+          (found (or found v-or-f))
+          (enable-recursive-minibuffers t)
+          val)
+     (setq val (completing-read (if found
+                                   (format
+                                        "Describe function or variable 
(default %s): " v-or-f)
+                                 "Describe function or variable: ")
+                               obarray
+                               (lambda (vv)
+                                 (or (fboundp vv)
+                                     (get vv 'variable-documentation)
+                                     (and (boundp vv) (not (keywordp vv)))))
+                               t nil nil
+                               (if found (symbol-name v-or-f))))
+     (list (if (equal val "")
+              v-or-f (intern val)))))
+  (if (not (symbolp symbol)) (message "You didn't specify a function or 
variable")
+    (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
+    (unless (frame-live-p frame) (setq frame (selected-frame)))
+    (help-xref-interned symbol buffer frame)))
+
+;;;###autoload
 (defun describe-syntax (&optional buffer)
   "Describe the syntax specifications in the syntax table of BUFFER.
 The descriptions are inserted in a help buffer, which is then displayed.
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index c62ddc3..564362a 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -621,10 +621,13 @@ See `help-make-xrefs'."
 
 
 ;; Additional functions for (re-)creating types of help buffers.
-(defun help-xref-interned (symbol)
+
+;;;###autoload
+(defun help-xref-interned (symbol &optional buffer frame)
   "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
 Both variable, function and face documentation are extracted into a single
-help buffer."
+help buffer. If SYMBOL is a variable, include buffer-local value for optional
+BUFFER or FRAME."
   (with-current-buffer (help-buffer)
     ;; Push the previous item on the stack before clobbering the output buffer.
     (help-setup-xref nil nil)
@@ -640,7 +643,7 @@ help buffer."
                          (get symbol 'variable-documentation))
                  ;; Don't record the current entry in the stack.
                  (setq help-xref-stack-item nil)
-                 (describe-variable symbol))))
+                 (describe-variable symbol buffer frame))))
       (cond
        (sdoc
        ;; We now have a help buffer on the variable.
diff --git a/lisp/help.el b/lisp/help.el
index bf72425..fb1719a 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -95,6 +95,7 @@
     (define-key map "k" 'describe-key)
     (define-key map "l" 'view-lossage)
     (define-key map "m" 'describe-mode)
+    (define-key map "o" 'describe-function-or-variable)
     (define-key map "n" 'view-emacs-news)
     (define-key map "p" 'finder-by-keyword)
     (define-key map "P" 'describe-package)
@@ -218,6 +219,7 @@ L LANG-ENV  Describes a specific language environment, or 
RET for current.
 m           Display documentation of current minor modes and current major 
mode,
               including their special commands.
 n           Display news of recent Emacs changes.
+o SYMBOL    Display the given function or variable's documentation and value.
 p TOPIC     Find packages matching a given topic keyword.
 P PACKAGE   Describe the given Emacs Lisp package.
 r           Display the Emacs manual in Info mode.
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 9e527f1..e6d6a3e 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -380,6 +380,7 @@ call."
     (define-key map "a-" 'image-decrease-speed)
     (define-key map "a0" 'image-reset-speed)
     (define-key map "ar" 'image-reverse-speed)
+    (define-key map "k" 'image-kill-buffer)
     (define-key map [remap forward-char] 'image-forward-hscroll)
     (define-key map [remap backward-char] 'image-backward-hscroll)
     (define-key map [remap right-char] 'image-forward-hscroll)
@@ -722,6 +723,11 @@ the image by calling `image-mode'."
       (image-mode-as-text)
     (image-mode)))
 
+(defun image-kill-buffer ()
+  "Kill the current buffer."
+  (interactive)
+  (kill-buffer (current-buffer)))
+
 (defun image-after-revert-hook ()
   (when (image-get-display-property)
     (image-toggle-display-text)
diff --git a/lisp/json.el b/lisp/json.el
index 68ab020..98974e6 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -166,7 +166,7 @@ without indentation.")
   "Advance past the character at point, returning it."
   (let ((char (json-peek)))
     (if (eq char :json-eof)
-        (signal 'end-of-file nil)
+        (signal 'json-end-of-file nil)
       (json-advance)
       char)))
 
@@ -186,6 +186,8 @@ without indentation.")
 (define-error 'json-string-format "Bad string format" 'json-error)
 (define-error 'json-key-format "Bad JSON object key" 'json-error)
 (define-error 'json-object-format "Bad JSON object" 'json-error)
+(define-error 'json-end-of-file "End of file while parsing JSON"
+  '(end-of-file json-error))
 
 
 
@@ -554,7 +556,7 @@ Advances point just past JSON object."
           (if (functionp (car record))
               (apply (car record) (cdr record))
             (signal 'json-readtable-error record)))
-      (signal 'end-of-file nil))))
+      (signal 'json-end-of-file nil))))
 
 ;; Syntactic sugar for the reader
 
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index a77fc3c..1df975a 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -546,8 +546,8 @@ not their associated values.
   `auth' is one of the symbols `simple', `krbv41' or `krbv42'.
   `base' is the base for the search as described in RFC 1779.
   `scope' is one of the three symbols `sub', `base' or `one'.
-  `binddn' is the distinguished name of the user to bind as (in RFC 1779 
syntax).
-  `auth' is one of the symbols `simple', `krbv41' or `krbv42'
+  `binddn' is the distinguished name of the user to bind as (in
+RFC 1779 syntax).
   `passwd' is the password to use for simple authentication.
   `deref' is one of the symbols `never', `always', `search' or `find'.
   `timelimit' is the timeout limit for the connection in seconds.
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index e7b3150..0104fa7 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -374,10 +374,12 @@ asynchronously, if possible."
          (when (re-search-forward eoc nil t)
            (goto-char (match-beginning 0))
            (delete-region (point-min) (line-beginning-position))))
-       (let* ((capability-command (plist-get parameters :capability-command)))
+       (let ((capability-command (plist-get parameters :capability-command))
+             (eo-capa (or (plist-get parameters :end-of-capability)
+                          eoc)))
          (list stream
                (network-stream-get-response stream start eoc)
-               (network-stream-command stream capability-command eoc)
+               (network-stream-command stream capability-command eo-capa)
                'tls))))))
 
 (defun network-stream-open-shell (name buffer host service parameters)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index e307eac..172a563 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1451,6 +1451,38 @@ unless optional argument SOFT is non-nil."
                    (end-of-line 0)
                    (insert comend))))))))))))
 
+;;;###autoload
+(defun comment-line (n)
+  "Comment or uncomment current line and leave point after it.
+With positive prefix, apply to N lines including current one.
+With negative prefix, apply to -N lines above.  Also, further
+consecutive invocations of this command will inherit the negative
+argument.
+
+If region is active, comment lines in active region instead.
+Unlike `comment-dwim', this always comments whole lines."
+  (interactive "p")
+  (if (use-region-p)
+      (comment-or-uncomment-region
+       (save-excursion
+         (goto-char (region-beginning))
+         (line-beginning-position))
+       (save-excursion
+         (goto-char (region-end))
+         (line-end-position)))
+    (when (and (eq last-command 'comment-line-backward)
+               (natnump n))
+      (setq n (- n)))
+    (let ((range
+           (list (line-beginning-position)
+                 (goto-char (line-end-position n)))))
+      (comment-or-uncomment-region
+       (apply #'min range)
+       (apply #'max range)))
+    (forward-line 1)
+    (back-to-indentation)
+    (unless (natnump n) (setq this-command 'comment-line-backward))))
+
 (provide 'newcomment)
 
 ;;; newcomment.el ends here
diff --git a/lisp/outline.el b/lisp/outline.el
index ae31b80..059ca62 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -777,7 +777,12 @@ Show the heading too, if it is currently invisible."
   (save-excursion
     (outline-back-to-heading t)
     (outline-flag-region (1- (point))
-                         (progn (outline-next-preface) (point)) nil)))
+                         (progn
+                           (outline-next-preface)
+                           (if (= 1 (- (point-max) (point)))
+                               (point-max)
+                             (point)))
+                         nil)))
 
 (define-obsolete-function-alias
     'show-entry 'outline-show-entry "25.1")
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index b4c3c59..df06d5a 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -462,22 +462,22 @@ FILE is created there."
 ;;        `gamegrid-add-score' was supposed to be used in the past and
 ;;        is covered here for backward-compatibility.
 ;;
-;;     2. The helper program "update-game-score" is setuid and the
-;;        file FILE does already exist in a system wide shared game
-;;        directory.  This should be the normal case on POSIX systems,
-;;        if the game was installed system wide.  Use
+;;     2. The helper program "update-game-score" is setgid or setuid
+;;        and the file FILE does already exist in a system wide shared
+;;        game directory.  This should be the normal case on POSIX
+;;        systems, if the game was installed system wide.  Use
 ;;        "update-game-score" to add the score to the file in the
 ;;        shared game directory.
 ;;
-;;     3. "update-game-score" is setuid, but the file FILE does *not*
-;;        exist in the system wide shared game directory.  Use
+;;     3. "update-game-score" is setgid/setuid, but the file FILE does
+;;        *not* exist in the system wide shared game directory.  Use
 ;;        `gamegrid-add-score-insecure' to create--if necessary--and
 ;;        update FILE.  This is for the case that a user has installed
 ;;        a game on her own.
 ;;
-;;     4. "update-game-score" is not setuid.  Use it to create/update
-;;        FILE in the user's home directory.  There is presumably no
-;;        shared game directory.
+;;     4. "update-game-score" is not setgid/setuid.  Use it to
+;;        create/update FILE in the user's home directory.  There is
+;;        presumably no shared game directory.
 
 (defvar gamegrid-shared-game-dir)
 
@@ -491,7 +491,7 @@ FILE is created there."
           (gamegrid-add-score-insecure file score))
          ((and gamegrid-shared-game-dir
                (file-exists-p (expand-file-name file 
shared-game-score-directory)))
-          ;; Use the setuid (or setgid) "update-game-score" program
+          ;; Use the setgid (or setuid) "update-game-score" program
           ;; to update a system-wide score file.
           (gamegrid-add-score-with-update-game-score-1 file
            (expand-file-name file shared-game-score-directory) score))
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d340550..303c36c 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1068,7 +1068,9 @@ minimum."
          (levels (python-indent--calculate-levels indentation)))
     (if previous
         (python-indent--previous-level levels (current-indentation))
-      (apply #'max levels))))
+      (if levels
+          (apply #'max levels)
+        0))))
 
 (defun python-indent-line (&optional previous)
   "Internal implementation of `python-indent-line-function'.
@@ -2331,57 +2333,57 @@ goes wrong and syntax highlighting in the shell gets 
messed up."
   (interactive)
   (python-shell-with-shell-buffer
     (python-shell-font-lock-with-font-lock-buffer
-      (delete-region (point-min) (point-max)))))
+      (erase-buffer))))
 
 (defun python-shell-font-lock-comint-output-filter-function (output)
   "Clean up the font-lock buffer after any OUTPUT."
-  (when (and (not (string= "" output))
-             ;; Is end of output and is not just a prompt.
-             (not (member
-                   (python-shell-comint-end-of-output-p
-                    (ansi-color-filter-apply output))
-                   '(nil 0))))
-    ;; If output is other than an input prompt then "real" output has
-    ;; been received and the font-lock buffer must be cleaned up.
-    (python-shell-font-lock-cleanup-buffer))
+  (if (and (not (string= "" output))
+           ;; Is end of output and is not just a prompt.
+           (not (member
+                 (python-shell-comint-end-of-output-p
+                  (ansi-color-filter-apply output))
+                 '(nil 0))))
+      ;; If output is other than an input prompt then "real" output has
+      ;; been received and the font-lock buffer must be cleaned up.
+      (python-shell-font-lock-cleanup-buffer)
+    ;; Otherwise just add a newline.
+    (python-shell-font-lock-with-font-lock-buffer
+      (goto-char (point-max))
+      (newline)))
   output)
 
 (defun python-shell-font-lock-post-command-hook ()
   "Fontifies current line in shell buffer."
-  (if (eq this-command 'comint-send-input)
-      ;; Add a newline when user sends input as this may be a block.
-      (python-shell-font-lock-with-font-lock-buffer
-        (goto-char (line-end-position))
-        (newline))
-    (when (and (python-util-comint-last-prompt)
-               (> (point) (cdr (python-util-comint-last-prompt))))
-      (let ((input (buffer-substring-no-properties
-                    (cdr (python-util-comint-last-prompt)) (point-max)))
-            (old-input (python-shell-font-lock-with-font-lock-buffer
-                         (buffer-substring-no-properties
-                          (line-beginning-position) (point-max))))
-            (current-point (point))
-            (buffer-undo-list t))
-        ;; When input hasn't changed, do nothing.
-        (when (not (string= input old-input))
-          (delete-region (cdr (python-util-comint-last-prompt)) (point-max))
-          (insert
-           (python-shell-font-lock-with-font-lock-buffer
-             (delete-region (line-beginning-position)
-                            (line-end-position))
-             (insert input)
-             ;; Ensure buffer is fontified, keeping it
-             ;; compatible with Emacs < 24.4.
-             (if (fboundp 'font-lock-ensure)
-                 (funcall 'font-lock-ensure)
-               (font-lock-default-fontify-buffer))
-             ;; Replace FACE text properties with FONT-LOCK-FACE so
-             ;; they are not overwritten by comint buffer's font lock.
-             (python-util-text-properties-replace-name
-              'face 'font-lock-face)
-             (buffer-substring (line-beginning-position)
-                               (line-end-position))))
-          (goto-char current-point))))))
+  (when (and (python-util-comint-last-prompt)
+             (> (point) (cdr (python-util-comint-last-prompt))))
+    (let ((input (buffer-substring-no-properties
+                  (cdr (python-util-comint-last-prompt)) (point-max)))
+          (pos (point))
+          (buffer-undo-list t)
+          (font-lock-buffer-pos nil))
+      ;; Keep all markers untouched, this prevents `hippie-expand' and
+      ;; others from getting confused.  Bug#19650.
+      (insert-before-markers
+       (python-shell-font-lock-with-font-lock-buffer
+        (delete-region (line-beginning-position)
+                        (point-max))
+         (setq font-lock-buffer-pos (point))
+         (insert input)
+        ;; Ensure buffer is fontified, keeping it
+        ;; compatible with Emacs < 24.4.
+        (if (fboundp 'font-lock-ensure)
+            (funcall 'font-lock-ensure)
+          (font-lock-default-fontify-buffer))
+        ;; Replace FACE text properties with FONT-LOCK-FACE so
+        ;; they are not overwritten by comint buffer's font lock.
+        (python-util-text-properties-replace-name
+         'face 'font-lock-face)
+        (buffer-substring font-lock-buffer-pos
+                           (point-max))))
+      ;; Remove non-fontified original text.
+      (delete-region pos (cdr (python-util-comint-last-prompt)))
+      ;; Point should be already at pos, this is for extra safety.
+      (goto-char pos))))
 
 (defun python-shell-font-lock-turn-on (&optional msg)
   "Turn on shell font-lock.
@@ -3148,67 +3150,68 @@ With argument MSG show activation/deactivation message."
   "Get completions using native readline for PROCESS.
 When IMPORT is non-nil takes precedence over INPUT for
 completion."
-  (when (and python-shell-completion-native-enable
-             (python-util-comint-last-prompt)
-             (>= (point) (cdr (python-util-comint-last-prompt))))
-    (let* ((input (or import input))
-           (original-filter-fn (process-filter process))
-           (redirect-buffer (get-buffer-create
-                             python-shell-completion-native-redirect-buffer))
-           (separators (python-rx
-                        (or whitespace open-paren close-paren)))
-           (trigger "\t\t\t")
-           (new-input (concat input trigger))
-           (input-length
-            (save-excursion
-              (+ (- (point-max) (comint-bol)) (length new-input))))
-           (delete-line-command (make-string input-length ?\b))
-           (input-to-send (concat new-input delete-line-command)))
-      ;; Ensure restoring the process filter, even if the user quits
-      ;; or there's some other error.
-      (unwind-protect
-          (with-current-buffer redirect-buffer
-            ;; Cleanup the redirect buffer
-            (delete-region (point-min) (point-max))
-            ;; Mimic `comint-redirect-send-command', unfortunately it
-            ;; can't be used here because it expects a newline in the
-            ;; command and that's exactly what we are trying to avoid.
-            (let ((comint-redirect-echo-input nil)
-                  (comint-redirect-verbose nil)
-                  (comint-redirect-perform-sanity-check nil)
-                  (comint-redirect-insert-matching-regexp nil)
-                  ;; Feed it some regex that will never match.
-                  (comint-redirect-finished-regexp "^\\'$")
-                  (comint-redirect-output-buffer redirect-buffer))
-              ;; Compatibility with Emacs 24.x.  Comint changed and
-              ;; now `comint-redirect-filter' gets 3 args.  This
-              ;; checks which version of `comint-redirect-filter' is
-              ;; in use based on its args and uses `apply-partially'
-              ;; to make it up for the 3 args case.
-              (if (= (length
-                      (help-function-arglist 'comint-redirect-filter)) 3)
-                  (set-process-filter
-                   process (apply-partially
-                            #'comint-redirect-filter original-filter-fn))
-                (set-process-filter process #'comint-redirect-filter))
-              (process-send-string process input-to-send)
-              (accept-process-output
-               process
-               python-shell-completion-native-output-timeout)
-              ;; XXX: can't use `python-shell-accept-process-output'
-              ;; here because there are no guarantees on how output
-              ;; ends.  The workaround here is to call
-              ;; `accept-process-output' until we don't find anything
-              ;; else to accept.
-              (while (accept-process-output
-                      process
-                      python-shell-completion-native-output-timeout))
-              (cl-remove-duplicates
-               (split-string
-                (buffer-substring-no-properties
-                 (point-min) (point-max))
-                separators t))))
-        (set-process-filter process original-filter-fn)))))
+  (with-current-buffer (process-buffer process)
+    (when (and python-shell-completion-native-enable
+               (python-util-comint-last-prompt)
+               (>= (point) (cdr (python-util-comint-last-prompt))))
+      (let* ((input (or import input))
+             (original-filter-fn (process-filter process))
+             (redirect-buffer (get-buffer-create
+                               python-shell-completion-native-redirect-buffer))
+             (separators (python-rx
+                          (or whitespace open-paren close-paren)))
+             (trigger "\t\t\t")
+             (new-input (concat input trigger))
+             (input-length
+              (save-excursion
+                (+ (- (point-max) (comint-bol)) (length new-input))))
+             (delete-line-command (make-string input-length ?\b))
+             (input-to-send (concat new-input delete-line-command)))
+        ;; Ensure restoring the process filter, even if the user quits
+        ;; or there's some other error.
+        (unwind-protect
+            (with-current-buffer redirect-buffer
+              ;; Cleanup the redirect buffer
+              (delete-region (point-min) (point-max))
+              ;; Mimic `comint-redirect-send-command', unfortunately it
+              ;; can't be used here because it expects a newline in the
+              ;; command and that's exactly what we are trying to avoid.
+              (let ((comint-redirect-echo-input nil)
+                    (comint-redirect-verbose nil)
+                    (comint-redirect-perform-sanity-check nil)
+                    (comint-redirect-insert-matching-regexp nil)
+                    ;; Feed it some regex that will never match.
+                    (comint-redirect-finished-regexp "^\\'$")
+                    (comint-redirect-output-buffer redirect-buffer))
+                ;; Compatibility with Emacs 24.x.  Comint changed and
+                ;; now `comint-redirect-filter' gets 3 args.  This
+                ;; checks which version of `comint-redirect-filter' is
+                ;; in use based on its args and uses `apply-partially'
+                ;; to make it up for the 3 args case.
+                (if (= (length
+                        (help-function-arglist 'comint-redirect-filter)) 3)
+                    (set-process-filter
+                     process (apply-partially
+                              #'comint-redirect-filter original-filter-fn))
+                  (set-process-filter process #'comint-redirect-filter))
+                (process-send-string process input-to-send)
+                (accept-process-output
+                 process
+                 python-shell-completion-native-output-timeout)
+                ;; XXX: can't use `python-shell-accept-process-output'
+                ;; here because there are no guarantees on how output
+                ;; ends.  The workaround here is to call
+                ;; `accept-process-output' until we don't find anything
+                ;; else to accept.
+                (while (accept-process-output
+                        process
+                        python-shell-completion-native-output-timeout))
+                (cl-remove-duplicates
+                 (split-string
+                  (buffer-substring-no-properties
+                   (point-min) (point-max))
+                  separators t))))
+          (set-process-filter process original-filter-fn))))))
 
 (defun python-shell-completion-get-completions (process import input)
   "Do completion at point using PROCESS for IMPORT or INPUT.
@@ -3251,20 +3254,23 @@ completion."
 Optional argument PROCESS forces completions to be retrieved
 using that one instead of current buffer's process."
   (setq process (or process (get-buffer-process (current-buffer))))
-  (let* ((last-prompt-end (cdr (python-util-comint-last-prompt)))
+  (let* ((line-start (if (derived-mode-p 'inferior-python-mode)
+                         ;; Working on a shell buffer: use prompt end.
+                         (cdr (python-util-comint-last-prompt))
+                       (line-beginning-position)))
          (import-statement
           (when (string-match-p
                  (rx (* space) word-start (or "from" "import") word-end space)
-                 (buffer-substring-no-properties last-prompt-end (point)))
-            (buffer-substring-no-properties last-prompt-end (point))))
+                 (buffer-substring-no-properties line-start (point)))
+            (buffer-substring-no-properties line-start (point))))
          (start
           (save-excursion
             (if (not (re-search-backward
                       (python-rx
                        (or whitespace open-paren close-paren string-delimiter))
-                      last-prompt-end
+                      line-start
                       t 1))
-                last-prompt-end
+                line-start
               (forward-char (length (match-string-no-properties 0)))
               (point))))
          (end (point))
@@ -3847,8 +3853,10 @@ The skeleton will be bound to python-skeleton-NAME."
   :type 'string
   :group 'python)
 
-(defvar-local python-check-custom-command nil
+(defvar python-check-custom-command nil
   "Internal use.")
+;; XXX: Avoid `defvar-local' for compat with Emacs<24.3
+(make-variable-buffer-local 'python-check-custom-command)
 
 (defun python-check (command)
   "Check a Python file (default current buffer's file).
@@ -3917,15 +3925,29 @@ See `python-check-command' for the default."
   :type 'string
   :group 'python)
 
+(defun python-eldoc--get-symbol-at-point ()
+  "Get the current symbol for eldoc.
+Returns the current symbol handling point within arguments."
+  (save-excursion
+    (let ((start (python-syntax-context 'paren)))
+      (when start
+        (goto-char start))
+      (when (or start
+                (eobp)
+                (memq (char-syntax (char-after)) '(?\ ?-)))
+        ;; Try to adjust to closest symbol if not in one.
+        (python-util-forward-comment -1)))
+    (python-info-current-symbol t)))
+
 (defun python-eldoc--get-doc-at-point (&optional force-input force-process)
   "Internal implementation to get documentation at point.
-If not FORCE-INPUT is passed then what `python-info-current-symbol'
+If not FORCE-INPUT is passed then what `python-eldoc--get-symbol-at-point'
 returns will be used.  If not FORCE-PROCESS is passed what
 `python-shell-get-process' returns is used."
   (let ((process (or force-process (python-shell-get-process))))
     (when process
       (let ((input (or force-input
-                       (python-info-current-symbol t))))
+                       (python-eldoc--get-symbol-at-point))))
         (and input
              ;; Prevent resizing the echo area when iPython is
              ;; enabled.  Bug#18794.
@@ -3945,7 +3967,7 @@ inferior Python process is updated properly."
   "Get help on SYMBOL using `help'.
 Interactively, prompt for symbol."
   (interactive
-   (let ((symbol (python-info-current-symbol t))
+   (let ((symbol (python-eldoc--get-symbol-at-point))
          (enable-recursive-minibuffers t))
      (list (read-string (if symbol
                             (format "Describe symbol (default %s): " symbol)
@@ -3954,6 +3976,17 @@ Interactively, prompt for symbol."
   (message (python-eldoc--get-doc-at-point symbol)))
 
 
+;;; Hideshow
+
+(defun python-hideshow-forward-sexp-function (arg)
+  "Python specific `forward-sexp' function for `hs-minor-mode'.
+Argument ARG is ignored."
+  arg  ; Shut up, byte compiler.
+  (python-nav-end-of-defun)
+  (unless (python-info-current-line-empty-p)
+    (backward-char)))
+
+
 ;;; Imenu
 
 (defvar python-imenu-format-item-label-function
@@ -4682,14 +4715,23 @@ Arguments START and END narrow the buffer region to 
work on."
                                                  (current-column))))
          (^ '(- (1+ (current-indentation))))))
 
-  (add-function :before-until (local 'eldoc-documentation-function)
-                #'python-eldoc-function)
-
-  (add-to-list 'hs-special-modes-alist
-               `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
-                             ,(lambda (_arg)
-                                (python-nav-end-of-defun))
-                             nil))
+  (if (null eldoc-documentation-function)
+      ;; Emacs<25
+      (setq (make-local-variable 'eldoc-documentation-function)
+            #'python-eldoc-function)
+    (add-function :before-until (local 'eldoc-documentation-function)
+                  #'python-eldoc-function))
+
+  (add-to-list
+   'hs-special-modes-alist
+   `(python-mode
+     "\\s-*\\(?:def\\|class\\)\\>"
+     ;; Use the empty string as end regexp so it doesn't default to
+     ;; "\\s)".  This way parens at end of defun are properly hidden.
+     ""
+     "#"
+     python-hideshow-forward-sexp-function
+     nil))
 
   (set (make-local-variable 'outline-regexp)
        (python-rx (* space) block-start))
diff --git a/lisp/subr.el b/lisp/subr.el
index 68cd230..deadca6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -136,8 +136,8 @@ ARGS is a list of the first N arguments to pass to FUN.
 The result is a new function which does the same as FUN, except that
 the first N arguments are fixed at the values with which this function
 was called."
-  `(closure (t) (&rest args)
-            (apply ',fun ,@(mapcar (lambda (arg) `',arg) args) args)))
+  (lambda (&rest args2)
+    (apply fun (append args args2))))
 
 (defmacro push (newelt place)
   "Add NEWELT to the list stored in the generalized variable PLACE.
@@ -316,7 +316,7 @@ Defaults to `error'."
   (unless parent (setq parent 'error))
   (let ((conditions
          (if (consp parent)
-             (apply #'nconc
+             (apply #'append
                     (mapcar (lambda (parent)
                               (cons parent
                                     (or (get parent 'error-conditions)
@@ -1274,6 +1274,7 @@ is converted into a string by expressing it in decimal."
 (set-advertised-calling-convention
  'all-completions '(string collection &optional predicate) "23.1")
 (set-advertised-calling-convention 'unintern '(name obarray) "23.3")
+(set-advertised-calling-convention 'indirect-function '(object) "25.1")
 (set-advertised-calling-convention 'redirect-frame-focus '(frame focus-frame) 
"24.3")
 (set-advertised-calling-convention 'decode-char '(ch charset) "21.4")
 (set-advertised-calling-convention 'encode-char '(ch charset) "21.4")
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index c171bd5..f6a3ca6 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1,4 +1,4 @@
-;;; css-mode.el --- Major mode to edit CSS files -*- lexical-binding: t -*-
+;;; css-mode.el --- Major mode to edit CSS files  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
 
@@ -401,11 +401,16 @@
               (cond
                ;; This is a false positive inside a string or comment.
                ((nth 8 (syntax-ppss)) nil)
+               ;; This is a false positive when encountering an
+               ;; interpolated variable (bug#19751).
+               ((eq (char-before (- (point) 1)) ?#) nil)
                ((eq (char-before) ?\})
                 (save-excursion
                   (forward-char -1)
                   (skip-chars-backward " \t")
-                  (unless (bolp) (newline))))
+                  (when (and (not (bolp))
+                             (scss-smie--not-interpolation-p))
+                    (newline))))
                (t
                 (while
                     (progn
@@ -450,7 +455,7 @@
 (defun scss-smie--not-interpolation-p ()
   (save-excursion
     (forward-char -1)
-    (or (zerop (skip-chars-backward "[:alnum:]"))
+    (or (zerop (skip-chars-backward "-[:alnum:]"))
         (not (looking-back "#{\\$" (- (point) 3))))))
 
 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index d803c16..707090a 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -1076,7 +1076,7 @@ Query all files in DIR if files is nil."
     (if (and (not files) local (not (eq local 'only-file)))
        (vc-cvs-dir-status-heuristic dir update-function)
       (if (not files) (setq files (vc-expand-dirs (list dir) 'CVS)))
-      (vc-cvs-command (current-buffer) 'async dir "-f" "status" files)
+      (vc-cvs-command (current-buffer) 'async files "-f" "status")
       ;; Alternative implementation: use the "update" command instead of
       ;; the "status" command.
       ;; (vc-cvs-command (current-buffer) 'async
diff --git a/src/ChangeLog b/src/ChangeLog
index 6b56abb..56f88f5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,117 @@
+2015-02-08  Paul Eggert  <address@hidden>
+
+       Minor tweaks to frame_size_history_add
+       * frame.c (frame_size_history_add): Don't assume length fits in 'int'.
+       Prefer XCAR and XCDR to Fcar and Fcdr when the arg is a cons.
+       (Fframe_after_make_frame): Simplify.
+       * gtkutil.c: Remove commented-out code.
+       * xfns.c (Fx_create_frame): Fix indenting.
+
+2015-02-08  Eli Zaretskii  <address@hidden>
+
+       * frame.c (Fframe_parameter): Don't replace a non-nil value of
+       foreground-color or background-color parameters with a nil value.
+       (Bug#19802)
+
+2015-02-08  Stefan Monnier  <address@hidden>
+
+       * data.c (Findirect_function): Like `symbol-function', don't signal an
+       error for void functions any more.
+
+2015-02-07  Martin Rudalics  <address@hidden>
+
+       * frame.c (frame_size_history_add): New function.
+       (frame_inhibit_resize): Consider frame_inhibit_implied_resize
+       only after frame's after_make_frame slot is true.
+       Inhibit resizing fullwidth-/height frames in one direction only.
+       Update frame_size_history.
+       (adjust_frame_size): Call frame_size_history_add.
+       (make_frame): Initalize after_make_frame slot.
+       (Fmake_terminal_frame): Adjust adjust_frame_size call.
+       (Fcan_run_window_configuration_change_hook): Rename to
+       Fframe_after_make_frame.  Set after_make_frame slot.
+       Return second argument.
+       (x_set_frame_parameters): Postpone handling fullscreen parameter
+       until after width and height parameters have been set.
+       Apply width and height changes only if can_x_set_window_size is true.
+       Update frame_size_history.
+       (Qadjust_frame_size_1, Qadjust_frame_size_2)
+       (Qadjust_frame_size_3, QEmacsFrameResize, Qframe_inhibit_resize)
+       (Qx_set_fullscreen, Qx_check_fullscreen, Qx_set_window_size_1)
+       (Qxg_frame_resized, Qxg_frame_set_char_size_1)
+       (Qxg_frame_set_char_size_2, Qxg_frame_set_char_size_3)
+       (Qxg_change_toolbar_position, Qx_net_wm_state)
+       (Qx_handle_net_wm_state, Qtb_size_cb, Qupdate_frame_tool_bar)
+       (Qfree_frame_tool_bar): New symbol for updating frame_size_history.
+       (Qtip_frame, Qterminal_frame): New symbols.
+       (Vframe_adjust_size_history): Rename to frame_size_history.
+       * frame.h (struct frame):
+       Rename can_run_window_configuration_change_hook slot to
+       after_make_frame.
+       (frame_size_history_add): Extern.
+       * gtkutil.c (xg_frame_resized): Call frame_size_history_add.
+       Don't set FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT here.
+       (xg_frame_set_char_size): Try to preserve the status of
+       fullwidth/-height frames.  Call frame_size_history_add.
+       (tb_size_cb, update_frame_tool_bar, free_frame_tool_bar)
+       (xg_change_toolbar_position): Call frame_size_history_add.
+       * w32fns.c (x_change_tool_bar_height): Handle frame's fullscreen
+       status.
+       (Fx_create_frame): Process fullscreen parameter after frame has
+       been resized.
+       (x_create_tip_frame): Pass Qtip_frame to adjust_frame_size.
+       (Fx_frame_geometry): Don't pollute pure storage.
+       * w32term.c (w32_read_socket): For WM_WINDOWPOSCHANGED,
+       WM_ACTIVATE and WM_ACTIVATEAPP set frame's visibility before
+       calling w32fullscreen_hook.  For WM_DISPLAYCHANGE call
+       w32fullscreen_hook immediately.
+       (x_fullscreen_adjust, x_check_fullscreen): Remove.
+       (w32fullscreen_hook): Call change_frame_size just as with a
+       "normal" frame resize operation.  Call do_pending_window_change.
+       (x_set_window_size): Try to handle fullwidth and fullheight more
+       accurately.  Don't rely on w32_enable_frame_resize_hack.
+       (w32_enable_frame_resize_hack): Remove variable.
+       * widget.c (EmacsFrameResize): Remove dead code.
+       Call frame_size_history_add
+       * window.c (run_window_configuration_change_hook):
+       Check f->after_make_frame instead of
+       f->can_run_window_configuration_change_hook.
+       * xfns.c (x_change_tool_bar_height): Handle frame's fullscreen status.
+       (Fx_create_frame): Process fullscreen parameter after frame has
+       been resized.
+       (Fx_frame_geometry): Don't pollute pure storage.
+       * xterm.c (x_net_wm_state, x_handle_net_wm_state):
+       Call frame_size_history_add.
+       (do_ewmh_fullscreen): Handle x_frame_normalize_before_maximize.
+       (x_check_fullscreen): Count in menubar when calling
+       XResizeWindow.  Wait for ConfigureNotify event.
+       Call frame_size_history_add.
+       (x_set_window_size_1): Remove PIXELWISE argument.  Try to handle
+       changing a fullheight frame's width or a fullwidth frame's
+       height.  Call frame_size_history_add.
+       (x_set_window_size): Simplify xg_frame_set_char_size and
+       x_set_window_size_1 calls.
+       (x_frame_normalize_before_maximize): New variable.
+
+2015-02-07  Paul Eggert  <address@hidden>
+
+       Remove no-longer-used cursor_in_echo_area code
+       * dispnew.c (set_window_cursor_after_update, update_frame_1):
+       Remove checks for negative cursor_in_echo_area, since this var is
+       a boolean, and has been a boolean for some time.  Simplify.
+       * dispnew.c (init_display):
+       * xdisp.c (message3_nolog, vmessage): Use bool for boolean.
+
+2015-02-05  Stefan Monnier  <address@hidden>
+
+       * eval.c (Ffunction): Handle the new (:documentation ...) form.
+       (syms_of_eval): Declare `:documentation'.
+
+2015-02-05  Martin Rudalics  <address@hidden>
+
+       * xdisp.c (Fwindow_text_pixel_size): Remove optional BUFFER
+       argument added on 2015-02-01.
+
 2015-02-04  Paul Eggert  <address@hidden>
 
        Remove no-longer-used two_byte_p calculations
@@ -224,8 +338,8 @@
        (x_horizontal_scroll_bar_report_motion, w32_read_socket)
        (w32_set_vertical_scroll_bar, w32_set_horizontal_scroll_bar)
        (w32_draw_window_cursor, x_new_font, x_set_offset)
-       (x_set_window_size, x_make_frame_invisible, x_iconify_frame): Use
-       bool where appropriate.
+       (x_set_window_size, x_make_frame_invisible, x_iconify_frame):
+       Use bool where appropriate.
 
        Use bool for boolean in w32fns.c
        * w32fns.c (w32_defined_color, x_decode_color)
@@ -694,8 +808,8 @@
        Qx_create_frame_2 to adjust_frame_size.
        * w32menu.c (set_frame_menubar): Simplify adjust_frame_size
        call.
-       * window.c (Fset_window_configuration): Pass
-       Qset_window_configuration to adjust_frame_size.
+       * window.c (Fset_window_configuration):
+       Pass Qset_window_configuration to adjust_frame_size.
        * xdisp.c (redisplay_tool_bar): Assign new height to
        frame_default_tool_bar_height.
        (redisplay_internal): If we haven't redisplayed this frame's
@@ -763,8 +877,8 @@
 
        * w32fns.c (Fw32_register_hot_key): Use XINT instead of XLI.
 
-       * w32notify.c (Fw32notify_add_watch, w32_get_watch_object): Use
-       make_pointer_integer instead of XIL.
+       * w32notify.c (Fw32notify_add_watch, w32_get_watch_object):
+       Use make_pointer_integer instead of XIL.
        (Fw32notify_rm_watch): Use XINTPTR instead of XLI.
 
        * w32inevt.c (handle_file_notifications): Use make_pointer_integer
diff --git a/src/data.c b/src/data.c
index d06b991..4770658 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2125,8 +2125,6 @@ DEFUN ("indirect-function", Findirect_function, 
Sindirect_function, 1, 2, 0,
        doc: /* Return the function at the end of OBJECT's function chain.
 If OBJECT is not a symbol, just return it.  Otherwise, follow all
 function indirections to find the final function binding and return it.
-If the final symbol in the chain is unbound, signal a void-function error.
-Optional arg NOERROR non-nil means to return nil instead of signaling.
 Signal a cyclic-function-indirection error if there is a loop in the
 function chain of symbols.  */)
   (register Lisp_Object object, Lisp_Object noerror)
@@ -2141,9 +2139,6 @@ function chain of symbols.  */)
   if (!NILP (result))
     return result;
 
-  if (NILP (noerror))
-    xsignal1 (Qvoid_function, object);
-
   return Qnil;
 }
 
diff --git a/src/dispnew.c b/src/dispnew.c
index e614cee..6ee4cce 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3911,45 +3911,35 @@ set_window_cursor_after_update (struct window *w)
     {
       cx = cy = vpos = hpos = 0;
 
-      if (cursor_in_echo_area >= 0)
+      /* If the mini-buffer is several lines high, find the last
+        line that has any text on it.  Note: either all lines
+        are enabled or none.  Otherwise we wouldn't be able to
+        determine Y.  */
+      struct glyph_row *last_row = NULL;
+      int yb = window_text_bottom_y (w);
+
+      for (struct glyph_row *row = w->current_matrix->rows;
+          row->enabled_p && (!last_row || MATRIX_ROW_BOTTOM_Y (row) <= yb);
+          row++)
+       if (row->used[TEXT_AREA] && row->glyphs[TEXT_AREA][0].charpos >= 0)
+         last_row = row;
+
+      if (last_row)
        {
-         /* If the mini-buffer is several lines high, find the last
-            line that has any text on it.  Note: either all lines
-            are enabled or none.  Otherwise we wouldn't be able to
-            determine Y.  */
-         struct glyph_row *row, *last_row;
-         struct glyph *glyph;
-         int yb = window_text_bottom_y (w);
-
-         last_row = NULL;
-         row = w->current_matrix->rows;
-         while (row->enabled_p
-                && (last_row == NULL
-                    || MATRIX_ROW_BOTTOM_Y (row) <= yb))
-           {
-             if (row->used[TEXT_AREA]
-                 && row->glyphs[TEXT_AREA][0].charpos >= 0)
-               last_row = row;
-             ++row;
-           }
+         struct glyph *start = last_row->glyphs[TEXT_AREA];
+         struct glyph *last = start + last_row->used[TEXT_AREA] - 1;
 
-         if (last_row)
-           {
-             struct glyph *start = last_row->glyphs[TEXT_AREA];
-             struct glyph *last = start + last_row->used[TEXT_AREA] - 1;
-
-             while (last > start && last->charpos < 0)
-               --last;
+         while (last > start && last->charpos < 0)
+           --last;
 
-             for (glyph = start; glyph < last; ++glyph)
-               {
-                 cx += glyph->pixel_width;
-                 ++hpos;
-               }
-
-             cy = last_row->y;
-             vpos = MATRIX_ROW_VPOS (last_row, w->current_matrix);
+         for (struct glyph *glyph = start; glyph < last; glyph++)
+           {
+             cx += glyph->pixel_width;
+             hpos++;
            }
+
+         cy = last_row->y;
+         vpos = MATRIX_ROW_VPOS (last_row, w->current_matrix);
        }
     }
   else
@@ -4569,58 +4559,43 @@ update_frame_1 (struct frame *f, bool force_p, bool 
inhibit_id_p,
          && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window))
        {
          int top = WINDOW_TOP_EDGE_LINE (XWINDOW (FRAME_MINIBUF_WINDOW (f)));
-         int row, col;
+         int col;
 
-         if (cursor_in_echo_area < 0)
+         /* Put cursor at the end of the prompt.  If the mini-buffer
+            is several lines high, find the last line that has
+            any text on it.  */
+         int row = FRAME_TOTAL_LINES (f);
+         do
            {
-             /* Negative value of cursor_in_echo_area means put
-                 cursor at beginning of line.  */
-             row = top;
+             row--;
              col = 0;
-           }
-         else
-           {
-             /* Positive value of cursor_in_echo_area means put
-                cursor at the end of the prompt.  If the mini-buffer
-                is several lines high, find the last line that has
-                any text on it.  */
-             row = FRAME_TOTAL_LINES (f);
-             do
-               {
-                 --row;
-                 col = 0;
 
-                 if (MATRIX_ROW_ENABLED_P (current_matrix, row))
-                   {
-                     /* Frame rows are filled up with spaces that
-                        must be ignored here.  */
-                     struct glyph_row *r = MATRIX_ROW (current_matrix,
-                                                       row);
-                     struct glyph *start = r->glyphs[TEXT_AREA];
-                     struct glyph *last = start + r->used[TEXT_AREA];
-
-                     while (last > start
-                            && (last - 1)->charpos < 0)
-                       --last;
-
-                     col = last - start;
-                   }
+             if (MATRIX_ROW_ENABLED_P (current_matrix, row))
+               {
+                 /* Frame rows are filled up with spaces that
+                    must be ignored here.  */
+                 struct glyph_row *r = MATRIX_ROW (current_matrix, row);
+                 struct glyph *start = r->glyphs[TEXT_AREA];
+
+                 col = r->used[TEXT_AREA];
+                 while (0 < col && start[col - 1].charpos < 0)
+                   col--;
                }
-             while (row > top && col == 0);
+           }
+         while (row > top && col == 0);
 
-             /* Make sure COL is not out of range.  */
-             if (col >= FRAME_CURSOR_X_LIMIT (f))
+         /* Make sure COL is not out of range.  */
+         if (col >= FRAME_CURSOR_X_LIMIT (f))
+           {
+             /* If we have another row, advance cursor into it.  */
+             if (row < FRAME_TOTAL_LINES (f) - 1)
                {
-                 /* If we have another row, advance cursor into it.  */
-                 if (row < FRAME_TOTAL_LINES (f) - 1)
-                   {
-                     col = FRAME_LEFT_SCROLL_BAR_COLS (f);
-                     row++;
-                   }
-                 /* Otherwise move it back in range.  */
-                 else
-                   col = FRAME_CURSOR_X_LIMIT (f) - 1;
+                 col = FRAME_LEFT_SCROLL_BAR_COLS (f);
+                 row++;
                }
+             /* Otherwise move it back in range.  */
+             else
+               col = FRAME_CURSOR_X_LIMIT (f) - 1;
            }
 
          cursor_to (f, row, col);
@@ -5966,7 +5941,7 @@ init_display (void)
   space_glyph.charpos = -1;
 
   inverse_video = 0;
-  cursor_in_echo_area = 0;
+  cursor_in_echo_area = false;
 
   /* Now is the time to initialize this; it's used by init_sys_modes
      during startup.  */
diff --git a/src/eval.c b/src/eval.c
index b98b224..e828da9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -575,10 +575,23 @@ usage: (function ARG)  */)
   if (!NILP (Vinternal_interpreter_environment)
       && CONSP (quoted)
       && EQ (XCAR (quoted), Qlambda))
-    /* This is a lambda expression within a lexical environment;
-       return an interpreted closure instead of a simple lambda.  */
-    return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment,
-                                  XCDR (quoted)));
+    { /* This is a lambda expression within a lexical environment;
+        return an interpreted closure instead of a simple lambda.  */
+      Lisp_Object cdr = XCDR (quoted);
+      Lisp_Object tmp = cdr;
+      if (CONSP (tmp)
+         && (tmp = XCDR (tmp), CONSP (tmp))
+         && (tmp = XCAR (tmp), CONSP (tmp))
+         && (EQ (QCdocumentation, XCAR (tmp))))
+       { /* Handle the special (:documentation <form>) to build the docstring
+            dynamically.  */
+         Lisp_Object docstring = eval_sub (Fcar (XCDR (tmp)));
+         CHECK_STRING (docstring);
+         cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr))));
+       }
+      return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment,
+                                    cdr));
+    }
   else
     /* Simply quote the argument.  */
     return quoted;
@@ -3668,6 +3681,7 @@ before making `inhibit-quit' nil.  */);
   DEFSYM (Qand_rest, "&rest");
   DEFSYM (Qand_optional, "&optional");
   DEFSYM (Qclosure, "closure");
+  DEFSYM (QCdocumentation, ":documentation");
   DEFSYM (Qdebug, "debug");
 
   DEFVAR_LISP ("inhibit-debugger", Vinhibit_debugger,
diff --git a/src/frame.c b/src/frame.c
index 890e897..92b6b7c 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -149,6 +149,32 @@ get_frame_param (register struct frame *frame, Lisp_Object 
prop)
   return Fcdr (tem);
 }
 
+
+void
+frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
+                       int width, int height, Lisp_Object rest)
+{
+  Lisp_Object frame;
+
+  XSETFRAME (frame, f);
+  if (CONSP (frame_size_history)
+      && INTEGERP (XCAR (frame_size_history))
+      && 0 < XINT (XCAR (frame_size_history)))
+    frame_size_history =
+      Fcons (make_number (XINT (XCAR (frame_size_history)) - 1),
+            Fcons (list4
+                   (frame, fun_symbol,
+                    ((width > 0)
+                     ? list4 (make_number (FRAME_TEXT_WIDTH (f)),
+                              make_number (FRAME_TEXT_HEIGHT (f)),
+                              make_number (width),
+                              make_number (height))
+                     : Qnil),
+                    rest),
+                   XCDR (frame_size_history)));
+}
+
+
 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
    state of frame F would be affected by a vertical (horizontal if
    HORIZONTAL is true) resize.  PARAMETER is the symbol of the frame
@@ -156,11 +182,27 @@ get_frame_param (register struct frame *frame, 
Lisp_Object prop)
 bool
 frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
 {
-  return (EQ (frame_inhibit_implied_resize, Qt)
-         || (CONSP (frame_inhibit_implied_resize)
-             && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
-         || !NILP (get_frame_param (f, Qfullscreen))
-         || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
+  Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
+  bool inhibit
+    = ((f->after_make_frame
+       && (EQ (frame_inhibit_implied_resize, Qt)
+           || (CONSP (frame_inhibit_implied_resize)
+               && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))))
+       || (horizontal
+          && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight))
+       || (!horizontal
+          && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth))
+       || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
+
+  if (inhibit && !FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
+    frame_size_history_add
+      (f, Qframe_inhibit_resize, 0, 0,
+       list5 (horizontal ? Qt : Qnil, parameter,
+             f->after_make_frame ? Qt : Qnil,
+             frame_inhibit_implied_resize,
+             fullscreen));
+
+  return inhibit;
 }
 
 static void
@@ -369,18 +411,9 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 
   XSETFRAME (frame, f);
 
-  /* `make-frame' initializes Vframe_adjust_size_history to (Qt) and
-     strips its car when exiting.  Just in case make sure its size never
-     exceeds 100.  */
-  if (!NILP (Fconsp (Vframe_adjust_size_history))
-      && EQ (Fcar (Vframe_adjust_size_history), Qt)
-      && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
-    Vframe_adjust_size_history =
-      Fcons (Qt, Fcons (list5 (make_number (0),
-                              make_number (new_text_width),
-                              make_number (new_text_height),
-                              make_number (inhibit), parameter),
-                       Fcdr (Vframe_adjust_size_history)));
+  frame_size_history_add
+    (f, Qadjust_frame_size_1, new_text_width, new_text_height,
+     list2 (parameter, make_number (inhibit)));
 
   /* The following two values are calculated from the old window body
      sizes and any "new" settings for scroll bars, dividers, fringes and
@@ -391,7 +424,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
     = frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qt : Qnil, Qt);
 
   if (inhibit >= 2 && inhibit <= 4)
-    /* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
+    /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
        within the limits and either frame_inhibit_resize tells us to do
        so or INHIBIT equals 4.  */
     {
@@ -449,16 +482,10 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
       else if (inhibit_vertical)
        new_text_height = old_text_height;
 
-      if (!NILP (Fconsp (Vframe_adjust_size_history))
-         && EQ (Fcar (Vframe_adjust_size_history), Qt)
-         && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
-       Vframe_adjust_size_history =
-         Fcons (Qt, Fcons (list5 (make_number (1),
-                                  make_number (new_text_width),
-                                  make_number (new_text_height),
-                                  make_number (new_cols),
-                                  make_number (new_lines)),
-                           Fcdr (Vframe_adjust_size_history)));
+      frame_size_history_add
+       (f, Qadjust_frame_size_2, new_text_width, new_text_height,
+        list2 (inhibit_horizontal ? Qt : Qnil,
+               inhibit_vertical ? Qt : Qnil));
 
       x_set_window_size (f, 0, new_text_width, new_text_height, 1);
       f->resized_p = true;
@@ -525,6 +552,11 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
        FrameRows (FRAME_TTY (f)) = new_lines + FRAME_TOP_MARGIN (f);
     }
 
+  frame_size_history_add
+    (f, Qadjust_frame_size_3, new_text_width, new_text_height,
+     list4 (make_number (old_pixel_width), make_number (old_pixel_height),
+           make_number (new_pixel_width), make_number (new_pixel_height)));
+
   /* Assign new sizes.  */
   FRAME_TEXT_WIDTH (f) = new_text_width;
   FRAME_TEXT_HEIGHT (f) = new_text_height;
@@ -533,17 +565,6 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
   SET_FRAME_COLS (f, new_cols);
   SET_FRAME_LINES (f, new_lines);
 
-  if (!NILP (Fconsp (Vframe_adjust_size_history))
-      && EQ (Fcar (Vframe_adjust_size_history), Qt)
-      && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100)
-    Vframe_adjust_size_history =
-      Fcons (Qt, Fcons (list5 (make_number (2),
-                              make_number (new_text_width),
-                              make_number (new_text_height),
-                              make_number (new_cols),
-                              make_number (new_lines)),
-                       Fcdr (Vframe_adjust_size_history)));
-
   {
     struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
     int text_area_x, text_area_y, text_area_width, text_area_height;
@@ -608,7 +629,7 @@ make_frame (bool mini_p)
   f->redisplay = true;
   f->garbaged = true;
   f->can_x_set_window_size = false;
-  f->can_run_window_configuration_change_hook = false;
+  f->after_make_frame = false;
   f->tool_bar_redisplayed_once = false;
   f->column_width = 1;  /* !FRAME_WINDOW_P value.  */
   f->line_height = 1;  /* !FRAME_WINDOW_P value.  */
@@ -1020,7 +1041,8 @@ affects all frames on the same terminal device.  */)
   {
     int width, height;
     get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
-    adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), 5, 0, 
Qnil);
+    adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f),
+                      5, 0, Qterminal_frame);
   }
 
   adjust_frame_glyphs (f);
@@ -2260,24 +2282,23 @@ If there is no window system support, this function 
does nothing.  */)
   return Qnil;
 }
 
-DEFUN ("frame-can-run-window-configuration-change-hook",
-       Fcan_run_window_configuration_change_hook,
-       Scan_run_window_configuration_change_hook, 2, 2, 0,
-       doc: /* Whether `window-configuration-change-hook' is run for frame 
FRAME.
-FRAME nil means use the selected frame.  Second argument ALLOW non-nil
+DEFUN ("frame-after-make-frame",
+       Fframe_after_make_frame,
+       Sframe_after_make_frame, 2, 2, 0,
+       doc: /* Mark FRAME as made.
+FRAME nil means use the selected frame.  Second argument MADE non-nil
 means functions on `window-configuration-change-hook' are called
-whenever the window configuration of FRAME changes.  ALLOW nil means
+whenever the window configuration of FRAME changes.  MADE nil means
 these functions are not called.
 
-This function is currently called by `face-set-after-frame-default' only
-and should be otherwise used with utter care to avoid that running
-functions on `window-configuration-change-hook' is impeded forever.  */)
-  (Lisp_Object frame, Lisp_Object allow)
+This function is currently called by `make-frame' only and should be
+otherwise used with utter care to avoid that running functions on
+`window-configuration-change-hook' is impeded forever.  */)
+  (Lisp_Object frame, Lisp_Object made)
 {
   struct frame *f = decode_live_frame (frame);
-
-  f->can_run_window_configuration_change_hook = NILP (allow) ? false : true;
-  return Qnil;
+  f->after_make_frame = !NILP (made);
+  return made;
 }
 
 
@@ -2591,7 +2612,12 @@ If FRAME is nil, describe the currently selected frame.  
*/)
                 important when param_alist's notion of colors is
                 "unspecified".  We need to do the same here.  */
              if (STRINGP (value) && !FRAME_WINDOW_P (f))
-               value = frame_unspecified_color (f, value);
+               {
+                 Lisp_Object tem = frame_unspecified_color (f, value);
+
+                 if (!NILP (tem))
+                   value = tem;
+               }
            }
          else
            value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
@@ -3037,7 +3063,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
      set them both at once.  So we wait until we've looked at the
      entire list before we set them.  */
   int width IF_LINT (= 0), height IF_LINT (= 0);
-  bool width_change = 0, height_change = 0;
+  bool width_change = false, height_change = false;
 
   /* Same here.  */
   Lisp_Object left, top;
@@ -3045,6 +3071,10 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
   /* Same with these.  */
   Lisp_Object icon_left, icon_top;
 
+  /* And with this.  */
+  Lisp_Object fullscreen;
+  bool fullscreen_change = false;
+
   /* Record in these vectors all the parms specified.  */
   Lisp_Object *parms;
   Lisp_Object *values;
@@ -3138,6 +3168,11 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
        icon_top = val;
       else if (EQ (prop, Qicon_left))
        icon_left = val;
+      else if (EQ (prop, Qfullscreen))
+       {
+         fullscreen = val;
+         fullscreen_change = true;
+       }
       else if (EQ (prop, Qforeground_color)
               || EQ (prop, Qbackground_color)
               || EQ (prop, Qfont))
@@ -3218,14 +3253,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
           that here since otherwise a size change implied by an
           intermittent font change may get lost as in Bug#17142.  */
        if (!width_change)
-         width = (f->new_width
+         width = ((f->can_x_set_window_size && f->new_width)
                   ? (f->new_pixelwise
                      ? f->new_width
                      : (f->new_width * FRAME_COLUMN_WIDTH (f)))
                   : FRAME_TEXT_WIDTH (f));
 
        if (!height_change)
-         height = (f->new_height
+         height = ((f->can_x_set_window_size && f->new_height)
                    ? (f->new_pixelwise
                       ? f->new_height
                       : (f->new_height * FRAME_LINE_HEIGHT (f)))
@@ -3298,6 +3333,20 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
        /* Actually set that position, and convert to absolute.  */
        x_set_offset (f, leftpos, toppos, -1);
       }
+
+    if (fullscreen_change)
+      {
+       Lisp_Object old_value = get_frame_param (f, Qfullscreen);
+
+       frame_size_history_add
+         (f, Qx_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
+
+       store_frame_param (f, Qfullscreen, fullscreen);
+       if (!EQ (fullscreen, old_value))
+         x_set_fullscreen (f, fullscreen, old_value);
+      }
+
+
 #ifdef HAVE_X_WINDOWS
     if ((!NILP (icon_left) || !NILP (icon_top))
        && ! (icon_left_no_change && icon_top_no_change))
@@ -4834,11 +4883,33 @@ syms_of_frame (void)
   DEFSYM (Qtool_bar_external, "tool-bar-external");
   DEFSYM (Qtool_bar_size, "tool-bar-size");
   DEFSYM (Qframe_inner_size, "frame-inner-size");
+  /* The following are used for frame_size_history.  */
+  DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
+  DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
+  DEFSYM (Qadjust_frame_size_3, "adjust-frame-size-3");
+  DEFSYM (QEmacsFrameResize, "EmacsFrameResize");
+  DEFSYM (Qframe_inhibit_resize, "frame-inhibit-resize");
+  DEFSYM (Qx_set_fullscreen, "x-set-fullscreen");
+  DEFSYM (Qx_check_fullscreen, "x-check-fullscreen");
+  DEFSYM (Qx_set_window_size_1, "x-set-window-size-1");
+  DEFSYM (Qxg_frame_resized, "xg-frame-resized");
+  DEFSYM (Qxg_frame_set_char_size_1, "xg-frame-set-char-size-1");
+  DEFSYM (Qxg_frame_set_char_size_2, "xg-frame-set-char-size-2");
+  DEFSYM (Qxg_frame_set_char_size_3, "xg-frame-set-char-size-3");
+  DEFSYM (Qxg_change_toolbar_position, "xg-change-toolbar-position");
+  DEFSYM (Qx_net_wm_state, "x-net-wm-state");
+  DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state");
+  DEFSYM (Qtb_size_cb, "tb-size-cb");
+  DEFSYM (Qupdate_frame_tool_bar, "update-frame-tool-bar");
+  DEFSYM (Qfree_frame_tool_bar, "free-frame-tool-bar");
+
   DEFSYM (Qchange_frame_size, "change-frame-size");
   DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size");
   DEFSYM (Qset_window_configuration, "set-window-configuration");
   DEFSYM (Qx_create_frame_1, "x-create-frame-1");
   DEFSYM (Qx_create_frame_2, "x-create-frame-2");
+  DEFSYM (Qtip_frame, "tip-frame");
+  DEFSYM (Qterminal_frame, "terminal-frame");
 
 #ifdef HAVE_NS
   DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
@@ -5106,9 +5177,22 @@ even if this option is non-nil.  */);
   frame_inhibit_implied_resize = Qt;
 #endif
 
-  DEFVAR_LISP ("frame-adjust-size-history", Vframe_adjust_size_history,
-               doc: /* History of frame size adjustments.  */);
-  Vframe_adjust_size_history = Qnil;
+  DEFVAR_LISP ("frame-size-history", frame_size_history,
+               doc: /* History of frame size adjustments.
+If non-nil, list recording frame size adjustment.  Adjustments are
+recorded only if the first element of this list is a positive number.
+Adding an adjustment decrements that number by one.
+
+The remaining elements are the adjustments.  Each adjustment is a list
+of four elements `frame', `function', `sizes' and `more'.  `frame' is
+the affected frame and `function' the invoking function.  `sizes' is
+usually a list of four elements `old-width', `old-height', `new-width'
+and `new-height' representing the old and new sizes recorded/requested
+by `function'.  `more' is a list with additional information.
+
+The function `frame--size-history' displays the value of this variable
+in a more readable form.  */);
+    frame_size_history = Qnil;
 
   staticpro (&Vframe_list);
 
@@ -5141,7 +5225,7 @@ even if this option is non-nil.  */);
   defsubr (&Sraise_frame);
   defsubr (&Slower_frame);
   defsubr (&Sx_focus_frame);
-  defsubr (&Scan_run_window_configuration_change_hook);
+  defsubr (&Sframe_after_make_frame);
   defsubr (&Sredirect_frame_focus);
   defsubr (&Sframe_focus);
   defsubr (&Sframe_parameters);
diff --git a/src/frame.h b/src/frame.h
index 0c08d12..6f5de3f 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -332,9 +332,8 @@ struct frame
      frame.  */
   bool_bf can_x_set_window_size : 1;
 
-  /* True means run_window_configuration_change_hook can be processed
-     for this frame.  */
-  bool_bf can_run_window_configuration_change_hook : 1;
+  /* Set to true after this frame was made by `make-frame'.  */
+  bool_bf after_make_frame : 1;
 
   /* True means tool bar has been redisplayed at least once in current
      session.  */
@@ -392,9 +391,9 @@ struct frame
   int left_pos, top_pos;
 
   /* Total width of this frame (including fringes, vertical scroll bar
-     and internal border widths) and total height (including menu bar,
-     tool bar, horizontal scroll bar and internal border widths) in
-     pixels.  */
+     and internal border widths) and total height (including internal
+     menu and tool bars, horizontal scroll bar and internal border
+     widths) in pixels.  */
   int pixel_width, pixel_height;
 
   /* These many pixels are the difference between the outer window (i.e. the
@@ -1124,6 +1123,8 @@ extern void frame_make_pointer_visible (struct frame *);
 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
 extern void adjust_frame_size (struct frame *, int, int, int, bool, 
Lisp_Object);
+extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
+                                   int width, int height, Lisp_Object rest);
 
 extern Lisp_Object Vframe_list;
 
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 21f3cb1..6f17078 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -50,12 +50,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "emacsgtkfixed.h"
 #endif
 
-/** #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ **/
-/**   (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + 
FRAME_TOOLBAR_HEIGHT (f)) **/
-
-/** #define FRAME_TOTAL_PIXEL_WIDTH(f) \ **/
-/**   (FRAME_PIXEL_WIDTH (f) + FRAME_TOOLBAR_WIDTH (f)) **/
-
 #ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW
 #define gtk_widget_set_has_window(w, b) \
   (gtk_fixed_set_has_window (GTK_FIXED (w), b))
@@ -886,24 +880,23 @@ xg_frame_resized (struct frame *f, int pixelwidth, int 
pixelheight)
   if (pixelwidth == -1 && pixelheight == -1)
     {
       if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f)))
-          gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET 
(f)),
-                                   0, 0,
-                                   &pixelwidth, &pixelheight);
-      else return;
+       gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
+                                0, 0, &pixelwidth, &pixelheight);
+      else
+       return;
     }
 
-
   width = FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth);
   height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight);
 
+  frame_size_history_add
+    (f, Qxg_frame_resized, width, height, Qnil);
+
   if (width != FRAME_TEXT_WIDTH (f)
       || height != FRAME_TEXT_HEIGHT (f)
       || pixelwidth != FRAME_PIXEL_WIDTH (f)
       || pixelheight != FRAME_PIXEL_HEIGHT (f))
     {
-      FRAME_PIXEL_WIDTH (f) = pixelwidth;
-      FRAME_PIXEL_HEIGHT (f) = pixelheight;
-
       xg_clear_under_internal_border (f);
       change_frame_size (f, width, height, 0, 1, 0, 1);
       SET_FRAME_GARBAGED (f);
@@ -921,24 +914,71 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
 {
   int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
   int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
+  Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
+  gint gwidth, gheight;
 
   if (FRAME_PIXEL_HEIGHT (f) == 0)
     return;
 
+  gtk_window_get_size (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                      &gwidth, &gheight);
+
   /* Do this before resize, as we don't know yet if we will be resized.  */
   xg_clear_under_internal_border (f);
 
-  /* Must resize our top level widget.  Font size may have changed,
-     but not rows/cols.  */
-  gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                     pixelwidth + FRAME_TOOLBAR_WIDTH (f),
-                    pixelheight + FRAME_TOOLBAR_HEIGHT (f)
-                    + FRAME_MENUBAR_HEIGHT (f));
-  x_wm_set_size_hint (f, 0, 0);
+  /* Resize the top level widget so rows and columns remain constant.
+
+     When the frame is fullheight and we only want to change the width
+     or it is fullwidth and we only want to change the height we should
+     be able to preserve the fullscreen property.  However, due to the
+     fact that we have to send a resize request anyway, the window
+     manager will abolish it.  At least the respective size should
+     remain unchanged but giving the frame back its normal size will
+     be broken ... */
+  if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_1, width, height,
+        list2 (make_number (gheight),
+               make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                            + FRAME_MENUBAR_HEIGHT (f))));
+
+      gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                        gwidth,
+                        pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                        + FRAME_MENUBAR_HEIGHT (f));
+    }
+  else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_2, width, height,
+        list2 (make_number (gwidth),
+               make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f))));
+
+      gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                        pixelwidth + FRAME_TOOLBAR_WIDTH (f),
+                        gheight);
+    }
+
+  else
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_3, width, height,
+        list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
+               make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                            + FRAME_MENUBAR_HEIGHT (f))));
+
+      gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                        pixelwidth + FRAME_TOOLBAR_WIDTH (f),
+                        pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                        + FRAME_MENUBAR_HEIGHT (f));
+      fullscreen = Qnil;
+    }
 
   SET_FRAME_GARBAGED (f);
   cancel_mouse_face (f);
 
+  x_wm_set_size_hint (f, 0, 0);
   /* We can not call change_frame_size for a mapped frame,
      we can not set pixel width/height either.  The window manager may
      override our resize request, XMonad does this all the time.
@@ -952,9 +992,17 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
       (void)gtk_events_pending ();
       gdk_flush ();
       x_wait_for_event (f, ConfigureNotify);
+
+      if (!NILP (fullscreen))
+       /* Try to restore fullscreen state.  */
+       {
+         store_frame_param (f, Qfullscreen, fullscreen);
+         x_set_fullscreen (f, fullscreen, fullscreen);
+       }
     }
   else
-    adjust_frame_size (f, -1, -1, 5, 0, Qxg_frame_set_char_size);
+    adjust_frame_size (f, width, height, 5, 0, Qxg_frame_set_char_size);
+
 }
 
 /* Handle height/width changes (i.e. add/remove/move menu/toolbar).
@@ -4214,8 +4262,12 @@ tb_size_cb (GtkWidget    *widget,
      allocated between widgets, it may get another.  So we must update
      size hints if tool bar size changes.  Seen on Fedora 18 at least.  */
   struct frame *f = user_data;
+
   if (xg_update_tool_bar_sizes (f))
-    adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+    {
+      frame_size_history_add (f, Qtb_size_cb, 0, 0, Qnil);
+      adjust_frame_size (f, -1, -1, 5, 0, Qtool_bar_lines);
+    }
 }
 
 /* Create a tool bar for frame F.  */
@@ -4489,10 +4541,11 @@ xg_update_tool_bar_sizes (struct frame *f)
       FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr;
       FRAME_TOOLBAR_TOP_HEIGHT (f) = nt;
       FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb;
-      return 1;
-    }
 
-  return 0;
+      return true;
+    }
+  else
+    return false;
 }
 
 static char *
@@ -4815,7 +4868,10 @@ update_frame_tool_bar (struct frame *f)
         xg_pack_tool_bar (f, FRAME_TOOL_BAR_POSITION (f));
       gtk_widget_show_all (x->toolbar_widget);
       if (xg_update_tool_bar_sizes (f))
-       adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+       {
+         frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
+         adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+       }
     }
 
   unblock_input ();
@@ -4863,6 +4919,7 @@ free_frame_tool_bar (struct frame *f)
                              NULL);
         }
 
+      frame_size_history_add (f, Qfree_frame_tool_bar, 0, 0, Qnil);
       adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
 
       unblock_input ();
@@ -4892,8 +4949,13 @@ xg_change_toolbar_position (struct frame *f, Lisp_Object 
pos)
 
   xg_pack_tool_bar (f, pos);
   g_object_unref (top_widget);
+
   if (xg_update_tool_bar_sizes (f))
-    adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+    {
+      frame_size_history_add (f, Qxg_change_toolbar_position, 0, 0, Qnil);
+      adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+    }
+
 
   unblock_input ();
 }
diff --git a/src/w32fns.c b/src/w32fns.c
index 8435270..08000d8 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1722,6 +1722,7 @@ x_change_tool_bar_height (struct frame *f, int height)
   int old_height = FRAME_TOOL_BAR_HEIGHT (f);
   int lines = (height + unit - 1) / unit;
   int old_text_height = FRAME_TEXT_HEIGHT (f);
+  Lisp_Object fullscreen;
 
   /* Make sure we redisplay all windows in this frame.  */
   windows_or_buffers_changed = 23;
@@ -1746,7 +1747,10 @@ x_change_tool_bar_height (struct frame *f, int height)
   f->n_tool_bar_rows = 0;
 
   adjust_frame_size (f, -1, -1,
-                    (!f->tool_bar_redisplayed_once ? 1
+                    ((!f->tool_bar_redisplayed_once
+                      && (NILP (fullscreen =
+                                get_frame_param (f, Qfullscreen))
+                          || EQ (fullscreen, Qfullwidth))) ? 1
                      : (old_height == 0 || height == 0) ? 2
                      : 4),
                     false, Qtool_bar_lines);
@@ -4668,8 +4672,6 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
                       "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qtitle, Qnil,
                       "title", "Title", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qfullscreen, Qnil,
-                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
 
   f->output_data.w32->dwStyle = WS_OVERLAPPEDWINDOW;
   f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
@@ -4728,6 +4730,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   x_wm_set_size_hint (f, window_prompting, false);
   unblock_input ();
 
+  /* Process fullscreen parameter here in the hope that normalizing a
+     fullheight/fullwidth frame will produce the size set by the last
+     adjust_frame_size call.  */
+  x_default_parameter (f, parameters, Qfullscreen, Qnil,
+                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
      cannot control visibility, so don't try.  */
@@ -5832,7 +5840,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   SET_FRAME_COLS (f, 0);
   SET_FRAME_LINES (f, 0);
   adjust_frame_size (f, width * FRAME_COLUMN_WIDTH (f),
-                    height * FRAME_LINE_HEIGHT (f), 0, true, Qnil);
+                    height * FRAME_LINE_HEIGHT (f), 0, true, Qtip_frame);
 
   /* Add `tooltip' frame parameter's default value. */
   if (NILP (Fframe_parameter (frame, Qtooltip)))
@@ -7558,7 +7566,7 @@ elements (all size values are in pixels).
     menu_bar_height = single_bar_height;
 
   return
-    listn (CONSTYPE_PURE, 10,
+    listn (CONSTYPE_HEAP, 10,
           Fcons (Qframe_position,
                  Fcons (make_number (frame_outer_edges.left),
                         make_number (frame_outer_edges.top))),
diff --git a/src/w32term.c b/src/w32term.c
index 251c46c..fb9d238 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3344,8 +3344,6 @@ static void x_horizontal_scroll_bar_report_motion (struct 
frame **, Lisp_Object
                                                   enum scroll_bar_part *,
                                                   Lisp_Object *, Lisp_Object *,
                                                   Time *);
-static void x_check_fullscreen (struct frame *);
-
 static void
 w32_define_cursor (Window window, Cursor cursor)
 {
@@ -4989,8 +4987,12 @@ w32_read_socket (struct terminal *terminal,
                 sets the WAIT flag.  */
              if ((msg.msg.message == WM_WINDOWPOSCHANGED || msg.msg.wParam)
                  && (f->want_fullscreen & FULLSCREEN_WAIT))
-               w32fullscreen_hook (f);
-             x_check_fullscreen (f);
+               {
+                 /* Must set visibility right here since otherwise
+                    w32fullscreen_hook returns immediately.  */
+                 SET_FRAME_VISIBLE (f, 1);
+                 w32fullscreen_hook (f);
+               }
            }
          check_visibility = 1;
          break;
@@ -5269,11 +5271,18 @@ w32_read_socket (struct terminal *terminal,
 
          if (f)
            {
+             Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
+
              dpyinfo->n_cbits = msg.msg.wParam;
              /* The new display could have a different resolution, in
-                which case we must reconsider what fullscreen
-                means.  */
-             x_check_fullscreen (f);
+                which case we must reconsider what fullscreen means.
+                The following code is untested yet.  */
+             if (!NILP (fullscreen))
+               {
+                 x_set_fullscreen (f, fullscreen, fullscreen);
+                 w32fullscreen_hook (f);
+               }
+
              DebPrint (("display change: %d %d\n",
                         (short) LOWORD (msg.msg.lParam),
                         (short) HIWORD (msg.msg.lParam)));
@@ -5959,75 +5968,6 @@ x_set_offset (struct frame *f, register int xoff, 
register int yoff,
   unblock_input ();
 }
 
-/* Calculate fullscreen size.  Return in *TOP_POS and *LEFT_POS the
-   wanted positions of the WM window (not Emacs window).
-   Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
-   window (FRAME_X_WINDOW).
- */
-
-static void
-x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, 
int *left_pos)
-{
-  int newwidth = FRAME_COLS (f);
-  int newheight = FRAME_LINES (f);
-  Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
-
-  *top_pos = f->top_pos;
-  *left_pos = f->left_pos;
-
-  if (f->want_fullscreen & FULLSCREEN_HEIGHT)
-    {
-      int ph;
-
-      ph = x_display_pixel_height (dpyinfo);
-      newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
-      ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
-      newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
-      *top_pos = 0;
-    }
-
-  if (f->want_fullscreen & FULLSCREEN_WIDTH)
-    {
-      int pw;
-
-      pw = x_display_pixel_width (dpyinfo);
-      newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
-      pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
-      newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
-      *left_pos = 0;
-    }
-
-  *width = newwidth;
-  *height = newheight;
-}
-
-/* Check if we need to resize the frame due to a fullscreen request.
-   If so needed, resize the frame.  */
-static void
-x_check_fullscreen (struct frame *f)
-{
-  if (f->want_fullscreen & FULLSCREEN_BOTH)
-    {
-      int width, height, ign;
-
-      x_real_positions (f, &f->left_pos, &f->top_pos);
-
-      x_fullscreen_adjust (f, &width, &height, &ign, &ign);
-
-      /* We do not need to move the window, it shall be taken care of
-         when setting WM manager hints.  */
-      if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
-        {
-          change_frame_size (f, width, height, 0, 1, 0, 0);
-          SET_FRAME_GARBAGED (f);
-          cancel_mouse_face (f);
-
-          /* Wait for the change of frame size to occur.  */
-          f->want_fullscreen |= FULLSCREEN_WAIT;
-        }
-    }
-}
-
 static void
 w32fullscreen_hook (struct frame *f)
 {
@@ -6074,6 +6014,10 @@ w32fullscreen_hook (struct frame *f)
           SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
                         rect.right - rect.left, rect.bottom - rect.top,
                         SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
+         change_frame_size
+           (f, FRAME_PIXEL_TO_TEXT_WIDTH (f, rect.right - rect.left),
+            FRAME_PIXEL_TO_TEXT_HEIGHT (f, rect.bottom - rect.top),
+            0, 1, 0, 1);
         }
       else
         {
@@ -6082,10 +6026,39 @@ w32fullscreen_hook (struct frame *f)
                               FRAME_NORMAL_PLACEMENT (f).rcNormalPosition, 
&rect);
           SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
                         rect.right - rect.left, rect.bottom - rect.top, 0);
+
+         if (f->want_fullscreen == FULLSCREEN_WIDTH)
+           {
+             int border_width = GetSystemMetrics (SM_CXFRAME);
+
+             change_frame_size
+               (f, (FRAME_PIXEL_TO_TEXT_WIDTH
+                    (f, rect.right - rect.left - 2 * border_width)),
+                0, 0, 1, 0, 1);
+           }
+         else
+           {
+             int border_height = GetSystemMetrics (SM_CYFRAME);
+             /* Won't work for wrapped menu bar.  */
+             int menu_bar_height = GetSystemMetrics (SM_CYMENU);
+             int title_height = GetSystemMetrics (SM_CYCAPTION);
+
+             change_frame_size
+               (f, 0, (FRAME_PIXEL_TO_TEXT_HEIGHT
+                       (f, rect.bottom - rect.top - 2 * border_height
+                        - title_height - menu_bar_height)),
+                0, 1, 0, 1);
+           }
         }
 
       f->want_fullscreen = FULLSCREEN_NONE;
       unblock_input ();
+
+      if (f->want_fullscreen == FULLSCREEN_BOTH
+         || f->want_fullscreen == FULLSCREEN_WIDTH
+         || f->want_fullscreen == FULLSCREEN_HEIGHT)
+       do_pending_window_change (0);
+
     }
   else
     f->want_fullscreen |= FULLSCREEN_WAIT;
@@ -6101,6 +6074,7 @@ x_set_window_size (struct frame *f, bool change_gravity,
                   int width, int height, bool pixelwise)
 {
   int pixelwidth, pixelheight;
+  Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
   RECT rect;
 
   block_input ();
@@ -6119,7 +6093,7 @@ x_set_window_size (struct frame *f, bool change_gravity,
   if (w32_add_wrapped_menu_bar_lines)
     {
       /* When the menu bar wraps sending a SetWindowPos shrinks the
-        height of the frame when the wrapped menu bar lines are not
+        height of the frame then the wrapped menu bar lines are not
         accounted for (Bug#15174 and Bug#18720).  Here we add these
         extra lines to the frame height.  */
       MENUBARINFO info;
@@ -6143,9 +6117,6 @@ x_set_window_size (struct frame *f, bool change_gravity,
   f->win_gravity = NorthWestGravity;
   x_wm_set_size_hint (f, (long) 0, false);
 
-  f->want_fullscreen = FULLSCREEN_NONE;
-  w32fullscreen_hook (f);
-
   rect.left = rect.top = 0;
   rect.right = pixelwidth;
   rect.bottom = pixelheight;
@@ -6153,45 +6124,45 @@ x_set_window_size (struct frame *f, bool change_gravity,
   AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                    FRAME_EXTERNAL_MENU_BAR (f));
 
-  my_set_window_pos (FRAME_W32_WINDOW (f),
-                    NULL,
-                    0, 0,
-                    rect.right - rect.left,
-                    rect.bottom - rect.top,
-                    SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
-
-  /* If w32_enable_frame_resize_hack is non-nil, immediately apply the
-     new pixel sizes to the frame and its subwindows.
-
-     Jason Rumney earlier refused to call change_frame_size right here
-     with the following argument:
-
-     The following mirrors what is done in xterm.c. It appears to be for
-     informing lisp of the new size immediately, while the actual resize
-     will happen asynchronously. But on Windows, the menu bar
-     automatically wraps when the frame is too narrow to contain it, and
-     that causes any calculations made here to come out wrong.  The end
-     is some nasty buggy behavior, including the potential loss of the
-     minibuffer.
-
-     Disabling this code is either not sufficient to fix the problems
-     completely, or it causes fresh problems, but at least it removes
-     the most problematic symptom of the minibuffer becoming unusable.
-
-     However, as the discussion about how to handle frame size
-     parameters on Windows (Bug#1348, Bug#16028) shows, that cure seems
-     worse than the disease.  In particular, menu bar wrapping looks
-     like a non-issue - maybe so because Windows eventually gets back to
-     us with the correct client rectangle anyway.  But we have to avoid
-     calling change_frame_size with a delta of less than one canoncial
-     character size when frame_resize_pixelwise is nil, as explained in
-     the comment above.  */
-
-  if (w32_enable_frame_resize_hack)
+  if (!(f->after_make_frame)
+      && !(f->want_fullscreen & FULLSCREEN_WAIT)
+      && FRAME_VISIBLE_P (f))
+    {
+      RECT window_rect;
+
+      GetWindowRect (FRAME_W32_WINDOW (f), &window_rect);
 
+      if (EQ (fullscreen, Qmaximized)
+         || EQ (fullscreen, Qfullboth)
+         || EQ (fullscreen, Qfullwidth))
+       {
+         rect.left = window_rect.left;
+         rect.right = window_rect.right;
+         pixelwidth = 0;
+       }
+      if (EQ (fullscreen, Qmaximized)
+         || EQ (fullscreen, Qfullboth)
+         || EQ (fullscreen, Qfullheight))
+       {
+         rect.top = window_rect.top;
+         rect.bottom = window_rect.bottom;
+         pixelheight = 0;
+       }
+    }
+
+  if (pixelwidth > 0 || pixelheight > 0)
     {
-      change_frame_size (f, FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth),
-                        FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight),
+      my_set_window_pos (FRAME_W32_WINDOW (f), NULL,
+                        0, 0,
+                        rect.right - rect.left,
+                        rect.bottom - rect.top,
+                        SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
+
+      change_frame_size (f,
+                        ((pixelwidth == 0)
+                            ? 0 : FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth)),
+                        ((pixelheight == 0)
+                         ? 0 : FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight)),
                         0, 1, 0, 1);
       SET_FRAME_GARBAGED (f);
 
@@ -7102,7 +7073,7 @@ Windows 8.  It is set to nil on Windows 9X.  */);
   w32_unicode_filenames = 0;
 
 
-  /* FIXME: The following two variables will be (hopefully) removed
+  /* FIXME: The following variable will be (hopefully) removed
      before Emacs 25.1 gets released.  */
 
   DEFVAR_BOOL ("w32-add-wrapped-menu-bar-lines",
@@ -7116,16 +7087,6 @@ wrapped menu bar lines when sending frame resize 
requests to the Windows
 API.  */);
   w32_add_wrapped_menu_bar_lines = 1;
 
-  DEFVAR_BOOL ("w32-enable-frame-resize-hack",
-              w32_enable_frame_resize_hack,
-     doc: /* Non-nil means enable hack for frame resizing on Windows.
-A value of nil means to resize frames by sending a corresponding request
-to the Windows API and changing the pixel sizes of the frame and its
-windows after the latter calls back.  If this is non-nil, Emacs changes
-the pixel sizes of the frame and its windows at the time it sends the
-resize request to the API.  */);
-  w32_enable_frame_resize_hack = 1;
-
   /* Tell Emacs about this window system.  */
   Fprovide (Qw32, Qnil);
 }
diff --git a/src/widget.c b/src/widget.c
index c4d6940..acf559f 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -460,7 +460,7 @@ update_wm_hints (EmacsFrame ew)
   base_width = (wmshell->core.width - ew->core.width
                + (rounded_width - (char_width * cw)));
   base_height = (wmshell->core.height - ew->core.height
-               + (rounded_height - (char_height * ch)));
+                + (rounded_height - (char_height * ch)));
 
   /* This is kind of sleazy, but I can't see how else to tell it to
      make it mark the WM_SIZE_HINTS size as user specified.
@@ -573,39 +573,20 @@ EmacsFrameResize (Widget widget)
 {
   EmacsFrame ew = (EmacsFrame)widget;
   struct frame *f = ew->emacs_frame.frame;
+  int width, height;
 
-  /* Always process resize requests pixelwise.  Frame maximizing
-     should work even when frame_resize_pixelwise is nil.  */
-  if (true || frame_resize_pixelwise)
-    {
-      int width, height;
-
-      pixel_to_text_size (ew, ew->core.width, ew->core.height, &width, 
&height);
-      change_frame_size (f, width, height, 0, 1, 0, 1);
+  pixel_to_text_size (ew, ew->core.width, ew->core.height, &width, &height);
 
-      update_wm_hints (ew);
-      update_various_frame_slots (ew);
+  frame_size_history_add
+    (f, QEmacsFrameResize, width, height,
+     list2 (make_number (ew->core.width), make_number (ew->core.height)));
 
-      cancel_mouse_face (f);
-    }
-  else
-    {
-      struct x_output *x = f->output_data.x;
-      int columns, rows;
+  change_frame_size (f, width, height, 0, 1, 0, 1);
 
-      pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, 
&rows);
-      if (columns != FRAME_COLS (f)
-         || rows != FRAME_LINES (f)
-         || ew->core.width != FRAME_PIXEL_WIDTH (f)
-         || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f))
-       {
-         change_frame_size (f, columns, rows, 0, 1, 0, 0);
-         update_wm_hints (ew);
-         update_various_frame_slots (ew);
+  update_wm_hints (ew);
+  update_various_frame_slots (ew);
 
-         cancel_mouse_face (f);
-       }
-    }
+  cancel_mouse_face (f);
 }
 
 static XtGeometryResult
diff --git a/src/window.c b/src/window.c
index b423010..5cbd58d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3332,7 +3332,7 @@ run_window_configuration_change_hook (struct frame *f)
 
   if (NILP (Vrun_hooks)
       || !(f->can_x_set_window_size)
-      || !(f->can_run_window_configuration_change_hook))
+      || !(f->after_make_frame))
     return;
 
   /* Use the right buffer.  Matters when running the local hooks.  */
diff --git a/src/xdisp.c b/src/xdisp.c
index 4459363..faec93f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9703,7 +9703,7 @@ in_display_vector_p (struct it *it)
          && it->dpvec + it->current.dpvec_index != it->dpend);
 }
 
-DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, 
Swindow_text_pixel_size, 0, 7, 0,
+DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, 
Swindow_text_pixel_size, 0, 6, 0,
        doc: /* Return the size of the text of WINDOW's buffer in pixels.
 WINDOW must be a live window and defaults to the selected one.  The
 return value is a cons of the maximum pixel-width of any text line and
@@ -9736,17 +9736,12 @@ Optional argument MODE-AND-HEADER-LINE nil or omitted 
means do not
 include the height of the mode- or header-line of WINDOW in the return
 value.  If it is either the symbol `mode-line' or `header-line', include
 only the height of that line, if present, in the return value.  If t,
-include the height of both, if present, in the return value.
-
-Optional argument BUFFER nil means to return the size of the text of
-WINDOW's buffer.  BUFFER t means to return the size of the text of the
-current buffer as if it were displayed in WINDOW.  Else BUFFER has to
-specify a live buffer and this function returns the size of the text of
-BUFFER as if it were displayed in WINDOW.  */)
+include the height of both, if present, in the return value.  */)
   (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit,
-   Lisp_Object y_limit, Lisp_Object mode_and_header_line, Lisp_Object buffer)
+   Lisp_Object y_limit, Lisp_Object mode_and_header_line)
 {
   struct window *w = decode_live_window (window);
+  Lisp_Object buffer = w->contents;
   struct buffer *b;
   struct it it;
   struct buffer *old_b = NULL;
@@ -9755,23 +9750,13 @@ BUFFER as if it were displayed in WINDOW.  */)
   void *itdata = NULL;
   int c, max_y = -1, x = 0, y = 0;
 
-  if (EQ (buffer, Qt))
-    b = current_buffer;
-  else
-    {
-      if (NILP (buffer))
-       buffer = w->contents;
-
-      CHECK_BUFFER (buffer);
-      if (!BUFFER_LIVE_P (XBUFFER (buffer)))
-       error ("Not a live buffer");
+  CHECK_BUFFER (buffer);
+  b = XBUFFER (buffer);
 
-      b = XBUFFER (buffer);
-      if (b != current_buffer)
-       {
-         old_b = current_buffer;
-         set_buffer_internal (b);
-       }
+  if (b != current_buffer)
+    {
+      old_b = current_buffer;
+      set_buffer_internal (b);
     }
 
   if (NILP (from))
@@ -10184,7 +10169,7 @@ message3_nolog (Lisp_Object m)
 
          fwrite (SDATA (s), SBYTES (s), 1, stderr);
        }
-      if (cursor_in_echo_area == 0)
+      if (!cursor_in_echo_area)
        fprintf (stderr, "\n");
       fflush (stderr);
     }
@@ -10326,7 +10311,7 @@ vmessage (const char *m, va_list ap)
            putc ('\n', stderr);
          noninteractive_need_newline = 0;
          vfprintf (stderr, m, ap);
-         if (cursor_in_echo_area == 0)
+         if (!cursor_in_echo_area)
            fprintf (stderr, "\n");
          fflush (stderr);
        }
diff --git a/src/xfns.c b/src/xfns.c
index 65eb6b4..629ac4b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1095,6 +1095,7 @@ x_change_tool_bar_height (struct frame *f, int height)
   int unit = FRAME_LINE_HEIGHT (f);
   int old_height = FRAME_TOOL_BAR_HEIGHT (f);
   int lines = (height + unit - 1) / unit;
+  Lisp_Object fullscreen;
 
   /* Make sure we redisplay all windows in this frame.  */
   windows_or_buffers_changed = 60;
@@ -1126,7 +1127,10 @@ x_change_tool_bar_height (struct frame *f, int height)
   f->n_tool_bar_rows = 0;
 
   adjust_frame_size (f, -1, -1,
-                    (!f->tool_bar_redisplayed_once ? 1
+                    ((!f->tool_bar_redisplayed_once
+                      && (NILP (fullscreen =
+                                get_frame_param (f, Qfullscreen))
+                          || EQ (fullscreen, Qfullwidth))) ? 1
                      : (old_height == 0 || height == 0) ? 2
                      : 4),
                     false, Qtool_bar_lines);
@@ -3180,8 +3184,6 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
                       "title", "Title", RES_TYPE_STRING);
   x_default_parameter (f, parms, Qwait_for_wm, Qt,
                       "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qfullscreen, Qnil,
-                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
   x_default_parameter (f, parms, Qtool_bar_position,
                        FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
 
@@ -3259,6 +3261,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   x_wm_set_size_hint (f, window_prompting, false);
   unblock_input ();
 
+  /* Process fullscreen parameter here in the hope that normalizing a
+     fullheight/fullwidth frame will produce the size set by the last
+     adjust_frame_size call.  */
+  x_default_parameter (f, parms, Qfullscreen, Qnil,
+                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
      cannot control visibility, so don't try.  */
@@ -4318,7 +4326,7 @@ elements (all size values are in pixels).
     inner_height -= tool_bar_height;
 
   return
-    listn (CONSTYPE_PURE, 10,
+    listn (CONSTYPE_HEAP, 10,
           Fcons (Qframe_position,
                  Fcons (make_number (f->left_pos), make_number (f->top_pos))),
           Fcons (Qframe_outer_size,
diff --git a/src/xterm.c b/src/xterm.c
index abceefb..555af2b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -215,7 +215,7 @@ enum xembed_message
   };
 
 static bool x_alloc_nearest_color_1 (Display *, Colormap, XColor *);
-static void x_set_window_size_1 (struct frame *, bool, int, int, bool);
+static void x_set_window_size_1 (struct frame *, bool, int, int);
 static void x_raise_frame (struct frame *);
 static void x_lower_frame (struct frame *);
 static const XColor *x_color_cells (Display *, int *);
@@ -6585,6 +6585,10 @@ x_net_wm_state (struct frame *f, Window window)
       break;
     }
 
+  frame_size_history_add
+    (f, Qx_net_wm_state, 0, 0,
+     list2 (get_frame_param (f, Qfullscreen), lval));
+
   store_frame_param (f, Qfullscreen, lval);
 /**   store_frame_param (f, Qsticky, sticky ? Qt : Qnil); **/
 }
@@ -9242,30 +9246,78 @@ do_ewmh_fullscreen (struct frame *f)
                           None);
           break;
         case FULLSCREEN_WIDTH:
-          if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT
-              || cur == FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, false, dpyinfo->Xatom_net_wm_state_fullscreen,
-                          dpyinfo->Xatom_net_wm_state_maximized_vert);
-          if (cur != FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, true,
-                         dpyinfo->Xatom_net_wm_state_maximized_horz, None);
+         if (x_frame_normalize_before_maximize && cur == FULLSCREEN_MAXIMIZED)
+           {
+             set_wm_state (frame, false,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert);
+             set_wm_state (frame, true,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz, None);
+           }
+         else
+           {
+             if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT
+                 || cur == FULLSCREEN_MAXIMIZED)
+               set_wm_state (frame, false, 
dpyinfo->Xatom_net_wm_state_fullscreen,
+                             dpyinfo->Xatom_net_wm_state_maximized_vert);
+             if (cur != FULLSCREEN_MAXIMIZED || 
x_frame_normalize_before_maximize)
+               set_wm_state (frame, true,
+                             dpyinfo->Xatom_net_wm_state_maximized_horz, None);
+           }
           break;
         case FULLSCREEN_HEIGHT:
-          if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_WIDTH
-              || cur == FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, false, dpyinfo->Xatom_net_wm_state_fullscreen,
-                          dpyinfo->Xatom_net_wm_state_maximized_horz);
-          if (cur != FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, true,
-                         dpyinfo->Xatom_net_wm_state_maximized_vert, None);
+         if (x_frame_normalize_before_maximize && cur == FULLSCREEN_MAXIMIZED)
+           {
+             set_wm_state (frame, false,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert);
+             set_wm_state (frame, true,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert, None);
+           }
+         else
+           {
+             if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_WIDTH
+                 || cur == FULLSCREEN_MAXIMIZED)
+               set_wm_state (frame, false, 
dpyinfo->Xatom_net_wm_state_fullscreen,
+                             dpyinfo->Xatom_net_wm_state_maximized_horz);
+             if (cur != FULLSCREEN_MAXIMIZED || 
x_frame_normalize_before_maximize)
+               set_wm_state (frame, true,
+                             dpyinfo->Xatom_net_wm_state_maximized_vert, None);
+           }
           break;
         case FULLSCREEN_MAXIMIZED:
-          if (cur == FULLSCREEN_BOTH)
-            set_wm_state (frame, false, dpyinfo->Xatom_net_wm_state_fullscreen,
-                         None);
-          set_wm_state (frame, true,
-                       dpyinfo->Xatom_net_wm_state_maximized_horz,
-                        dpyinfo->Xatom_net_wm_state_maximized_vert);
+         if (x_frame_normalize_before_maximize && cur == FULLSCREEN_WIDTH)
+           {
+             set_wm_state (frame, false,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz, None);
+             set_wm_state (frame, true,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert);
+           }
+         else if (x_frame_normalize_before_maximize && cur == 
FULLSCREEN_HEIGHT)
+           {
+             set_wm_state (frame, false,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert, None);
+             set_wm_state (frame, true,
+                           dpyinfo->Xatom_net_wm_state_maximized_horz,
+                           dpyinfo->Xatom_net_wm_state_maximized_vert);
+           }
+         else
+           {
+             if (cur == FULLSCREEN_BOTH)
+               set_wm_state (frame, false, 
dpyinfo->Xatom_net_wm_state_fullscreen,
+                             None);
+             else if (cur == FULLSCREEN_HEIGHT)
+               set_wm_state (frame, true,
+                             dpyinfo->Xatom_net_wm_state_maximized_horz, None);
+             else if (cur == FULLSCREEN_WIDTH)
+               set_wm_state (frame, true, None,
+                             dpyinfo->Xatom_net_wm_state_maximized_vert);
+             else
+               set_wm_state (frame, true,
+                             dpyinfo->Xatom_net_wm_state_maximized_horz,
+                             dpyinfo->Xatom_net_wm_state_maximized_vert);
+           }
           break;
         case FULLSCREEN_NONE:
           if (cur == FULLSCREEN_BOTH)
@@ -9322,6 +9374,10 @@ x_handle_net_wm_state (struct frame *f, const 
XPropertyEvent *event)
       break;
     }
 
+  frame_size_history_add
+    (f, Qx_handle_net_wm_state, 0, 0,
+     list2 (get_frame_param (f, Qfullscreen), lval));
+
   store_frame_param (f, Qfullscreen, lval);
   store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
 
@@ -9358,13 +9414,26 @@ x_check_fullscreen (struct frame *f)
           break;
         case FULLSCREEN_WIDTH:
           width = x_display_pixel_width (dpyinfo);
-          break;
+         height = height + FRAME_MENUBAR_HEIGHT (f);
+         break;
         case FULLSCREEN_HEIGHT:
           height = x_display_pixel_height (dpyinfo);
         }
 
+      frame_size_history_add
+       (f, Qx_check_fullscreen, width, height, Qnil);
+
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
-                     width, height);
+                    width, height);
+
+      if (FRAME_VISIBLE_P (f))
+       x_wait_for_event (f, ConfigureNotify);
+      else
+       {
+         change_frame_size (f, width, height - FRAME_MENUBAR_HEIGHT (f),
+                            false, true, false, true);
+         x_sync (f);
+       }
     }
 }
 
@@ -9505,21 +9574,57 @@ x_wait_for_event (struct frame *f, int eventtype)
 
 static void
 x_set_window_size_1 (struct frame *f, bool change_gravity,
-                    int width, int height, bool pixelwise)
+                    int width, int height)
 {
-  int pixelwidth, pixelheight;
-
-  pixelwidth = (pixelwise
-               ? FRAME_TEXT_TO_PIXEL_WIDTH (f, width)
-               : FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width));
-  pixelheight = ((pixelwise
-                 ? FRAME_TEXT_TO_PIXEL_HEIGHT (f, height)
-                 : FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height)));
+  int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
+  int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
+  int old_width = FRAME_PIXEL_WIDTH (f);
+  int old_height = FRAME_PIXEL_HEIGHT (f);
+  Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
 
   if (change_gravity) f->win_gravity = NorthWestGravity;
   x_wm_set_size_hint (f, 0, false);
-  XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
-                pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
+
+  /* When the frame is fullheight and we only want to change the width
+     or it is fullwidth and we only want to change the height we should
+     be able to preserve the fullscreen property.  However, due to the
+     fact that we have to send a resize request anyway, the window
+     manager will abolish it.  At least the respective size should
+     remain unchanged but giving the frame back its normal size will
+     be broken ... */
+  if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_1, width, height,
+        list2 (make_number (old_height),
+               make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f))));
+
+      XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                    old_width, pixelheight + FRAME_MENUBAR_HEIGHT (f));
+    }
+  else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_2, width, height,
+        list2 (make_number (old_width), make_number (pixelwidth)));
+
+      XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                    pixelwidth, old_height);
+    }
+
+  else
+    {
+      frame_size_history_add
+       (f, Qxg_frame_set_char_size_3, width, height,
+        list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
+               make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                            + FRAME_MENUBAR_HEIGHT (f))));
+
+      XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                    pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
+      fullscreen = Qnil;
+    }
+
 
 
   /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
@@ -9546,7 +9651,16 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
      not right if the frame is visible.  Instead wait (with timeout)
      for the ConfigureNotify.  */
   if (FRAME_VISIBLE_P (f))
-    x_wait_for_event (f, ConfigureNotify);
+    {
+      x_wait_for_event (f, ConfigureNotify);
+
+      if (!NILP (fullscreen))
+       /* Try to restore fullscreen state.  */
+       {
+         store_frame_param (f, Qfullscreen, fullscreen);
+         x_set_fullscreen (f, fullscreen, fullscreen);
+       }
+    }
   else
     {
       change_frame_size (f, width, height, false, true, false, true);
@@ -9593,20 +9707,21 @@ x_set_window_size (struct frame *f, bool change_gravity,
     }
 #endif
 
+  /* Pixelize width and height, if necessary.  */
+  if (! pixelwise)
+    {
+      width = width * FRAME_COLUMN_WIDTH (f);
+      height = height * FRAME_LINE_HEIGHT (f);
+    }
+
 #ifdef USE_GTK
   if (FRAME_GTK_WIDGET (f))
-    if (! pixelwise)
-      xg_frame_set_char_size (f, width * FRAME_COLUMN_WIDTH (f),
-                             height * FRAME_LINE_HEIGHT (f));
-    else
-      xg_frame_set_char_size (f, width, height);
+    xg_frame_set_char_size (f, width, height);
   else
-    x_set_window_size_1 (f, change_gravity, width, height, pixelwise);
+    x_set_window_size_1 (f, change_gravity, width, height);
 #else /* not USE_GTK */
-
-  x_set_window_size_1 (f, change_gravity, width, height, pixelwise);
+  x_set_window_size_1 (f, change_gravity, width, height);
   x_clear_under_internal_border (f);
-
 #endif /* not USE_GTK */
 
   /* If cursor was outside the new size, mark it as off.  */
@@ -11617,4 +11732,15 @@ default is nil, which is the same as `super'.  */);
                                     make_float (DEFAULT_REHASH_SIZE),
                                     make_float (DEFAULT_REHASH_THRESHOLD),
                                     Qnil);
+
+  DEFVAR_BOOL ("x-frame-normalize-before-maximize",
+              x_frame_normalize_before_maximize,
+    doc: /* Non-nil means normalize frame before maximizing.
+If this variable is t, Emacs asks the window manager to give the frame
+intermediately its normal size whenever changing from a full-height or
+full-width state to the fully maximized one and vice versa.
+
+Set this variable only if your window manager cannot handle the
+transition between the various maximization states.  */);
+  x_frame_normalize_before_maximize = false;
 }
diff --git a/test/ChangeLog b/test/ChangeLog
index 60b3ed3..ff02bd6 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,12 +1,40 @@
-2015-02-01 Joakim Verona  <address@hidden>
-       Support for testing xwidgets
-       * xwidget-test-manual.el:
+2015-02-07  Fabián Ezequiel Gallina  <address@hidden>
+
+       * automated/python-tests.el
+       (python-eldoc--get-symbol-at-point-1)
+       (python-eldoc--get-symbol-at-point-2)
+       (python-eldoc--get-symbol-at-point-3)
+       (python-eldoc--get-symbol-at-point-4): New tests.
+
+2015-02-07  Fabián Ezequiel Gallina  <address@hidden>
+
+       * automated/python-tests.el
+       (python-tests-visible-string): New function.
+       (python-parens-electric-indent-1)
+       (python-triple-quote-pairing): Fix indentation, move require calls.
+       (python-hideshow-hide-levels-1)
+       (python-hideshow-hide-levels-2): New tests.
+
+2015-02-07  Dmitry Gutov  <address@hidden>
+
+       * automated/vc-tests.el (vc-test--working-revision): Fix
+       `vc-working-revision' checks to be compared against nil, which is
+       what is should return for unregistered files.
+
+2015-02-06 Nicolas Petton <address@hidden>
+
+       * automated/seq-tests.el: New tests for seq-mapcat, seq-partition
+       and seq-group-by.
+
+2015-02-05  Artur Malabarba  <address@hidden>
+
+       * automated/package-test.el (package-test-get-deps): Fix typo.
+       (package-test-sort-by-dependence): New test
 
 2015-02-03  Artur Malabarba  <address@hidden>
 
        * automated/package-test.el (package-test-get-deps): New test.
 
-
 2015-01-31  Stefan Monnier  <address@hidden>
 
        * automated/eieio-tests.el (eieio-test-23-inheritance-check): Simplify.
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 004e2e8..7d2a343 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -498,7 +498,7 @@ Must called from within a `tar-mode' buffer."
                      (list 1 package-x-test--single-archive-entry-1-4))))))
 
 (ert-deftest package-test-get-deps ()
-  "Test `package-test-get-deps' with complex structures."
+  "Test `package--get-deps' with complex structures."
   (let ((package-alist
          (mapcar (lambda (p) (list (package-desc-name p) p))
            (list simple-single-desc
@@ -526,6 +526,32 @@ Must called from within a `tar-mode' buffer."
      (equal (package--get-deps 'simple-depend-2 'direct)
             '(simple-depend-1 multi-file)))))
 
+(ert-deftest package-test-sort-by-dependence ()
+  "Test `package--sort-by-dependence' with complex structures."
+  (let ((package-alist
+         (mapcar (lambda (p) (list (package-desc-name p) p))
+           (list simple-single-desc
+                 simple-depend-desc
+                 multi-file-desc
+                 new-pkg-desc
+                 simple-depend-desc-1
+                 simple-depend-desc-2)))
+        (delete-list
+         (list simple-single-desc
+               simple-depend-desc
+               multi-file-desc
+               new-pkg-desc
+               simple-depend-desc-1
+               simple-depend-desc-2)))
+    (should
+     (equal (package--sort-by-dependence delete-list)
+            (list simple-depend-desc-2 simple-depend-desc-1 new-pkg-desc
+                  multi-file-desc simple-depend-desc simple-single-desc)))
+    (should
+     (equal (package--sort-by-dependence (reverse delete-list))
+            (list new-pkg-desc simple-depend-desc-2 simple-depend-desc-1
+                  multi-file-desc simple-depend-desc simple-single-desc)))))
+
 (provide 'package-test)
 
 ;;; package-test.el ends here
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 672b05c..47e2a6e 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -24,6 +24,11 @@
 (require 'ert)
 (require 'python)
 
+;; Dependencies for testing:
+(require 'electric)
+(require 'hideshow)
+
+
 (defmacro python-tests-with-temp-buffer (contents &rest body)
   "Create a `python-mode' enabled temp buffer with CONTENTS.
 BODY is code to be executed within the temp buffer.  Point is
@@ -104,6 +109,28 @@ STRING, it is skipped so the next STRING occurrence is 
selected."
          (call-interactively 'self-insert-command)))
      chars)))
 
+(defun python-tests-visible-string (&optional min max)
+  "Return the buffer string excluding invisible overlays.
+Argument MIN and MAX delimit the region to be returned and
+default to `point-min' and `point-max' respectively."
+  (let* ((min (or min (point-min)))
+         (max (or max (point-max)))
+         (buffer (current-buffer))
+         (buffer-contents (buffer-substring-no-properties min max))
+         (overlays
+          (sort (overlays-in min max)
+                (lambda (a b)
+                  (let ((overlay-end-a (overlay-end a))
+                        (overlay-end-b (overlay-end b)))
+                    (> overlay-end-a overlay-end-b))))))
+    (with-temp-buffer
+      (insert buffer-contents)
+      (dolist (overlay overlays)
+        (if (overlay-get overlay 'invisible)
+            (delete-region (overlay-start overlay)
+                           (overlay-end overlay))))
+      (buffer-substring-no-properties (point-min) (point-max)))))
+
 
 ;;; Tests for your tests, so you can test while you test.
 
@@ -2916,6 +2943,63 @@ class Foo(models.Model):
 
 ;;; Eldoc
 
+(ert-deftest python-eldoc--get-symbol-at-point-1 ()
+  "Test paren handling."
+  (python-tests-with-temp-buffer
+   "
+map(xx
+map(codecs.open('somefile'
+"
+   (python-tests-look-at "ap(xx")
+   (should (string= (python-eldoc--get-symbol-at-point) "map"))
+   (goto-char (line-end-position))
+   (should (string= (python-eldoc--get-symbol-at-point) "map"))
+   (python-tests-look-at "('somefile'")
+   (should (string= (python-eldoc--get-symbol-at-point) "map"))
+   (goto-char (line-end-position))
+   (should (string= (python-eldoc--get-symbol-at-point) "codecs.open"))))
+
+(ert-deftest python-eldoc--get-symbol-at-point-2 ()
+  "Ensure self is replaced with the class name."
+  (python-tests-with-temp-buffer
+   "
+class TheClass:
+
+    def some_method(self, n):
+        return n
+
+    def other(self):
+        return self.some_method(1234)
+
+"
+   (python-tests-look-at "self.some_method")
+   (should (string= (python-eldoc--get-symbol-at-point)
+                    "TheClass.some_method"))
+   (python-tests-look-at "1234)")
+   (should (string= (python-eldoc--get-symbol-at-point)
+                    "TheClass.some_method"))))
+
+(ert-deftest python-eldoc--get-symbol-at-point-3 ()
+  "Ensure symbol is found when point is at end of buffer."
+  (python-tests-with-temp-buffer
+   "
+some_symbol
+
+"
+   (goto-char (point-max))
+   (should (string= (python-eldoc--get-symbol-at-point)
+                    "some_symbol"))))
+
+(ert-deftest python-eldoc--get-symbol-at-point-4 ()
+  "Ensure symbol is found when point is at whitespace."
+  (python-tests-with-temp-buffer
+   "
+some_symbol   some_other_symbol
+"
+   (python-tests-look-at "  some_other_symbol")
+   (should (string= (python-eldoc--get-symbol-at-point)
+                    "some_symbol"))))
+
 
 ;;; Imenu
 
@@ -4358,12 +4442,11 @@ def foo(a, b, c):
 ;;; Electricity
 
 (ert-deftest python-parens-electric-indent-1 ()
-  (require 'electric)
   (let ((eim electric-indent-mode))
     (unwind-protect
         (progn
           (python-tests-with-temp-buffer
-              "
+           "
 from django.conf.urls import patterns, include, url
 
 from django.contrib import admin
@@ -4375,66 +4458,148 @@ urlpatterns = patterns('',
     url(r'^$', views.index
 )
 "
-            (electric-indent-mode 1)
-            (python-tests-look-at "views.index")
-            (end-of-line)
+           (electric-indent-mode 1)
+           (python-tests-look-at "views.index")
+           (end-of-line)
 
-            ;; Inserting commas within the same line should leave
-            ;; indentation unchanged.
-            (python-tests-self-insert ",")
-            (should (= (current-indentation) 4))
+           ;; Inserting commas within the same line should leave
+           ;; indentation unchanged.
+           (python-tests-self-insert ",")
+           (should (= (current-indentation) 4))
 
-            ;; As well as any other input happening within the same
-            ;; set of parens.
-            (python-tests-self-insert " name='index')")
-            (should (= (current-indentation) 4))
+           ;; As well as any other input happening within the same
+           ;; set of parens.
+           (python-tests-self-insert " name='index')")
+           (should (= (current-indentation) 4))
 
-            ;; But a comma outside it, should trigger indentation.
-            (python-tests-self-insert ",")
-            (should (= (current-indentation) 23))
+           ;; But a comma outside it, should trigger indentation.
+           (python-tests-self-insert ",")
+           (should (= (current-indentation) 23))
 
-            ;; Newline indents to the first argument column
-            (python-tests-self-insert "\n")
-            (should (= (current-indentation) 23))
+           ;; Newline indents to the first argument column
+           (python-tests-self-insert "\n")
+           (should (= (current-indentation) 23))
 
-            ;; All this input must not change indentation
-            (indent-line-to 4)
-            (python-tests-self-insert "url(r'^/login$', views.login)")
-            (should (= (current-indentation) 4))
+           ;; All this input must not change indentation
+           (indent-line-to 4)
+           (python-tests-self-insert "url(r'^/login$', views.login)")
+           (should (= (current-indentation) 4))
 
-            ;; But this comma does
-            (python-tests-self-insert ",")
-            (should (= (current-indentation) 23))))
+           ;; But this comma does
+           (python-tests-self-insert ",")
+           (should (= (current-indentation) 23))))
       (or eim (electric-indent-mode -1)))))
 
 (ert-deftest python-triple-quote-pairing ()
-  (require 'electric)
   (let ((epm electric-pair-mode))
     (unwind-protect
         (progn
           (python-tests-with-temp-buffer
-              "\"\"\n"
-            (or epm (electric-pair-mode 1))
-            (goto-char (1- (point-max)))
-            (python-tests-self-insert ?\")
-            (should (string= (buffer-string)
-                             "\"\"\"\"\"\"\n"))
-            (should (= (point) 4)))
+           "\"\"\n"
+           (or epm (electric-pair-mode 1))
+           (goto-char (1- (point-max)))
+           (python-tests-self-insert ?\")
+           (should (string= (buffer-string)
+                            "\"\"\"\"\"\"\n"))
+           (should (= (point) 4)))
           (python-tests-with-temp-buffer
-              "\n"
-            (python-tests-self-insert (list ?\" ?\" ?\"))
-            (should (string= (buffer-string)
-                             "\"\"\"\"\"\"\n"))
-            (should (= (point) 4)))
+           "\n"
+           (python-tests-self-insert (list ?\" ?\" ?\"))
+           (should (string= (buffer-string)
+                            "\"\"\"\"\"\"\n"))
+           (should (= (point) 4)))
           (python-tests-with-temp-buffer
-              "\"\n\"\"\n"
-            (goto-char (1- (point-max)))
-            (python-tests-self-insert ?\")
-            (should (= (point) (1- (point-max))))
-            (should (string= (buffer-string)
-                             "\"\n\"\"\"\n"))))
+           "\"\n\"\"\n"
+           (goto-char (1- (point-max)))
+           (python-tests-self-insert ?\")
+           (should (= (point) (1- (point-max))))
+           (should (string= (buffer-string)
+                            "\"\n\"\"\"\n"))))
       (or epm (electric-pair-mode -1)))))
 
+
+;;; Hideshow support
+
+(ert-deftest python-hideshow-hide-levels-1 ()
+  "Should hide all methods when called after class start."
+  (let ((enabled hs-minor-mode))
+    (unwind-protect
+        (progn
+          (python-tests-with-temp-buffer
+           "
+class SomeClass:
+
+    def __init__(self, arg, kwarg=1):
+        self.arg = arg
+        self.kwarg = kwarg
+
+    def filter(self, nums):
+        def fn(item):
+            return item in [self.arg, self.kwarg]
+        return filter(fn, nums)
+
+    def __str__(self):
+        return '%s-%s' % (self.arg, self.kwarg)
+"
+           (hs-minor-mode 1)
+           (python-tests-look-at "class SomeClass:")
+           (forward-line)
+           (hs-hide-level 1)
+           (should
+            (string=
+             (python-tests-visible-string)
+             "
+class SomeClass:
+
+    def __init__(self, arg, kwarg=1):
+    def filter(self, nums):
+    def __str__(self):"))))
+      (or enabled (hs-minor-mode -1)))))
+
+(ert-deftest python-hideshow-hide-levels-2 ()
+  "Should hide nested methods and parens at end of defun."
+  (let ((enabled hs-minor-mode))
+    (unwind-protect
+        (progn
+          (python-tests-with-temp-buffer
+           "
+class SomeClass:
+
+    def __init__(self, arg, kwarg=1):
+        self.arg = arg
+        self.kwarg = kwarg
+
+    def filter(self, nums):
+        def fn(item):
+            return item in [self.arg, self.kwarg]
+        return filter(fn, nums)
+
+    def __str__(self):
+        return '%s-%s' % (self.arg, self.kwarg)
+"
+           (hs-minor-mode 1)
+           (python-tests-look-at "def fn(item):")
+           (hs-hide-block)
+           (should
+            (string=
+             (python-tests-visible-string)
+             "
+class SomeClass:
+
+    def __init__(self, arg, kwarg=1):
+        self.arg = arg
+        self.kwarg = kwarg
+
+    def filter(self, nums):
+        def fn(item):
+        return filter(fn, nums)
+
+    def __str__(self):
+        return '%s-%s' % (self.arg, self.kwarg)
+"))))
+      (or enabled (hs-minor-mode -1)))))
+
+
 
 (provide 'python-tests)
 
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index 2398979..ecbc004 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
 
-;; Author: Nicolas Petton <address@hidden>
+;; Author: Nicolas Petton <address@hidden>
 ;; Maintainer: address@hidden
 
 ;; This file is part of GNU Emacs.
@@ -197,5 +197,29 @@ Evaluate BODY for each created sequence.
     (should (equal (seq-concatenate 'vector nil '(8 10)) [8 10]))
     (should (equal (seq-concatenate 'vector seq nil) [2 4 6]))))
 
+(ert-deftest test-seq-mapcat ()
+  (should (equal (seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)))
+                 '(1 2 3 4 5 6)))
+  (should (equal (seq-mapcat #'seq-reverse '[(3 2 1) (6 5 4)])
+                 '(1 2 3 4 5 6)))
+  (should (equal (seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)) 'vector)
+                 '[1 2 3 4 5 6])))
+
+(ert-deftest test-seq-partition ()
+  (should (same-contents-p (seq-partition '(0 1 2 3 4 5 6 7) 3)
+                           '((0 1 2) (3 4 5) (6 7))))
+  (should (same-contents-p (seq-partition '[0 1 2 3 4 5 6 7] 3)
+                           '([0 1 2] [3 4 5] [6 7])))
+  (should (same-contents-p (seq-partition "Hello world" 2)
+                           '("He" "ll" "o " "wo" "rl" "d")))
+  (should (equal (seq-partition '() 2) '()))
+  (should (equal (seq-partition '(1 2 3) -1) '())))
+
+(ert-deftest test-seq-group-by ()
+  (should (equal (seq-group-by #'test-sequences-oddp [1 2 3 4])
+                 '((t 3 1) (nil 4 2))))
+  (should (equal (seq-group-by #'car '((a 1) (b 3) (c 4) (a 2)))
+                 '((a (a 2) (a 1)) (b (b 3)) (c (c 4))))))
+
 (provide 'seq-tests)
 ;;; seq-tests.el ends here
diff --git a/test/automated/vc-tests.el b/test/automated/vc-tests.el
index 5b7b3cc..e83eb85 100644
--- a/test/automated/vc-tests.el
+++ b/test/automated/vc-tests.el
@@ -330,18 +330,20 @@ For backends which dont support it, `vc-not-supported' is 
signalled."
            (vc-working-revision default-directory backend) '("0" "master")))
 
          (let ((tmp-name (expand-file-name "foo" default-directory)))
-           ;; Check for initial state.
-           (should
-            (member (vc-working-revision tmp-name backend) '("0" "master")))
+           ;; Check for initial state, should be nil until it's registered.
+            ;; Don't pass the backend explictly, otherwise some implementations
+            ;; return non-nil.
+           (should (null (vc-working-revision tmp-name)))
 
-           ;; Write a new file.  Check for state.
+           ;; Write a new file.  Check state.
            (write-region "foo" nil tmp-name nil 'nomessage)
-           (should
-            (member (vc-working-revision tmp-name backend) '("0" "master")))
+           (should (null (vc-working-revision tmp-name)))
 
            ;; Register a file.  Check for state.
            (vc-register
             (list backend (list (file-name-nondirectory tmp-name))))
+            ;; FIXME: Don't pass the backend.  Emacs should be able to
+            ;; figure it out.
            (should
             (member (vc-working-revision tmp-name backend) '("0" "master")))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]