emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 2b41d6a 03/13: -


From: Paul Eggert
Subject: [Emacs-diffs] master 2b41d6a 03/13: -
Date: Sat, 30 Jan 2016 22:12:15 +0000

branch: master
commit 2b41d6a979b0ea361e078891b8763b4ae7be8092
Merge: fe9c8b6 71468e0
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    -
---
 doc/emacs/dired.texi         |   26 ++-
 doc/lispref/control.texi     |  224 +++++++++++------
 doc/lispref/elisp.texi       |    1 +
 doc/lispref/functions.texi   |  225 +++++++++++++++++
 etc/NEWS                     |   33 +++-
 lisp/progmodes/cc-engine.el  |  171 ++++++++++++-
 lisp/progmodes/cc-fonts.el   |   93 +-------
 lisp/textmodes/reftex-ref.el |    2 +-
 src/buffer.c                 |    8 +-
 src/dispextern.h             |   28 +--
 src/dispnew.c                |    7 +-
 src/emacs.c                  |    7 +-
 src/emacsgtkfixed.c          |   40 +--
 src/emacsgtkfixed.h          |    2 -
 src/gtkutil.c                |   28 ++-
 src/image.c                  |   67 +++---
 src/keyboard.c               |    4 +-
 src/lisp.h                   |    3 -
 src/print.c                  |   14 +-
 src/sysdep.c                 |    2 +
 src/window.c                 |    6 +-
 src/xdisp.c                  |   66 ++----
 src/xterm.c                  |   16 +-
 src/xwidget.c                |  554 ++++++++++++++++-------------------------
 src/xwidget.h                |  115 +++++-----
 25 files changed, 969 insertions(+), 773 deletions(-)

diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 92c1fd5..123f1ae 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -778,27 +778,31 @@ Byte compile the specified Emacs Lisp files
 Compilation, elisp, The Emacs Lisp Reference Manual}.
 
 @kindex A @r{(Dired)}
address@hidden dired-do-search
address@hidden dired-do-find-regexp
 @cindex search multiple files (in Dired)
 @item A @var{regexp} @key{RET}
 Search all the specified files for the regular expression @var{regexp}
-(@code{dired-do-search}).
+(@code{dired-do-find-regexp}).
 
-This command is a variant of @code{tags-search}.  The search stops at
-the first match it finds; use @kbd{M-x tags-loop-continue} to resume
-the search and find the next match.  @xref{Identifier Search}.
+This command is a variant of @code{xref-find-references}
+(@pxref{Identifier Search}), it displays the @file{*xref*} buffer,
+where you can navigate between matches and display them as needed
+using the commands described in @ref{Xref Commands}.
 
 @kindex Q @r{(Dired)}
address@hidden dired-do-query-replace-regexp
address@hidden dired-do-find-regexp-and-replace
 @cindex search and replace in multiple files (in Dired)
 @item Q @var{regexp} @key{RET} @var{to} @key{RET}
 Perform @code{query-replace-regexp} on each of the specified files,
 replacing matches for @var{regexp} with the string
address@hidden (@code{dired-do-query-replace-regexp}).
-
-This command is a variant of @code{tags-query-replace}.  If you exit the
-query replace loop, you can use @kbd{M-x tags-loop-continue} to resume
-the scan and replace more matches.  @xref{Identifier Search}.
address@hidden (@code{dired-do-find-regexp-and-replace}).
+
+This command is a variant of @code{xref-query-replace}.  It presents
+an @file{*xref*} buffer that lists all the matches of @var{regexp},
+and you can use the special commands in that buffer (@pxref{Xref
+Commands}).  In particular, if you exit the query replace loop, you
+can use @kbd{r} in that buffer to replace more matches.
address@hidden Search}.
 @end table
 
 @node Shell Commands in Dired
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 008a991..df60347 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -297,36 +297,147 @@ For example:
 @cindex pcase
 @cindex pattern matching
 
-To compare a particular value against various possible cases, the macro
address@hidden can come handy.  It takes the following form:
+The @code{cond} form lets you choose between alternatives using
+predicate conditions that compare values of expressions against
+specific values known and written in advance.  However, sometimes it
+is useful to select alternatives based on more general conditions that
+distinguish between broad classes of values.  The @code{pcase} macro
+allows to choose between alternatives based on matching the value of
+an expression against a series of patterns.  A pattern can be a
+literal value (comparison to literal values is what @code{cond} does),
+or it can be a more general description of the expected structure of
+the expression's value.
+
address@hidden pcase expression &rest clauses
+Evaluate @var{expression} and choose among an arbitrary number of
+alternatives based on the value of @var{expression}.  The possible
+alternatives are specified by @var{clauses}, each of which must be a
+list of the form @code{(@var{pattern} @var{body-forms})}.
address@hidden tries to match the value of @var{expression} to the
address@hidden of each clause, in textual order.  If the value matches,
+the clause succeeds; @code{pcase} then evaluates its @var{body-forms},
+and returns the value of the last of @var{body-forms}.  Any remaining
address@hidden are ignored.
+
+The @var{pattern} part of a clause can be of one of two types:
address@hidden, a pattern quoted with a backquote; or a
address@hidden, which is not quoted.  UPatterns are simpler, so we
+describe them first.
+
+Note: In the description of the patterns below, we use ``the value
+being matched'' to refer to the value of the @var{expression} that is
+the first argument of @code{pcase}.
+
+A UPattern can have one of the following forms:
 
address@hidden
-(pcase @var{exp} @var{branch}1 @var{branch}2 @var{branch}3 @dots{})
address@hidden example
address@hidden @code
 
-where each @var{branch} takes the form @code{(@var{upattern}
address@hidden@dots{})}.
address@hidden '@var{val}
+Matches if the value being matched is @code{equal} to @var{val}.
address@hidden @var{atom}
+Matches any @var{atom}, which can be a keyword, a number, or a string.
+(These are self-quoting, so this kind of UPattern is actually a
+shorthand for @code{'@var{atom}}.)
address@hidden _
+Matches any value.  This is known as @dfn{don't care} or @dfn{wildcard}.
address@hidden @var{symbol}
+Matches any value, and additionally let-binds @var{symbol} to the
+value it matched, so that you can later refer to it, either in the
address@hidden or also later in the pattern.
address@hidden (pred @var{predfun})
+Matches if the predicate function @var{predfun} returns address@hidden
+when called with the value being matched as its argument.
address@hidden can be one of the possible forms described below.
address@hidden (guard @var{boolean-expression})
+Matches if @var{boolean-expression} evaluates to address@hidden  This
+allows to include in a UPattern boolean conditions that refer to
+symbols bound to values (including the value being matched) by
+previous UPatterns.  Typically used inside an @code{and} UPattern, see
+below.  For example, @address@hidden(and x (guard (< x 10)))}} is a pattern
+which matches any number smaller than 10 and let-binds the variable
address@hidden to that number.
address@hidden (let @var{upattern} @var{expression})
+Matches if the specified @var{expression} matches the specified
address@hidden  This allows to match a pattern against the value of
+an @emph{arbitrary} expression, not just the expression that is the
+first argument to @code{pcase}.  (It is called @code{let} because
address@hidden can bind symbols to values using the @var{symbol}
+UPattern.)
address@hidden (app @var{function} @var{upattern})
+Matches if @var{function} applied to the value being matched returns a
+value that matches @var{upattern}.  This is like the @code{pred}
+UPattern, except that it tests the result against @var{UPattern},
+rather than against a boolean truth value.  The @var{function} call can
+use one of the forms described below.
address@hidden (or @var{upattern1} @address@hidden)
+Matches if one the argument UPatterns matches.  As soon as the first
+matching UPattern is found, the rest are not tested.  For this reason,
+if any of the UPatterns let-bind symbols to the matched value, they
+should all bind the same symbols.
address@hidden (and @var{upattern1} @address@hidden)
+Matches if all the argument UPatterns match.
address@hidden table
+
+The function calls used in the @code{pred} and @code{app} UPatterns
+can have one of the following forms:
+
address@hidden @asis
address@hidden function symbol, like @code{integerp}
+In this case, the named function is applied to the value being
+matched.
address@hidden lambda-function @code{(lambda (@var{arg}) @var{body})}
+In this case, the lambda-function is called with one argument, the
+value being matched.
address@hidden @code{(@var{func} @address@hidden)}
+This is a function call with @var{n} specified arguments; the function
+is called with these @var{n} arguments and an additional @var{n}+1-th
+argument that is the value being matched.
address@hidden table
 
-It will first evaluate @var{exp} and then compare the value against each
address@hidden to see which @var{branch} to use, after which it will run the
-corresponding @var{body-forms}.  A common use case is to distinguish
-between a few different constant values:
+Here's an illustrative example of using UPatterns:
 
address@hidden FIXME: This example should use every one of the UPatterns 
described
address@hidden above at least once.
 @example
 (pcase (get-return-code x)
-  (`success       (message "Done!"))
-  (`would-block   (message "Sorry, can't do it now"))
-  (`read-only     (message "The shmliblick is read-only"))
-  (`access-denied (message "You do not have the needed rights"))
+  ('success       (message "Done!"))
+  ('would-block   (message "Sorry, can't do it now"))
+  ('read-only     (message "The shmliblick is read-only"))
+  ('access-denied (message "You do not have the needed rights"))
   (code           (message "Unknown return code %S" code)))
 @end example
 
-In the last clause, @code{code} is a variable that gets bound to the value that
-was returned by @code{(get-return-code x)}.
+The QPatterns are more powerful.  They allow to match the value of the
address@hidden that is the first argument of @code{pcase} against
+specifications of its @emph{structure}.  For example, you can specify
+that the value must be a list of 2 elements whose first element is a
+string and the second element is a number.  QPatterns can have one of
+the following forms:
+
address@hidden @code
address@hidden `(@var{qpattern1} . @var{qpattern2})
+Matches if the value being matched is a cons cell whose @code{car}
+matches @var{qpattern1} and whose @code{cdr} matches @var{qpattern2}.
address@hidden address@hidden @var{qpattern2} @dots{} @var{qpatternm}]
+Matches if the value being matched is a vector of length @var{m} whose
address@hidden@code{(@var{m}-1)}th elements match @var{qpattern1},
address@hidden @dots{} @var{qpatternm}, respectively.
address@hidden `(,@var{upattern1} ,@var{upattern2} @dots{})
+Matches if the value being matched is a list whose elements match the
+corresponding @var{upattern1}, @var{upattern2}, etc.
address@hidden @var{atom}
+Matches if corresponding element of the value being matched is
address@hidden to the specified @var{atom}.
address@hidden ,@var{upattern}
+Matches if the corresponding element of the value being matched
+matches the specified @var{upattern}.
address@hidden table
+
address@hidden defmac
 
-To give a more complex example, a simple interpreter for a little
-expression language could look like (note that this example requires
-lexical binding):
+Here is an example of using @code{pcase} to implement a simple
+interpreter for a little expression language (note that this example
+requires lexical binding, @pxref{Lexical Binding}):
 
 @example
 (defun evaluate (exp env)
@@ -340,13 +451,19 @@ lexical binding):
     (_                  (error "Unknown expression %S" exp))))
 @end example
 
-Where @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a three
-element list starting with the symbol @code{add}, then extracts the second and
-third elements and binds them to the variables @code{x} and @code{y}.
address@hidden(pred numberp)} is a pattern that simply checks that @code{exp}
-is a number, and @code{_} is the catch-all pattern that matches anything.
+Here @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a
+three-element list starting with the literal symbol @code{add}, then
+extracts the second and third elements and binds them to the variables
address@hidden and @code{y}.  Then it evaluates @code{x} and @code{y} and
+adds the results.  The @code{call} and @code{fn} patterns similarly
+implement two flavors of function calls.  @code{(pred numberp)} is a
+pattern that simply checks that @code{exp} is a number and if so,
+evaluates it.  @code{(pred symbolp)} matches symbols, and returns
+their association.  Finally, @code{_} is the catch-all pattern that
+matches anything, so it's suitable for reporting syntax errors.
 
-Here are some sample programs including their evaluation results:
+Here are some sample programs in this small language, including their
+evaluation results:
 
 @example
 (evaluate '(add 1 2) nil)                 ;=> 3
@@ -355,56 +472,13 @@ Here are some sample programs including their evaluation 
results:
 (evaluate '(sub 1 2) nil)                 ;=> error
 @end example
 
-There are two kinds of patterns involved in @code{pcase}, called
address@hidden and @emph{Q-patterns}.  The @var{upattern} mentioned above
-are U-patterns and can take the following forms:
+Additional UPatterns can be defined using the @code{pcase-defmacro}
+macro.
 
address@hidden @code
address@hidden address@hidden
-This is one of the most common form of patterns.  The intention is to mimic the
-backquote macro: this pattern matches those values that could have been built
-by such a backquote expression.  Since we're pattern matching rather than
-building a value, the unquote does not indicate where to plug an expression,
-but instead it lets one specify a U-pattern that should match the value at
-that location.
-
-More specifically, a Q-pattern can take the following forms:
address@hidden @code
address@hidden (@var{qpattern1} . @var{qpattern2})
-This pattern matches any cons cell whose @code{car} matches @var{qpattern1} and
-whose @code{cdr} matches @var{qpattern2}.
address@hidden address@hidden @var{qpattern2} @dots{} @var{qpatternm}]
-This pattern matches a vector of length @var{M} whose 0..(@var{M}-1)th
-elements match @var{qpattern1}, @var{qpattern2} @dots{} @var{qpatternm},
-respectively.
address@hidden @var{atom}
-This pattern matches any atom @code{equal} to @var{atom}.
address@hidden ,@var{upattern}
-This pattern matches any object that matches the @var{upattern}.
address@hidden table
-
address@hidden @var{symbol}
-A mere symbol in a U-pattern matches anything, and additionally let-binds this
-symbol to the value that it matched, so that you can later refer to it, either
-in the @var{body-forms} or also later in the pattern.
address@hidden _
-This so-called @emph{don't care} pattern matches anything, like the previous
-one, but unlike symbol patterns it does not bind any variable.
address@hidden (pred @var{pred})
-This pattern matches if the function @var{pred} returns address@hidden when
-called with the object being matched.
address@hidden (or @var{upattern1} @address@hidden)
-This pattern matches as soon as one of the argument patterns succeeds.
-All argument patterns should let-bind the same variables.
address@hidden (and @var{upattern1} @address@hidden)
-This pattern matches only if all the argument patterns succeed.
address@hidden (guard @var{exp})
-This pattern ignores the object being examined and simply succeeds if @var{exp}
-evaluates to address@hidden and fails otherwise.  It is typically used inside
-an @code{and} pattern.  For example, @code{(and x (guard (< x 10)))}
-is a pattern which matches any number smaller than 10 and let-binds it to
-the variable @code{x}.
address@hidden table
address@hidden pcase-defmacro name args &rest body
+Define a new UPattern for @code{pcase}.  The UPattern will have the
+form @code{(@var{name} @var{args})}.
address@hidden defmac
 
 @node Combining Conditions
 @section Constructs for Combining Conditions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index da519f5..4c1541e 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -536,6 +536,7 @@ Functions
 * Calling Functions::       How to use an existing function.
 * Mapping Functions::       Applying a function to each element of a list, etc.
 * Anonymous Functions::     Lambda expressions are functions with no names.
+* Generic Functions::       Polymorphism, Emacs-style.
 * Function Cells::          Accessing or setting the function definition
                               of a symbol.
 * Closures::                Functions that enclose a lexical environment.
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 1e8e754..c5f5b4c 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -18,6 +18,7 @@ define them.
 * Calling Functions::           How to use an existing function.
 * Mapping Functions::           Applying a function to each element of a list, 
etc.
 * Anonymous Functions::         Lambda expressions are functions with no names.
+* Generic Functions::           Polymorphism, Emacs-style.
 * Function Cells::              Accessing or setting the function definition
                             of a symbol.
 * Closures::                    Functions that enclose a lexical environment.
@@ -1092,6 +1093,230 @@ the compiled code.  The byte-compiler cannot assume 
this list is a
 function, even though it looks like one, since it does not know that
 @code{change-property} intends to use it as a function.
 
address@hidden Generic Functions
address@hidden Generic Functions
address@hidden generic functions
address@hidden polymorphism
+
+  Functions defined using @code{defun} have a hard-coded set of
+assumptions about the types and expected values of their arguments.
+For example, a function that was designed to handle values of its
+argument that are either numbers or lists of numbers will fail or
+signal an error if called with a value of any other type, such as a
+vector or a string.  This happens because the implementation of the
+function is not prepared to deal with types other than those assumed
+during the design.
+
+  By contrast, object-oriented programs use @dfn{polymorphic
+functions}: a set of specialized functions having the same name, each
+one of which was written for a certain specific set of argument types.
+Which of the functions is actually called is decided at run time based
+on the types of the actual arguments.
+
address@hidden CLOS
+  Emacs provides support for polymorphism.  Like other Lisp
+environments, notably Common Lisp and its Common Lisp Object System
+(@acronym{CLOS}), this support is based on @dfn{generic functions}.
+The Emacs generic functions closely follow @acronym{CLOS}, including
+use of similar names, so if you have experience with @acronym{CLOS},
+the rest of this section will sound very familiar.
+
+  A generic function specifies an abstract operation, by defining its
+name and list of arguments, but (usually) no implementation.  The
+actual implementation for several specific classes of arguments is
+provided by @dfn{methods}, which should be defined separately.  Each
+method that implements a generic function has the same name as the
+generic function, but the method's definition indicates what kinds of
+arguments it can handle by @dfn{specializing} the arguments defined by
+the generic function.  These @dfn{argument specializers} can be more
+or less specific; for example, a @code{string} type is more specific
+than a more general type, such as @code{sequence}.
+
+  Note that, unlike in message-based OO languages, such as address@hidden and
+Simula, methods that implement generic functions don't belong to a
+class, they belong to the generic function they implement.
+
+  When a generic function is invoked, it selects the applicable
+methods by comparing the actual arguments passed by the caller with
+the argument specializers of each method.  A method is applicable if
+the actual arguments of the call are compatible with the method's
+specializers.  If more than one method is applicable, they are
+combined using certain rules, described below, and the combination
+then handles the call.
+
address@hidden cl-defgeneric name arguments [documentation] address@hidden 
&rest body
+This macro defines a generic function with the specified @var{name}
+and @var{arguments}.  If @var{body} is present, it provides the
+default implementation.  If @var{documentation} is present (it should
+always be), it specifies the documentation string for the generic
+function, in the form @code{(:documentation @var{docstring})}.  The
+optional @var{options-and-methods} can be one of the following forms:
+
address@hidden @code
address@hidden (declare @var{declarations})
+A declare form, as described in @ref{Declare Form}.
address@hidden (:argument-precedence-order &rest @var{args})
+This form affects the sorting order for combining applicable methods.
+Normally, when two methods are compared during combination, method
+arguments are examined left to right, and the first method whose
+argument specializer is more specific will come before the other one.
+The order defined by this form overrides that, and the arguments are
+examined according to their order in this form, and not left to right.
address@hidden (:method address@hidden@dots{}] args &rest body)
+This form defines a method like @code{cl-defmethod} does.
address@hidden table
address@hidden defmac
+
address@hidden cl-defmethod name [qualifier] arguments &rest [docstring] body
+This macro defines a particular implementation for the generic
+function called @var{name}.  The implementation code is given by
address@hidden  If present, @var{docstring} is the documentation string
+for the method.  The @var{arguments} list, which must be identical in
+all the methods that implement a generic function, and must match the
+argument list of that function, provides argument specializers of the
+form @code{(@var{arg} @var{spec})}, where @var{arg} is the argument
+name as specified in the @code{cl-defgeneric} call, and @var{spec} is
+one of the following specializer forms:
+
address@hidden @code
address@hidden @var{type}
+This specializer requires the argument to be of the given @var{type},
+one of the types from the type hierarchy described below.
address@hidden (eql @var{object})
+This specializer requires the argument be @code{eql} to the given
address@hidden
address@hidden (head @var{object})
+The argument must be a cons cell whose @code{car} is @code{eql} to
address@hidden
address@hidden @var{struct-tag}
+The argument must be an instance of a class named @var{struct-tag}
+defined with @code{cl-defstruct} (@pxref{Structures,,, cl, Common Lisp
+Extensions for GNU Emacs Lisp}), or of one of its parent classes.
address@hidden table
+
+Alternatively, the argument specializer can be of the form
address@hidden&context (@var{expr} @var{spec})}, in which case the value of
address@hidden must be compatible with the specializer provided by
address@hidden; @var{spec} can be any of the forms described above.  In
+other words, this form of specializer uses the value of @var{expr}
+instead of arguments for the decision whether the method is
+applicable.  For example, @code{&context (overwrite-mode (eql t))}
+will make the method compatible only when @code{overwrite-mode} is
+turned on.
+
+The type specializer, @code{(@var{arg} @var{type})}, can specify one
+of the @dfn{system types} in the following list.  When a parent type
+is specified, an argument whose type is any of its more specific child
+types, as well as grand-children, grand-grand-children, etc. will also
+be compatible.
+
address@hidden @code
address@hidden integer
+Parent type: @code{number}.
address@hidden number
address@hidden null
+Parent type: @code{symbol}
address@hidden symbol
address@hidden string
+Parent type: @code{array}.
address@hidden array
+Parent type: @code{sequence}.
address@hidden cons
+Parent type: @code{list}.
address@hidden list
+Parent type: @code{sequence}.
address@hidden marker
address@hidden overlay
address@hidden float
+Parent type: @code{number}.
address@hidden window-configuration
address@hidden process
address@hidden window
address@hidden subr
address@hidden compiled-function
address@hidden buffer
address@hidden char-table
+Parent type: @code{array}.
address@hidden bool-vector
+Parent type: @code{array}.
address@hidden vector
+Parent type: @code{array}.
address@hidden frame
address@hidden hash-table
address@hidden font-spec
address@hidden font-entity
address@hidden font-object
address@hidden table
+
+The optional @var{qualifier} allows to combine several applicable
+methods.  If it is not present, the defined method is a @dfn{primary}
+method, responsible for providing the primary implementation of the
+generic function for the specialized arguments.  You can also define
address@hidden methods}, by using one of the following values as
address@hidden:
+
address@hidden @code
address@hidden :before
+This auxiliary method will run before the primary method.  More
+accurately, all the @code{:before} methods will run before the
+primary, in the most-specific-first order.
address@hidden :after
+This auxiliary method will run after the primary method.  More
+accurately, all such methods will run after the primary, in the
+most-specific-last order.
address@hidden :around
+This auxiliary method will run @emph{instead} of the primary method.
+The most specific of such methods will be run before any other method.
+Such methods normally use @code{cl-call-next-method}, described below,
+to invoke the other auxiliary or primary methods.
address@hidden :extra @var{string}
+This allows to add more methods, distinguished by @var{string}, for
+the same specializers and qualifiers.
address@hidden table
address@hidden defmac
+
address@hidden dispatch of methods for generic function
address@hidden multiple-dispatch methods
+Each time a generic function is called, it builds the @dfn{effective
+method} which will handle this invocation by combining the applicable
+methods defined for the function.  The process of finding the
+applicable methods and producing the effective method is called
address@hidden  The applicable methods are those all of whose
+specializers are compatible with the actual arguments of the call.
+Since all of the arguments must be compatible with the specializers,
+they all determine whether a method is applicable.  Methods that
+explicitly specialize more than one argument are called
address@hidden methods}.
+
+The applicable methods are sorted into the order in which they will be
+combined.  The method whose left-most argument specializer is the most
+specific one will come first in the order.  (Specifying
address@hidden:argument-precedence-order} as part of @code{cl-defmethod}
+overrides that, as described above.)  If the method body calls
address@hidden, the next most-specific method will run.
+If there are applicable @code{:around} methods, the most-specific of
+them will run first; it should call @code{cl-call-next-method} to run
+any of the less specific @code{:around} methods.  Next, the
address@hidden:before} methods run in the order of their specificity, followed
+by the primary method, and lastly the @code{:after} methods in the
+reverse order of their specificity.
+
address@hidden cl-call-next-method &rest args
+When invoked from within the lexical body of a primary or an
address@hidden:around} auxiliary method, call the next applicable method for
+the same generic function.  Normally, it is called with no arguments,
+which means to call the next applicable method with the same arguments
+that the calling method was invoked.  Otherwise, the specified
+arguments are used instead.
address@hidden defun
+
address@hidden cl-next-method-p
+This function, when called from within the lexical body of a primary
+or an @code{:around} auxiliary method, returns address@hidden if there
+is a next method to call.
address@hidden defun
+
+
 @node Function Cells
 @section Accessing Function Cell Contents
 
diff --git a/etc/NEWS b/etc/NEWS
index 4a370a9..1cc45c3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,8 @@ by setting `autoload-timestamps' to nil.
 ** New configure option --with-cairo.
 This builds Emacs with Cairo drawing.  As a side effect, it provides
 support for built-in printing, when Emacs was built with GTK+.
+Cairo drawing is an experimental feature in Emacs, and subject to
+change in future releases.
 
 +++
 ** New configure option --with-modules.
@@ -577,9 +579,12 @@ If you need your objects to be named, do it by inheriting 
from `eieio-named'.
 *** The <class> variables are declared obsolete.
 +++
 *** The <initarg> variables are declared obsolete.
++++
 *** defgeneric and defmethod are declared obsolete.
+Use the equivalent facilities from cl-generic.el instead.
 +++
 *** `constructor' is now an obsolete alias for `make-instance'.
+--- `pcase' accepts a new UPattern `eieio'.
 
 ** ido
 
@@ -772,6 +777,9 @@ prepending it.
 +++
 *** New functions `cl-fresh-line', `cl-digit-char-p', and `cl-parse-integer'.
 
+---
+*** `pcase' accepts the new UPattern `cl-struct'.
+
 ** Calendar and diary
 
 +++
@@ -1073,6 +1081,10 @@ As a result of this, the following commands are now 
obsolete:
 replacements yet.
 
 +++
+*** Variants of `tags-search' and `tags-query-replace' in Dired were also
+replaced by xref-style commands, see the "Dired" section below.
+
++++
 *** New variables
 
 `find-tag-marker-ring-length' is now an obsolete alias for
@@ -1216,6 +1228,17 @@ compression command is determined from the new
 *** `W' is now bound to `browse-url-of-dired-file', and is useful for
 viewing HTML files and the like.
 
+*** New user interface for the `A' and `Q' commands.
+These keys, now bound to `dired-do-find-regexp' and
+`dired-do-find-regexp-and-replace', work similarly to
+`xref-find-apropos' and `xref-query-replace': they present the matches
+in the `*xref*' buffer and let you move through the matches.  No need
+to use `tags-loop-continue' to resume the search or replace loop.  The
+previous commands, `dired-do-search' and
+`dired-do-query-replace-regexp', are still available, but not bound to
+keys; rebind `A' and `Q' to invoke them if you want the old behavior
+back.  We intend to obsolete the old commands in a future release.
+
 ** Tabulated List Mode
 
 +++
@@ -1246,7 +1269,10 @@ command is called from Emacs (i.e., INSIDE_EMACS 
environment variable
 is set).  This feature requires newer versions of GnuPG (2.1.5 or
 later) and Pinentry (0.9.5 or later).
 
++++
 ** cl-generic.el provides CLOS-style multiple-dispatch generic functions.
+The main entry points are `cl-defgeneric' and `cl-defmethod'.  See the
+node "Generic Functions" in the Emacs Lisp manual for more details.
 
 ---
 ** scss-mode (a minor variant of css-mode)
@@ -1266,11 +1292,12 @@ a typographically-correct documents.
 ** The `seq' library adds sequence manipulation functions and macros
 that complement basic functions provided by subr.el.  All functions
 are prefixed with `seq-' and work on lists, strings and vectors.
+`pcase' accepts a new Upattern `seq'.
 
 ---
 ** The `map' library provides map-manipulation functions that work on
 alists, hash-table and arrays.  All functions are prefixed with
-`map-'.
+`map-'.  `pcase' accepts a new UPattern `map'.
 
 ---
 ** The `thunk' library provides functions and macros to control the
@@ -1441,7 +1468,9 @@ that happen, `unhandled-file-name-directory' now defaults 
to calling
 * Lisp Changes in Emacs 25.1
 
 ** pcase
-*** New UPatterns `quote', `app', `cl-struct', `eieio', `seq', and `map'.
++++
+*** New UPatterns `quote', `app'.
++++
 *** New UPatterns can be defined with `pcase-defmacro'.
 +++
 *** New vector QPattern.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index b08c555..7d3f528 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6802,6 +6802,110 @@ comment at the start of cc-engine.el for more info."
        ;; This identifier is bound only in the inner let.
        '(setq start id-start))))
 
+(defun c-forward-declarator (&optional limit)
+  ;; Assuming point is at the start of a declarator, move forward over it,
+  ;; leaving point at the next token after it (e.g. a ) or a ; or a ,).
+  ;;
+  ;; Return a list (ID-START ID-END BRACKETS-AFTER-ID GOT-INIT), where 
ID-START and
+  ;; ID-END are the bounds of the declarator's identifier, and
+  ;; BRACKETS-AFTER-ID is non-nil if a [...] pair is present after the id.
+  ;; GOT-INIT is non-nil when the declarator is followed by "=" or "(".
+  ;;
+  ;; If no declarator is found, leave point unmoved and return nil.  LIMIT is
+  ;; an optional limit for forward searching.
+  ;;
+  ;; Note that the global variable `c-last-identifier-range' is written to, so
+  ;; the caller should bind it if necessary.
+
+  ;; Inside the following "condition form", we move forward over the
+  ;; declarator's identifier up as far as any opening bracket (for array
+  ;; size) or paren (for parameters of function-type) or brace (for
+  ;; array/struct initialization) or "=" or terminating delimiter
+  ;; (e.g. "," or ";" or "}").
+  (let ((here (point))
+       id-start id-end brackets-after-id paren-depth)
+    (or limit (setq limit (point-max)))
+    (if        (and
+        (< (point) limit)
+
+        ;; The following form moves forward over the declarator's
+        ;; identifier (and what precedes it), returning t.  If there
+        ;; wasn't one, it returns nil.
+        (let (got-identifier)
+          (setq paren-depth 0)
+          ;; Skip over type decl prefix operators, one for each iteration
+          ;; of the while.  These are, e.g. "*" in "int *foo" or "(" and
+          ;; "*" in "int (*foo) (void)" (Note similar code in
+          ;; `c-forward-decl-or-cast-1'.)
+          (while (and (looking-at c-type-decl-prefix-key)
+                      (if (and (c-major-mode-is 'c++-mode)
+                               (match-beginning 3))
+                          ;; If the third submatch matches in C++ then
+                          ;; we're looking at an identifier that's a
+                          ;; prefix only if it specifies a member pointer.
+                          (progn
+                            (setq id-start (point))
+                            (c-forward-name)
+                            (if (looking-at "\\(::\\)")
+                                ;; We only check for a trailing "::" and
+                                ;; let the "*" that should follow be
+                                ;; matched in the next round.
+                                t
+                              ;; It turned out to be the real identifier,
+                              ;; so flag that and stop.
+                              (setq got-identifier t)
+                              nil))
+                        t))
+            (if (eq (char-after) ?\()
+                (progn
+                  (setq paren-depth (1+ paren-depth))
+                  (forward-char))
+              (goto-char (match-end 1)))
+            (c-forward-syntactic-ws))
+
+          ;; If we haven't passed the identifier already, do it now.
+          (unless got-identifier
+            (setq id-start (point))
+            (c-forward-name))
+          (prog1
+              (/= (point) here)
+            (save-excursion
+              (c-backward-syntactic-ws)
+              (setq id-end (point)))))
+
+        ;; Skip out of the parens surrounding the identifier.  If closing
+        ;; parens are missing, this form returns nil.
+        (or (= paren-depth 0)
+            (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
+
+        (<= (point) limit)
+
+        ;; Skip over any trailing bit, such as "__attribute__".
+        (progn
+          (when (looking-at c-decl-hangon-key)
+            (c-forward-keyword-clause 1))
+          (<= (point) limit))
+
+        ;; Search syntactically to the end of the declarator (";",
+        ;; ",", a closing paren, eob etc) or to the beginning of an
+        ;; initializer or function prototype ("=" or "\\s\(").
+        ;; Note that square brackets are now not also treated as
+        ;; initializers, since this broke when there were also
+        ;; initializing brace lists.
+        (let (found)
+          (while
+              (and (setq found (c-syntactic-re-search-forward
+                                "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t 
t))
+                   (eq (char-before) ?\[)
+                   (c-go-up-list-forward))
+            (setq brackets-after-id t))
+          (backward-char)
+          found))
+       (list id-start id-end brackets-after-id (match-beginning 1))
+
+      (goto-char here)
+      nil)))
+
 (defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
   ;; Move forward over a declaration or a cast if at the start of one.
   ;; The point is assumed to be at the start of some token.  Nil is
@@ -8156,14 +8260,14 @@ comment at the start of cc-engine.el for more info."
   ;; Return the position of the first argument declaration if point is
   ;; inside a K&R style argument declaration list, nil otherwise.
   ;; `c-recognize-knr-p' is not checked.  If LIM is non-nil, it's a
-  ;; position that bounds the backward search for the argument list.
+  ;; position that bounds the backward search for the argument list.  This
+  ;; function doesn't move point.
   ;;
   ;; Point must be within a possible K&R region, e.g. just before a top-level
   ;; "{".  It must be outside of parens and brackets.  The test can return
   ;; false positives otherwise.
   ;;
   ;; This function might do hidden buffer changes.
-
   (save-excursion
     (save-restriction
       ;; If we're in a macro, our search range is restricted to it.  Narrow to
@@ -8172,8 +8276,12 @@ comment at the start of cc-engine.el for more info."
             (macro-end (save-excursion (and macro-start (c-end-of-macro) 
(point))))
             (low-lim (max (or lim (point-min))   (or macro-start (point-min))))
             before-lparen after-rparen
-            (pp-count-out 20)) ; Max number of paren/brace constructs before
+            (here (point))
+            (pp-count-out 20)  ; Max number of paren/brace constructs before
                                ; we give up
+            ids              ; List of identifiers in the parenthesised list.
+            id-start after-prec-token decl-or-cast decl-res
+            c-last-identifier-range identifier-ok)
        (narrow-to-region low-lim (or macro-end (point-max)))
 
        ;; Search backwards for the defun's argument list.  We give up if we
@@ -8192,8 +8300,12 @@ comment at the start of cc-engine.el for more info."
        ;; int foo (bar, baz, yuk)
        ;;     int bar [] ;
        ;;     int (*baz) (my_type) ;
-       ;;     int (*) (void) (*yuk) (void) ;
+       ;;     int (*(* yuk) (void)) (void) ;
        ;; {
+       ;;
+       ;; Additionally, for a knr list to be recognized:
+       ;; o - The identifier of each deeclarator up to and including the
+       ;;   one "near" point must be contained in the arg list.
 
        (catch 'knr
          (while (> pp-count-out 0) ; go back one paren/bracket pair each time.
@@ -8239,21 +8351,58 @@ comment at the start of cc-engine.el for more info."
                       (goto-char before-lparen)
                       (c-forward-token-2) ; to first token inside parens
                       (and
-                       (c-on-identifier)
-                       (c-forward-token-2)
+                       (setq id-start (c-on-identifier)) ; Must be at least 
one.
                        (catch 'id-list
-                         (while (eq (char-after) ?\,)
+                         (while
+                             (progn
+                               (forward-char)
+                               (c-end-of-current-token)
+                               (push (buffer-substring-no-properties id-start
+                                                                     (point))
+                                     ids)
+                               (c-forward-syntactic-ws)
+                               (eq (char-after) ?\,))
                            (c-forward-token-2)
-                           (unless (c-on-identifier) (throw 'id-list nil))
-                           (c-forward-token-2))
-                         (eq (char-after) ?\))))))
+                           (unless (setq id-start (c-on-identifier))
+                             (throw 'id-list nil)))
+                         (eq (char-after) ?\)))))
 
+                    ;; Are all the identifiers in the k&r list up to the
+                    ;; current one also in the argument list?
+                    (progn
+                      (forward-char)   ; over the )
+                      (setq after-prec-token after-rparen)
+                      (c-forward-syntactic-ws)
+                      (while (and
+                              (or (consp (setq decl-or-cast
+                                               (c-forward-decl-or-cast-1
+                                                after-prec-token
+                                                nil ; Or 'arglist ???
+                                                nil)))
+                                  (progn
+                                    (goto-char after-prec-token)
+                                    (c-forward-syntactic-ws)
+                                    (setq identifier-ok (eq (char-after) ?{))
+                                    nil))
+                              (eq (char-after) ?\;)
+                              (setq after-prec-token (1+ (point)))
+                              (goto-char (car decl-or-cast))
+                              (setq decl-res (c-forward-declarator))
+                              (setq identifier-ok
+                                    (member (buffer-substring-no-properties
+                                       (car decl-res) (cadr decl-res))
+                                      ids))
+                              (progn
+                                (goto-char after-prec-token)
+                                (prog1 (< (point) here)
+                                  (c-forward-syntactic-ws))))
+                        (setq identifier-ok nil))
+                      identifier-ok))
                    ;; ...Yes.  We've identified the function's argument list.
                    (throw 'knr
                           (progn (goto-char after-rparen)
                                  (c-forward-syntactic-ws)
                                  (point)))
-
                  ;; ...No.  The current parens aren't the function's arg list.
                  (goto-char before-lparen))
 
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 03e67a9..1e101d1 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1006,6 +1006,7 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   ;;(message "c-font-lock-declarators from %s to %s" (point) limit)
   (c-fontify-types-and-refs
       ((pos (point)) next-pos id-start id-end
+       decl-res
        paren-depth
        id-face got-init
        c-last-identifier-range
@@ -1015,93 +1016,15 @@ casts and declarations are fontified.  Used on level 2 
and higher."
     ;; The following `while' fontifies a single declarator id each time round.
     ;; It loops only when LIST is non-nil.
     (while
-       ;; Inside the following "condition form", we move forward over the
-       ;; declarator's identifier up as far as any opening bracket (for array
-       ;; size) or paren (for parameters of function-type) or brace (for
-       ;; array/struct initialization) or "=" or terminating delimiter
-       ;; (e.g. "," or ";" or "}").
-       (and
-           pos
-           (< (point) limit)
-
-           ;; The following form moves forward over the declarator's
-           ;; identifier (and what precedes it), returning t.  If there
-           ;; wasn't one, it returns nil, terminating the `while'.
-           (let (got-identifier)
-             (setq paren-depth 0)
-             ;; Skip over type decl prefix operators, one for each iteration
-             ;; of the while.  These are, e.g. "*" in "int *foo" or "(" and
-             ;; "*" in "int (*foo) (void)" (Note similar code in
-             ;; `c-forward-decl-or-cast-1'.)
-             (while (and (looking-at c-type-decl-prefix-key)
-                         (if (and (c-major-mode-is 'c++-mode)
-                                  (match-beginning 3))
-                             ;; If the third submatch matches in C++ then
-                             ;; we're looking at an identifier that's a
-                             ;; prefix only if it specifies a member pointer.
-                             (progn
-                               (setq id-start (point))
-                               (c-forward-name)
-                               (if (looking-at "\\(::\\)")
-                                   ;; We only check for a trailing "::" and
-                                   ;; let the "*" that should follow be
-                                   ;; matched in the next round.
-                                   t
-                                 ;; It turned out to be the real identifier,
-                                 ;; so flag that and stop.
-                                 (setq got-identifier t)
-                                 nil))
-                           t))
-               (if (eq (char-after) ?\()
-                   (progn
-                     (setq paren-depth (1+ paren-depth))
-                     (forward-char))
-                 (goto-char (match-end 1)))
-               (c-forward-syntactic-ws))
-
-             ;; If we haven't passed the identifier already, do it now.
-             (unless got-identifier
-               (setq id-start (point))
-               (c-forward-name))
-             (setq id-end (point))
-
-             (/= id-end pos))
-
-           ;; Skip out of the parens surrounding the identifier.  If closing
-           ;; parens are missing, this form returns nil.
-           (or (= paren-depth 0)
-               (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
-
-           (<= (point) limit)
-
-           ;; Skip over any trailing bit, such as "__attribute__".
-           (progn
-             (when (looking-at c-decl-hangon-key)
-               (c-forward-keyword-clause 1))
-             (<= (point) limit))
-
-           ;; Search syntactically to the end of the declarator (";",
-           ;; ",", a closing paren, eob etc) or to the beginning of an
-           ;; initializer or function prototype ("=" or "\\s(").
-           ;; Note that square brackets are now not also treated as
-           ;; initializers, since this broke when there were also
-           ;; initializing brace lists.
-           (let (found)
-             (while
-                 (and (setq found (c-syntactic-re-search-forward
-                            "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
-                      (eq (char-before) ?\[)
-                      (c-go-up-list-forward))
-                    (setq brackets-after-id t))
-             found))
-
-      (setq next-pos (match-beginning 0)
-           id-face (if (and (eq (char-after next-pos) ?\()
-                            (not brackets-after-id))
+       (and pos (setq decl-res (c-forward-declarator limit)))
+      (setq next-pos (point)
+           id-start (car decl-res)
+           id-face (if (and (eq (char-after) ?\()
+                            (not (car (cddr decl-res)))) ; brackets-after-id
                        'font-lock-function-name-face
                      'font-lock-variable-name-face)
-           got-init (and (match-beginning 1)
-                         (char-after (match-beginning 1))))
+           got-init (and (cadr (cddr decl-res)) ; got-init
+                         (char-after)))
 
       (if types
          ;; Register and fontify the identifier as a type.
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 7f13ed5..f5a784b 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -228,7 +228,7 @@ This function is controlled by the settings of 
reftex-insert-label-flags."
                                  (symbol-value reftex-docstruct-symbol)))
               (ding)
               (if (y-or-n-p
-`                  (format-message "Label `%s' exists. Use anyway? " label))
+                   (format-message "Label `%s' exists. Use anyway? " label))
                   (setq valid t)))
 
              ;; Label is ok
diff --git a/src/buffer.c b/src/buffer.c
index 51bbad7..0c52eaf 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -42,10 +42,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "blockinput.h"
 #include "keymap.h"
 #include "frame.h"
+#include "xwidget.h"
 
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
 #ifdef WINDOWSNT
 #include "w32heap.h"           /* for mmap_* */
 #endif
@@ -1749,10 +1747,8 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
   unlock_buffer (b);
 
   kill_buffer_processes (buffer);
-
-#ifdef HAVE_XWIDGETS
   kill_buffer_xwidgets (buffer);
-#endif
+
   /* Killing buffer processes may run sentinels which may have killed
      our buffer.  */
   if (!BUFFER_LIVE_P (b))
diff --git a/src/dispextern.h b/src/dispextern.h
index fad5bfd..7d7d730 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -347,11 +347,10 @@ enum glyph_type
   IMAGE_GLYPH,
 
   /* Glyph is a space of fractional width and/or height.  */
-  STRETCH_GLYPH
-#ifdef HAVE_XWIDGETS
-  /* Glyph is an external widget drawn by the GUI toolkit.   */
-  ,XWIDGET_GLYPH
-#endif
+  STRETCH_GLYPH,
+
+  /* Glyph is an external widget drawn by the GUI toolkit.  */
+  XWIDGET_GLYPH
 };
 
 
@@ -504,8 +503,10 @@ struct glyph
     int img_id;
 
 #ifdef HAVE_XWIDGETS
+    /* Xwidget reference (type == XWIDGET_GLYPH).  */
     struct xwidget *xwidget;
 #endif
+
     /* Sub-structure for type == STRETCH_GLYPH.  */
     struct
     {
@@ -1357,9 +1358,9 @@ struct glyph_string
   /* Image, if any.  */
   struct image *img;
 
-#ifdef HAVE_XWIDGETS
+  /* Xwidget.  */
   struct xwidget *xwidget;
-#endif
+
   /* Slice */
   struct glyph_slice slice;
 
@@ -2111,11 +2112,10 @@ enum display_element_type
   IT_TRUNCATION,
 
   /* Continuation glyphs.  See the comment for IT_TRUNCATION.  */
-  IT_CONTINUATION
+  IT_CONTINUATION,
 
-#ifdef HAVE_XWIDGETS
-  ,IT_XWIDGET
-#endif
+  /* Xwidget.  */
+  IT_XWIDGET
 };
 
 
@@ -2179,9 +2179,7 @@ enum it_method {
   GET_FROM_C_STRING,
   GET_FROM_IMAGE,
   GET_FROM_STRETCH,
-#ifdef HAVE_XWIDGETS
   GET_FROM_XWIDGET,
-#endif
   NUM_IT_METHODS
 };
 
@@ -2399,12 +2397,10 @@ struct it
       struct {
        Lisp_Object object;
       } stretch;
-#ifdef HAVE_XWIDGETS
       /* method == GET_FROM_XWIDGET */
       struct {
        Lisp_Object object;
       } xwidget;
-#endif
     } u;
 
     /* Current text and display positions.  */
@@ -2529,10 +2525,8 @@ struct it
   /* If what == IT_IMAGE, the id of the image to display.  */
   ptrdiff_t image_id;
 
-#ifdef HAVE_XWIDGETS
   /* If what == IT_XWIDGET.  */
   struct xwidget *xwidget;
-#endif
 
   /* Values from `slice' property.  */
   struct it_slice slice;
diff --git a/src/dispnew.c b/src/dispnew.c
index 32c0dff..fe07f79 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -39,15 +39,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "syssignal.h"
 #include "systime.h"
 #include "tparam.h"
+#include "xwidget.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
-
 #include <errno.h>
 
 #include <fpending.h>
@@ -3547,9 +3544,7 @@ update_window (struct window *w, bool force_p)
   add_window_display_history (w, w->current_matrix->method, paused_p);
 #endif
 
-#ifdef HAVE_XWIDGETS
   xwidget_end_redisplay (w, w->current_matrix);
-#endif
   clear_glyph_matrix (desired_matrix);
 
   return paused_p;
diff --git a/src/emacs.c b/src/emacs.c
index fcf048c..f661196 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -65,10 +65,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "character.h"
 #include "buffer.h"
 #include "window.h"
-
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
+#include "xwidget.h"
 #include "atimer.h"
 #include "blockinput.h"
 #include "syssignal.h"
@@ -1495,9 +1492,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
       syms_of_xfns ();
       syms_of_xmenu ();
       syms_of_fontset ();
-#ifdef HAVE_XWIDGETS
       syms_of_xwidget ();
-#endif
       syms_of_xsettings ();
 #ifdef HAVE_X_SM
       syms_of_xsmfns ();
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 08b8403..6795155 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -23,9 +23,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "frame.h"
 #include "xterm.h"
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
+#include "xwidget.h"
 #include "emacsgtkfixed.h"
 
 /* Silence a bogus diagnostic; see GNOME bug 683906.  */
@@ -50,7 +48,6 @@ static void emacs_fixed_get_preferred_width  (GtkWidget 
*widget,
 static void emacs_fixed_get_preferred_height (GtkWidget *widget,
                                               gint      *minimum,
                                               gint      *natural);
-
 static GType emacs_fixed_get_type (void);
 G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
 
@@ -75,28 +72,28 @@ struct GtkFixedPrivateL
   GList *children;
 };
 
-static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
-                                                  GtkAllocation *allocation)
+static void
+emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
+                                     GtkAllocation *allocation)
 {
-  // For xwidgets.
+  /* For xwidgets.
 
-  // This basically re-implements the base class method and adds an
-  // additional case for an xwidget view.
+     This basically re-implements the base class method and adds an
+     additional case for an xwidget view.
 
-  // It would be nicer if the bse class method could be called first,
-  // and the the xview modification only would remain here. It wasn't
-  // possible to solve it that way yet.
+     It would be nicer if the bse class method could be called first,
+     and the the xview modification only would remain here. It wasn't
+     possible to solve it that way yet.  */
   EmacsFixedClass *klass;
   GtkWidgetClass *parent_class;
-  struct GtkFixedPrivateL* priv;
+  struct GtkFixedPrivateL *priv;
 
   klass = EMACS_FIXED_GET_CLASS (widget);
   parent_class = g_type_class_peek_parent (klass);
   parent_class->size_allocate (widget, allocation);
 
-  priv = G_TYPE_INSTANCE_GET_PRIVATE (widget,
-                               GTK_TYPE_FIXED,
-                               struct GtkFixedPrivateL);
+  priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, GTK_TYPE_FIXED,
+                                     struct GtkFixedPrivateL);
 
   gtk_widget_set_allocation (widget, allocation);
 
@@ -154,7 +151,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
 
   widget_class = (GtkWidgetClass*) klass;
 
-
   widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
   widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
 #ifdef HAVE_XWIDGETS
@@ -163,7 +159,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
   g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
 }
 
-
 static void
 emacs_fixed_init (EmacsFixed *fixed)
 {
@@ -172,14 +167,7 @@ emacs_fixed_init (EmacsFixed *fixed)
   fixed->priv->f = 0;
 }
 
-/**
- * emacs_fixed_new:
- *
- * Creates a new #EmacsFixed.
- *
- * Returns: a new #EmacsFixed.
- */
-GtkWidget*
+GtkWidget *
 emacs_fixed_new (struct frame *f)
 {
   EmacsFixed *fixed = g_object_new (emacs_fixed_get_type (), NULL);
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 378bd2b..72652c5 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
 
 struct frame;
 
-//typedef struct _EmacsFixed              EmacsFixed;
 typedef struct _EmacsFixedPrivate       EmacsFixedPrivate;
 typedef struct _EmacsFixedClass         EmacsFixedClass;
 
@@ -41,7 +40,6 @@ struct _EmacsFixed
   EmacsFixedPrivate *priv;
 };
 
-
 struct _EmacsFixedClass
 {
   GtkFixedClass parent_class;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 768df34..14b76ce 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4084,20 +4084,28 @@ xg_page_setup_dialog (void)
 Lisp_Object
 xg_get_page_setup (void)
 {
-  GtkPageOrientation orientation;
   Lisp_Object orientation_symbol;
 
   if (page_setup == NULL)
     page_setup = gtk_page_setup_new ();
-  orientation = gtk_page_setup_get_orientation (page_setup);
-  if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT)
-    orientation_symbol = Qportrait;
-  else if (orientation == GTK_PAGE_ORIENTATION_LANDSCAPE)
-    orientation_symbol = Qlandscape;
-  else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
-    orientation_symbol = Qreverse_portrait;
-  else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE)
-    orientation_symbol = Qreverse_landscape;
+
+  switch (gtk_page_setup_get_orientation (page_setup))
+    {
+    case GTK_PAGE_ORIENTATION_PORTRAIT:
+      orientation_symbol = Qportrait;
+      break;
+    case GTK_PAGE_ORIENTATION_LANDSCAPE:
+      orientation_symbol = Qlandscape;
+      break;
+    case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
+      orientation_symbol = Qreverse_portrait;
+      break;
+    case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
+      orientation_symbol = Qreverse_landscape;
+      break;
+    default:
+      eassume (false);
+    }
 
   return listn (CONSTYPE_HEAP, 7,
                Fcons (Qorientation, orientation_symbol),
diff --git a/src/image.c b/src/image.c
index 8bb5ff7..144fe30 100644
--- a/src/image.c
+++ b/src/image.c
@@ -57,8 +57,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #endif /* HAVE_WINDOW_SYSTEM */
 
 #ifdef HAVE_X_WINDOWS
-#define COLOR_TABLE_SUPPORT 1
-
 typedef struct x_bitmap_record Bitmap_Record;
 #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
 #define NO_PIXMAP None
@@ -74,9 +72,6 @@ typedef struct x_bitmap_record Bitmap_Record;
 # include "w32.h"
 #endif
 
-/* W32_TODO : Color tables on W32.  */
-#undef COLOR_TABLE_SUPPORT
-
 typedef struct w32_bitmap_record Bitmap_Record;
 #define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y)
 #define NO_PIXMAP 0
@@ -89,13 +84,7 @@ typedef struct w32_bitmap_record Bitmap_Record;
 
 #endif /* HAVE_NTGUI */
 
-#ifdef USE_CAIRO
-#undef COLOR_TABLE_SUPPORT
-#endif
-
 #ifdef HAVE_NS
-#undef COLOR_TABLE_SUPPORT
-
 typedef struct ns_bitmap_record Bitmap_Record;
 
 #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
@@ -109,6 +98,12 @@ typedef struct ns_bitmap_record Bitmap_Record;
 #define DefaultDepthOfScreen(screen) x_display_list->n_planes
 #endif /* HAVE_NS */
 
+#if (defined HAVE_X_WINDOWS \
+     && ! (defined HAVE_NTGUI || defined USE_CAIRO || defined HAVE_NS))
+/* W32_TODO : Color tables on W32.  */
+# define COLOR_TABLE_SUPPORT 1
+#endif
+
 static void x_disable_image (struct frame *, struct image *);
 static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
                               Lisp_Object);
@@ -4615,16 +4610,14 @@ colors_in_color_table (int *n)
 static unsigned long
 lookup_rgb_color (struct frame *f, int r, int g, int b)
 {
-  unsigned long pixel;
-
 #ifdef HAVE_NTGUI
-  pixel = PALETTERGB (r >> 8, g >> 8, b >> 8);
-#endif /* HAVE_NTGUI */
-
-#ifdef HAVE_NS
-  pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
-#endif /* HAVE_NS */
-  return pixel;
+  return PALETTERGB (r >> 8, g >> 8, b >> 8);
+#elif defined HAVE_NS
+  return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
+#else
+  xsignal1 (Qfile_error,
+           build_string ("This Emacs mishandles this image file type"));
+#endif
 }
 
 static void
@@ -7320,7 +7313,6 @@ tiff_load (struct frame *f, struct image *img)
   {
     unsigned char *data = (unsigned char *) xmalloc (width*height*4);
     uint32_t *dataptr = (uint32_t *) data;
-    int r, g, b, a;
 
     for (y = 0; y < height; ++y)
       {
@@ -7634,19 +7626,19 @@ gif_load (struct frame *f, struct image *img)
 {
   int rc, width, height, x, y, i, j;
   ColorMapObject *gif_color_map;
-  unsigned long pixel_colors[256];
   GifFileType *gif;
   gif_memory_source memsrc;
   Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
   Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL);
   Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
-  unsigned long bgcolor = 0;
   EMACS_INT idx;
   int gif_err;
 
 #ifdef USE_CAIRO
   unsigned char *data = 0;
 #else
+  unsigned long pixel_colors[256];
+  unsigned long bgcolor = 0;
   XImagePtr ximg;
 #endif
 
@@ -7833,9 +7825,13 @@ gif_load (struct frame *f, struct image *img)
      gif_load call to construct and save all animation frames.  */
 
   init_color_table ();
+
+#ifndef USE_CAIRO
   if (STRINGP (specified_bg))
     bgcolor = x_alloc_image_color (f, img, specified_bg,
                                   FRAME_BACKGROUND_PIXEL (f));
+#endif
+
   for (j = 0; j <= idx; ++j)
     {
       /* We use a local variable `raster' here because RasterBits is a
@@ -9182,11 +9178,6 @@ svg_load_image (struct frame *f,         /* Pointer to 
emacs frame structure.  *
   int height;
   const guint8 *pixels;
   int rowstride;
-  XImagePtr ximg;
-  Lisp_Object specified_bg;
-  XColor background;
-  int x;
-  int y;
 
 #if ! GLIB_CHECK_VERSION (2, 36, 0)
   /* g_type_init is a glib function that must be called prior to
@@ -9240,16 +9231,14 @@ svg_load_image (struct frame *f,         /* Pointer to 
emacs frame structure.  *
 #ifdef USE_CAIRO
   {
     unsigned char *data = (unsigned char *) xmalloc (width*height*4);
-    int y;
     uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
 
-    for (y = 0; y < height; ++y)
+    for (int y = 0; y < height; ++y)
       {
         const guchar *iconptr = pixels + y * rowstride;
         uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
-        int x;
 
-        for (x = 0; x < width; ++x)
+        for (int x = 0; x < width; ++x)
           {
             if (iconptr[3] == 0)
               *dataptr = bgcolor;
@@ -9269,6 +9258,7 @@ svg_load_image (struct frame *f,         /* Pointer to 
emacs frame structure.  *
   }
 #else
   /* Try to create a x pixmap to hold the svg pixmap.  */
+  XImagePtr ximg;
   if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
     {
       g_object_unref (pixbuf);
@@ -9279,7 +9269,8 @@ svg_load_image (struct frame *f,         /* Pointer to 
emacs frame structure.  *
 
   /* Handle alpha channel by combining the image with a background
      color.  */
-  specified_bg = image_spec_value (img->spec, QCbackground, NULL);
+  XColor background;
+  Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
   if (!STRINGP (specified_bg)
       || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
     x_query_frame_background_color (f, &background);
@@ -9295,9 +9286,9 @@ svg_load_image (struct frame *f,         /* Pointer to 
emacs frame structure.  *
      non-transparent images.  Each pixel must be "flattened" by
      calculating the resulting color, given the transparency of the
      pixel, and the image background color.  */
-  for (y = 0; y < height; ++y)
+  for (int y = 0; y < height; ++y)
     {
-      for (x = 0; x < width; ++x)
+      for (int x = 0; x < width; ++x)
        {
          int red;
          int green;
@@ -9597,8 +9588,6 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
                        0, 0, img->width, img->height, ~0, ZPixmap);
       if (ximg)
        {
-         int x, y;
-
          /* Initialize the color table.  */
          init_color_table ();
 
@@ -9606,8 +9595,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
             color table.  After having done so, the color table will
             contain an entry for each color used by the image.  */
 #ifdef COLOR_TABLE_SUPPORT
-         for (y = 0; y < img->height; ++y)
-           for (x = 0; x < img->width; ++x)
+         for (int y = 0; y < img->height; ++y)
+           for (int x = 0; x < img->width; ++x)
              {
                unsigned long pixel = XGetPixel (ximg, x, y);
 
diff --git a/src/keyboard.c b/src/keyboard.c
index fe503b8..b26cee2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5960,7 +5960,7 @@ make_lispy_event (struct input_event *event)
 #ifdef HAVE_XWIDGETS
     case XWIDGET_EVENT:
       {
-        return Fcons (Qxwidget_event,event->arg);
+        return Fcons (Qxwidget_event, event->arg);
       }
 #endif
 
@@ -10971,7 +10971,7 @@ syms_of_keyboard (void)
 #endif
 
 #ifdef HAVE_XWIDGETS
-  DEFSYM (Qxwidget_event,"xwidget-event");
+  DEFSYM (Qxwidget_event, "xwidget-event");
 #endif
 
 #ifdef USE_FILE_NOTIFY
diff --git a/src/lisp.h b/src/lisp.h
index 8aa034e9..ee055e9 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -799,11 +799,8 @@ enum pvec_type
   PVEC_WINDOW_CONFIGURATION,
   PVEC_SUBR,
   PVEC_OTHER,
-
-#ifdef HAVE_XWIDGETS
   PVEC_XWIDGET,
   PVEC_XWIDGET_VIEW,
-#endif
 
   /* These should be last, check internal_equal to see why.  */
   PVEC_COMPILED,
diff --git a/src/print.c b/src/print.c
index 4dd4e96..2ecc0f5 100644
--- a/src/print.c
+++ b/src/print.c
@@ -32,10 +32,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "disptab.h"
 #include "intervals.h"
 #include "blockinput.h"
-
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
+#include "xwidget.h"
 
 #include <c-ctype.h>
 #include <float.h>
@@ -1740,18 +1737,11 @@ print_object (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag)
          print_c_string (XSUBR (obj)->symbol_name, printcharfun);
          printchar ('>', printcharfun);
        }
-#ifdef HAVE_XWIDGETS
-      else if (XWIDGETP (obj))
+      else if (XWIDGETP (obj) || XWIDGET_VIEW_P (obj))
        {
          print_c_string ("#<xwidget ", printcharfun);
          printchar ('>', printcharfun);
        }
-      else if (XWIDGET_VIEW_P (obj))
-       {
-         print_c_string ("#<xwidget ", printcharfun);
-         printchar ('>', printcharfun);
-       }
-#endif
       else if (WINDOWP (obj))
        {
          int len = sprintf (buf, "#<window %"pI"d",
diff --git a/src/sysdep.c b/src/sysdep.c
index a86b536..19a7212 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -100,6 +100,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "cm.h"
 
 #include "gnutls.h"
+/* MS-Windows loads GnuTLS at run time, if available; we don't want to
+   do that during startup just to call gnutls_rnd.  */
 #if 0x020c00 <= GNUTLS_VERSION_NUMBER && !defined WINDOWSNT
 # include <gnutls/crypto.h>
 #else
diff --git a/src/window.c b/src/window.c
index add2de3..70b7e58 100644
--- a/src/window.c
+++ b/src/window.c
@@ -35,15 +35,13 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "dispextern.h"
 #include "blockinput.h"
 #include "termhooks.h"         /* For FRAME_TERMINAL.  */
+#include "xwidget.h"
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 #ifdef MSDOS
 #include "msdos.h"
 #endif
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
 
 static ptrdiff_t count_windows (struct window *);
 static ptrdiff_t get_leaf_windows (struct window *, struct window **,
@@ -4371,9 +4369,7 @@ Signal an error when WINDOW is the only window on its 
frame.  */)
 
       /* Block input.  */
       block_input ();
-#ifdef HAVE_XWIDGETS
       xwidget_view_delete_all_in_window (w);
-#endif
       window_resize_apply (p, horflag);
       /* If this window is referred to by the dpyinfo's mouse
         highlight, invalidate that slot to be safe (Bug#9904).  */
diff --git a/src/xdisp.c b/src/xdisp.c
index 89385c0..5185e77 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -314,13 +314,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "font.h"
 #include "fontset.h"
 #include "blockinput.h"
+#include "xwidget.h"
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
 #ifndef FRAME_X_OUTPUT
 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
 #endif
@@ -857,9 +855,7 @@ static bool next_element_from_buffer (struct it *);
 static bool next_element_from_composition (struct it *);
 static bool next_element_from_image (struct it *);
 static bool next_element_from_stretch (struct it *);
-#ifdef HAVE_XWIDGETS
 static bool next_element_from_xwidget (struct it *);
-#endif
 static void load_overlay_strings (struct it *, ptrdiff_t);
 static bool get_next_display_element (struct it *);
 static enum move_it_result
@@ -5147,11 +5143,8 @@ handle_single_display_spec (struct it *it, Lisp_Object 
spec, Lisp_Object object,
                      && valid_image_p (value))
 #endif /* not HAVE_WINDOW_SYSTEM */
              || (CONSP (value) && EQ (XCAR (value), Qspace))
-#ifdef HAVE_XWIDGETS
              || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p)
-                && valid_xwidget_spec_p (value))
-#endif
-             );
+                && valid_xwidget_spec_p (value)));
 
   if (valid_p && display_replaced == 0)
     {
@@ -5226,17 +5219,15 @@ handle_single_display_spec (struct it *it, Lisp_Object 
spec, Lisp_Object object,
          *position = it->position = start_pos;
          retval = 1 + (it->area == TEXT_AREA);
        }
-#ifdef HAVE_XWIDGETS
-      else if (valid_xwidget_spec_p(value))
+      else if (valid_xwidget_spec_p (value))
        {
           it->what = IT_XWIDGET;
           it->method = GET_FROM_XWIDGET;
           it->position = start_pos;
          it->object = NILP (object) ? it->w->contents : object;
          *position = start_pos;
-          it->xwidget = lookup_xwidget(value);
+          it->xwidget = lookup_xwidget (value);
        }
-#endif
 #ifdef HAVE_WINDOW_SYSTEM
       else
        {
@@ -5989,11 +5980,9 @@ push_it (struct it *it, struct text_pos *position)
     case GET_FROM_STRETCH:
       p->u.stretch.object = it->object;
       break;
-#ifdef HAVE_XWIDGETS
     case GET_FROM_XWIDGET:
       p->u.xwidget.object = it->object;
       break;
-#endif
     case GET_FROM_BUFFER:
     case GET_FROM_DISPLAY_VECTOR:
     case GET_FROM_STRING:
@@ -6095,11 +6084,9 @@ pop_it (struct it *it)
       it->object = p->u.image.object;
       it->slice = p->u.image.slice;
       break;
-#ifdef HAVE_XWIDGETS
     case GET_FROM_XWIDGET:
       it->object = p->u.xwidget.object;
       break;
-#endif
     case GET_FROM_STRETCH:
       it->object = p->u.stretch.object;
       break;
@@ -6775,9 +6762,7 @@ static next_element_function const 
get_next_element[NUM_IT_METHODS] =
   next_element_from_c_string,
   next_element_from_image,
   next_element_from_stretch,
-#ifdef HAVE_XWIDGETS
   next_element_from_xwidget,
-#endif
 };
 
 #define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@ -7638,9 +7623,7 @@ set_iterator_to_next (struct it *it, bool reseat_p)
 
     case GET_FROM_IMAGE:
     case GET_FROM_STRETCH:
-#ifdef HAVE_XWIDGETS
     case GET_FROM_XWIDGET:
-#endif
 
       /* The position etc with which we have to proceed are on
         the stack.  The position may be at the end of a string,
@@ -8103,14 +8086,12 @@ next_element_from_image (struct it *it)
   return true;
 }
 
-#ifdef HAVE_XWIDGETS
 static bool
 next_element_from_xwidget (struct it *it)
 {
   it->what = IT_XWIDGET;
   return true;
 }
-#endif
 
 
 /* Fill iterator IT with next display element from a stretch glyph
@@ -18844,9 +18825,11 @@ dump_glyph (struct glyph_row *row, struct glyph 
*glyph, int area)
               glyph->left_box_line_p,
               glyph->right_box_line_p);
     }
-#ifdef HAVE_XWIDGETS
   else if (glyph->type == XWIDGET_GLYPH)
     {
+#ifndef HAVE_XWIDGETS
+      eassume (false);
+#else
       fprintf (stderr,
               "  %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
               glyph - row->glyphs[TEXT_AREA],
@@ -18863,9 +18846,8 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, 
int area)
               glyph->face_id,
               glyph->left_box_line_p,
               glyph->right_box_line_p);
-
-    }
 #endif
+    }
 }
 
 
@@ -24364,13 +24346,11 @@ calc_pixel_width_or_height (double *res, struct it 
*it, Lisp_Object prop,
 
              return OK_PIXELS (width_p ? img->width : img->height);
            }
-# ifdef HAVE_XWIDGETS
          if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop))
            {
               // TODO: Don't return dummy size.
               return OK_PIXELS (100);
             }
-# endif
 #endif
          if (EQ (car, Qplus) || EQ (car, Qminus))
            {
@@ -25273,8 +25253,11 @@ compute_overhangs_and_x (struct glyph_string *s, int 
x, bool backward_p)
        }                                                               \
      while (false)
 
-#ifdef HAVE_XWIDGETS
-#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
+#ifndef HAVE_XWIDGETS
+# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
+     eassume (false)
+#else
+# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
      do                                                                        
\
        {                                                               \
         s = alloca (sizeof *s);                                        \
@@ -25287,7 +25270,6 @@ compute_overhangs_and_x (struct glyph_string *s, int x, 
bool backward_p)
      while (false)
 #endif
 
-
 /* Add a glyph string for a sequence of character glyphs to the list
    of strings between HEAD and TAIL.  START is the index of the first
    glyph in row area AREA of glyph row ROW that is part of the new
@@ -25441,13 +25423,11 @@ compute_overhangs_and_x (struct glyph_string *s, int 
x, bool backward_p)
                                        HL, X, LAST_X);                 \
              break;
 
-#ifdef HAVE_XWIDGETS
-# define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
+#define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X)  \
             case XWIDGET_GLYPH:                                         \
               BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL,       \
                                           HL, X, LAST_X);               \
               break;
-#endif
 
 #define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)   \
            case GLYPHLESS_GLYPH:                                       \
@@ -25456,7 +25436,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, 
bool backward_p)
              break;                                                    \
                                                                        \
            default:                                                    \
-             emacs_abort ();                                                   
\
+             emacs_abort ();                                           \
            }                                                           \
                                                                        \
          if (s)                                                        \
@@ -25468,16 +25448,10 @@ compute_overhangs_and_x (struct glyph_string *s, int 
x, bool backward_p)
     } while (false)
 
 
-#ifdef HAVE_XWIDGETS
-# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)    \
+#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)     \
     BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X)       \
     BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X)      \
     BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
-#else
-# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)    \
-    BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X)       \
-    BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
-#endif
 
 
 /* Draw glyphs between START and END in AREA of ROW on window W,
@@ -26118,10 +26092,10 @@ produce_image_glyph (struct it *it)
     }
 }
 
-#ifdef HAVE_XWIDGETS
 static void
 produce_xwidget_glyph (struct it *it)
 {
+#ifdef HAVE_XWIDGETS
   struct xwidget *xw;
   int glyph_ascent, crop;
   eassert (it->what == IT_XWIDGET);
@@ -26219,8 +26193,8 @@ produce_xwidget_glyph (struct it *it)
       else
        IT_EXPAND_MATRIX_WIDTH (it, area);
     }
-}
 #endif
+}
 
 /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
    of the glyph, WIDTH and HEIGHT are the width and height of the
@@ -27631,10 +27605,8 @@ x_produce_glyphs (struct it *it)
     produce_image_glyph (it);
   else if (it->what == IT_STRETCH)
     produce_stretch_glyph (it);
-#ifdef HAVE_XWIDGETS
   else if (it->what == IT_XWIDGET)
     produce_xwidget_glyph (it);
-#endif
 
  done:
   /* Accumulate dimensions.  Note: can't assume that it->descent > 0
@@ -28004,10 +27976,8 @@ get_window_cursor_type (struct window *w, struct glyph 
*glyph, int *width,
   /* Use normal cursor if not blinked off.  */
   if (!w->cursor_off_p)
     {
-#ifdef HAVE_XWIDGETS
       if (glyph != NULL && glyph->type == XWIDGET_GLYPH)
         return NO_CURSOR;
-#endif
       if (glyph != NULL && glyph->type == IMAGE_GLYPH)
        {
          if (cursor_type == FILLED_BOX_CURSOR)
diff --git a/src/xterm.c b/src/xterm.c
index 44eed22..1f71afd 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -62,9 +62,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "frame.h"
 #include "dispextern.h"
-#ifdef HAVE_XWIDGETS
-# include "xwidget.h"
-#endif
+#include "xwidget.h"
 #include "fontset.h"
 #include "termhooks.h"
 #include "termopts.h"
@@ -1315,7 +1313,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row, struct draw_fring
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   Display *display = FRAME_X_DISPLAY (f);
-  Window window = FRAME_X_WINDOW (f);
   GC gc = f->output_data.x->normal_gc;
   struct face *face = p->face;
 
@@ -1358,6 +1355,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row, struct draw_fring
 #else  /* not USE_CAIRO */
   if (p->which)
     {
+      Window window = FRAME_X_WINDOW (f);
       char *bits;
       Pixmap pixmap, clipmask = (Pixmap) 0;
       int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
@@ -3514,11 +3512,9 @@ x_draw_glyph_string (struct glyph_string *s)
       x_draw_image_glyph_string (s);
       break;
 
-#ifdef HAVE_XWIDGETS
     case XWIDGET_GLYPH:
       x_draw_xwidget_glyph_string (s);
       break;
-#endif
 
     case STRETCH_GLYPH:
       x_draw_stretch_glyph_string (s);
@@ -3762,7 +3758,7 @@ x_delete_glyphs (struct frame *f, register int n)
 /* Like XClearArea, but check that WIDTH and HEIGHT are reasonable.
    If they are <= 0, this is probably an error.  */
 
-static void
+static ATTRIBUTE_UNUSED void
 x_clear_area1 (Display *dpy, Window window,
                int x, int y, int width, int height, int exposures)
 {
@@ -3770,7 +3766,6 @@ x_clear_area1 (Display *dpy, Window window,
   XClearArea (dpy, window, x, y, width, height, exposures);
 }
 
-
 void
 x_clear_area (struct frame *f, int x, int y, int width, int height)
 {
@@ -8929,10 +8924,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row 
*row, int width, enum text
   if (cursor_glyph == NULL)
     return;
 
-#ifdef HAVE_XWIDGETS
+  /* Experimental avoidance of cursor on xwidget.  */
   if (cursor_glyph->type == XWIDGET_GLYPH)
-    return; // Experimental avoidance of cursor on xwidget.
-#endif
+    return;
 
   /* If on an image, draw like a normal cursor.  That's usually better
      visible than drawing a bar, esp. if the image is large so that
diff --git a/src/xwidget.c b/src/xwidget.c
index ea5dea0..be3e4ca 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -19,6 +19,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
+#include "xwidget.h"
 
 #include <signal.h>
 
@@ -105,8 +106,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <webkit/webkitdownload.h>
 #include <webkit/webkitwebpolicydecision.h>
 
-#include "xwidget.h"
-
 static struct xwidget *
 allocate_xwidget (void)
 {
@@ -120,8 +119,8 @@ allocate_xwidget_view (void)
                                 PVEC_XWIDGET_VIEW);
 }
 
-#define XSETXWIDGET(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET))
-#define XSETXWIDGET_VIEW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW))
+#define XSETXWIDGET(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)
+#define XSETXWIDGET_VIEW(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)
 
 static struct xwidget_view *xwidget_view_lookup (struct xwidget *,
                                                 struct window *);
@@ -163,67 +162,57 @@ If BUFFER is nil, use the current buffer.
 If BUFFER is a string and no such buffer exists, create it.
 TYPE is a symbol which can take one of the following values:
 
-- webkit_osr
+- webkit-osr
 
 Returns the newly constructed xwidget, or nil if construction fails.  */)
-  (Lisp_Object beg, Lisp_Object end,
-  Lisp_Object type,
-  Lisp_Object title,
-  Lisp_Object width, Lisp_Object height,
-  Lisp_Object arguments, Lisp_Object buffer)
+  (Lisp_Object beg, Lisp_Object end, Lisp_Object type,
+   Lisp_Object title, Lisp_Object width, Lisp_Object height,
+   Lisp_Object arguments, Lisp_Object buffer)
 {
-  //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES)
-  // arg "type" and fwd should be keyword args eventually
-  //(make-xwidget 3 3 'button "oei" 31 31 nil)
-  //(xwidget-info (car xwidget-list))
+  CHECK_SYMBOL (type);
+  CHECK_NATNUM (width);
+  CHECK_NATNUM (height);
+  /* This should work a bit like "make-button"
+     (make-button BEG END &rest PROPERTIES)
+     TYPE etc. should be keyword args eventually.
+     (make-xwidget 3 3 'button "oei" 31 31 nil)
+     (xwidget-info (car xwidget-list))  */
   struct xwidget *xw = allocate_xwidget ();
   Lisp_Object val;
   xw->type = type;
   xw->title = title;
-  if (NILP (buffer))
-    buffer = Fcurrent_buffer ();       // no need to gcpro because
-                                        // Fcurrent_buffer doesn't
-                                        // call Feval/eval_sub.
-  else
-    buffer = Fget_buffer_create (buffer);
-  xw->buffer = buffer;
-
+  xw->buffer = NILP (buffer) ? Fcurrent_buffer () : Fget_buffer_create 
(buffer);
   xw->height = XFASTINT (height);
   xw->width = XFASTINT (width);
-  xw->kill_without_query = 0;
-  XSETXWIDGET (val, xw);       // set the vectorlike_header of VAL
-                                // with the correct value
+  xw->kill_without_query = false;
+  XSETXWIDGET (val, xw);
   Vxwidget_list = Fcons (val, Vxwidget_list);
   xw->widgetwindow_osr = NULL;
   xw->widget_osr = NULL;
   xw->plist = Qnil;
 
-
   if (EQ (xw->type, Qwebkit_osr))
     {
       block_input ();
       xw->widgetwindow_osr = gtk_offscreen_window_new ();
       gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
                          xw->height);
-      xw->widgetscrolledwindow_osr = NULL;     //webkit osr is the
-                                                //only scrolled
-                                                //component atm
+
+      /* WebKit OSR is the only scrolled component at the moment.  */
+      xw->widgetscrolledwindow_osr = NULL;
 
       if (EQ (xw->type, Qwebkit_osr))
         {
           xw->widgetscrolledwindow_osr = gtk_scrolled_window_new (NULL, NULL);
-          gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW
-                                                      (xw->
-                                                       
widgetscrolledwindow_osr),
-                                                      xw->height);
-          gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW
-                                                     (xw->
-                                                      
widgetscrolledwindow_osr),
-                                                     xw->width);
-          gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
-                                          (xw->widgetscrolledwindow_osr),
-                                          GTK_POLICY_ALWAYS,
-                                          GTK_POLICY_ALWAYS);
+          gtk_scrolled_window_set_min_content_height
+           (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
+            xw->height);
+          gtk_scrolled_window_set_min_content_width
+           (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
+            xw->width);
+          gtk_scrolled_window_set_policy
+           (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
+            GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
 
           xw->widget_osr = webkit_web_view_new ();
           gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr),
@@ -248,12 +237,10 @@ Returns the newly constructed xwidget, or nil if 
construction fails.  */)
       gtk_widget_show (xw->widgetwindow_osr);
       gtk_widget_show (xw->widgetscrolledwindow_osr);
 
-      /* store some xwidget data in the gtk widgets for convenient
+      /* Store some xwidget data in the gtk widgets for convenient
          retrieval in the event handlers.  */
-      g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET,
-                         (gpointer) (xw));
-      g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET,
-                         (gpointer) (xw));
+      g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, xw);
+      g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, xw);
 
       /* signals */
       if (EQ (xw->type, Qwebkit_osr))
@@ -286,7 +273,6 @@ Returns the newly constructed xwidget, or nil if 
construction fails.  */)
         }
 
       unblock_input ();
-
     }
 
   return val;
@@ -317,18 +303,16 @@ BUFFER may be a buffer or the name of one.  */)
   return xw_list;
 }
 
-static int
+static bool
 xwidget_hidden (struct xwidget_view *xv)
 {
   return xv->hidden;
 }
 
-
-
 static void
 xwidget_show_view (struct xwidget_view *xv)
 {
-  xv->hidden = 0;
+  xv->hidden = false;
   gtk_widget_show (xv->widgetwindow);
   gtk_fixed_move (GTK_FIXED (xv->emacswindow),
                   xv->widgetwindow,
@@ -336,33 +320,30 @@ xwidget_show_view (struct xwidget_view *xv)
                   xv->y + xv->clip_top);
 }
 
-
 /* Hide an xvidget view.  */
 static void
 xwidget_hide_view (struct xwidget_view *xv)
 {
-  xv->hidden = 1;
+  xv->hidden = true;
   gtk_fixed_move (GTK_FIXED (xv->emacswindow), xv->widgetwindow,
                   10000, 10000);
 }
 
-
-
 /* When the off-screen webkit master view changes this signal is called.
    It copies the bitmap from the off-screen instance.  */
 static gboolean
-offscreen_damage_event (GtkWidget * widget, GdkEvent * event,
+offscreen_damage_event (GtkWidget *widget, GdkEvent *event,
                         gpointer xv_widget)
 {
-  // Queue a redraw of onscreen widget.
-  // There is a guard against receiving an invalid widget,
-  // which should only happen if we failed to remove the
-  // specific signal handler for the damage event.
+  /* Queue a redraw of onscreen widget.
+     There is a guard against receiving an invalid widget,
+     which should only happen if we failed to remove the
+     specific signal handler for the damage event.  */
   if (GTK_IS_WIDGET (xv_widget))
     gtk_widget_queue_draw (GTK_WIDGET (xv_widget));
   else
     printf ("Warning, offscreen_damage_event received invalid xv pointer:%p\n",
-            (void *) xv_widget);
+            xv_widget);
 
   return FALSE;
 }
@@ -377,75 +358,58 @@ store_xwidget_event_string (struct xwidget *xw, const 
char *eventname,
   EVENT_INIT (event);
   event.kind = XWIDGET_EVENT;
   event.frame_or_window = Qnil;
-
-  event.arg = Qnil;
-  event.arg = Fcons (build_string (eventstr), event.arg);
-  event.arg = Fcons (xwl, event.arg);
-  event.arg = Fcons (intern (eventname), event.arg);
+  event.arg = list3 (intern (eventname), xwl, build_string (eventstr));
   kbd_buffer_store_event (&event);
-
 }
 
-//TODO deprecated, use load-status
+/* TODO deprecated, use load-status.  */
 void
-webkit_document_load_finished_cb (WebKitWebView * webkitwebview,
-                                  WebKitWebFrame * arg1,
+webkit_document_load_finished_cb (WebKitWebView *webkitwebview,
+                                  WebKitWebFrame *arg1,
                                   gpointer data)
 {
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
+  struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
                                           XG_XWIDGET);
 
   store_xwidget_event_string (xw, "document-load-finished", "");
 }
 
 gboolean
-webkit_download_cb (WebKitWebView * webkitwebview,
-                    WebKitDownload * arg1,
+webkit_download_cb (WebKitWebView *webkitwebview,
+                    WebKitDownload *arg1,
                     gpointer data)
 {
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
+  struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
                                           XG_XWIDGET);
   store_xwidget_event_string (xw, "download-requested",
                               webkit_download_get_uri (arg1));
-
   return FALSE;
 }
 
 static gboolean
-webkit_mime_type_policy_typedecision_requested_cb (WebKitWebView *webView,
-                                                   WebKitWebFrame *frame,
-                                                   WebKitNetworkRequest * 
request,
-                                                   gchar * mimetype,
-                                                   WebKitWebPolicyDecision 
*policy_decision,
-                                                   gpointer user_data)
+webkit_mime_type_policy_typedecision_requested_cb
+(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
+ gchar *mimetype, WebKitWebPolicyDecision *policy_decision, gpointer user_data)
 {
-  // This function makes webkit send a download signal for all unknown
-  // mime types.  TODO Defer the decision to lisp, so that its possible
-  // to make Emacs handle teext mime for instance.xs
+  /* This function makes webkit send a download signal for all unknown
+     mime types.  TODO: Defer the decision to Lisp, so that it's
+     possible to make Emacs handle teext mime for instance.xs.  */
   if (!webkit_web_view_can_show_mime_type (webView, mimetype))
     {
       webkit_web_policy_decision_download (policy_decision);
       return TRUE;
     }
   else
-    {
-      return FALSE;
-    }
+    return FALSE;
 }
 
-
 static gboolean
-webkit_new_window_policy_decision_requested_cb (WebKitWebView *webView,
-                                                WebKitWebFrame *frame,
-                                                WebKitNetworkRequest *request,
-                                                WebKitWebNavigationAction 
*navigation_action,
-                                                WebKitWebPolicyDecision 
*policy_decision,
-                                                gpointer user_data)
+webkit_new_window_policy_decision_requested_cb
+(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
+ WebKitWebNavigationAction *navigation_action,
+ WebKitWebPolicyDecision *policy_decision, gpointer user_data)
 {
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
+  struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
   webkit_web_navigation_action_get_original_uri (navigation_action);
 
   store_xwidget_event_string (xw, "new-window-policy-decision-requested",
@@ -455,29 +419,24 @@ webkit_new_window_policy_decision_requested_cb 
(WebKitWebView *webView,
 }
 
 static gboolean
-webkit_navigation_policy_decision_requested_cb (WebKitWebView *webView,
-                                                WebKitWebFrame *frame,
-                                                WebKitNetworkRequest *request,
-                                                WebKitWebNavigationAction 
*navigation_action,
-                                                WebKitWebPolicyDecision * 
policy_decision,
-                                                gpointer user_data)
+webkit_navigation_policy_decision_requested_cb
+(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
+ WebKitWebNavigationAction *navigation_action,
+ WebKitWebPolicyDecision *policy_decision, gpointer user_data)
 {
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
+  struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
   store_xwidget_event_string (xw, "navigation-policy-decision-requested",
                               webkit_web_navigation_action_get_original_uri
                               (navigation_action));
   return FALSE;
 }
 
-// For gtk3 offscreen rendered widgets.
+/* For gtk3 offscreen rendered widgets.  */
 static gboolean
-xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
+xwidget_osr_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
 {
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
-  struct xwidget_view *xv =
-    (struct xwidget_view *) g_object_get_data (G_OBJECT (widget),
+  struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
+  struct xwidget_view *xv = g_object_get_data (G_OBJECT (widget),
                                                XG_XWIDGET_VIEW);
 
   cairo_rectangle (cr, 0, 0, xv->clip_right, xv->clip_bottom);
@@ -491,31 +450,30 @@ xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, 
gpointer data)
 }
 
 static gboolean
-xwidget_osr_event_forward (GtkWidget * widget,
-                           GdkEvent * event,
-                           gpointer user_data)
+xwidget_osr_event_forward (GtkWidget *widget, GdkEvent *event,
+                          gpointer user_data)
 {
   /* Copy events that arrive at the outer widget to the offscreen widget.  */
-  struct xwidget *xw =
-    (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
+  struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
   GdkEvent *eventcopy = gdk_event_copy (event);
   eventcopy->any.window = gtk_widget_get_window (xw->widget_osr);
 
-  //TODO This might leak events.  They should be deallocated later,
-  //perhaps in xwgir_event_cb
+  /* TODO: This might leak events.  They should be deallocated later,
+     perhaps in xwgir_event_cb.  */
   gtk_main_do_event (eventcopy);
-  return TRUE;                 //dont propagate this event furter
-}
 
+  /* Don't propagate this event further.  */
+  return TRUE;
+}
 
 static gboolean
-xwidget_osr_event_set_embedder (GtkWidget * widget,
-                                GdkEvent * event, gpointer data)
+xwidget_osr_event_set_embedder (GtkWidget *widget, GdkEvent *event,
+                               gpointer data)
 {
-  struct xwidget_view *xv = (struct xwidget_view *) data;
+  struct xwidget_view *xv = data;
   struct xwidget *xww = XXWIDGET (xv->model);
   gdk_offscreen_window_set_embedder (gtk_widget_get_window
-                                     (xww->widgetwindow_osr),
+                                    (xww->widgetwindow_osr),
                                      gtk_widget_get_window (xv->widget));
   return FALSE;
 }
@@ -539,11 +497,11 @@ xwidget_init_view (struct xwidget *xww,
   if (EQ (xww->type, Qwebkit_osr))
     {
       xv->widget = gtk_drawing_area_new ();
-      // Expose event handling.
+      /* Expose event handling.  */
       gtk_widget_set_app_paintable (xv->widget, TRUE);
       gtk_widget_add_events (xv->widget, GDK_ALL_EVENTS_MASK);
 
-      /* Draw the view on damage-event */
+      /* Draw the view on damage-event.  */
       g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event",
                         G_CALLBACK (offscreen_damage_event), xv->widget);
 
@@ -558,38 +516,33 @@ xwidget_init_view (struct xwidget *xww,
         }
       else
         {
-          // xwgir debug , orthogonal to forwarding
+          /* xwgir debug, orthogonal to forwarding.  */
           g_signal_connect (G_OBJECT (xv->widget), "enter-notify-event",
                             G_CALLBACK (xwidget_osr_event_set_embedder), xv);
         }
       g_signal_connect (G_OBJECT (xv->widget), "draw",
                         G_CALLBACK (xwidget_osr_draw_cb), NULL);
     }
-  // Widget realization.
 
-  // Make container widget 1st, and put the actual widget inside the
-  // container later.  Drawing should crop container window if necessary
-  // to handle case where xwidget is partially obscured by other Emacs
-  // windows.  Other containers than gtk_fixed where explored, but
-  // gtk_fixed had the most predictable behaviour so far.
+  /* Widget realization.
+
+     Make container widget first, and put the actual widget inside the
+     container later.  Drawing should crop container window if necessary
+     to handle case where xwidget is partially obscured by other Emacs
+     windows.  Other containers than gtk_fixed where explored, but
+     gtk_fixed had the most predictable behaviour so far.  */
+
   xv->emacswindow = FRAME_GTK_WIDGET (s->f);
   xv->widgetwindow = gtk_fixed_new ();
   gtk_widget_set_has_window (xv->widgetwindow, TRUE);
   gtk_container_add (GTK_CONTAINER (xv->widgetwindow), xv->widget);
 
-  // Store some xwidget data in the gtk widgets.
-  // The emacs frame.
-  g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, (gpointer) (s->f));
-  // The xwidget.
-  g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, (gpointer) (xww));
-  // The xwidget.
-  g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, (gpointer) (xv));
-  // The xwidget window.
-  g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, (gpointer) 
(xww));
-  // the xwidget view.
-  g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW,
-                     (gpointer) (xv));
-
+  /* Store some xwidget data in the gtk widgets.  */
+  g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, s->f);
+  g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, xww);
+  g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, xv);
+  g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, xww);
+  g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW, xv);
 
   gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width,
                                xww->height);
@@ -599,18 +552,15 @@ xwidget_init_view (struct xwidget *xww,
   xv->y = y;
   gtk_widget_show_all (xv->widgetwindow);
 
-
   return xv;
 }
 
-
 void
 x_draw_xwidget_glyph_string (struct glyph_string *s)
 {
   /* This method is called by the redisplay engine and places the
      xwidget on screen.  Moving and clipping is done here.  Also view
-     initialization.
-   */
+     initialization.  */
   struct xwidget *xww = s->xwidget;
   struct xwidget_view *xv = xwidget_view_lookup (xww, s->w);
   int clip_right;
@@ -620,16 +570,14 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
 
   int x = s->x;
   int y = s->y + (s->height / 2) - (xww->height / 2);
-  int moved = 0;
 
-  /* We do initialization here in the display loop because there is no
-     other time to know things like window placement etc.
-   */
+  /* Do initialization here in the display loop because there is no
+     other time to know things like window placement etc.  */
   xv = xwidget_init_view (xww, s, x, y);
 
-  // Calculate clipping, which is used for all manner of onscreen
-  // xwidget views.  Each widget border can get clipped by other emacs
-  // objects so there are four clipping variables.
+  /* Calculate clipping, which is used for all manner of onscreen
+     xwidget views.  Each widget border can get clipped by other emacs
+     objects so there are four clipping variables.  */
   clip_right =
     min (xww->width,
          WINDOW_RIGHT_EDGE_X (s->w) - x -
@@ -646,31 +594,32 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
          WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
   clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
 
-  // We are conserned with movement of the onscreen area.  The area
-  // might sit still when the widget actually moves.  This happens
-  // when an Emacs window border moves across a widget window.  So, if
-  // any corner of the outer widget clipping window moves, that counts
-  // as movement here, even if it looks like no movement happens
-  // because the widget sits still inside the clipping area.  The
-  // widget can also move inside the clipping area, which happens
-  // later
-  moved = (xv->x + xv->clip_left != x + clip_left)
-    || ((xv->y + xv->clip_top) != (y + clip_top));
+  /* We are conserned with movement of the onscreen area.  The area
+     might sit still when the widget actually moves.  This happens
+     when an Emacs window border moves across a widget window.  So, if
+     any corner of the outer widget clipping window moves, that counts
+     as movement here, even if it looks like no movement happens
+     because the widget sits still inside the clipping area.  The
+     widget can also move inside the clipping area, which happens
+     later.  */
+  bool moved = (xv->x + xv->clip_left != x + clip_left
+               || xv->y + xv->clip_top != y + clip_top);
   xv->x = x;
   xv->y = y;
-  if (moved) // Has it moved?
-    {
-          gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)),
-                          xv->widgetwindow, x + clip_left, y + clip_top);
-    }
-  // Clip the widget window if some parts happen to be outside
-  // drawable area.  An Emacs window is not a gtk window.  A gtk window
-  // covers the entire frame.  Clipping might have changed even if we
-  // havent actualy moved, we try figure out when we need to reclip
-  // for real.
-  if ((xv->clip_right != clip_right)
-      || (xv->clip_bottom != clip_bottom)
-      || (xv->clip_top != clip_top) || (xv->clip_left != clip_left))
+
+  /* Has it moved?  */
+  if (moved)
+    gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)),
+                   xv->widgetwindow, x + clip_left, y + clip_top);
+
+  /* Clip the widget window if some parts happen to be outside
+     drawable area.  An Emacs window is not a gtk window.  A gtk window
+     covers the entire frame.  Clipping might have changed even if we
+     havent actualy moved, we try figure out when we need to reclip
+     for real.  */
+  if (xv->clip_right != clip_right
+      || xv->clip_bottom != clip_bottom
+      || xv->clip_top != clip_top || xv->clip_left != clip_left)
     {
       gtk_widget_set_size_request (xv->widgetwindow, clip_right + clip_left,
                                    clip_bottom + clip_top);
@@ -682,10 +631,11 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
       xv->clip_top = clip_top;
       xv->clip_left = clip_left;
     }
-  // If emacs wants to repaint the area where the widget lives, queue
-  // a redraw.  It seems its possible to get out of sync with emacs
-  // redraws so emacs background sometimes shows up instead of the
-  // xwidgets background.  It's just a visual glitch though.
+
+  /* If emacs wants to repaint the area where the widget lives, queue
+     a redraw.  It seems its possible to get out of sync with emacs
+     redraws so emacs background sometimes shows up instead of the
+     xwidgets background.  It's just a visual glitch though.  */
   if (!xwidget_hidden (xv))
     {
       gtk_widget_queue_draw (xv->widgetwindow);
@@ -693,19 +643,15 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
     }
 }
 
-
-// Macro that checks WEBKIT_IS_WEB_VIEW(xw->widget_osr) first
-#define WEBKIT_FN_INIT()                        \
-  struct xwidget* xw; \
-  CHECK_XWIDGET (xwidget); \
- if (NILP (xwidget)) {printf("ERROR xwidget nil\n"); return Qnil;};    \
-  xw = XXWIDGET (xwidget);                                                    \
-  if (NULL == xw) printf("ERROR xw is 0\n");                               \
-  if ((NULL == xw->widget_osr) || !WEBKIT_IS_WEB_VIEW(xw->widget_osr)){  \
-    printf ("ERROR xw->widget_osr does not hold a webkit instance\n");\
-    return Qnil;\
-  };
-
+/* Macro that checks WEBKIT_IS_WEB_VIEW (xw->widget_osr) first.  */
+#define WEBKIT_FN_INIT()                                               \
+  CHECK_XWIDGET (xwidget);                                             \
+  struct xwidget *xw = XXWIDGET (xwidget);                             \
+  if (!xw->widget_osr || !WEBKIT_IS_WEB_VIEW (xw->widget_osr))         \
+    {                                                                  \
+      printf ("ERROR xw->widget_osr does not hold a webkit instance\n"); \
+      return Qnil;                                                     \
+    }
 
 DEFUN ("xwidget-webkit-goto-uri",
        Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri,
@@ -723,7 +669,7 @@ DEFUN ("xwidget-webkit-goto-uri",
 DEFUN ("xwidget-webkit-execute-script",
        Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script,
        2, 2, 0,
-       doc: /* Make the Webkit XWIDGET execute javascript SCRIPT.  */)
+       doc: /* Make the Webkit XWIDGET execute JavaScript SCRIPT.  */)
   (Lisp_Object xwidget, Lisp_Object script)
 {
   WEBKIT_FN_INIT ();
@@ -741,14 +687,14 @@ This can be used to work around the lack of a return 
value from the
 exec method.  */ )
   (Lisp_Object xwidget)
 {
-  // TODO support multibyte strings
+  /* TODO support multibyte strings.  */
   WEBKIT_FN_INIT ();
   const gchar *str =
     webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr));
   if (str == 0)
     {
-      // TODO maybe return Qnil instead.  I suppose webkit returns
-      // nullpointer when doc is not properly loaded or something
+      /* TODO maybe return Qnil instead.  I suppose webkit returns
+        null pointer when doc is not properly loaded or something.  */
       return build_string ("");
     }
   return build_string (str);
@@ -759,32 +705,30 @@ DEFUN ("xwidget-resize", Fxwidget_resize, 
Sxwidget_resize, 3, 3, 0,
   (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height)
 {
   CHECK_XWIDGET (xwidget);
+  CHECK_NATNUM (new_width);
+  CHECK_NATNUM (new_height);
   struct xwidget *xw = XXWIDGET (xwidget);
-  struct xwidget_view *xv;
-  int w, h;
-
-  CHECK_NUMBER (new_width);
-  CHECK_NUMBER (new_height);
-  w = XFASTINT (new_width);
-  h = XFASTINT (new_height);
+  int w = XFASTINT (new_width);
+  int h = XFASTINT (new_height);
 
   xw->width = w;
   xw->height = h;
-  // If there is a offscreen widget resize it 1st.
+
+  /* If there is an offscreen widget resize it first.  */
   if (xw->widget_osr)
     {
+      /* Use minimum size.  */
       gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr),
-                                   xw->width, xw->height);     //minimum size
+                                   xw->width, xw->height);
+
       gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
                          xw->height);
-      gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW
-                                                  (xw->
-                                                   widgetscrolledwindow_osr),
-                                                  xw->height);
-      gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW
-                                                 (xw->
-                                                  widgetscrolledwindow_osr),
-                                                 xw->width);
+      gtk_scrolled_window_set_min_content_height
+       (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
+        xw->height);
+      gtk_scrolled_window_set_min_content_width
+       (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
+        xw->width);
 
       gtk_container_resize_children (GTK_CONTAINER (xw->widgetwindow_osr));
 
@@ -794,7 +738,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 
3, 3, 0,
     {
       if (XWIDGET_VIEW_P (XCAR (tail)))
         {
-          xv = XXWIDGET_VIEW (XCAR (tail));
+          struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
           if (XXWIDGET (xv->model) == xw)
               gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width,
                                            xw->height);
@@ -816,37 +760,17 @@ VALUE is the amount to scroll, either relatively or 
absolutely.  */)
    Lisp_Object value)
 {
   CHECK_XWIDGET (xwidget);
+  CHECK_NATNUM (value);
   struct xwidget *xw = XXWIDGET (xwidget);
-  GtkAdjustment *adjustment;
-  float final_value = 0.0;
-
-  adjustment =
-    gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
-                                         (xw->widgetscrolledwindow_osr));
-  if (EQ (Qvertical, axis))
-    {
-      adjustment =
-        gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
-                                             (xw->widgetscrolledwindow_osr));
-    }
-  if (EQ (Qhorizontal, axis))
-    {
-      adjustment =
-        gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW
-                                             (xw->widgetscrolledwindow_osr));
-    }
-
+  GtkAdjustment *adjustment
+    = ((EQ (Qhorizontal, axis)
+       ? gtk_scrolled_window_get_hadjustment
+       : gtk_scrolled_window_get_vadjustment)
+       (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr)));
+  double final_value = XFASTINT (value);
   if (EQ (Qt, relative))
-    {
-      final_value = gtk_adjustment_get_value (adjustment) + XFASTINT (value);
-    }
-  else
-    {
-      final_value = 0.0 + XFASTINT (value);
-    }
-
+    final_value += gtk_adjustment_get_value (adjustment);
   gtk_adjustment_set_value (adjustment, final_value);
-
   return Qnil;
 }
 
@@ -861,13 +785,9 @@ Emacs allocated area accordingly.  */)
 {
   CHECK_XWIDGET (xwidget);
   GtkRequisition requisition;
-  Lisp_Object rv;
   gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition);
-  rv = Qnil;
-  rv = Fcons (make_number (requisition.height), rv);
-  rv = Fcons (make_number (requisition.width), rv);
-  return rv;
-
+  return list2 (make_number (requisition.width),
+               make_number (requisition.height));
 }
 
 DEFUN ("xwidgetp",
@@ -896,18 +816,9 @@ Currently [TYPE TITLE WIDTH HEIGHT].  */)
   (Lisp_Object xwidget)
 {
   CHECK_XWIDGET (xwidget);
-  Lisp_Object info, n;
   struct xwidget *xw = XXWIDGET (xwidget);
-
-  info = Fmake_vector (make_number (4), Qnil);
-  ASET (info, 0, xw->type);
-  ASET (info, 1, xw->title);
-  XSETFASTINT (n, xw->width);
-  ASET (info, 2, n);
-  XSETFASTINT (n, xw->height);
-  ASET (info, 3, n);
-
-  return info;
+  return CALLN (Fvector, xw->type, xw->title,
+               make_natnum (xw->width), make_natnum (xw->height));
 }
 
 DEFUN ("xwidget-view-info",
@@ -919,17 +830,9 @@ Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT]. 
 */)
 {
   CHECK_XWIDGET_VIEW (xwidget_view);
   struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
-  Lisp_Object info;
-
-  info = Fmake_vector (make_number (6), Qnil);
-  ASET (info, 0, make_number (xv->x));
-  ASET (info, 1, make_number (xv->y));
-  ASET (info, 2, make_number (xv->clip_right));
-  ASET (info, 3, make_number (xv->clip_bottom));
-  ASET (info, 4, make_number (xv->clip_top));
-  ASET (info, 5, make_number (xv->clip_left));
-
-  return info;
+  return CALLN (Fvector, make_number (xv->x), make_number (xv->y),
+               make_number (xv->clip_right), make_number (xv->clip_bottom),
+               make_number (xv->clip_top), make_number (xv->clip_left));
 }
 
 DEFUN ("xwidget-view-model",
@@ -963,8 +866,8 @@ DEFUN ("delete-xwidget-view",
   struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
   gtk_widget_destroy (xv->widgetwindow);
   Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list);
-  // xv->model still has signals pointing to the view.  There can be
-  // several views.  Find the matching signals and delete them all.
+  /* xv->model still has signals pointing to the view.  There can be
+     several views.  Find the matching signals and delete them all.  */
   g_signal_handlers_disconnect_matched  (XXWIDGET 
(xv->model)->widgetwindow_osr,
                                          G_SIGNAL_MATCH_DATA,
                                          0, 0, 0, 0,
@@ -1002,7 +905,7 @@ DEFUN ("xwidget-plist",
        Fxwidget_plist, Sxwidget_plist,
        1, 1, 0,
        doc: /* Return the plist of XWIDGET.  */)
-  (register Lisp_Object xwidget)
+  (Lisp_Object xwidget)
 {
   CHECK_XWIDGET (xwidget);
   return XXWIDGET (xwidget)->plist;
@@ -1012,7 +915,7 @@ DEFUN ("xwidget-buffer",
        Fxwidget_buffer, Sxwidget_buffer,
        1, 1, 0,
        doc: /* Return the buffer of XWIDGET.  */)
-  (register Lisp_Object xwidget)
+  (Lisp_Object xwidget)
 {
   CHECK_XWIDGET (xwidget);
   return XXWIDGET (xwidget)->buffer;
@@ -1023,7 +926,7 @@ DEFUN ("set-xwidget-plist",
        2, 2, 0,
        doc: /* Replace the plist of XWIDGET with PLIST.
 Returns PLIST.  */)
-  (register Lisp_Object xwidget, Lisp_Object plist)
+  (Lisp_Object xwidget, Lisp_Object plist)
 {
   CHECK_XWIDGET (xwidget);
   CHECK_LIST (plist);
@@ -1059,7 +962,6 @@ DEFUN ("xwidget-query-on-exit-flag",
 void
 syms_of_xwidget (void)
 {
-
   defsubr (&Smake_xwidget);
   defsubr (&Sxwidgetp);
   DEFSYM (Qxwidgetp, "xwidgetp");
@@ -1111,7 +1013,6 @@ syms_of_xwidget (void)
   Vxwidget_view_list = Qnil;
 
   Fprovide (intern ("xwidget-internal"), Qnil);
-
 }
 
 
@@ -1125,19 +1026,13 @@ syms_of_xwidget (void)
 bool
 valid_xwidget_spec_p (Lisp_Object object)
 {
-  int valid_p = false;
-
-  if (CONSP (object) && EQ (XCAR (object), Qxwidget))
-      valid_p = true;
-
-  return valid_p;
+  return CONSP (object) && EQ (XCAR (object), Qxwidget);
 }
 
 
-
 /* Find a value associated with key in spec.  */
 static Lisp_Object
-xwidget_spec_value (Lisp_Object spec, Lisp_Object key, int *found)
+xwidget_spec_value (Lisp_Object spec, Lisp_Object key)
 {
   Lisp_Object tail;
 
@@ -1147,15 +1042,9 @@ xwidget_spec_value (Lisp_Object spec, Lisp_Object key, 
int *found)
        CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail)))
     {
       if (EQ (XCAR (tail), key))
-        {
-          if (found)
-            *found = 1;
-          return XCAR (XCDR (tail));
-        }
+       return XCAR (XCDR (tail));
     }
 
-  if (found)
-    *found = 0;
   return Qnil;
 }
 
@@ -1195,19 +1084,17 @@ lookup_xwidget (Lisp_Object spec)
 {
   /* When a xwidget lisp spec is found initialize the C struct that is
      used in the C code.  This is done by redisplay so values change
-     if the spec changes.  So, take special care of one-shot events.
-   */
-  int found = 0;
+     if the spec changes.  So, take special care of one-shot events.  */
   Lisp_Object value;
   struct xwidget *xw;
 
-  value = xwidget_spec_value (spec, QCxwidget, &found);
+  value = xwidget_spec_value (spec, QCxwidget);
   xw = XXWIDGET (value);
 
   return xw;
 }
 
-/* Set up detection of touched xwidget  */
+/* Set up detection of touched xwidget.  */
 static void
 xwidget_start_redisplay (void)
 {
@@ -1215,7 +1102,7 @@ xwidget_start_redisplay (void)
        tail = XCDR (tail))
     {
       if (XWIDGET_VIEW_P (XCAR (tail)))
-        XXWIDGET_VIEW (XCAR (tail))->redisplayed = 0;
+        XXWIDGET_VIEW (XCAR (tail))->redisplayed = false;
     }
 }
 
@@ -1224,57 +1111,48 @@ xwidget_start_redisplay (void)
 static void
 xwidget_touch (struct xwidget_view *xv)
 {
-  xv->redisplayed = 1;
+  xv->redisplayed = true;
 }
 
-static int
+static bool
 xwidget_touched (struct xwidget_view *xv)
 {
   return xv->redisplayed;
 }
 
-/* Redisplay has ended, now we should hide untouched xwidgets
-*/
+/* Redisplay has ended, now we should hide untouched xwidgets.  */
 void
 xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
 {
-
   int i;
   int area;
 
   xwidget_start_redisplay ();
-  // Iterate desired glyph matrix of window here, hide gtk widgets
-  // not in the desired matrix.
+  /* Iterate desired glyph matrix of window here, hide gtk widgets
+     not in the desired matrix.
 
-  // This only takes care of xwidgets in active windows.  If a window
-  // goes away from screen xwidget views wust be deleted
+     This only takes care of xwidgets in active windows.  If a window
+     goes away from screen xwidget views wust be deleted.
 
-  //  dump_glyph_matrix (matrix, 2);
+     dump_glyph_matrix (matrix, 2);  */
   for (i = 0; i < matrix->nrows; ++i)
     {
-      //    dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs);
+      /* dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs); */
       struct glyph_row *row;
       row = MATRIX_ROW (matrix, i);
-      if (row->enabled_p != 0)
-        {
-          for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
-            {
-              struct glyph *glyph = row->glyphs[area];
-              struct glyph *glyph_end = glyph + row->used[area];
-              for (; glyph < glyph_end; ++glyph)
-                {
-                  if (glyph->type == XWIDGET_GLYPH)
-                    {
-                      /*
-                        The only call to xwidget_end_redisplay is in dispnew
-                         xwidget_end_redisplay (w->current_matrix);
-                       */
-                      xwidget_touch (xwidget_view_lookup (glyph->u.xwidget,
-                                                          w));
-                    }
-                }
-            }
-        }
+      if (row->enabled_p)
+       for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
+         {
+           struct glyph *glyph = row->glyphs[area];
+           struct glyph *glyph_end = glyph + row->used[area];
+           for (; glyph < glyph_end; ++glyph)
+             if (glyph->type == XWIDGET_GLYPH)
+               {
+                 /* The only call to xwidget_end_redisplay is in dispnew.
+                    xwidget_end_redisplay (w->current_matrix);  */
+                 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget, w));
+               }
+         }
     }
 
   for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail);
@@ -1284,8 +1162,8 @@ xwidget_end_redisplay (struct window *w, struct 
glyph_matrix *matrix)
         {
           struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
 
-          // "touched" is only meaningful for the current window, so
-          // disregard other views.
+          /* "touched" is only meaningful for the current window, so
+             disregard other views.  */
           if (XWINDOW (xv->w) == w)
             {
               if (xwidget_touched (xv))
@@ -1306,7 +1184,7 @@ kill_buffer_xwidgets (Lisp_Object buffer)
     {
       xwidget = XCAR (tail);
       Vxwidget_list = Fdelq (xwidget, Vxwidget_list);
-      /* TODO free the GTK things in xw */
+      /* TODO free the GTK things in xw.  */
       {
         CHECK_XWIDGET (xwidget);
         struct xwidget *xw = XXWIDGET (xwidget);
diff --git a/src/xwidget.h b/src/xwidget.h
index fdcf40d..1e11f11 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -20,60 +20,62 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef XWIDGET_H_INCLUDED
 #define XWIDGET_H_INCLUDED
 
-void x_draw_xwidget_glyph_string (struct glyph_string *s);
-void syms_of_xwidget (void);
-
-//extern Lisp_Object Qxwidget;
+#include "lisp.h"
 
+struct glyph_matrix;
+struct glyph_string;
+struct xwidget;
+struct xwidget_view;
+struct window;
 
-bool valid_xwidget_spec_p (Lisp_Object object);
+#ifdef HAVE_XWIDGETS
+# include <gtk/gtk.h>
 
-#include <gtk/gtk.h>
+struct xwidget
+{
+  struct vectorlike_header header;
 
+  /* Auxiliary data.  */
+  Lisp_Object plist;
 
-/*
-each xwidget instance/model is described by this struct.
+  /* The widget type.  */
+  Lisp_Object type;
 
-lisp pseudovector.
+  /* The buffer where the xwidget lives.  */
+  Lisp_Object buffer;
 
+  /* A title used for button labels, for instance.  */
+  Lisp_Object title;
 
- */
-struct xwidget
-{
-  struct vectorlike_header header;
-  Lisp_Object plist;           //auxilliary data
-  Lisp_Object type;            //the widget type
-  Lisp_Object buffer;          //buffer where xwidget lives
-  Lisp_Object title;           //a title that is used for button labels for 
instance
+  /* Here ends the Lisp part.  "height" is the marker field.  */
 
-  //here ends the lisp part.
-  //"height" is the marker field
   int height;
   int width;
 
-  //for offscreen widgets, unused if not osr
+  /* For offscreen widgets, unused if not osr.  */
   GtkWidget *widget_osr;
   GtkWidget *widgetwindow_osr;
-  //this is used if the widget (webkit) is to be wrapped in a scrolled window,
+
+  /* Used if the widget (webkit) is to be wrapped in a scrolled window.  */
   GtkWidget *widgetscrolledwindow_osr;
-  /* Non-nil means kill silently if Emacs is exited. */
-  unsigned int kill_without_query:1;
 
+  /* Kill silently if Emacs is exited.  */
+  bool_bf kill_without_query : 1;
 };
 
-
-//struct for each xwidget view
 struct xwidget_view
 {
   struct vectorlike_header header;
   Lisp_Object model;
   Lisp_Object w;
 
-  //here ends the lisp part.
-  //"redisplayed" is the marker field
-  int redisplayed;             //if touched by redisplay
+  /* Here ends the lisp part.  "redisplayed" is the marker field.  */
+
+  /* If touched by redisplay.  */
+  bool redisplayed;
 
-  int hidden;                  //if the "live" instance isnt drawn
+  /* The "live" instance isn't drawn.  */
+  bool hidden;
 
   GtkWidget *widget;
   GtkWidget *widgetwindow;
@@ -85,48 +87,47 @@ struct xwidget_view
   int clip_top;
   int clip_left;
 
-
   long handler_id;
 };
+#endif
 
-/* Test for xwidget pseudovector*/
+/* Test for xwidget pseudovector.  */
 #define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
-#define XXWIDGET(a) (eassert (XWIDGETP(a)), \
-                     (struct xwidget *) XUNTAG(a, Lisp_Vectorlike))
+#define XXWIDGET(a) (eassert (XWIDGETP (a)), \
+                     (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
 
 #define CHECK_XWIDGET(x) \
   CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
 
-/* Test for xwidget_view pseudovector */
+/* Test for xwidget_view pseudovector.  */
 #define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
-#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P(a)), \
-                          (struct xwidget_view *) XUNTAG(a, Lisp_Vectorlike))
+#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
+                          (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
 
 #define CHECK_XWIDGET_VIEW(x) \
   CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
 
-struct xwidget_type
-{
-  /* A symbol uniquely identifying the xwidget type, */
-  Lisp_Object *type;
-
-  /* Check that SPEC is a valid image specification for the given
-     image type.  Value is non-zero if SPEC is valid.  */
-  int (*valid_p) (Lisp_Object spec);
-
-  /* Next in list of all supported image types.  */
-  struct xwidget_type *next;
-};
-
-
-struct xwidget *xwidget_from_id (int id);
-
-void xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix);
-
-struct xwidget *lookup_xwidget (Lisp_Object spec);
 #define XG_XWIDGET "emacs_xwidget"
 #define XG_XWIDGET_VIEW "emacs_xwidget_view"
-void xwidget_view_delete_all_in_window (struct window *w);
 
-void kill_buffer_xwidgets (Lisp_Object buffer);
+#ifdef HAVE_XWIDGETS
+void syms_of_xwidget (void);
+bool valid_xwidget_spec_p (Lisp_Object);
+void xwidget_view_delete_all_in_window (struct window *);
+void x_draw_xwidget_glyph_string (struct glyph_string *);
+struct xwidget *lookup_xwidget (Lisp_Object spec);
+void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
+void kill_buffer_xwidgets (Lisp_Object);
+#else
+INLINE_HEADER_BEGIN
+INLINE void syms_of_xwidget (void) {}
+INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
+INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
+INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume 
(0); }
+INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
+INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
+INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
+INLINE_HEADER_END
+#endif
+
 #endif /* XWIDGET_H_INCLUDED */



reply via email to

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