aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2012-10-11 20:29:47 +0900
committerKenichi Handa2012-10-11 20:29:47 +0900
commitd3e4228575e9ba9e99dc4a7dae788280ffcc4566 (patch)
tree97d35f3c0766372c166a31f3c0f7aba791a38dde
parentcde44a7728488ca6bc6a46c18d9c5e647b160547 (diff)
parentfd2f90cf5c6a15610aa1e17e73d6d8a5f8cb1999 (diff)
downloademacs-d3e4228575e9ba9e99dc4a7dae788280ffcc4566.tar.gz
emacs-d3e4228575e9ba9e99dc4a7dae788280ffcc4566.zip
merge trunk
-rw-r--r--ChangeLog9
-rw-r--r--admin/ChangeLog5
-rw-r--r--admin/admin.el27
-rw-r--r--autogen/Makefile.in2
-rw-r--r--autogen/config.in3
-rwxr-xr-xautogen/configure160
-rw-r--r--configure.ac82
-rw-r--r--doc/emacs/ChangeLog16
-rw-r--r--doc/emacs/basic.texi11
-rw-r--r--doc/emacs/cal-xtra.texi5
-rw-r--r--doc/emacs/calendar.texi11
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/misc/ChangeLog4
-rw-r--r--doc/misc/trampver.texi2
-rw-r--r--etc/NEWS50
-rw-r--r--lib-src/ChangeLog17
-rw-r--r--lib-src/emacsclient.c198
-rw-r--r--lib-src/makefile.w32-in2
-rw-r--r--lisp/ChangeLog236
-rw-r--r--lisp/battery.el2
-rw-r--r--lisp/bindings.el38
-rw-r--r--lisp/calendar/calendar.el2
-rw-r--r--lisp/cedet/ChangeLog19
-rw-r--r--lisp/cedet/semantic.el1
-rw-r--r--lisp/cedet/semantic/bovine/el.el2
-rw-r--r--lisp/cedet/semantic/ede-grammar.el10
-rw-r--r--lisp/cedet/semantic/wisent/python.el16
-rw-r--r--lisp/comint.el16
-rw-r--r--lisp/cus-start.el3
-rw-r--r--lisp/emacs-lisp/autoload.el2
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el2
-rw-r--r--lisp/emacs-lisp/cl-macs.el43
-rw-r--r--lisp/emacs-lisp/edebug.el4
-rw-r--r--lisp/faces.el2
-rw-r--r--lisp/ffap.el18
-rw-r--r--lisp/frame.el55
-rw-r--r--lisp/generic-x.el79
-rw-r--r--lisp/gnus/ChangeLog5
-rw-r--r--lisp/gnus/shr.el2
-rw-r--r--lisp/international/mule-cmds.el3
-rw-r--r--lisp/loadup.el13
-rw-r--r--lisp/mouse.el2
-rw-r--r--lisp/net/tramp-cache.el39
-rw-r--r--lisp/net/tramp-gvfs.el8
-rw-r--r--lisp/net/tramp-sh.el95
-rw-r--r--lisp/net/tramp-smb.el23
-rw-r--r--lisp/net/tramp.el55
-rw-r--r--lisp/net/trampver.el4
-rw-r--r--lisp/newcomment.el12
-rw-r--r--lisp/progmodes/cc-bytecomp.el24
-rw-r--r--lisp/progmodes/cc-vars.el10
-rw-r--r--lisp/progmodes/python.el475
-rw-r--r--lisp/select.el12
-rw-r--r--lisp/server.el73
-rw-r--r--lisp/simple.el2
-rw-r--r--lisp/startup.el3
-rw-r--r--lisp/subr.el8
-rw-r--r--lisp/term/common-win.el2
-rw-r--r--lisp/term/ns-win.el11
-rw-r--r--lisp/term/w32-win.el51
-rw-r--r--lisp/term/x-win.el5
-rw-r--r--lisp/textmodes/rst.el4
-rw-r--r--lisp/textmodes/tex-mode.el3
-rw-r--r--lisp/url/ChangeLog5
-rw-r--r--lisp/url/url-methods.el4
-rw-r--r--lisp/w32-common-fns.el130
-rw-r--r--lisp/w32-fns.el107
-rw-r--r--lisp/w32-vars.el24
-rw-r--r--lisp/window.el94
-rw-r--r--msdos/ChangeLog4
-rw-r--r--msdos/sed1v2.inp2
-rw-r--r--nt/ChangeLog5
-rw-r--r--nt/config.nt3
-rw-r--r--src/ChangeLog373
-rw-r--r--src/Makefile.in28
-rw-r--r--src/alloc.c15
-rw-r--r--src/commands.h3
-rw-r--r--src/conf_post.h14
-rw-r--r--src/cygw32.c169
-rw-r--r--src/cygw32.h53
-rw-r--r--src/dispextern.h4
-rw-r--r--src/dispnew.c10
-rw-r--r--src/emacs.c61
-rw-r--r--src/font.c4
-rw-r--r--src/font.h5
-rw-r--r--src/fontset.c2
-rw-r--r--src/frame.c12
-rw-r--r--src/frame.h5
-rw-r--r--src/image.c80
-rw-r--r--src/indent.c1
-rw-r--r--src/keyboard.c324
-rw-r--r--src/keyboard.h30
-rw-r--r--src/keymap.c159
-rw-r--r--src/keymap.h13
-rw-r--r--src/lisp.h27
-rw-r--r--src/makefile.w32-in28
-rw-r--r--src/marker.c2
-rw-r--r--src/menu.c6
-rw-r--r--src/nsfont.m13
-rw-r--r--src/nsmenu.m3
-rw-r--r--src/nsterm.m7
-rw-r--r--src/process.c15
-rw-r--r--src/ralloc.c5
-rw-r--r--src/regex.c1
-rw-r--r--src/search.c16
-rw-r--r--src/term.c1
-rw-r--r--src/termhooks.h6
-rw-r--r--src/termopts.h11
-rw-r--r--src/unexcw.c1
-rw-r--r--src/unexw32.c3
-rw-r--r--src/w32.c20
-rw-r--r--src/w32.h17
-rw-r--r--src/w32common.h53
-rw-r--r--src/w32console.c51
-rw-r--r--src/w32fns.c811
-rw-r--r--src/w32font.c4
-rw-r--r--src/w32heap.c55
-rw-r--r--src/w32heap.h23
-rw-r--r--src/w32inevt.c172
-rw-r--r--src/w32menu.c29
-rw-r--r--src/w32proc.c15
-rw-r--r--src/w32select.c9
-rw-r--r--src/w32select.h28
-rw-r--r--src/w32term.c50
-rw-r--r--src/w32term.h59
-rw-r--r--src/w32xfns.c32
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c7
-rw-r--r--src/xfaces.c18
-rw-r--r--src/xsettings.c1
-rw-r--r--src/xsmfns.c1
131 files changed, 3596 insertions, 1851 deletions
diff --git a/ChangeLog b/ChangeLog
index 50450bbc506..9c839658429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
2 2
3 * .bzrignore: Add several files under admin/charsets. 3 * .bzrignore: Add several files under admin/charsets.
4 4
52012-10-08 Daniel Colascione <dancol@dancol.org>
6
7 * configure.ac: Add --with-w32 as a window system option. Limit
8 it to Cygwin for now. Integrate w32 into the refactored window
9 system configuration and set TERM_HEADER to w32term.h when w32 is
10 configured.
11
12 (CYGWIN_OBJ): Add cygw32.o.
13
52012-10-07 Jan Djärv <jan.h.d@swipnet.se> 142012-10-07 Jan Djärv <jan.h.d@swipnet.se>
6 15
7 * configure.ac: Check that OSX is 10.4 or newer. 16 * configure.ac: Check that OSX is 10.4 or newer.
diff --git a/admin/ChangeLog b/admin/ChangeLog
index ef8ff5ce65c..ca2ebbdfa06 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -22,6 +22,11 @@
22 charsets/mapfiles/MULE-tibetan.map, 22 charsets/mapfiles/MULE-tibetan.map,
23 charsets/mapfiles/MULE-uviscii.map: Fix typo. 23 charsets/mapfiles/MULE-uviscii.map: Fix typo.
24 24
252012-10-09 Glenn Morris <rgm@gnu.org>
26
27 * admin.el (cusver-scan-cus-start): New function.
28 (cusver-check): Scan old cus-start.el.
29
252012-10-07 Glenn Morris <rgm@gnu.org> 302012-10-07 Glenn Morris <rgm@gnu.org>
26 31
27 * admin.el (cusver-new-version): Set default. 32 * admin.el (cusver-new-version): Set default.
diff --git a/admin/admin.el b/admin/admin.el
index 3e3fbba7202..59d085b6405 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -446,8 +446,6 @@ If optional OLD is non-nil, also include defvars."
446 (1+ emacs-minor-version)) 446 (1+ emacs-minor-version))
447 "Version number that new defcustoms should have.") 447 "Version number that new defcustoms should have.")
448 448
449;; TODO do something about renamed variables with aliases to the old name?
450;; Scan old cus-start.el to find variables moved from C to lisp?
451(defun cusver-scan (file &optional old) 449(defun cusver-scan (file &optional old)
452 "Scan FILE for `defcustom' calls. 450 "Scan FILE for `defcustom' calls.
453Return a list with elements of the form (VAR . VER), 451Return a list with elements of the form (VAR . VER),
@@ -486,6 +484,21 @@ If optional argument OLD is non-nil, also scan for defvars."
486 (message "%sdone" m) 484 (message "%sdone" m)
487 alist)) 485 alist))
488 486
487(defun cusver-scan-cus-start (file)
488 "Scan cus-start.el and return an alist with elements (VAR . VER)."
489 (if (file-readable-p file)
490 (with-temp-buffer
491 (insert-file-contents file)
492 (when (search-forward "(let ((all '(" nil t)
493 (backward-char 1)
494 (let (var ver alist)
495 (dolist (elem (ignore-errors (read (current-buffer))))
496 (when (symbolp (setq var (car-safe elem)))
497 (or (stringp (setq ver (nth 3 elem)))
498 (setq ver nil))
499 (setq alist (cons (cons var ver) alist))))
500 alist)))))
501
489(define-button-type 'cusver-xref 'action #'cusver-goto-xref) 502(define-button-type 'cusver-xref 'action #'cusver-goto-xref)
490 503
491(defun cusver-goto-xref (button) 504(defun cusver-goto-xref (button)
@@ -501,11 +514,9 @@ If optional argument OLD is non-nil, also scan for defvars."
501 (pop-to-buffer (current-buffer)))))) 514 (pop-to-buffer (current-buffer))))))
502 515
503;; You should probably at least do a grep over the old directory 516;; You should probably at least do a grep over the old directory
504;; to check the results of this look sensible. Eg cus-start if 517;; to check the results of this look sensible.
505;; something moved from C to Lisp. 518;; TODO Check cus-start if something moved from C to Lisp.
506;; TODO handle renamed things with aliases to the old names. 519;; TODO Handle renamed things with aliases to the old names.
507;; What to do about new files? Does everything in there need a :version,
508;; or eg just the defgroup?
509(defun cusver-check (newdir olddir version) 520(defun cusver-check (newdir olddir version)
510 "Check that defcustoms have :version tags where needed. 521 "Check that defcustoms have :version tags where needed.
511NEWDIR is the current lisp/ directory, OLDDIR is that from the previous 522NEWDIR is the current lisp/ directory, OLDDIR is that from the previous
@@ -537,6 +548,8 @@ changes (in a non-trivial way). This function does not check for that."
537 (message "Reading old defcustoms...") 548 (message "Reading old defcustoms...")
538 (dolist (file oldfiles) 549 (dolist (file oldfiles)
539 (setq oldcus (append oldcus (cusver-scan file t)))) 550 (setq oldcus (append oldcus (cusver-scan file t))))
551 (setq oldcus (append oldcus (cusver-scan-cus-start
552 (expand-file-name "cus-start.el" olddir))))
540 ;; newcus has elements (FILE (VAR VER) ... ). 553 ;; newcus has elements (FILE (VAR VER) ... ).
541 ;; oldcus just (VAR . VER). 554 ;; oldcus just (VAR . VER).
542 (message "Checking for version tags...") 555 (message "Checking for version tags...")
diff --git a/autogen/Makefile.in b/autogen/Makefile.in
index 14cb3c9c9c1..db60a006a21 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -753,6 +753,8 @@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
753UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ 753UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
754VERSION = @VERSION@ 754VERSION = @VERSION@
755VMLIMIT_OBJ = @VMLIMIT_OBJ@ 755VMLIMIT_OBJ = @VMLIMIT_OBJ@
756W32_LIBS = @W32_LIBS@
757W32_OBJ = @W32_OBJ@
756WARN_CFLAGS = @WARN_CFLAGS@ 758WARN_CFLAGS = @WARN_CFLAGS@
757WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ 759WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
758WERROR_CFLAGS = @WERROR_CFLAGS@ 760WERROR_CFLAGS = @WERROR_CFLAGS@
diff --git a/autogen/config.in b/autogen/config.in
index 8a8799db1cf..c5f32371dd7 100644
--- a/autogen/config.in
+++ b/autogen/config.in
@@ -692,6 +692,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
692 Mac OS X. */ 692 Mac OS X. */
693#undef HAVE_NS 693#undef HAVE_NS
694 694
695/* Define to use native MS Windows GUI. */
696#undef HAVE_NTGUI
697
695/* Define to 1 if libotf has OTF_get_variation_glyphs. */ 698/* Define to 1 if libotf has OTF_get_variation_glyphs. */
696#undef HAVE_OTF_GET_VARIATION_GLYPHS 699#undef HAVE_OTF_GET_VARIATION_GLYPHS
697 700
diff --git a/autogen/configure b/autogen/configure
index 623d93bb39c..67e1039d54c 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -1204,6 +1204,8 @@ LIB_PTHREAD
1204VMLIMIT_OBJ 1204VMLIMIT_OBJ
1205GMALLOC_OBJ 1205GMALLOC_OBJ
1206HAVE_XSERVER 1206HAVE_XSERVER
1207W32_LIBS
1208W32_OBJ
1207LIB_STANDARD 1209LIB_STANDARD
1208NS_OBJC_OBJ 1210NS_OBJC_OBJ
1209NS_OBJ 1211NS_OBJ
@@ -1362,6 +1364,7 @@ with_toolkit_scroll_bars
1362with_xaw3d 1364with_xaw3d
1363with_xim 1365with_xim
1364with_ns 1366with_ns
1367with_w32
1365with_gpm 1368with_gpm
1366with_dbus 1369with_dbus
1367with_gconf 1370with_gconf
@@ -2081,6 +2084,7 @@ Optional Packages:
2081 --without-xaw3d don't use Xaw3d 2084 --without-xaw3d don't use Xaw3d
2082 --without-xim don't use X11 XIM 2085 --without-xim don't use X11 XIM
2083 --with-ns use NeXTstep (Cocoa or GNUstep) windowing system 2086 --with-ns use NeXTstep (Cocoa or GNUstep) windowing system
2087 --with-w32 use native MS Windows GUI
2084 --without-gpm don't use -lgpm for mouse support on a GNU/Linux 2088 --without-gpm don't use -lgpm for mouse support on a GNU/Linux
2085 console 2089 console
2086 --without-dbus don't compile with D-Bus support 2090 --without-dbus don't compile with D-Bus support
@@ -4093,6 +4097,14 @@ else
4093fi 4097fi
4094 4098
4095 4099
4100# Check whether --with-w32 was given.
4101if test "${with_w32+set}" = set; then :
4102 withval=$with_w32;
4103else
4104 with_w32=no
4105fi
4106
4107
4096 4108
4097# Check whether --with-gpm was given. 4109# Check whether --with-gpm was given.
4098if test "${with_gpm+set}" = set; then : 4110if test "${with_gpm+set}" = set; then :
@@ -9568,6 +9580,7 @@ $as_echo "#define NS_HAVE_NSINTEGER 1" >>confdefs.h
9568fi 9580fi
9569 9581
9570 9582
9583
9571INSTALL_ARCH_INDEP_EXTRA=install-etc 9584INSTALL_ARCH_INDEP_EXTRA=install-etc
9572ns_self_contained=no 9585ns_self_contained=no
9573NS_OBJ= 9586NS_OBJ=
@@ -9603,6 +9616,38 @@ CPPFLAGS="$tmp_CPPFLAGS"
9603 9616
9604 9617
9605 9618
9619HAVE_W32=no
9620W32_OBJ=
9621W32_LIBS=
9622if test "${with_w32}" != no; then
9623 if test "${opsys}" != "cygwin"; then
9624 as_fn_error "Using w32 with an autotools build is only supported for Cygwin." "$LINENO" 5
9625 fi
9626 ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
9627if test "x$ac_cv_header_windows_h" = x""yes; then :
9628 HAVE_W32=yes
9629else
9630 as_fn_error "\`--with-w32' was specified, but windows.h
9631 cannot be found." "$LINENO" 5
9632fi
9633
9634
9635
9636$as_echo "#define HAVE_NTGUI 1" >>confdefs.h
9637
9638 W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
9639 W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
9640 W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
9641 W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
9642fi
9643
9644
9645
9646if test "${HAVE_W32}" = "yes"; then
9647 window_system=w32
9648 with_xft=no
9649fi
9650
9606## $window_system is now set to the window system we will 9651## $window_system is now set to the window system we will
9607## ultimately use. 9652## ultimately use.
9608 9653
@@ -9635,6 +9680,9 @@ case "${window_system}" in
9635 nextstep ) 9680 nextstep )
9636 term_header=nsterm.h 9681 term_header=nsterm.h
9637 ;; 9682 ;;
9683 w32 )
9684 term_header=w32term.h
9685 ;;
9638esac 9686esac
9639 9687
9640if test -n "${term_header}"; then 9688if test -n "${term_header}"; then
@@ -11701,6 +11749,10 @@ if test "${with_toolkit_scroll_bars}" != "no"; then
11701 $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h 11749 $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
11702 11750
11703 USE_TOOLKIT_SCROLL_BARS=yes 11751 USE_TOOLKIT_SCROLL_BARS=yes
11752 elif test "${HAVE_W32}" = "yes"; then
11753 $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
11754
11755 USE_TOOLKIT_SCROLL_BARS=yes
11704 fi 11756 fi
11705fi 11757fi
11706 11758
@@ -12262,6 +12314,99 @@ fi
12262### Use -lXpm if available, unless `--with-xpm=no'. 12314### Use -lXpm if available, unless `--with-xpm=no'.
12263HAVE_XPM=no 12315HAVE_XPM=no
12264LIBXPM= 12316LIBXPM=
12317
12318if test "${HAVE_W32}" = "yes"; then
12319 if test "${with_xpm}" != "no"; then
12320 SAVE_CPPFLAGS="$CPPFLAGS"
12321 SAVE_LDFLAGS="$LDFLAGS"
12322 CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
12323 LDFLAGS="$LDFLAGS -L/usr/lib/noX"
12324 ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
12325if test "x$ac_cv_header_X11_xpm_h" = x""yes; then :
12326 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReadFileToImage in -lXpm" >&5
12327$as_echo_n "checking for XpmReadFileToImage in -lXpm... " >&6; }
12328if test "${ac_cv_lib_Xpm_XpmReadFileToImage+set}" = set; then :
12329 $as_echo_n "(cached) " >&6
12330else
12331 ac_check_lib_save_LIBS=$LIBS
12332LIBS="-lXpm $LIBS"
12333cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12334/* end confdefs.h. */
12335
12336/* Override any GCC internal prototype to avoid an error.
12337 Use char because int might match the return type of a GCC
12338 builtin and then its argument prototype would still apply. */
12339#ifdef __cplusplus
12340extern "C"
12341#endif
12342char XpmReadFileToImage ();
12343int
12344main ()
12345{
12346return XpmReadFileToImage ();
12347 ;
12348 return 0;
12349}
12350_ACEOF
12351if ac_fn_c_try_link "$LINENO"; then :
12352 ac_cv_lib_Xpm_XpmReadFileToImage=yes
12353else
12354 ac_cv_lib_Xpm_XpmReadFileToImage=no
12355fi
12356rm -f core conftest.err conftest.$ac_objext \
12357 conftest$ac_exeext conftest.$ac_ext
12358LIBS=$ac_check_lib_save_LIBS
12359fi
12360{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xpm_XpmReadFileToImage" >&5
12361$as_echo "$ac_cv_lib_Xpm_XpmReadFileToImage" >&6; }
12362if test "x$ac_cv_lib_Xpm_XpmReadFileToImage" = x""yes; then :
12363 HAVE_XPM=yes
12364fi
12365
12366fi
12367
12368
12369 if test "${HAVE_XPM}" = "yes"; then
12370 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReturnAllocPixels preprocessor define" >&5
12371$as_echo_n "checking for XpmReturnAllocPixels preprocessor define... " >&6; }
12372 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12373/* end confdefs.h. */
12374#include "X11/xpm.h"
12375#ifndef XpmReturnAllocPixels
12376no_return_alloc_pixels
12377#endif
12378
12379_ACEOF
12380if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
12381 $EGREP "no_return_alloc_pixels" >/dev/null 2>&1; then :
12382 HAVE_XPM=no
12383else
12384 HAVE_XPM=yes
12385fi
12386rm -f conftest*
12387
12388
12389 if test "${HAVE_XPM}" = "yes"; then
12390 REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
12391 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12392$as_echo "yes" >&6; }
12393 else
12394 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12395$as_echo "no" >&6; }
12396 CPPFLAGS="$SAVE_CPPFLAGS"
12397 LDFLAGS="$SAVE_LDFLAGS"
12398 fi
12399 fi
12400 fi
12401
12402 if test "${HAVE_XPM}" = "yes"; then
12403
12404$as_echo "#define HAVE_XPM 1" >>confdefs.h
12405
12406 LIBXPM=-lXpm
12407 fi
12408fi
12409
12265if test "${HAVE_X11}" = "yes"; then 12410if test "${HAVE_X11}" = "yes"; then
12266 if test "${with_xpm}" != "no"; then 12411 if test "${with_xpm}" != "no"; then
12267 ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default" 12412 ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
@@ -12348,10 +12493,11 @@ $as_echo "#define HAVE_XPM 1" >>confdefs.h
12348fi 12493fi
12349 12494
12350 12495
12496
12351### Use -ljpeg if available, unless `--with-jpeg=no'. 12497### Use -ljpeg if available, unless `--with-jpeg=no'.
12352HAVE_JPEG=no 12498HAVE_JPEG=no
12353LIBJPEG= 12499LIBJPEG=
12354if test "${HAVE_X11}" = "yes"; then 12500if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
12355 if test "${with_jpeg}" != "no"; then 12501 if test "${with_jpeg}" != "no"; then
12356 ac_fn_c_check_header_mongrel "$LINENO" "jerror.h" "ac_cv_header_jerror_h" "$ac_includes_default" 12502 ac_fn_c_check_header_mongrel "$LINENO" "jerror.h" "ac_cv_header_jerror_h" "$ac_includes_default"
12357if test "x$ac_cv_header_jerror_h" = x""yes; then : 12503if test "x$ac_cv_header_jerror_h" = x""yes; then :
@@ -12430,7 +12576,7 @@ fi
12430### Use -lpng if available, unless `--with-png=no'. 12576### Use -lpng if available, unless `--with-png=no'.
12431HAVE_PNG=no 12577HAVE_PNG=no
12432LIBPNG= 12578LIBPNG=
12433if test "${HAVE_X11}" = "yes"; then 12579if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
12434 if test "${with_png}" != "no"; then 12580 if test "${with_png}" != "no"; then
12435 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h 12581 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
12436 # in /usr/include/libpng. 12582 # in /usr/include/libpng.
@@ -12520,7 +12666,7 @@ fi
12520### Use -ltiff if available, unless `--with-tiff=no'. 12666### Use -ltiff if available, unless `--with-tiff=no'.
12521HAVE_TIFF=no 12667HAVE_TIFF=no
12522LIBTIFF= 12668LIBTIFF=
12523if test "${HAVE_X11}" = "yes"; then 12669if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
12524 if test "${with_tiff}" != "no"; then 12670 if test "${with_tiff}" != "no"; then
12525 ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default" 12671 ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default"
12526if test "x$ac_cv_header_tiffio_h" = x""yes; then : 12672if test "x$ac_cv_header_tiffio_h" = x""yes; then :
@@ -12584,7 +12730,8 @@ fi
12584### Use -lgif or -lungif if available, unless `--with-gif=no'. 12730### Use -lgif or -lungif if available, unless `--with-gif=no'.
12585HAVE_GIF=no 12731HAVE_GIF=no
12586LIBGIF= 12732LIBGIF=
12587if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no"; then 12733if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
12734 || test "${HAVE_W32}" = "yes"; then
12588 ac_fn_c_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" 12735 ac_fn_c_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default"
12589if test "x$ac_cv_header_gif_lib_h" = x""yes; then : 12736if test "x$ac_cv_header_gif_lib_h" = x""yes; then :
12590 # EGifPutExtensionLast only exists from version libungif-4.1.0b1. 12737 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
@@ -12805,6 +12952,9 @@ $as_echo "#define NS_IMPL_GNUSTEP 1" >>confdefs.h
12805 OTHER_FILES=ns-app 12952 OTHER_FILES=ns-app
12806fi 12953fi
12807 12954
12955if test "${HAVE_W32}" = "yes"; then
12956 HAVE_MENUS=yes
12957fi
12808 12958
12809### Use session management (-lSM -lICE) if available 12959### Use session management (-lSM -lICE) if available
12810HAVE_X_SM=no 12960HAVE_X_SM=no
@@ -16078,7 +16228,7 @@ fi
16078 16228
16079 16229
16080if test "$opsys" = "cygwin"; then 16230if test "$opsys" = "cygwin"; then
16081 CYGWIN_OBJ="sheap.o" 16231 CYGWIN_OBJ="sheap.o cygw32.o"
16082 ## Cygwin differs because of its unexec(). 16232 ## Cygwin differs because of its unexec().
16083 PRE_ALLOC_OBJ= 16233 PRE_ALLOC_OBJ=
16084 POST_ALLOC_OBJ=lastfile.o 16234 POST_ALLOC_OBJ=lastfile.o
diff --git a/configure.ac b/configure.ac
index 748f435aec2..5520dd6a903 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,7 @@ OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
177OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d]) 177OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
178OPTION_DEFAULT_ON([xim],[don't use X11 XIM]) 178OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
179OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system]) 179OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
180OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI])
180 181
181OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console]) 182OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
182OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support]) 183OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
@@ -1534,6 +1535,7 @@ fail;
1534 AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.]) 1535 AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
1535 fi 1536 fi
1536fi 1537fi
1538
1537AC_SUBST(TEMACS_LDFLAGS2) 1539AC_SUBST(TEMACS_LDFLAGS2)
1538 1540
1539INSTALL_ARCH_INDEP_EXTRA=install-etc 1541INSTALL_ARCH_INDEP_EXTRA=install-etc
@@ -1574,6 +1576,30 @@ AC_SUBST(NS_OBJ)
1574AC_SUBST(NS_OBJC_OBJ) 1576AC_SUBST(NS_OBJC_OBJ)
1575AC_SUBST(LIB_STANDARD) 1577AC_SUBST(LIB_STANDARD)
1576 1578
1579HAVE_W32=no
1580W32_OBJ=
1581W32_LIBS=
1582if test "${with_w32}" != no; then
1583 if test "${opsys}" != "cygwin"; then
1584 AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin.])
1585 fi
1586 AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
1587 [AC_MSG_ERROR([`--with-w32' was specified, but windows.h
1588 cannot be found.])])
1589 AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
1590 W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
1591 W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
1592 W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
1593 W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
1594fi
1595AC_SUBST(W32_OBJ)
1596AC_SUBST(W32_LIBS)
1597
1598if test "${HAVE_W32}" = "yes"; then
1599 window_system=w32
1600 with_xft=no
1601fi
1602
1577## $window_system is now set to the window system we will 1603## $window_system is now set to the window system we will
1578## ultimately use. 1604## ultimately use.
1579 1605
@@ -1610,6 +1636,9 @@ dnl use the toolkit if we have gtk, or X11R5 or newer.
1610 nextstep ) 1636 nextstep )
1611 term_header=nsterm.h 1637 term_header=nsterm.h
1612 ;; 1638 ;;
1639 w32 )
1640 term_header=w32term.h
1641 ;;
1613esac 1642esac
1614 1643
1615if test -n "${term_header}"; then 1644if test -n "${term_header}"; then
@@ -2310,6 +2339,9 @@ if test "${with_toolkit_scroll_bars}" != "no"; then
2310 elif test "${HAVE_NS}" = "yes"; then 2339 elif test "${HAVE_NS}" = "yes"; then
2311 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS) 2340 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2312 USE_TOOLKIT_SCROLL_BARS=yes 2341 USE_TOOLKIT_SCROLL_BARS=yes
2342 elif test "${HAVE_W32}" = "yes"; then
2343 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2344 USE_TOOLKIT_SCROLL_BARS=yes
2313 fi 2345 fi
2314fi 2346fi
2315 2347
@@ -2476,6 +2508,41 @@ AC_SUBST(M17N_FLT_LIBS)
2476### Use -lXpm if available, unless `--with-xpm=no'. 2508### Use -lXpm if available, unless `--with-xpm=no'.
2477HAVE_XPM=no 2509HAVE_XPM=no
2478LIBXPM= 2510LIBXPM=
2511
2512if test "${HAVE_W32}" = "yes"; then
2513 if test "${with_xpm}" != "no"; then
2514 SAVE_CPPFLAGS="$CPPFLAGS"
2515 SAVE_LDFLAGS="$LDFLAGS"
2516 CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
2517 LDFLAGS="$LDFLAGS -L/usr/lib/noX"
2518 AC_CHECK_HEADER(X11/xpm.h,
2519 [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
2520 if test "${HAVE_XPM}" = "yes"; then
2521 AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2522 AC_EGREP_CPP(no_return_alloc_pixels,
2523 [#include "X11/xpm.h"
2524#ifndef XpmReturnAllocPixels
2525no_return_alloc_pixels
2526#endif
2527 ], HAVE_XPM=no, HAVE_XPM=yes)
2528
2529 if test "${HAVE_XPM}" = "yes"; then
2530 REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
2531 AC_MSG_RESULT(yes)
2532 else
2533 AC_MSG_RESULT(no)
2534 CPPFLAGS="$SAVE_CPPFLAGS"
2535 LDFLAGS="$SAVE_LDFLAGS"
2536 fi
2537 fi
2538 fi
2539
2540 if test "${HAVE_XPM}" = "yes"; then
2541 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm libary (-lXpm).])
2542 LIBXPM=-lXpm
2543 fi
2544fi
2545
2479if test "${HAVE_X11}" = "yes"; then 2546if test "${HAVE_X11}" = "yes"; then
2480 if test "${with_xpm}" != "no"; then 2547 if test "${with_xpm}" != "no"; then
2481 AC_CHECK_HEADER(X11/xpm.h, 2548 AC_CHECK_HEADER(X11/xpm.h,
@@ -2502,12 +2569,13 @@ no_return_alloc_pixels
2502 LIBXPM=-lXpm 2569 LIBXPM=-lXpm
2503 fi 2570 fi
2504fi 2571fi
2572
2505AC_SUBST(LIBXPM) 2573AC_SUBST(LIBXPM)
2506 2574
2507### Use -ljpeg if available, unless `--with-jpeg=no'. 2575### Use -ljpeg if available, unless `--with-jpeg=no'.
2508HAVE_JPEG=no 2576HAVE_JPEG=no
2509LIBJPEG= 2577LIBJPEG=
2510if test "${HAVE_X11}" = "yes"; then 2578if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2511 if test "${with_jpeg}" != "no"; then 2579 if test "${with_jpeg}" != "no"; then
2512 dnl Checking for jpeglib.h can lose because of a redefinition of 2580 dnl Checking for jpeglib.h can lose because of a redefinition of
2513 dnl HAVE_STDLIB_H. 2581 dnl HAVE_STDLIB_H.
@@ -2535,7 +2603,7 @@ AC_SUBST(LIBJPEG)
2535### Use -lpng if available, unless `--with-png=no'. 2603### Use -lpng if available, unless `--with-png=no'.
2536HAVE_PNG=no 2604HAVE_PNG=no
2537LIBPNG= 2605LIBPNG=
2538if test "${HAVE_X11}" = "yes"; then 2606if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2539 if test "${with_png}" != "no"; then 2607 if test "${with_png}" != "no"; then
2540 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h 2608 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
2541 # in /usr/include/libpng. 2609 # in /usr/include/libpng.
@@ -2568,7 +2636,7 @@ AC_SUBST(LIBPNG)
2568### Use -ltiff if available, unless `--with-tiff=no'. 2636### Use -ltiff if available, unless `--with-tiff=no'.
2569HAVE_TIFF=no 2637HAVE_TIFF=no
2570LIBTIFF= 2638LIBTIFF=
2571if test "${HAVE_X11}" = "yes"; then 2639if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2572 if test "${with_tiff}" != "no"; then 2640 if test "${with_tiff}" != "no"; then
2573 AC_CHECK_HEADER(tiffio.h, 2641 AC_CHECK_HEADER(tiffio.h,
2574 [tifflibs="-lz -lm" 2642 [tifflibs="-lz -lm"
@@ -2588,7 +2656,8 @@ AC_SUBST(LIBTIFF)
2588### Use -lgif or -lungif if available, unless `--with-gif=no'. 2656### Use -lgif or -lungif if available, unless `--with-gif=no'.
2589HAVE_GIF=no 2657HAVE_GIF=no
2590LIBGIF= 2658LIBGIF=
2591if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no"; then 2659if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
2660 || test "${HAVE_W32}" = "yes"; then
2592 AC_CHECK_HEADER(gif_lib.h, 2661 AC_CHECK_HEADER(gif_lib.h,
2593# EGifPutExtensionLast only exists from version libungif-4.1.0b1. 2662# EGifPutExtensionLast only exists from version libungif-4.1.0b1.
2594# Earlier versions can crash Emacs. 2663# Earlier versions can crash Emacs.
@@ -2670,6 +2739,9 @@ if test "${HAVE_NS}" = "yes"; then
2670 OTHER_FILES=ns-app 2739 OTHER_FILES=ns-app
2671fi 2740fi
2672 2741
2742if test "${HAVE_W32}" = "yes"; then
2743 HAVE_MENUS=yes
2744fi
2673 2745
2674### Use session management (-lSM -lICE) if available 2746### Use session management (-lSM -lICE) if available
2675HAVE_X_SM=no 2747HAVE_X_SM=no
@@ -4205,7 +4277,7 @@ fi
4205AC_SUBST(RALLOC_OBJ) 4277AC_SUBST(RALLOC_OBJ)
4206 4278
4207if test "$opsys" = "cygwin"; then 4279if test "$opsys" = "cygwin"; then
4208 CYGWIN_OBJ="sheap.o" 4280 CYGWIN_OBJ="sheap.o cygw32.o"
4209 ## Cygwin differs because of its unexec(). 4281 ## Cygwin differs because of its unexec().
4210 PRE_ALLOC_OBJ= 4282 PRE_ALLOC_OBJ=
4211 POST_ALLOC_OBJ=lastfile.o 4283 POST_ALLOC_OBJ=lastfile.o
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 067574b9a0d..3aad65f7bed 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,13 @@
12012-10-10 Dani Moncayo <dmoncayo@gmail.com>
2
3 * basic.texi (Arguments): Fix typos.
4
52012-10-08 Glenn Morris <rgm@gnu.org>
6
7 * cal-xtra.texi (Calendar Customizing): Mention calendar-month-header.
8
9 * calendar.texi (Writing Calendar Files): Mention cal-html-holidays.
10
12012-10-06 Glenn Morris <rgm@gnu.org> 112012-10-06 Glenn Morris <rgm@gnu.org>
2 12
3 * calendar.texi (Writing Calendar Files): Tweak week descriptions. 13 * calendar.texi (Writing Calendar Files): Tweak week descriptions.
@@ -419,7 +429,7 @@
419 * misc.texi (emacsclient Options): Add cross-reference to "Windows 429 * misc.texi (emacsclient Options): Add cross-reference to "Windows
420 Startup". (Bug#11091) 430 Startup". (Bug#11091)
421 431
4222012-04-02 Dani Moncayo <dmoncayo@gmail.com> (tiny change) 4322012-04-02 Dani Moncayo <dmoncayo@gmail.com>
423 433
424 * custom.texi (Changing a Variable): Fix example. 434 * custom.texi (Changing a Variable): Fix example.
425 435
@@ -452,7 +462,7 @@
452 * mule.texi (International Chars): 462 * mule.texi (International Chars):
453 etc/HELLO is for character demonstration. 463 etc/HELLO is for character demonstration.
454 464
4552012-03-15 Dani Moncayo <dmoncayo@gmail.com> (tiny change) 4652012-03-15 Dani Moncayo <dmoncayo@gmail.com>
456 466
457 * dired.texi (Shell Commands in Dired): Fix typo. 467 * dired.texi (Shell Commands in Dired): Fix typo.
458 468
@@ -479,7 +489,7 @@
479 * macos.texi (Mac / GNUstep Customization): Remove text about 489 * macos.texi (Mac / GNUstep Customization): Remove text about
480 ns-find-file and ns-drag-file (Bug#5855, Bug#10050). 490 ns-find-file and ns-drag-file (Bug#5855, Bug#10050).
481 491
4822012-02-25 Dani Moncayo <dmoncayo@gmail.com> (tiny change) 4922012-02-25 Dani Moncayo <dmoncayo@gmail.com>
483 493
484 * buffers.texi (Select Buffer): Mention that saving in a new file 494 * buffers.texi (Select Buffer): Mention that saving in a new file
485 name can switch to a different major mode. 495 name can switch to a different major mode.
diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index 42bd2a4fde2..07060db5af2 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -757,7 +757,8 @@ the character @samp{1}.
757value. For example, the command @kbd{M-q} (@code{fill-paragraph}) 757value. For example, the command @kbd{M-q} (@code{fill-paragraph})
758fills text; with an argument, it justifies the text as well. 758fills text; with an argument, it justifies the text as well.
759(@xref{Filling}, for more information on @kbd{M-q}.) For these 759(@xref{Filling}, for more information on @kbd{M-q}.) For these
760commands, it is enough to the argument with a single @kbd{C-u}. 760commands, it is enough to specify the argument with a single
761@kbd{C-u}.
761 762
762 Some commands use the value of the argument as a repeat count, but 763 Some commands use the value of the argument as a repeat count, but
763do something special when there is no argument. For example, the 764do something special when there is no argument. For example, the
@@ -776,10 +777,10 @@ described when they come up; they exist to make an individual command
776more convenient, and they are documented in that command's 777more convenient, and they are documented in that command's
777documentation string. 778documentation string.
778 779
779 We use the term ``prefix argument'' as well as ``numeric argument'', 780 We use the term @dfn{prefix argument} to emphasize that you type
780to emphasize that you type these argument before the command, and to 781such arguments before the command, and to distinguish them from
781distinguish them from minibuffer arguments that come after the 782minibuffer arguments (@pxref{Minibuffer}), which are entered after
782command. 783invoking the command.
783 784
784@node Repeating 785@node Repeating
785@section Repeating a Command 786@section Repeating a Command
diff --git a/doc/emacs/cal-xtra.texi b/doc/emacs/cal-xtra.texi
index b29a8526625..09beabc40cb 100644
--- a/doc/emacs/cal-xtra.texi
+++ b/doc/emacs/cal-xtra.texi
@@ -41,6 +41,11 @@ To display text @emph{between} the months, for example week numbers,
41customize the variables @code{calendar-intermonth-header} and 41customize the variables @code{calendar-intermonth-header} and
42@code{calendar-intermonth-text} as described in their documentation. 42@code{calendar-intermonth-text} as described in their documentation.
43 43
44@vindex calendar-month-header
45 The variable @code{calendar-month-header} controls the text that
46appears above each month in the calendar. By default, it shows the
47month and year.
48
44@vindex calendar-holiday-marker 49@vindex calendar-holiday-marker
45@vindex diary-entry-marker 50@vindex diary-entry-marker
46@vindex calendar-today-marker 51@vindex calendar-today-marker
diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi
index d46e26cddcf..d1ddd0dce90 100644
--- a/doc/emacs/calendar.texi
+++ b/doc/emacs/calendar.texi
@@ -349,11 +349,12 @@ calendar deletes or iconifies that frame depending on the value of
349 349
350@cindex calendar and HTML 350@cindex calendar and HTML
351 The Calendar HTML commands produce files of HTML code that contain 351 The Calendar HTML commands produce files of HTML code that contain
352calendar and diary entries. Each file applies to one month, and has a 352calendar, holiday, and diary entries. Each file applies to one month,
353name of the format @file{@var{yyyy}-@var{mm}.html}, where @var{yyyy} and 353and has a name of the format @file{@var{yyyy}-@var{mm}.html}, where
354@var{mm} are the four-digit year and two-digit month, respectively. The 354@var{yyyy} and @var{mm} are the four-digit year and two-digit month,
355variable @code{cal-html-directory} specifies the default output 355respectively. The variable @code{cal-html-directory} specifies the
356directory for the HTML files. 356default output directory for the HTML files. To prevent holidays
357from being shown, customize @code{cal-html-holidays}.
357 358
358@vindex cal-html-css-default 359@vindex cal-html-css-default
359 Diary entries enclosed by @code{<} and @code{>} are interpreted as 360 Diary entries enclosed by @code{<} and @code{>} are interpreted as
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 7609efb8ac9..974a0d67192 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1978,7 +1978,7 @@
1978 * numbers.texi (Integer Basics): Add indexing for 1978 * numbers.texi (Integer Basics): Add indexing for
1979 most-positive-fixnum and most-negative-fixnum. (Bug#9525) 1979 most-positive-fixnum and most-negative-fixnum. (Bug#9525)
1980 1980
19812011-09-14 Dani Moncayo <dmoncayo@gmail.com> (tiny change) 19812011-09-14 Dani Moncayo <dmoncayo@gmail.com>
1982 1982
1983 * lists.texi (Sets And Lists): Fix typo. (Bug#9393) 1983 * lists.texi (Sets And Lists): Fix typo. (Bug#9393)
1984 1984
@@ -1987,7 +1987,7 @@
1987 * processes.texi (Network Servers): Clarify what the process 1987 * processes.texi (Network Servers): Clarify what the process
1988 buffer is used for (bug#9233). 1988 buffer is used for (bug#9233).
1989 1989
19902011-08-30 Dani Moncayo <dmoncayo@gmail.com> (tiny change) 19902011-08-30 Dani Moncayo <dmoncayo@gmail.com>
1991 1991
1992 * lists.texi (Building Lists): Fix typo. 1992 * lists.texi (Building Lists): Fix typo.
1993 1993
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 5fdd4acde95..3ee183ff255 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,7 @@
12012-10-09 Michael Albinus <michael.albinus@gmx.de>
2
3 * trampver.texi: Update release number.
4
12012-10-06 Glenn Morris <rgm@gnu.org> 52012-10-06 Glenn Morris <rgm@gnu.org>
2 6
3 * erc.texi: Include emacsver.texi, and use EMACSVER rather than 7 * erc.texi: Include emacsver.texi, and use EMACSVER rather than
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index d902ac0fb97..96043a07300 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -8,7 +8,7 @@
8@c In the Tramp CVS, the version number is auto-frobbed from 8@c In the Tramp CVS, the version number is auto-frobbed from
9@c configure.ac, so you should edit that file and run 9@c configure.ac, so you should edit that file and run
10@c "autoconf && ./configure" to change the version number. 10@c "autoconf && ./configure" to change the version number.
11@set trampver 2.2.6 11@set trampver 2.2.7-pre
12 12
13@c Other flags from configuration 13@c Other flags from configuration
14@set instprefix /usr/local 14@set instprefix /usr/local
diff --git a/etc/NEWS b/etc/NEWS
index 1a7eb82967d..2b934741c2c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -23,18 +23,36 @@ so we will look at it and add it to the manual.
23 23
24* Installation Changes in Emacs 24.3 24* Installation Changes in Emacs 24.3
25 25
26---
27** The default toolkit has been changed to Gtk+ version 3.
28If you don't pass --with-x-toolkit to configure or if you pass
29--with-x-toolkit=gtk or --with-x-toolkit=yes, configure will try to build
30with Gtk+ version 3, and if that fails, try Gtk+ version 2.
31You can explicitly require a specific version by passing
32--with-x-toolkit=gtk2 or --with-x-toolkit=gtk3 to configure.
33
34---
26** New configure option '--without-all' to disable additional features. 35** New configure option '--without-all' to disable additional features.
27This disables most of the features that are normally enabled by default. 36This disables most of the features that are normally enabled by default.
28 37
38---
29** New configure option '--enable-link-time-optimization' to utilize 39** New configure option '--enable-link-time-optimization' to utilize
30an appropriate feature provided by GCC since version 4.5.0. 40an appropriate feature provided by GCC since version 4.5.0.
31 41
42---
32** New configure option '--enable-gcc-warnings', intended for developers. 43** New configure option '--enable-gcc-warnings', intended for developers.
33If building with GCC, this enables compile-time checks that warn about 44If building with GCC, this enables compile-time checks that warn about
34possibly-questionable C code. On a recent GNU system there should be 45possibly-questionable C code. On a recent GNU system there should be
35no warnings; on older and on non-GNU systems the generated warnings 46no warnings; on older and on non-GNU systems the generated warnings
36may be useful. 47may be useful.
37 48
49---
50** The configuration option '--enable-use-lisp-union-type' has been
51renamed to '--enable-check-lisp-object-type', as the resulting
52Lisp_Object type no longer uses a union to implement the compile time
53check that this option enables.
54
55---
38** The configure option '--disable-maintainer-mode' has been removed, 56** The configure option '--disable-maintainer-mode' has been removed,
39as it was confusingly-named and rarely useful. 57as it was confusingly-named and rarely useful.
40 58
@@ -60,18 +78,10 @@ directories to the search path. You must add them yourself if you want them.
60(from the bin and libexec directories, respectively). The former is 78(from the bin and libexec directories, respectively). The former is
61no longer relevant, the latter is replaced by lisp (in vc-sccs.el). 79no longer relevant, the latter is replaced by lisp (in vc-sccs.el).
62 80
63** The configuration option '--enable-use-lisp-union-type' has been
64renamed to '--enable-check-lisp-object-type', as the resulting
65Lisp_Object type no longer uses a union to implement the compile time
66check that this option enables.
67
68--- 81---
69** The default toolkit has been changed to Gtk+ version 3. 82** The native Windows user interface is available for Cygwin. Passing
70If you don't pass --with-x-toolkit to configure or if you pass 83--with-w32 will configure a Cygwin emacs to use the Windows user
71--with-x-toolkit=gtk or --with-x-toolkit=yes, configure will try to build 84interface instead of the default, X11.
72with Gtk+ version 3, and if that fails, try Gtk+ version 2.
73You can explicitly require a specific version by passing
74--with-x-toolkit=gtk2 or --with-x-toolkit=gtk3 to configure.
75 85
76 86
77* Startup Changes in Emacs 24.3 87* Startup Changes in Emacs 24.3
@@ -160,8 +170,6 @@ On encountering a fatal error, Emacs now outputs a textual description
160of the fatal signal, and a short backtrace on platforms like glibc 170of the fatal signal, and a short backtrace on platforms like glibc
161that support backtraces. 171that support backtraces.
162 172
163** `message-log-max' now defaults to 1000, not 100.
164
165--- 173---
166** If your Emacs was built from a bzr checkout, the new variable 174** If your Emacs was built from a bzr checkout, the new variable
167`emacs-bzr-version' contains information about the bzr revision used. 175`emacs-bzr-version' contains information about the bzr revision used.
@@ -280,14 +288,16 @@ Use `Buffer-menu-name-width' and `Buffer-menu-size-width' instead.
280 288
281** Calendar 289** Calendar
282 290
291+++
283*** You can customize the header text that appears above each calendar month. 292*** You can customize the header text that appears above each calendar month.
284See the variable `calendar-month-header'. 293See the variable `calendar-month-header'.
285 294
286+++ 295+++
287*** New LaTeX calendar style, produced by `cal-tex-cursor-week2-summary'. 296*** New LaTeX calendar style, produced by `cal-tex-cursor-week2-summary'.
288 297
298+++
289*** The calendars produced by cal-html include holidays. 299*** The calendars produced by cal-html include holidays.
290Customize cal-html-holidays to change this. 300Customize `cal-html-holidays' to change this.
291 301
292** CL 302** CL
293 303
@@ -421,6 +431,9 @@ The option `follow-intercept-processes' has been removed.
421specifying URL types which should be converted to remote file names at 431specifying URL types which should be converted to remote file names at
422the FFAP prompt. The default is now '("ftp"). 432the FFAP prompt. The default is now '("ftp").
423 433
434** Generic-x
435`javascript-generic-mode' is now an obsolete alias for `js-mode'.
436
424** Ibuffer 437** Ibuffer
425 438
426*** New `derived-mode' filter, bound to `/ M'. 439*** New `derived-mode' filter, bound to `/ M'.
@@ -703,7 +716,7 @@ are deprecated and will be removed eventually.
703*** `compile-internal' 716*** `compile-internal'
704*** `mode-line-inverse-video' 717*** `mode-line-inverse-video'
705*** `cvs-commit-buffer-require-final-newline' 718*** `cvs-commit-buffer-require-final-newline'
706(use `'log-edit-require-final-newline'instead) 719(use `log-edit-require-final-newline' instead)
707*** `cvs-changelog-full-paragraphs' 720*** `cvs-changelog-full-paragraphs'
708(use `log-edit-changelog-full-paragraphs' instead) 721(use `log-edit-changelog-full-paragraphs' instead)
709*** `cvs-diff-ignore-marks', `cvs-diff-buffer-name' 722*** `cvs-diff-ignore-marks', `cvs-diff-buffer-name'
@@ -832,7 +845,7 @@ macro-calls to be left for later expansion (as before), but will also
832result in a warning ("Eager macro-expansion skipped due to cycle") 845result in a warning ("Eager macro-expansion skipped due to cycle")
833describing the cycle. 846describing the cycle.
834 847
835** Misc new functions: 848** Miscellaneous new functions:
836 849
837*** `autoloadp' 850*** `autoloadp'
838*** `autoload-do-load'. 851*** `autoload-do-load'.
@@ -877,6 +890,11 @@ is detected.
877Emacs now supports mouse highlight, help-echo (in the echo area), and 890Emacs now supports mouse highlight, help-echo (in the echo area), and
878mouse-autoselect-window. 891mouse-autoselect-window.
879 892
893** Two new functions are available in Cygwin builds of Emacs:
894cygwin-convert-path-from-windows and cygwin-convert-path-to-windows.
895These functions allow Lisp code to access the Cygwin file-name mapping
896machinery to convert between Cygwin and Windows-native file names.
897
880** On MS-Windows Vista and later Emacs now supports symbolic links. 898** On MS-Windows Vista and later Emacs now supports symbolic links.
881 899
882* Changes in Emacs 24.2 900* Changes in Emacs 24.2
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 2a8ac9b8131..85351d7f08d 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,20 @@
12012-10-08 Eli Zaretskii <eliz@gnu.org>
2
3 * makefile.w32-in (obj): Add cygw32.o.
4
52012-10-08 Daniel Colascione <dancol@dancol.org>
6
7 * emacsclient.c: Include windows.h when HAVE_NTGUI.
8 (alt_display): New variable. We send the display held by this
9 variable when the primary display is either unsupported or not
10 present.
11 (longopts): Allow display everywhere.
12 (w32_set_user_model_id): Move lower in file, inside HAVE_NTGUI
13 section.
14 (decode_options): Use alt_display. Explain why.
15 (main): Retry connection with alt_display if connection with main
16 display fails.
17
12012-10-01 Fabrice Popineau <fabrice.popineau@gmail.com> 182012-10-01 Fabrice Popineau <fabrice.popineau@gmail.com>
2 19
3 * make-docfile.c (write_globals): Special-case 20 * make-docfile.c (write_globals): Special-case
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 07300dbf249..8d60d7961da 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -44,6 +44,10 @@ char *w32_getenv (char *);
44 44
45#else /* !WINDOWSNT */ 45#else /* !WINDOWSNT */
46 46
47# ifdef HAVE_NTGUI
48# include <windows.h>
49# endif /* HAVE_NTGUI */
50
47# include "syswait.h" 51# include "syswait.h"
48 52
49# ifdef HAVE_INET_SOCKETS 53# ifdef HAVE_INET_SOCKETS
@@ -140,6 +144,9 @@ int current_frame = 1;
140/* The display on which Emacs should work. --display. */ 144/* The display on which Emacs should work. --display. */
141const char *display = NULL; 145const char *display = NULL;
142 146
147/* The alternate display we should try if Emacs does not support display. */
148const char *alt_display = NULL;
149
143/* The parent window ID, if we are opening a frame via XEmbed. */ 150/* The parent window ID, if we are opening a frame via XEmbed. */
144char *parent_id = NULL; 151char *parent_id = NULL;
145 152
@@ -182,9 +189,7 @@ struct option longopts[] =
182 { "socket-name", required_argument, NULL, 's' }, 189 { "socket-name", required_argument, NULL, 's' },
183#endif 190#endif
184 { "server-file", required_argument, NULL, 'f' }, 191 { "server-file", required_argument, NULL, 'f' },
185#ifndef WINDOWSNT
186 { "display", required_argument, NULL, 'd' }, 192 { "display", required_argument, NULL, 'd' },
187#endif
188 { "parent-id", required_argument, NULL, 'p' }, 193 { "parent-id", required_argument, NULL, 'p' },
189 { 0, 0, 0, 0 } 194 { 0, 0, 0, 0 }
190}; 195};
@@ -385,32 +390,6 @@ w32_getenv (char *envvar)
385 return NULL; 390 return NULL;
386} 391}
387 392
388void
389w32_set_user_model_id (void)
390{
391 HMODULE shell;
392 HRESULT (WINAPI * set_user_model) (wchar_t * id);
393
394 /* On Windows 7 and later, we need to set the user model ID
395 to associate emacsclient launched files with Emacs frames
396 in the UI. */
397 shell = LoadLibrary ("shell32.dll");
398 if (shell)
399 {
400 set_user_model
401 = (void *) GetProcAddress (shell,
402 "SetCurrentProcessExplicitAppUserModelID");
403 /* If the function is defined, then we are running on Windows 7
404 or newer, and the UI uses this to group related windows
405 together. Since emacs, runemacs, emacsclient are related, we
406 want them grouped even though the executables are different,
407 so we need to set a consistent ID between them. */
408 if (set_user_model)
409 set_user_model (L"GNU.Emacs");
410
411 FreeLibrary (shell);
412 }
413}
414 393
415int 394int
416w32_window_app (void) 395w32_window_app (void)
@@ -605,16 +584,29 @@ decode_options (int argc, char **argv)
605 Without the -c option, we used to set `display' to $DISPLAY by 584 Without the -c option, we used to set `display' to $DISPLAY by
606 default, but this changed the default behavior and is sometimes 585 default, but this changed the default behavior and is sometimes
607 inconvenient. So we force users to use "--display $DISPLAY" if 586 inconvenient. So we force users to use "--display $DISPLAY" if
608 they want Emacs to connect to their current display. */ 587 they want Emacs to connect to their current display.
588
589 Some window systems have a notion of default display not
590 reflected in the DISPLAY variable. If the user didn't give us an
591 explicit display, try this platform-specific after trying the
592 display in DISPLAY (if any). */
609 if (!current_frame && !tty && !display) 593 if (!current_frame && !tty && !display)
610 { 594 {
611 display = egetenv ("DISPLAY"); 595 /* Set these here so we use a default_display only when the user
612#ifdef NS_IMPL_COCOA 596 didn't give us an explicit display. */
613 /* Under Cocoa, we don't really use displays the same way as in X, 597#if defined (NS_IMPL_COCOA)
614 so provide a dummy. */ 598 alt_display = "ns";
615 if (!display || strlen (display) == 0) 599#elif defined (HAVE_NTGUI)
616 display = "ns"; 600 alt_display = "w32";
617#endif 601#endif
602
603 display = egetenv ("DISPLAY");
604 }
605
606 if (!display)
607 {
608 display = alt_display;
609 alt_display = NULL;
618 } 610 }
619 611
620 /* A null-string display is invalid. */ 612 /* A null-string display is invalid. */
@@ -1415,10 +1407,37 @@ set_socket (int no_exit_if_error)
1415 exit (EXIT_FAILURE); 1407 exit (EXIT_FAILURE);
1416} 1408}
1417 1409
1418#ifdef WINDOWSNT 1410#ifdef HAVE_NTGUI
1419FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ 1411FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
1420FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ 1412FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
1421 1413
1414void
1415w32_set_user_model_id (void)
1416{
1417 HMODULE shell;
1418 HRESULT (WINAPI * set_user_model) (wchar_t * id);
1419
1420 /* On Windows 7 and later, we need to set the user model ID
1421 to associate emacsclient launched files with Emacs frames
1422 in the UI. */
1423 shell = LoadLibrary ("shell32.dll");
1424 if (shell)
1425 {
1426 set_user_model
1427 = (void *) GetProcAddress (shell,
1428 "SetCurrentProcessExplicitAppUserModelID");
1429 /* If the function is defined, then we are running on Windows 7
1430 or newer, and the UI uses this to group related windows
1431 together. Since emacs, runemacs, emacsclient are related, we
1432 want them grouped even though the executables are different,
1433 so we need to set a consistent ID between them. */
1434 if (set_user_model)
1435 set_user_model (L"GNU.Emacs");
1436
1437 FreeLibrary (shell);
1438 }
1439}
1440
1422BOOL CALLBACK 1441BOOL CALLBACK
1423w32_find_emacs_process (HWND hWnd, LPARAM lParam) 1442w32_find_emacs_process (HWND hWnd, LPARAM lParam)
1424{ 1443{
@@ -1467,7 +1486,7 @@ w32_give_focus (void)
1467 && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) 1486 && (get_wc = GetProcAddress (user32, "RealGetWindowClassA")))
1468 EnumWindows (w32_find_emacs_process, (LPARAM) 0); 1487 EnumWindows (w32_find_emacs_process, (LPARAM) 0);
1469} 1488}
1470#endif 1489#endif /* HAVE_NTGUI */
1471 1490
1472/* Start the emacs daemon and try to connect to it. */ 1491/* Start the emacs daemon and try to connect to it. */
1473 1492
@@ -1537,11 +1556,13 @@ main (int argc, char **argv)
1537 main_argv = argv; 1556 main_argv = argv;
1538 progname = argv[0]; 1557 progname = argv[0];
1539 1558
1540#ifdef WINDOWSNT 1559#ifdef HAVE_NTGUI
1541 /* On Windows 7 and later, we need to explicitly associate emacsclient 1560 /* On Windows 7 and later, we need to explicitly associate
1542 with emacs so the UI behaves sensibly. */ 1561 emacsclient with emacs so the UI behaves sensibly. This
1562 association does no harm if we're not actually connecting to an
1563 Emacs using a window display. */
1543 w32_set_user_model_id (); 1564 w32_set_user_model_id ();
1544#endif 1565#endif /* HAVE_NTGUI */
1545 1566
1546 /* Process options. */ 1567 /* Process options. */
1547 decode_options (argc, argv); 1568 decode_options (argc, argv);
@@ -1577,9 +1598,10 @@ main (int argc, char **argv)
1577 fail (); 1598 fail ();
1578 } 1599 }
1579 1600
1580#ifdef WINDOWSNT 1601#ifdef HAVE_NTGUI
1602 if (display && !strcmp (display, "w32"))
1581 w32_give_focus (); 1603 w32_give_focus ();
1582#endif 1604#endif /* HAVE_NTGUI */
1583 1605
1584 /* Send over our environment and current directory. */ 1606 /* Send over our environment and current directory. */
1585 if (!current_frame) 1607 if (!current_frame)
@@ -1748,46 +1770,56 @@ main (int argc, char **argv)
1748 if (end_p != NULL) 1770 if (end_p != NULL)
1749 *end_p++ = '\0'; 1771 *end_p++ = '\0';
1750 1772
1751 if (strprefix ("-emacs-pid ", p)) 1773 if (strprefix ("-emacs-pid ", p))
1752 { 1774 {
1753 /* -emacs-pid PID: The process id of the Emacs process. */ 1775 /* -emacs-pid PID: The process id of the Emacs process. */
1754 emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10); 1776 emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10);
1755 } 1777 }
1756 else if (strprefix ("-window-system-unsupported ", p)) 1778 else if (strprefix ("-window-system-unsupported ", p))
1757 { 1779 {
1758 /* -window-system-unsupported: Emacs was compiled without X 1780 /* -window-system-unsupported: Emacs was compiled without support
1759 support. Try again on the terminal. */ 1781 for whatever window system we tried. Try the alternate
1760 nowait = 0; 1782 display, or, failing that, try the terminal. */
1761 tty = 1; 1783 if (alt_display)
1762 goto retry; 1784 {
1763 } 1785 display = alt_display;
1764 else if (strprefix ("-print ", p)) 1786 alt_display = NULL;
1765 { 1787 }
1766 /* -print STRING: Print STRING on the terminal. */ 1788 else
1767 str = unquote_argument (p + strlen ("-print ")); 1789 {
1768 if (needlf) 1790 nowait = 0;
1769 printf ("\n"); 1791 tty = 1;
1770 printf ("%s", str); 1792 }
1771 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1793
1772 } 1794 goto retry;
1773 else if (strprefix ("-print-nonl ", p)) 1795 }
1774 { 1796 else if (strprefix ("-print ", p))
1775 /* -print-nonl STRING: Print STRING on the terminal. 1797 {
1776 Used to continue a preceding -print command. */ 1798 /* -print STRING: Print STRING on the terminal. */
1777 str = unquote_argument (p + strlen ("-print-nonl ")); 1799 str = unquote_argument (p + strlen ("-print "));
1778 printf ("%s", str); 1800 if (needlf)
1779 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1801 printf ("\n");
1780 } 1802 printf ("%s", str);
1781 else if (strprefix ("-error ", p)) 1803 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1782 { 1804 }
1783 /* -error DESCRIPTION: Signal an error on the terminal. */ 1805 else if (strprefix ("-print-nonl ", p))
1784 str = unquote_argument (p + strlen ("-error ")); 1806 {
1785 if (needlf) 1807 /* -print-nonl STRING: Print STRING on the terminal.
1786 printf ("\n"); 1808 Used to continue a preceding -print command. */
1787 fprintf (stderr, "*ERROR*: %s", str); 1809 str = unquote_argument (p + strlen ("-print-nonl "));
1788 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1810 printf ("%s", str);
1789 exit_status = EXIT_FAILURE; 1811 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1790 } 1812 }
1813 else if (strprefix ("-error ", p))
1814 {
1815 /* -error DESCRIPTION: Signal an error on the terminal. */
1816 str = unquote_argument (p + strlen ("-error "));
1817 if (needlf)
1818 printf ("\n");
1819 fprintf (stderr, "*ERROR*: %s", str);
1820 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1821 exit_status = EXIT_FAILURE;
1822 }
1791#ifdef SIGSTOP 1823#ifdef SIGSTOP
1792 else if (strprefix ("-suspend ", p)) 1824 else if (strprefix ("-suspend ", p))
1793 { 1825 {
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index 23ef71de10c..ecc5fb866b3 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -124,7 +124,7 @@ $(BLD)/profile.exe: $(PROFILEOBJS)
124obj = dosfns.o msdos.o \ 124obj = dosfns.o msdos.o \
125 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ 125 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
126 fontset.o menu.o \ 126 fontset.o menu.o \
127 w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ 127 w32.o w32console.o w32fns.o w32heap.o w32inevt.o cygw32.o \
128 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ 128 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
129 font.o w32font.o w32uniscribe.o \ 129 font.o w32font.o w32uniscribe.o \
130 dispnew.o frame.o scroll.o xdisp.o window.o bidi.o \ 130 dispnew.o frame.o scroll.o xdisp.o window.o bidi.o \
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8c83912e96d..b8c4e518b0c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,16 +2,248 @@
2 2
3 * international/eucjp-ms.el: Re-generated. 3 * international/eucjp-ms.el: Re-generated.
4 4
52012-10-10 Kenichi Handa <handa@gnu.org>
6
7 * select.el (xselect--encode-string): If a coding is specified for
8 selection, and that is compatible with COMPOUND_TEXT, use it.
9
102012-10-10 Martin Rudalics <rudalics@gmx.at>
11
12 * window.el (switch-to-buffer-preserve-window-point): New option.
13 (switch-to-buffer): Obey
14 `switch-to-buffer-preserve-window-point' (Bug#4041).
15
162012-10-09 Stefan Monnier <monnier@iro.umontreal.ca>
17
18 * newcomment.el (comment-start-skip, comment-end-skip, comment-end):
19 Don't document nil as a useful value (bug#12583).
20
212012-10-09 Michael Albinus <michael.albinus@gmx.de>
22
23 * net/tramp.el (tramp-debug-message):
24 Remove "tramp-with-progress-reporter" from regexp of ignored functions.
25 (with-tramp-progress-reporter): Rename from
26 `tramp-with-progress-reporter'.
27 (with-tramp-file-property, with-tramp-connection-property):
28 Move from tramp-cache.el, rename from `with-file-property' and
29 `with-connection-property', respectively.
30
31 * net/tramp-cache.el: Remove `with-file-property' and
32 `with-connection-property'.
33
34 * net/tramp.el:
35 * net/tramp-gvfs.el:
36 * net/tramp-sh.el:
37 * net/tramp-smb.el: Adapt callees.
38
39 * net/trampver.el: Update release number.
40
412012-10-09 Glenn Morris <rgm@gnu.org>
42
43 * w32-fns.el (set-message-beep):
44 * term/w32-win.el (set-message-beep): Update declarations.
45
462012-10-09 Stefan Monnier <monnier@iro.umontreal.ca>
47
48 * bindings.el (mode-line-toggle-read-only, mode-line-toggle-modified)
49 (mode-line-widen, mode-line-input-method-map)
50 (mode-line-coding-system-map, mode-line-remote)
51 (mode-line-unbury-buffer, mode-line-bury-buffer)
52 (mode-line-next-buffer, mode-line-previous-buffer):
53 Replace save-selected-window+select-window => with-selected-window.
54
55 * progmodes/cc-bytecomp.el (cc-bytecomp-defmacro): Remove, unused.
56 * progmodes/cc-vars.el (bq-process): Remove, unused.
57
58 * emacs-lisp/cl-macs.el (cl-defstruct): Obey the :read-only property.
59
602012-10-09 Fabián Ezequiel Gallina <fgallina@cuca>
61
62 Implemented `backward-up-list'-like navigation.
63 * progmodes/python.el (python-nav-up-list)
64 (python-nav-backward-up-list): New functions.
65 (python-mode-map): Define substitute key for backward-up-list to
66 python-nav-backward-up-list.
67
682012-10-08 Fabián Ezequiel Gallina <fgallina@cuca>
69
70 * progmodes/python.el (python-fill-paragraph): Rename from
71 python-fill-paragraph-function. Fixed fill-paragraph for
72 decorators (Bug#12605).
73
742012-10-08 Fabián Ezequiel Gallina <fgallina@cuca>
75
76 * progmodes/python.el (python-shell-output-filter): Handle extra
77 carriage return in OSX (Bug#12409).
78
792012-10-08 Fabián Ezequiel Gallina <fgallina@cuca>
80
81 Fix shell handling of unbalanced quotes and parens in output.
82 * progmodes/python.el (python-rx-constituents): Add string-delimiter.
83 (python-syntax-propertize-function): Use it.
84 (python-shell-output-syntax-table): New var.
85 (inferior-python-mode): Prevent unbalanced parens/quotes from
86 previous output mess with current input context.
87
882012-10-08 Juanma Barranquero <lekktu@gmail.com>
89
90 * generic-x.el (javascript-generic-mode, javascript-generic-mode-hook):
91 Make obsolete aliases of js-mode and js-mode-hook (from js.el).
92
932012-10-08 Michael Albinus <michael.albinus@gmx.de>
94
95 * ffap.el (ffap-replace-file-component): Support Tramp file name
96 syntax, not only ange-ftp's one.
97
982012-10-08 Glenn Morris <rgm@gnu.org>
99
100 * cus-start.el (message-log-max): Set :version.
101
102 * calendar/calendar.el (calendar-intermonth-header): Doc fix.
103
1042012-10-08 Martin Rudalics <rudalics@gmx.at>
105
106 * emacs-lisp/edebug.el (edebug-pop-to-buffer): Don't try to split
107 the minibuffer window (Bug#10851).
108
1092012-10-08 Fabián Ezequiel Gallina <fgallina@cuca>
110
111 Enhancements on forward-sexp movement.
112 * progmodes/python.el (python-nav-beginning-of-statement)
113 (python-nav-end-of-statement): Return point-marker.
114 (python-nav-forward-sexp): lisp-like forward-sexp behavior.
115 (python-info-current-symbol)
116 (python-info-statement-starts-block-p): Rename from
117 python-info-beginning-of-block-p.
118 (python-info-statement-ends-block-p): Rename from
119 python-info-end-of-block-p.
120 (python-info-beginning-of-statement-p)
121 (python-info-end-of-statement-p)
122 (python-info-beginning-of-block-p, python-info-end-of-block-p):
123 New functions.
124
1252012-10-08 Stefan Monnier <monnier@iro.umontreal.ca>
126
127 * comint.el (comint-preinput-scroll-to-bottom): Preserve the
128 frame-selected-windows.
129
1302012-10-08 Daniel Colascione <dancol@dancol.org>
131
132 * battery.el (battery-status-function): Check for
133 w32-battery-status itself, not system-time windows-nt.
134
135 * frame.el: Require cl-lib.
136 (display-format-alist): New variable mapping frame types to
137 functions that initialize them.
138 (window-system-for-display): New function: interprets
139 display-format-alist.
140 (make-frame-on-display): Remove existing display-selection logic
141 and just forward to make-frame, which will now DTRT.
142 (make-frame): Restructure to use window-system-for-display to
143 figure out how to create a frame on a given display.
144 (display-mouse-p): Look for frame-type w32, not a particular
145 system-type.
146
147 * loadup.el: Load w32 lisp code when we have the w32 feature.
148
149 * mouse.el (mouse-yank-primarY): Look for frame-type w32, not
150 system-type windows-nt.
151
152 * server.el (server-create-window-system-frame): Look for window
153 type.
154 (server-proces-filter): Only force a window system when windows-nt
155 _and_ w32. Explain why.
156
157 * simple.el (normal-erase-is-backspace-mode): Add w32 to the list
158 of window systems we configure for the mode.
159
160 * startup.el (command-line): Mark window system is initialized
161 after we've done it.
162
163 * common-win.el (x-select-text): Look for w32, not windows-nt.
164
165 * ns-win.el: Require cl-lib. Add ourselves to
166 display-format-alist.
167 (ns-initialize-window-system): Assert we're not initialized twice.
168
169 * w32-win.el: Enable lexical binding; require cl-lib; add
170 ourselves to display-format-alist.
171 (w32-handle-dropped-file): Convert incoming dropped files from
172 Windows paths to Cygwin ones before passing them on to the rest of
173 Emacs.
174 (w32-drag-n-drop): New paramter new-frame. Simplify logic.
175 (w32-initialize-window-system): Assert we're not initialized twice.
176
177 * x-win.el: Require cl-lib; add ourselves to display-format-alist.
178 (x-initialize-window-system): Assert we're not initialized twice.
179
180 * w32-common-fns.el: New File.
181 (w32-version, w32-using-nt, w32-get-clipboard-data)
182 (w32-set-clipboard-data, x-set-selection, x-get-selection)
183 (w32-charset-info-alist, x-last-selected, text)
184 (x-get-selection-value, x-selection-value): Move here.
185
186 * w32-fns.el: Require w32-common-fns.
187 (w32-version, w32-using-nt, w32-get-clipboard-data)
188 (w32-set-clipboard-data, x-set-selection, x-get-selection)
189 (w32-charset-info-alist, x-last-selected, text)
190 (x-get-selection-value, x-selection-value): Move to
191 w32-common-fns.
192
193 * w32-vars.el:
194 (w32-allow-system-shell, w32-system-shells): Define only in
195 non-cygwin case.
196
1972012-10-07 Stefan Monnier <monnier@iro.umontreal.ca>
198
199 * subr.el (read-passwd-map): Don't use `defconst' (bug#12597).
200 (read-passwd): Remove a few more potential sources of leaks.
201
2022012-10-07 Fabián Ezequiel Gallina <fgallina@cuca>
203
204 * progmodes/python.el (inferior-python-mode)
205 (python-shell-make-comint): Fix initialization of local
206 variables copied from parent buffer.
207
2082012-10-07 Jan Djärv <jan.h.d@swipnet.se>
209
210 * term/ns-win.el (ns-read-file-name): Update declaration to match
211 nsfns.m.
212 (ns-respond-to-change-font): Change fontsize separatly so we are sure
213 it is set when font is acted upon.
214
2152012-10-07 Fabián Ezequiel Gallina <fgallina@cuca>
216
217 Enhancements to indentation.
218 * progmodes/python.el (python-indent-context): Give priority to
219 inside-string context. Make comments indentation markers.
220 (python-indent-region): Do not mess with strings, unless it's the
221 enclosing set of quotes.
222
2232012-10-07 Stefan Monnier <monnier@iro.umontreal.ca>
224
225 * window.el (internal--before-save-selected-window)
226 (internal--after-save-selected-window): New functions extracted from
227 save-selected-window. Make sure we return the `alist' we construct.
228 (save-selected-window): Use them.
229
230 * textmodes/tex-mode.el (tex-recenter-output-buffer):
231 Use with-selected-window.
232
233 * emacs-lisp/autoload.el (make-autoload): Add `cl-defmacro' to the
234 forms that define macros (bug#12593).
235
52012-10-07 Kenichi Handa <handa@gnu.org> 2362012-10-07 Kenichi Handa <handa@gnu.org>
6 237
7 * international/mule-conf.el (compound-text-with-extensions): Add 238 * international/mule-conf.el (compound-text-with-extensions):
8 :mime-charset property as x-ctext. 239 Add :mime-charset property as x-ctext.
9 240
102012-10-07 Stefan Merten <smerten@oekonux.de> 2412012-10-07 Stefan Merten <smerten@oekonux.de>
11 242
12 * textmodes/rst.el (rst-new-adornment-down, rst-indent-field) 243 * textmodes/rst.el (rst-new-adornment-down, rst-indent-field)
13 (rst-indent-literal-normal, rst-indent-literal-minimized) 244 (rst-indent-literal-normal, rst-indent-literal-minimized)
14 (rst-indent-comment): Correct :version tag. 245 (rst-indent-comment): Correct :version tag.
246 (rst-official-cvs-rev): Correct version string.
15 247
162012-10-07 Glenn Morris <rgm@gnu.org> 2482012-10-07 Glenn Morris <rgm@gnu.org>
17 249
diff --git a/lisp/battery.el b/lisp/battery.el
index 8e98291b11c..69d25643bb9 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -60,7 +60,7 @@
60 (> (buffer-size) 0))) 60 (> (buffer-size) 0)))
61 (error nil))) 61 (error nil)))
62 'battery-pmset) 62 'battery-pmset)
63 ((eq system-type 'windows-nt) 63 ((fboundp 'w32-battery-status)
64 'w32-battery-status)) 64 'w32-battery-status))
65 "Function for getting battery status information. 65 "Function for getting battery status information.
66The function has to return an alist of conversion definitions. 66The function has to return an alist of conversion definitions.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index b4f9d29fe52..de5dd48c291 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -38,23 +38,20 @@ corresponding to the mode line clicked."
38(defun mode-line-toggle-read-only (event) 38(defun mode-line-toggle-read-only (event)
39 "Like `toggle-read-only', for the mode-line." 39 "Like `toggle-read-only', for the mode-line."
40 (interactive "e") 40 (interactive "e")
41 (save-selected-window 41 (with-selected-window (posn-window (event-start event))
42 (select-window (posn-window (event-start event)))
43 (read-only-mode 'toggle))) 42 (read-only-mode 'toggle)))
44 43
45(defun mode-line-toggle-modified (event) 44(defun mode-line-toggle-modified (event)
46 "Toggle the buffer-modified flag from the mode-line." 45 "Toggle the buffer-modified flag from the mode-line."
47 (interactive "e") 46 (interactive "e")
48 (save-selected-window 47 (with-selected-window (posn-window (event-start event))
49 (select-window (posn-window (event-start event)))
50 (set-buffer-modified-p (not (buffer-modified-p))) 48 (set-buffer-modified-p (not (buffer-modified-p)))
51 (force-mode-line-update))) 49 (force-mode-line-update)))
52 50
53(defun mode-line-widen (event) 51(defun mode-line-widen (event)
54 "Widen a buffer from the mode-line." 52 "Widen a buffer from the mode-line."
55 (interactive "e") 53 (interactive "e")
56 (save-selected-window 54 (with-selected-window (posn-window (event-start event))
57 (select-window (posn-window (event-start event)))
58 (widen) 55 (widen)
59 (force-mode-line-update))) 56 (force-mode-line-update)))
60 57
@@ -63,17 +60,13 @@ corresponding to the mode line clicked."
63 (define-key map [mode-line mouse-2] 60 (define-key map [mode-line mouse-2]
64 (lambda (e) 61 (lambda (e)
65 (interactive "e") 62 (interactive "e")
66 (save-selected-window 63 (with-selected-window (posn-window (event-start e))
67 (select-window
68 (posn-window (event-start e)))
69 (toggle-input-method) 64 (toggle-input-method)
70 (force-mode-line-update)))) 65 (force-mode-line-update))))
71 (define-key map [mode-line mouse-3] 66 (define-key map [mode-line mouse-3]
72 (lambda (e) 67 (lambda (e)
73 (interactive "e") 68 (interactive "e")
74 (save-selected-window 69 (with-selected-window (posn-window (event-start e))
75 (select-window
76 (posn-window (event-start e)))
77 (describe-current-input-method)))) 70 (describe-current-input-method))))
78 (purecopy map))) 71 (purecopy map)))
79 72
@@ -82,16 +75,14 @@ corresponding to the mode line clicked."
82 (define-key map [mode-line mouse-1] 75 (define-key map [mode-line mouse-1]
83 (lambda (e) 76 (lambda (e)
84 (interactive "e") 77 (interactive "e")
85 (save-selected-window 78 (with-selected-window (posn-window (event-start e))
86 (select-window (posn-window (event-start e)))
87 (when (and enable-multibyte-characters 79 (when (and enable-multibyte-characters
88 buffer-file-coding-system) 80 buffer-file-coding-system)
89 (describe-coding-system buffer-file-coding-system))))) 81 (describe-coding-system buffer-file-coding-system)))))
90 (define-key map [mode-line mouse-3] 82 (define-key map [mode-line mouse-3]
91 (lambda (e) 83 (lambda (e)
92 (interactive "e") 84 (interactive "e")
93 (save-selected-window 85 (with-selected-window (posn-window (event-start e))
94 (select-window (posn-window (event-start e)))
95 (call-interactively 'set-buffer-file-coding-system)))) 86 (call-interactively 'set-buffer-file-coding-system))))
96 (purecopy map)) 87 (purecopy map))
97 "Local keymap for the coding-system part of the mode line.") 88 "Local keymap for the coding-system part of the mode line.")
@@ -237,8 +228,7 @@ mnemonics of the following coding systems:
237 'mouse-face 'mode-line-highlight 228 'mouse-face 'mode-line-highlight
238 'help-echo (purecopy (lambda (window _object _point) 229 'help-echo (purecopy (lambda (window _object _point)
239 (format "%s" 230 (format "%s"
240 (save-selected-window 231 (with-selected-window window
241 (select-window window)
242 (concat 232 (concat
243 (if (file-remote-p default-directory) 233 (if (file-remote-p default-directory)
244 "Current directory is remote: " 234 "Current directory is remote: "
@@ -474,15 +464,13 @@ By default, this shows the information specified by
474(defun mode-line-unbury-buffer (event) "\ 464(defun mode-line-unbury-buffer (event) "\
475Call `unbury-buffer' in this window." 465Call `unbury-buffer' in this window."
476 (interactive "e") 466 (interactive "e")
477 (save-selected-window 467 (with-selected-window (posn-window (event-start event))
478 (select-window (posn-window (event-start event)))
479 (unbury-buffer))) 468 (unbury-buffer)))
480 469
481(defun mode-line-bury-buffer (event) "\ 470(defun mode-line-bury-buffer (event) "\
482Like `bury-buffer', but temporarily select EVENT's window." 471Like `bury-buffer', but temporarily select EVENT's window."
483 (interactive "e") 472 (interactive "e")
484 (save-selected-window 473 (with-selected-window (posn-window (event-start event))
485 (select-window (posn-window (event-start event)))
486 (bury-buffer))) 474 (bury-buffer)))
487 475
488(defun mode-line-other-buffer () "\ 476(defun mode-line-other-buffer () "\
@@ -493,15 +481,13 @@ Switch to the most recently selected buffer other than the current one."
493(defun mode-line-next-buffer (event) 481(defun mode-line-next-buffer (event)
494 "Like `next-buffer', but temporarily select EVENT's window." 482 "Like `next-buffer', but temporarily select EVENT's window."
495 (interactive "e") 483 (interactive "e")
496 (save-selected-window 484 (with-selected-window (posn-window (event-start event))
497 (select-window (posn-window (event-start event)))
498 (next-buffer))) 485 (next-buffer)))
499 486
500(defun mode-line-previous-buffer (event) 487(defun mode-line-previous-buffer (event)
501 "Like `previous-buffer', but temporarily select EVENT's window." 488 "Like `previous-buffer', but temporarily select EVENT's window."
502 (interactive "e") 489 (interactive "e")
503 (save-selected-window 490 (with-selected-window (posn-window (event-start event))
504 (select-window (posn-window (event-start event)))
505 (previous-buffer))) 491 (previous-buffer)))
506 492
507(defmacro bound-and-true-p (var) 493(defmacro bound-and-true-p (var)
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 96a5725ef69..02d1e3b54e9 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -511,7 +511,7 @@ Must be at least one less than `calendar-column-width'."
511 :version "23.1") 511 :version "23.1")
512 512
513(defcustom calendar-intermonth-header nil 513(defcustom calendar-intermonth-header nil
514 "Header text display in the space to the left of each calendar month. 514 "Header text to display in the space to the left of each calendar month.
515See `calendar-intermonth-text'." 515See `calendar-intermonth-text'."
516 :group 'calendar 516 :group 'calendar
517 :initialize 'custom-initialize-default 517 :initialize 'custom-initialize-default
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog
index ff5b603833d..14e8d6c1d64 100644
--- a/lisp/cedet/ChangeLog
+++ b/lisp/cedet/ChangeLog
@@ -1,3 +1,22 @@
12012-10-08 David Engster <deng@randomsample.de>>
2
3 * semantic/bovine/el.el: Add `semantic-default-elisp-setup' to
4 `emacs-lisp-mode-hook'. This was accidentally removed during the
5 CEDET update (2012-10-01T18:10:29Z!cyd@gnu.org).
6
72012-10-07 David Engster <deng@randomsample.de>
8
9 * semantic/wisent/python.el (semantic-ctxt-current-function)
10 (semantic-ctxt-current-assignment): New overrides, simply
11 returning nil. The defaults do not work correctly and can send
12 the parser in an infinite loop (bug#12458).
13
14 * semantic/ede-grammar.el (project-compile-target): Fix grammar
15 compilation after introduction of %provide statement.
16
17 * semantic.el (semantic-new-buffer-setup-functions): Remove setup
18 function for `f90-mode', since the parser only exists upstream.
19
12012-10-06 Glenn Morris <rgm@gnu.org> 202012-10-06 Glenn Morris <rgm@gnu.org>
2 21
3 * semantic/complete.el (semantic-displayor-tooltip-max-tags): Doc fix. 22 * semantic/complete.el (semantic-displayor-tooltip-max-tags): Doc fix.
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index 5182a38327c..e02790cbfa8 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -273,7 +273,6 @@ setup to use Semantic."
273 (js-mode . wisent-javascript-setup-parser) 273 (js-mode . wisent-javascript-setup-parser)
274 (python-mode . wisent-python-default-setup) 274 (python-mode . wisent-python-default-setup)
275 (scheme-mode . semantic-default-scheme-setup) 275 (scheme-mode . semantic-default-scheme-setup)
276 (f90-mode . semantic-default-f90-setup)
277 (srecode-template-mode . srecode-template-setup-parser) 276 (srecode-template-mode . srecode-template-setup-parser)
278 (texinfo-mode . semantic-default-texi-setup) 277 (texinfo-mode . semantic-default-texi-setup)
279 (makefile-automake-mode . semantic-default-make-setup) 278 (makefile-automake-mode . semantic-default-make-setup)
diff --git a/lisp/cedet/semantic/bovine/el.el b/lisp/cedet/semantic/bovine/el.el
index 7bad1483dc3..ea99df9edb9 100644
--- a/lisp/cedet/semantic/bovine/el.el
+++ b/lisp/cedet/semantic/bovine/el.el
@@ -944,6 +944,8 @@ ELisp variables can be pretty long, so track this one too.")
944 "Setup hook function for Emacs Lisp files and Semantic." 944 "Setup hook function for Emacs Lisp files and Semantic."
945 ) 945 )
946 946
947(add-hook 'emacs-lisp-mode-hook 'semantic-default-elisp-setup)
948
947;;; LISP MODE 949;;; LISP MODE
948;; 950;;
949;; @TODO: Lisp supports syntaxes that Emacs Lisp does not. 951;; @TODO: Lisp supports syntaxes that Emacs Lisp does not.
diff --git a/lisp/cedet/semantic/ede-grammar.el b/lisp/cedet/semantic/ede-grammar.el
index c92fcabecb1..16cf0ca96a2 100644
--- a/lisp/cedet/semantic/ede-grammar.el
+++ b/lisp/cedet/semantic/ede-grammar.el
@@ -143,12 +143,10 @@ Lays claim to all -by.el, and -wy.el files."
143 (utd 0)) 143 (utd 0))
144 (mapc (lambda (src) 144 (mapc (lambda (src)
145 (with-current-buffer (find-file-noselect src) 145 (with-current-buffer (find-file-noselect src)
146 (save-excursion 146 (let* ((package (semantic-grammar-create-package))
147 (semantic-grammar-create-package)) 147 (fname (progn (string-match ".*/\\(.+\\.el\\)" package)
148 ;; After compile, the current buffer is the compiled grammar. 148 (match-string 1 package)))
149 ;; Save and compile it. 149 (src (with-current-buffer fname (buffer-file-name)))
150 (save-buffer)
151 (let* ((src (buffer-file-name))
152 (csrc (concat (file-name-sans-extension src) ".elc"))) 150 (csrc (concat (file-name-sans-extension src) ".elc")))
153 (if (< emacs-major-version 24) 151 (if (< emacs-major-version 24)
154 ;; Does not have `byte-recompile-file' 152 ;; Does not have `byte-recompile-file'
diff --git a/lisp/cedet/semantic/wisent/python.el b/lisp/cedet/semantic/wisent/python.el
index ea603f251bb..a0ea488f0fe 100644
--- a/lisp/cedet/semantic/wisent/python.el
+++ b/lisp/cedet/semantic/wisent/python.el
@@ -478,6 +478,22 @@ To be implemented for Python! For now just return nil."
478 (let ((name (semantic-tag-name tag))) 478 (let ((name (semantic-tag-name tag)))
479 (concat (mapconcat 'identity (split-string name "\\.") "/") ".py"))) 479 (concat (mapconcat 'identity (split-string name "\\.") "/") ".py")))
480 480
481;; Override ctxt-current-function/assignment defaults, since they do
482;; not work properly with Python code, even leading to endless loops
483;; (see bug #xxxxx).
484(define-mode-local-override semantic-ctxt-current-function python-mode (&optional point)
485 "Return the current function call the cursor is in at POINT.
486The function returned is the one accepting the arguments that
487the cursor is currently in. It will not return function symbol if the
488cursor is on the text representing that function."
489 nil)
490
491(define-mode-local-override semantic-ctxt-current-assignment python-mode (&optional point)
492 "Return the current assignment near the cursor at POINT.
493Return a list as per `semantic-ctxt-current-symbol'.
494Return nil if there is nothing relevant."
495 nil)
496
481;;; Enable Semantic in `python-mode'. 497;;; Enable Semantic in `python-mode'.
482;; 498;;
483 499
diff --git a/lisp/comint.el b/lisp/comint.el
index fea9cecfa03..cff9afee0df 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2088,8 +2088,7 @@ This function should be a pre-command hook."
2088 (if (and comint-scroll-to-bottom-on-input 2088 (if (and comint-scroll-to-bottom-on-input
2089 (memq this-command '(self-insert-command comint-magic-space yank 2089 (memq this-command '(self-insert-command comint-magic-space yank
2090 hilit-yank))) 2090 hilit-yank)))
2091 (let* ((selected (selected-window)) 2091 (let* ((current (current-buffer))
2092 (current (current-buffer))
2093 (process (get-buffer-process current)) 2092 (process (get-buffer-process current))
2094 (scroll comint-scroll-to-bottom-on-input)) 2093 (scroll comint-scroll-to-bottom-on-input))
2095 (if (and process (< (point) (process-mark process))) 2094 (if (and process (< (point) (process-mark process)))
@@ -2099,10 +2098,8 @@ This function should be a pre-command hook."
2099 (lambda (window) 2098 (lambda (window)
2100 (if (and (eq (window-buffer window) current) 2099 (if (and (eq (window-buffer window) current)
2101 (or (eq scroll t) (eq scroll 'all))) 2100 (or (eq scroll t) (eq scroll 'all)))
2102 (progn 2101 (with-selected-window window
2103 (select-window window) 2102 (goto-char (point-max)))))
2104 (goto-char (point-max))
2105 (select-window selected))))
2106 nil t)))))) 2103 nil t))))))
2107 2104
2108(defvar follow-mode) 2105(defvar follow-mode)
@@ -2783,11 +2780,8 @@ the load or compile."
2783 (if (and buff 2780 (if (and buff
2784 (buffer-modified-p buff) 2781 (buffer-modified-p buff)
2785 (y-or-n-p (format "Save buffer %s first? " (buffer-name buff)))) 2782 (y-or-n-p (format "Save buffer %s first? " (buffer-name buff))))
2786 ;; save BUFF. 2783 (with-current-buffer buff
2787 (let ((old-buffer (current-buffer))) 2784 (save-buffer)))))
2788 (set-buffer buff)
2789 (save-buffer)
2790 (set-buffer old-buffer)))))
2791 2785
2792(defun comint-extract-string () 2786(defun comint-extract-string ()
2793 "Return string around point, or nil." 2787 "Return string around point, or nil."
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 28c1d3e3026..579551c9a91 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -452,7 +452,8 @@ since it could result in memory overflow and make Emacs crash."
452 (message-log-max debug (choice (const :tag "Disable" nil) 452 (message-log-max debug (choice (const :tag "Disable" nil)
453 (integer :menu-tag "lines" 453 (integer :menu-tag "lines"
454 :format "%v") 454 :format "%v")
455 (other :tag "Unlimited" t))) 455 (other :tag "Unlimited" t))
456 "24.3")
456 (unibyte-display-via-language-environment mule boolean) 457 (unibyte-display-via-language-environment mule boolean)
457 (blink-cursor-alist cursor alist "22.1") 458 (blink-cursor-alist cursor alist "22.1")
458 (overline-margin display integer "22.1") 459 (overline-margin display integer "22.1")
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index e6e2d1e60e0..382e25f3121 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -153,7 +153,7 @@ expression, in which case we want to handle forms differently."
153 easy-mmode-define-minor-mode define-minor-mode 153 easy-mmode-define-minor-mode define-minor-mode
154 cl-defun defun* cl-defmacro defmacro* 154 cl-defun defun* cl-defmacro defmacro*
155 define-overloadable-function)) 155 define-overloadable-function))
156 (let* ((macrop (memq car '(defmacro defmacro*))) 156 (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*)))
157 (name (nth 1 form)) 157 (name (nth 1 form))
158 (args (pcase car 158 (args (pcase car
159 ((or `defun `defmacro 159 ((or `defun `defmacro
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index e25ac5f9708..d05fbc42060 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -260,7 +260,7 @@ Remove from SYMBOL's plist the property PROPNAME and its value.
260;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when 260;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
261;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp 261;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
262;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) 262;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*)
263;;;;;; "cl-macs" "cl-macs.el" "6951d080daefb5194b1d21fe9b2deae4") 263;;;;;; "cl-macs" "cl-macs.el" "885919e79dbcd11081cfb2e039b470c7")
264;;; Generated autoloads from cl-macs.el 264;;; Generated autoloads from cl-macs.el
265 265
266(autoload 'cl--compiler-macro-list* "cl-macs" "\ 266(autoload 'cl--compiler-macro-list* "cl-macs" "\
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 99bae1944e8..592c33d21c5 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2324,26 +2324,29 @@ value, that slot cannot be set via `setf'.
2324 (if (= pos 0) '(car cl-x) 2324 (if (= pos 0) '(car cl-x)
2325 `(nth ,pos cl-x)))) forms) 2325 `(nth ,pos cl-x)))) forms)
2326 (push (cons accessor t) side-eff) 2326 (push (cons accessor t) side-eff)
2327 ;; Don't bother defining a setf-expander, since gv-get can use 2327 (if (cadr (memq :read-only (cddr desc)))
2328 ;; the compiler macro to get the same result. 2328 (push `(gv-define-expander ,accessor
2329 ;;(push `(gv-define-setter ,accessor (cl-val cl-x) 2329 (lambda (_cl-do _cl-x)
2330 ;; ,(if (cadr (memq :read-only (cddr desc))) 2330 (error "%s is a read-only slot" ',accessor)))
2331 ;; `(progn (ignore cl-x cl-val) 2331 forms)
2332 ;; (error "%s is a read-only slot" 2332 ;; For normal slots, we don't need to define a setf-expander,
2333 ;; ',accessor)) 2333 ;; since gv-get can use the compiler macro to get the
2334 ;; ;; If cl is loaded only for compilation, 2334 ;; same result.
2335 ;; ;; the call to cl--struct-setf-expander would 2335 ;; (push `(gv-define-setter ,accessor (cl-val cl-x)
2336 ;; ;; cause a warning because it may not be 2336 ;; ;; If cl is loaded only for compilation,
2337 ;; ;; defined at run time. Suppress that warning. 2337 ;; ;; the call to cl--struct-setf-expander would
2338 ;; `(progn 2338 ;; ;; cause a warning because it may not be
2339 ;; (declare-function 2339 ;; ;; defined at run time. Suppress that warning.
2340 ;; cl--struct-setf-expander "cl-macs" 2340 ;; (progn
2341 ;; (x name accessor pred-form pos)) 2341 ;; (declare-function
2342 ;; (cl--struct-setf-expander 2342 ;; cl--struct-setf-expander "cl-macs"
2343 ;; cl-val cl-x ',name ',accessor 2343 ;; (x name accessor pred-form pos))
2344 ;; ,(and pred-check `',pred-check) 2344 ;; (cl--struct-setf-expander
2345 ;; ,pos)))) 2345 ;; cl-val cl-x ',name ',accessor
2346 ;; forms) 2346 ;; ,(and pred-check `',pred-check)
2347 ;; ,pos)))
2348 ;; forms)
2349 )
2347 (if print-auto 2350 (if print-auto
2348 (nconc print-func 2351 (nconc print-func
2349 (list `(princ ,(format " %s" slot) cl-s) 2352 (list `(princ ,(format " %s" slot) cl-s)
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 18d1661e985..483ed64de20 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -371,7 +371,7 @@ Return the result of the last expression in BODY."
371 ((get-buffer-window buffer 0)) 371 ((get-buffer-window buffer 0))
372 ((one-window-p 'nomini) 372 ((one-window-p 'nomini)
373 ;; When there's one window only, split it. 373 ;; When there's one window only, split it.
374 (split-window)) 374 (split-window (minibuffer-selected-window)))
375 ((let ((trace-window (get-buffer-window edebug-trace-buffer))) 375 ((let ((trace-window (get-buffer-window edebug-trace-buffer)))
376 (catch 'found 376 (catch 'found
377 (dolist (elt (window-list nil 'nomini)) 377 (dolist (elt (window-list nil 'nomini))
@@ -382,7 +382,7 @@ Return the result of the last expression in BODY."
382 (throw 'found elt)))))) 382 (throw 'found elt))))))
383 ;; All windows are dedicated or show `edebug-trace-buffer', split 383 ;; All windows are dedicated or show `edebug-trace-buffer', split
384 ;; selected one. 384 ;; selected one.
385 (t (split-window)))) 385 (t (split-window (minibuffer-selected-window)))))
386 (set-window-buffer window buffer) 386 (set-window-buffer window buffer)
387 (select-window window) 387 (select-window window)
388 (set-window-hscroll window 0)) ;; should this be?? 388 (set-window-hscroll window 0)) ;; should this be??
diff --git a/lisp/faces.el b/lisp/faces.el
index 803b7e68fc4..08aa800c067 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -96,7 +96,7 @@ ALTERNATIVE2 etc."
96;; This is defined originally in xfaces.c. 96;; This is defined originally in xfaces.c.
97(defcustom face-font-registry-alternatives 97(defcustom face-font-registry-alternatives
98 (mapcar (lambda (arg) (mapcar 'purecopy arg)) 98 (mapcar (lambda (arg) (mapcar 'purecopy arg))
99 (if (eq system-type 'windows-nt) 99 (if (featurep 'w32)
100 '(("iso8859-1" "ms-oemlatin") 100 '(("iso8859-1" "ms-oemlatin")
101 ("gb2312.1980" "gb2312" "gbk" "gb18030") 101 ("gb2312.1980" "gb2312" "gbk" "gb18030")
102 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978") 102 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
diff --git a/lisp/ffap.el b/lisp/ffap.el
index f3e8d4c194e..4c75609fe01 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -482,18 +482,12 @@ Returned values:
482 482
483(defun ffap-replace-file-component (fullname name) 483(defun ffap-replace-file-component (fullname name)
484 "In remote FULLNAME, replace path with NAME. May return nil." 484 "In remote FULLNAME, replace path with NAME. May return nil."
485 ;; Use ange-ftp or efs if loaded, but do not load them otherwise. 485 ;; Use efs if loaded, but do not load it otherwise.
486 (let (found) 486 (if (fboundp 'efs-replace-path-component)
487 (mapc 487 (funcall efs-replace-path-component fullname name)
488 (function (lambda (sym) (and (fboundp sym) (setq found sym)))) 488 (and (stringp fullname)
489 '( 489 (stringp name)
490 efs-replace-path-component 490 (concat (file-remote-p fullname) name))))
491 ange-ftp-replace-path-component
492 ange-ftp-replace-name-component
493 ))
494 (and found
495 (fset 'ffap-replace-file-component found)
496 (funcall found fullname name))))
497;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new") 491;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new")
498 492
499(defun ffap-file-suffix (file) 493(defun ffap-file-suffix (file)
diff --git a/lisp/frame.el b/lisp/frame.el
index 0bef358ecfb..b7b61bcc576 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -25,6 +25,8 @@
25;;; Commentary: 25;;; Commentary:
26 26
27;;; Code: 27;;; Code:
28(eval-when-compile (require 'cl-lib))
29
28(defvar frame-creation-function-alist 30(defvar frame-creation-function-alist
29 (list (cons nil 31 (list (cons nil
30 (if (fboundp 'tty-create-frame-with-faces) 32 (if (fboundp 'tty-create-frame-with-faces)
@@ -45,6 +47,12 @@ Then, for frames on WINDOW-SYSTEM, any parameters specified in
45ALIST supersede the corresponding parameters specified in 47ALIST supersede the corresponding parameters specified in
46`default-frame-alist'.") 48`default-frame-alist'.")
47 49
50(defvar display-format-alist nil
51 "Alist of patterns to decode display names.
52The car of each entry is a regular expression matching a display
53name string. The cdr is a symbol giving the window-system that
54handles the corresponding kind of display.")
55
48;; The initial value given here used to ask for a minibuffer. 56;; The initial value given here used to ask for a minibuffer.
49;; But that's not necessary, because the default is to have one. 57;; But that's not necessary, because the default is to have one.
50;; By not specifying it here, we let an X resource specify it. 58;; By not specifying it here, we let an X resource specify it.
@@ -510,31 +518,19 @@ is not considered (see `next-frame')."
510 0)) 518 0))
511 (select-frame-set-input-focus (selected-frame))) 519 (select-frame-set-input-focus (selected-frame)))
512 520
513(declare-function x-initialize-window-system "term/x-win" ()) 521(defun window-system-for-display (display)
514(declare-function ns-initialize-window-system "term/ns-win" ()) 522 "Return the window system for DISPLAY.
515(defvar x-display-name) ; term/x-win 523Return nil if we don't know how to interpret DISPLAY."
524 (cl-loop for descriptor in display-format-alist
525 for pattern = (car descriptor)
526 for system = (cdr descriptor)
527 when (string-match-p pattern display) return system))
516 528
517(defun make-frame-on-display (display &optional parameters) 529(defun make-frame-on-display (display &optional parameters)
518 "Make a frame on display DISPLAY. 530 "Make a frame on display DISPLAY.
519The optional argument PARAMETERS specifies additional frame parameters." 531The optional argument PARAMETERS specifies additional frame parameters."
520 (interactive "sMake frame on display: ") 532 (interactive "sMake frame on display: ")
521 (cond ((featurep 'ns) 533 (make-frame (cons (cons 'display display) parameters)))
522 (when (and (boundp 'ns-initialized) (not ns-initialized))
523 (setq x-display-name display)
524 (ns-initialize-window-system))
525 (make-frame `((window-system . ns)
526 (display . ,display) . ,parameters)))
527 ((eq system-type 'windows-nt)
528 ;; On Windows, ignore DISPLAY.
529 (make-frame parameters))
530 (t
531 (unless (string-match-p "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
532 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
533 (when (and (boundp 'x-initialized) (not x-initialized))
534 (setq x-display-name display)
535 (x-initialize-window-system))
536 (make-frame `((window-system . x)
537 (display . ,display) . ,parameters)))))
538 534
539(declare-function x-close-connection "xfns.c" (terminal)) 535(declare-function x-close-connection "xfns.c" (terminal))
540 536
@@ -616,6 +612,8 @@ neither or both.
616 (window-system . nil) The frame should be displayed on a terminal device. 612 (window-system . nil) The frame should be displayed on a terminal device.
617 (window-system . x) The frame should be displayed in an X window. 613 (window-system . x) The frame should be displayed in an X window.
618 614
615 (display . \":0\") The frame should appear on display :0.
616
619 (terminal . TERMINAL) The frame should use the terminal object TERMINAL. 617 (terminal . TERMINAL) The frame should use the terminal object TERMINAL.
620 618
621In addition, any parameter specified in `default-frame-alist', 619In addition, any parameter specified in `default-frame-alist',
@@ -626,11 +624,15 @@ this function runs the hook `before-make-frame-hook'. After
626creating the frame, it runs the hook `after-make-frame-functions' 624creating the frame, it runs the hook `after-make-frame-functions'
627with one arg, the newly created frame. 625with one arg, the newly created frame.
628 626
627If a display parameter is supplied and a window-system is not,
628guess the window-system from the display.
629
629On graphical displays, this function does not itself make the new 630On graphical displays, this function does not itself make the new
630frame the selected frame. However, the window system may select 631frame the selected frame. However, the window system may select
631the new frame according to its own rules." 632the new frame according to its own rules."
632 (interactive) 633 (interactive)
633 (let* ((w (cond 634 (let* ((display (cdr (assq 'display parameters)))
635 (w (cond
634 ((assq 'terminal parameters) 636 ((assq 'terminal parameters)
635 (let ((type (terminal-live-p (cdr (assq 'terminal parameters))))) 637 (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
636 (cond 638 (cond
@@ -640,6 +642,10 @@ the new frame according to its own rules."
640 (t type)))) 642 (t type))))
641 ((assq 'window-system parameters) 643 ((assq 'window-system parameters)
642 (cdr (assq 'window-system parameters))) 644 (cdr (assq 'window-system parameters)))
645 (display
646 (or (window-system-for-display display)
647 (error "Don't know how to interpret display \"%S\""
648 display)))
643 (t window-system))) 649 (t window-system)))
644 (frame-creation-function (cdr (assq w frame-creation-function-alist))) 650 (frame-creation-function (cdr (assq w frame-creation-function-alist)))
645 (oldframe (selected-frame)) 651 (oldframe (selected-frame))
@@ -647,6 +653,11 @@ the new frame according to its own rules."
647 frame) 653 frame)
648 (unless frame-creation-function 654 (unless frame-creation-function
649 (error "Don't know how to create a frame on window system %s" w)) 655 (error "Don't know how to create a frame on window system %s" w))
656
657 (unless (get w 'window-system-initialized)
658 (funcall (cdr (assq w window-system-initialization-alist)))
659 (put w 'window-system-initialized t))
660
650 ;; Add parameters from `window-system-default-frame-alist'. 661 ;; Add parameters from `window-system-default-frame-alist'.
651 (dolist (p (cdr (assq w window-system-default-frame-alist))) 662 (dolist (p (cdr (assq w window-system-default-frame-alist)))
652 (unless (assq (car p) params) 663 (unless (assq (car p) params)
@@ -1260,7 +1271,7 @@ frame's display)."
1260 (cond 1271 (cond
1261 ((eq frame-type 'pc) 1272 ((eq frame-type 'pc)
1262 (msdos-mouse-p)) 1273 (msdos-mouse-p))
1263 ((eq system-type 'windows-nt) 1274 ((eq frame-type 'w32)
1264 (with-no-warnings 1275 (with-no-warnings
1265 (> w32-num-mouse-buttons 0))) 1276 (> w32-num-mouse-buttons 0)))
1266 ((memq frame-type '(x ns)) 1277 ((memq frame-type '(x ns))
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index ce1599b9010..878021ec5c5 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -646,83 +646,10 @@ like an INI file. You can add this hook to `find-file-hook'."
646 "Generic mode for Sys V pkginfo files.")) 646 "Generic mode for Sys V pkginfo files."))
647 647
648;; Javascript mode 648;; Javascript mode
649;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU] 649;; Obsolete; defer to js-mode from js.el.
650(when (memq 'javascript-generic-mode generic-extras-enable-list) 650(when (memq 'javascript-generic-mode generic-extras-enable-list)
651 651 (define-obsolete-function-alias 'javascript-generic-mode 'js-mode "24.3")
652(define-generic-mode javascript-generic-mode 652 (define-obsolete-variable-alias 'javascript-generic-mode-hook 'js-mode-hook "24.3"))
653 '("//" ("/*" . "*/"))
654 '("break"
655 "case"
656 "continue"
657 "default"
658 "delete"
659 "do"
660 "else"
661 "export"
662 "for"
663 "function"
664 "if"
665 "import"
666 "in"
667 "new"
668 "return"
669 "switch"
670 "this"
671 "typeof"
672 "var"
673 "void"
674 "while"
675 "with"
676 ;; words reserved for ECMA extensions below
677 "catch"
678 "class"
679 "const"
680 "debugger"
681 "enum"
682 "extends"
683 "finally"
684 "super"
685 "throw"
686 "try"
687 ;; Java Keywords reserved by JavaScript
688 "abstract"
689 "boolean"
690 "byte"
691 "char"
692 "double"
693 "false"
694 "final"
695 "float"
696 "goto"
697 "implements"
698 "instanceof"
699 "int"
700 "interface"
701 "long"
702 "native"
703 "null"
704 "package"
705 "private"
706 "protected"
707 "public"
708 "short"
709 "static"
710 "synchronized"
711 "throws"
712 "transient"
713 "true")
714 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
715 (1 font-lock-function-name-face))
716 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
717 (1 font-lock-variable-name-face)))
718 '("\\.js\\'")
719 (list
720 (function
721 (lambda ()
722 (setq imenu-generic-expression
723 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
724 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
725 "Generic mode for JavaScript files."))
726 653
727;; VRML files 654;; VRML files
728(when (memq 'vrml-generic-mode generic-extras-enable-list) 655(when (memq 'vrml-generic-mode generic-extras-enable-list)
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index f79353ebfb3..c6b2a4c37a7 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
12012-10-09 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * shr.el (shr-insert): \r is also not inserted, so don't try to delete
4 it.
5
12012-10-06 Glenn Morris <rgm@gnu.org> 62012-10-06 Glenn Morris <rgm@gnu.org>
2 7
3 * gnus-notifications.el (gnus-notifications): 8 * gnus-notifications.el (gnus-notifications):
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index e7a6c5d2081..03704554459 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -391,7 +391,7 @@ size, and full-buffer size."
391 (shr-indent)) 391 (shr-indent))
392 (end-of-line)) 392 (end-of-line))
393 (insert " "))) 393 (insert " ")))
394 (unless (string-match "[ \t\n ]\\'" text) 394 (unless (string-match "[ \t\r\n ]\\'" text)
395 (delete-char -1))))) 395 (delete-char -1)))))
396 396
397(defun shr-find-fill-point () 397(defun shr-find-fill-point ()
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index a32c69a691e..58dd24ec8ea 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2670,7 +2670,8 @@ See also `locale-charset-language-names', `locale-language-names',
2670 ;; On Windows, override locale-coding-system, 2670 ;; On Windows, override locale-coding-system,
2671 ;; default-file-name-coding-system, keyboard-coding-system, 2671 ;; default-file-name-coding-system, keyboard-coding-system,
2672 ;; terminal-coding-system with system codepage. 2672 ;; terminal-coding-system with system codepage.
2673 (when (boundp 'w32-ansi-code-page) 2673 (when (and (eq system-type 'windows-nt)
2674 (boundp 'w32-ansi-code-page))
2674 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page)))) 2675 (let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
2675 (when (coding-system-p code-page-coding) 2676 (when (coding-system-p code-page-coding)
2676 (unless frame (setq locale-coding-system code-page-coding)) 2677 (unless frame (setq locale-coding-system code-page-coding))
diff --git a/lisp/loadup.el b/lisp/loadup.el
index d389427bafd..e0f5c6265b9 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -237,15 +237,18 @@
237 (load "term/common-win") 237 (load "term/common-win")
238 (load "term/x-win"))) 238 (load "term/x-win")))
239 239
240(if (eq system-type 'windows-nt) 240(if (or (eq system-type 'windows-nt)
241 (featurep 'w32))
241 (progn 242 (progn
242 (load "w32-vars")
243 (load "term/common-win") 243 (load "term/common-win")
244 (load "w32-vars")
244 (load "term/w32-win") 245 (load "term/w32-win")
245 (load "ls-lisp")
246 (load "disp-table") 246 (load "disp-table")
247 (load "dos-w32") 247 (load "w32-common-fns")
248 (load "w32-fns"))) 248 (when (eq system-type 'windows-nt)
249 (load "w32-fns")
250 (load "ls-lisp")
251 (load "dos-w32"))))
249(if (eq system-type 'ms-dos) 252(if (eq system-type 'ms-dos)
250 (progn 253 (progn
251 (load "dos-w32") 254 (load "dos-w32")
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 74bb97b3086..fa5c69281de 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1151,7 +1151,7 @@ regardless of where you click."
1151 (or mouse-yank-at-point (mouse-set-point click)) 1151 (or mouse-yank-at-point (mouse-set-point click))
1152 (let ((primary 1152 (let ((primary
1153 (cond 1153 (cond
1154 ((eq system-type 'windows-nt) 1154 ((eq (framep (selected-frame)) 'w32)
1155 ;; MS-Windows emulates PRIMARY in x-get-selection, but not 1155 ;; MS-Windows emulates PRIMARY in x-get-selection, but not
1156 ;; in x-get-selection-value (the latter only accesses the 1156 ;; in x-get-selection-value (the latter only accesses the
1157 ;; clipboard). So try PRIMARY first, in case they selected 1157 ;; clipboard). So try PRIMARY first, in case they selected
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index fe5eb0049d0..e4fca46ce2d 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -139,27 +139,6 @@ Returns VALUE."
139 value)) 139 value))
140 140
141;;;###tramp-autoload 141;;;###tramp-autoload
142(defmacro with-file-property (vec file property &rest body)
143 "Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache.
144FILE must be a local file name on a connection identified via VEC."
145 `(if (file-name-absolute-p ,file)
146 (let ((value (tramp-get-file-property ,vec ,file ,property 'undef)))
147 (when (eq value 'undef)
148 ;; We cannot pass @body as parameter to
149 ;; `tramp-set-file-property' because it mangles our
150 ;; debug messages.
151 (setq value (progn ,@body))
152 (tramp-set-file-property ,vec ,file ,property value))
153 value)
154 ,@body))
155
156;;;###tramp-autoload
157(put 'with-file-property 'lisp-indent-function 3)
158(put 'with-file-property 'edebug-form-spec t)
159(tramp-compat-font-lock-add-keywords
160 'emacs-lisp-mode '("\\<with-file-property\\>"))
161
162;;;###tramp-autoload
163(defun tramp-flush-file-property (vec file) 142(defun tramp-flush-file-property (vec file)
164 "Remove all properties of FILE in the cache context of VEC." 143 "Remove all properties of FILE in the cache context of VEC."
165 ;; Remove file property of symlinks. 144 ;; Remove file property of symlinks.
@@ -250,24 +229,6 @@ PROPERTY is set persistent when KEY is a vector."
250 value)) 229 value))
251 230
252;;;###tramp-autoload 231;;;###tramp-autoload
253(defmacro with-connection-property (key property &rest body)
254 "Check in Tramp for property PROPERTY, otherwise executes BODY and set."
255 `(let ((value (tramp-get-connection-property ,key ,property 'undef)))
256 (when (eq value 'undef)
257 ;; We cannot pass ,@body as parameter to
258 ;; `tramp-set-connection-property' because it mangles our debug
259 ;; messages.
260 (setq value (progn ,@body))
261 (tramp-set-connection-property ,key ,property value))
262 value))
263
264;;;###tramp-autoload
265(put 'with-connection-property 'lisp-indent-function 2)
266(put 'with-connection-property 'edebug-form-spec t)
267(tramp-compat-font-lock-add-keywords
268 'emacs-lisp-mode '("\\<with-connection-property\\>"))
269
270;;;###tramp-autoload
271(defun tramp-flush-connection-property (key) 232(defun tramp-flush-connection-property (key)
272 "Remove all properties identified by KEY. 233 "Remove all properties identified by KEY.
273KEY identifies the connection, it is either a process or a vector." 234KEY identifies the connection, it is either a process or a vector."
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index f78122ec704..60b39606d86 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -537,7 +537,7 @@ is no information where to trace the message.")
537 "Like `copy-file' for Tramp files." 537 "Like `copy-file' for Tramp files."
538 (with-parsed-tramp-file-name 538 (with-parsed-tramp-file-name
539 (if (tramp-tramp-file-p filename) filename newname) nil 539 (if (tramp-tramp-file-p filename) filename newname) nil
540 (tramp-with-progress-reporter 540 (with-tramp-progress-reporter
541 v 0 (format "Copying %s to %s" filename newname) 541 v 0 (format "Copying %s to %s" filename newname)
542 (condition-case err 542 (condition-case err
543 (let ((args 543 (let ((args
@@ -741,7 +741,7 @@ is no information where to trace the message.")
741 "Like `rename-file' for Tramp files." 741 "Like `rename-file' for Tramp files."
742 (with-parsed-tramp-file-name 742 (with-parsed-tramp-file-name
743 (if (tramp-tramp-file-p filename) filename newname) nil 743 (if (tramp-tramp-file-p filename) filename newname) nil
744 (tramp-with-progress-reporter 744 (with-tramp-progress-reporter
745 v 0 (format "Renaming %s to %s" filename newname) 745 v 0 (format "Renaming %s to %s" filename newname)
746 (condition-case err 746 (condition-case err
747 (rename-file 747 (rename-file
@@ -1056,7 +1056,7 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
1056 (catch 'mounted 1056 (catch 'mounted
1057 (dolist 1057 (dolist
1058 (elt 1058 (elt
1059 (with-file-property vec "/" "list-mounts" 1059 (with-tramp-file-property vec "/" "list-mounts"
1060 (with-tramp-dbus-call-method vec t 1060 (with-tramp-dbus-call-method vec t
1061 :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker 1061 :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
1062 tramp-gvfs-interface-mounttracker "listMounts")) 1062 tramp-gvfs-interface-mounttracker "listMounts"))
@@ -1199,7 +1199,7 @@ connection if a previous connection has died for some reason."
1199 (tramp-gvfs-object-path 1199 (tramp-gvfs-object-path
1200 (tramp-make-tramp-file-name method user host "")))) 1200 (tramp-make-tramp-file-name method user host ""))))
1201 1201
1202 (tramp-with-progress-reporter 1202 (with-tramp-progress-reporter
1203 vec 3 1203 vec 3
1204 (if (zerop (length user)) 1204 (if (zerop (length user))
1205 (format "Opening connection for %s using %s" host method) 1205 (format "Opening connection for %s using %s" host method)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 2c1af3e83fa..ec321d00506 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1058,7 +1058,7 @@ target of the symlink differ."
1058 "Like `file-truename' for Tramp files." 1058 "Like `file-truename' for Tramp files."
1059 (with-parsed-tramp-file-name (expand-file-name filename) nil 1059 (with-parsed-tramp-file-name (expand-file-name filename) nil
1060 (tramp-make-tramp-file-name method user host 1060 (tramp-make-tramp-file-name method user host
1061 (with-file-property v localname "file-truename" 1061 (with-tramp-file-property v localname "file-truename"
1062 (let ((result nil)) ; result steps in reverse order 1062 (let ((result nil)) ; result steps in reverse order
1063 (tramp-message v 4 "Finding true name for `%s'" filename) 1063 (tramp-message v 4 "Finding true name for `%s'" filename)
1064 (cond 1064 (cond
@@ -1167,7 +1167,7 @@ target of the symlink differ."
1167(defun tramp-sh-handle-file-exists-p (filename) 1167(defun tramp-sh-handle-file-exists-p (filename)
1168 "Like `file-exists-p' for Tramp files." 1168 "Like `file-exists-p' for Tramp files."
1169 (with-parsed-tramp-file-name filename nil 1169 (with-parsed-tramp-file-name filename nil
1170 (with-file-property v localname "file-exists-p" 1170 (with-tramp-file-property v localname "file-exists-p"
1171 (or (not (null (tramp-get-file-property 1171 (or (not (null (tramp-get-file-property
1172 v localname "file-attributes-integer" nil))) 1172 v localname "file-attributes-integer" nil)))
1173 (not (null (tramp-get-file-property 1173 (not (null (tramp-get-file-property
@@ -1185,7 +1185,8 @@ target of the symlink differ."
1185 ;; Don't modify `last-coding-system-used' by accident. 1185 ;; Don't modify `last-coding-system-used' by accident.
1186 (let ((last-coding-system-used last-coding-system-used)) 1186 (let ((last-coding-system-used last-coding-system-used))
1187 (with-parsed-tramp-file-name (expand-file-name filename) nil 1187 (with-parsed-tramp-file-name (expand-file-name filename) nil
1188 (with-file-property v localname (format "file-attributes-%s" id-format) 1188 (with-tramp-file-property
1189 v localname (format "file-attributes-%s" id-format)
1189 (save-excursion 1190 (save-excursion
1190 (tramp-convert-file-attributes 1191 (tramp-convert-file-attributes
1191 v 1192 v
@@ -1481,7 +1482,8 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1481 1482
1482(defun tramp-remote-selinux-p (vec) 1483(defun tramp-remote-selinux-p (vec)
1483 "Check, whether SELINUX is enabled on the remote host." 1484 "Check, whether SELINUX is enabled on the remote host."
1484 (with-connection-property (tramp-get-connection-process vec) "selinux-p" 1485 (with-tramp-connection-property
1486 (tramp-get-connection-process vec) "selinux-p"
1485 (let ((result (tramp-find-executable 1487 (let ((result (tramp-find-executable
1486 vec "getenforce" (tramp-get-remote-path vec) t t))) 1488 vec "getenforce" (tramp-get-remote-path vec) t t)))
1487 (and result 1489 (and result
@@ -1493,7 +1495,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1493(defun tramp-sh-handle-file-selinux-context (filename) 1495(defun tramp-sh-handle-file-selinux-context (filename)
1494 "Like `file-selinux-context' for Tramp files." 1496 "Like `file-selinux-context' for Tramp files."
1495 (with-parsed-tramp-file-name filename nil 1497 (with-parsed-tramp-file-name filename nil
1496 (with-file-property v localname "file-selinux-context" 1498 (with-tramp-file-property v localname "file-selinux-context"
1497 (let ((context '(nil nil nil nil)) 1499 (let ((context '(nil nil nil nil))
1498 (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):" 1500 (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
1499 "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)"))) 1501 "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)")))
@@ -1537,7 +1539,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1537(defun tramp-sh-handle-file-executable-p (filename) 1539(defun tramp-sh-handle-file-executable-p (filename)
1538 "Like `file-executable-p' for Tramp files." 1540 "Like `file-executable-p' for Tramp files."
1539 (with-parsed-tramp-file-name filename nil 1541 (with-parsed-tramp-file-name filename nil
1540 (with-file-property v localname "file-executable-p" 1542 (with-tramp-file-property v localname "file-executable-p"
1541 ;; Examine `file-attributes' cache to see if request can be 1543 ;; Examine `file-attributes' cache to see if request can be
1542 ;; satisfied without remote operation. 1544 ;; satisfied without remote operation.
1543 (or (tramp-check-cached-permissions v ?x) 1545 (or (tramp-check-cached-permissions v ?x)
@@ -1546,7 +1548,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1546(defun tramp-sh-handle-file-readable-p (filename) 1548(defun tramp-sh-handle-file-readable-p (filename)
1547 "Like `file-readable-p' for Tramp files." 1549 "Like `file-readable-p' for Tramp files."
1548 (with-parsed-tramp-file-name filename nil 1550 (with-parsed-tramp-file-name filename nil
1549 (with-file-property v localname "file-readable-p" 1551 (with-tramp-file-property v localname "file-readable-p"
1550 ;; Examine `file-attributes' cache to see if request can be 1552 ;; Examine `file-attributes' cache to see if request can be
1551 ;; satisfied without remote operation. 1553 ;; satisfied without remote operation.
1552 (or (tramp-check-cached-permissions v ?r) 1554 (or (tramp-check-cached-permissions v ?r)
@@ -1600,13 +1602,13 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1600 ;; desirable to return t immediately for "/method:foo:". It can 1602 ;; desirable to return t immediately for "/method:foo:". It can
1601 ;; be expected that this is always a directory. 1603 ;; be expected that this is always a directory.
1602 (or (zerop (length localname)) 1604 (or (zerop (length localname))
1603 (with-file-property v localname "file-directory-p" 1605 (with-tramp-file-property v localname "file-directory-p"
1604 (tramp-run-test "-d" filename))))) 1606 (tramp-run-test "-d" filename)))))
1605 1607
1606(defun tramp-sh-handle-file-writable-p (filename) 1608(defun tramp-sh-handle-file-writable-p (filename)
1607 "Like `file-writable-p' for Tramp files." 1609 "Like `file-writable-p' for Tramp files."
1608 (with-parsed-tramp-file-name filename nil 1610 (with-parsed-tramp-file-name filename nil
1609 (with-file-property v localname "file-writable-p" 1611 (with-tramp-file-property v localname "file-writable-p"
1610 (if (file-exists-p filename) 1612 (if (file-exists-p filename)
1611 ;; Examine `file-attributes' cache to see if request can be 1613 ;; Examine `file-attributes' cache to see if request can be
1612 ;; satisfied without remote operation. 1614 ;; satisfied without remote operation.
@@ -1619,7 +1621,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1619(defun tramp-sh-handle-file-ownership-preserved-p (filename) 1621(defun tramp-sh-handle-file-ownership-preserved-p (filename)
1620 "Like `file-ownership-preserved-p' for Tramp files." 1622 "Like `file-ownership-preserved-p' for Tramp files."
1621 (with-parsed-tramp-file-name filename nil 1623 (with-parsed-tramp-file-name filename nil
1622 (with-file-property v localname "file-ownership-preserved-p" 1624 (with-tramp-file-property v localname "file-ownership-preserved-p"
1623 (let ((attributes (file-attributes filename))) 1625 (let ((attributes (file-attributes filename)))
1624 ;; Return t if the file doesn't exist, since it's true that no 1626 ;; Return t if the file doesn't exist, since it's true that no
1625 ;; information would be lost by an (attempted) delete and create. 1627 ;; information would be lost by an (attempted) delete and create.
@@ -1637,7 +1639,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1637 (let* ((temp 1639 (let* ((temp
1638 (copy-tree 1640 (copy-tree
1639 (with-parsed-tramp-file-name directory nil 1641 (with-parsed-tramp-file-name directory nil
1640 (with-file-property 1642 (with-tramp-file-property
1641 v localname 1643 v localname
1642 (format "directory-files-and-attributes-%s" id-format) 1644 (format "directory-files-and-attributes-%s" id-format)
1643 (save-excursion 1645 (save-excursion
@@ -1987,7 +1989,7 @@ file names."
1987 (tramp-error 1989 (tramp-error
1988 v 'file-already-exists "File %s already exists" newname)) 1990 v 'file-already-exists "File %s already exists" newname))
1989 1991
1990 (tramp-with-progress-reporter 1992 (with-tramp-progress-reporter
1991 v 0 (format "%s %s to %s" 1993 v 0 (format "%s %s to %s"
1992 (if (eq op 'copy) "Copying" "Renaming") 1994 (if (eq op 'copy) "Copying" "Renaming")
1993 filename newname) 1995 filename newname)
@@ -2505,7 +2507,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
2505 nil) 2507 nil)
2506 ((and suffix (nth 2 suffix)) 2508 ((and suffix (nth 2 suffix))
2507 ;; We found an uncompression rule. 2509 ;; We found an uncompression rule.
2508 (tramp-with-progress-reporter 2510 (with-tramp-progress-reporter
2509 v 0 (format "Uncompressing %s" file) 2511 v 0 (format "Uncompressing %s" file)
2510 (when (tramp-send-command-and-check 2512 (when (tramp-send-command-and-check
2511 v (concat (nth 2 suffix) " " 2513 v (concat (nth 2 suffix) " "
@@ -2517,7 +2519,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
2517 (t 2519 (t
2518 ;; We don't recognize the file as compressed, so compress it. 2520 ;; We don't recognize the file as compressed, so compress it.
2519 ;; Try gzip. 2521 ;; Try gzip.
2520 (tramp-with-progress-reporter v 0 (format "Compressing %s" file) 2522 (with-tramp-progress-reporter v 0 (format "Compressing %s" file)
2521 (when (tramp-send-command-and-check 2523 (when (tramp-send-command-and-check
2522 v (concat "gzip -f " 2524 v (concat "gzip -f "
2523 (tramp-shell-quote-argument localname))) 2525 (tramp-shell-quote-argument localname)))
@@ -2673,7 +2675,7 @@ the result will be a local, non-Tramp, filename."
2673 (string-match "\\`su\\(do\\)?\\'" method)) 2675 (string-match "\\`su\\(do\\)?\\'" method))
2674 (setq uname (concat uname user))) 2676 (setq uname (concat uname user)))
2675 (setq uname 2677 (setq uname
2676 (with-connection-property v uname 2678 (with-tramp-connection-property v uname
2677 (tramp-send-command 2679 (tramp-send-command
2678 v (format "cd %s; pwd" (tramp-shell-quote-argument uname))) 2680 v (format "cd %s; pwd" (tramp-shell-quote-argument uname)))
2679 (with-current-buffer (tramp-get-buffer v) 2681 (with-current-buffer (tramp-get-buffer v)
@@ -2943,7 +2945,7 @@ the result will be a local, non-Tramp, filename."
2943 ;; Use inline encoding for file transfer. 2945 ;; Use inline encoding for file transfer.
2944 (rem-enc 2946 (rem-enc
2945 (save-excursion 2947 (save-excursion
2946 (tramp-with-progress-reporter 2948 (with-tramp-progress-reporter
2947 v 3 (format "Encoding remote file %s" filename) 2949 v 3 (format "Encoding remote file %s" filename)
2948 (tramp-barf-unless-okay 2950 (tramp-barf-unless-okay
2949 v (format rem-enc (tramp-shell-quote-argument localname)) 2951 v (format rem-enc (tramp-shell-quote-argument localname))
@@ -2957,7 +2959,7 @@ the result will be a local, non-Tramp, filename."
2957 (with-temp-buffer 2959 (with-temp-buffer
2958 (set-buffer-multibyte nil) 2960 (set-buffer-multibyte nil)
2959 (insert-buffer-substring (tramp-get-buffer v)) 2961 (insert-buffer-substring (tramp-get-buffer v))
2960 (tramp-with-progress-reporter 2962 (with-tramp-progress-reporter
2961 v 3 (format "Decoding remote file %s with function %s" 2963 v 3 (format "Decoding remote file %s with function %s"
2962 filename loc-dec) 2964 filename loc-dec)
2963 (funcall loc-dec (point-min) (point-max)) 2965 (funcall loc-dec (point-min) (point-max))
@@ -2975,7 +2977,7 @@ the result will be a local, non-Tramp, filename."
2975 (let (file-name-handler-alist 2977 (let (file-name-handler-alist
2976 (coding-system-for-write 'binary)) 2978 (coding-system-for-write 'binary))
2977 (write-region (point-min) (point-max) tmpfile2)) 2979 (write-region (point-min) (point-max) tmpfile2))
2978 (tramp-with-progress-reporter 2980 (with-tramp-progress-reporter
2979 v 3 (format "Decoding remote file %s with command %s" 2981 v 3 (format "Decoding remote file %s with command %s"
2980 filename loc-dec) 2982 filename loc-dec)
2981 (unwind-protect 2983 (unwind-protect
@@ -3203,7 +3205,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3203 (set-buffer-multibyte nil) 3205 (set-buffer-multibyte nil)
3204 ;; Use encoding function or command. 3206 ;; Use encoding function or command.
3205 (if (functionp loc-enc) 3207 (if (functionp loc-enc)
3206 (tramp-with-progress-reporter 3208 (with-tramp-progress-reporter
3207 v 3 (format "Encoding region using function `%s'" 3209 v 3 (format "Encoding region using function `%s'"
3208 loc-enc) 3210 loc-enc)
3209 (let ((coding-system-for-read 'binary)) 3211 (let ((coding-system-for-read 'binary))
@@ -3221,7 +3223,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3221 (tramp-compat-temporary-file-directory))) 3223 (tramp-compat-temporary-file-directory)))
3222 (funcall loc-enc (point-min) (point-max)))) 3224 (funcall loc-enc (point-min) (point-max))))
3223 3225
3224 (tramp-with-progress-reporter 3226 (with-tramp-progress-reporter
3225 v 3 (format "Encoding region using command `%s'" 3227 v 3 (format "Encoding region using command `%s'"
3226 loc-enc) 3228 loc-enc)
3227 (unless (zerop (tramp-call-local-coding-command 3229 (unless (zerop (tramp-call-local-coding-command
@@ -3235,7 +3237,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3235 ;; Send buffer into remote decoding command which 3237 ;; Send buffer into remote decoding command which
3236 ;; writes to remote file. Because this happens on 3238 ;; writes to remote file. Because this happens on
3237 ;; the remote host, we cannot use the function. 3239 ;; the remote host, we cannot use the function.
3238 (tramp-with-progress-reporter 3240 (with-tramp-progress-reporter
3239 v 3 3241 v 3
3240 (format "Decoding region into remote file %s" filename) 3242 (format "Decoding region into remote file %s" filename)
3241 (goto-char (point-max)) 3243 (goto-char (point-max))
@@ -3335,7 +3337,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3335 "Like `vc-registered' for Tramp files." 3337 "Like `vc-registered' for Tramp files."
3336 (tramp-compat-with-temp-message "" 3338 (tramp-compat-with-temp-message ""
3337 (with-parsed-tramp-file-name file nil 3339 (with-parsed-tramp-file-name file nil
3338 (tramp-with-progress-reporter 3340 (with-tramp-progress-reporter
3339 v 3 (format "Checking `vc-registered' for %s" file) 3341 v 3 (format "Checking `vc-registered' for %s" file)
3340 3342
3341 ;; There could be new files, created by the vc backend. We 3343 ;; There could be new files, created by the vc backend. We
@@ -3433,7 +3435,7 @@ Only send the definition if it has not already been done."
3433 (let ((scripts (tramp-get-connection-property 3435 (let ((scripts (tramp-get-connection-property
3434 (tramp-get-connection-process vec) "scripts" nil))) 3436 (tramp-get-connection-process vec) "scripts" nil)))
3435 (unless (member name scripts) 3437 (unless (member name scripts)
3436 (tramp-with-progress-reporter vec 5 (format "Sending script `%s'" name) 3438 (with-tramp-progress-reporter vec 5 (format "Sending script `%s'" name)
3437 ;; The script could contain a call of Perl. This is masked with `%s'. 3439 ;; The script could contain a call of Perl. This is masked with `%s'.
3438 (tramp-barf-unless-okay 3440 (tramp-barf-unless-okay
3439 vec 3441 vec
@@ -3602,7 +3604,7 @@ file exists and nonzero exit status otherwise."
3602 3604
3603(defun tramp-open-shell (vec shell) 3605(defun tramp-open-shell (vec shell)
3604 "Opens shell SHELL." 3606 "Opens shell SHELL."
3605 (tramp-with-progress-reporter 3607 (with-tramp-progress-reporter
3606 vec 5 (format "Opening remote shell `%s'" shell) 3608 vec 5 (format "Opening remote shell `%s'" shell)
3607 ;; Find arguments for this shell. 3609 ;; Find arguments for this shell.
3608 (let ((tramp-end-of-output tramp-initial-end-of-output) 3610 (let ((tramp-end-of-output tramp-initial-end-of-output)
@@ -3638,7 +3640,7 @@ file exists and nonzero exit status otherwise."
3638 (tramp-file-name-method vec) 'tramp-remote-shell))) 3640 (tramp-file-name-method vec) 'tramp-remote-shell)))
3639 shell) 3641 shell)
3640 (setq shell 3642 (setq shell
3641 (with-connection-property vec "remote-shell" 3643 (with-tramp-connection-property vec "remote-shell"
3642 ;; CCC: "root" does not exist always, see QNAP 459. 3644 ;; CCC: "root" does not exist always, see QNAP 459.
3643 ;; Which check could we apply instead? 3645 ;; Which check could we apply instead?
3644 (tramp-send-command vec "echo ~root" t) 3646 (tramp-send-command vec "echo ~root" t)
@@ -3673,7 +3675,7 @@ file exists and nonzero exit status otherwise."
3673 (tramp-open-shell vec shell)) 3675 (tramp-open-shell vec shell))
3674 3676
3675 ;; Busyboxes tend to behave strange. We check for the existence. 3677 ;; Busyboxes tend to behave strange. We check for the existence.
3676 (with-connection-property vec "busybox" 3678 (with-tramp-connection-property vec "busybox"
3677 (tramp-send-command vec (format "%s --version" shell) t) 3679 (tramp-send-command vec (format "%s --version" shell) t)
3678 (let ((case-fold-search t)) 3680 (let ((case-fold-search t))
3679 (and (string-match "busybox" (buffer-string)) t)))))) 3681 (and (string-match "busybox" (buffer-string)) t))))))
@@ -3798,7 +3800,7 @@ process to set up. VEC specifies the connection."
3798 ;; successfully, sending 625 bytes failed. Emacs makes a hack when 3800 ;; successfully, sending 625 bytes failed. Emacs makes a hack when
3799 ;; this host type is detected locally. It cannot handle remote 3801 ;; this host type is detected locally. It cannot handle remote
3800 ;; hosts, though. 3802 ;; hosts, though.
3801 (with-connection-property proc "chunksize" 3803 (with-tramp-connection-property proc "chunksize"
3802 (cond 3804 (cond
3803 ((and (integerp tramp-chunksize) (> tramp-chunksize 0)) 3805 ((and (integerp tramp-chunksize) (> tramp-chunksize 0))
3804 tramp-chunksize) 3806 tramp-chunksize)
@@ -4327,7 +4329,7 @@ connection if a previous connection has died for some reason."
4327 (when (and (boundp 'non-essential) (symbol-value 'non-essential)) 4329 (when (and (boundp 'non-essential) (symbol-value 'non-essential))
4328 (throw 'non-essential 'non-essential)) 4330 (throw 'non-essential 'non-essential))
4329 4331
4330 (tramp-with-progress-reporter 4332 (with-tramp-progress-reporter
4331 vec 3 4333 vec 3
4332 (if (zerop (length (tramp-file-name-user vec))) 4334 (if (zerop (length (tramp-file-name-user vec)))
4333 (format "Opening connection for %s using %s" 4335 (format "Opening connection for %s using %s"
@@ -4773,7 +4775,7 @@ This is used internally by `tramp-file-mode-from-int'."
4773;; Variables local to connection. 4775;; Variables local to connection.
4774 4776
4775(defun tramp-get-remote-path (vec) 4777(defun tramp-get-remote-path (vec)
4776 (with-connection-property 4778 (with-tramp-connection-property
4777 ;; When `tramp-own-remote-path' is in `tramp-remote-path', we 4779 ;; When `tramp-own-remote-path' is in `tramp-remote-path', we
4778 ;; cache the result for the session only. Otherwise, the result 4780 ;; cache the result for the session only. Otherwise, the result
4779 ;; is cached persistently. 4781 ;; is cached persistently.
@@ -4845,7 +4847,7 @@ This is used internally by `tramp-file-mode-from-int'."
4845 remote-path))))) 4847 remote-path)))))
4846 4848
4847(defun tramp-get-ls-command (vec) 4849(defun tramp-get-ls-command (vec)
4848 (with-connection-property vec "ls" 4850 (with-tramp-connection-property vec "ls"
4849 (tramp-message vec 5 "Finding a suitable `ls' command") 4851 (tramp-message vec 5 "Finding a suitable `ls' command")
4850 (or 4852 (or
4851 (catch 'ls-found 4853 (catch 'ls-found
@@ -4871,7 +4873,7 @@ This is used internally by `tramp-file-mode-from-int'."
4871 4873
4872(defun tramp-get-ls-command-with-dired (vec) 4874(defun tramp-get-ls-command-with-dired (vec)
4873 (save-match-data 4875 (save-match-data
4874 (with-connection-property vec "ls-dired" 4876 (with-tramp-connection-property vec "ls-dired"
4875 (tramp-message vec 5 "Checking, whether `ls --dired' works") 4877 (tramp-message vec 5 "Checking, whether `ls --dired' works")
4876 ;; Some "ls" versions are sensible wrt the order of arguments, 4878 ;; Some "ls" versions are sensible wrt the order of arguments,
4877 ;; they fail when "-al" is after the "--dired" argument (for 4879 ;; they fail when "-al" is after the "--dired" argument (for
@@ -4880,7 +4882,7 @@ This is used internally by `tramp-file-mode-from-int'."
4880 vec (format "%s --dired -al /dev/null" (tramp-get-ls-command vec)))))) 4882 vec (format "%s --dired -al /dev/null" (tramp-get-ls-command vec))))))
4881 4883
4882(defun tramp-get-test-command (vec) 4884(defun tramp-get-test-command (vec)
4883 (with-connection-property vec "test" 4885 (with-tramp-connection-property vec "test"
4884 (tramp-message vec 5 "Finding a suitable `test' command") 4886 (tramp-message vec 5 "Finding a suitable `test' command")
4885 (if (tramp-send-command-and-check vec "test 0") 4887 (if (tramp-send-command-and-check vec "test 0")
4886 "test" 4888 "test"
@@ -4890,7 +4892,7 @@ This is used internally by `tramp-file-mode-from-int'."
4890 ;; Does `test A -nt B' work? Use abominable `find' construct if it 4892 ;; Does `test A -nt B' work? Use abominable `find' construct if it
4891 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, 4893 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command,
4892 ;; for otherwise the shell crashes. 4894 ;; for otherwise the shell crashes.
4893 (with-connection-property vec "test-nt" 4895 (with-tramp-connection-property vec "test-nt"
4894 (or 4896 (or
4895 (progn 4897 (progn
4896 (tramp-send-command 4898 (tramp-send-command
@@ -4908,17 +4910,17 @@ This is used internally by `tramp-file-mode-from-int'."
4908 "tramp_test_nt %s %s")))) 4910 "tramp_test_nt %s %s"))))
4909 4911
4910(defun tramp-get-file-exists-command (vec) 4912(defun tramp-get-file-exists-command (vec)
4911 (with-connection-property vec "file-exists" 4913 (with-tramp-connection-property vec "file-exists"
4912 (tramp-message vec 5 "Finding command to check if file exists") 4914 (tramp-message vec 5 "Finding command to check if file exists")
4913 (tramp-find-file-exists-command vec))) 4915 (tramp-find-file-exists-command vec)))
4914 4916
4915(defun tramp-get-remote-ln (vec) 4917(defun tramp-get-remote-ln (vec)
4916 (with-connection-property vec "ln" 4918 (with-tramp-connection-property vec "ln"
4917 (tramp-message vec 5 "Finding a suitable `ln' command") 4919 (tramp-message vec 5 "Finding a suitable `ln' command")
4918 (tramp-find-executable vec "ln" (tramp-get-remote-path vec)))) 4920 (tramp-find-executable vec "ln" (tramp-get-remote-path vec))))
4919 4921
4920(defun tramp-get-remote-perl (vec) 4922(defun tramp-get-remote-perl (vec)
4921 (with-connection-property vec "perl" 4923 (with-tramp-connection-property vec "perl"
4922 (tramp-message vec 5 "Finding a suitable `perl' command") 4924 (tramp-message vec 5 "Finding a suitable `perl' command")
4923 (let ((result 4925 (let ((result
4924 (or (tramp-find-executable vec "perl5" (tramp-get-remote-path vec)) 4926 (or (tramp-find-executable vec "perl5" (tramp-get-remote-path vec))
@@ -4926,16 +4928,16 @@ This is used internally by `tramp-file-mode-from-int'."
4926 vec "perl" (tramp-get-remote-path vec))))) 4928 vec "perl" (tramp-get-remote-path vec)))))
4927 ;; We must check also for some Perl modules. 4929 ;; We must check also for some Perl modules.
4928 (when result 4930 (when result
4929 (with-connection-property vec "perl-file-spec" 4931 (with-tramp-connection-property vec "perl-file-spec"
4930 (tramp-send-command-and-check 4932 (tramp-send-command-and-check
4931 vec (format "%s -e 'use File::Spec;'" result))) 4933 vec (format "%s -e 'use File::Spec;'" result)))
4932 (with-connection-property vec "perl-cwd-realpath" 4934 (with-tramp-connection-property vec "perl-cwd-realpath"
4933 (tramp-send-command-and-check 4935 (tramp-send-command-and-check
4934 vec (format "%s -e 'use Cwd \"realpath\";'" result)))) 4936 vec (format "%s -e 'use Cwd \"realpath\";'" result))))
4935 result))) 4937 result)))
4936 4938
4937(defun tramp-get-remote-stat (vec) 4939(defun tramp-get-remote-stat (vec)
4938 (with-connection-property vec "stat" 4940 (with-tramp-connection-property vec "stat"
4939 (tramp-message vec 5 "Finding a suitable `stat' command") 4941 (tramp-message vec 5 "Finding a suitable `stat' command")
4940 (let ((result (tramp-find-executable 4942 (let ((result (tramp-find-executable
4941 vec "stat" (tramp-get-remote-path vec))) 4943 vec "stat" (tramp-get-remote-path vec)))
@@ -4953,7 +4955,7 @@ This is used internally by `tramp-file-mode-from-int'."
4953 result))) 4955 result)))
4954 4956
4955(defun tramp-get-remote-readlink (vec) 4957(defun tramp-get-remote-readlink (vec)
4956 (with-connection-property vec "readlink" 4958 (with-tramp-connection-property vec "readlink"
4957 (tramp-message vec 5 "Finding a suitable `readlink' command") 4959 (tramp-message vec 5 "Finding a suitable `readlink' command")
4958 (let ((result (tramp-find-executable 4960 (let ((result (tramp-find-executable
4959 vec "readlink" (tramp-get-remote-path vec)))) 4961 vec "readlink" (tramp-get-remote-path vec))))
@@ -4963,12 +4965,12 @@ This is used internally by `tramp-file-mode-from-int'."
4963 result)))) 4965 result))))
4964 4966
4965(defun tramp-get-remote-trash (vec) 4967(defun tramp-get-remote-trash (vec)
4966 (with-connection-property vec "trash" 4968 (with-tramp-connection-property vec "trash"
4967 (tramp-message vec 5 "Finding a suitable `trash' command") 4969 (tramp-message vec 5 "Finding a suitable `trash' command")
4968 (tramp-find-executable vec "trash" (tramp-get-remote-path vec)))) 4970 (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))
4969 4971
4970(defun tramp-get-remote-id (vec) 4972(defun tramp-get-remote-id (vec)
4971 (with-connection-property vec "id" 4973 (with-tramp-connection-property vec "id"
4972 (tramp-message vec 5 "Finding POSIX `id' command") 4974 (tramp-message vec 5 "Finding POSIX `id' command")
4973 (or 4975 (or
4974 (catch 'id-found 4976 (catch 'id-found
@@ -4982,7 +4984,7 @@ This is used internally by `tramp-file-mode-from-int'."
4982 (tramp-error vec 'file-error "Couldn't find a POSIX `id' command")))) 4984 (tramp-error vec 'file-error "Couldn't find a POSIX `id' command"))))
4983 4985
4984(defun tramp-get-remote-uid (vec id-format) 4986(defun tramp-get-remote-uid (vec id-format)
4985 (with-connection-property vec (format "uid-%s" id-format) 4987 (with-tramp-connection-property vec (format "uid-%s" id-format)
4986 (let ((res (tramp-send-command-and-read 4988 (let ((res (tramp-send-command-and-read
4987 vec 4989 vec
4988 (format "%s -u%s %s" 4990 (format "%s -u%s %s"
@@ -4994,7 +4996,7 @@ This is used internally by `tramp-file-mode-from-int'."
4994 (if (and (equal id-format 'integer) (not (integerp res))) -1 res)))) 4996 (if (and (equal id-format 'integer) (not (integerp res))) -1 res))))
4995 4997
4996(defun tramp-get-remote-gid (vec id-format) 4998(defun tramp-get-remote-gid (vec id-format)
4997 (with-connection-property vec (format "gid-%s" id-format) 4999 (with-tramp-connection-property vec (format "gid-%s" id-format)
4998 (let ((res (tramp-send-command-and-read 5000 (let ((res (tramp-send-command-and-read
4999 vec 5001 vec
5000 (format "%s -g%s %s" 5002 (format "%s -g%s %s"
@@ -5020,7 +5022,7 @@ the length of the file to be compressed.
5020If no corresponding command is found, nil is returned." 5022If no corresponding command is found, nil is returned."
5021 (when (and (integerp tramp-inline-compress-start-size) 5023 (when (and (integerp tramp-inline-compress-start-size)
5022 (> size tramp-inline-compress-start-size)) 5024 (> size tramp-inline-compress-start-size))
5023 (with-connection-property (tramp-get-connection-process vec) prop 5025 (with-tramp-connection-property (tramp-get-connection-process vec) prop
5024 (tramp-find-inline-compress vec) 5026 (tramp-find-inline-compress vec)
5025 (tramp-get-connection-property 5027 (tramp-get-connection-property
5026 (tramp-get-connection-process vec) prop nil)))) 5028 (tramp-get-connection-process vec) prop nil))))
@@ -5041,7 +5043,8 @@ function cell is returned to be applied on a buffer."
5041 ;; no inline coding is found. 5043 ;; no inline coding is found.
5042 (ignore-errors 5044 (ignore-errors
5043 (let ((coding 5045 (let ((coding
5044 (with-connection-property (tramp-get-connection-process vec) prop 5046 (with-tramp-connection-property
5047 (tramp-get-connection-process vec) prop
5045 (tramp-find-inline-encoding vec) 5048 (tramp-find-inline-encoding vec)
5046 (tramp-get-connection-property 5049 (tramp-get-connection-property
5047 (tramp-get-connection-process vec) prop nil))) 5050 (tramp-get-connection-process vec) prop nil)))
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index f1d54b6fd3c..567f8f2969a 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -355,7 +355,7 @@ pass to the OPERATION."
355 (let ((t1 (tramp-tramp-file-p dirname)) 355 (let ((t1 (tramp-tramp-file-p dirname))
356 (t2 (tramp-tramp-file-p newname))) 356 (t2 (tramp-tramp-file-p newname)))
357 (with-parsed-tramp-file-name (if t1 dirname newname) nil 357 (with-parsed-tramp-file-name (if t1 dirname newname) nil
358 (tramp-with-progress-reporter 358 (with-tramp-progress-reporter
359 v 0 (format "Copying %s to %s" dirname newname) 359 v 0 (format "Copying %s to %s" dirname newname)
360 (cond 360 (cond
361 ;; We must use a local temporary directory. 361 ;; We must use a local temporary directory.
@@ -491,7 +491,7 @@ KEEP-DATE has no effect in case NEWNAME resides on an SMB server.
491PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored." 491PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
492 (setq filename (expand-file-name filename) 492 (setq filename (expand-file-name filename)
493 newname (expand-file-name newname)) 493 newname (expand-file-name newname))
494 (tramp-with-progress-reporter 494 (with-tramp-progress-reporter
495 (tramp-dissect-file-name (if (file-remote-p filename) filename newname)) 495 (tramp-dissect-file-name (if (file-remote-p filename) filename newname))
496 0 (format "Copying %s to %s" filename newname) 496 0 (format "Copying %s to %s" filename newname)
497 497
@@ -642,7 +642,8 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
642 (unless id-format (setq id-format 'integer)) 642 (unless id-format (setq id-format 'integer))
643 (ignore-errors 643 (ignore-errors
644 (with-parsed-tramp-file-name filename nil 644 (with-parsed-tramp-file-name filename nil
645 (with-file-property v localname (format "file-attributes-%s" id-format) 645 (with-tramp-file-property
646 v localname (format "file-attributes-%s" id-format)
646 (if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v)) 647 (if (and (tramp-smb-get-share v) (tramp-smb-get-stat-capability v))
647 (tramp-smb-do-file-attributes-with-stat v id-format) 648 (tramp-smb-do-file-attributes-with-stat v id-format)
648 ;; Reading just the filename entry via "dir localname" is not 649 ;; Reading just the filename entry via "dir localname" is not
@@ -753,7 +754,7 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
753 v 'file-error 754 v 'file-error
754 "Cannot make local copy of non-existing file `%s'" filename)) 755 "Cannot make local copy of non-existing file `%s'" filename))
755 (let ((tmpfile (tramp-compat-make-temp-file filename))) 756 (let ((tmpfile (tramp-compat-make-temp-file filename)))
756 (tramp-with-progress-reporter 757 (with-tramp-progress-reporter
757 v 3 (format "Fetching %s to tmp file %s" filename tmpfile) 758 v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
758 (unless (tramp-smb-send-command 759 (unless (tramp-smb-send-command
759 v (format "get \"%s\" \"%s\"" 760 v (format "get \"%s\" \"%s\""
@@ -771,7 +772,7 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
771 (all-completions 772 (all-completions
772 filename 773 filename
773 (with-parsed-tramp-file-name directory nil 774 (with-parsed-tramp-file-name directory nil
774 (with-file-property v localname "file-name-all-completions" 775 (with-tramp-file-property v localname "file-name-all-completions"
775 (save-match-data 776 (save-match-data
776 (let ((entries (tramp-smb-get-file-entries directory))) 777 (let ((entries (tramp-smb-get-file-entries directory)))
777 (mapcar 778 (mapcar
@@ -1119,7 +1120,7 @@ target of the symlink differ."
1119 (if (file-remote-p filename) filename newname)) 1120 (if (file-remote-p filename) filename newname))
1120 'file-already-exists newname)) 1121 'file-already-exists newname))
1121 1122
1122 (tramp-with-progress-reporter 1123 (with-tramp-progress-reporter
1123 (tramp-dissect-file-name (if (file-remote-p filename) filename newname)) 1124 (tramp-dissect-file-name (if (file-remote-p filename) filename newname))
1124 0 (format "Renaming %s to %s" filename newname) 1125 0 (format "Renaming %s to %s" filename newname)
1125 1126
@@ -1253,7 +1254,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
1253 (list start end tmpfile append 'no-message lockname confirm) 1254 (list start end tmpfile append 'no-message lockname confirm)
1254 (list start end tmpfile append 'no-message lockname))) 1255 (list start end tmpfile append 'no-message lockname)))
1255 1256
1256 (tramp-with-progress-reporter 1257 (with-tramp-progress-reporter
1257 v 3 (format "Moving tmp file %s to %s" tmpfile filename) 1258 v 3 (format "Moving tmp file %s to %s" tmpfile filename)
1258 (unwind-protect 1259 (unwind-protect
1259 (unless (tramp-smb-send-command 1260 (unless (tramp-smb-send-command
@@ -1312,7 +1313,7 @@ Either the shares are listed, or the `dir' command is executed.
1312Result is a list of (LOCALNAME MODE SIZE MONTH DAY TIME YEAR)." 1313Result is a list of (LOCALNAME MODE SIZE MONTH DAY TIME YEAR)."
1313 (with-parsed-tramp-file-name (file-name-as-directory directory) nil 1314 (with-parsed-tramp-file-name (file-name-as-directory directory) nil
1314 (setq localname (or localname "/")) 1315 (setq localname (or localname "/"))
1315 (with-file-property v localname "file-entries" 1316 (with-tramp-file-property v localname "file-entries"
1316 (with-current-buffer (tramp-get-connection-buffer v) 1317 (with-current-buffer (tramp-get-connection-buffer v)
1317 (let* ((share (tramp-smb-get-share v)) 1318 (let* ((share (tramp-smb-get-share v))
1318 (cache (tramp-get-connection-property v "share-cache" nil)) 1319 (cache (tramp-get-connection-property v "share-cache" nil))
@@ -1497,7 +1498,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
1497 ;; When we are not logged in yet, we return nil. 1498 ;; When we are not logged in yet, we return nil.
1498 (if (let ((p (tramp-get-connection-process vec))) 1499 (if (let ((p (tramp-get-connection-process vec)))
1499 (and p (processp p) (memq (process-status p) '(run open)))) 1500 (and p (processp p) (memq (process-status p) '(run open))))
1500 (with-connection-property 1501 (with-tramp-connection-property
1501 (tramp-get-connection-process vec) "cifs-capabilities" 1502 (tramp-get-connection-process vec) "cifs-capabilities"
1502 (save-match-data 1503 (save-match-data
1503 (when (tramp-smb-send-command vec "posix") 1504 (when (tramp-smb-send-command vec "posix")
@@ -1515,7 +1516,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
1515 ;; When we are not logged in yet, we return nil. 1516 ;; When we are not logged in yet, we return nil.
1516 (if (let ((p (tramp-get-connection-process vec))) 1517 (if (let ((p (tramp-get-connection-process vec)))
1517 (and p (processp p) (memq (process-status p) '(run open)))) 1518 (and p (processp p) (memq (process-status p) '(run open))))
1518 (with-connection-property 1519 (with-tramp-connection-property
1519 (tramp-get-connection-process vec) "stat-capability" 1520 (tramp-get-connection-process vec) "stat-capability"
1520 (tramp-smb-send-command vec "stat .")))) 1521 (tramp-smb-send-command vec "stat ."))))
1521 1522
@@ -1625,7 +1626,7 @@ If ARGUMENT is non-nil, use it as argument for
1625 (setq args (append args (list argument)))) 1626 (setq args (append args (list argument))))
1626 1627
1627 ;; OK, let's go. 1628 ;; OK, let's go.
1628 (tramp-with-progress-reporter 1629 (with-tramp-progress-reporter
1629 vec 3 1630 vec 3
1630 (format "Opening connection for //%s%s/%s" 1631 (format "Opening connection for //%s%s/%s"
1631 (if (not (zerop (length user))) (concat user "@") "") 1632 (if (not (zerop (length user))) (concat user "@") "")
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index b1532eb2ae4..874c0aa7fef 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1353,8 +1353,7 @@ ARGS to actually emit the message (if applicable)."
1353 "tramp-debug-message" 1353 "tramp-debug-message"
1354 "tramp-error" 1354 "tramp-error"
1355 "tramp-error-with-buffer" 1355 "tramp-error-with-buffer"
1356 "tramp-message" 1356 "tramp-message")
1357 "tramp-with-progress-reporter")
1358 t) 1357 t)
1359 "$") 1358 "$")
1360 fn))) 1359 fn)))
@@ -1498,7 +1497,7 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1498 (when (string-match message (or (current-message) "")) 1497 (when (string-match message (or (current-message) ""))
1499 (tramp-compat-funcall 'progress-reporter-update reporter value)))) 1498 (tramp-compat-funcall 'progress-reporter-update reporter value))))
1500 1499
1501(defmacro tramp-with-progress-reporter (vec level message &rest body) 1500(defmacro with-tramp-progress-reporter (vec level message &rest body)
1502 "Executes BODY, spinning a progress reporter with MESSAGE. 1501 "Executes BODY, spinning a progress reporter with MESSAGE.
1503If LEVEL does not fit for visible messages, or if this is a 1502If LEVEL does not fit for visible messages, or if this is a
1504nested call of the macro, there are only traces without a visible 1503nested call of the macro, there are only traces without a visible
@@ -1527,7 +1526,42 @@ progress reporter."
1527 (tramp-message ,vec ,level "%s...done" ,message)))) 1526 (tramp-message ,vec ,level "%s...done" ,message))))
1528 1527
1529(tramp-compat-font-lock-add-keywords 1528(tramp-compat-font-lock-add-keywords
1530 'emacs-lisp-mode '("\\<tramp-with-progress-reporter\\>")) 1529 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>"))
1530
1531(defmacro with-tramp-file-property (vec file property &rest body)
1532 "Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache.
1533FILE must be a local file name on a connection identified via VEC."
1534 `(if (file-name-absolute-p ,file)
1535 (let ((value (tramp-get-file-property ,vec ,file ,property 'undef)))
1536 (when (eq value 'undef)
1537 ;; We cannot pass @body as parameter to
1538 ;; `tramp-set-file-property' because it mangles our
1539 ;; debug messages.
1540 (setq value (progn ,@body))
1541 (tramp-set-file-property ,vec ,file ,property value))
1542 value)
1543 ,@body))
1544
1545(put 'with-tramp-file-property 'lisp-indent-function 3)
1546(put 'with-tramp-file-property 'edebug-form-spec t)
1547(tramp-compat-font-lock-add-keywords
1548 'emacs-lisp-mode '("\\<with-tramp-file-property\\>"))
1549
1550(defmacro with-tramp-connection-property (key property &rest body)
1551 "Check in Tramp for property PROPERTY, otherwise executes BODY and set."
1552 `(let ((value (tramp-get-connection-property ,key ,property 'undef)))
1553 (when (eq value 'undef)
1554 ;; We cannot pass ,@body as parameter to
1555 ;; `tramp-set-connection-property' because it mangles our debug
1556 ;; messages.
1557 (setq value (progn ,@body))
1558 (tramp-set-connection-property ,key ,property value))
1559 value))
1560
1561(put 'with-tramp-connection-property 'lisp-indent-function 2)
1562(put 'with-tramp-connection-property 'edebug-form-spec t)
1563(tramp-compat-font-lock-add-keywords
1564 'emacs-lisp-mode '("\\<with-tramp-connection-property\\>"))
1531 1565
1532(defalias 'tramp-drop-volume-letter 1566(defalias 'tramp-drop-volume-letter
1533 (if (memq system-type '(cygwin windows-nt)) 1567 (if (memq system-type '(cygwin windows-nt))
@@ -2860,7 +2894,7 @@ User is always nil."
2860 (setq filename (expand-file-name filename)) 2894 (setq filename (expand-file-name filename))
2861 (let (result local-copy remote-copy) 2895 (let (result local-copy remote-copy)
2862 (with-parsed-tramp-file-name filename nil 2896 (with-parsed-tramp-file-name filename nil
2863 (tramp-with-progress-reporter 2897 (with-tramp-progress-reporter
2864 v 3 (format "Inserting `%s'" filename) 2898 v 3 (format "Inserting `%s'" filename)
2865 (unwind-protect 2899 (unwind-protect
2866 (if (not (file-exists-p filename)) 2900 (if (not (file-exists-p filename))
@@ -2983,7 +3017,7 @@ User is always nil."
2983 (if (not (file-exists-p file)) 3017 (if (not (file-exists-p file))
2984 nil 3018 nil
2985 (let ((tramp-message-show-message (not nomessage))) 3019 (let ((tramp-message-show-message (not nomessage)))
2986 (tramp-with-progress-reporter v 0 (format "Loading %s" file) 3020 (with-tramp-progress-reporter v 0 (format "Loading %s" file)
2987 (let ((local-copy (file-local-copy file))) 3021 (let ((local-copy (file-local-copy file)))
2988 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. 3022 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
2989 (unwind-protect 3023 (unwind-protect
@@ -3127,7 +3161,7 @@ beginning of local filename are not substituted."
3127 "Send the login name." 3161 "Send the login name."
3128 (when (not (stringp tramp-current-user)) 3162 (when (not (stringp tramp-current-user))
3129 (setq tramp-current-user 3163 (setq tramp-current-user
3130 (with-connection-property vec "login-as" 3164 (with-tramp-connection-property vec "login-as"
3131 (save-window-excursion 3165 (save-window-excursion
3132 (let ((enable-recursive-minibuffers t)) 3166 (let ((enable-recursive-minibuffers t))
3133 (pop-to-buffer (tramp-get-connection-buffer vec)) 3167 (pop-to-buffer (tramp-get-connection-buffer vec))
@@ -3417,13 +3451,13 @@ the remote host use line-endings as defined in the variable
3417(defun tramp-get-inode (vec) 3451(defun tramp-get-inode (vec)
3418 "Returns the virtual inode number. 3452 "Returns the virtual inode number.
3419If it doesn't exist, generate a new one." 3453If it doesn't exist, generate a new one."
3420 (with-file-property vec (tramp-file-name-localname vec) "inode" 3454 (with-tramp-file-property vec (tramp-file-name-localname vec) "inode"
3421 (setq tramp-inodes (1+ tramp-inodes)))) 3455 (setq tramp-inodes (1+ tramp-inodes))))
3422 3456
3423(defun tramp-get-device (vec) 3457(defun tramp-get-device (vec)
3424 "Returns the virtual device number. 3458 "Returns the virtual device number.
3425If it doesn't exist, generate a new one." 3459If it doesn't exist, generate a new one."
3426 (with-connection-property (tramp-get-connection-process vec) "device" 3460 (with-tramp-connection-property (tramp-get-connection-process vec) "device"
3427 (cons -1 (setq tramp-devices (1+ tramp-devices))))) 3461 (cons -1 (setq tramp-devices (1+ tramp-devices)))))
3428 3462
3429(defun tramp-equal-remote (file1 file2) 3463(defun tramp-equal-remote (file1 file2)
@@ -3545,7 +3579,7 @@ would yield `t'. On the other hand, the following check results in nil:
3545 3579
3546(defun tramp-get-remote-tmpdir (vec) 3580(defun tramp-get-remote-tmpdir (vec)
3547 "Return directory for temporary files on the remote host identified by VEC." 3581 "Return directory for temporary files on the remote host identified by VEC."
3548 (with-connection-property vec "tmpdir" 3582 (with-tramp-connection-property vec "tmpdir"
3549 (let ((dir (tramp-make-tramp-file-name 3583 (let ((dir (tramp-make-tramp-file-name
3550 (tramp-file-name-method vec) 3584 (tramp-file-name-method vec)
3551 (tramp-file-name-user vec) 3585 (tramp-file-name-user vec)
@@ -3833,7 +3867,6 @@ Only works for Bourne-like shells."
3833;; * In Emacs 21, `insert-directory' shows total number of bytes used 3867;; * In Emacs 21, `insert-directory' shows total number of bytes used
3834;; by the files in that directory. Add this here. 3868;; by the files in that directory. Add this here.
3835;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) 3869;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman)
3836;; * Make ffap.el grok Tramp filenames. (Eli Tziperman)
3837;; * abbreviate-file-name 3870;; * abbreviate-file-name
3838;; * Better error checking. At least whenever we see something 3871;; * Better error checking. At least whenever we see something
3839;; strange when doing zerop, we should kill the process and start 3872;; strange when doing zerop, we should kill the process and start
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 2d0a8e3d23d..331884691f4 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -31,7 +31,7 @@
31;; should be changed only there. 31;; should be changed only there.
32 32
33;;;###tramp-autoload 33;;;###tramp-autoload
34(defconst tramp-version "2.2.6" 34(defconst tramp-version "2.2.7-pre"
35 "This version of Tramp.") 35 "This version of Tramp.")
36 36
37;;;###tramp-autoload 37;;;###tramp-autoload
@@ -44,7 +44,7 @@
44 (= emacs-major-version 21) 44 (= emacs-major-version 21)
45 (>= emacs-minor-version 4))) 45 (>= emacs-minor-version 4)))
46 "ok" 46 "ok"
47 (format "Tramp 2.2.6 is not fit for %s" 47 (format "Tramp 2.2.7-pre is not fit for %s"
48 (when (string-match "^.*$" (emacs-version)) 48 (when (string-match "^.*$" (emacs-version))
49 (match-string 0 (emacs-version))))))) 49 (match-string 0 (emacs-version)))))))
50 (unless (string-match "\\`ok\\'" x) (error "%s" x))) 50 (unless (string-match "\\`ok\\'" x) (error "%s" x)))
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index a7fedf20f53..a754c89c4ae 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -117,20 +117,20 @@ Comments might be indented to a different value in order not to go beyond
117If there are any \\(...\\) pairs, the comment delimiter text is held to begin 117If there are any \\(...\\) pairs, the comment delimiter text is held to begin
118at the place matched by the close of the first pair.") 118at the place matched by the close of the first pair.")
119;;;###autoload 119;;;###autoload
120(put 'comment-start-skip 'safe-local-variable 'string-or-null-p) 120(put 'comment-start-skip 'safe-local-variable 'stringp)
121 121
122;;;###autoload 122;;;###autoload
123(defvar comment-end-skip nil 123(defvar comment-end-skip nil
124 "Regexp to match the end of a comment plus everything back to its body.") 124 "Regexp to match the end of a comment plus everything back to its body.")
125;;;###autoload 125;;;###autoload
126(put 'comment-end-skip 'safe-local-variable 'string-or-null-p) 126(put 'comment-end-skip 'safe-local-variable 'stringp)
127 127
128;;;###autoload 128;;;###autoload
129(defvar comment-end (purecopy "") 129(defvar comment-end (purecopy "")
130 "String to insert to end a new comment. 130 "String to insert to end a new comment.
131Should be an empty string if comments are terminated by end-of-line.") 131Should be an empty string if comments are terminated by end-of-line.")
132;;;###autoload 132;;;###autoload
133(put 'comment-end 'safe-local-variable 'string-or-null-p) 133(put 'comment-end 'safe-local-variable 'stringp)
134 134
135;;;###autoload 135;;;###autoload
136(defvar comment-indent-function 'comment-indent-default 136(defvar comment-indent-function 'comment-indent-default
@@ -327,9 +327,9 @@ terminated by the end of line (i.e. `comment-end' is empty)."
327;;;###autoload 327;;;###autoload
328(defun comment-normalize-vars (&optional noerror) 328(defun comment-normalize-vars (&optional noerror)
329 "Check and setup the variables needed by other commenting functions. 329 "Check and setup the variables needed by other commenting functions.
330Functions autoloaded from newcomment.el, being entry points, should call 330Any command calling functions from newcomment.el should call this function
331this function before any other, so the rest of the code can assume that 331before any other, so the rest of the code can assume that the variables are
332the variables are properly set." 332properly set."
333 (unless (and (not comment-start) noerror) 333 (unless (and (not comment-start) noerror)
334 (unless comment-start 334 (unless comment-start
335 (let ((cs (read-string "No comment syntax is defined. Use: "))) 335 (let ((cs (read-string "No comment syntax is defined. Use: ")))
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index bd9805673a4..4236f1c983f 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -338,30 +338,6 @@ at compile time, e.g. for macros and inline functions."
338 (cc-bytecomp-debug-msg 338 (cc-bytecomp-debug-msg
339 "cc-bytecomp-defun: Covered function %s" ',fun)))))) 339 "cc-bytecomp-defun: Covered function %s" ',fun))))))
340 340
341(put 'cc-bytecomp-defmacro 'lisp-indent-function 'defun)
342(defmacro cc-bytecomp-defmacro (fun &rest temp-macro)
343 "Bind the symbol as a macro during compilation (and evaluation) of the
344file. Don't use outside `eval-when-compile'."
345 `(let ((orig-fun (assq ',fun cc-bytecomp-original-functions)))
346 (if (not orig-fun)
347 (setq orig-fun
348 (list ',fun
349 nil
350 (if (fboundp ',fun)
351 (progn
352 (cc-bytecomp-debug-msg
353 "cc-bytecomp-defmacro: Saving %s" ',fun)
354 (symbol-function ',fun))
355 (cc-bytecomp-debug-msg
356 "cc-bytecomp-defmacro: Saving %s as unbound" ',fun)
357 'unbound))
358 cc-bytecomp-original-functions
359 (cons orig-fun cc-bytecomp-original-functions)))
360 (defmacro ,fun ,@temp-macro)
361 (cc-bytecomp-debug-msg
362 "cc-bytecomp-defmacro: Bound macro %s" ',fun)
363 (setcar (cdr orig-fun) (symbol-function ',fun))))
364
365(defmacro cc-bytecomp-put (symbol propname value) 341(defmacro cc-bytecomp-put (symbol propname value)
366 "Set a property on a symbol during compilation (and evaluation) of 342 "Set a property on a symbol during compilation (and evaluation) of
367the file. Don't use outside `eval-when-compile'." 343the file. Don't use outside `eval-when-compile'."
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 5201e4a26ed..d56c1124a9c 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -49,16 +49,6 @@
49 (require 'custom) 49 (require 'custom)
50 (require 'widget)) 50 (require 'widget))
51 51
52(cc-eval-when-compile
53 ;; Need the function form of `backquote', which isn't standardized
54 ;; between Emacsen. It's called `bq-process' in XEmacs, and
55 ;; `backquote-process' in Emacs. `backquote-process' returns a
56 ;; slightly more convoluted form, so let `bq-process' be the norm.
57 (if (fboundp 'backquote-process)
58 (cc-bytecomp-defmacro bq-process (form)
59 `(cdr (backquote-process ,form)))))
60
61
62;;; Helpers 52;;; Helpers
63 53
64;; This widget exists in newer versions of the Custom library 54;; This widget exists in newer versions of the Custom library
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 726c0b2d542..5bf64c18f99 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -235,6 +235,9 @@
235 (substitute-key-definition 'forward-sentence 235 (substitute-key-definition 'forward-sentence
236 'python-nav-forward-block 236 'python-nav-forward-block
237 map global-map) 237 map global-map)
238 (substitute-key-definition 'backward-up-list
239 'python-nav-backward-up-list
240 map global-map)
238 (define-key map "\C-c\C-j" 'imenu) 241 (define-key map "\C-c\C-j" 'imenu)
239 ;; Indent specific 242 ;; Indent specific
240 (define-key map "\177" 'python-indent-dedent-line-backspace) 243 (define-key map "\177" 'python-indent-dedent-line-backspace)
@@ -337,19 +340,28 @@
337 "==" ">=" "is" "not"))) 340 "==" ">=" "is" "not")))
338 ;; FIXME: Use regexp-opt. 341 ;; FIXME: Use regexp-opt.
339 (assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**=" 342 (assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**="
340 ">>=" "<<=" "&=" "^=" "|=")))) 343 ">>=" "<<=" "&=" "^=" "|=")))
341 "Additional Python specific sexps for `python-rx'")) 344 (string-delimiter . ,(rx (and
342 345 ;; Match even number of backslashes.
343(defmacro python-rx (&rest regexps) 346 (or (not (any ?\\ ?\' ?\")) point
344 "Python mode specialized rx macro. 347 ;; Quotes might be preceded by a escaped quote.
348 (and (or (not (any ?\\)) point) ?\\
349 (* ?\\ ?\\) (any ?\' ?\")))
350 (* ?\\ ?\\)
351 ;; Match single or triple quotes of any kind.
352 (group (or "\"" "\"\"\"" "'" "'''"))))))
353 "Additional Python specific sexps for `python-rx'")
354
355 (defmacro python-rx (&rest regexps)
356 "Python mode specialized rx macro.
345This variant of `rx' supports common python named REGEXPS." 357This variant of `rx' supports common python named REGEXPS."
346 (let ((rx-constituents (append python-rx-constituents rx-constituents))) 358 (let ((rx-constituents (append python-rx-constituents rx-constituents)))
347 (cond ((null regexps) 359 (cond ((null regexps)
348 (error "No regexp")) 360 (error "No regexp"))
349 ((cdr regexps) 361 ((cdr regexps)
350 (rx-to-string `(and ,@regexps) t)) 362 (rx-to-string `(and ,@regexps) t))
351 (t 363 (t
352 (rx-to-string (car regexps) t))))) 364 (rx-to-string (car regexps) t))))))
353 365
354 366
355;;; Font-lock and syntax 367;;; Font-lock and syntax
@@ -498,16 +510,7 @@ The type returned can be `comment', `string' or `paren'."
498 510
499(defconst python-syntax-propertize-function 511(defconst python-syntax-propertize-function
500 (syntax-propertize-rules 512 (syntax-propertize-rules
501 ((rx 513 ((python-rx string-delimiter)
502 (and
503 ;; Match even number of backslashes.
504 (or (not (any ?\\ ?\' ?\")) point
505 ;; Quotes might be preceded by a escaped quote.
506 (and (or (not (any ?\\)) point) ?\\
507 (* ?\\ ?\\) (any ?\' ?\")))
508 (* ?\\ ?\\)
509 ;; Match single or triple quotes of any kind.
510 (group (or "\"" "\"\"\"" "'" "'''"))))
511 (0 (ignore (python-syntax-stringify)))))) 514 (0 (ignore (python-syntax-stringify))))))
512 515
513(defsubst python-syntax-count-quotes (quote-char &optional point limit) 516(defsubst python-syntax-count-quotes (quote-char &optional point limit)
@@ -676,12 +679,12 @@ START is the buffer position where the sexp starts."
676 (goto-char (line-beginning-position)) 679 (goto-char (line-beginning-position))
677 (bobp)) 680 (bobp))
678 'no-indent) 681 'no-indent)
679 ;; Inside a paren
680 ((setq start (python-syntax-context 'paren ppss))
681 'inside-paren)
682 ;; Inside string 682 ;; Inside string
683 ((setq start (python-syntax-context 'string ppss)) 683 ((setq start (python-syntax-context 'string ppss))
684 'inside-string) 684 'inside-string)
685 ;; Inside a paren
686 ((setq start (python-syntax-context 'paren ppss))
687 'inside-paren)
685 ;; After backslash 688 ;; After backslash
686 ((setq start (when (not (or (python-syntax-context 'string ppss) 689 ((setq start (when (not (or (python-syntax-context 'string ppss)
687 (python-syntax-context 'comment ppss))) 690 (python-syntax-context 'comment ppss)))
@@ -710,7 +713,7 @@ START is the buffer position where the sexp starts."
710 ;; After normal line 713 ;; After normal line
711 ((setq start (save-excursion 714 ((setq start (save-excursion
712 (back-to-indentation) 715 (back-to-indentation)
713 (python-util-forward-comment -1) 716 (skip-chars-backward (rx (or whitespace ?\n)))
714 (python-nav-beginning-of-statement) 717 (python-nav-beginning-of-statement)
715 (point-marker))) 718 (point-marker)))
716 'after-line) 719 'after-line)
@@ -973,7 +976,16 @@ Called from a program, START and END specify the region to indent."
973 (back-to-indentation) 976 (back-to-indentation)
974 (setq word (current-word)) 977 (setq word (current-word))
975 (forward-line 1) 978 (forward-line 1)
976 (when word 979 (when (and word
980 ;; Don't mess with strings, unless it's the
981 ;; enclosing set of quotes.
982 (or (not (python-syntax-context 'string))
983 (eq
984 (syntax-after
985 (+ (1- (point))
986 (current-indentation)
987 (python-syntax-count-quotes (char-after) (point))))
988 (string-to-syntax "|"))))
977 (beginning-of-line) 989 (beginning-of-line)
978 (delete-horizontal-space) 990 (delete-horizontal-space)
979 (indent-to (python-indent-calculate-indentation))))) 991 (indent-to (python-indent-calculate-indentation)))))
@@ -1160,7 +1172,8 @@ Returns nil if point is not in a def or class."
1160 (python-info-line-ends-backslash-p)) 1172 (python-info-line-ends-backslash-p))
1161 (python-syntax-context 'string) 1173 (python-syntax-context 'string)
1162 (python-syntax-context 'paren)) 1174 (python-syntax-context 'paren))
1163 (forward-line -1))))) 1175 (forward-line -1))))
1176 (point-marker))
1164 1177
1165(defun python-nav-end-of-statement () 1178(defun python-nav-end-of-statement ()
1166 "Move to end of current statement." 1179 "Move to end of current statement."
@@ -1171,7 +1184,8 @@ Returns nil if point is not in a def or class."
1171 (python-info-line-ends-backslash-p) 1184 (python-info-line-ends-backslash-p)
1172 (python-syntax-context 'string) 1185 (python-syntax-context 'string)
1173 (python-syntax-context 'paren)) 1186 (python-syntax-context 'paren))
1174 (forward-line 1))))) 1187 (forward-line 1))))
1188 (point-marker))
1175 1189
1176(defun python-nav-backward-statement (&optional arg) 1190(defun python-nav-backward-statement (&optional arg)
1177 "Move backward to previous statement. 1191 "Move backward to previous statement.
@@ -1286,151 +1300,104 @@ When ARG > 0 move forward, else if ARG is < 0."
1286 (while (and (funcall search-fn paren-regexp nil t) 1300 (while (and (funcall search-fn paren-regexp nil t)
1287 (python-syntax-context 'paren))))))) 1301 (python-syntax-context 'paren)))))))
1288 1302
1289(defun python-nav--forward-sexp () 1303(defun python-nav--forward-sexp (&optional dir)
1290 "Move to forward sexp." 1304 "Move to forward sexp.
1291 (case (python-syntax-context-type) 1305With positive Optional argument DIR direction move forward, else
1292 (string 1306backwards."
1293 ;; Inside of a string, get out of it. 1307 (setq dir (or dir 1))
1294 (while (and (re-search-forward "[\"']" nil t) 1308 (unless (= dir 0)
1295 (python-syntax-context 'string)))) 1309 (let* ((forward-p (if (> dir 0)
1296 (comment 1310 (and (setq dir 1) t)
1297 ;; Inside of a comment, just move forward. 1311 (and (setq dir -1) nil)))
1298 (python-util-forward-comment)) 1312 (re-search-fn (if forward-p
1299 (paren 1313 're-search-forward
1300 (python-nav-lisp-forward-sexp-safe 1)) 1314 're-search-backward))
1301 (t 1315 (context-type (python-syntax-context-type)))
1302 (if (and (not (eobp)) 1316 (cond
1303 (= (syntax-class (syntax-after (point))) 4)) 1317 ((eq context-type 'string)
1304 ;; Looking an open-paren 1318 ;; Inside of a string, get out of it.
1305 (python-nav-lisp-forward-sexp-safe 1) 1319 (while (and (funcall re-search-fn "[\"']" nil t)
1306 (let ((block-starting-pos 1320 (python-syntax-context 'string))))
1307 (save-excursion (python-nav-beginning-of-block))) 1321 ((eq context-type 'comment)
1308 (block-ending-pos 1322 ;; Inside of a comment, just move forward.
1309 (save-excursion (python-nav-end-of-block))) 1323 (python-util-forward-comment dir))
1310 (next-block-starting-pos 1324 ((or (eq context-type 'paren)
1311 (save-excursion (python-nav-forward-block)))) 1325 (and forward-p (looking-at (python-rx open-paren)))
1312 (cond 1326 (and (not forward-p)
1313 ((not block-starting-pos) 1327 (eq (syntax-class (syntax-after (1- (point))))
1314 ;; Not inside a block, move to closest one. 1328 (car (string-to-syntax ")")))))
1315 (and next-block-starting-pos 1329 ;; Inside a paren or looking at it, lisp knows what to do.
1316 (goto-char next-block-starting-pos))) 1330 (python-nav-lisp-forward-sexp-safe dir))
1317 ((= (point) block-starting-pos) 1331 (t
1318 ;; Point is at beginning of block 1332 ;; This part handles the lispy feel of
1319 (if (and next-block-starting-pos 1333 ;; `python-nav-forward-sexp'. Knowing everything about the
1320 (< next-block-starting-pos block-ending-pos)) 1334 ;; current context and the context of the next sexp tries to
1321 ;; Beginning of next block is closer than current's 1335 ;; follow the lisp sexp motion commands in a symmetric manner.
1322 ;; end, move to it. 1336 (let* ((context
1323 (goto-char next-block-starting-pos) 1337 (cond
1324 (goto-char block-ending-pos))) 1338 ((python-info-beginning-of-block-p) 'block-start)
1325 ((= block-ending-pos (point)) 1339 ((python-info-end-of-block-p) 'block-end)
1326 ;; Point is at end of current block 1340 ((python-info-beginning-of-statement-p) 'statement-start)
1327 (let ((parent-block-end-pos 1341 ((python-info-end-of-statement-p) 'statement-end)))
1328 (save-excursion 1342 (next-sexp-pos
1329 (python-util-forward-comment) 1343 (save-excursion
1330 (python-nav-beginning-of-block) 1344 (python-nav-lisp-forward-sexp-safe dir)
1331 (python-nav-end-of-block)))) 1345 (point)))
1332 (if (and parent-block-end-pos 1346 (next-sexp-context
1333 (or (not next-block-starting-pos) 1347 (save-excursion
1334 (> next-block-starting-pos parent-block-end-pos))) 1348 (goto-char next-sexp-pos)
1335 ;; If the parent block ends before next block 1349 (cond
1336 ;; starts move to it. 1350 ((python-info-beginning-of-block-p) 'block-start)
1337 (goto-char parent-block-end-pos) 1351 ((python-info-end-of-block-p) 'block-end)
1338 (and next-block-starting-pos 1352 ((python-info-beginning-of-statement-p) 'statement-start)
1339 (goto-char next-block-starting-pos))))) 1353 ((python-info-end-of-statement-p) 'statement-end)
1340 (t (python-nav-end-of-block)))))))) 1354 ((python-info-statement-starts-block-p) 'starts-block)
1355 ((python-info-statement-ends-block-p) 'ends-block)))))
1356 (if forward-p
1357 (cond ((and (not (eobp))
1358 (python-info-current-line-empty-p))
1359 (python-util-forward-comment dir)
1360 (python-nav--forward-sexp dir))
1361 ((eq context 'block-start)
1362 (python-nav-end-of-block))
1363 ((eq context 'statement-start)
1364 (python-nav-end-of-statement))
1365 ((and (memq context '(statement-end block-end))
1366 (eq next-sexp-context 'ends-block))
1367 (goto-char next-sexp-pos)
1368 (python-nav-end-of-block))
1369 ((and (memq context '(statement-end block-end))
1370 (eq next-sexp-context 'starts-block))
1371 (goto-char next-sexp-pos)
1372 (python-nav-end-of-block))
1373 ((memq context '(statement-end block-end))
1374 (goto-char next-sexp-pos)
1375 (python-nav-end-of-statement))
1376 (t (goto-char next-sexp-pos)))
1377 (cond ((and (not (bobp))
1378 (python-info-current-line-empty-p))
1379 (python-util-forward-comment dir)
1380 (python-nav--forward-sexp dir))
1381 ((eq context 'block-end)
1382 (python-nav-beginning-of-block))
1383 ((eq context 'statement-end)
1384 (python-nav-beginning-of-statement))
1385 ((and (memq context '(statement-start block-start))
1386 (eq next-sexp-context 'starts-block))
1387 (goto-char next-sexp-pos)
1388 (python-nav-beginning-of-block))
1389 ((and (memq context '(statement-start block-start))
1390 (eq next-sexp-context 'ends-block))
1391 (goto-char next-sexp-pos)
1392 (python-nav-beginning-of-block))
1393 ((memq context '(statement-start block-start))
1394 (goto-char next-sexp-pos)
1395 (python-nav-beginning-of-statement))
1396 (t (goto-char next-sexp-pos))))))))))
1341 1397
1342(defun python-nav--backward-sexp () 1398(defun python-nav--backward-sexp ()
1343 "Move to backward sexp." 1399 "Move to backward sexp."
1344 (case (python-syntax-context-type) 1400 (python-nav--forward-sexp -1))
1345 (string
1346 ;; Inside of a string, get out of it.
1347 (while (and (re-search-backward "[\"']" nil t)
1348 (python-syntax-context 'string))))
1349 (comment
1350 ;; Inside of a comment, just move backward.
1351 (python-util-forward-comment -1))
1352 (paren
1353 ;; Handle parens like we are lisp.
1354 (python-nav-lisp-forward-sexp-safe -1))
1355 (t
1356 (let* ((block-starting-pos
1357 (save-excursion (python-nav-beginning-of-block)))
1358 (block-ending-pos
1359 (save-excursion (python-nav-end-of-block)))
1360 (prev-block-ending-pos
1361 (save-excursion (when (python-nav-backward-block)
1362 (python-nav-end-of-block))))
1363 (prev-block-parent-ending-pos
1364 (save-excursion
1365 (when prev-block-ending-pos
1366 (goto-char prev-block-ending-pos)
1367 (python-util-forward-comment)
1368 (python-nav-beginning-of-block)
1369 (python-nav-end-of-block)))))
1370 (if (and (not (bobp))
1371 (= (syntax-class (syntax-after (1- (point)))) 5))
1372 ;; Char before point is a paren closing char, handle it
1373 ;; like we are lisp.
1374 (python-nav-lisp-forward-sexp-safe -1)
1375 (cond
1376 ((not block-ending-pos)
1377 ;; Not in and ending pos, move to end of previous block.
1378 (and (python-nav-backward-block)
1379 (python-nav-end-of-block)))
1380 ((= (point) block-ending-pos)
1381 ;; In ending pos, we need to search backwards for the
1382 ;; closest point looking the list of candidates from here.
1383 (let ((candidates))
1384 (dolist (name
1385 '(prev-block-parent-ending-pos
1386 prev-block-ending-pos
1387 block-ending-pos
1388 block-starting-pos))
1389 (when (and (symbol-value name)
1390 (< (symbol-value name) (point)))
1391 (add-to-list 'candidates (symbol-value name))))
1392 (goto-char (apply 'max candidates))))
1393 ((> (point) block-ending-pos)
1394 ;; After an ending position, move to it.
1395 (goto-char block-ending-pos))
1396 ((= (point) block-starting-pos)
1397 ;; On a block starting position.
1398 (if (not (> (point) (or prev-block-ending-pos (point))))
1399 ;; Point is after the end position of the block that
1400 ;; wraps the current one, just move a block backward.
1401 (python-nav-backward-block)
1402 ;; If we got here we are facing a case like this one:
1403 ;;
1404 ;; try:
1405 ;; return here()
1406 ;; except Exception as e:
1407 ;;
1408 ;; Where point is on the "except" and must move to the
1409 ;; end of "here()".
1410 (goto-char prev-block-ending-pos)
1411 (let ((parent-block-ending-pos
1412 (save-excursion
1413 (python-nav-forward-sexp)
1414 (and (not (looking-at (python-rx block-start)))
1415 (point)))))
1416 (when (and parent-block-ending-pos
1417 (> parent-block-ending-pos prev-block-ending-pos))
1418 ;; If we got here we are facing a case like this one:
1419 ;;
1420 ;; except ImportError:
1421 ;; if predicate():
1422 ;; processing()
1423 ;; here()
1424 ;; except AttributeError:
1425 ;;
1426 ;; Where point is on the "except" and must move to
1427 ;; the end of "here()". Without this extra step we'd
1428 ;; just get to the end of processing().
1429 (goto-char parent-block-ending-pos)))))
1430 (t
1431 (if (and prev-block-ending-pos (< prev-block-ending-pos (point)))
1432 (goto-char prev-block-ending-pos)
1433 (python-nav-beginning-of-block)))))))))
1434 1401
1435(defun python-nav-forward-sexp (&optional arg) 1402(defun python-nav-forward-sexp (&optional arg)
1436 "Move forward across one block of code. 1403 "Move forward across one block of code.
@@ -1445,6 +1412,67 @@ move backward N times."
1445 (python-nav--backward-sexp) 1412 (python-nav--backward-sexp)
1446 (setq arg (1+ arg)))) 1413 (setq arg (1+ arg))))
1447 1414
1415(defun python-nav--up-list (&optional dir)
1416 "Internal implementation of `python-nav-up-list'.
1417DIR is always 1 or -1 and comes sanitized from
1418`python-nav-up-list' calls."
1419 (let ((context (python-syntax-context-type))
1420 (forward-p (> dir 0)))
1421 (cond
1422 ((memq context '(string comment)))
1423 ((eq context 'paren)
1424 (let ((forward-sexp-function))
1425 (up-list dir)))
1426 ((and forward-p (python-info-end-of-block-p))
1427 (let ((parent-end-pos
1428 (save-excursion
1429 (let ((indentation (and
1430 (python-nav-beginning-of-block)
1431 (current-indentation))))
1432 (while (and indentation
1433 (> indentation 0)
1434 (>= (current-indentation) indentation)
1435 (python-nav-backward-block)))
1436 (python-nav-end-of-block)))))
1437 (and (> (or parent-end-pos (point)) (point))
1438 (goto-char parent-end-pos))))
1439 (forward-p (python-nav-end-of-block))
1440 ((and (not forward-p)
1441 (> (current-indentation) 0)
1442 (python-info-beginning-of-block-p))
1443 (let ((prev-block-pos
1444 (save-excursion
1445 (let ((indentation (current-indentation)))
1446 (while (and (python-nav-backward-block)
1447 (> (current-indentation) indentation))))
1448 (point))))
1449 (and (> (point) prev-block-pos)
1450 (goto-char prev-block-pos))))
1451 ((not forward-p) (python-nav-beginning-of-block)))))
1452
1453(defun python-nav-up-list (&optional arg)
1454 "Move forward out of one level of parentheses (or blocks).
1455With ARG, do this that many times.
1456A negative argument means move backward but still to a less deep spot.
1457This command assumes point is not in a string or comment."
1458 (interactive "^p")
1459 (or arg (setq arg 1))
1460 (while (> arg 0)
1461 (python-nav--up-list 1)
1462 (setq arg (1- arg)))
1463 (while (< arg 0)
1464 (python-nav--up-list -1)
1465 (setq arg (1+ arg))))
1466
1467(defun python-nav-backward-up-list (&optional arg)
1468 "Move backward out of one level of parentheses (or blocks).
1469With ARG, do this that many times.
1470A negative argument means move backward but still to a less deep spot.
1471This command assumes point is not in a string or comment."
1472 (interactive "^p")
1473 (or arg (setq arg 1))
1474 (python-nav-up-list (- arg)))
1475
1448 1476
1449;;; Shell integration 1477;;; Shell integration
1450 1478
@@ -1643,6 +1671,22 @@ uniqueness for different types of configurations."
1643OUTPUT is a string with the contents of the buffer." 1671OUTPUT is a string with the contents of the buffer."
1644 (ansi-color-filter-apply output)) 1672 (ansi-color-filter-apply output))
1645 1673
1674(defvar python-shell--parent-buffer nil)
1675
1676(defvar python-shell-output-syntax-table
1677 (let ((table (make-syntax-table python-dotty-syntax-table)))
1678 (modify-syntax-entry ?\' "." table)
1679 (modify-syntax-entry ?\" "." table)
1680 (modify-syntax-entry ?\( "." table)
1681 (modify-syntax-entry ?\[ "." table)
1682 (modify-syntax-entry ?\{ "." table)
1683 (modify-syntax-entry ?\) "." table)
1684 (modify-syntax-entry ?\] "." table)
1685 (modify-syntax-entry ?\} "." table)
1686 table)
1687 "Syntax table for shell output.
1688It makes parens and quotes be treated as punctuation chars.")
1689
1646(define-derived-mode inferior-python-mode comint-mode "Inferior Python" 1690(define-derived-mode inferior-python-mode comint-mode "Inferior Python"
1647 "Major mode for Python inferior process. 1691 "Major mode for Python inferior process.
1648Runs a Python interpreter as a subprocess of Emacs, with Python 1692Runs a Python interpreter as a subprocess of Emacs, with Python
@@ -1665,7 +1709,12 @@ initialization of the interpreter via `python-shell-setup-codes'
1665variable. 1709variable.
1666 1710
1667\(Type \\[describe-mode] in the process buffer for a list of commands.)" 1711\(Type \\[describe-mode] in the process buffer for a list of commands.)"
1668 (set-syntax-table python-mode-syntax-table) 1712 (and python-shell--parent-buffer
1713 (python-util-clone-local-variables python-shell--parent-buffer))
1714 (setq comint-prompt-regexp (format "^\\(?:%s\\|%s\\|%s\\)"
1715 python-shell-prompt-regexp
1716 python-shell-prompt-block-regexp
1717 python-shell-prompt-pdb-regexp))
1669 (setq mode-line-process '(":%s")) 1718 (setq mode-line-process '(":%s"))
1670 (make-local-variable 'comint-output-filter-functions) 1719 (make-local-variable 'comint-output-filter-functions)
1671 (add-hook 'comint-output-filter-functions 1720 (add-hook 'comint-output-filter-functions
@@ -1686,10 +1735,21 @@ variable.
1686 (make-local-variable 'python-pdbtrack-tracked-buffer) 1735 (make-local-variable 'python-pdbtrack-tracked-buffer)
1687 (make-local-variable 'python-shell-internal-last-output) 1736 (make-local-variable 'python-shell-internal-last-output)
1688 (when python-shell-enable-font-lock 1737 (when python-shell-enable-font-lock
1738 (set-syntax-table python-mode-syntax-table)
1689 (set (make-local-variable 'font-lock-defaults) 1739 (set (make-local-variable 'font-lock-defaults)
1690 '(python-font-lock-keywords nil nil nil nil)) 1740 '(python-font-lock-keywords nil nil nil nil))
1691 (set (make-local-variable 'syntax-propertize-function) 1741 (set (make-local-variable 'syntax-propertize-function)
1692 python-syntax-propertize-function)) 1742 (syntax-propertize-rules
1743 (comint-prompt-regexp
1744 (0 (ignore
1745 (put-text-property
1746 comint-last-input-start end 'syntax-table
1747 python-shell-output-syntax-table)
1748 (font-lock-unfontify-region comint-last-input-start end))))
1749 ((python-rx string-delimiter)
1750 (0 (ignore
1751 (and (not (eq (get-text-property start 'field) 'output))
1752 (python-syntax-stringify))))))))
1693 (compilation-shell-minor-mode 1)) 1753 (compilation-shell-minor-mode 1))
1694 1754
1695(defun python-shell-make-comint (cmd proc-name &optional pop internal) 1755(defun python-shell-make-comint (cmd proc-name &optional pop internal)
@@ -1712,15 +1772,10 @@ killed."
1712 (let* ((cmdlist (split-string-and-unquote cmd)) 1772 (let* ((cmdlist (split-string-and-unquote cmd))
1713 (buffer (apply #'make-comint-in-buffer proc-name proc-buffer-name 1773 (buffer (apply #'make-comint-in-buffer proc-name proc-buffer-name
1714 (car cmdlist) nil (cdr cmdlist))) 1774 (car cmdlist) nil (cdr cmdlist)))
1715 (current-buffer (current-buffer)) 1775 (python-shell--parent-buffer (current-buffer))
1716 (process (get-buffer-process buffer))) 1776 (process (get-buffer-process buffer)))
1717 (with-current-buffer buffer 1777 (with-current-buffer buffer
1718 (inferior-python-mode) 1778 (inferior-python-mode))
1719 (python-util-clone-local-variables current-buffer)
1720 (setq comint-prompt-regexp (format "^\\(?:%s\\|%s\\|%s\\)"
1721 python-shell-prompt-regexp
1722 python-shell-prompt-block-regexp
1723 python-shell-prompt-pdb-regexp)))
1724 (accept-process-output process) 1779 (accept-process-output process)
1725 (and pop (pop-to-buffer buffer t)) 1780 (and pop (pop-to-buffer buffer t))
1726 (and internal (set-process-query-on-exit-flag process nil)))) 1781 (and internal (set-process-query-on-exit-flag process nil))))
@@ -1875,7 +1930,9 @@ detecting a prompt at the end of the buffer."
1875 python-shell-output-filter-buffer 1930 python-shell-output-filter-buffer
1876 (concat python-shell-output-filter-buffer string)) 1931 (concat python-shell-output-filter-buffer string))
1877 (when (string-match 1932 (when (string-match
1878 (format "\n\\(?:%s\\|%s\\|%s\\)$" 1933 ;; XXX: It seems on OSX an extra carriage return is attached
1934 ;; at the end of output, this handles that too.
1935 (format "\r?\n\\(?:%s\\|%s\\|%s\\)$"
1879 python-shell-prompt-regexp 1936 python-shell-prompt-regexp
1880 python-shell-prompt-block-regexp 1937 python-shell-prompt-block-regexp
1881 python-shell-prompt-pdb-regexp) 1938 python-shell-prompt-pdb-regexp)
@@ -2279,28 +2336,28 @@ inferior python process is updated properly."
2279 2336
2280(defcustom python-fill-comment-function 'python-fill-comment 2337(defcustom python-fill-comment-function 'python-fill-comment
2281 "Function to fill comments. 2338 "Function to fill comments.
2282This is the function used by `python-fill-paragraph-function' to 2339This is the function used by `python-fill-paragraph' to
2283fill comments." 2340fill comments."
2284 :type 'symbol 2341 :type 'symbol
2285 :group 'python) 2342 :group 'python)
2286 2343
2287(defcustom python-fill-string-function 'python-fill-string 2344(defcustom python-fill-string-function 'python-fill-string
2288 "Function to fill strings. 2345 "Function to fill strings.
2289This is the function used by `python-fill-paragraph-function' to 2346This is the function used by `python-fill-paragraph' to
2290fill strings." 2347fill strings."
2291 :type 'symbol 2348 :type 'symbol
2292 :group 'python) 2349 :group 'python)
2293 2350
2294(defcustom python-fill-decorator-function 'python-fill-decorator 2351(defcustom python-fill-decorator-function 'python-fill-decorator
2295 "Function to fill decorators. 2352 "Function to fill decorators.
2296This is the function used by `python-fill-paragraph-function' to 2353This is the function used by `python-fill-paragraph' to
2297fill decorators." 2354fill decorators."
2298 :type 'symbol 2355 :type 'symbol
2299 :group 'python) 2356 :group 'python)
2300 2357
2301(defcustom python-fill-paren-function 'python-fill-paren 2358(defcustom python-fill-paren-function 'python-fill-paren
2302 "Function to fill parens. 2359 "Function to fill parens.
2303This is the function used by `python-fill-paragraph-function' to 2360This is the function used by `python-fill-paragraph' to
2304fill parens." 2361fill parens."
2305 :type 'symbol 2362 :type 'symbol
2306 :group 'python) 2363 :group 'python)
@@ -2377,7 +2434,7 @@ SYMMETRIC:
2377 :safe (lambda (val) 2434 :safe (lambda (val)
2378 (memq val '(django onetwo pep-257 pep-257-nn symmetric nil)))) 2435 (memq val '(django onetwo pep-257 pep-257-nn symmetric nil))))
2379 2436
2380(defun python-fill-paragraph-function (&optional justify) 2437(defun python-fill-paragraph (&optional justify)
2381 "`fill-paragraph-function' handling multi-line strings and possibly comments. 2438 "`fill-paragraph-function' handling multi-line strings and possibly comments.
2382If any of the current line is in or at the end of a multi-line string, 2439If any of the current line is in or at the end of a multi-line string,
2383fill the string or the paragraph of it that point is in, preserving 2440fill the string or the paragraph of it that point is in, preserving
@@ -2396,8 +2453,7 @@ Optional argument JUSTIFY defines if the paragraph should be justified."
2396 (funcall python-fill-string-function justify)) 2453 (funcall python-fill-string-function justify))
2397 ;; Decorators 2454 ;; Decorators
2398 ((equal (char-after (save-excursion 2455 ((equal (char-after (save-excursion
2399 (back-to-indentation) 2456 (python-nav-beginning-of-statement))) ?@)
2400 (point))) ?@)
2401 (funcall python-fill-decorator-function justify)) 2457 (funcall python-fill-decorator-function justify))
2402 ;; Parens 2458 ;; Parens
2403 ((or (python-syntax-context 'paren) 2459 ((or (python-syntax-context 'paren)
@@ -2409,12 +2465,12 @@ Optional argument JUSTIFY defines if the paragraph should be justified."
2409 (t t)))) 2465 (t t))))
2410 2466
2411(defun python-fill-comment (&optional justify) 2467(defun python-fill-comment (&optional justify)
2412 "Comment fill function for `python-fill-paragraph-function'. 2468 "Comment fill function for `python-fill-paragraph'.
2413JUSTIFY should be used (if applicable) as in `fill-paragraph'." 2469JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2414 (fill-comment-paragraph justify)) 2470 (fill-comment-paragraph justify))
2415 2471
2416(defun python-fill-string (&optional justify) 2472(defun python-fill-string (&optional justify)
2417 "String fill function for `python-fill-paragraph-function'. 2473 "String fill function for `python-fill-paragraph'.
2418JUSTIFY should be used (if applicable) as in `fill-paragraph'." 2474JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2419 (let* ((marker (point-marker)) 2475 (let* ((marker (point-marker))
2420 (str-start-pos 2476 (str-start-pos
@@ -2484,12 +2540,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2484 (indent-according-to-mode))))) t) 2540 (indent-according-to-mode))))) t)
2485 2541
2486(defun python-fill-decorator (&optional justify) 2542(defun python-fill-decorator (&optional justify)
2487 "Decorator fill function for `python-fill-paragraph-function'. 2543 "Decorator fill function for `python-fill-paragraph'.
2488JUSTIFY should be used (if applicable) as in `fill-paragraph'." 2544JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2489 t) 2545 t)
2490 2546
2491(defun python-fill-paren (&optional justify) 2547(defun python-fill-paren (&optional justify)
2492 "Paren fill function for `python-fill-paragraph-function'. 2548 "Paren fill function for `python-fill-paragraph'.
2493JUSTIFY should be used (if applicable) as in `fill-paragraph'." 2549JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2494 (save-restriction 2550 (save-restriction
2495 (narrow-to-region (progn 2551 (narrow-to-region (progn
@@ -2879,12 +2935,43 @@ parent defun name."
2879 ".") ".") 2935 ".") ".")
2880 name))))))) 2936 name)))))))
2881 2937
2882(defsubst python-info-beginning-of-block-statement-p () 2938(defun python-info-statement-starts-block-p ()
2883 "Return non-nil if current statement opens a block." 2939 "Return non-nil if current statement opens a block."
2884 (save-excursion 2940 (save-excursion
2885 (python-nav-beginning-of-statement) 2941 (python-nav-beginning-of-statement)
2886 (looking-at (python-rx block-start)))) 2942 (looking-at (python-rx block-start))))
2887 2943
2944(defun python-info-statement-ends-block-p ()
2945 "Return non-nil if point is at end of block."
2946 (let ((end-of-block-pos (save-excursion
2947 (python-nav-end-of-block)))
2948 (end-of-statement-pos (save-excursion
2949 (python-nav-end-of-statement))))
2950 (and end-of-block-pos end-of-statement-pos
2951 (= end-of-block-pos end-of-statement-pos))))
2952
2953(defun python-info-beginning-of-statement-p ()
2954 "Return non-nil if point is at beginning of statement."
2955 (= (point) (save-excursion
2956 (python-nav-beginning-of-statement)
2957 (point))))
2958
2959(defun python-info-end-of-statement-p ()
2960 "Return non-nil if point is at end of statement."
2961 (= (point) (save-excursion
2962 (python-nav-end-of-statement)
2963 (point))))
2964
2965(defun python-info-beginning-of-block-p ()
2966 "Return non-nil if point is at beginning of block."
2967 (and (python-info-beginning-of-statement-p)
2968 (python-info-statement-starts-block-p)))
2969
2970(defun python-info-end-of-block-p ()
2971 "Return non-nil if point is at end of block."
2972 (and (python-info-end-of-statement-p)
2973 (python-info-statement-ends-block-p)))
2974
2888(defun python-info-closing-block () 2975(defun python-info-closing-block ()
2889 "Return the point of the block the current line closes." 2976 "Return the point of the block the current line closes."
2890 (let ((closing-word (save-excursion 2977 (let ((closing-word (save-excursion
@@ -3109,7 +3196,7 @@ if that value is non-nil."
3109 3196
3110 (set (make-local-variable 'paragraph-start) "\\s-*$") 3197 (set (make-local-variable 'paragraph-start) "\\s-*$")
3111 (set (make-local-variable 'fill-paragraph-function) 3198 (set (make-local-variable 'fill-paragraph-function)
3112 'python-fill-paragraph-function) 3199 'python-fill-paragraph)
3113 3200
3114 (set (make-local-variable 'beginning-of-defun-function) 3201 (set (make-local-variable 'beginning-of-defun-function)
3115 #'python-beginning-of-defun-function) 3202 #'python-beginning-of-defun-function)
diff --git a/lisp/select.el b/lisp/select.el
index d3153a0ce0e..54520704261 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -248,7 +248,17 @@ two markers or an overlay. Otherwise, it is nil."
248 (setq non-unicode t) 248 (setq non-unicode t)
249 (setq eight-bit t))))) 249 (setq eight-bit t)))))
250 str) 250 str)
251 (setq type (if non-unicode 'COMPOUND_TEXT 251 (setq type (if (or non-unicode
252 (and
253 non-latin-1
254 ;; If a coding is specified for
255 ;; selection, and that is
256 ;; compatible with COMPOUND_TEXT,
257 ;; use it.
258 coding
259 (eq (coding-system-get coding :mime-charset)
260 'x-ctext)))
261 'COMPOUND_TEXT
252 (if non-latin-1 'UTF8_STRING 262 (if non-latin-1 'UTF8_STRING
253 (if eight-bit 'C_STRING 263 (if eight-bit 'C_STRING
254 'STRING)))))))) 264 'STRING))))))))
diff --git a/lisp/server.el b/lisp/server.el
index 73c253a87a6..7a356a90378 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -833,35 +833,40 @@ This handles splitting the command if it would be bigger than
833 833
834(defun server-create-window-system-frame (display nowait proc parent-id 834(defun server-create-window-system-frame (display nowait proc parent-id
835 &optional parameters) 835 &optional parameters)
836 (add-to-list 'frame-inherited-parameters 'client) 836 (let* ((display (or display
837 (if (not (fboundp 'make-frame-on-display)) 837 (frame-parameter nil 'display)
838 (progn 838 (error "Please specify display.")))
839 ;; This emacs does not support X. 839 (w (or (cdr (assq 'window-system parameters))
840 (server-log "Window system unsupported" proc) 840 (window-system-for-display display))))
841 (server-send-string proc "-window-system-unsupported \n") 841
842 nil) 842 (unless (assq w window-system-initialization-alist)
843 ;; Flag frame as client-created, but use a dummy client. 843 (setq w nil))
844 ;; This will prevent the frame from being deleted when 844
845 ;; emacsclient quits while also preventing 845 (cond (w
846 ;; `server-save-buffers-kill-terminal' from unexpectedly 846 ;; Flag frame as client-created, but use a dummy client.
847 ;; killing emacs on that frame. 847 ;; This will prevent the frame from being deleted when
848 (let* ((params `((client . ,(if nowait 'nowait proc)) 848 ;; emacsclient quits while also preventing
849 ;; This is a leftover, see above. 849 ;; `server-save-buffers-kill-terminal' from unexpectedly
850 (environment . ,(process-get proc 'env)) 850 ;; killing emacs on that frame.
851 ,@parameters)) 851 (let* ((params `((client . ,(if nowait 'nowait proc))
852 (display (or display 852 ;; This is a leftover, see above.
853 (frame-parameter nil 'display) 853 (environment . ,(process-get proc 'env))
854 (getenv "DISPLAY") 854 ,@parameters))
855 (error "Please specify display"))) 855 frame)
856 frame) 856 (if parent-id
857 (if parent-id 857 (push (cons 'parent-id (string-to-number parent-id)) params))
858 (push (cons 'parent-id (string-to-number parent-id)) params)) 858 (add-to-list 'frame-inherited-parameters 'client)
859 (setq frame (make-frame-on-display display params)) 859 (setq frame (make-frame-on-display display params))
860 (server-log (format "%s created" frame) proc) 860 (server-log (format "%s created" frame) proc)
861 (select-frame frame) 861 (select-frame frame)
862 (process-put proc 'frame frame) 862 (process-put proc 'frame frame)
863 (process-put proc 'terminal (frame-terminal frame)) 863 (process-put proc 'terminal (frame-terminal frame))
864 frame))) 864 frame))
865
866 (t
867 (server-log "Window system unsupported" proc)
868 (server-send-string proc "-window-system-unsupported \n")
869 nil))))
865 870
866(defun server-goto-toplevel (proc) 871(defun server-goto-toplevel (proc)
867 (condition-case nil 872 (condition-case nil
@@ -1121,9 +1126,13 @@ The following commands are accepted by the client:
1121 tty-type (pop args-left) 1126 tty-type (pop args-left)
1122 dontkill (or dontkill 1127 dontkill (or dontkill
1123 (not use-current-frame))) 1128 (not use-current-frame)))
1124 ;; On Windows, emacsclient always asks for a tty frame. 1129 ;; On Windows, emacsclient always asks for a tty
1125 ;; If running a GUI server, force the frame type to GUI. 1130 ;; frame. If running a GUI server, force the frame
1126 (when (eq window-system 'w32) 1131 ;; type to GUI. (Cygwin is perfectly happy with
1132 ;; multi-tty support, so don't override the user's
1133 ;; choice there.)
1134 (when (and (eq system-type 'windows-nt)
1135 (eq window-system 'w32))
1127 (push "-window-system" args-left))) 1136 (push "-window-system" args-left)))
1128 1137
1129 ;; -position LINE[:COLUMN]: Set point to the given 1138 ;; -position LINE[:COLUMN]: Set point to the given
diff --git a/lisp/simple.el b/lisp/simple.el
index 616a4d7b1ea..aed945d6e13 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6872,7 +6872,7 @@ call `normal-erase-is-backspace-mode' (which see) instead."
6872 (if (if (eq normal-erase-is-backspace 'maybe) 6872 (if (if (eq normal-erase-is-backspace 'maybe)
6873 (and (not noninteractive) 6873 (and (not noninteractive)
6874 (or (memq system-type '(ms-dos windows-nt)) 6874 (or (memq system-type '(ms-dos windows-nt))
6875 (memq window-system '(ns)) 6875 (memq window-system '(w32 ns))
6876 (and (memq window-system '(x)) 6876 (and (memq window-system '(x))
6877 (fboundp 'x-backspace-delete-keys-p) 6877 (fboundp 'x-backspace-delete-keys-p)
6878 (x-backspace-delete-keys-p)) 6878 (x-backspace-delete-keys-p))
diff --git a/lisp/startup.el b/lisp/startup.el
index 6658e16683b..bd75abe5b35 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -890,7 +890,8 @@ Amongst another things, it parses the command-line arguments."
890 ;; Initialize the window system. (Open connection, etc.) 890 ;; Initialize the window system. (Open connection, etc.)
891 (funcall 891 (funcall
892 (or (cdr (assq initial-window-system window-system-initialization-alist)) 892 (or (cdr (assq initial-window-system window-system-initialization-alist))
893 (error "Unsupported window system `%s'" initial-window-system)))) 893 (error "Unsupported window system `%s'" initial-window-system)))
894 (put initial-window-system 'window-system-initialized t))
894 ;; If there was an error, print the error message and exit. 895 ;; If there was an error, print the error message and exit.
895 (error 896 (error
896 (princ 897 (princ
diff --git a/lisp/subr.el b/lisp/subr.el
index e438a860cbc..ec2d16e6529 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2143,7 +2143,9 @@ any other non-digit terminates the character code and is then used as input."))
2143 (setq first nil)) 2143 (setq first nil))
2144 code)) 2144 code))
2145 2145
2146(defconst read-passwd-map 2146(defvar read-passwd-map
2147 ;; BEWARE: `defconst' would purecopy it, breaking the sharing with
2148 ;; minibuffer-local-map along the way!
2147 (let ((map (make-sparse-keymap))) 2149 (let ((map (make-sparse-keymap)))
2148 (set-keymap-parent map minibuffer-local-map) 2150 (set-keymap-parent map minibuffer-local-map)
2149 (define-key map "\C-u" #'delete-minibuffer-contents) ;bug#12570 2151 (define-key map "\C-u" #'delete-minibuffer-contents) ;bug#12570
@@ -2186,7 +2188,9 @@ by doing (clear-string STRING)."
2186 (lambda () 2188 (lambda ()
2187 (setq minibuf (current-buffer)) 2189 (setq minibuf (current-buffer))
2188 ;; Turn off electricity. 2190 ;; Turn off electricity.
2189 (set (make-local-variable 'post-self-insert-hook) nil) 2191 (setq-local post-self-insert-hook nil)
2192 (setq-local buffer-undo-list t)
2193 (setq-local select-active-regions nil)
2190 (use-local-map read-passwd-map) 2194 (use-local-map read-passwd-map)
2191 (add-hook 'after-change-functions hide-chars-fun nil 'local)) 2195 (add-hook 'after-change-functions hide-chars-fun nil 'local))
2192 (unwind-protect 2196 (unwind-protect
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 067b996d1ff..b44e092cc0a 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -57,7 +57,7 @@ clipboard as well.
57 57
58On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard' 58On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard'
59is not used)." 59is not used)."
60 (cond ((eq system-type 'windows-nt) 60 (cond ((eq (framep (selected-frame)) 'w32)
61 (if x-select-enable-clipboard 61 (if x-select-enable-clipboard
62 (w32-set-clipboard-data text)) 62 (w32-set-clipboard-data text))
63 (setq x-last-selected-text text)) 63 (setq x-last-selected-text text))
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index c229ec14dd5..e31362b8313 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -39,7 +39,7 @@
39;; this file, which works in close coordination with src/nsfns.m. 39;; this file, which works in close coordination with src/nsfns.m.
40 40
41;;; Code: 41;;; Code:
42 42(eval-when-compile (require 'cl-lib))
43(or (featurep 'ns) 43(or (featurep 'ns)
44 (error "%s: Loading ns-win.el but not compiled for GNUstep/MacOS" 44 (error "%s: Loading ns-win.el but not compiled for GNUstep/MacOS"
45 (invocation-name))) 45 (invocation-name)))
@@ -448,7 +448,7 @@ Lines are highlighted according to `ns-input-line'."
448;; nsterm.m 448;; nsterm.m
449 449
450(declare-function ns-read-file-name "nsfns.m" 450(declare-function ns-read-file-name "nsfns.m"
451 (prompt &optional dir isLoad init)) 451 (prompt &optional dir mustmatch init dir_only_p))
452 452
453;;;; File handling. 453;;;; File handling.
454 454
@@ -633,8 +633,9 @@ This function has been overloaded in Nextstep.")
633`ns-input-fontsize' of new font." 633`ns-input-fontsize' of new font."
634 (interactive) 634 (interactive)
635 (modify-frame-parameters (selected-frame) 635 (modify-frame-parameters (selected-frame)
636 (list (cons 'font ns-input-font) 636 (list (cons 'fontsize ns-input-fontsize)))
637 (cons 'fontsize ns-input-fontsize))) 637 (modify-frame-parameters (selected-frame)
638 (list (cons 'font ns-input-font)))
638 (set-frame-font ns-input-font)) 639 (set-frame-font ns-input-font))
639 640
640 641
@@ -908,6 +909,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
908;; defines functions and variables that we use now. 909;; defines functions and variables that we use now.
909(defun ns-initialize-window-system () 910(defun ns-initialize-window-system ()
910 "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing." 911 "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
912 (cl-assert (not ns-initialized))
911 913
912 ;; PENDING: not needed? 914 ;; PENDING: not needed?
913 (setq command-line-args (x-handle-args command-line-args)) 915 (setq command-line-args (x-handle-args command-line-args))
@@ -935,6 +937,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
935 (x-apply-session-resources) 937 (x-apply-session-resources)
936 (setq ns-initialized t)) 938 (setq ns-initialized t))
937 939
940(add-to-list 'display-format-alist '("\\`ns\\'" . ns))
938(add-to-list 'handle-args-function-alist '(ns . x-handle-args)) 941(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
939(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces)) 942(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
940(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system)) 943(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index a4fac3441db..ad6e1125027 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -1,4 +1,4 @@
1;;; w32-win.el --- parse switches controlling interface with W32 window system 1;;; w32-win.el --- parse switches controlling interface with W32 window system -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
4 4
@@ -68,6 +68,7 @@
68;; (if (not (eq window-system 'w32)) 68;; (if (not (eq window-system 'w32))
69;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name))) 69;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
70 70
71(eval-when-compile (require 'cl-lib))
71(require 'frame) 72(require 'frame)
72(require 'mouse) 73(require 'mouse)
73(require 'scroll-bar) 74(require 'scroll-bar)
@@ -88,7 +89,7 @@
88(make-obsolete 'w32-default-color-map nil "24.1") 89(make-obsolete 'w32-default-color-map nil "24.1")
89 90
90(declare-function w32-send-sys-command "w32fns.c") 91(declare-function w32-send-sys-command "w32fns.c")
91(declare-function set-message-beep "w32console.c") 92(declare-function set-message-beep "w32fns.c")
92 93
93;; Conditional on new-fontset so bootstrapping works on non-GUI compiles 94;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
94(if (fboundp 'new-fontset) 95(if (fboundp 'new-fontset)
@@ -102,7 +103,22 @@
102;; (interactive "e") 103;; (interactive "e")
103;; (princ event)) 104;; (princ event))
104 105
105(defun w32-drag-n-drop (event) 106(defun w32-handle-dropped-file (window file-name)
107 (let ((f (if (eq system-type 'cygwin)
108 (cygwin-convert-path-from-windows file-name t)
109 (subst-char-in-string ?\\ ?/ file-name)))
110 (coding (or file-name-coding-system
111 default-file-name-coding-system)))
112
113 (setq file-name
114 (mapconcat 'url-hexify-string
115 (split-string (encode-coding-string f coding)
116 "/")
117 "/")))
118 (dnd-handle-one-url window 'private
119 (concat "file:" file-name)))
120
121(defun w32-drag-n-drop (event &optional new-frame)
106 "Edit the files listed in the drag-n-drop EVENT. 122 "Edit the files listed in the drag-n-drop EVENT.
107Switch to a buffer editing the last file dropped." 123Switch to a buffer editing the last file dropped."
108 (interactive "e") 124 (interactive "e")
@@ -116,26 +132,21 @@ Switch to a buffer editing the last file dropped."
116 (y (cdr coords))) 132 (y (cdr coords)))
117 (if (and (> x 0) (> y 0)) 133 (if (and (> x 0) (> y 0))
118 (set-frame-selected-window nil window)) 134 (set-frame-selected-window nil window))
119 (mapc (lambda (file-name) 135
120 (let ((f (subst-char-in-string ?\\ ?/ file-name)) 136 (when new-frame
121 (coding (or file-name-coding-system 137 (select-frame (make-frame)))
122 default-file-name-coding-system))) 138 (raise-frame)
123 (setq file-name 139 (setq window (selected-window))
124 (mapconcat 'url-hexify-string 140
125 (split-string (encode-coding-string f coding) 141 (mapc (apply-partially #'w32-handle-dropped-file window)
126 "/") 142 (car (cdr (cdr event)))))))
127 "/")))
128 (dnd-handle-one-url window 'private
129 (concat "file:" file-name)))
130 (car (cdr (cdr event)))))
131 (raise-frame)))
132 143
133(defun w32-drag-n-drop-other-frame (event) 144(defun w32-drag-n-drop-other-frame (event)
134 "Edit the files listed in the drag-n-drop EVENT, in other frames. 145 "Edit the files listed in the drag-n-drop EVENT, in other frames.
135May create new frames, or reuse existing ones. The frame editing 146May create new frames, or reuse existing ones. The frame editing
136the last file dropped is selected." 147the last file dropped is selected."
137 (interactive "e") 148 (interactive "e")
138 (mapcar 'find-file-other-frame (car (cdr (cdr event))))) 149 (w32-drag-n-drop event t))
139 150
140;; Bind the drag-n-drop event. 151;; Bind the drag-n-drop event.
141(global-set-key [drag-n-drop] 'w32-drag-n-drop) 152(global-set-key [drag-n-drop] 'w32-drag-n-drop)
@@ -230,6 +241,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
230 241
231(defun w32-initialize-window-system () 242(defun w32-initialize-window-system ()
232 "Initialize Emacs for W32 GUI frames." 243 "Initialize Emacs for W32 GUI frames."
244 (cl-assert (not w32-initialized))
233 245
234 ;; Do the actual Windows setup here; the above code just defines 246 ;; Do the actual Windows setup here; the above code just defines
235 ;; functions and variables that we use now. 247 ;; functions and variables that we use now.
@@ -243,7 +255,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
243 ;; so as not to choke when we use it in X resource queries. 255 ;; so as not to choke when we use it in X resource queries.
244 (replace-regexp-in-string "[.*]" "-" (invocation-name)))) 256 (replace-regexp-in-string "[.*]" "-" (invocation-name))))
245 257
246 (x-open-connection "" x-command-line-resources 258 (x-open-connection "w32" x-command-line-resources
247 ;; Exit with a fatal error if this fails and we 259 ;; Exit with a fatal error if this fails and we
248 ;; are the initial display 260 ;; are the initial display
249 (eq initial-window-system 'w32)) 261 (eq initial-window-system 'w32))
@@ -294,7 +306,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
294 (setq default-frame-alist 306 (setq default-frame-alist
295 (cons '(reverse . t) default-frame-alist))))) 307 (cons '(reverse . t) default-frame-alist)))))
296 308
297 ;; Don't let Emacs suspend under w32 gui 309 ;; Don't let Emacs suspend under Windows.
298 (add-hook 'suspend-hook 'x-win-suspend-error) 310 (add-hook 'suspend-hook 'x-win-suspend-error)
299 311
300 ;; Turn off window-splitting optimization; w32 is usually fast enough 312 ;; Turn off window-splitting optimization; w32 is usually fast enough
@@ -312,6 +324,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
312 (x-apply-session-resources) 324 (x-apply-session-resources)
313 (setq w32-initialized t)) 325 (setq w32-initialized t))
314 326
327(add-to-list 'display-format-alist '("\\`w32\\'" . w32))
315(add-to-list 'handle-args-function-alist '(w32 . x-handle-args)) 328(add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
316(add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces)) 329(add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
317(add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system)) 330(add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system))
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 9b7254cd132..2f2125a31db 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -67,6 +67,8 @@
67;; An alist of X options and the function which handles them. See 67;; An alist of X options and the function which handles them. See
68;; ../startup.el. 68;; ../startup.el.
69 69
70(eval-when-compile (require 'cl-lib))
71
70(if (not (fboundp 'x-create-frame)) 72(if (not (fboundp 'x-create-frame))
71 (error "%s: Loading x-win.el but not compiled for X" (invocation-name))) 73 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
72 74
@@ -1338,6 +1340,8 @@ Request data types in the order specified by `x-select-request-type'."
1338 1340
1339(defun x-initialize-window-system () 1341(defun x-initialize-window-system ()
1340 "Initialize Emacs for X frames and open the first connection to an X server." 1342 "Initialize Emacs for X frames and open the first connection to an X server."
1343 (cl-assert (not x-initialized))
1344
1341 ;; Make sure we have a valid resource name. 1345 ;; Make sure we have a valid resource name.
1342 (or (stringp x-resource-name) 1346 (or (stringp x-resource-name)
1343 (let (i) 1347 (let (i)
@@ -1451,6 +1455,7 @@ Request data types in the order specified by `x-select-request-type'."
1451 (x-apply-session-resources) 1455 (x-apply-session-resources)
1452 (setq x-initialized t)) 1456 (setq x-initialized t))
1453 1457
1458(add-to-list 'display-format-alist '("\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" . x))
1454(add-to-list 'handle-args-function-alist '(x . x-handle-args)) 1459(add-to-list 'handle-args-function-alist '(x . x-handle-args))
1455(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces)) 1460(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
1456(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system)) 1461(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el
index f2c74dfb941..b0adb35f768 100644
--- a/lisp/textmodes/rst.el
+++ b/lisp/textmodes/rst.el
@@ -218,7 +218,7 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match."
218;; Use CVSHeader to really get information from CVS and not other version 218;; Use CVSHeader to really get information from CVS and not other version
219;; control systems. 219;; control systems.
220(defconst rst-cvs-header 220(defconst rst-cvs-header
221 "$CVSHeader: sm/rst_el/rst.el,v 1.327.2.5 2012-10-07 12:44:34 stefan Exp $") 221 "$CVSHeader: sm/rst_el/rst.el,v 1.327.2.6 2012-10-07 13:05:50 stefan Exp $")
222(defconst rst-cvs-rev 222(defconst rst-cvs-rev
223 (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+" 223 (rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+"
224 " .*" rst-cvs-header "0.0") 224 " .*" rst-cvs-header "0.0")
@@ -247,7 +247,7 @@ SVN revision is the upstream (docutils) revision.")
247 "Official version of the package.") 247 "Official version of the package.")
248(defconst rst-official-cvs-rev 248(defconst rst-official-cvs-rev
249 (rst-extract-version "[%$]" "Revision: " "[0-9]+\\(?:\\.[0-9]+\\)+" " " 249 (rst-extract-version "[%$]" "Revision: " "[0-9]+\\(?:\\.[0-9]+\\)+" " "
250 "$Revision: 1.327.2.5 $") 250 "%Revision: 1.327 %")
251 "CVS revision of this file in the official version.") 251 "CVS revision of this file in the official version.")
252 252
253(defconst rst-version 253(defconst rst-version
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index a324daa9283..062f43be57b 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -2565,8 +2565,7 @@ line LINE of the window, or centered if LINE is nil."
2565 (if (null tex-shell) 2565 (if (null tex-shell)
2566 (message "No TeX output buffer") 2566 (message "No TeX output buffer")
2567 (setq window (display-buffer tex-shell)) 2567 (setq window (display-buffer tex-shell))
2568 (save-selected-window 2568 (with-selected-window window
2569 (select-window window)
2570 (bury-buffer tex-shell) 2569 (bury-buffer tex-shell)
2571 (goto-char (point-max)) 2570 (goto-char (point-max))
2572 (recenter (if linenum 2571 (recenter (if linenum
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 01248a91cf2..c7fc4fcbfe1 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,8 @@
12012-10-08 Glenn Morris <rgm@gnu.org>
2
3 * url-methods.el (url-scheme-get-property): url-https.el was
4 merged into url-http.el, so load the latter for https. (Bug#12599)
5
12012-10-02 Stefan Monnier <monnier@iro.umontreal.ca> 62012-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * url-http.el (url-http-user-agent-string): Leak less info. 8 * url-http.el (url-http-user-agent-string): Leak less info.
diff --git a/lisp/url/url-methods.el b/lisp/url/url-methods.el
index 26fe72014f7..3168d5aab3f 100644
--- a/lisp/url/url-methods.el
+++ b/lisp/url/url-methods.el
@@ -118,7 +118,9 @@ it has not already been loaded."
118 (let* ((stub (concat "url-" scheme)) 118 (let* ((stub (concat "url-" scheme))
119 (loader (intern stub))) 119 (loader (intern stub)))
120 (condition-case () 120 (condition-case ()
121 (require loader) 121 ;; url-https.el was merged into url-http because of 8+3
122 ;; filename limitations, so we have to do this dance.
123 (require (if (equal "https" scheme) 'url-http loader))
122 (error nil)) 124 (error nil))
123 (if (fboundp loader) 125 (if (fboundp loader)
124 (progn 126 (progn
diff --git a/lisp/w32-common-fns.el b/lisp/w32-common-fns.el
new file mode 100644
index 00000000000..fc045683394
--- /dev/null
+++ b/lisp/w32-common-fns.el
@@ -0,0 +1,130 @@
1;;; w32-common-fns.el --- Lisp routines for Windows and Cygwin-w32
2
3;; Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21;;;
22;;; This file contains functions that are used by both native NT Emacs
23;;; and Cygwin Emacs compiled to use the native Windows widget
24;;; library.
25
26(defun w32-version ()
27 "Return the MS-Windows version numbers.
28The value is a list of three integers: the major and minor version
29numbers, and the build number."
30 (x-server-version))
31
32(defun w32-using-nt ()
33 "Return non-nil if running on a Windows NT descendant.
34That includes all Windows systems except for 9X/Me."
35 (getenv "SystemRoot"))
36
37(declare-function w32-get-clipboard-data "w32select.c")
38(declare-function w32-set-clipboard-data "w32select.c")
39(declare-function x-server-version "w32fns.c" (&optional display))
40
41;;; Fix interface to (X-specific) mouse.el
42(defun x-set-selection (type data)
43 "Make an X selection of type TYPE and value DATA.
44The argument TYPE (nil means `PRIMARY') says which selection, and
45DATA specifies the contents. TYPE must be a symbol. \(It can also
46be a string, which stands for the symbol with that name, but this
47is considered obsolete.) DATA may be a string, a symbol, an
48integer (or a cons of two integers or list of two integers).
49
50The selection may also be a cons of two markers pointing to the same buffer,
51or an overlay. In these cases, the selection is considered to be the text
52between the markers *at whatever time the selection is examined*.
53Thus, editing done in the buffer after you specify the selection
54can alter the effective value of the selection.
55
56The data may also be a vector of valid non-vector selection values.
57
58The return value is DATA.
59
60Interactively, this command sets the primary selection. Without
61prefix argument, it reads the selection in the minibuffer. With
62prefix argument, it uses the text of the region as the selection value.
63
64Note that on MS-Windows, primary and secondary selections set by Emacs
65are not available to other programs."
66 (put 'x-selections (or type 'PRIMARY) data))
67
68(defun x-get-selection (&optional type _data-type)
69 "Return the value of an X Windows selection.
70The argument TYPE (default `PRIMARY') says which selection,
71and the argument DATA-TYPE (default `STRING') says
72how to convert the data.
73
74TYPE may be any symbol \(but nil stands for `PRIMARY'). However,
75only a few symbols are commonly used. They conventionally have
76all upper-case names. The most often used ones, in addition to
77`PRIMARY', are `SECONDARY' and `CLIPBOARD'.
78
79DATA-TYPE is usually `STRING', but can also be one of the symbols
80in `selection-converter-alist', which see."
81 (get 'x-selections (or type 'PRIMARY)))
82
83;; x-selection-owner-p is used in simple.el
84(defun x-selection-owner-p (&optional type)
85 (and (memq type '(nil PRIMARY SECONDARY))
86 (get 'x-selections (or type 'PRIMARY))))
87
88;; The "Windows" keys on newer keyboards bring up the Start menu
89;; whether you want it or not - make Emacs ignore these keystrokes
90;; rather than beep.
91(global-set-key [lwindow] 'ignore)
92(global-set-key [rwindow] 'ignore)
93
94(defvar w32-charset-info-alist) ; w32font.c
95
96
97;;;; Selections
98
99;; We keep track of the last text selected here, so we can check the
100;; current selection against it, and avoid passing back our own text
101;; from x-selection-value.
102(defvar x-last-selected-text nil)
103
104(defun x-get-selection-value ()
105 "Return the value of the current selection.
106Consult the selection. Treat empty strings as if they were unset."
107 (if x-select-enable-clipboard
108 (let (text)
109 ;; Don't die if x-get-selection signals an error.
110 (condition-case c
111 (setq text (w32-get-clipboard-data))
112 (error (message "w32-get-clipboard-data:%s" c)))
113 (if (string= text "") (setq text nil))
114 (cond
115 ((not text) nil)
116 ((eq text x-last-selected-text) nil)
117 ((string= text x-last-selected-text)
118 ;; Record the newer string, so subsequent calls can use the 'eq' test.
119 (setq x-last-selected-text text)
120 nil)
121 (t
122 (setq x-last-selected-text text))))))
123
124(defalias 'x-selection-value 'x-get-selection-value)
125
126;; Arrange for the kill and yank functions to set and check the clipboard.
127(setq interprogram-cut-function 'x-select-text)
128(setq interprogram-paste-function 'x-get-selection-value)
129
130(provide 'w32-common-fns)
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
index 1769ee73be5..5d9b68e9de5 100644
--- a/lisp/w32-fns.el
+++ b/lisp/w32-fns.el
@@ -26,34 +26,20 @@
26 26
27;;; Code: 27;;; Code:
28(require 'w32-vars) 28(require 'w32-vars)
29(require 'w32-common-fns)
29 30
30(defvar explicit-shell-file-name) 31(defvar explicit-shell-file-name)
31 32
32;;;; Function keys 33;;;; Function keys
33 34
34(declare-function set-message-beep "w32console.c") 35(declare-function set-message-beep "w32fns.c")
35(declare-function w32-get-clipboard-data "w32select.c")
36(declare-function w32-get-locale-info "w32proc.c") 36(declare-function w32-get-locale-info "w32proc.c")
37(declare-function w32-get-valid-locale-ids "w32proc.c") 37(declare-function w32-get-valid-locale-ids "w32proc.c")
38(declare-function w32-set-clipboard-data "w32select.c")
39 38
40;; Map all versions of a filename (8.3, longname, mixed case) to the 39;; Map all versions of a filename (8.3, longname, mixed case) to the
41;; same buffer. 40;; same buffer.
42(setq find-file-visit-truename t) 41(setq find-file-visit-truename t)
43 42
44(declare-function x-server-version "w32fns.c" (&optional display))
45
46(defun w32-version ()
47 "Return the MS-Windows version numbers.
48The value is a list of three integers: the major and minor version
49numbers, and the build number."
50 (x-server-version))
51
52(defun w32-using-nt ()
53 "Return non-nil if running on a Windows NT descendant.
54That includes all Windows systems except for 9X/Me."
55 (and (eq system-type 'windows-nt) (getenv "SystemRoot")))
56
57(defun w32-shell-name () 43(defun w32-shell-name ()
58 "Return the name of the shell being used." 44 "Return the name of the shell being used."
59 (or (bound-and-true-p shell-file-name) 45 (or (bound-and-true-p shell-file-name)
@@ -240,53 +226,6 @@ requires it (see `w32-shell-dos-semantics')."
240 (setq start (match-end 0)))) 226 (setq start (match-end 0))))
241 name))) 227 name)))
242 228
243;;; Fix interface to (X-specific) mouse.el
244(defun x-set-selection (type data)
245 "Make an X selection of type TYPE and value DATA.
246The argument TYPE (nil means `PRIMARY') says which selection, and
247DATA specifies the contents. TYPE must be a symbol. \(It can also
248be a string, which stands for the symbol with that name, but this
249is considered obsolete.) DATA may be a string, a symbol, an
250integer (or a cons of two integers or list of two integers).
251
252The selection may also be a cons of two markers pointing to the same buffer,
253or an overlay. In these cases, the selection is considered to be the text
254between the markers *at whatever time the selection is examined*.
255Thus, editing done in the buffer after you specify the selection
256can alter the effective value of the selection.
257
258The data may also be a vector of valid non-vector selection values.
259
260The return value is DATA.
261
262Interactively, this command sets the primary selection. Without
263prefix argument, it reads the selection in the minibuffer. With
264prefix argument, it uses the text of the region as the selection value.
265
266Note that on MS-Windows, primary and secondary selections set by Emacs
267are not available to other programs."
268 (put 'x-selections (or type 'PRIMARY) data))
269
270(defun x-get-selection (&optional type _data-type)
271 "Return the value of an X Windows selection.
272The argument TYPE (default `PRIMARY') says which selection,
273and the argument DATA-TYPE (default `STRING') says
274how to convert the data.
275
276TYPE may be any symbol \(but nil stands for `PRIMARY'). However,
277only a few symbols are commonly used. They conventionally have
278all upper-case names. The most often used ones, in addition to
279`PRIMARY', are `SECONDARY' and `CLIPBOARD'.
280
281DATA-TYPE is usually `STRING', but can also be one of the symbols
282in `selection-converter-alist', which see."
283 (get 'x-selections (or type 'PRIMARY)))
284
285;; x-selection-owner-p is used in simple.el
286(defun x-selection-owner-p (&optional type)
287 (and (memq type '(nil PRIMARY SECONDARY))
288 (get 'x-selections (or type 'PRIMARY))))
289
290(defun set-w32-system-coding-system (coding-system) 229(defun set-w32-system-coding-system (coding-system)
291 "Set the coding system used by the Windows system to CODING-SYSTEM. 230 "Set the coding system used by the Windows system to CODING-SYSTEM.
292This is used for things like passing font names with non-ASCII 231This is used for things like passing font names with non-ASCII
@@ -311,14 +250,6 @@ This function is provided for backward compatibility, since
311;; Set to a system sound if you want a fancy bell. 250;; Set to a system sound if you want a fancy bell.
312(set-message-beep nil) 251(set-message-beep nil)
313 252
314;; The "Windows" keys on newer keyboards bring up the Start menu
315;; whether you want it or not - make Emacs ignore these keystrokes
316;; rather than beep.
317(global-set-key [lwindow] 'ignore)
318(global-set-key [rwindow] 'ignore)
319
320(defvar w32-charset-info-alist) ; w32font.c
321
322(defun w32-add-charset-info (xlfd-charset windows-charset codepage) 253(defun w32-add-charset-info (xlfd-charset windows-charset codepage)
323 "Function to add character sets to display with Windows fonts. 254 "Function to add character sets to display with Windows fonts.
324Creates entries in `w32-charset-info-alist'. 255Creates entries in `w32-charset-info-alist'.
@@ -380,40 +311,6 @@ bit output with no translation."
380 'w32-charset-info-alist "21.1") 311 'w32-charset-info-alist "21.1")
381 312
382 313
383;;;; Selections
384
385;; We keep track of the last text selected here, so we can check the
386;; current selection against it, and avoid passing back our own text
387;; from x-selection-value.
388(defvar x-last-selected-text nil)
389
390(defun x-get-selection-value ()
391 "Return the value of the current selection.
392Consult the selection. Treat empty strings as if they were unset."
393 (if x-select-enable-clipboard
394 (let (text)
395 ;; Don't die if x-get-selection signals an error.
396 (condition-case c
397 (setq text (w32-get-clipboard-data))
398 (error (message "w32-get-clipboard-data:%s" c)))
399 (if (string= text "") (setq text nil))
400 (cond
401 ((not text) nil)
402 ((eq text x-last-selected-text) nil)
403 ((string= text x-last-selected-text)
404 ;; Record the newer string, so subsequent calls can use the 'eq' test.
405 (setq x-last-selected-text text)
406 nil)
407 (t
408 (setq x-last-selected-text text))))))
409
410(defalias 'x-selection-value 'x-get-selection-value)
411
412;; Arrange for the kill and yank functions to set and check the clipboard.
413(setq interprogram-cut-function 'x-select-text)
414(setq interprogram-paste-function 'x-get-selection-value)
415
416
417;;;; Support for build process 314;;;; Support for build process
418 315
419;; From autoload.el 316;; From autoload.el
diff --git a/lisp/w32-vars.el b/lisp/w32-vars.el
index c8716ef6c36..0e152b125bc 100644
--- a/lisp/w32-vars.el
+++ b/lisp/w32-vars.el
@@ -44,17 +44,19 @@ X does. See `w32-fixed-font-alist' for the font menu definition."
44 "Include proportional fonts in the default font dialog.") 44 "Include proportional fonts in the default font dialog.")
45(make-obsolete-variable 'w32-list-proportional-fonts "no longer used." "23.1") 45(make-obsolete-variable 'w32-list-proportional-fonts "no longer used." "23.1")
46 46
47(defcustom w32-allow-system-shell nil 47(unless (eq system-type 'cygwin)
48 "Disable startup warning when using \"system\" shells." 48 (defcustom w32-allow-system-shell nil
49 :type 'boolean 49 "Disable startup warning when using \"system\" shells."
50 :group 'w32) 50 :type 'boolean
51 51 :group 'w32))
52(defcustom w32-system-shells '("cmd" "cmd.exe" "command" "command.com" 52
53 "4nt" "4nt.exe" "4dos" "4dos.exe" 53(unless (eq system-type 'cygwin)
54 "tcc" "tcc.exe" "ndos" "ndos.exe") 54 (defcustom w32-system-shells '("cmd" "cmd.exe" "command" "command.com"
55 "List of strings recognized as Windows system shells." 55 "4nt" "4nt.exe" "4dos" "4dos.exe"
56 :type '(repeat string) 56 "tcc" "tcc.exe" "ndos" "ndos.exe")
57 :group 'w32) 57 "List of strings recognized as Windows system shells."
58 :type '(repeat string)
59 :group 'w32))
58 60
59;; Want "menu" custom type for this. 61;; Want "menu" custom type for this.
60(defcustom w32-fixed-font-alist 62(defcustom w32-fixed-font-alist
diff --git a/lisp/window.el b/lisp/window.el
index 41af7f9f44b..b033f9c26e3 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -28,6 +28,35 @@
28 28
29;;; Code: 29;;; Code:
30 30
31(defun internal--before-save-selected-window ()
32 (cons (selected-window)
33 ;; We save and restore all frames' selected windows, because
34 ;; `select-window' can change the frame-selected-window of
35 ;; whatever frame that window is in. Each text terminal's
36 ;; top-frame is preserved by putting it last in the list.
37 (apply #'append
38 (mapcar (lambda (terminal)
39 (let ((frames (frames-on-display-list terminal))
40 (top-frame (tty-top-frame terminal))
41 alist)
42 (if top-frame
43 (setq frames
44 (cons top-frame
45 (delq top-frame frames))))
46 (dolist (f frames)
47 (push (cons f (frame-selected-window f))
48 alist))
49 alist))
50 (terminal-list)))))
51
52(defun internal--after-save-selected-window (state)
53 (dolist (elt (cdr state))
54 (and (frame-live-p (car elt))
55 (window-live-p (cdr elt))
56 (set-frame-selected-window (car elt) (cdr elt) 'norecord)))
57 (when (window-live-p (car state))
58 (select-window (car state) 'norecord)))
59
31(defmacro save-selected-window (&rest body) 60(defmacro save-selected-window (&rest body)
32 "Execute BODY, then select the previously selected window. 61 "Execute BODY, then select the previously selected window.
33The value returned is the value of the last form in BODY. 62The value returned is the value of the last form in BODY.
@@ -44,34 +73,11 @@ its normal operation could make a different buffer current. The
44order of recently selected windows and the buffer list ordering 73order of recently selected windows and the buffer list ordering
45are not altered by this macro (unless they are altered in BODY)." 74are not altered by this macro (unless they are altered in BODY)."
46 (declare (indent 0) (debug t)) 75 (declare (indent 0) (debug t))
47 `(let ((save-selected-window-window (selected-window)) 76 `(let ((save-selected-window--state (internal--before-save-selected-window)))
48 ;; We save and restore all frames' selected windows, because
49 ;; `select-window' can change the frame-selected-window of
50 ;; whatever frame that window is in. Each text terminal's
51 ;; top-frame is preserved by putting it last in the list.
52 (save-selected-window-alist
53 (apply 'append
54 (mapcar (lambda (terminal)
55 (let ((frames (frames-on-display-list terminal))
56 (top-frame (tty-top-frame terminal))
57 alist)
58 (if top-frame
59 (setq frames
60 (cons top-frame
61 (delq top-frame frames))))
62 (dolist (f frames)
63 (push (cons f (frame-selected-window f))
64 alist))))
65 (terminal-list)))))
66 (save-current-buffer 77 (save-current-buffer
67 (unwind-protect 78 (unwind-protect
68 (progn ,@body) 79 (progn ,@body)
69 (dolist (elt save-selected-window-alist) 80 (internal--after-save-selected-window save-selected-window--state)))))
70 (and (frame-live-p (car elt))
71 (window-live-p (cdr elt))
72 (set-frame-selected-window (car elt) (cdr elt) 'norecord)))
73 (when (window-live-p save-selected-window-window)
74 (select-window save-selected-window-window 'norecord))))))
75 81
76(defvar temp-buffer-window-setup-hook nil 82(defvar temp-buffer-window-setup-hook nil
77 "Normal hook run by `with-temp-buffer-window' before buffer display. 83 "Normal hook run by `with-temp-buffer-window' before buffer display.
@@ -5812,6 +5818,26 @@ buffer with the name BUFFER-OR-NAME and return that buffer."
5812 buffer)) 5818 buffer))
5813 (other-buffer))) 5819 (other-buffer)))
5814 5820
5821(defcustom switch-to-buffer-preserve-window-point nil
5822 "If non-nil, `switch-to-buffer' tries to preserve `window-point'.
5823If this is nil, `switch-to-buffer' displays the buffer at that
5824buffer's `point'. If this is `already-displayed', it tries to
5825display the buffer at its pevious position in the selected
5826window, provided the buffer is currently displayed in some other
5827window on any visible or iconified frame. If this is t, it
5828unconditionally tries to display the buffer at its previous
5829position in the selected window.
5830
5831This variable is ignored if the the buffer is already displayed
5832in the selected window or never appeared in it before, or if
5833`switch-to-buffer' calls `pop-to-buffer' to display the buffer."
5834 :type '(choice
5835 (const :tag "Never" nil)
5836 (const :tag "If already displayed elsewhere" already-displayed)
5837 (const :tag "Always" t))
5838 :group 'windows
5839 :version "24.3")
5840
5815(defun switch-to-buffer (buffer-or-name &optional norecord force-same-window) 5841(defun switch-to-buffer (buffer-or-name &optional norecord force-same-window)
5816 "Switch to buffer BUFFER-OR-NAME in the selected window. 5842 "Switch to buffer BUFFER-OR-NAME in the selected window.
5817If the selected window cannot display the specified 5843If the selected window cannot display the specified
@@ -5837,6 +5863,10 @@ If optional argument FORCE-SAME-WINDOW is non-nil, the buffer
5837must be displayed in the selected window; if that is impossible, 5863must be displayed in the selected window; if that is impossible,
5838signal an error rather than calling `pop-to-buffer'. 5864signal an error rather than calling `pop-to-buffer'.
5839 5865
5866The option `switch-to-buffer-preserve-window-point' can be used
5867to make the buffer appear at its last position in the selected
5868window.
5869
5840Return the buffer switched to." 5870Return the buffer switched to."
5841 (interactive 5871 (interactive
5842 (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window)) 5872 (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window))
@@ -5853,7 +5883,19 @@ Return the buffer switched to."
5853 (if force-same-window 5883 (if force-same-window
5854 (user-error "Cannot switch buffers in a dedicated window") 5884 (user-error "Cannot switch buffers in a dedicated window")
5855 (pop-to-buffer buffer norecord))) 5885 (pop-to-buffer buffer norecord)))
5856 (t (set-window-buffer nil buffer))) 5886 (t
5887 (let* ((entry (assq buffer (window-prev-buffers)))
5888 (displayed (and (eq switch-to-buffer-preserve-window-point
5889 'already-displayed)
5890 (get-buffer-window buffer 0))))
5891 (set-window-buffer nil buffer)
5892 (when (and entry
5893 (or (eq switch-to-buffer-preserve-window-point t)
5894 displayed))
5895 ;; Try to restore start and point of buffer in the selected
5896 ;; window (Bug#4041).
5897 (set-window-start (selected-window) (nth 1 entry) t)
5898 (set-window-point nil (nth 2 entry))))))
5857 5899
5858 (unless norecord 5900 (unless norecord
5859 (select-window (selected-window))) 5901 (select-window (selected-window)))
diff --git a/msdos/ChangeLog b/msdos/ChangeLog
index d3d9bc657cc..4d90e8356e3 100644
--- a/msdos/ChangeLog
+++ b/msdos/ChangeLog
@@ -1,3 +1,7 @@
12012-10-08 Eli Zaretskii <eliz@gnu.org>
2
3 * sed1v2.inp (W32_LIBS, W32_OBJ): Edit to empty.
4
12012-10-04 Paul Eggert <eggert@cs.ucla.edu> 52012-10-04 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 Merge from gnulib. 7 Merge from gnulib.
diff --git a/msdos/sed1v2.inp b/msdos/sed1v2.inp
index fbee1dd03f9..553d69038fe 100644
--- a/msdos/sed1v2.inp
+++ b/msdos/sed1v2.inp
@@ -128,6 +128,8 @@ s/\.h\.in/.h-in/
128/^CANNOT_DUMP *=/s/@CANNOT_DUMP@/no/ 128/^CANNOT_DUMP *=/s/@CANNOT_DUMP@/no/
129/^DEPFLAGS *=/s/@DEPFLAGS@// 129/^DEPFLAGS *=/s/@DEPFLAGS@//
130/^MKDEPDIR *=/s/@MKDEPDIR@// 130/^MKDEPDIR *=/s/@MKDEPDIR@//
131/^W32_OBJ *=/s/@W32_OBJ@//
132/^W32_LIBS *=/s/@W32_LIBS@//
131/^version *=/s/@[^@\n]*@// 133/^version *=/s/@[^@\n]*@//
132/^@SET_MAKE@$/s/@SET_MAKE@// 134/^@SET_MAKE@$/s/@SET_MAKE@//
133/^ [ ]*\$(libsrc)\/make-docfile.*>.*\/DOC/s!make-docfile!make-docfile -o $(etc)/DOC! 135/^ [ ]*\$(libsrc)\/make-docfile.*>.*\/DOC/s!make-docfile!make-docfile -o $(etc)/DOC!
diff --git a/nt/ChangeLog b/nt/ChangeLog
index b0dcb9982f1..e659b87eb76 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,8 @@
12012-10-08 Juanma Barranquero <lekktu@gmail.com>
2
3 * config.nt: Sync with autogen/config.in.
4 (HAVE_NTGUI): New macro.
5
12012-10-02 Eli Zaretskii <eliz@gnu.org> 62012-10-02 Eli Zaretskii <eliz@gnu.org>
2 7
3 * preprep.c (RVA_TO_PTR): Cast the result to 'void *', to avoid 8 * preprep.c (RVA_TO_PTR): Cast the result to 'void *', to avoid
diff --git a/nt/config.nt b/nt/config.nt
index e342c78e20f..cd695bc4e34 100644
--- a/nt/config.nt
+++ b/nt/config.nt
@@ -701,6 +701,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
701 Mac OS X. */ 701 Mac OS X. */
702#undef HAVE_NS 702#undef HAVE_NS
703 703
704/* Define to use native Windows GUI. */
705#define HAVE_NTGUI 1
706
704/* Define to 1 if libotf has OTF_get_variation_glyphs. */ 707/* Define to 1 if libotf has OTF_get_variation_glyphs. */
705#undef HAVE_OTF_GET_VARIATION_GLYPHS 708#undef HAVE_OTF_GET_VARIATION_GLYPHS
706 709
diff --git a/src/ChangeLog b/src/ChangeLog
index 492b966a256..0b274598986 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,10 +1,368 @@
12012-10-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 * marker.c (cached_modiff): EMACS_INT, not int.
4
5 * w32select.c (waiting_for_input): Declare by including "keyboard.h"
6 instead of having a wrong decl.
7 * nsmenu.m (waiting_for_input): Remove wrong decl.
8
92012-10-10 Paul Eggert <eggert@cs.ucla.edu>
10
11 keyboard.c, keymap.c: Use bool for booleans.
12 * dispnew.c (sit_for): Distinguish between 3-way display_option
13 and boolean do_display.
14 * keyboard.c (single_kboard, this_command_key_count_reset)
15 (waiting_for_input, echoing, immediate_quit, input_pending)
16 (interrupt_input, interrupts_deferred, pop_kboard)
17 (temporarily_switch_to_single_kboard, ignore_mouse_drag_p)
18 (command_loop_1, adjust_point_for_property)
19 (safe_run_hooks_error, input_polling_used, read_char):
20 (help_char_p, readable_events, kbd_buffer_events_waiting)
21 (kbd_buffer_get_event, timer_check_2, make_lispy_event)
22 (lucid_event_type_list_p, get_input_pending):
23 (gobble_input, menu_separator_name_p, menu_bar_item)
24 (parse_menu_item, parse_tool_bar_item, read_char_x_menu_prompt)
25 (read_char_minibuf_menu_prompt, access_keymap_keyremap)
26 (keyremap_step, test_undefined, read_key_sequence)
27 (detect_input_pending, detect_input_pending_ignore_squeezables)
28 (detect_input_pending_run_timers, requeued_events_pending_p)
29 (quit_throw_to_read_char, Fset_input_interrupt_mode):
30 * keymap.c (get_keymap, keymap_parent, keymap_memberp)
31 (access_keymap_1, access_keymap, map_keymap, get_keyelt)
32 (Fdefine_key, Flookup_key, struct accessible_keymaps_data)
33 (accessible_keymaps_1, Fkey_description, push_key_description):
34 (shadow_lookup, struct where_is_internal_data)
35 (where_is_internal, Fwhere_is_internal, where_is_internal_1)
36 (Fdescribe_buffer_bindings, describe_map_tree, struct describe_map_elt)
37 (describe_map, describe_vector):
38 * menu.c (single_menu_item):
39 * nsmenu.m (ns_update_menubar):
40 * process.c (wait_reading_process_output):
41 * search.c (scan_buffer, scan_newline):
42 Use bool for boolean.
43 * keyboard.c (timers_run, swallow_events)
44 (detect_input_pending_run_timers):
45 * process.c (wait_reading_process_output):
46 Use unsigned for counter where wraparound-on-overflow is desired,
47 since unsigned is guaranteed to have that behavior and signed is not.
48 (read_char): Use ptrdiff_t for string length.
49 (get_input_pending): Remove first argument, since it was always
50 the same pointer-to-int (now pointer-to-boolean) &input_pending,
51 and behave as if it had that value. Return new value of
52 input_pending. All callers changed.
53 * keyboard.h (struct kboard): Use unsigned : 1 for boolean member
54 immediate_echo. Use ptrdiff_t for echo_after_prompt, since it's
55 a string length.
56 * keymap.c (push_key_description): Omit last arg, which was always 1.
57 All callers changed.
58
59 * regex.c (immediate_quit) [emacs]: Remove duplicate decl.
60
612012-10-10 Juanma Barranquero <lekktu@gmail.com>
62
63 * makefile.w32-in ($(BLD)/dispnew.$(O), $(BLD)/indent.$(O))
64 ($(BLD)/term.$(O)): Update dependencies.
65
662012-10-10 Dmitry Antipov <dmantipov@yandex.ru>
67
68 * alloc.c (mark_object): Use meaningful PVEC_NORMAL_VECTOR.
69 * lisp.h (enum pvec_type): Adjust comments and omit explicit
70 initializer for PVEC_NORMAL_VECTOR.
71
722012-10-10 Paul Eggert <eggert@cs.ucla.edu>
73
74 Clean out old termopts cruft.
75 * termopts.h (flow_control, meta_key): Remove unused decls.
76 * dispnew.c, indent.c, nsterm.m, term.c, xsettings.c, xsmfns.c:
77 Don't include termopts.h.
78
792012-10-10 Dmitry Antipov <dmantipov@yandex.ru>
80
81 * alloc.c (gc_sweep): Use pointer-to-a-pointer loop for buffers.
82
832012-10-10 Paul Eggert <eggert@cs.ucla.edu>
84
85 * commands.h (immediate_quit): Remove duplicate decl.
86
872012-10-09 Jan Djärv <jan.h.d@swipnet.se>
88
89 * nsfont.m (Vfonts_in_cache): Remove, not needed as font.c handles
90 caching.
91 (nsfont_open): Remove setting of Vfonts_in_cache.
92 (syms_of_nsfont): Remove initialization of Vfonts_in_cache
93
942012-10-09 Eli Zaretskii <eliz@gnu.org>
95
96 * w32fns.c (w32_last_error): Change the return value to DWORD, to
97 match what GetLastError returns. Explain why the function is
98 needed.
99
100 * frame.c (delete_frame): Rename local variable 'tooltip_frame' to
101 'is_tooltip_frame', to avoid confusion with its global namesake.
102
1032012-10-08 Daniel Colascione <dancol@dancol.org>
104
105 * xdisp.c (start_hourglass): Call w32_note_current_window when
106 HAVE_NTGUI, not just WINDOWSNT, resolving a problem in the cygw32
107 build that caused Emacs to display the hourglass cursor forever.
108
109 * w32fns.c (Fx_display_color_cells): Instead of using NCOLORS,
110 which is broken under remote desktop, calculate the number of
111 colors available for a display based on the display's number of
112 planes and number of bits per pixel per plane. (bug#10397).
113
1142012-10-08 Jan Djärv <jan.h.d@swipnet.se>
115
116 * nsfont.m (Vfonts_in_cache): New variable.
117 (nsfont_open): Use unsignedLongLongValue for cache in case wide ints
118 are used. Add cached fonts to Vfonts_in_cache.
119 (syms_of_nsfont): Initialize and staticpro Vfonts_in_cache.
120
1212012-10-08 Juanma Barranquero <lekktu@gmail.com>
122
123 * makefile.w32-in (LOCAL_FLAGS): Don't define HAVE_NTGUI, it's now
124 in nt/config.nt.
125 (FONT_H): Define after FRAME_H.
126 ($(BLD)/emacs.$(O), $(BLD)/process.$(O), $(BLD)/w32heap.$(O)):
127 Update dependencies.
128
129 * w32term.c: Remove leftover declaration of keyboard_codepage.
130
1312012-10-08 Eli Zaretskii <eliz@gnu.org>
132
133 * makefile.w32-in (FONT_H): Add $(FRAME_H).
134 (W32TERM_H): Add $(ATIMER_H) and $(FRAME_H).
135 ($(BLD)/emacs.$(O), $(BLD)/w32console.$(O)): Update dependencies.
136 (GLOBAL_SOURCES): Add cygw32.c.
137 ($(BLD)/unexw32.$(O)):
138 ($(BLD)/w32.$(O)):
139 ($(BLD)/w32console.$(O)):
140 ($(BLD)/w32fns.$(O)):
141 ($(BLD)/w32heap.$(O)):
142 ($(BLD)/w32menu.$(O)):
143 ($(BLD)/w32proc.$(O)): Add w32common.h.
144
145 * w32fns.c (w32_color_map_lookup, x_to_w32_color): Argument is now
146 'const char *'.
147 (x_to_w32_color): Don't modify the argument, modify a copy instead.
148
1492012-10-08 Daniel Colascione <dancol@dancol.org>
150
151 * w32term.h (WM_EMACS_BRINGTOTOP, WM_EMACS_INPUT_READY)
152 (WM_EMACS_END): Change WM_EMACS_BRINGTOTOP from 22 to 21 to close
153 accidental message numbering hole. Change other messages to
154 match.
155
156 * w32select.h (HAVE_W32SELECT): Remove.
157
158 * w32select.c, w32proc.c, w32menu.c, w32console.c, w32.c: Include
159 w32common.h instead of w32heap.h
160
161 * w32heap.h (ROUND_UP, ROUND_DOWN, get_page_size)
162 (get_allocation_unit, get_processor_type, get_w32_major_version)
163 (get_w32_minor_version, sysinfo_cache, osinfo_cache)
164 (w32_major_version, w32_minor_version, w32_build_number, OS_9X)
165 (OS_NT, os_subtype, cache_system_info): Move declarations to
166 w32common.
167
168 * w32heap.c: Include w32common.h.
169 (sysinfo_cache, syspage_mask, osinfo_cache, w32_major_version)
170 (w32_minor_version, w32_build_number, w32_subtype): Remove
171 duplicate definitions.
172
173 * w32fns.c: Include w32common.h; include w32heap.h only in
174 WINDOWSNT.
175
176 (Fx_file_dialog): Clarify comment on GetOpenFileName structure.
177 Use `report_file_error' instead of `error' in order to better
178 inform users of what went wrong. Increase NTGUI_UNICODE file
179 dialog box file name length to 32k, the maximum allowed by the NT
180 kernel.
181
182 * w32common.h: New file.
183 (ROUND_UP, ROUND_DOWN, get_page_size)
184 (get_allocation_unit, get_processor_type, get_w32_major_version)
185 (get_w32_minor_version, sysinfo_cache, osinfo_cache)
186 (w32_major_version, w32_minor_version, w32_build_number, OS_9X)
187 (OS_NT, os_subtype, cache_system_info): Move here.
188
189 * unexw32.c, unexcw.c: Include w32common.h.
190
191 * emacs.c (main): Use (defined (WINDOWSNT) || defined
192 HAVE_NTGUI) instead of removed HAVE_W32SELECT to decide whether
193 to call syms_of_w32select.
194
195 * cygw32.h: Remove obsolete EXFUN declarations.
196
197 * cygw32.c (Qutf_16_le): Rename to Qutf_16le.
198
199 * Makefile.in (SOME_MACHINE_OBJECTS): Reverse accidental removal
200 of w32inevt.o from SOME_MACHINE_OBJECTS.
201
2022012-10-08 Daniel Colascione <dancol@dancol.org>
203
204 * image.c: Permanent fix for JPEG compilation issue --- limit
205 jpeglib `boolean' redefinition to Cygwin builds.
206
2072012-10-08 Eli Zaretskii <eliz@gnu.org>
208
209 * image.c (CHECK_LIB_AVAILABLE): Remove, no longer used.
210
211 * emacs.c (DAEMON_MUST_EXEC) [HAVE_NTGUI]: Define this only on
212 Cygwin.
213
2142012-10-08 Daniel Colascione <dancol@dancol.org>
215
216 * xfaces.c, xdisp.c, window.c, w32xfns.c, w32term.h, w32term.c,
217 w32select.h w32select.c, w32proc.c, w32menu.c, w32inevt.c,
218 w32help.c, w32font.c, w32font.c, w32fns.c, w32console.c, w32.h,
219 w32.c, unexw32.c, termhooks.h, process.c, menu.c, keyboard.h,
220 keyboard.c, image.c, frame.h, frame.c, fontset.c, font.h, font.c,
221 emacs.c, dispextern.h, cygw32.h, cygw32.c, conf_post.h,
222 Makefile.in: use HAVE_NTGUI for W32 GUI and WINDOWSNT for the
223 operating system. defined(HAVE_NTGUI) && !defined(WINDOWSNT) is
224 now a supported configuration.
225
226 * Makefile.in: consolidate image variables into LIBIMAGE; add
227 W32_OBJ and W32_LIBS. Compile new files.
228
229 * conf_post.h:
230 (_DebPrint) declare tracing facility for W32 debugging. We need
231 to unify tracing later.
232
233 (NTGUI_UNICODE) Define when compiling for Cygwin to allow the
234 unconditional use of W32 Unicode functions. Cygwin runs only on
235 100% Unicode operating systems.
236
237 * cygw32.c: New file. Define Cygwin-specific facilities.
238 (Fcygwin_convert_path_to_windows)
239 (Fcygwin_convert_path_from_windows): New user functions for
240 accessing Cygwin path-munging routines.
241
242 * cygw32.h: New file.
243 (WCSDATA, to_unicode, from_unicode): Define facilities for storing
244 UTF-16LE strings temporarily inside non-Lisp-visible string
245 objects.
246
247 (w32_strerror): Just what it says on the tin.
248
249 * emacs.c: Make the NS fork-then-exec code for daemon-launching
250 also run for Cygwin; both systems have the same problem with using
251 GUI facilities in a forked child. Also call syms_of_cygw32,
252 syms_of_w32select in correct places.
253
254 (DAEMON_MUST_EXEC): new macro defined to signal that a platform
255 needs fork-then-exec for daemon launching.
256
257 * font.h: Include frame.h.
258
259 * image.c: Use the image library cache machinery only when we're
260 compiling for native WINDOWSNT; Cygwin can use shared libraries
261 like any other Unixlike system.
262
263 * keyboard.c: Clarify a comment regarding the input loop.
264
265 * menu.c: When NTGUI_UNICODE is defined, use Unicode menu
266 functions directly instead of trying to detect at runtime that our
267 host operating system supports them. We make this change for two
268 reasons: Cygwin lacks support for the multibyte character
269 conversion functions used by the legacy menu code, and Cygwin
270 never needs to rely on non-Unicode APIs.
271
272 * unexw32.c (hinst): Declare extern.
273
274 * w32.c: Change header order;
275 (w32_strerror): Move to w32fns.c because we need it for
276 non-WINDOWSNT builds.
277
278 * w32.h: Add #error macro to make sure we don't include w32.h for
279 Cygwin builds. Remove w32select declarations.
280
281 * w32console.c (w32_sys_ring_bell, Fset_message_beep): Move to
282 w32fns.c. w32console.c is WINDOWSNT-only.
283
284 * w32fns.c: Include cygw32.h or w32.h depending on CYGWIN; more
285 NTGUI_UNICODE tweaks. (See above.) Change _snprintf to the more
286 POSIXy alternative.
287 (faked_key, sysinfo_cache, osinfo_cahce, syspage_mask)
288 (w32_major_version, w32_minor_version, w32_build_number)
289 (os_subtype, sound_type): Define here
290 (w32_defined_color): Make color parameter const for consistency
291 with other _defined_color functions.
292 (w32_createwindow): Unconditionally call w32_init_class instead of
293 doing so only when hprevinst is non-NULL. Plumbing hprevinst
294 through the code is complex and unnecessary because class
295 registration is practically free.
296 (w32_name_of_message): New EMACSDEBUG-only function.
297 (Fset_message_beep): Move here
298 (Fx_open_connection): Require that the display name for Windows be
299 "w32" for consistency, emacsclient disambiguation, and maybe, one
300 day, multi-window-system support.
301 (file_dialog_callback): NTGUI_UNICODE changes; encode and decode
302 Cygwin files for W32 GUI facilities, since these clearly don't
303 expect Cygwin names.
304 (_DebPrint): Define.
305 (w32_strerror, w32_console_toggle_lock_key, w32_kbd_mods_to_emacs)
306 (w32_kbd_patch_key, w32_sys_ring_bell): Move here.
307 (Ssystem_move_file_to_trash): Define only for native WINDOWSNT.
308 (w32_last_error): Remove.
309
310 * w32font.c: Define _strlwr to strlwr for non-WINDOWSNT builds.
311
312 * w32heap.c (syspage_mask): Declare here.
313 (cache_system_info): Remove.
314
315 * w32inevt.c (faked_key): Define globally, not statically.
316 (w32_kbd_mods_to_emacs, w32_kbd_patch_key, faked_key)
317 (w32_console_toggle_lock_key): Move to w32fns.c.
318
319 * w32menu.c: Include setjmp.h. NTGUI_UNICODE changes throughout.
320
321 * w32proc.c (_DebPrint): Move to w32fns.c.
322 * w32select.c: Include string.h, stdio.h for Cygwin.
323 * w32select.h: New File.
324
325 * w32term.c: Include io.h for non-CYGWIN builds; needed for
326 get_osfhandle.
327 (w32_message_fd): New variable. Under Cygwin, holds the file
328 descriptor the system used to tell us about pending thread
329 messages.
330
331 (w32_init_term): Remove incorrect calls to fcntl and init_sigio
332 that prevented compilation under non-WINDOWSNT systems.
333
334 (w32_initialize): Open /dev/windows and assign it to
335 w32_message_fd. Provide w32 feature.
336
337 * w32term.h: Include frame.h, atimer.h. Declare various frame functions.
338 (WM_EMACS_INPUT_READY): add.
339 (prepend_msg, w32_message_fd): Declare globally.
340
341 * w32xfns.c:
342 (keyboard_handle): Use only when WINDOWSNT.
343 (notify_msg_ready): New function. Posts a message to the main
344 thread's message queue under CYGWIN, which wakes up the main
345 thread from select(2) by making the /dev/windows file descriptor
346 ready. Under WINDOWSNT, it sets an event the same way the old
347 code did.
348
349 (post, prepend_msg): Actually call notify_msg_ready instead of
350 setting the input event directly.
351
3522012-10-07 Eli Zaretskii <eliz@gnu.org>
353
354 * ralloc.c (relinquish): If a heap is ready to be relinquished,
355 but it still has blocs in it, don't return it to the system,
356 instead of aborting. (Bug#12402)
357
12012-10-07 Jan Djärv <jan.h.d@swipnet.se> 3582012-10-07 Jan Djärv <jan.h.d@swipnet.se>
2 359
3 * nsterm.m (ns_dumpglyphs_image): Only draw slize of image (Bug#12506). 360 * nsterm.m (ns_dumpglyphs_image): Only draw slice of image (Bug#12506).
4 361
5 * nsterm.m (ns_update_auto_hide_menu_bar): Remove defintion of 362 * nsterm.m (ns_update_auto_hide_menu_bar): Remove defintion of
6 MAC_OS_X_VERSION_10_6. 363 MAC_OS_X_VERSION_10_6.
7 (syms_of_nsterm): Remove comment about Panther and above for ns-antialias-text. 364 (syms_of_nsterm): Remove comment about Panther and above for
365 ns-antialias-text.
8 * nsterm.h (MAC_OS_X_VERSION_10_3, onTiger): Remove. 366 * nsterm.h (MAC_OS_X_VERSION_10_3, onTiger): Remove.
9 (EmacsApp): Remove check for >= MAC_OS_X_VERSION_10_4. 367 (EmacsApp): Remove check for >= MAC_OS_X_VERSION_10_4.
10 (struct nsfont_info): Remove check for >= MAC_OS_X_VERSION_10_3. 368 (struct nsfont_info): Remove check for >= MAC_OS_X_VERSION_10_3.
@@ -12,7 +370,8 @@
12 * nsselect.m (ns_string_from_pasteboard): Remove check for >= 370 * nsselect.m (ns_string_from_pasteboard): Remove check for >=
13 MAC_OS_X_VERSION_10_4. 371 MAC_OS_X_VERSION_10_4.
14 372
15 * nsmenu.m (fillWithWidgetValue:): Remove code for < MAC_OS_X_VERSION_10_2. 373 * nsmenu.m (fillWithWidgetValue:): Remove code for <
374 MAC_OS_X_VERSION_10_2.
16 375
17 * nsimage.m (setPixmapData, getPixelAtX, setAlphaAtX): Remove onTiger. 376 * nsimage.m (setPixmapData, getPixelAtX, setAlphaAtX): Remove onTiger.
18 377
@@ -21,13 +380,13 @@
21 380
22 * nsterm.m (ns_in_resize): Remove (Bug#12479). 381 * nsterm.m (ns_in_resize): Remove (Bug#12479).
23 (ns_resize_handle_rect, mouseDown, mouseUp, mouseDragged): Remove. 382 (ns_resize_handle_rect, mouseDown, mouseUp, mouseDragged): Remove.
24 (ns_clear_frame, sendEvent, windowDidResize, drawRect:): Remove ns_in_resize 383 (ns_clear_frame, sendEvent, windowDidResize, drawRect:): Remove
25 check. 384 ns_in_resize check.
26 (ns_clear_frame_area): Remove resize handle code. 385 (ns_clear_frame_area): Remove resize handle code.
27 386
28 * nsfns.m (ns_in_resize): Remove. 387 * nsfns.m (ns_in_resize): Remove.
29 (x_set_icon_name, ns_set_name, ns_set_name_as_filename): Remove ns_in_resize 388 (x_set_icon_name, ns_set_name, ns_set_name_as_filename): Remove
30 check. 389 ns_in_resize check.
31 390
322012-10-07 Paul Eggert <eggert@cs.ucla.edu> 3912012-10-07 Paul Eggert <eggert@cs.ucla.edu>
33 392
diff --git a/src/Makefile.in b/src/Makefile.in
index f8da0091711..c24e421bbbc 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -135,13 +135,10 @@ LIB_MATH=@LIB_MATH@
135## -lpthreads, or empty. 135## -lpthreads, or empty.
136LIB_PTHREAD=@LIB_PTHREAD@ 136LIB_PTHREAD=@LIB_PTHREAD@
137 137
138LIBTIFF=@LIBTIFF@ 138LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
139LIBJPEG=@LIBJPEG@ 139
140LIBPNG=@LIBPNG@
141LIBGIF=@LIBGIF@
142LIBXPM=@LIBXPM@
143XFT_LIBS=@XFT_LIBS@ 140XFT_LIBS=@XFT_LIBS@
144LIBX_EXTRA=$(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) -lX11 $(XFT_LIBS) 141LIBX_EXTRA=-lX11 $(XFT_LIBS)
145 142
146FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ 143FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
147FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ 144FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
@@ -261,6 +258,13 @@ NS_OBJ=@NS_OBJ@
261NS_OBJC_OBJ=@NS_OBJC_OBJ@ 258NS_OBJC_OBJ=@NS_OBJC_OBJ@
262## Only set if NS_IMPL_GNUSTEP. 259## Only set if NS_IMPL_GNUSTEP.
263GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@ 260GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@
261## w32fns.o w32menu.c w32reg.o fringe.o fontset.o w32font.o w32term.o
262## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else
263## empty.
264W32_OBJ=@W32_OBJ@
265## -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32 lusp10 -lcomctl32
266## --lwinspool if HAVE_W32, else empty.
267W32_LIBS=@W32_LIBS@
264 268
265## Empty if !HAVE_X_WINDOWS 269## Empty if !HAVE_X_WINDOWS
266## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT 270## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT
@@ -342,7 +346,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
342 doprnt.o intervals.o textprop.o composite.o xml.o \ 346 doprnt.o intervals.o textprop.o composite.o xml.o \
343 profiler.o \ 347 profiler.o \
344 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ 348 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
345 $(WINDOW_SYSTEM_OBJ) 349 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ)
346obj = $(base_obj) $(NS_OBJC_OBJ) 350obj = $(base_obj) $(NS_OBJC_OBJ)
347 351
348## Object files used on some machine or other. 352## Object files used on some machine or other.
@@ -351,7 +355,7 @@ obj = $(base_obj) $(NS_OBJC_OBJ)
351## in the list, in case they ever add any such entries. 355## in the list, in case they ever add any such entries.
352SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ 356SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
353 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ 357 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
354 fontset.o dbusbind.o \ 358 fontset.o dbusbind.o cygw32.o \
355 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ 359 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
356 w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ 360 w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
357 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ 361 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
@@ -385,9 +389,11 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
385## Note that SunOS needs -lm to come before -lc; otherwise, you get 389## Note that SunOS needs -lm to come before -lc; otherwise, you get
386## duplicated symbols. If the standard libraries were compiled 390## duplicated symbols. If the standard libraries were compiled
387## with GCC, we might need LIB_GCC again after them. 391## with GCC, we might need LIB_GCC again after them.
388LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ 392LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \
389 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(LIB_TIMER_TIME) \ 393 $(LIBX_OTHER) $(LIBSOUND) \
390 $(DBUS_LIBS) $(LIB_EXECINFO) \ 394 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
395 $(LIB_TIMER_TIME) $(DBUS_LIBS) \
396 $(LIB_EXECINFO) \
391 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 397 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
392 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 398 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
393 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 399 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
diff --git a/src/alloc.c b/src/alloc.c
index 3ed8cc2d990..95be8db1614 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5689,7 +5689,7 @@ mark_object (Lisp_Object arg)
5689 pvectype = ((ptr->header.size & PVEC_TYPE_MASK) 5689 pvectype = ((ptr->header.size & PVEC_TYPE_MASK)
5690 >> PSEUDOVECTOR_SIZE_BITS); 5690 >> PSEUDOVECTOR_SIZE_BITS);
5691 else 5691 else
5692 pvectype = 0; 5692 pvectype = PVEC_NORMAL_VECTOR;
5693 5693
5694 if (pvectype != PVEC_SUBR && pvectype != PVEC_BUFFER) 5694 if (pvectype != PVEC_SUBR && pvectype != PVEC_BUFFER)
5695 CHECK_LIVE (live_vector_p); 5695 CHECK_LIVE (live_vector_p);
@@ -6311,19 +6311,14 @@ gc_sweep (void)
6311 6311
6312 /* Free all unmarked buffers */ 6312 /* Free all unmarked buffers */
6313 { 6313 {
6314 register struct buffer *buffer = all_buffers, *prev = 0, *next; 6314 register struct buffer *buffer, **bprev = &all_buffers;
6315 6315
6316 total_buffers = 0; 6316 total_buffers = 0;
6317 while (buffer) 6317 for (buffer = all_buffers; buffer; buffer = *bprev)
6318 if (!VECTOR_MARKED_P (buffer)) 6318 if (!VECTOR_MARKED_P (buffer))
6319 { 6319 {
6320 if (prev) 6320 *bprev = buffer->header.next.buffer;
6321 prev->header.next = buffer->header.next;
6322 else
6323 all_buffers = buffer->header.next.buffer;
6324 next = buffer->header.next.buffer;
6325 lisp_free (buffer); 6321 lisp_free (buffer);
6326 buffer = next;
6327 } 6322 }
6328 else 6323 else
6329 { 6324 {
@@ -6331,7 +6326,7 @@ gc_sweep (void)
6331 /* Do not use buffer_(set|get)_intervals here. */ 6326 /* Do not use buffer_(set|get)_intervals here. */
6332 buffer->text->intervals = balance_intervals (buffer->text->intervals); 6327 buffer->text->intervals = balance_intervals (buffer->text->intervals);
6333 total_buffers++; 6328 total_buffers++;
6334 prev = buffer, buffer = buffer->header.next.buffer; 6329 bprev = &buffer->header.next.buffer;
6335 } 6330 }
6336 } 6331 }
6337 6332
diff --git a/src/commands.h b/src/commands.h
index 36f600cee01..510fce0e182 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -36,9 +36,6 @@ extern Lisp_Object control_x_map;
36 events until a non-ASCII event is acceptable as input. */ 36 events until a non-ASCII event is acceptable as input. */
37extern Lisp_Object unread_switch_frame; 37extern Lisp_Object unread_switch_frame;
38 38
39/* Nonzero means ^G can quit instantly */
40extern int immediate_quit;
41
42/* Nonzero if input is coming from the keyboard */ 39/* Nonzero if input is coming from the keyboard */
43 40
44#define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive) 41#define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive)
diff --git a/src/conf_post.h b/src/conf_post.h
index 0c4d029bc5d..aa008107ba6 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -142,6 +142,20 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
142#endif 142#endif
143#endif 143#endif
144 144
145#if defined HAVE_NTGUI && !defined DebPrint
146# ifdef EMACSDEBUG
147extern void _DebPrint (const char *fmt, ...);
148# define DebPrint(stuff) _DebPrint stuff
149# else
150# define DebPrint(stuff)
151# endif
152#endif
153
154#if defined CYGWIN && defined HAVE_NTGUI
155# define NTGUI_UNICODE /* Cygwin runs only on UNICODE-supporting systems */
156# define _WIN32_WINNT 0x500 /* Win2k */
157#endif
158
145#ifdef emacs /* Don't do this for lib-src. */ 159#ifdef emacs /* Don't do this for lib-src. */
146/* Tell regex.c to use a type compatible with Emacs. */ 160/* Tell regex.c to use a type compatible with Emacs. */
147#define RE_TRANSLATE_TYPE Lisp_Object 161#define RE_TRANSLATE_TYPE Lisp_Object
diff --git a/src/cygw32.c b/src/cygw32.c
new file mode 100644
index 00000000000..c45a45648e9
--- /dev/null
+++ b/src/cygw32.c
@@ -0,0 +1,169 @@
1/* Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19
20#include "cygw32.h"
21#include "character.h"
22#include "buffer.h"
23#include <unistd.h>
24#include <fcntl.h>
25static Lisp_Object Qutf_16le;
26
27static Lisp_Object
28fchdir_unwind (Lisp_Object dir_fd)
29{
30 (void) fchdir (XFASTINT (dir_fd));
31 (void) close (XFASTINT (dir_fd));
32 return Qnil;
33}
34
35static void
36chdir_to_default_directory ()
37{
38 Lisp_Object new_cwd;
39 int old_cwd_fd = open (".", O_RDONLY | O_DIRECTORY);
40
41 if (old_cwd_fd == -1)
42 error ("could not open current directory: %s", strerror (errno));
43
44 record_unwind_protect (fchdir_unwind, make_number (old_cwd_fd));
45
46 new_cwd = Funhandled_file_name_directory (
47 Fexpand_file_name (build_string ("."), Qnil));
48 if (!STRINGP (new_cwd))
49 new_cwd = build_string ("/");
50
51 if (chdir (SDATA (ENCODE_FILE (new_cwd))))
52 error ("could not chdir: %s", strerror (errno));
53}
54
55static Lisp_Object
56conv_filename_to_w32_unicode (Lisp_Object in, int absolute_p)
57{
58 ssize_t converted_len;
59 Lisp_Object converted;
60 unsigned flags;
61 int count = SPECPDL_INDEX ();
62
63 chdir_to_default_directory ();
64
65 flags = CCP_POSIX_TO_WIN_W;
66 if (!absolute_p) {
67 flags |= CCP_RELATIVE;
68 }
69
70 in = ENCODE_FILE (in);
71
72 converted_len = cygwin_conv_path (flags, SDATA (in), NULL, 0);
73 if (converted_len < 2)
74 error ("cygwin_conv_path: %s", strerror (errno));
75
76 converted = make_uninit_string (converted_len - 1);
77 if (cygwin_conv_path (flags, SDATA (in),
78 SDATA (converted), converted_len))
79 error ("cygwin_conv_path: %s", strerror (errno));
80
81 return unbind_to (count, converted);
82}
83
84static Lisp_Object
85conv_filename_from_w32_unicode (const wchar_t* in, int absolute_p)
86{
87 ssize_t converted_len;
88 Lisp_Object converted;
89 unsigned flags;
90 int count = SPECPDL_INDEX ();
91
92 chdir_to_default_directory ();
93
94 flags = CCP_WIN_W_TO_POSIX;
95 if (!absolute_p) {
96 flags |= CCP_RELATIVE;
97 }
98
99 converted_len = cygwin_conv_path (flags, in, NULL, 0);
100 if (converted_len < 1)
101 error ("cygwin_conv_path: %s", strerror (errno));
102
103 converted = make_uninit_string (converted_len - 1 /*subtract terminator*/);
104 if (cygwin_conv_path (flags, in, SDATA (converted), converted_len))
105 error ("cygwin_conv_path: %s", strerror (errno));
106
107 return unbind_to (count, DECODE_FILE (converted));
108}
109
110Lisp_Object
111from_unicode (Lisp_Object str)
112{
113 CHECK_STRING (str);
114 if (!STRING_MULTIBYTE (str) &&
115 SBYTES (str) & 1)
116 {
117 str = Fsubstring (str, make_number (0), make_number (-1));
118 }
119
120 return code_convert_string_norecord (str, Qutf_16le, 0);
121}
122
123wchar_t *
124to_unicode (Lisp_Object str, Lisp_Object *buf)
125{
126 *buf = code_convert_string_norecord (str, Qutf_16le, 1);
127 /* We need to make a another copy (in addition to the one made by
128 code_convert_string_norecord) to ensure that the final string is
129 _doubly_ zero terminated --- that is, that the string is
130 terminated by two zero bytes and one utf-16le null character.
131 Because strings are already terminated with a single zero byte,
132 we just add one additional zero. */
133 str = make_uninit_string (SBYTES (*buf) + 1);
134 memcpy (SDATA (str), SDATA (*buf), SBYTES (*buf));
135 SDATA (str) [SBYTES (*buf)] = '\0';
136 *buf = str;
137 return WCSDATA (*buf);
138}
139
140DEFUN ("cygwin-convert-path-to-windows",
141 Fcygwin_convert_path_to_windows, Scygwin_convert_path_to_windows,
142 1, 2, 0,
143 doc: /* Convert PATH to a Windows path. If ABSOLUTE-P if
144 non-nil, return an absolute path.*/)
145 (Lisp_Object path, Lisp_Object absolute_p)
146{
147 return from_unicode (
148 conv_filename_to_w32_unicode (path, absolute_p == Qnil ? 0 : 1));
149}
150
151DEFUN ("cygwin-convert-path-from-windows",
152 Fcygwin_convert_path_from_windows, Scygwin_convert_path_from_windows,
153 1, 2, 0,
154 doc: /* Convert a Windows path to a Cygwin path. If ABSOLUTE-P
155 if non-nil, return an absolute path.*/)
156 (Lisp_Object path, Lisp_Object absolute_p)
157{
158 return conv_filename_from_w32_unicode (to_unicode (path, &path),
159 absolute_p == Qnil ? 0 : 1);
160}
161
162void
163syms_of_cygw32 (void)
164{
165 /* No, not utf-16-le: that one has a BOM. */
166 DEFSYM (Qutf_16le, "utf-16le");
167 defsubr (&Scygwin_convert_path_from_windows);
168 defsubr (&Scygwin_convert_path_to_windows);
169}
diff --git a/src/cygw32.h b/src/cygw32.h
new file mode 100644
index 00000000000..78e77a9a141
--- /dev/null
+++ b/src/cygw32.h
@@ -0,0 +1,53 @@
1/* Header for Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef CYGW32_H
20#define CYGW32_H
21#include <config.h>
22#include <windef.h>
23#include <sys/cygwin.h>
24#include <wchar.h>
25
26#include <signal.h>
27#include <stdio.h>
28#include <limits.h>
29#include <errno.h>
30#include <math.h>
31#include <setjmp.h>
32
33#include "lisp.h"
34#include "coding.h"
35
36/* *** Character conversion *** */
37
38/* Access the wide-character string stored in a Lisp string object. */
39#define WCSDATA(x) ((wchar_t *) SDATA (x))
40
41/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
42 string, and store it in *BUF. BUF may safely point to STR on entry. */
43extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
44
45/* Convert STR, a UTF-16LE encoded string embedded in a unibyte string
46 object, to a multi-byte Emacs string, and return it. */
47extern Lisp_Object from_unicode (Lisp_Object str);
48
49/* *** Misc *** */
50extern void syms_of_cygw32 (void);
51extern char * w32_strerror (int error_no);
52
53#endif /* CYGW32_H */
diff --git a/src/dispextern.h b/src/dispextern.h
index f1ea8e97ee8..c5ebb808b05 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3144,7 +3144,7 @@ int draw_window_fringes (struct window *, int);
3144int update_window_fringes (struct window *, int); 3144int update_window_fringes (struct window *, int);
3145void compute_fringe_widths (struct frame *, int); 3145void compute_fringe_widths (struct frame *, int);
3146 3146
3147#ifdef WINDOWSNT 3147#ifdef HAVE_NTGUI
3148void w32_init_fringe (struct redisplay_interface *); 3148void w32_init_fringe (struct redisplay_interface *);
3149void w32_reset_fringes (void); 3149void w32_reset_fringes (void);
3150#endif 3150#endif
@@ -3247,7 +3247,7 @@ extern char unspecified_fg[], unspecified_bg[];
3247#ifdef HAVE_X_WINDOWS 3247#ifdef HAVE_X_WINDOWS
3248void gamma_correct (struct frame *, XColor *); 3248void gamma_correct (struct frame *, XColor *);
3249#endif 3249#endif
3250#ifdef WINDOWSNT 3250#ifdef HAVE_NTGUI
3251void gamma_correct (struct frame *, COLORREF *); 3251void gamma_correct (struct frame *, COLORREF *);
3252#endif 3252#endif
3253 3253
diff --git a/src/dispnew.c b/src/dispnew.c
index 6f8fb10b41d..0956e3f2905 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 26
27#include "lisp.h" 27#include "lisp.h"
28#include "termchar.h" 28#include "termchar.h"
29#include "termopts.h"
30/* cm.h must come after dispextern.h on Windows. */ 29/* cm.h must come after dispextern.h on Windows. */
31#include "dispextern.h" 30#include "dispextern.h"
32#include "cm.h" 31#include "cm.h"
@@ -5919,15 +5918,16 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5919 TIMEOUT is number of seconds to wait (float or integer), 5918 TIMEOUT is number of seconds to wait (float or integer),
5920 or t to wait forever. 5919 or t to wait forever.
5921 READING is true if reading input. 5920 READING is true if reading input.
5922 If DO_DISPLAY is >0 display process output while waiting. 5921 If DISPLAY_OPTION is >0 display process output while waiting.
5923 If DO_DISPLAY is >1 perform an initial redisplay before waiting. 5922 If DISPLAY_OPTION is >1 perform an initial redisplay before waiting.
5924*/ 5923*/
5925 5924
5926Lisp_Object 5925Lisp_Object
5927sit_for (Lisp_Object timeout, bool reading, int do_display) 5926sit_for (Lisp_Object timeout, bool reading, int display_option)
5928{ 5927{
5929 intmax_t sec; 5928 intmax_t sec;
5930 int nsec; 5929 int nsec;
5930 bool do_display = display_option > 0;
5931 5931
5932 swallow_events (do_display); 5932 swallow_events (do_display);
5933 5933
@@ -5935,7 +5935,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
5935 || !NILP (Vexecuting_kbd_macro)) 5935 || !NILP (Vexecuting_kbd_macro))
5936 return Qnil; 5936 return Qnil;
5937 5937
5938 if (do_display >= 2) 5938 if (display_option > 1)
5939 redisplay_preserve_echo_area (2); 5939 redisplay_preserve_echo_area (2);
5940 5940
5941 if (INTEGERP (timeout)) 5941 if (INTEGERP (timeout))
diff --git a/src/emacs.c b/src/emacs.c
index bc54f56b98a..0a2a60bee0c 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -33,9 +33,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33 33
34#ifdef WINDOWSNT 34#ifdef WINDOWSNT
35#include <fcntl.h> 35#include <fcntl.h>
36#include <windows.h> /* just for w32.h */
37#include "w32.h" 36#include "w32.h"
38#include "w32heap.h" /* for prototype of sbrk */ 37#include "w32heap.h"
38#endif
39
40#if defined WINDOWSNT || defined HAVE_NTGUI
41#include "w32select.h"
42#include "w32font.h"
43#endif
44
45#if defined HAVE_NTGUI && defined CYGWIN
46#include "cygw32.h"
39#endif 47#endif
40 48
41#ifdef HAVE_WINDOW_SYSTEM 49#ifdef HAVE_WINDOW_SYSTEM
@@ -156,6 +164,22 @@ static void *my_heap_start;
156static uprintmax_t heap_bss_diff; 164static uprintmax_t heap_bss_diff;
157#endif 165#endif
158 166
167/* To run as a daemon under Cocoa or Windows, we must do a fork+exec,
168 not a simple fork.
169
170 On Cocoa, CoreFoundation lib fails in forked process:
171 http://developer.apple.com/ReleaseNotes/
172 CoreFoundation/CoreFoundation.html)
173
174 On Windows, a Cygwin fork child cannot access the USER subsystem.
175
176 We mark being in the exec'd process by a daemon name argument of
177 form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors,
178 NAME is the original daemon name, if any. */
179#if defined NS_IMPL_COCOA || (defined HAVE_NTGUI && defined CYGWIN)
180# define DAEMON_MUST_EXEC
181#endif
182
159/* True means running Emacs without interactive terminal. */ 183/* True means running Emacs without interactive terminal. */
160bool noninteractive; 184bool noninteractive;
161 185
@@ -669,7 +693,7 @@ main (int argc, char **argv)
669 bool no_loadup = 0; 693 bool no_loadup = 0;
670 char *junk = 0; 694 char *junk = 0;
671 char *dname_arg = 0; 695 char *dname_arg = 0;
672#ifdef NS_IMPL_COCOA 696#ifdef DAEMON_MUST_EXEC
673 char dname_arg2[80]; 697 char dname_arg2[80];
674#endif 698#endif
675 char *ch_to_dir; 699 char *ch_to_dir;
@@ -964,25 +988,19 @@ main (int argc, char **argv)
964 exit (1); 988 exit (1);
965 } 989 }
966 990
967#ifndef NS_IMPL_COCOA 991#ifndef DAEMON_MUST_EXEC
968#ifdef USE_GTK 992#ifdef USE_GTK
969 fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 993 fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
970Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\ 994Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\
971Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n"); 995Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n");
972#endif 996#endif /* USE_GTK */
973 f = fork (); 997 f = fork ();
974#else /* NS_IMPL_COCOA */ 998#else /* DAEMON_MUST_EXEC */
975 /* Under Cocoa we must do fork+exec as CoreFoundation lib fails in
976 forked process: http://developer.apple.com/ReleaseNotes/
977 CoreFoundation/CoreFoundation.html)
978 We mark being in the exec'd process by a daemon name argument of
979 form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors,
980 NAME is the original daemon name, if any. */
981 if (!dname_arg || !strchr (dname_arg, '\n')) 999 if (!dname_arg || !strchr (dname_arg, '\n'))
982 f = fork (); /* in orig */ 1000 f = fork (); /* in orig */
983 else 1001 else
984 f = 0; /* in exec'd */ 1002 f = 0; /* in exec'd */
985#endif /* NS_IMPL_COCOA */ 1003#endif /* !DAEMON_MUST_EXEC */
986 if (f > 0) 1004 if (f > 0)
987 { 1005 {
988 int retval; 1006 int retval;
@@ -1018,7 +1036,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1018 exit (1); 1036 exit (1);
1019 } 1037 }
1020 1038
1021#ifdef NS_IMPL_COCOA 1039#ifdef DAEMON_MUST_EXEC
1022 { 1040 {
1023 /* In orig process, forked as child, OR in exec'd. */ 1041 /* In orig process, forked as child, OR in exec'd. */
1024 if (!dname_arg || !strchr (dname_arg, '\n')) 1042 if (!dname_arg || !strchr (dname_arg, '\n'))
@@ -1054,7 +1072,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1054 dname_arg2); 1072 dname_arg2);
1055 dname_arg = *dname_arg2 ? dname_arg2 : NULL; 1073 dname_arg = *dname_arg2 ? dname_arg2 : NULL;
1056 } 1074 }
1057#endif /* NS_IMPL_COCOA */ 1075#endif /* DAEMON_MUST_EXEC */
1058 1076
1059 if (dname_arg) 1077 if (dname_arg)
1060 daemon_name = xstrdup (dname_arg); 1078 daemon_name = xstrdup (dname_arg);
@@ -1357,6 +1375,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1357#ifdef WINDOWSNT 1375#ifdef WINDOWSNT
1358 syms_of_ntproc (); 1376 syms_of_ntproc ();
1359#endif /* WINDOWSNT */ 1377#endif /* WINDOWSNT */
1378#if defined CYGWIN && defined HAVE_NTGUI
1379 syms_of_cygw32 ();
1380#endif
1360 syms_of_window (); 1381 syms_of_window ();
1361 syms_of_xdisp (); 1382 syms_of_xdisp ();
1362 syms_of_font (); 1383 syms_of_font ();
@@ -1387,11 +1408,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1387#ifdef HAVE_NTGUI 1408#ifdef HAVE_NTGUI
1388 syms_of_w32term (); 1409 syms_of_w32term ();
1389 syms_of_w32fns (); 1410 syms_of_w32fns ();
1390 syms_of_w32select ();
1391 syms_of_w32menu (); 1411 syms_of_w32menu ();
1392 syms_of_fontset (); 1412 syms_of_fontset ();
1393#endif /* HAVE_NTGUI */ 1413#endif /* HAVE_NTGUI */
1394 1414
1415#if defined WINDOWSNT || defined HAVE_NTGUI
1416 syms_of_w32select ();
1417#endif
1418
1395#ifdef MSDOS 1419#ifdef MSDOS
1396 syms_of_xmenu (); 1420 syms_of_xmenu ();
1397 syms_of_dosfns (); 1421 syms_of_dosfns ();
@@ -1436,8 +1460,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1436 globals_of_w32font (); 1460 globals_of_w32font ();
1437 globals_of_w32fns (); 1461 globals_of_w32fns ();
1438 globals_of_w32menu (); 1462 globals_of_w32menu ();
1439 globals_of_w32select ();
1440#endif /* HAVE_NTGUI */ 1463#endif /* HAVE_NTGUI */
1464
1465#if defined WINDOWSNT || defined HAVE_NTGUI
1466 globals_of_w32select ();
1467#endif
1441 } 1468 }
1442 1469
1443 init_charset (); 1470 init_charset ();
diff --git a/src/font.c b/src/font.c
index 1f22fee88ee..629e8bb977a 100644
--- a/src/font.c
+++ b/src/font.c
@@ -5208,9 +5208,9 @@ EMACS_FONT_LOG is set. Otherwise, it is set to t. */);
5208#ifdef HAVE_BDFFONT 5208#ifdef HAVE_BDFFONT
5209 syms_of_bdffont (); 5209 syms_of_bdffont ();
5210#endif /* HAVE_BDFFONT */ 5210#endif /* HAVE_BDFFONT */
5211#ifdef WINDOWSNT 5211#ifdef HAVE_NTGUI
5212 syms_of_w32font (); 5212 syms_of_w32font ();
5213#endif /* WINDOWSNT */ 5213#endif /* HAVE_NTGUI */
5214#ifdef HAVE_NS 5214#ifdef HAVE_NS
5215 syms_of_nsfont (); 5215 syms_of_nsfont ();
5216#endif /* HAVE_NS */ 5216#endif /* HAVE_NS */
diff --git a/src/font.h b/src/font.h
index 0475eb665dd..3035a909efc 100644
--- a/src/font.h
+++ b/src/font.h
@@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#define EMACS_FONT_H 23#define EMACS_FONT_H
24 24
25#include "ccl.h" 25#include "ccl.h"
26#include "frame.h"
26 27
27/* We have three types of Lisp objects related to font. 28/* We have three types of Lisp objects related to font.
28 29
@@ -818,11 +819,11 @@ extern struct font_driver ftxfont_driver;
818extern void syms_of_bdffont (void); 819extern void syms_of_bdffont (void);
819#endif /* HAVE_BDFFONT */ 820#endif /* HAVE_BDFFONT */
820#endif /* HAVE_X_WINDOWS */ 821#endif /* HAVE_X_WINDOWS */
821#ifdef WINDOWSNT 822#ifdef HAVE_NTGUI
822extern struct font_driver w32font_driver; 823extern struct font_driver w32font_driver;
823extern struct font_driver uniscribe_font_driver; 824extern struct font_driver uniscribe_font_driver;
824extern void syms_of_w32font (void); 825extern void syms_of_w32font (void);
825#endif /* WINDOWSNT */ 826#endif /* HAVE_NTGUI */
826#ifdef HAVE_NS 827#ifdef HAVE_NS
827extern Lisp_Object Qfontsize; 828extern Lisp_Object Qfontsize;
828extern struct font_driver nsfont_driver; 829extern struct font_driver nsfont_driver;
diff --git a/src/fontset.c b/src/fontset.c
index 7b051cbe1f3..da745b31ca1 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -42,7 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#ifdef HAVE_X_WINDOWS 42#ifdef HAVE_X_WINDOWS
43#include "xterm.h" 43#include "xterm.h"
44#endif 44#endif
45#ifdef WINDOWSNT 45#ifdef HAVE_NTGUI
46#include "w32term.h" 46#include "w32term.h"
47#endif 47#endif
48#ifdef HAVE_NS 48#ifdef HAVE_NS
diff --git a/src/frame.c b/src/frame.c
index 2fcf7275f9c..017d051fc1d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1124,7 +1124,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1124 struct frame *sf = SELECTED_FRAME (); 1124 struct frame *sf = SELECTED_FRAME ();
1125 struct kboard *kb; 1125 struct kboard *kb;
1126 1126
1127 int minibuffer_selected, tooltip_frame; 1127 int minibuffer_selected, is_tooltip_frame;
1128 1128
1129 if (EQ (frame, Qnil)) 1129 if (EQ (frame, Qnil))
1130 { 1130 {
@@ -1176,13 +1176,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip"))); 1179 is_tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip")));
1180 1180
1181 /* Run `delete-frame-functions' unless FORCE is `noelisp' or 1181 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1182 frame is a tooltip. FORCE is set to `noelisp' when handling 1182 frame is a tooltip. FORCE is set to `noelisp' when handling
1183 a disconnect from the terminal, so we don't dare call Lisp 1183 a disconnect from the terminal, so we don't dare call Lisp
1184 code. */ 1184 code. */
1185 if (NILP (Vrun_hooks) || tooltip_frame) 1185 if (NILP (Vrun_hooks) || is_tooltip_frame)
1186 ; 1186 ;
1187 else if (EQ (force, Qnoelisp)) 1187 else if (EQ (force, Qnoelisp))
1188 pending_funcalls 1188 pending_funcalls
@@ -1461,7 +1461,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1461 } 1461 }
1462 1462
1463 /* Cause frame titles to update--necessary if we now have just one frame. */ 1463 /* Cause frame titles to update--necessary if we now have just one frame. */
1464 if (!tooltip_frame) 1464 if (!is_tooltip_frame)
1465 update_mode_lines = 1; 1465 update_mode_lines = 1;
1466 1466
1467 return Qnil; 1467 return Qnil;
@@ -2697,7 +2697,7 @@ static const struct frame_parm_table frame_parms[] =
2697 {"tool-bar-position", &Qtool_bar_position}, 2697 {"tool-bar-position", &Qtool_bar_position},
2698}; 2698};
2699 2699
2700#ifdef WINDOWSNT 2700#ifdef HAVE_NTGUI
2701 2701
2702/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the 2702/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2703 wanted positions of the WM window (not Emacs window). 2703 wanted positions of the WM window (not Emacs window).
@@ -2741,7 +2741,7 @@ x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int
2741 *height = newheight; 2741 *height = newheight;
2742} 2742}
2743 2743
2744#endif /* WINDOWSNT */ 2744#endif /* HAVE_NTGUI */
2745 2745
2746#ifdef HAVE_WINDOW_SYSTEM 2746#ifdef HAVE_WINDOW_SYSTEM
2747 2747
diff --git a/src/frame.h b/src/frame.h
index 26235cc036e..7bf76c21c56 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -618,7 +618,7 @@ typedef struct frame *FRAME_PTR;
618#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial) 618#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
619#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) 619#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
620#define FRAME_X_P(f) ((f)->output_method == output_x_window) 620#define FRAME_X_P(f) ((f)->output_method == output_x_window)
621#ifndef WINDOWSNT 621#ifndef HAVE_NTGUI
622#define FRAME_W32_P(f) (0) 622#define FRAME_W32_P(f) (0)
623#else 623#else
624#define FRAME_W32_P(f) ((f)->output_method == output_w32) 624#define FRAME_W32_P(f) ((f)->output_method == output_w32)
@@ -1210,7 +1210,7 @@ extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1210 1210
1211extern Lisp_Object Qface_set_after_frame_default; 1211extern Lisp_Object Qface_set_after_frame_default;
1212 1212
1213#ifdef WINDOWSNT 1213#ifdef HAVE_NTGUI
1214extern void x_fullscreen_adjust (struct frame *f, int *, int *, 1214extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1215 int *, int *); 1215 int *, int *);
1216#endif 1216#endif
@@ -1282,6 +1282,7 @@ extern char *x_get_resource_string (const char *, const char *);
1282#endif 1282#endif
1283 1283
1284extern void x_query_colors (struct frame *f, XColor *, int); 1284extern void x_query_colors (struct frame *f, XColor *, int);
1285extern void x_query_color (struct frame *f, XColor *);
1285 1286
1286#endif /* HAVE_WINDOW_SYSTEM */ 1287#endif /* HAVE_WINDOW_SYSTEM */
1287 1288
diff --git a/src/image.c b/src/image.c
index 91eeb91920c..9b41cf74993 100644
--- a/src/image.c
+++ b/src/image.c
@@ -75,7 +75,12 @@ typedef struct x_bitmap_record Bitmap_Record;
75#endif /* HAVE_X_WINDOWS */ 75#endif /* HAVE_X_WINDOWS */
76 76
77#ifdef HAVE_NTGUI 77#ifdef HAVE_NTGUI
78#include "w32.h" 78
79/* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */
80#ifdef WINDOWSNT
81# include "w32.h"
82#endif
83
79/* W32_TODO : Color tables on W32. */ 84/* W32_TODO : Color tables on W32. */
80#undef COLOR_TABLE_SUPPORT 85#undef COLOR_TABLE_SUPPORT
81 86
@@ -560,8 +565,9 @@ static struct image_type *lookup_image_type (Lisp_Object);
560static void x_laplace (struct frame *, struct image *); 565static void x_laplace (struct frame *, struct image *);
561static void x_emboss (struct frame *, struct image *); 566static void x_emboss (struct frame *, struct image *);
562static void x_build_heuristic_mask (struct frame *, struct image *, 567static void x_build_heuristic_mask (struct frame *, struct image *,
563 Lisp_Object); 568 Lisp_Object);
564#ifdef HAVE_NTGUI 569#ifdef WINDOWSNT
570extern Lisp_Object Vlibrary_cache;
565#define CACHE_IMAGE_TYPE(type, status) \ 571#define CACHE_IMAGE_TYPE(type, status) \
566 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) 572 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
567#else 573#else
@@ -589,7 +595,7 @@ define_image_type (struct image_type *type)
589 595
590 if (type->init) 596 if (type->init)
591 { 597 {
592#ifdef HAVE_NTGUI 598#if defined HAVE_NTGUI && defined WINDOWSNT
593 /* If we failed to load the library before, don't try again. */ 599 /* If we failed to load the library before, don't try again. */
594 Lisp_Object tested = Fassq (target_type, Vlibrary_cache); 600 Lisp_Object tested = Fassq (target_type, Vlibrary_cache);
595 if (CONSP (tested) && NILP (XCDR (tested))) 601 if (CONSP (tested) && NILP (XCDR (tested)))
@@ -1834,7 +1840,7 @@ mark_image_cache (struct image_cache *c)
1834 X / NS / W32 support code 1840 X / NS / W32 support code
1835 ***********************************************************************/ 1841 ***********************************************************************/
1836 1842
1837#ifdef HAVE_NTGUI 1843#ifdef WINDOWSNT
1838 1844
1839/* Macro for defining functions that will be loaded from image DLLs. */ 1845/* Macro for defining functions that will be loaded from image DLLs. */
1840#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args 1846#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args
@@ -1845,7 +1851,7 @@ mark_image_cache (struct image_cache *c)
1845 if (!fn_##func) return 0; \ 1851 if (!fn_##func) return 0; \
1846 } 1852 }
1847 1853
1848#endif /* HAVE_NTGUI */ 1854#endif /* WINDOWSNT */
1849 1855
1850/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the 1856/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the
1851 windowing system. 1857 windowing system.
@@ -2897,7 +2903,7 @@ xbm_load (struct frame *f, struct image *img)
2897 else 2903 else
2898 bits = (char *) XBOOL_VECTOR (data)->data; 2904 bits = (char *) XBOOL_VECTOR (data)->data;
2899 2905
2900#ifdef WINDOWSNT 2906#ifdef HAVE_NTGUI
2901 { 2907 {
2902 char *invertedBits; 2908 char *invertedBits;
2903 int nbytes, i; 2909 int nbytes, i;
@@ -3008,7 +3014,7 @@ static const struct image_keyword xpm_format[XPM_LAST] =
3008 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 3014 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
3009}; 3015};
3010 3016
3011#ifdef HAVE_NTGUI 3017#if defined HAVE_NTGUI && defined WINDOWSNT
3012static bool init_xpm_functions (void); 3018static bool init_xpm_functions (void);
3013#else 3019#else
3014#define init_xpm_functions NULL 3020#define init_xpm_functions NULL
@@ -3207,7 +3213,7 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *
3207#endif /* ALLOC_XPM_COLORS */ 3213#endif /* ALLOC_XPM_COLORS */
3208 3214
3209 3215
3210#ifdef HAVE_NTGUI 3216#ifdef WINDOWSNT
3211 3217
3212/* XPM library details. */ 3218/* XPM library details. */
3213 3219
@@ -3233,8 +3239,15 @@ init_xpm_functions (void)
3233 return 1; 3239 return 1;
3234} 3240}
3235 3241
3236#endif /* HAVE_NTGUI */ 3242#endif /* WINDOWSNT */
3237 3243
3244#if defined HAVE_NTGUI && !defined WINDOWSNT
3245/* Glue for code below */
3246#define fn_XpmReadFileToImage XpmReadFileToImage
3247#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer
3248#define fn_XImageFree XImageFree
3249#define fn_XpmFreeAttributes XpmFreeAttributes
3250#endif /* HAVE_NTGUI && !WINDOWSNT */
3238 3251
3239/* Value is true if COLOR_SYMBOLS is a valid color symbols list 3252/* Value is true if COLOR_SYMBOLS is a valid color symbols list
3240 for XPM images. Such a list must consist of conses whose car and 3253 for XPM images. Such a list must consist of conses whose car and
@@ -5340,7 +5353,7 @@ static const struct image_keyword png_format[PNG_LAST] =
5340 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 5353 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
5341}; 5354};
5342 5355
5343#ifdef HAVE_NTGUI 5356#if defined HAVE_NTGUI && defined WINDOWSNT
5344static bool init_png_functions (void); 5357static bool init_png_functions (void);
5345#else 5358#else
5346#define init_png_functions NULL 5359#define init_png_functions NULL
@@ -5378,7 +5391,7 @@ png_image_p (Lisp_Object object)
5378 5391
5379#ifdef HAVE_PNG 5392#ifdef HAVE_PNG
5380 5393
5381#ifdef HAVE_NTGUI 5394#ifdef WINDOWSNT
5382/* PNG library details. */ 5395/* PNG library details. */
5383 5396
5384DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); 5397DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp));
@@ -5478,7 +5491,7 @@ init_png_functions (void)
5478#define fn_png_set_longjmp_fn png_set_longjmp_fn 5491#define fn_png_set_longjmp_fn png_set_longjmp_fn
5479#endif /* libpng version >= 1.5 */ 5492#endif /* libpng version >= 1.5 */
5480 5493
5481#endif /* HAVE_NTGUI */ 5494#endif /* WINDOWSNT */
5482 5495
5483/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp. 5496/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp.
5484 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp 5497 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp
@@ -5999,7 +6012,7 @@ static const struct image_keyword jpeg_format[JPEG_LAST] =
5999 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 6012 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
6000}; 6013};
6001 6014
6002#ifdef HAVE_NTGUI 6015#if defined HAVE_NTGUI && defined WINDOWSNT
6003static bool init_jpeg_functions (void); 6016static bool init_jpeg_functions (void);
6004#else 6017#else
6005#define init_jpeg_functions NULL 6018#define init_jpeg_functions NULL
@@ -6049,14 +6062,27 @@ jpeg_image_p (Lisp_Object object)
6049#define __WIN32__ 1 6062#define __WIN32__ 1
6050#endif 6063#endif
6051 6064
6065/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types.
6066 Some versions of jpeglib try to detect whether rpcndr.h is loaded,
6067 using the Windows boolean type instead of the jpeglib boolean type
6068 if so. Cygwin jpeglib, however, doesn't try to detect whether its
6069 headers are included along with windows.h, so under Cygwin, jpeglib
6070 attempts to define a conflicting boolean type. Worse, forcing
6071 Cygwin jpeglib headers to use the Windows boolean type doesn't work
6072 because it created an ABI incompatibility between the
6073 already-compiled jpeg library and the header interface definition.
6074
6075 The best we can do is to define jpeglib's boolean type to a
6076 different name. This name, jpeg_boolean, remains in effect through
6077 the rest of image.c.
6078*/
6079#if defined CYGWIN && defined HAVE_NTGUI
6080#define boolean jpeg_boolean
6081#endif
6052#include <jpeglib.h> 6082#include <jpeglib.h>
6053#include <jerror.h> 6083#include <jerror.h>
6054 6084
6055#ifdef HAVE_STLIB_H_1 6085#ifdef WINDOWSNT
6056#define HAVE_STDLIB_H 1
6057#endif
6058
6059#ifdef HAVE_NTGUI
6060 6086
6061/* JPEG library details. */ 6087/* JPEG library details. */
6062DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); 6088DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t));
@@ -6106,7 +6132,7 @@ jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6106#define fn_jpeg_std_error jpeg_std_error 6132#define fn_jpeg_std_error jpeg_std_error
6107#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart 6133#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart
6108 6134
6109#endif /* HAVE_NTGUI */ 6135#endif /* WINDOWSNT */
6110 6136
6111struct my_jpeg_error_mgr 6137struct my_jpeg_error_mgr
6112{ 6138{
@@ -6630,7 +6656,7 @@ tiff_image_p (Lisp_Object object)
6630 6656
6631#include <tiffio.h> 6657#include <tiffio.h>
6632 6658
6633#ifdef HAVE_NTGUI 6659#ifdef WINDOWSNT
6634 6660
6635/* TIFF library details. */ 6661/* TIFF library details. */
6636DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); 6662DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler));
@@ -6674,7 +6700,7 @@ init_tiff_functions (void)
6674#define fn_TIFFReadRGBAImage TIFFReadRGBAImage 6700#define fn_TIFFReadRGBAImage TIFFReadRGBAImage
6675#define fn_TIFFClose TIFFClose 6701#define fn_TIFFClose TIFFClose
6676#define fn_TIFFSetDirectory TIFFSetDirectory 6702#define fn_TIFFSetDirectory TIFFSetDirectory
6677#endif /* HAVE_NTGUI */ 6703#endif /* WINDOWSNT */
6678 6704
6679 6705
6680/* Reading from a memory buffer for TIFF images Based on the PNG 6706/* Reading from a memory buffer for TIFF images Based on the PNG
@@ -7046,7 +7072,7 @@ static const struct image_keyword gif_format[GIF_LAST] =
7046 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 7072 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
7047}; 7073};
7048 7074
7049#ifdef HAVE_NTGUI 7075#if defined HAVE_NTGUI && defined WINDOWSNT
7050static bool init_gif_functions (void); 7076static bool init_gif_functions (void);
7051#else 7077#else
7052#define init_gif_functions NULL 7078#define init_gif_functions NULL
@@ -7110,7 +7136,7 @@ gif_image_p (Lisp_Object object)
7110#endif /* HAVE_NTGUI */ 7136#endif /* HAVE_NTGUI */
7111 7137
7112 7138
7113#ifdef HAVE_NTGUI 7139#ifdef WINDOWSNT
7114 7140
7115/* GIF library details. */ 7141/* GIF library details. */
7116DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); 7142DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *));
@@ -7140,7 +7166,7 @@ init_gif_functions (void)
7140#define fn_DGifOpen DGifOpen 7166#define fn_DGifOpen DGifOpen
7141#define fn_DGifOpenFileName DGifOpenFileName 7167#define fn_DGifOpenFileName DGifOpenFileName
7142 7168
7143#endif /* HAVE_NTGUI */ 7169#endif /* WINDOWSNT */
7144 7170
7145/* Reading a GIF image from memory 7171/* Reading a GIF image from memory
7146 Based on the PNG memory stuff to a certain extent. */ 7172 Based on the PNG memory stuff to a certain extent. */
@@ -8137,7 +8163,7 @@ svg_image_p (Lisp_Object object)
8137 8163
8138#include <librsvg/rsvg.h> 8164#include <librsvg/rsvg.h>
8139 8165
8140#ifdef HAVE_NTGUI 8166#ifdef WINDOWSNT
8141 8167
8142/* SVG library functions. */ 8168/* SVG library functions. */
8143DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new); 8169DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new);
@@ -8215,7 +8241,7 @@ init_svg_functions (void)
8215#define fn_g_type_init g_type_init 8241#define fn_g_type_init g_type_init
8216#define fn_g_object_unref g_object_unref 8242#define fn_g_object_unref g_object_unref
8217#define fn_g_error_free g_error_free 8243#define fn_g_error_free g_error_free
8218#endif /* !HAVE_NTGUI */ 8244#endif /* !WINDOWSNT */
8219 8245
8220/* Load SVG image IMG for use on frame F. Value is true if 8246/* Load SVG image IMG for use on frame F. Value is true if
8221 successful. */ 8247 successful. */
diff --git a/src/indent.c b/src/indent.c
index b368a7aeb09..81a63455ecb 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include "frame.h" 30#include "frame.h"
31#include "window.h" 31#include "window.h"
32#include "termchar.h" 32#include "termchar.h"
33#include "termopts.h"
34#include "disptab.h" 33#include "disptab.h"
35#include "intervals.h" 34#include "intervals.h"
36#include "dispextern.h" 35#include "dispextern.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index d06b02024c5..d58178b7561 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -86,8 +86,8 @@ KBOARD *initial_kboard;
86KBOARD *current_kboard; 86KBOARD *current_kboard;
87KBOARD *all_kboards; 87KBOARD *all_kboards;
88 88
89/* Nonzero in the single-kboard state, 0 in the any-kboard state. */ 89/* True in the single-kboard state, false in the any-kboard state. */
90static int single_kboard; 90static bool single_kboard;
91 91
92/* Non-nil disable property on a command means 92/* Non-nil disable property on a command means
93 do not execute it; call disabled-command-function's value instead. */ 93 do not execute it; call disabled-command-function's value instead. */
@@ -113,9 +113,9 @@ static Lisp_Object recent_keys;
113Lisp_Object this_command_keys; 113Lisp_Object this_command_keys;
114ptrdiff_t this_command_key_count; 114ptrdiff_t this_command_key_count;
115 115
116/* 1 after calling Freset_this_command_lengths. 116/* True after calling Freset_this_command_lengths.
117 Usually it is 0. */ 117 Usually it is false. */
118static int this_command_key_count_reset; 118static bool this_command_key_count_reset;
119 119
120/* This vector is used as a buffer to record the events that were actually read 120/* This vector is used as a buffer to record the events that were actually read
121 by read_key_sequence. */ 121 by read_key_sequence. */
@@ -140,11 +140,11 @@ static ptrdiff_t before_command_echo_length;
140static sys_jmp_buf getcjmp; 140static sys_jmp_buf getcjmp;
141 141
142/* True while doing kbd input. */ 142/* True while doing kbd input. */
143int waiting_for_input; 143bool waiting_for_input;
144 144
145/* True while displaying for echoing. Delays C-g throwing. */ 145/* True while displaying for echoing. Delays C-g throwing. */
146 146
147static int echoing; 147static bool echoing;
148 148
149/* Non-null means we can start echoing at the next input pause even 149/* Non-null means we can start echoing at the next input pause even
150 though there is something in the echo area. */ 150 though there is something in the echo area. */
@@ -163,8 +163,8 @@ struct kboard *echo_kboard;
163 163
164Lisp_Object echo_message_buffer; 164Lisp_Object echo_message_buffer;
165 165
166/* Nonzero means C-g should cause immediate error-signal. */ 166/* True means C-g should cause immediate error-signal. */
167int immediate_quit; 167bool immediate_quit;
168 168
169/* Character that causes a quit. Normally C-g. 169/* Character that causes a quit. Normally C-g.
170 170
@@ -270,7 +270,7 @@ static Lisp_Object Qhelp_form_show;
270static FILE *dribble; 270static FILE *dribble;
271 271
272/* Nonzero if input is available. */ 272/* Nonzero if input is available. */
273int input_pending; 273bool input_pending;
274 274
275/* Circular buffer for pre-read keyboard input. */ 275/* Circular buffer for pre-read keyboard input. */
276 276
@@ -313,7 +313,7 @@ static Lisp_Object Qmouse_fixup_help_message;
313/* Symbols to denote kinds of events. */ 313/* Symbols to denote kinds of events. */
314static Lisp_Object Qfunction_key; 314static Lisp_Object Qfunction_key;
315Lisp_Object Qmouse_click; 315Lisp_Object Qmouse_click;
316#if defined (WINDOWSNT) 316#ifdef HAVE_NTGUI
317Lisp_Object Qlanguage_change; 317Lisp_Object Qlanguage_change;
318#endif 318#endif
319static Lisp_Object Qdrag_n_drop; 319static Lisp_Object Qdrag_n_drop;
@@ -372,18 +372,18 @@ static ptrdiff_t echo_length (void);
372static Lisp_Object Qpolling_period; 372static Lisp_Object Qpolling_period;
373 373
374/* Incremented whenever a timer is run. */ 374/* Incremented whenever a timer is run. */
375int timers_run; 375unsigned timers_run;
376 376
377/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt 377/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
378 happens. */ 378 happens. */
379EMACS_TIME *input_available_clear_time; 379EMACS_TIME *input_available_clear_time;
380 380
381/* Nonzero means use SIGIO interrupts; zero means use CBREAK mode. 381/* True means use SIGIO interrupts; false means use CBREAK mode.
382 Default is 1 if INTERRUPT_INPUT is defined. */ 382 Default is true if INTERRUPT_INPUT is defined. */
383int interrupt_input; 383bool interrupt_input;
384 384
385/* Nonzero while interrupts are temporarily deferred during redisplay. */ 385/* Nonzero while interrupts are temporarily deferred during redisplay. */
386int interrupts_deferred; 386bool interrupts_deferred;
387 387
388/* If we support a window system, turn on the code to poll periodically 388/* If we support a window system, turn on the code to poll periodically
389 to detect C-g. It isn't actually used when doing interrupt input. */ 389 to detect C-g. It isn't actually used when doing interrupt input. */
@@ -411,10 +411,10 @@ static EMACS_TIME timer_last_idleness_start_time;
411/* Function for init_keyboard to call with no args (if nonzero). */ 411/* Function for init_keyboard to call with no args (if nonzero). */
412static void (*keyboard_init_hook) (void); 412static void (*keyboard_init_hook) (void);
413 413
414static void get_input_pending (int *, int); 414static bool get_input_pending (int);
415static int readable_events (int); 415static bool readable_events (int);
416static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, 416static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *,
417 Lisp_Object, int *); 417 Lisp_Object, bool *);
418static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, 418static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t,
419 Lisp_Object *); 419 Lisp_Object *);
420static Lisp_Object make_lispy_event (struct input_event *); 420static Lisp_Object make_lispy_event (struct input_event *);
@@ -428,7 +428,7 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
428 Lisp_Object, const char *const *, 428 Lisp_Object, const char *const *,
429 Lisp_Object *, ptrdiff_t); 429 Lisp_Object *, ptrdiff_t);
430static Lisp_Object make_lispy_switch_frame (Lisp_Object); 430static Lisp_Object make_lispy_switch_frame (Lisp_Object);
431static int help_char_p (Lisp_Object); 431static bool help_char_p (Lisp_Object);
432static void save_getcjmp (sys_jmp_buf); 432static void save_getcjmp (sys_jmp_buf);
433static void restore_getcjmp (sys_jmp_buf); 433static void restore_getcjmp (sys_jmp_buf);
434static Lisp_Object apply_modifiers (int, Lisp_Object); 434static Lisp_Object apply_modifiers (int, Lisp_Object);
@@ -438,7 +438,7 @@ static Lisp_Object restore_kboard_configuration (Lisp_Object);
438static void deliver_input_available_signal (int signo); 438static void deliver_input_available_signal (int signo);
439#endif 439#endif
440static void handle_interrupt (bool); 440static void handle_interrupt (bool);
441static _Noreturn void quit_throw_to_read_char (int); 441static _Noreturn void quit_throw_to_read_char (bool);
442static void process_special_events (void); 442static void process_special_events (void);
443static void timer_start_idle (void); 443static void timer_start_idle (void);
444static void timer_stop_idle (void); 444static void timer_stop_idle (void);
@@ -516,7 +516,7 @@ echo_char (Lisp_Object c)
516 516
517 if (INTEGERP (c)) 517 if (INTEGERP (c))
518 { 518 {
519 ptr = push_key_description (XINT (c), ptr, 1); 519 ptr = push_key_description (XINT (c), ptr);
520 } 520 }
521 else if (SYMBOLP (c)) 521 else if (SYMBOLP (c))
522 { 522 {
@@ -925,7 +925,7 @@ pop_kboard (void)
925{ 925{
926 struct terminal *t; 926 struct terminal *t;
927 struct kboard_stack *p = kboard_stack; 927 struct kboard_stack *p = kboard_stack;
928 int found = 0; 928 bool found = 0;
929 for (t = terminal_list; t; t = t->next_terminal) 929 for (t = terminal_list; t; t = t->next_terminal)
930 { 930 {
931 if (t->kboard == p->kboard) 931 if (t->kboard == p->kboard)
@@ -958,7 +958,7 @@ pop_kboard (void)
958void 958void
959temporarily_switch_to_single_kboard (struct frame *f) 959temporarily_switch_to_single_kboard (struct frame *f)
960{ 960{
961 int was_locked = single_kboard; 961 bool was_locked = single_kboard;
962 if (was_locked) 962 if (was_locked)
963 { 963 {
964 if (f != NULL && FRAME_KBOARD (f) != current_kboard) 964 if (f != NULL && FRAME_KBOARD (f) != current_kboard)
@@ -1057,12 +1057,7 @@ cmd_error (Lisp_Object data)
1057 Vprint_length = old_length; 1057 Vprint_length = old_length;
1058 1058
1059 Vquit_flag = Qnil; 1059 Vquit_flag = Qnil;
1060
1061 Vinhibit_quit = Qnil; 1060 Vinhibit_quit = Qnil;
1062#if 0 /* This shouldn't be necessary anymore. --lorentey */
1063 if (command_loop_level == 0 && minibuf_level == 0)
1064 any_kboard_state ();
1065#endif
1066 1061
1067 return make_number (0); 1062 return make_number (0);
1068} 1063}
@@ -1149,12 +1144,6 @@ command_loop (void)
1149 while (1) 1144 while (1)
1150 { 1145 {
1151 internal_catch (Qtop_level, top_level_1, Qnil); 1146 internal_catch (Qtop_level, top_level_1, Qnil);
1152#if 0 /* This shouldn't be necessary anymore. --lorentey */
1153 /* Reset single_kboard in case top-level set it while
1154 evaluating an -f option, or we are stuck there for some
1155 other reason. */
1156 any_kboard_state ();
1157#endif
1158 internal_catch (Qtop_level, command_loop_2, Qnil); 1147 internal_catch (Qtop_level, command_loop_2, Qnil);
1159 executing_kbd_macro = Qnil; 1148 executing_kbd_macro = Qnil;
1160 1149
@@ -1265,8 +1254,7 @@ tracking_off (Lisp_Object old_value)
1265 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW)) 1254 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
1266 { 1255 {
1267 redisplay_preserve_echo_area (6); 1256 redisplay_preserve_echo_area (6);
1268 get_input_pending (&input_pending, 1257 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
1269 READABLE_EVENTS_DO_TIMERS_NOW);
1270 } 1258 }
1271 } 1259 }
1272 return Qnil; 1260 return Qnil;
@@ -1301,7 +1289,7 @@ usage: (track-mouse BODY...) */)
1301#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS 1289#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS
1302static 1290static
1303#endif 1291#endif
1304int ignore_mouse_drag_p; 1292bool ignore_mouse_drag_p;
1305 1293
1306static FRAME_PTR 1294static FRAME_PTR
1307some_mouse_moved (void) 1295some_mouse_moved (void)
@@ -1329,9 +1317,9 @@ some_mouse_moved (void)
1329 sans error-handling encapsulation. */ 1317 sans error-handling encapsulation. */
1330 1318
1331static int read_key_sequence (Lisp_Object *, int, Lisp_Object, 1319static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
1332 int, int, int); 1320 bool, bool, bool);
1333void safe_run_hooks (Lisp_Object); 1321void safe_run_hooks (Lisp_Object);
1334static void adjust_point_for_property (ptrdiff_t, int); 1322static void adjust_point_for_property (ptrdiff_t, bool);
1335 1323
1336/* Cancel hourglass from protect_unwind. 1324/* Cancel hourglass from protect_unwind.
1337 ARG is not used. */ 1325 ARG is not used. */
@@ -1359,10 +1347,7 @@ command_loop_1 (void)
1359 int i; 1347 int i;
1360 EMACS_INT prev_modiff = 0; 1348 EMACS_INT prev_modiff = 0;
1361 struct buffer *prev_buffer = NULL; 1349 struct buffer *prev_buffer = NULL;
1362#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1350 bool already_adjusted = 0;
1363 int was_locked = single_kboard;
1364#endif
1365 int already_adjusted = 0;
1366 1351
1367 kset_prefix_arg (current_kboard, Qnil); 1352 kset_prefix_arg (current_kboard, Qnil);
1368 kset_last_prefix_arg (current_kboard, Qnil); 1353 kset_last_prefix_arg (current_kboard, Qnil);
@@ -1731,10 +1716,6 @@ command_loop_1 (void)
1731 if (!NILP (KVAR (current_kboard, defining_kbd_macro)) 1716 if (!NILP (KVAR (current_kboard, defining_kbd_macro))
1732 && NILP (KVAR (current_kboard, Vprefix_arg))) 1717 && NILP (KVAR (current_kboard, Vprefix_arg)))
1733 finalize_kbd_macro_chars (); 1718 finalize_kbd_macro_chars ();
1734#if 0 /* This shouldn't be necessary anymore. --lorentey */
1735 if (!was_locked)
1736 any_kboard_state ();
1737#endif
1738 } 1719 }
1739} 1720}
1740 1721
@@ -1744,7 +1725,7 @@ command_loop_1 (void)
1744 LAST_PT is the last position of point. */ 1725 LAST_PT is the last position of point. */
1745 1726
1746static void 1727static void
1747adjust_point_for_property (ptrdiff_t last_pt, int modified) 1728adjust_point_for_property (ptrdiff_t last_pt, bool modified)
1748{ 1729{
1749 ptrdiff_t beg, end; 1730 ptrdiff_t beg, end;
1750 Lisp_Object val, overlay, tmp; 1731 Lisp_Object val, overlay, tmp;
@@ -1752,7 +1733,7 @@ adjust_point_for_property (ptrdiff_t last_pt, int modified)
1752 suppress the point adjustment for automatic composition so that a 1733 suppress the point adjustment for automatic composition so that a
1753 user can keep inserting another character at point or keep 1734 user can keep inserting another character at point or keep
1754 deleting characters around point. */ 1735 deleting characters around point. */
1755 int check_composition = ! modified, check_display = 1, check_invisible = 1; 1736 bool check_composition = ! modified, check_display = 1, check_invisible = 1;
1756 ptrdiff_t orig_pt = PT; 1737 ptrdiff_t orig_pt = PT;
1757 1738
1758 /* FIXME: cycling is probably not necessary because these properties 1739 /* FIXME: cycling is probably not necessary because these properties
@@ -1791,7 +1772,8 @@ adjust_point_for_property (ptrdiff_t last_pt, int modified)
1791 check_display = 0; 1772 check_display = 0;
1792 if (check_invisible && PT > BEGV && PT < ZV) 1773 if (check_invisible && PT > BEGV && PT < ZV)
1793 { 1774 {
1794 int inv, ellipsis = 0; 1775 int inv;
1776 bool ellipsis = 0;
1795 beg = end = PT; 1777 beg = end = PT;
1796 1778
1797 /* Find boundaries `beg' and `end' of the invisible area, if any. */ 1779 /* Find boundaries `beg' and `end' of the invisible area, if any. */
@@ -1920,7 +1902,7 @@ safe_run_hooks_error (Lisp_Object error_data)
1920 if (SYMBOLP (hook)) 1902 if (SYMBOLP (hook))
1921 { 1903 {
1922 Lisp_Object val; 1904 Lisp_Object val;
1923 int found = 0; 1905 bool found = 0;
1924 Lisp_Object newval = Qnil; 1906 Lisp_Object newval = Qnil;
1925 for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val)) 1907 for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val))
1926 if (EQ (fun, XCAR (val))) 1908 if (EQ (fun, XCAR (val)))
@@ -2050,9 +2032,9 @@ start_polling (void)
2050#endif 2032#endif
2051} 2033}
2052 2034
2053/* Nonzero if we are using polling to handle input asynchronously. */ 2035/* True if we are using polling to handle input asynchronously. */
2054 2036
2055int 2037bool
2056input_polling_used (void) 2038input_polling_used (void)
2057{ 2039{
2058#ifdef POLL_FOR_INPUT 2040#ifdef POLL_FOR_INPUT
@@ -2228,7 +2210,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
2228 2210
2229/* Input of single characters from keyboard */ 2211/* Input of single characters from keyboard */
2230 2212
2231static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, int *used_mouse_menu, 2213static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
2232 EMACS_TIME *end_time); 2214 EMACS_TIME *end_time);
2233static void record_char (Lisp_Object c); 2215static void record_char (Lisp_Object c);
2234 2216
@@ -2265,9 +2247,9 @@ do { if (polling_stopped_here) start_polling (); \
2265 not to run input methods, but in other respects to act as if 2247 not to run input methods, but in other respects to act as if
2266 not reading a key sequence. 2248 not reading a key sequence.
2267 2249
2268 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1 2250 If USED_MOUSE_MENU is non-null, then set *USED_MOUSE_MENU to true
2269 if we used a mouse menu to read the input, or zero otherwise. If 2251 if we used a mouse menu to read the input, or false otherwise. If
2270 USED_MOUSE_MENU is null, we don't dereference it. 2252 USED_MOUSE_MENU is null, don't dereference it.
2271 2253
2272 Value is -2 when we find input on another keyboard. A second call 2254 Value is -2 when we find input on another keyboard. A second call
2273 to read_char will read it. 2255 to read_char will read it.
@@ -2281,7 +2263,7 @@ do { if (polling_stopped_here) start_polling (); \
2281Lisp_Object 2263Lisp_Object
2282read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, 2264read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2283 Lisp_Object prev_event, 2265 Lisp_Object prev_event,
2284 int *used_mouse_menu, EMACS_TIME *end_time) 2266 bool *used_mouse_menu, EMACS_TIME *end_time)
2285{ 2267{
2286 Lisp_Object c; 2268 Lisp_Object c;
2287 ptrdiff_t jmpcount; 2269 ptrdiff_t jmpcount;
@@ -2290,9 +2272,9 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2290 Lisp_Object tem, save; 2272 Lisp_Object tem, save;
2291 volatile Lisp_Object previous_echo_area_message; 2273 volatile Lisp_Object previous_echo_area_message;
2292 volatile Lisp_Object also_record; 2274 volatile Lisp_Object also_record;
2293 volatile int reread; 2275 volatile bool reread;
2294 struct gcpro gcpro1, gcpro2; 2276 struct gcpro gcpro1, gcpro2;
2295 int volatile polling_stopped_here = 0; 2277 bool volatile polling_stopped_here = 0;
2296 struct kboard *orig_kboard = current_kboard; 2278 struct kboard *orig_kboard = current_kboard;
2297 2279
2298 also_record = Qnil; 2280 also_record = Qnil;
@@ -2328,7 +2310,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2328 2310
2329 if (CONSP (Vunread_command_events)) 2311 if (CONSP (Vunread_command_events))
2330 { 2312 {
2331 int was_disabled = 0; 2313 bool was_disabled = 0;
2332 2314
2333 c = XCAR (Vunread_command_events); 2315 c = XCAR (Vunread_command_events);
2334 Vunread_command_events = XCDR (Vunread_command_events); 2316 Vunread_command_events = XCDR (Vunread_command_events);
@@ -2430,7 +2412,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2430 /* if redisplay was requested */ 2412 /* if redisplay was requested */
2431 if (commandflag >= 0) 2413 if (commandflag >= 0)
2432 { 2414 {
2433 int echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); 2415 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]);
2434 2416
2435 /* If there is pending input, process any events which are not 2417 /* If there is pending input, process any events which are not
2436 user-visible, such as X selection_request events. */ 2418 user-visible, such as X selection_request events. */
@@ -2862,12 +2844,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2862 if (!NILP (tem)) 2844 if (!NILP (tem))
2863 { 2845 {
2864 struct buffer *prev_buffer = current_buffer; 2846 struct buffer *prev_buffer = current_buffer;
2865#if 0 /* This shouldn't be necessary anymore. --lorentey */
2866 int was_locked = single_kboard;
2867 ptrdiff_t count = SPECPDL_INDEX ();
2868 record_single_kboard_state ();
2869#endif
2870
2871 last_input_event = c; 2847 last_input_event = c;
2872 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt); 2848 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt);
2873 2849
@@ -2878,13 +2854,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2878 example banishing the mouse under mouse-avoidance-mode. */ 2854 example banishing the mouse under mouse-avoidance-mode. */
2879 timer_resume_idle (); 2855 timer_resume_idle ();
2880 2856
2881#if 0 /* This shouldn't be necessary anymore. --lorentey */
2882 /* Resume allowing input from any kboard, if that was true before. */
2883 if (!was_locked)
2884 any_kboard_state ();
2885 unbind_to (count, Qnil);
2886#endif
2887
2888 if (current_buffer != prev_buffer) 2857 if (current_buffer != prev_buffer)
2889 { 2858 {
2890 /* The command may have changed the keymaps. Pretend there 2859 /* The command may have changed the keymaps. Pretend there
@@ -2992,15 +2961,15 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2992 { 2961 {
2993 Lisp_Object keys; 2962 Lisp_Object keys;
2994 ptrdiff_t key_count; 2963 ptrdiff_t key_count;
2995 int key_count_reset; 2964 bool key_count_reset;
2996 struct gcpro gcpro1; 2965 struct gcpro gcpro1;
2997 ptrdiff_t count = SPECPDL_INDEX (); 2966 ptrdiff_t count = SPECPDL_INDEX ();
2998 2967
2999 /* Save the echo status. */ 2968 /* Save the echo status. */
3000 int saved_immediate_echo = current_kboard->immediate_echo; 2969 bool saved_immediate_echo = current_kboard->immediate_echo;
3001 struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause; 2970 struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause;
3002 Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); 2971 Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string);
3003 int saved_echo_after_prompt = current_kboard->echo_after_prompt; 2972 ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt;
3004 2973
3005#if 0 2974#if 0
3006 if (before_command_restore_flag) 2975 if (before_command_restore_flag)
@@ -3201,9 +3170,9 @@ record_menu_key (Lisp_Object c)
3201 num_input_events++; 3170 num_input_events++;
3202} 3171}
3203 3172
3204/* Return 1 if should recognize C as "the help character". */ 3173/* Return true if should recognize C as "the help character". */
3205 3174
3206static int 3175static bool
3207help_char_p (Lisp_Object c) 3176help_char_p (Lisp_Object c)
3208{ 3177{
3209 Lisp_Object tail; 3178 Lisp_Object tail;
@@ -3375,7 +3344,7 @@ restore_getcjmp (sys_jmp_buf temp)
3375 3344
3376/* Return true if there are any events in the queue that read-char 3345/* Return true if there are any events in the queue that read-char
3377 would return. If this returns false, a read-char would block. */ 3346 would return. If this returns false, a read-char would block. */
3378static int 3347static bool
3379readable_events (int flags) 3348readable_events (int flags)
3380{ 3349{
3381 if (flags & READABLE_EVENTS_DO_TIMERS_NOW) 3350 if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
@@ -3714,15 +3683,14 @@ discard_mouse_events (void)
3714} 3683}
3715 3684
3716 3685
3717/* Return non-zero if there are any real events waiting in the event 3686/* Return true if there are any real events waiting in the event
3718 buffer, not counting `NO_EVENT's. 3687 buffer, not counting `NO_EVENT's.
3719 3688
3720 If DISCARD is non-zero, discard NO_EVENT events at the front of 3689 Discard NO_EVENT events at the front of the input queue, possibly
3721 the input queue, possibly leaving the input queue empty if there 3690 leaving the input queue empty if there are no real input events. */
3722 are no real input events. */
3723 3691
3724int 3692bool
3725kbd_buffer_events_waiting (int discard) 3693kbd_buffer_events_waiting (void)
3726{ 3694{
3727 struct input_event *sp; 3695 struct input_event *sp;
3728 3696
@@ -3734,9 +3702,7 @@ kbd_buffer_events_waiting (int discard)
3734 sp = kbd_buffer; 3702 sp = kbd_buffer;
3735 } 3703 }
3736 3704
3737 if (discard) 3705 kbd_fetch_ptr = sp;
3738 kbd_fetch_ptr = sp;
3739
3740 return sp != kbd_store_ptr && sp->kind != NO_EVENT; 3706 return sp != kbd_store_ptr && sp->kind != NO_EVENT;
3741} 3707}
3742 3708
@@ -3758,7 +3724,7 @@ clear_event (struct input_event *event)
3758 3724
3759static Lisp_Object 3725static Lisp_Object
3760kbd_buffer_get_event (KBOARD **kbp, 3726kbd_buffer_get_event (KBOARD **kbp,
3761 int *used_mouse_menu, 3727 bool *used_mouse_menu,
3762 EMACS_TIME *end_time) 3728 EMACS_TIME *end_time)
3763{ 3729{
3764 Lisp_Object obj; 3730 Lisp_Object obj;
@@ -3766,8 +3732,8 @@ kbd_buffer_get_event (KBOARD **kbp,
3766#ifdef subprocesses 3732#ifdef subprocesses
3767 if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4) 3733 if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4)
3768 { 3734 {
3769 /* Start reading input again, we have processed enough so we can 3735 /* Start reading input again because we have processed enough to
3770 accept new events again. */ 3736 be able to accept new events again. */
3771 unhold_keyboard_input (); 3737 unhold_keyboard_input ();
3772 start_polling (); 3738 start_polling ();
3773 } 3739 }
@@ -3947,7 +3913,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3947 x_activate_menubar (XFRAME (event->frame_or_window)); 3913 x_activate_menubar (XFRAME (event->frame_or_window));
3948 } 3914 }
3949#endif 3915#endif
3950#if defined (WINDOWSNT) 3916#ifdef HAVE_NTGUI
3951 else if (event->kind == LANGUAGE_CHANGE_EVENT) 3917 else if (event->kind == LANGUAGE_CHANGE_EVENT)
3952 { 3918 {
3953 /* Make an event (language-change (FRAME CODEPAGE LANGUAGE-ID)). */ 3919 /* Make an event (language-change (FRAME CODEPAGE LANGUAGE-ID)). */
@@ -4203,14 +4169,14 @@ process_special_events (void)
4203 are ripe, and return, without reading any user-visible events. */ 4169 are ripe, and return, without reading any user-visible events. */
4204 4170
4205void 4171void
4206swallow_events (int do_display) 4172swallow_events (bool do_display)
4207{ 4173{
4208 int old_timers_run; 4174 unsigned old_timers_run;
4209 4175
4210 process_special_events (); 4176 process_special_events ();
4211 4177
4212 old_timers_run = timers_run; 4178 old_timers_run = timers_run;
4213 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW); 4179 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
4214 4180
4215 if (timers_run != old_timers_run && do_display) 4181 if (timers_run != old_timers_run && do_display)
4216 redisplay_preserve_echo_area (7); 4182 redisplay_preserve_echo_area (7);
@@ -4337,7 +4303,7 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
4337 EMACS_TIME difference; 4303 EMACS_TIME difference;
4338 EMACS_TIME timer_difference = invalid_emacs_time (); 4304 EMACS_TIME timer_difference = invalid_emacs_time ();
4339 EMACS_TIME idle_timer_difference = invalid_emacs_time (); 4305 EMACS_TIME idle_timer_difference = invalid_emacs_time ();
4340 int ripe, timer_ripe = 0, idle_timer_ripe = 0; 4306 bool ripe, timer_ripe = 0, idle_timer_ripe = 0;
4341 4307
4342 /* Set TIMER and TIMER_DIFFERENCE 4308 /* Set TIMER and TIMER_DIFFERENCE
4343 based on the next ordinary timer. 4309 based on the next ordinary timer.
@@ -5417,7 +5383,7 @@ make_lispy_event (struct input_event *event)
5417 (sizeof (lispy_function_keys) 5383 (sizeof (lispy_function_keys)
5418 / sizeof (lispy_function_keys[0]))); 5384 / sizeof (lispy_function_keys[0])));
5419 5385
5420#ifdef WINDOWSNT 5386#ifdef HAVE_NTGUI
5421 case MULTIMEDIA_KEY_EVENT: 5387 case MULTIMEDIA_KEY_EVENT:
5422 if (event->code < (sizeof (lispy_multimedia_keys) 5388 if (event->code < (sizeof (lispy_multimedia_keys)
5423 / sizeof (lispy_multimedia_keys[0])) 5389 / sizeof (lispy_multimedia_keys[0]))
@@ -5441,7 +5407,7 @@ make_lispy_event (struct input_event *event)
5441#endif 5407#endif
5442 { 5408 {
5443 int button = event->code; 5409 int button = event->code;
5444 int is_double; 5410 bool is_double;
5445 Lisp_Object position; 5411 Lisp_Object position;
5446 Lisp_Object *start_pos_ptr; 5412 Lisp_Object *start_pos_ptr;
5447 Lisp_Object start_pos; 5413 Lisp_Object start_pos;
@@ -5722,7 +5688,7 @@ make_lispy_event (struct input_event *event)
5722 struct frame *fr; 5688 struct frame *fr;
5723 int fuzz; 5689 int fuzz;
5724 int symbol_num; 5690 int symbol_num;
5725 int is_double; 5691 bool is_double;
5726 5692
5727 if (WINDOWP (event->frame_or_window)) 5693 if (WINDOWP (event->frame_or_window))
5728 fr = XFRAME (XWINDOW (event->frame_or_window)->frame); 5694 fr = XFRAME (XWINDOW (event->frame_or_window)->frame);
@@ -6664,11 +6630,11 @@ parse_solitary_modifier (Lisp_Object symbol)
6664 return 0; 6630 return 0;
6665} 6631}
6666 6632
6667/* Return 1 if EVENT is a list whose elements are all integers or symbols. 6633/* Return true if EVENT is a list whose elements are all integers or symbols.
6668 Such a list is not valid as an event, 6634 Such a list is not valid as an event,
6669 but it can be a Lucid-style event type list. */ 6635 but it can be a Lucid-style event type list. */
6670 6636
6671int 6637bool
6672lucid_event_type_list_p (Lisp_Object object) 6638lucid_event_type_list_p (Lisp_Object object)
6673{ 6639{
6674 Lisp_Object tail; 6640 Lisp_Object tail;
@@ -6693,8 +6659,10 @@ lucid_event_type_list_p (Lisp_Object object)
6693 return NILP (tail); 6659 return NILP (tail);
6694} 6660}
6695 6661
6696/* Store into *addr a value nonzero if terminal input chars are available. 6662/* Return true if terminal input chars are available.
6697 Serves the purpose of ioctl (0, FIONREAD, addr) 6663 Also, store the return value into INPUT_PENDING.
6664
6665 Serves the purpose of ioctl (0, FIONREAD, ...)
6698 but works even if FIONREAD does not exist. 6666 but works even if FIONREAD does not exist.
6699 (In fact, this may actually read some input.) 6667 (In fact, this may actually read some input.)
6700 6668
@@ -6705,19 +6673,21 @@ lucid_event_type_list_p (Lisp_Object object)
6705 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse 6673 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse
6706 movements and toolkit scroll bar thumb drags. */ 6674 movements and toolkit scroll bar thumb drags. */
6707 6675
6708static void 6676static bool
6709get_input_pending (int *addr, int flags) 6677get_input_pending (int flags)
6710{ 6678{
6711 /* First of all, have we already counted some input? */ 6679 /* First of all, have we already counted some input? */
6712 *addr = (!NILP (Vquit_flag) || readable_events (flags)); 6680 input_pending = (!NILP (Vquit_flag) || readable_events (flags));
6713 6681
6714 /* If input is being read as it arrives, and we have none, there is none. */ 6682 /* If input is being read as it arrives, and we have none, there is none. */
6715 if (*addr > 0 || (interrupt_input && ! interrupts_deferred)) 6683 if (!input_pending && (!interrupt_input || interrupts_deferred))
6716 return; 6684 {
6685 /* Try to read some input and see how much we get. */
6686 gobble_input ();
6687 input_pending = (!NILP (Vquit_flag) || readable_events (flags));
6688 }
6717 6689
6718 /* Try to read some input and see how much we get. */ 6690 return input_pending;
6719 gobble_input ();
6720 *addr = (!NILP (Vquit_flag) || readable_events (flags));
6721} 6691}
6722 6692
6723/* Put a BUFFER_SWITCH_EVENT in the buffer 6693/* Put a BUFFER_SWITCH_EVENT in the buffer
@@ -6767,7 +6737,7 @@ int
6767gobble_input (void) 6737gobble_input (void)
6768{ 6738{
6769 int nread = 0; 6739 int nread = 0;
6770 int err = 0; 6740 bool err = 0;
6771 struct terminal *t; 6741 struct terminal *t;
6772 6742
6773 /* Store pending user signal events, if any. */ 6743 /* Store pending user signal events, if any. */
@@ -7337,9 +7307,9 @@ static const char* separator_names[] = {
7337 0, 7307 0,
7338}; 7308};
7339 7309
7340/* Return non-zero if LABEL specifies a separator. */ 7310/* Return true if LABEL specifies a separator. */
7341 7311
7342int 7312bool
7343menu_separator_name_p (const char *label) 7313menu_separator_name_p (const char *label)
7344{ 7314{
7345 if (!label) 7315 if (!label)
@@ -7514,6 +7484,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
7514{ 7484{
7515 struct gcpro gcpro1; 7485 struct gcpro gcpro1;
7516 int i; 7486 int i;
7487 bool parsed;
7517 Lisp_Object tem; 7488 Lisp_Object tem;
7518 7489
7519 if (EQ (item, Qundefined)) 7490 if (EQ (item, Qundefined))
@@ -7545,9 +7516,9 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
7545 parse_menu_item, so that if it turns out it wasn't a menu item, 7516 parse_menu_item, so that if it turns out it wasn't a menu item,
7546 it still correctly hides any further menu item. */ 7517 it still correctly hides any further menu item. */
7547 GCPRO1 (key); 7518 GCPRO1 (key);
7548 i = parse_menu_item (item, 1); 7519 parsed = parse_menu_item (item, 1);
7549 UNGCPRO; 7520 UNGCPRO;
7550 if (!i) 7521 if (!parsed)
7551 return; 7522 return;
7552 7523
7553 item = AREF (item_properties, ITEM_PROPERTY_DEF); 7524 item = AREF (item_properties, ITEM_PROPERTY_DEF);
@@ -7623,7 +7594,7 @@ menu_item_eval_property (Lisp_Object sexpr)
7623 parse_menu_item returns true if the item is a menu item and false 7594 parse_menu_item returns true if the item is a menu item and false
7624 otherwise. */ 7595 otherwise. */
7625 7596
7626int 7597bool
7627parse_menu_item (Lisp_Object item, int inmenubar) 7598parse_menu_item (Lisp_Object item, int inmenubar)
7628{ 7599{
7629 Lisp_Object def, tem, item_string, start; 7600 Lisp_Object def, tem, item_string, start;
@@ -7923,7 +7894,7 @@ static Lisp_Object QCrtl;
7923 7894
7924static void init_tool_bar_items (Lisp_Object); 7895static void init_tool_bar_items (Lisp_Object);
7925static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); 7896static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*);
7926static int parse_tool_bar_item (Lisp_Object, Lisp_Object); 7897static bool parse_tool_bar_item (Lisp_Object, Lisp_Object);
7927static void append_tool_bar_item (void); 7898static void append_tool_bar_item (void);
7928 7899
7929 7900
@@ -8056,7 +8027,7 @@ set_prop (ptrdiff_t idx, Lisp_Object val)
8056 8027
8057 8028
8058/* Parse a tool bar item specification ITEM for key KEY and return the 8029/* Parse a tool bar item specification ITEM for key KEY and return the
8059 result in tool_bar_item_properties. Value is zero if ITEM is 8030 result in tool_bar_item_properties. Value is false if ITEM is
8060 invalid. 8031 invalid.
8061 8032
8062 ITEM is a list `(menu-item CAPTION BINDING PROPS...)'. 8033 ITEM is a list `(menu-item CAPTION BINDING PROPS...)'.
@@ -8101,12 +8072,13 @@ set_prop (ptrdiff_t idx, Lisp_Object val)
8101 8072
8102 A text label to show with the tool bar button if labels are enabled. */ 8073 A text label to show with the tool bar button if labels are enabled. */
8103 8074
8104static int 8075static bool
8105parse_tool_bar_item (Lisp_Object key, Lisp_Object item) 8076parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8106{ 8077{
8107 Lisp_Object filter = Qnil; 8078 Lisp_Object filter = Qnil;
8108 Lisp_Object caption; 8079 Lisp_Object caption;
8109 int i, have_label = 0; 8080 int i;
8081 bool have_label = 0;
8110 8082
8111 /* Definition looks like `(menu-item CAPTION BINDING PROPS...)'. 8083 /* Definition looks like `(menu-item CAPTION BINDING PROPS...)'.
8112 Rule out items that aren't lists, don't start with 8084 Rule out items that aren't lists, don't start with
@@ -8363,9 +8335,9 @@ append_tool_bar_item (void)
8363 PREV_EVENT is the previous input event, or nil if we are reading 8335 PREV_EVENT is the previous input event, or nil if we are reading
8364 the first event of a key sequence. 8336 the first event of a key sequence.
8365 8337
8366 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1 8338 If USED_MOUSE_MENU is non-null, set *USED_MOUSE_MENU to true
8367 if we used a mouse menu to read the input, or zero otherwise. If 8339 if we used a mouse menu to read the input, or false otherwise. If
8368 USED_MOUSE_MENU is null, we don't dereference it. 8340 USED_MOUSE_MENU is null, don't dereference it.
8369 8341
8370 The prompting is done based on the prompt-string of the map 8342 The prompting is done based on the prompt-string of the map
8371 and the strings associated with various map elements. 8343 and the strings associated with various map elements.
@@ -8378,7 +8350,7 @@ append_tool_bar_item (void)
8378 8350
8379static Lisp_Object 8351static Lisp_Object
8380read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, 8352read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8381 Lisp_Object prev_event, int *used_mouse_menu) 8353 Lisp_Object prev_event, bool *used_mouse_menu)
8382{ 8354{
8383#ifdef HAVE_MENUS 8355#ifdef HAVE_MENUS
8384 ptrdiff_t mapno; 8356 ptrdiff_t mapno;
@@ -8472,7 +8444,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8472 /* FIXME: Use the minibuffer's frame width. */ 8444 /* FIXME: Use the minibuffer's frame width. */
8473 ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4; 8445 ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4;
8474 ptrdiff_t idx = -1; 8446 ptrdiff_t idx = -1;
8475 int nobindings = 1; 8447 bool nobindings = 1;
8476 Lisp_Object rest, vector; 8448 Lisp_Object rest, vector;
8477 char *menu; 8449 char *menu;
8478 8450
@@ -8520,7 +8492,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8520 /* Present the documented bindings, a line at a time. */ 8492 /* Present the documented bindings, a line at a time. */
8521 while (1) 8493 while (1)
8522 { 8494 {
8523 int notfirst = 0; 8495 bool notfirst = 0;
8524 ptrdiff_t i = nlength; 8496 ptrdiff_t i = nlength;
8525 Lisp_Object obj; 8497 Lisp_Object obj;
8526 Lisp_Object orig_defn_macro; 8498 Lisp_Object orig_defn_macro;
@@ -8576,8 +8548,8 @@ read_char_minibuf_menu_prompt (int commandflag,
8576 /* Ignore the element if it has no prompt string. */ 8548 /* Ignore the element if it has no prompt string. */
8577 if (INTEGERP (event) && parse_menu_item (elt, -1)) 8549 if (INTEGERP (event) && parse_menu_item (elt, -1))
8578 { 8550 {
8579 /* 1 if the char to type matches the string. */ 8551 /* True if the char to type matches the string. */
8580 int char_matches; 8552 bool char_matches;
8581 Lisp_Object upcased_event, downcased_event; 8553 Lisp_Object upcased_event, downcased_event;
8582 Lisp_Object desc = Qnil; 8554 Lisp_Object desc = Qnil;
8583 Lisp_Object s 8555 Lisp_Object s
@@ -8629,7 +8601,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8629 i += 2; 8601 i += 2;
8630 } 8602 }
8631 notfirst = 1; 8603 notfirst = 1;
8632 nobindings = 0 ; 8604 nobindings = 0;
8633 8605
8634 /* If the char to type doesn't match the string's 8606 /* If the char to type doesn't match the string's
8635 first char, explicitly show what char to type. */ 8607 first char, explicitly show what char to type. */
@@ -8763,14 +8735,14 @@ typedef struct keyremap
8763 8735
8764/* Lookup KEY in MAP. 8736/* Lookup KEY in MAP.
8765 MAP is a keymap mapping keys to key vectors or functions. 8737 MAP is a keymap mapping keys to key vectors or functions.
8766 If the mapping is a function and DO_FUNCTION is non-zero, then 8738 If the mapping is a function and DO_FUNCALL is true,
8767 the function is called with PROMPT as parameter and its return 8739 the function is called with PROMPT as parameter and its return
8768 value is used as the return value of this function (after checking 8740 value is used as the return value of this function (after checking
8769 that it is indeed a vector). */ 8741 that it is indeed a vector). */
8770 8742
8771static Lisp_Object 8743static Lisp_Object
8772access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, 8744access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8773 int do_funcall) 8745 bool do_funcall)
8774{ 8746{
8775 Lisp_Object next; 8747 Lisp_Object next;
8776 8748
@@ -8809,15 +8781,15 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8809 BUFSIZE is its maximum size. 8781 BUFSIZE is its maximum size.
8810 FKEY is a pointer to the keyremap structure to use. 8782 FKEY is a pointer to the keyremap structure to use.
8811 INPUT is the index of the last element in KEYBUF. 8783 INPUT is the index of the last element in KEYBUF.
8812 DOIT if non-zero says that the remapping can actually take place. 8784 DOIT if true says that the remapping can actually take place.
8813 DIFF is used to return the number of keys added/removed by the remapping. 8785 DIFF is used to return the number of keys added/removed by the remapping.
8814 PARENT is the root of the keymap. 8786 PARENT is the root of the keymap.
8815 PROMPT is the prompt to use if the remapping happens through a function. 8787 PROMPT is the prompt to use if the remapping happens through a function.
8816 The return value is non-zero if the remapping actually took place. */ 8788 Return true if the remapping actually took place. */
8817 8789
8818static int 8790static bool
8819keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, 8791keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8820 int input, int doit, int *diff, Lisp_Object prompt) 8792 int input, bool doit, int *diff, Lisp_Object prompt)
8821{ 8793{
8822 Lisp_Object next, key; 8794 Lisp_Object next, key;
8823 8795
@@ -8871,7 +8843,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8871 return 0; 8843 return 0;
8872} 8844}
8873 8845
8874static int 8846static bool
8875test_undefined (Lisp_Object binding) 8847test_undefined (Lisp_Object binding)
8876{ 8848{
8877 return (EQ (binding, Qundefined) 8849 return (EQ (binding, Qundefined)
@@ -8913,13 +8885,13 @@ test_undefined (Lisp_Object binding)
8913 off the switch-frame event until later; the next call to 8885 off the switch-frame event until later; the next call to
8914 read_char will return it. 8886 read_char will return it.
8915 8887
8916 If FIX_CURRENT_BUFFER is nonzero, we restore current_buffer 8888 If FIX_CURRENT_BUFFER, we restore current_buffer
8917 from the selected window's buffer. */ 8889 from the selected window's buffer. */
8918 8890
8919static int 8891static int
8920read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, 8892read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8921 int dont_downcase_last, int can_return_switch_frame, 8893 bool dont_downcase_last, bool can_return_switch_frame,
8922 int fix_current_buffer) 8894 bool fix_current_buffer)
8923{ 8895{
8924 Lisp_Object from_string; 8896 Lisp_Object from_string;
8925 ptrdiff_t count = SPECPDL_INDEX (); 8897 ptrdiff_t count = SPECPDL_INDEX ();
@@ -8952,7 +8924,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8952 key sequence. */ 8924 key sequence. */
8953 Lisp_Object orig_keymap; 8925 Lisp_Object orig_keymap;
8954 8926
8955 /* 1 if we have already considered switching to the local-map property 8927 /* Positive if we have already considered switching to the local-map property
8956 of the place where a mouse click occurred. */ 8928 of the place where a mouse click occurred. */
8957 int localized_local_map = 0; 8929 int localized_local_map = 0;
8958 8930
@@ -8992,10 +8964,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8992 /* Likewise, for key_translation_map and input-decode-map. */ 8964 /* Likewise, for key_translation_map and input-decode-map. */
8993 keyremap keytran, indec; 8965 keyremap keytran, indec;
8994 8966
8995 /* Non-zero if we are trying to map a key by changing an upper-case 8967 /* True if we are trying to map a key by changing an upper-case
8996 letter to lower case, or a shifted function key to an unshifted 8968 letter to lower case, or a shifted function key to an unshifted
8997 one. */ 8969 one. */
8998 int shift_translated = 0; 8970 bool shift_translated = 0;
8999 8971
9000 /* If we receive a `switch-frame' or `select-window' event in the middle of 8972 /* If we receive a `switch-frame' or `select-window' event in the middle of
9001 a key sequence, we put it off for later. 8973 a key sequence, we put it off for later.
@@ -9011,7 +8983,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9011 int original_uppercase_position = -1; 8983 int original_uppercase_position = -1;
9012 8984
9013 /* Gets around Microsoft compiler limitations. */ 8985 /* Gets around Microsoft compiler limitations. */
9014 int dummyflag = 0; 8986 bool dummyflag = 0;
9015 8987
9016 struct buffer *starting_buffer; 8988 struct buffer *starting_buffer;
9017 8989
@@ -9173,7 +9145,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9173 : (/* indec.start < t || fkey.start < t || */ keytran.start < t)) 9145 : (/* indec.start < t || fkey.start < t || */ keytran.start < t))
9174 { 9146 {
9175 Lisp_Object key; 9147 Lisp_Object key;
9176 int used_mouse_menu = 0; 9148 bool used_mouse_menu = 0;
9177 9149
9178 /* Where the last real key started. If we need to throw away a 9150 /* Where the last real key started. If we need to throw away a
9179 key that has expanded into more than one element of keybuf 9151 key that has expanded into more than one element of keybuf
@@ -9267,7 +9239,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9267 return. Any better way to fix this? -- cyd */ 9239 return. Any better way to fix this? -- cyd */
9268 || (interrupted_kboard != current_kboard)) 9240 || (interrupted_kboard != current_kboard))
9269 { 9241 {
9270 int found = 0; 9242 bool found = 0;
9271 struct kboard *k; 9243 struct kboard *k;
9272 9244
9273 for (k = all_kboards; k; k = k->next_kboard) 9245 for (k = all_kboards; k; k = k->next_kboard)
@@ -9821,7 +9793,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9821 while (indec.end < t) 9793 while (indec.end < t)
9822 { 9794 {
9823 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9795 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9824 int done, diff; 9796 bool done;
9797 int diff;
9825 9798
9826 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9799 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9827 done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input), 9800 done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input),
@@ -9855,7 +9828,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9855 while (fkey.end < indec.start) 9828 while (fkey.end < indec.start)
9856 { 9829 {
9857 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9830 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9858 int done, diff; 9831 bool done;
9832 int diff;
9859 9833
9860 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9834 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9861 done = keyremap_step (keybuf, bufsize, &fkey, 9835 done = keyremap_step (keybuf, bufsize, &fkey,
@@ -9884,7 +9858,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9884 while (keytran.end < fkey.start) 9858 while (keytran.end < fkey.start)
9885 { 9859 {
9886 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9860 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9887 int done, diff; 9861 bool done;
9862 int diff;
9888 9863
9889 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9864 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9890 done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input), 9865 done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input),
@@ -10270,38 +10245,32 @@ a special event, so ignore the prefix argument and don't clear it. */)
10270 10245
10271 10246
10272 10247
10273/* Return nonzero if input events are pending. */ 10248/* Return true if input events are pending. */
10274 10249
10275int 10250bool
10276detect_input_pending (void) 10251detect_input_pending (void)
10277{ 10252{
10278 if (!input_pending) 10253 return input_pending || get_input_pending (0);
10279 get_input_pending (&input_pending, 0);
10280
10281 return input_pending;
10282} 10254}
10283 10255
10284/* Return nonzero if input events other than mouse movements are 10256/* Return true if input events other than mouse movements are
10285 pending. */ 10257 pending. */
10286 10258
10287int 10259bool
10288detect_input_pending_ignore_squeezables (void) 10260detect_input_pending_ignore_squeezables (void)
10289{ 10261{
10290 if (!input_pending) 10262 return input_pending || get_input_pending (READABLE_EVENTS_IGNORE_SQUEEZABLES);
10291 get_input_pending (&input_pending, READABLE_EVENTS_IGNORE_SQUEEZABLES);
10292
10293 return input_pending;
10294} 10263}
10295 10264
10296/* Return nonzero if input events are pending, and run any pending timers. */ 10265/* Return true if input events are pending, and run any pending timers. */
10297 10266
10298int 10267bool
10299detect_input_pending_run_timers (int do_display) 10268detect_input_pending_run_timers (bool do_display)
10300{ 10269{
10301 int old_timers_run = timers_run; 10270 unsigned old_timers_run = timers_run;
10302 10271
10303 if (!input_pending) 10272 if (!input_pending)
10304 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW); 10273 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
10305 10274
10306 if (old_timers_run != timers_run && do_display) 10275 if (old_timers_run != timers_run && do_display)
10307 { 10276 {
@@ -10332,13 +10301,13 @@ clear_input_pending (void)
10332 input_pending = 0; 10301 input_pending = 0;
10333} 10302}
10334 10303
10335/* Return nonzero if there are pending requeued events. 10304/* Return true if there are pending requeued events.
10336 This isn't used yet. The hope is to make wait_reading_process_output 10305 This isn't used yet. The hope is to make wait_reading_process_output
10337 call it, and return if it runs Lisp code that unreads something. 10306 call it, and return if it runs Lisp code that unreads something.
10338 The problem is, kbd_buffer_get_event needs to be fixed to know what 10307 The problem is, kbd_buffer_get_event needs to be fixed to know what
10339 to do in that case. It isn't trivial. */ 10308 to do in that case. It isn't trivial. */
10340 10309
10341int 10310bool
10342requeued_events_pending_p (void) 10311requeued_events_pending_p (void)
10343{ 10312{
10344 return (!NILP (Vunread_command_events)); 10313 return (!NILP (Vunread_command_events));
@@ -10359,10 +10328,9 @@ if there is a doubt, the value is t. */)
10359 /* Process non-user-visible events (Bug#10195). */ 10328 /* Process non-user-visible events (Bug#10195). */
10360 process_special_events (); 10329 process_special_events ();
10361 10330
10362 get_input_pending (&input_pending, 10331 return (get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW
10363 READABLE_EVENTS_DO_TIMERS_NOW 10332 | READABLE_EVENTS_FILTER_EVENTS)
10364 | READABLE_EVENTS_FILTER_EVENTS); 10333 ? Qt : Qnil);
10365 return input_pending > 0 ? Qt : Qnil;
10366} 10334}
10367 10335
10368DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, 10336DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
@@ -10868,7 +10836,7 @@ handle_interrupt (bool in_signal_handler)
10868/* Handle a C-g by making read_char return C-g. */ 10836/* Handle a C-g by making read_char return C-g. */
10869 10837
10870static void 10838static void
10871quit_throw_to_read_char (int from_signal) 10839quit_throw_to_read_char (bool from_signal)
10872{ 10840{
10873 /* When not called from a signal handler it is safe to call 10841 /* When not called from a signal handler it is safe to call
10874 Lisp. */ 10842 Lisp. */
@@ -10898,7 +10866,7 @@ otherwise Emacs uses CBREAK mode.
10898See also `current-input-mode'. */) 10866See also `current-input-mode'. */)
10899 (Lisp_Object interrupt) 10867 (Lisp_Object interrupt)
10900{ 10868{
10901 int new_interrupt_input; 10869 bool new_interrupt_input;
10902#ifdef USABLE_SIGIO 10870#ifdef USABLE_SIGIO
10903#ifdef HAVE_X_WINDOWS 10871#ifdef HAVE_X_WINDOWS
10904 if (x_display_list != NULL) 10872 if (x_display_list != NULL)
@@ -11394,7 +11362,7 @@ syms_of_keyboard (void)
11394 DEFSYM (Qconfig_changed_event, "config-changed-event"); 11362 DEFSYM (Qconfig_changed_event, "config-changed-event");
11395 DEFSYM (Qmenu_enable, "menu-enable"); 11363 DEFSYM (Qmenu_enable, "menu-enable");
11396 11364
11397#if defined (WINDOWSNT) 11365#ifdef HAVE_NTGUI
11398 DEFSYM (Qlanguage_change, "language-change"); 11366 DEFSYM (Qlanguage_change, "language-change");
11399#endif 11367#endif
11400 11368
diff --git a/src/keyboard.h b/src/keyboard.h
index bc35bba4ecc..e57c8cc7193 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -169,12 +169,12 @@ struct kboard
169 reading from this KBOARD again until more input arrives. */ 169 reading from this KBOARD again until more input arrives. */
170 char kbd_queue_has_data; 170 char kbd_queue_has_data;
171 171
172 /* Nonzero means echo each character as typed. */ 172 /* True means echo each character as typed. */
173 char immediate_echo; 173 unsigned immediate_echo : 1;
174 174
175 /* If we have echoed a prompt string specified by the user, 175 /* If we have echoed a prompt string specified by the user,
176 this is its length in characters. Otherwise this is -1. */ 176 this is its length in characters. Otherwise this is -1. */
177 char echo_after_prompt; 177 ptrdiff_t echo_after_prompt;
178 }; 178 };
179 179
180KEYBOARD_INLINE void 180KEYBOARD_INLINE void
@@ -463,14 +463,14 @@ extern Lisp_Object Qhelp_echo;
463extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line; 463extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line;
464 464
465/* True while doing kbd input. */ 465/* True while doing kbd input. */
466extern int waiting_for_input; 466extern bool waiting_for_input;
467 467
468/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt 468/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
469 happens. */ 469 happens. */
470extern EMACS_TIME *input_available_clear_time; 470extern EMACS_TIME *input_available_clear_time;
471 471
472#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS 472#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS
473extern int ignore_mouse_drag_p; 473extern bool ignore_mouse_drag_p;
474#endif 474#endif
475 475
476/* The primary selection. */ 476/* The primary selection. */
@@ -482,7 +482,7 @@ struct input_event;
482extern Lisp_Object parse_modifiers (Lisp_Object); 482extern Lisp_Object parse_modifiers (Lisp_Object);
483extern Lisp_Object reorder_modifiers (Lisp_Object); 483extern Lisp_Object reorder_modifiers (Lisp_Object);
484extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, 484extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object,
485 int *, EMACS_TIME *); 485 bool *, EMACS_TIME *);
486extern int parse_solitary_modifier (Lisp_Object symbol); 486extern int parse_solitary_modifier (Lisp_Object symbol);
487 487
488 488
@@ -506,10 +506,10 @@ extern Time last_event_timestamp;
506 506
507extern int quit_char; 507extern int quit_char;
508 508
509extern int timers_run; 509extern unsigned int timers_run;
510 510
511extern int menu_separator_name_p (const char *); 511extern bool menu_separator_name_p (const char *);
512extern int parse_menu_item (Lisp_Object, int); 512extern bool parse_menu_item (Lisp_Object, int);
513 513
514extern void init_kboard (KBOARD *); 514extern void init_kboard (KBOARD *);
515extern void delete_kboard (KBOARD *); 515extern void delete_kboard (KBOARD *);
@@ -524,15 +524,15 @@ extern void start_polling (void);
524extern void stop_polling (void); 524extern void stop_polling (void);
525extern void set_poll_suppress_count (int); 525extern void set_poll_suppress_count (int);
526extern int gobble_input (void); 526extern int gobble_input (void);
527extern int input_polling_used (void); 527extern bool input_polling_used (void);
528extern void clear_input_pending (void); 528extern void clear_input_pending (void);
529extern int requeued_events_pending_p (void); 529extern bool requeued_events_pending_p (void);
530extern void bind_polling_period (int); 530extern void bind_polling_period (int);
531extern int make_ctrl_char (int) ATTRIBUTE_CONST; 531extern int make_ctrl_char (int) ATTRIBUTE_CONST;
532extern void stuff_buffered_input (Lisp_Object); 532extern void stuff_buffered_input (Lisp_Object);
533extern void clear_waiting_for_input (void); 533extern void clear_waiting_for_input (void);
534extern void swallow_events (int); 534extern void swallow_events (bool);
535extern int lucid_event_type_list_p (Lisp_Object); 535extern bool lucid_event_type_list_p (Lisp_Object);
536extern void kbd_buffer_store_event (struct input_event *); 536extern void kbd_buffer_store_event (struct input_event *);
537extern void kbd_buffer_store_event_hold (struct input_event *, 537extern void kbd_buffer_store_event_hold (struct input_event *,
538 struct input_event *); 538 struct input_event *);
@@ -544,14 +544,14 @@ extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object,
544 Lisp_Object, ptrdiff_t); 544 Lisp_Object, ptrdiff_t);
545extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object); 545extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object);
546extern Lisp_Object menu_item_eval_property (Lisp_Object); 546extern Lisp_Object menu_item_eval_property (Lisp_Object);
547extern int kbd_buffer_events_waiting (int); 547extern bool kbd_buffer_events_waiting (void);
548extern void add_user_signal (int, const char *); 548extern void add_user_signal (int, const char *);
549 549
550extern int tty_read_avail_input (struct terminal *, struct input_event *); 550extern int tty_read_avail_input (struct terminal *, struct input_event *);
551extern EMACS_TIME timer_check (void); 551extern EMACS_TIME timer_check (void);
552extern void mark_kboards (void); 552extern void mark_kboards (void);
553 553
554#ifdef WINDOWSNT 554#ifdef HAVE_NTGUI
555extern const char *const lispy_function_keys[]; 555extern const char *const lispy_function_keys[];
556#endif 556#endif
557 557
diff --git a/src/keymap.c b/src/keymap.c
index 6ea142651bf..fbdd31e0de3 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -99,12 +99,12 @@ static void describe_command (Lisp_Object, Lisp_Object);
99static void describe_translation (Lisp_Object, Lisp_Object); 99static void describe_translation (Lisp_Object, Lisp_Object);
100static void describe_map (Lisp_Object, Lisp_Object, 100static void describe_map (Lisp_Object, Lisp_Object,
101 void (*) (Lisp_Object, Lisp_Object), 101 void (*) (Lisp_Object, Lisp_Object),
102 int, Lisp_Object, Lisp_Object*, int, int); 102 bool, Lisp_Object, Lisp_Object*, bool, bool);
103static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, 103static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object,
104 void (*) (Lisp_Object, Lisp_Object), int, 104 void (*) (Lisp_Object, Lisp_Object), bool,
105 Lisp_Object, Lisp_Object, int, int); 105 Lisp_Object, Lisp_Object, bool, bool);
106static void silly_event_symbol_error (Lisp_Object); 106static void silly_event_symbol_error (Lisp_Object);
107static Lisp_Object get_keyelt (Lisp_Object, int); 107static Lisp_Object get_keyelt (Lisp_Object, bool);
108 108
109/* Keymap object support - constructors and predicates. */ 109/* Keymap object support - constructors and predicates. */
110 110
@@ -207,15 +207,12 @@ when reading a key-sequence to be looked-up in this keymap. */)
207/* Check that OBJECT is a keymap (after dereferencing through any 207/* Check that OBJECT is a keymap (after dereferencing through any
208 symbols). If it is, return it. 208 symbols). If it is, return it.
209 209
210 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value 210 If AUTOLOAD and if OBJECT is a symbol whose function value
211 is an autoload form, do the autoload and try again. 211 is an autoload form, do the autoload and try again.
212 If AUTOLOAD is nonzero, callers must assume GC is possible. 212 If AUTOLOAD, callers must assume GC is possible.
213
214 If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR
215 is zero as well), return Qt.
216 213
217 ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. 214 ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap.
218 If ERROR_IF_NOT_KEYMAP is non-zero, signal an error; otherwise, 215 If ERROR_IF_NOT_KEYMAP, signal an error; otherwise,
219 just return Qnil. 216 just return Qnil.
220 217
221 Note that most of the time, we don't want to pursue autoloads. 218 Note that most of the time, we don't want to pursue autoloads.
@@ -224,11 +221,11 @@ when reading a key-sequence to be looked-up in this keymap. */)
224 but it seems to me that only read_key_sequence, Flookup_key, and 221 but it seems to me that only read_key_sequence, Flookup_key, and
225 Fdefine_key should cause keymaps to be autoloaded. 222 Fdefine_key should cause keymaps to be autoloaded.
226 223
227 This function can GC when AUTOLOAD is non-zero, because it calls 224 This function can GC when AUTOLOAD is true, because it calls
228 Fautoload_do_load which can GC. */ 225 Fautoload_do_load which can GC. */
229 226
230Lisp_Object 227Lisp_Object
231get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) 228get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload)
232{ 229{
233 Lisp_Object tem; 230 Lisp_Object tem;
234 231
@@ -280,7 +277,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
280 We assume that KEYMAP is a valid keymap. */ 277 We assume that KEYMAP is a valid keymap. */
281 278
282static Lisp_Object 279static Lisp_Object
283keymap_parent (Lisp_Object keymap, int autoload) 280keymap_parent (Lisp_Object keymap, bool autoload)
284{ 281{
285 Lisp_Object list; 282 Lisp_Object list;
286 283
@@ -307,7 +304,7 @@ If KEYMAP has no parent, return nil. */)
307} 304}
308 305
309/* Check whether MAP is one of MAPS parents. */ 306/* Check whether MAP is one of MAPS parents. */
310static int 307static bool
311keymap_memberp (Lisp_Object map, Lisp_Object maps) 308keymap_memberp (Lisp_Object map, Lisp_Object maps)
312{ 309{
313 if (NILP (map)) return 0; 310 if (NILP (map)) return 0;
@@ -365,19 +362,20 @@ Return PARENT. PARENT should be nil or another keymap. */)
365 362
366 MAP must be a keymap or a list of keymaps. 363 MAP must be a keymap or a list of keymaps.
367 364
368 If T_OK is non-zero, bindings for Qt are treated as default 365 If T_OK, bindings for Qt are treated as default
369 bindings; any key left unmentioned by other tables and bindings is 366 bindings; any key left unmentioned by other tables and bindings is
370 given the binding of Qt. 367 given the binding of Qt.
371 368
372 If T_OK is zero, bindings for Qt are not treated specially. 369 If not T_OK, bindings for Qt are not treated specially.
373 370
374 If NOINHERIT, don't accept a subkeymap found in an inherited keymap. 371 If NOINHERIT, don't accept a subkeymap found in an inherited keymap.
375 372
376 Returns Qunbound if no binding was found (and returns Qnil if a nil 373 Return Qunbound if no binding was found (and return Qnil if a nil
377 binding was found). */ 374 binding was found). */
378 375
379static Lisp_Object 376static Lisp_Object
380access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int autoload) 377access_keymap_1 (Lisp_Object map, Lisp_Object idx,
378 bool t_ok, bool noinherit, bool autoload)
381{ 379{
382 /* If idx is a list (some sort of mouse click, perhaps?), 380 /* If idx is a list (some sort of mouse click, perhaps?),
383 the index we want to use is the car of the list, which 381 the index we want to use is the car of the list, which
@@ -547,7 +545,7 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int
547 545
548Lisp_Object 546Lisp_Object
549access_keymap (Lisp_Object map, Lisp_Object idx, 547access_keymap (Lisp_Object map, Lisp_Object idx,
550 int t_ok, int noinherit, int autoload) 548 bool t_ok, bool noinherit, bool autoload)
551{ 549{
552 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload); 550 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload);
553 return EQ (val, Qunbound) ? Qnil : val; 551 return EQ (val, Qunbound) ? Qnil : val;
@@ -630,9 +628,10 @@ map_keymap_call (Lisp_Object key, Lisp_Object val, Lisp_Object fun, void *dummy)
630} 628}
631 629
632/* Same as map_keymap_internal, but traverses parent keymaps as well. 630/* Same as map_keymap_internal, but traverses parent keymaps as well.
633 A non-zero AUTOLOAD indicates that autoloaded keymaps should be loaded. */ 631 AUTOLOAD indicates that autoloaded keymaps should be loaded. */
634void 632void
635map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data, int autoload) 633map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args,
634 void *data, bool autoload)
636{ 635{
637 struct gcpro gcpro1; 636 struct gcpro gcpro1;
638 GCPRO1 (args); 637 GCPRO1 (args);
@@ -711,13 +710,13 @@ usage: (map-keymap FUNCTION KEYMAP) */)
711 Also if OBJECT has a menu string as the first element, 710 Also if OBJECT has a menu string as the first element,
712 remove that. Also remove a menu help string as second element. 711 remove that. Also remove a menu help string as second element.
713 712
714 If AUTOLOAD is nonzero, load autoloadable keymaps 713 If AUTOLOAD, load autoloadable keymaps
715 that are referred to with indirection. 714 that are referred to with indirection.
716 715
717 This can GC because menu_item_eval_property calls Feval. */ 716 This can GC because menu_item_eval_property calls Feval. */
718 717
719static Lisp_Object 718static Lisp_Object
720get_keyelt (Lisp_Object object, int autoload) 719get_keyelt (Lisp_Object object, bool autoload)
721{ 720{
722 while (1) 721 while (1)
723 { 722 {
@@ -1114,10 +1113,10 @@ binding is altered. If there is no binding for KEY, the new pair
1114binding KEY to DEF is added at the front of KEYMAP. */) 1113binding KEY to DEF is added at the front of KEYMAP. */)
1115 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) 1114 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def)
1116{ 1115{
1117 register ptrdiff_t idx; 1116 ptrdiff_t idx;
1118 register Lisp_Object c; 1117 Lisp_Object c;
1119 register Lisp_Object cmd; 1118 Lisp_Object cmd;
1120 int metized = 0; 1119 bool metized = 0;
1121 int meta_bit; 1120 int meta_bit;
1122 ptrdiff_t length; 1121 ptrdiff_t length;
1123 struct gcpro gcpro1, gcpro2, gcpro3; 1122 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -1271,11 +1270,11 @@ third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will
1271recognize the default bindings, just as `read-key-sequence' does. */) 1270recognize the default bindings, just as `read-key-sequence' does. */)
1272 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) 1271 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default)
1273{ 1272{
1274 register ptrdiff_t idx; 1273 ptrdiff_t idx;
1275 register Lisp_Object cmd; 1274 Lisp_Object cmd;
1276 register Lisp_Object c; 1275 Lisp_Object c;
1277 ptrdiff_t length; 1276 ptrdiff_t length;
1278 int t_ok = !NILP (accept_default); 1277 bool t_ok = !NILP (accept_default);
1279 struct gcpro gcpro1, gcpro2; 1278 struct gcpro gcpro1, gcpro2;
1280 1279
1281 GCPRO2 (keymap, key); 1280 GCPRO2 (keymap, key);
@@ -1887,7 +1886,7 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_
1887struct accessible_keymaps_data { 1886struct accessible_keymaps_data {
1888 Lisp_Object maps, tail, thisseq; 1887 Lisp_Object maps, tail, thisseq;
1889 /* Does the current sequence end in the meta-prefix-char? */ 1888 /* Does the current sequence end in the meta-prefix-char? */
1890 int is_metized; 1889 bool is_metized;
1891}; 1890};
1892 1891
1893static void 1892static void
@@ -1898,7 +1897,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1898 Lisp_Object maps = d->maps; 1897 Lisp_Object maps = d->maps;
1899 Lisp_Object tail = d->tail; 1898 Lisp_Object tail = d->tail;
1900 Lisp_Object thisseq = d->thisseq; 1899 Lisp_Object thisseq = d->thisseq;
1901 int is_metized = d->is_metized && INTEGERP (key); 1900 bool is_metized = d->is_metized && INTEGERP (key);
1902 Lisp_Object tem; 1901 Lisp_Object tem;
1903 1902
1904 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); 1903 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0);
@@ -2060,7 +2059,7 @@ The `kbd' macro is an approximate inverse of this. */)
2060 Lisp_Object sep = build_string (" "); 2059 Lisp_Object sep = build_string (" ");
2061 Lisp_Object key; 2060 Lisp_Object key;
2062 Lisp_Object result; 2061 Lisp_Object result;
2063 int add_meta = 0; 2062 bool add_meta = 0;
2064 USE_SAFE_ALLOCA; 2063 USE_SAFE_ALLOCA;
2065 2064
2066 if (!NILP (prefix)) 2065 if (!NILP (prefix))
@@ -2155,9 +2154,10 @@ The `kbd' macro is an approximate inverse of this. */)
2155 2154
2156 2155
2157char * 2156char *
2158push_key_description (EMACS_INT ch, char *p, int force_multibyte) 2157push_key_description (EMACS_INT ch, char *p)
2159{ 2158{
2160 int c, c2, tab_as_ci; 2159 int c, c2;
2160 bool tab_as_ci;
2161 2161
2162 /* Clear all the meaningless bits above the meta bit. */ 2162 /* Clear all the meaningless bits above the meta bit. */
2163 c = ch & (meta_modifier | ~ - meta_modifier); 2163 c = ch & (meta_modifier | ~ - meta_modifier);
@@ -2256,21 +2256,12 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2256 *p++ = 'P'; 2256 *p++ = 'P';
2257 *p++ = 'C'; 2257 *p++ = 'C';
2258 } 2258 }
2259 else if (c < 128 2259 else if (c < 128)
2260 || (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2260 *p++ = c;
2261 && SINGLE_BYTE_CHAR_P (c)
2262 && !force_multibyte))
2263 {
2264 *p++ = c;
2265 }
2266 else 2261 else
2267 { 2262 {
2268 /* Now we are sure that C is a valid character code. */ 2263 /* Now we are sure that C is a valid character code. */
2269 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2264 p += CHAR_STRING (c, (unsigned char *) p);
2270 && ! force_multibyte)
2271 *p++ = multibyte_char_to_unibyte (c);
2272 else
2273 p += CHAR_STRING (c, (unsigned char *) p);
2274 } 2265 }
2275 2266
2276 return p; 2267 return p;
@@ -2299,9 +2290,8 @@ around function keys and event symbols. */)
2299 2290
2300 if (INTEGERP (key)) /* Normal character. */ 2291 if (INTEGERP (key)) /* Normal character. */
2301 { 2292 {
2302 char tem[KEY_DESCRIPTION_SIZE], *p; 2293 char tem[KEY_DESCRIPTION_SIZE];
2303 2294 char *p = push_key_description (XINT (key), tem);
2304 p = push_key_description (XINT (key), tem, 1);
2305 *p = 0; 2295 *p = 0;
2306 return make_specified_string (tem, -1, p - tem, 1); 2296 return make_specified_string (tem, -1, p - tem, 1);
2307 } 2297 }
@@ -2429,7 +2419,7 @@ static void where_is_internal_1 (Lisp_Object key, Lisp_Object binding,
2429 2419
2430static Lisp_Object 2420static Lisp_Object
2431shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, 2421shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag,
2432 int remap) 2422 bool remap)
2433{ 2423{
2434 Lisp_Object tail, value; 2424 Lisp_Object tail, value;
2435 2425
@@ -2461,7 +2451,7 @@ static Lisp_Object Vmouse_events;
2461 2451
2462struct where_is_internal_data { 2452struct where_is_internal_data {
2463 Lisp_Object definition, this, last; 2453 Lisp_Object definition, this, last;
2464 int last_is_meta, noindirect; 2454 bool last_is_meta, noindirect;
2465 Lisp_Object sequences; 2455 Lisp_Object sequences;
2466}; 2456};
2467 2457
@@ -2474,7 +2464,7 @@ struct where_is_internal_data {
2474 2464
2475static Lisp_Object 2465static Lisp_Object
2476where_is_internal (Lisp_Object definition, Lisp_Object keymaps, 2466where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2477 int noindirect, int nomenus) 2467 bool noindirect, bool nomenus)
2478{ 2468{
2479 Lisp_Object maps = Qnil; 2469 Lisp_Object maps = Qnil;
2480 Lisp_Object found; 2470 Lisp_Object found;
@@ -2523,7 +2513,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2523 [M-CHAR] sequences, check if last character of the sequence 2513 [M-CHAR] sequences, check if last character of the sequence
2524 is the meta-prefix char. */ 2514 is the meta-prefix char. */
2525 Lisp_Object last; 2515 Lisp_Object last;
2526 int last_is_meta; 2516 bool last_is_meta;
2527 2517
2528 this = Fcar (XCAR (maps)); 2518 this = Fcar (XCAR (maps));
2529 map = Fcdr (XCAR (maps)); 2519 map = Fcdr (XCAR (maps));
@@ -2606,7 +2596,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2606 /* Actually relevant bindings. */ 2596 /* Actually relevant bindings. */
2607 Lisp_Object found = Qnil; 2597 Lisp_Object found = Qnil;
2608 /* 1 means ignore all menu bindings entirely. */ 2598 /* 1 means ignore all menu bindings entirely. */
2609 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); 2599 bool nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii);
2610 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 2600 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
2611 /* List of sequences found via remapping. Keep them in a separate 2601 /* List of sequences found via remapping. Keep them in a separate
2612 variable, so as to push them later, since we prefer 2602 variable, so as to push them later, since we prefer
@@ -2615,7 +2605,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2615 /* Whether or not we're handling remapped sequences. This is needed 2605 /* Whether or not we're handling remapped sequences. This is needed
2616 because remapping is not done recursively by Fcommand_remapping: you 2606 because remapping is not done recursively by Fcommand_remapping: you
2617 can't remap a remapped command. */ 2607 can't remap a remapped command. */
2618 int remapped = 0; 2608 bool remapped = 0;
2619 Lisp_Object tem = Qnil; 2609 Lisp_Object tem = Qnil;
2620 2610
2621 /* Refresh the C version of the modifier preference. */ 2611 /* Refresh the C version of the modifier preference. */
@@ -2767,10 +2757,10 @@ where_is_internal_1 (Lisp_Object key, Lisp_Object binding, Lisp_Object args, voi
2767{ 2757{
2768 struct where_is_internal_data *d = data; /* Cast! */ 2758 struct where_is_internal_data *d = data; /* Cast! */
2769 Lisp_Object definition = d->definition; 2759 Lisp_Object definition = d->definition;
2770 int noindirect = d->noindirect; 2760 bool noindirect = d->noindirect;
2771 Lisp_Object this = d->this; 2761 Lisp_Object this = d->this;
2772 Lisp_Object last = d->last; 2762 Lisp_Object last = d->last;
2773 int last_is_meta = d->last_is_meta; 2763 bool last_is_meta = d->last_is_meta;
2774 Lisp_Object sequence; 2764 Lisp_Object sequence;
2775 2765
2776 /* Search through indirections unless that's not wanted. */ 2766 /* Search through indirections unless that's not wanted. */
@@ -2821,8 +2811,8 @@ The optional argument MENUS, if non-nil, says to mention menu bindings.
2821 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) 2811 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus)
2822{ 2812{
2823 Lisp_Object outbuf, shadow; 2813 Lisp_Object outbuf, shadow;
2824 int nomenu = NILP (menus); 2814 bool nomenu = NILP (menus);
2825 register Lisp_Object start1; 2815 Lisp_Object start1;
2826 struct gcpro gcpro1; 2816 struct gcpro gcpro1;
2827 2817
2828 const char *alternate_heading 2818 const char *alternate_heading
@@ -2857,10 +2847,10 @@ You type Translation\n\
2857 alternate_heading = 0; 2847 alternate_heading = 0;
2858 } 2848 }
2859 2849
2860 bufend = push_key_description (translate[c], buf, 1); 2850 bufend = push_key_description (translate[c], buf);
2861 insert (buf, bufend - buf); 2851 insert (buf, bufend - buf);
2862 Findent_to (make_number (16), make_number (1)); 2852 Findent_to (make_number (16), make_number (1));
2863 bufend = push_key_description (c, buf, 1); 2853 bufend = push_key_description (c, buf);
2864 insert (buf, bufend - buf); 2854 insert (buf, bufend - buf);
2865 2855
2866 insert ("\n", 1); 2856 insert ("\n", 1);
@@ -2977,34 +2967,34 @@ You type Translation\n\
2977 2967
2978/* Insert a description of the key bindings in STARTMAP, 2968/* Insert a description of the key bindings in STARTMAP,
2979 followed by those of all maps reachable through STARTMAP. 2969 followed by those of all maps reachable through STARTMAP.
2980 If PARTIAL is nonzero, omit certain "uninteresting" commands 2970 If PARTIAL, omit certain "uninteresting" commands
2981 (such as `undefined'). 2971 (such as `undefined').
2982 If SHADOW is non-nil, it is a list of maps; 2972 If SHADOW is non-nil, it is a list of maps;
2983 don't mention keys which would be shadowed by any of them. 2973 don't mention keys which would be shadowed by any of them.
2984 PREFIX, if non-nil, says mention only keys that start with PREFIX. 2974 PREFIX, if non-nil, says mention only keys that start with PREFIX.
2985 TITLE, if not 0, is a string to insert at the beginning. 2975 TITLE, if not 0, is a string to insert at the beginning.
2986 TITLE should not end with a colon or a newline; we supply that. 2976 TITLE should not end with a colon or a newline; we supply that.
2987 If NOMENU is not 0, then omit menu-bar commands. 2977 If NOMENU, then omit menu-bar commands.
2988 2978
2989 If TRANSL is nonzero, the definitions are actually key translations 2979 If TRANSL, the definitions are actually key translations
2990 so print strings and vectors differently. 2980 so print strings and vectors differently.
2991 2981
2992 If ALWAYS_TITLE is nonzero, print the title even if there are no maps 2982 If ALWAYS_TITLE, print the title even if there are no maps
2993 to look through. 2983 to look through.
2994 2984
2995 If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, 2985 If MENTION_SHADOW, then when something is shadowed by SHADOW,
2996 don't omit it; instead, mention it but say it is shadowed. 2986 don't omit it; instead, mention it but say it is shadowed.
2997 2987
2998 Any inserted text ends in two newlines (used by `help-make-xrefs'). */ 2988 Any inserted text ends in two newlines (used by `help-make-xrefs'). */
2999 2989
3000void 2990void
3001describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, 2991describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow,
3002 Lisp_Object prefix, const char *title, int nomenu, int transl, 2992 Lisp_Object prefix, const char *title, bool nomenu,
3003 int always_title, int mention_shadow) 2993 bool transl, bool always_title, bool mention_shadow)
3004{ 2994{
3005 Lisp_Object maps, orig_maps, seen, sub_shadows; 2995 Lisp_Object maps, orig_maps, seen, sub_shadows;
3006 struct gcpro gcpro1, gcpro2, gcpro3; 2996 struct gcpro gcpro1, gcpro2, gcpro3;
3007 int something = 0; 2997 bool something = 0;
3008 const char *key_heading 2998 const char *key_heading
3009 = "\ 2999 = "\
3010key binding\n\ 3000key binding\n\
@@ -3179,7 +3169,12 @@ describe_translation (Lisp_Object definition, Lisp_Object args)
3179 into an array of `struct describe_map_elt', 3169 into an array of `struct describe_map_elt',
3180 then sorts them by the events. */ 3170 then sorts them by the events. */
3181 3171
3182struct describe_map_elt { Lisp_Object event; Lisp_Object definition; int shadowed; }; 3172struct describe_map_elt
3173{
3174 Lisp_Object event;
3175 Lisp_Object definition;
3176 bool shadowed;
3177};
3183 3178
3184/* qsort comparison function for sorting `struct describe_map_elt' by 3179/* qsort comparison function for sorting `struct describe_map_elt' by
3185 the event field. */ 3180 the event field. */
@@ -3209,14 +3204,14 @@ describe_map_compare (const void *aa, const void *bb)
3209static void 3204static void
3210describe_map (Lisp_Object map, Lisp_Object prefix, 3205describe_map (Lisp_Object map, Lisp_Object prefix,
3211 void (*elt_describer) (Lisp_Object, Lisp_Object), 3206 void (*elt_describer) (Lisp_Object, Lisp_Object),
3212 int partial, Lisp_Object shadow, 3207 bool partial, Lisp_Object shadow,
3213 Lisp_Object *seen, int nomenu, int mention_shadow) 3208 Lisp_Object *seen, bool nomenu, bool mention_shadow)
3214{ 3209{
3215 Lisp_Object tail, definition, event; 3210 Lisp_Object tail, definition, event;
3216 Lisp_Object tem; 3211 Lisp_Object tem;
3217 Lisp_Object suppress; 3212 Lisp_Object suppress;
3218 Lisp_Object kludge; 3213 Lisp_Object kludge;
3219 int first = 1; 3214 bool first = 1;
3220 struct gcpro gcpro1, gcpro2, gcpro3; 3215 struct gcpro gcpro1, gcpro2, gcpro3;
3221 3216
3222 /* These accumulate the values from sparse keymap bindings, 3217 /* These accumulate the values from sparse keymap bindings,
@@ -3258,7 +3253,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3258 1, mention_shadow); 3253 1, mention_shadow);
3259 else if (CONSP (XCAR (tail))) 3254 else if (CONSP (XCAR (tail)))
3260 { 3255 {
3261 int this_shadowed = 0; 3256 bool this_shadowed = 0;
3262 3257
3263 event = XCAR (XCAR (tail)); 3258 event = XCAR (XCAR (tail));
3264 3259
@@ -3428,7 +3423,7 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3428 of bytes that lead to the character set or portion of a character 3423 of bytes that lead to the character set or portion of a character
3429 set described by this chartable. 3424 set described by this chartable.
3430 3425
3431 If PARTIAL is nonzero, it means do not mention suppressed commands 3426 If PARTIAL, it means do not mention suppressed commands
3432 (that assumes the vector is in a keymap). 3427 (that assumes the vector is in a keymap).
3433 3428
3434 SHADOW is a list of keymaps that shadow this map. 3429 SHADOW is a list of keymaps that shadow this map.
@@ -3448,8 +3443,8 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3448static void 3443static void
3449describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, 3444describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3450 void (*elt_describer) (Lisp_Object, Lisp_Object), 3445 void (*elt_describer) (Lisp_Object, Lisp_Object),
3451 int partial, Lisp_Object shadow, Lisp_Object entire_map, 3446 bool partial, Lisp_Object shadow, Lisp_Object entire_map,
3452 int keymap_p, int mention_shadow) 3447 bool keymap_p, bool mention_shadow)
3453{ 3448{
3454 Lisp_Object definition; 3449 Lisp_Object definition;
3455 Lisp_Object tem2; 3450 Lisp_Object tem2;
@@ -3457,7 +3452,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3457 int i; 3452 int i;
3458 Lisp_Object suppress; 3453 Lisp_Object suppress;
3459 Lisp_Object kludge; 3454 Lisp_Object kludge;
3460 int first = 1; 3455 bool first = 1;
3461 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 3456 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3462 /* Range of elements to be handled. */ 3457 /* Range of elements to be handled. */
3463 int from, to, stop; 3458 int from, to, stop;
@@ -3497,7 +3492,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3497 3492
3498 for (i = from; ; i++) 3493 for (i = from; ; i++)
3499 { 3494 {
3500 int this_shadowed = 0; 3495 bool this_shadowed = 0;
3501 int range_beg, range_end; 3496 int range_beg, range_end;
3502 Lisp_Object val; 3497 Lisp_Object val;
3503 3498
diff --git a/src/keymap.h b/src/keymap.h
index 5ed70c67b85..c704ee0b050 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -34,11 +34,11 @@ extern Lisp_Object Qkeymap, Qmenu_bar;
34extern Lisp_Object Qremap; 34extern Lisp_Object Qremap;
35extern Lisp_Object Qmenu_item; 35extern Lisp_Object Qmenu_item;
36extern Lisp_Object current_global_map; 36extern Lisp_Object current_global_map;
37extern char *push_key_description (EMACS_INT, char *, int); 37extern char *push_key_description (EMACS_INT, char *);
38extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, int, int, int); 38extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, bool, bool, bool);
39extern Lisp_Object get_keymap (Lisp_Object, int, int); 39extern Lisp_Object get_keymap (Lisp_Object, bool, bool);
40extern void describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object, 40extern void describe_map_tree (Lisp_Object, bool, Lisp_Object, Lisp_Object,
41 const char *, int, int, int, int); 41 const char *, bool, bool, bool, bool);
42extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **); 42extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **);
43extern void initial_define_key (Lisp_Object, int, const char *); 43extern void initial_define_key (Lisp_Object, int, const char *);
44extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); 44extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
@@ -47,7 +47,8 @@ extern void keys_of_keymap (void);
47 47
48typedef void (*map_keymap_function_t) 48typedef void (*map_keymap_function_t)
49 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data); 49 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data);
50extern void map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object largs, void* cargs, int autoload); 50extern void map_keymap (Lisp_Object, map_keymap_function_t, Lisp_Object,
51 void *, bool);
51extern void map_keymap_canonical (Lisp_Object map, 52extern void map_keymap_canonical (Lisp_Object map,
52 map_keymap_function_t fun, 53 map_keymap_function_t fun,
53 Lisp_Object args, void *data); 54 Lisp_Object args, void *data);
diff --git a/src/lisp.h b/src/lisp.h
index 2a647e593a8..1de9ec74d9f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -345,15 +345,11 @@ static ptrdiff_t const PSEUDOVECTOR_FLAG
345 = PSEUDOVECTOR_FLAG; 345 = PSEUDOVECTOR_FLAG;
346 346
347/* In a pseudovector, the size field actually contains a word with one 347/* In a pseudovector, the size field actually contains a word with one
348 PSEUDOVECTOR_FLAG bit set, and exactly one of the following bits to 348 PSEUDOVECTOR_FLAG bit set, and one of the following values extracted
349 indicate the actual type. 349 with PVEC_TYPE_MASK to indicate the actual type. */
350 We use a bitset, even tho only one of the bits can be set at any
351 particular time just so as to be able to use micro-optimizations such as
352 testing membership of a particular subset of pseudovectors in Fequal.
353 It is not crucial, but there are plenty of bits here, so why not do it? */
354enum pvec_type 350enum pvec_type
355{ 351{
356 PVEC_NORMAL_VECTOR = 0, /* Unused! */ 352 PVEC_NORMAL_VECTOR,
357 PVEC_FREE, 353 PVEC_FREE,
358 PVEC_PROCESS, 354 PVEC_PROCESS,
359 PVEC_FRAME, 355 PVEC_FRAME,
@@ -3202,9 +3198,9 @@ extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
3202extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, 3198extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
3203 ptrdiff_t, ptrdiff_t, Lisp_Object); 3199 ptrdiff_t, ptrdiff_t, Lisp_Object);
3204extern ptrdiff_t scan_buffer (int, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3200extern ptrdiff_t scan_buffer (int, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3205 ptrdiff_t *, int); 3201 ptrdiff_t *, bool);
3206extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3202extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3207 EMACS_INT, int); 3203 EMACS_INT, bool);
3208extern ptrdiff_t find_next_newline (ptrdiff_t, int); 3204extern ptrdiff_t find_next_newline (ptrdiff_t, int);
3209extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t); 3205extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t);
3210extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t); 3206extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t);
@@ -3247,7 +3243,7 @@ extern Lisp_Object Qdisabled, QCfilter;
3247extern Lisp_Object Qup, Qdown, Qbottom; 3243extern Lisp_Object Qup, Qdown, Qbottom;
3248extern Lisp_Object Qtop; 3244extern Lisp_Object Qtop;
3249extern Lisp_Object last_undo_boundary; 3245extern Lisp_Object last_undo_boundary;
3250extern int input_pending; 3246extern bool input_pending;
3251extern Lisp_Object menu_bar_items (Lisp_Object); 3247extern Lisp_Object menu_bar_items (Lisp_Object);
3252extern Lisp_Object tool_bar_items (Lisp_Object, int *); 3248extern Lisp_Object tool_bar_items (Lisp_Object, int *);
3253extern void discard_mouse_events (void); 3249extern void discard_mouse_events (void);
@@ -3255,9 +3251,9 @@ extern void discard_mouse_events (void);
3255void handle_input_available_signal (int); 3251void handle_input_available_signal (int);
3256#endif 3252#endif
3257extern Lisp_Object pending_funcalls; 3253extern Lisp_Object pending_funcalls;
3258extern int detect_input_pending (void); 3254extern bool detect_input_pending (void);
3259extern int detect_input_pending_ignore_squeezables (void); 3255extern bool detect_input_pending_ignore_squeezables (void);
3260extern int detect_input_pending_run_timers (int); 3256extern bool detect_input_pending_run_timers (bool);
3261extern void safe_run_hooks (Lisp_Object); 3257extern void safe_run_hooks (Lisp_Object);
3262extern void cmd_error_internal (Lisp_Object, const char *); 3258extern void cmd_error_internal (Lisp_Object, const char *);
3263extern Lisp_Object command_loop_1 (void); 3259extern Lisp_Object command_loop_1 (void);
@@ -3336,7 +3332,7 @@ extern bool running_asynch_code;
3336extern Lisp_Object QCtype, Qlocal; 3332extern Lisp_Object QCtype, Qlocal;
3337extern Lisp_Object Qprocessp; 3333extern Lisp_Object Qprocessp;
3338extern void kill_buffer_processes (Lisp_Object); 3334extern void kill_buffer_processes (Lisp_Object);
3339extern int wait_reading_process_output (intmax_t, int, int, int, 3335extern int wait_reading_process_output (intmax_t, int, int, bool,
3340 Lisp_Object, 3336 Lisp_Object,
3341 struct Lisp_Process *, 3337 struct Lisp_Process *,
3342 int); 3338 int);
@@ -3563,7 +3559,8 @@ extern char *emacs_root_dir (void);
3563 Used during startup to detect startup of dumped Emacs. */ 3559 Used during startup to detect startup of dumped Emacs. */
3564extern bool initialized; 3560extern bool initialized;
3565 3561
3566extern int immediate_quit; /* Nonzero means ^G can quit instantly. */ 3562/* True means ^G can quit instantly. */
3563extern bool immediate_quit;
3567 3564
3568extern void *xmalloc (size_t); 3565extern void *xmalloc (size_t);
3569extern void *xzalloc (size_t); 3566extern void *xzalloc (size_t);
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index c6fbf59fb5a..40a075dbf3c 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -27,7 +27,7 @@ EMACSLOADPATH=$(CURDIR)/../lisp
27# Size in MBs of the static heap in temacs.exe. 27# Size in MBs of the static heap in temacs.exe.
28HEAPSIZE = $(EMACS_HEAPSIZE) 28HEAPSIZE = $(EMACS_HEAPSIZE)
29 29
30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc -DHAVE_NTGUI=1 $(EMACS_EXTRA_C_FLAGS) 30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc $(EMACS_EXTRA_C_FLAGS)
31 31
32SRC = . 32SRC = .
33EMACS = $(BLD)/emacs.exe 33EMACS = $(BLD)/emacs.exe
@@ -207,7 +207,7 @@ make-buildobj-SH:
207GLOBAL_SOURCES = dosfns.c msdos.c \ 207GLOBAL_SOURCES = dosfns.c msdos.c \
208 xterm.c xfns.c xmenu.c xselect.c xrdb.c xsmfns.c fringe.c image.c \ 208 xterm.c xfns.c xmenu.c xselect.c xrdb.c xsmfns.c fringe.c image.c \
209 fontset.c menu.c dbusbind.c \ 209 fontset.c menu.c dbusbind.c \
210 w32.c w32console.c w32fns.c w32heap.c w32inevt.c \ 210 w32.c w32console.c w32fns.c w32heap.c w32inevt.c cygw32.c \
211 w32menu.c w32proc.c w32reg.c w32select.c w32term.c w32xfns.c \ 211 w32menu.c w32proc.c w32reg.c w32select.c w32term.c w32xfns.c \
212 font.c w32font.c w32uniscribe.c \ 212 font.c w32font.c w32uniscribe.c \
213 dispnew.c frame.c scroll.c xdisp.c window.c bidi.c \ 213 dispnew.c frame.c scroll.c xdisp.c window.c bidi.c \
@@ -423,10 +423,11 @@ DISPEXTERN_H = $(SRC)/dispextern.h \
423 $(W32GUI_H) 423 $(W32GUI_H)
424FILEMODE_H = $(GNU_LIB)/filemode.h \ 424FILEMODE_H = $(GNU_LIB)/filemode.h \
425 $(NT_INC)/sys/stat.h 425 $(NT_INC)/sys/stat.h
426FONT_H = $(SRC)/font.h \
427 $(CCL_H)
428FRAME_H = $(SRC)/frame.h \ 426FRAME_H = $(SRC)/frame.h \
429 $(DISPEXTERN_H) 427 $(DISPEXTERN_H)
428FONT_H = $(SRC)/font.h \
429 $(CCL_H) \
430 $(FRAME_H)
430FTOASTR_H = $(GNU_LIB)/ftoastr.h \ 431FTOASTR_H = $(GNU_LIB)/ftoastr.h \
431 $(GNU_LIB)/intprops.h 432 $(GNU_LIB)/intprops.h
432GRP_H = $(NT_INC)/grp.h \ 433GRP_H = $(NT_INC)/grp.h \
@@ -476,6 +477,8 @@ TERMHOOKS_H = $(SRC)/termhooks.h \
476W32FONT_H = $(SRC)/w32font.h \ 477W32FONT_H = $(SRC)/w32font.h \
477 $(FONT_H) 478 $(FONT_H)
478W32TERM_H = $(SRC)/w32term.h \ 479W32TERM_H = $(SRC)/w32term.h \
480 $(ATIMER_H) \
481 $(FRAME_H) \
479 $(W32GUI_H) 482 $(W32GUI_H)
480WINDOW_H = $(SRC)/window.h \ 483WINDOW_H = $(SRC)/window.h \
481 $(DISPEXTERN_H) 484 $(DISPEXTERN_H)
@@ -732,7 +735,6 @@ $(BLD)/dispnew.$(O) : \
732 $(SRC)/disptab.h \ 735 $(SRC)/disptab.h \
733 $(SRC)/indent.h \ 736 $(SRC)/indent.h \
734 $(SRC)/termchar.h \ 737 $(SRC)/termchar.h \
735 $(SRC)/termopts.h \
736 $(NT_INC)/unistd.h \ 738 $(NT_INC)/unistd.h \
737 $(BUFFER_H) \ 739 $(BUFFER_H) \
738 $(CHARACTER_H) \ 740 $(CHARACTER_H) \
@@ -796,6 +798,7 @@ $(BLD)/emacs.$(O) : \
796 $(SRC)/unexec.h \ 798 $(SRC)/unexec.h \
797 $(SRC)/w32.h \ 799 $(SRC)/w32.h \
798 $(SRC)/w32heap.h \ 800 $(SRC)/w32heap.h \
801 $(SRC)/w32select.h \
799 $(NT_INC)/sys/file.h \ 802 $(NT_INC)/sys/file.h \
800 $(NT_INC)/unistd.h \ 803 $(NT_INC)/unistd.h \
801 $(GNU_LIB)/ignore-value.h \ 804 $(GNU_LIB)/ignore-value.h \
@@ -811,6 +814,7 @@ $(BLD)/emacs.$(O) : \
811 $(SYSSIGNAL_H) \ 814 $(SYSSIGNAL_H) \
812 $(SYSTTY_H) \ 815 $(SYSTTY_H) \
813 $(TERMHOOKS_H) \ 816 $(TERMHOOKS_H) \
817 $(W32FONT_H) \
814 $(W32TERM_H) \ 818 $(W32TERM_H) \
815 $(WINDOW_H) 819 $(WINDOW_H)
816 820
@@ -1010,7 +1014,6 @@ $(BLD)/indent.$(O) : \
1010 $(SRC)/indent.h \ 1014 $(SRC)/indent.h \
1011 $(SRC)/region-cache.h \ 1015 $(SRC)/region-cache.h \
1012 $(SRC)/termchar.h \ 1016 $(SRC)/termchar.h \
1013 $(SRC)/termopts.h \
1014 $(BUFFER_H) \ 1017 $(BUFFER_H) \
1015 $(CHARACTER_H) \ 1018 $(CHARACTER_H) \
1016 $(CONFIG_H) \ 1019 $(CONFIG_H) \
@@ -1167,6 +1170,7 @@ $(BLD)/w32.$(O) : \
1167 $(SRC)/w32.c \ 1170 $(SRC)/w32.c \
1168 $(SRC)/ndir.h \ 1171 $(SRC)/ndir.h \
1169 $(SRC)/w32.h \ 1172 $(SRC)/w32.h \
1173 $(SRC)/w32common.h \
1170 $(SRC)/w32heap.h \ 1174 $(SRC)/w32heap.h \
1171 $(NT_INC)/pwd.h \ 1175 $(NT_INC)/pwd.h \
1172 $(NT_INC)/sys/file.h \ 1176 $(NT_INC)/sys/file.h \
@@ -1184,6 +1188,7 @@ $(BLD)/w32.$(O) : \
1184 1188
1185$(BLD)/w32heap.$(O) : \ 1189$(BLD)/w32heap.$(O) : \
1186 $(SRC)/w32heap.c \ 1190 $(SRC)/w32heap.c \
1191 $(SRC)/w32common.h \
1187 $(SRC)/w32heap.h \ 1192 $(SRC)/w32heap.h \
1188 $(CONFIG_H) \ 1193 $(CONFIG_H) \
1189 $(LISP_H) 1194 $(LISP_H)
@@ -1207,6 +1212,7 @@ $(BLD)/w32proc.$(O) : \
1207 $(SRC)/w32proc.c \ 1212 $(SRC)/w32proc.c \
1208 $(SRC)/syswait.h \ 1213 $(SRC)/syswait.h \
1209 $(SRC)/w32.h \ 1214 $(SRC)/w32.h \
1215 $(SRC)/w32common.h \
1210 $(SRC)/w32heap.h \ 1216 $(SRC)/w32heap.h \
1211 $(NT_INC)/nl_types.h \ 1217 $(NT_INC)/nl_types.h \
1212 $(NT_INC)/sys/file.h \ 1218 $(NT_INC)/sys/file.h \
@@ -1224,7 +1230,7 @@ $(BLD)/w32console.$(O) : \
1224 $(SRC)/w32console.c \ 1230 $(SRC)/w32console.c \
1225 $(SRC)/disptab.h \ 1231 $(SRC)/disptab.h \
1226 $(SRC)/termchar.h \ 1232 $(SRC)/termchar.h \
1227 $(SRC)/w32heap.h \ 1233 $(SRC)/w32common.h \
1228 $(SRC)/w32inevt.h \ 1234 $(SRC)/w32inevt.h \
1229 $(CHARACTER_H) \ 1235 $(CHARACTER_H) \
1230 $(CODING_H) \ 1236 $(CODING_H) \
@@ -1233,6 +1239,7 @@ $(BLD)/w32console.$(O) : \
1233 $(FRAME_H) \ 1239 $(FRAME_H) \
1234 $(LISP_H) \ 1240 $(LISP_H) \
1235 $(TERMHOOKS_H) \ 1241 $(TERMHOOKS_H) \
1242 $(W32TERM_H) \
1236 $(WINDOW_H) 1243 $(WINDOW_H)
1237 1244
1238$(BLD)/print.$(O) : \ 1245$(BLD)/print.$(O) : \
@@ -1403,7 +1410,6 @@ $(BLD)/term.$(O) : \
1403 $(SRC)/disptab.h \ 1410 $(SRC)/disptab.h \
1404 $(SRC)/keymap.h \ 1411 $(SRC)/keymap.h \
1405 $(SRC)/termchar.h \ 1412 $(SRC)/termchar.h \
1406 $(SRC)/termopts.h \
1407 $(SRC)/tparam.h \ 1413 $(SRC)/tparam.h \
1408 $(NT_INC)/sys/file.h \ 1414 $(NT_INC)/sys/file.h \
1409 $(NT_INC)/sys/time.h \ 1415 $(NT_INC)/sys/time.h \
@@ -1461,6 +1467,7 @@ $(BLD)/undo.$(O) : \
1461$(BLD)/unexw32.$(O) : \ 1467$(BLD)/unexw32.$(O) : \
1462 $(SRC)/unexw32.c \ 1468 $(SRC)/unexw32.c \
1463 $(SRC)/unexec.h \ 1469 $(SRC)/unexec.h \
1470 $(SRC)/w32common.h \
1464 $(SRC)/w32heap.h \ 1471 $(SRC)/w32heap.h \
1465 $(CONFIG_H) 1472 $(CONFIG_H)
1466 1473
@@ -1547,6 +1554,7 @@ $(BLD)/w32fns.$(O) : \
1547 $(SRC)/epaths.h \ 1554 $(SRC)/epaths.h \
1548 $(SRC)/fontset.h \ 1555 $(SRC)/fontset.h \
1549 $(SRC)/w32.h \ 1556 $(SRC)/w32.h \
1557 $(SRC)/w32common.h \
1550 $(SRC)/w32heap.h \ 1558 $(SRC)/w32heap.h \
1551 $(BUFFER_H) \ 1559 $(BUFFER_H) \
1552 $(CCL_H) \ 1560 $(CCL_H) \
@@ -1570,7 +1578,7 @@ $(BLD)/w32menu.$(O) : \
1570 $(SRC)/w32menu.c \ 1578 $(SRC)/w32menu.c \
1571 $(SRC)/blockinput.h \ 1579 $(SRC)/blockinput.h \
1572 $(SRC)/keymap.h \ 1580 $(SRC)/keymap.h \
1573 $(SRC)/w32heap.h \ 1581 $(SRC)/w32common.h \
1574 $(BUFFER_H) \ 1582 $(BUFFER_H) \
1575 $(CHARACTER_H) \ 1583 $(CHARACTER_H) \
1576 $(CHARSET_H) \ 1584 $(CHARSET_H) \
@@ -1620,7 +1628,7 @@ $(BLD)/w32select.$(O) : \
1620 $(SRC)/w32select.c \ 1628 $(SRC)/w32select.c \
1621 $(SRC)/blockinput.h \ 1629 $(SRC)/blockinput.h \
1622 $(SRC)/composite.h \ 1630 $(SRC)/composite.h \
1623 $(SRC)/w32heap.h \ 1631 $(SRC)/w32common.h \
1624 $(CHARSET_H) \ 1632 $(CHARSET_H) \
1625 $(CODING_H) \ 1633 $(CODING_H) \
1626 $(CONFIG_H) \ 1634 $(CONFIG_H) \
diff --git a/src/marker.c b/src/marker.c
index e01647bdb2a..2e2aba579db 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -29,7 +29,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29static ptrdiff_t cached_charpos; 29static ptrdiff_t cached_charpos;
30static ptrdiff_t cached_bytepos; 30static ptrdiff_t cached_bytepos;
31static struct buffer *cached_buffer; 31static struct buffer *cached_buffer;
32static int cached_modiff; 32static EMACS_INT cached_modiff;
33 33
34/* Juanma Barranquero <lekktu@gmail.com> reported ~3x increased 34/* Juanma Barranquero <lekktu@gmail.com> reported ~3x increased
35 bootstrap time when byte_char_debug_check is enabled; so this 35 bootstrap time when byte_char_debug_check is enabled; so this
diff --git a/src/menu.c b/src/menu.c
index 5374aa9157a..6e052dc65a9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -40,7 +40,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40#endif /* HAVE_WINDOW_SYSTEM */ 40#endif /* HAVE_WINDOW_SYSTEM */
41 41
42#ifdef HAVE_NTGUI 42#ifdef HAVE_NTGUI
43# ifdef NTGUI_UNICODE
44# define unicode_append_menu AppendMenuW
45# else /* !NTGUI_UNICODE */
43extern AppendMenuW_Proc unicode_append_menu; 46extern AppendMenuW_Proc unicode_append_menu;
47# endif /* NTGUI_UNICODE */
44extern HMENU current_popup_menu; 48extern HMENU current_popup_menu;
45#endif /* HAVE_NTGUI */ 49#endif /* HAVE_NTGUI */
46 50
@@ -327,7 +331,7 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
327{ 331{
328 Lisp_Object map, item_string, enabled; 332 Lisp_Object map, item_string, enabled;
329 struct gcpro gcpro1, gcpro2; 333 struct gcpro gcpro1, gcpro2;
330 int res; 334 bool res;
331 struct skp *skp = skp_v; 335 struct skp *skp = skp_v;
332 336
333 /* Parse the menu item and leave the result in item_properties. */ 337 /* Parse the menu item and leave the result in item_properties. */
diff --git a/src/nsfont.m b/src/nsfont.m
index b13c96aa6ed..a820b60ac58 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -53,6 +53,7 @@ extern float ns_antialias_threshold;
53extern int ns_tmp_flags; 53extern int ns_tmp_flags;
54extern struct nsfont_info *ns_tmp_font; 54extern struct nsfont_info *ns_tmp_font;
55 55
56
56/* font glyph and metrics caching functions, implemented at end */ 57/* font glyph and metrics caching functions, implemented at end */
57static void ns_uni_to_glyphs (struct nsfont_info *font_info, 58static void ns_uni_to_glyphs (struct nsfont_info *font_info,
58 unsigned char block); 59 unsigned char block);
@@ -799,8 +800,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
799 { 800 {
800 if (NSFONT_TRACE) 801 if (NSFONT_TRACE)
801 fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); 802 fprintf(stderr, "*** nsfont_open CACHE HIT!\n");
802 /* FIXME: Cast from (unsigned long) to Lisp_Object. */ 803 XHASH (font_object) = [cached unsignedLongLongValue];
803 XHASH (font_object) = [cached unsignedLongValue];
804 return font_object; 804 return font_object;
805 } 805 }
806 else 806 else
@@ -808,9 +808,12 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
808 font_object = font_make_object (VECSIZE (struct nsfont_info), 808 font_object = font_make_object (VECSIZE (struct nsfont_info),
809 font_entity, pixel_size); 809 font_entity, pixel_size);
810 if (!synthItal) 810 if (!synthItal)
811 [fontCache setObject: [NSNumber numberWithUnsignedLong: 811 {
812 (unsigned long) XHASH (font_object)] 812 [fontCache setObject: [NSNumber
813 forKey: nsfont]; 813 numberWithUnsignedLongLong:
814 (unsigned long long) XHASH (font_object)]
815 forKey: nsfont];
816 }
814 } 817 }
815 818
816 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); 819 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 9af732c6c45..a5983c70cdb 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -128,8 +128,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
128 static EmacsMenu *last_submenu = nil; 128 static EmacsMenu *last_submenu = nil;
129 BOOL needsSet = NO; 129 BOOL needsSet = NO;
130 const char *submenuTitle = [[submenu title] UTF8String]; 130 const char *submenuTitle = [[submenu title] UTF8String];
131 extern int waiting_for_input; 131 bool owfi;
132 int owfi;
133 Lisp_Object items; 132 Lisp_Object items;
134 widget_value *wv, *first_wv, *prev_wv = 0; 133 widget_value *wv, *first_wv, *prev_wv = 0;
135 int i; 134 int i;
diff --git a/src/nsterm.m b/src/nsterm.m
index 6b739befeeb..1d935fc76de 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -55,7 +55,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
55#include "ccl.h" 55#include "ccl.h"
56 56
57#include "termhooks.h" 57#include "termhooks.h"
58#include "termopts.h"
59#include "termchar.h" 58#include "termchar.h"
60 59
61#include "window.h" 60#include "window.h"
@@ -1315,7 +1314,7 @@ static void
1315ns_fullscreen_hook (FRAME_PTR f) 1314ns_fullscreen_hook (FRAME_PTR f)
1316{ 1315{
1317 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); 1316 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1318 1317
1319 if (! f->async_visible) return; 1318 if (! f->async_visible) return;
1320#ifndef NEW_STYLE_FS 1319#ifndef NEW_STYLE_FS
1321 if (f->want_fullscreen == FULLSCREEN_BOTH) 1320 if (f->want_fullscreen == FULLSCREEN_BOTH)
@@ -5942,7 +5941,7 @@ not_in_argv (NSString *arg)
5942 [w setBackgroundColor: col]; 5941 [w setBackgroundColor: col];
5943 if ([col alphaComponent] != 1.0) 5942 if ([col alphaComponent] != 1.0)
5944 [w setOpaque: NO]; 5943 [w setOpaque: NO];
5945 5944
5946 f->border_width = bwidth; 5945 f->border_width = bwidth;
5947 FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; 5946 FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height;
5948 FRAME_TOOLBAR_HEIGHT (f) = tobar_height; 5947 FRAME_TOOLBAR_HEIGHT (f) = tobar_height;
@@ -5995,7 +5994,7 @@ not_in_argv (NSString *arg)
5995 } 5994 }
5996 break; 5995 break;
5997 } 5996 }
5998 5997
5999 emacsframe->want_fullscreen = FULLSCREEN_NONE; 5998 emacsframe->want_fullscreen = FULLSCREEN_NONE;
6000 } 5999 }
6001 6000
diff --git a/src/process.c b/src/process.c
index 92bea0d3a27..2cbce9d28ea 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4302,7 +4302,7 @@ wait_reading_process_output_1 (void)
4302 -1 meaning caller will actually read the input, so don't throw to 4302 -1 meaning caller will actually read the input, so don't throw to
4303 the quit handler, or 4303 the quit handler, or
4304 4304
4305 DO_DISPLAY != 0 means redisplay should be done to show subprocess 4305 DO_DISPLAY means redisplay should be done to show subprocess
4306 output that arrives. 4306 output that arrives.
4307 4307
4308 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil 4308 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil
@@ -4322,7 +4322,7 @@ wait_reading_process_output_1 (void)
4322 4322
4323int 4323int
4324wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 4324wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4325 int do_display, 4325 bool do_display,
4326 Lisp_Object wait_for_cell, 4326 Lisp_Object wait_for_cell,
4327 struct Lisp_Process *wait_proc, int just_wait_proc) 4327 struct Lisp_Process *wait_proc, int just_wait_proc)
4328{ 4328{
@@ -4419,7 +4419,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4419 4419
4420 do 4420 do
4421 { 4421 {
4422 int old_timers_run = timers_run; 4422 unsigned old_timers_run = timers_run;
4423 struct buffer *old_buffer = current_buffer; 4423 struct buffer *old_buffer = current_buffer;
4424 Lisp_Object old_window = selected_window; 4424 Lisp_Object old_window = selected_window;
4425 4425
@@ -4646,6 +4646,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4646 process_output_skip = 0; 4646 process_output_skip = 0;
4647 } 4647 }
4648#endif 4648#endif
4649
4649#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 4650#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
4650 nfds = xg_select 4651 nfds = xg_select
4651#elif defined (HAVE_NS) 4652#elif defined (HAVE_NS)
@@ -4752,7 +4753,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4752 4753
4753 if (read_kbd != 0) 4754 if (read_kbd != 0)
4754 { 4755 {
4755 int old_timers_run = timers_run; 4756 unsigned old_timers_run = timers_run;
4756 struct buffer *old_buffer = current_buffer; 4757 struct buffer *old_buffer = current_buffer;
4757 Lisp_Object old_window = selected_window; 4758 Lisp_Object old_window = selected_window;
4758 int leave = 0; 4759 int leave = 0;
@@ -6820,14 +6821,14 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
6820 see full version for other parameters. We know that wait_proc will 6821 see full version for other parameters. We know that wait_proc will
6821 always be NULL, since `subprocesses' isn't defined. 6822 always be NULL, since `subprocesses' isn't defined.
6822 6823
6823 DO_DISPLAY != 0 means redisplay should be done to show subprocess 6824 DO_DISPLAY means redisplay should be done to show subprocess
6824 output that arrives. 6825 output that arrives.
6825 6826
6826 Return true if we received input from any process. */ 6827 Return true if we received input from any process. */
6827 6828
6828int 6829int
6829wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 6830wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6830 int do_display, 6831 bool do_display,
6831 Lisp_Object wait_for_cell, 6832 Lisp_Object wait_for_cell,
6832 struct Lisp_Process *wait_proc, int just_wait_proc) 6833 struct Lisp_Process *wait_proc, int just_wait_proc)
6833{ 6834{
@@ -6903,7 +6904,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6903 6904
6904 do 6905 do
6905 { 6906 {
6906 int old_timers_run = timers_run; 6907 unsigned old_timers_run = timers_run;
6907 timer_delay = timer_check (); 6908 timer_delay = timer_check ();
6908 if (timers_run != old_timers_run && do_display) 6909 if (timers_run != old_timers_run && do_display)
6909 /* We must retry, since a timer may have requeued itself 6910 /* We must retry, since a timer may have requeued itself
diff --git a/src/ralloc.c b/src/ralloc.c
index e4a8fe9c6da..11897411930 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -327,10 +327,11 @@ relinquish (void)
327 327
328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess) 328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess)
329 { 329 {
330 /* This heap should have no blocs in it. */ 330 /* This heap should have no blocs in it. If it does, we
331 cannot return it to the system. */
331 if (last_heap->first_bloc != NIL_BLOC 332 if (last_heap->first_bloc != NIL_BLOC
332 || last_heap->last_bloc != NIL_BLOC) 333 || last_heap->last_bloc != NIL_BLOC)
333 emacs_abort (); 334 return;
334 335
335 /* Return the last heap, with its header, to the system. */ 336 /* Return the last heap, with its header, to the system. */
336 excess = (char *)last_heap->end - (char *)last_heap->start; 337 excess = (char *)last_heap->end - (char *)last_heap->start;
diff --git a/src/regex.c b/src/regex.c
index 17562043df1..7443eff3977 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1834,7 +1834,6 @@ typedef struct
1834/* Explicit quit checking is needed for Emacs, which uses polling to 1834/* Explicit quit checking is needed for Emacs, which uses polling to
1835 process input events. */ 1835 process input events. */
1836#ifdef emacs 1836#ifdef emacs
1837extern int immediate_quit;
1838# define IMMEDIATE_QUIT_CHECK \ 1837# define IMMEDIATE_QUIT_CHECK \
1839 do { \ 1838 do { \
1840 if (immediate_quit) QUIT; \ 1839 if (immediate_quit) QUIT; \
diff --git a/src/search.c b/src/search.c
index 7c084c62e28..aacdbe33eef 100644
--- a/src/search.c
+++ b/src/search.c
@@ -636,12 +636,12 @@ newline_cache_on_off (struct buffer *buf)
636 If we don't find COUNT instances before reaching END, set *SHORTAGE 636 If we don't find COUNT instances before reaching END, set *SHORTAGE
637 to the number of TARGETs left unfound, and return END. 637 to the number of TARGETs left unfound, and return END.
638 638
639 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 639 If ALLOW_QUIT, set immediate_quit. That's good to do
640 except when inside redisplay. */ 640 except when inside redisplay. */
641 641
642ptrdiff_t 642ptrdiff_t
643scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, 643scan_buffer (int target, ptrdiff_t start, ptrdiff_t end,
644 ptrdiff_t count, ptrdiff_t *shortage, int allow_quit) 644 ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit)
645{ 645{
646 struct region_cache *newline_cache; 646 struct region_cache *newline_cache;
647 int direction; 647 int direction;
@@ -837,23 +837,23 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
837 the number of line boundaries left unfound, and position at 837 the number of line boundaries left unfound, and position at
838 the limit we bumped up against. 838 the limit we bumped up against.
839 839
840 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 840 If ALLOW_QUIT, set immediate_quit. That's good to do
841 except in special cases. */ 841 except in special cases. */
842 842
843EMACS_INT 843EMACS_INT
844scan_newline (ptrdiff_t start, ptrdiff_t start_byte, 844scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
845 ptrdiff_t limit, ptrdiff_t limit_byte, 845 ptrdiff_t limit, ptrdiff_t limit_byte,
846 register EMACS_INT count, int allow_quit) 846 EMACS_INT count, bool allow_quit)
847{ 847{
848 int direction = ((count > 0) ? 1 : -1); 848 int direction = ((count > 0) ? 1 : -1);
849 849
850 register unsigned char *cursor; 850 unsigned char *cursor;
851 unsigned char *base; 851 unsigned char *base;
852 852
853 ptrdiff_t ceiling; 853 ptrdiff_t ceiling;
854 register unsigned char *ceiling_addr; 854 unsigned char *ceiling_addr;
855 855
856 int old_immediate_quit = immediate_quit; 856 bool old_immediate_quit = immediate_quit;
857 857
858 /* The code that follows is like scan_buffer 858 /* The code that follows is like scan_buffer
859 but checks for either newline or carriage return. */ 859 but checks for either newline or carriage return. */
diff --git a/src/term.c b/src/term.c
index 189fb783cbc..acce9c0548c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 28
29#include "lisp.h" 29#include "lisp.h"
30#include "termchar.h" 30#include "termchar.h"
31#include "termopts.h"
32#include "tparam.h" 31#include "tparam.h"
33#include "character.h" 32#include "character.h"
34#include "buffer.h" 33#include "buffer.h"
diff --git a/src/termhooks.h b/src/termhooks.h
index f35bd929af1..c33c2dd1587 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -107,9 +107,9 @@ enum event_kind
107 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second 107 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second
108 horizontal wheel that is present on some 108 horizontal wheel that is present on some
109 mice. See WHEEL_EVENT. */ 109 mice. See WHEEL_EVENT. */
110#if defined (WINDOWSNT) 110#ifdef HAVE_NTGUI
111 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is 111 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is
112 generated on WINDOWSNT or Mac OS 112 generated when HAVE_NTGUI or on Mac OS
113 when the keyboard layout or input 113 when the keyboard layout or input
114 language is changed by the 114 language is changed by the
115 user. */ 115 user. */
@@ -188,7 +188,7 @@ enum event_kind
188 188
189 , CONFIG_CHANGED_EVENT 189 , CONFIG_CHANGED_EVENT
190 190
191#ifdef WINDOWSNT 191#ifdef HAVE_NTGUI
192 /* Generated when an APPCOMMAND event is received, in response to 192 /* Generated when an APPCOMMAND event is received, in response to
193 Multimedia or Internet buttons on some keyboards. 193 Multimedia or Internet buttons on some keyboards.
194 Such keys are available as normal function keys on X through the 194 Such keys are available as normal function keys on X through the
diff --git a/src/termopts.h b/src/termopts.h
index 7bf71aeefe7..05fa0a52eee 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -17,15 +17,8 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 19
20/* Nonzero means use ^S/^Q as cretinous flow control. */
21extern int flow_control;
22
23/* Nonzero means use interrupt-driven input. */ 20/* Nonzero means use interrupt-driven input. */
24extern int interrupt_input; 21extern bool interrupt_input;
25 22
26/* Nonzero while interrupts are temporarily deferred during redisplay. */ 23/* Nonzero while interrupts are temporarily deferred during redisplay. */
27extern int interrupts_deferred; 24extern bool interrupts_deferred;
28
29/* Terminal has meta key */
30extern int meta_key;
31
diff --git a/src/unexcw.c b/src/unexcw.c
index 96c4b4a9aec..8c5d574530d 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include "unexec.h" 22#include "unexec.h"
23#include "w32common.h"
23 24
24#include <lisp.h> 25#include <lisp.h>
25#include <stdio.h> 26#include <stdio.h>
diff --git a/src/unexw32.c b/src/unexw32.c
index 3eefc9ce058..82671d0f120 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <config.h> 23#include <config.h>
24#include "unexec.h" 24#include "unexec.h"
25#include "w32common.h"
25 26
26#include <stdio.h> 27#include <stdio.h>
27#include <fcntl.h> 28#include <fcntl.h>
@@ -83,7 +84,7 @@ DWORD_PTR extra_bss_size_static = 0;
83PIMAGE_SECTION_HEADER heap_section; 84PIMAGE_SECTION_HEADER heap_section;
84 85
85#ifdef HAVE_NTGUI 86#ifdef HAVE_NTGUI
86HINSTANCE hinst = NULL; 87extern HINSTANCE hinst;
87HINSTANCE hprevinst = NULL; 88HINSTANCE hprevinst = NULL;
88LPSTR lpCmdLine = ""; 89LPSTR lpCmdLine = "";
89int nCmdShow = 0; 90int nCmdShow = 0;
diff --git a/src/w32.c b/src/w32.c
index f17c06ea807..b50cd13517d 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -31,13 +31,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <sys/file.h> 31#include <sys/file.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/utime.h> 33#include <sys/utime.h>
34#include <mbstring.h> /* for _mbspbrk */
35#include <math.h> 34#include <math.h>
36#include <time.h> 35#include <time.h>
37 36
38/* must include CRT headers *before* config.h */ 37/* must include CRT headers *before* config.h */
39 38
40#include <config.h> 39#include <config.h>
40#include <mbstring.h> /* for _mbspbrk */
41 41
42#undef access 42#undef access
43#undef chdir 43#undef chdir
@@ -173,6 +173,7 @@ typedef struct _REPARSE_DATA_BUFFER {
173 173
174#include "w32.h" 174#include "w32.h"
175#include "ndir.h" 175#include "ndir.h"
176#include "w32common.h"
176#include "w32heap.h" 177#include "w32heap.h"
177#include "systime.h" 178#include "systime.h"
178#include "dispextern.h" /* for xstrcasecmp */ 179#include "dispextern.h" /* for xstrcasecmp */
@@ -866,23 +867,6 @@ create_symbolic_link (LPTSTR lpSymlinkFilename,
866 return retval; 867 return retval;
867} 868}
868 869
869/* Equivalent of strerror for W32 error codes. */
870char *
871w32_strerror (int error_no)
872{
873 static char buf[500];
874
875 if (error_no == 0)
876 error_no = GetLastError ();
877
878 buf[0] = '\0';
879 if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL,
880 error_no,
881 0, /* choose most suitable language */
882 buf, sizeof (buf), NULL))
883 sprintf (buf, "w32 error %u", error_no);
884 return buf;
885}
886 870
887/* Return 1 if P is a valid pointer to an object of size SIZE. Return 871/* Return 1 if P is a valid pointer to an object of size SIZE. Return
888 0 if P is NOT a valid pointer. Return -1 if we cannot validate P. 872 0 if P is NOT a valid pointer. Return -1 if we cannot validate P.
diff --git a/src/w32.h b/src/w32.h
index 2e2315e245d..c4cfdf5fedd 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -19,6 +19,12 @@ GNU General Public License for more details.
19You should have received a copy of the GNU General Public License 19You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#ifdef CYGWIN
23#error "w32.h is not compatible with Cygwin"
24#endif
25
26#include <windows.h>
27
22 28
23/* File descriptor set emulation. */ 29/* File descriptor set emulation. */
24 30
@@ -130,17 +136,6 @@ extern LPBYTE w32_get_resource (char * key, LPDWORD type);
130extern void init_ntproc (int); 136extern void init_ntproc (int);
131extern void term_ntproc (int); 137extern void term_ntproc (int);
132extern void globals_of_w32 (void); 138extern void globals_of_w32 (void);
133extern void syms_of_w32term (void);
134extern void syms_of_w32fns (void);
135extern void globals_of_w32fns (void);
136extern void syms_of_w32select (void);
137extern void globals_of_w32select (void);
138extern void term_w32select (void);
139extern void syms_of_w32menu (void);
140extern void globals_of_w32menu (void);
141extern void syms_of_fontset (void);
142extern void syms_of_w32font (void);
143extern void check_windows_init_file (void);
144 139
145extern void term_timers (void); 140extern void term_timers (void);
146extern void init_timers (void); 141extern void init_timers (void);
diff --git a/src/w32common.h b/src/w32common.h
new file mode 100644
index 00000000000..50724e5553c
--- /dev/null
+++ b/src/w32common.h
@@ -0,0 +1,53 @@
1/* Common functions for Microsoft Windows builds of Emacs
2 Copyright (C) 2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef W32COMMON_H
22#define W32COMMON_H
23
24#include <windows.h>
25
26#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
27#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
28
29#define get_page_size() sysinfo_cache.dwPageSize
30#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
31#define get_processor_type() sysinfo_cache.dwProcessorType
32#define get_w32_major_version() w32_major_version
33#define get_w32_minor_version() w32_minor_version
34
35extern SYSTEM_INFO sysinfo_cache;
36extern OSVERSIONINFO osinfo_cache;
37extern unsigned long syspage_mask;
38
39extern int w32_major_version;
40extern int w32_minor_version;
41extern int w32_build_number;
42
43enum {
44 OS_9X = 1,
45 OS_NT
46};
47
48extern int os_subtype;
49
50/* Cache system info, e.g., the NT page size. */
51extern void cache_system_info (void);
52
53#endif /* W32COMMON_H */
diff --git a/src/w32console.c b/src/w32console.c
index b22b09af2f2..f0574689bf1 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -36,7 +36,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include "termhooks.h" 36#include "termhooks.h"
37#include "termchar.h" 37#include "termchar.h"
38#include "dispextern.h" 38#include "dispextern.h"
39#include "w32heap.h" /* for os_subtype */ 39#include "w32term.h"
40#include "w32common.h" /* for os_subtype */
40#include "w32inevt.h" 41#include "w32inevt.h"
41 42
42/* from window.c */ 43/* from window.c */
@@ -430,53 +431,6 @@ w32con_delete_glyphs (struct frame *f, int n)
430 scroll_line (f, n, LEFT); 431 scroll_line (f, n, LEFT);
431} 432}
432 433
433static unsigned int sound_type = 0xFFFFFFFF;
434#define MB_EMACS_SILENT (0xFFFFFFFF - 1)
435
436void
437w32_sys_ring_bell (struct frame *f)
438{
439 if (sound_type == 0xFFFFFFFF)
440 {
441 Beep (666, 100);
442 }
443 else if (sound_type == MB_EMACS_SILENT)
444 {
445 /* Do nothing. */
446 }
447 else
448 MessageBeep (sound_type);
449}
450
451DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
452 doc: /* Set the sound generated when the bell is rung.
453SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
454to use the corresponding system sound for the bell. The 'silent sound
455prevents Emacs from making any sound at all.
456SOUND is nil to use the normal beep. */)
457 (Lisp_Object sound)
458{
459 CHECK_SYMBOL (sound);
460
461 if (NILP (sound))
462 sound_type = 0xFFFFFFFF;
463 else if (EQ (sound, intern ("asterisk")))
464 sound_type = MB_ICONASTERISK;
465 else if (EQ (sound, intern ("exclamation")))
466 sound_type = MB_ICONEXCLAMATION;
467 else if (EQ (sound, intern ("hand")))
468 sound_type = MB_ICONHAND;
469 else if (EQ (sound, intern ("question")))
470 sound_type = MB_ICONQUESTION;
471 else if (EQ (sound, intern ("ok")))
472 sound_type = MB_OK;
473 else if (EQ (sound, intern ("silent")))
474 sound_type = MB_EMACS_SILENT;
475 else
476 sound_type = 0xFFFFFFFF;
477
478 return sound;
479}
480 434
481static void 435static void
482w32con_reset_terminal_modes (struct terminal *t) 436w32con_reset_terminal_modes (struct terminal *t)
@@ -850,5 +804,4 @@ scroll-back buffer. */);
850 defsubr (&Sset_screen_color); 804 defsubr (&Sset_screen_color);
851 defsubr (&Sget_screen_color); 805 defsubr (&Sget_screen_color);
852 defsubr (&Sset_cursor_size); 806 defsubr (&Sset_cursor_size);
853 defsubr (&Sset_message_beep);
854} 807}
diff --git a/src/w32fns.c b/src/w32fns.c
index 6d5d6822354..28a689ddc6c 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -44,8 +44,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "fontset.h" 44#include "fontset.h"
45#include "systime.h" 45#include "systime.h"
46#include "termhooks.h" 46#include "termhooks.h"
47
48#include "w32common.h"
49
50#ifdef WINDOWSNT
47#include "w32heap.h" 51#include "w32heap.h"
52#endif /* WINDOWSNT */
53
54#if CYGWIN
55#include "cygw32.h"
56#else
48#include "w32.h" 57#include "w32.h"
58#endif
49 59
50#include "bitmaps/gray.xbm" 60#include "bitmaps/gray.xbm"
51 61
@@ -58,9 +68,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58 68
59#include <dlgs.h> 69#include <dlgs.h>
60#include <imm.h> 70#include <imm.h>
61#define FILE_NAME_TEXT_FIELD edt1
62#define FILE_NAME_COMBO_BOX cmb13
63#define FILE_NAME_LIST lst1
64 71
65#include "font.h" 72#include "font.h"
66#include "w32font.h" 73#include "w32font.h"
@@ -78,6 +85,7 @@ extern int w32_console_toggle_lock_key (int, Lisp_Object);
78extern void w32_menu_display_help (HWND, HMENU, UINT, UINT); 85extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
79extern void w32_free_menu_strings (HWND); 86extern void w32_free_menu_strings (HWND);
80extern const char *map_w32_filename (const char *, const char **); 87extern const char *map_w32_filename (const char *, const char **);
88extern char * w32_strerror (int error_no);
81 89
82/* If non-NULL, a handle to a frame where to display the hourglass cursor. */ 90/* If non-NULL, a handle to a frame where to display the hourglass cursor. */
83static HWND hourglass_hwnd = NULL; 91static HWND hourglass_hwnd = NULL;
@@ -161,7 +169,11 @@ ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
161MonitorFromPoint_Proc monitor_from_point_fn = NULL; 169MonitorFromPoint_Proc monitor_from_point_fn = NULL;
162GetMonitorInfo_Proc get_monitor_info_fn = NULL; 170GetMonitorInfo_Proc get_monitor_info_fn = NULL;
163 171
172#ifdef NTGUI_UNICODE
173#define unicode_append_menu AppendMenuW
174#else /* !NTGUI_UNICODE */
164extern AppendMenuW_Proc unicode_append_menu; 175extern AppendMenuW_Proc unicode_append_menu;
176#endif /* NTGUI_UNICODE */
165 177
166/* Flag to selectively ignore WM_IME_CHAR messages. */ 178/* Flag to selectively ignore WM_IME_CHAR messages. */
167static int ignore_ime_char = 0; 179static int ignore_ime_char = 0;
@@ -198,6 +210,33 @@ extern int uniscribe_available;
198static void w32_show_hourglass (struct frame *); 210static void w32_show_hourglass (struct frame *);
199static void w32_hide_hourglass (void); 211static void w32_hide_hourglass (void);
200 212
213#ifdef WINDOWSNT
214/* From w32inevet.c */
215extern int faked_key;
216#endif /* WINDOWSNT */
217
218/* This gives us the page size and the size of the allocation unit on NT. */
219SYSTEM_INFO sysinfo_cache;
220
221/* This gives us version, build, and platform identification. */
222OSVERSIONINFO osinfo_cache;
223
224unsigned long syspage_mask = 0;
225
226/* The major and minor versions of NT. */
227int w32_major_version;
228int w32_minor_version;
229int w32_build_number;
230
231/* Distinguish between Windows NT and Windows 95. */
232int os_subtype;
233
234#ifdef HAVE_NTGUI
235HINSTANCE hinst = NULL;
236#endif
237
238static unsigned int sound_type = 0xFFFFFFFF;
239#define MB_EMACS_SILENT (0xFFFFFFFF - 1)
201 240
202 241
203/* Error if we are not connected to MS-Windows. */ 242/* Error if we are not connected to MS-Windows. */
@@ -662,7 +701,7 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
662} 701}
663 702
664static Lisp_Object 703static Lisp_Object
665w32_color_map_lookup (char *colorname) 704w32_color_map_lookup (const char *colorname)
666{ 705{
667 Lisp_Object tail, ret = Qnil; 706 Lisp_Object tail, ret = Qnil;
668 707
@@ -741,7 +780,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
741 780
742 781
743static Lisp_Object 782static Lisp_Object
744x_to_w32_color (char * colorname) 783x_to_w32_color (const char * colorname)
745{ 784{
746 register Lisp_Object ret = Qnil; 785 register Lisp_Object ret = Qnil;
747 786
@@ -750,11 +789,10 @@ x_to_w32_color (char * colorname)
750 if (colorname[0] == '#') 789 if (colorname[0] == '#')
751 { 790 {
752 /* Could be an old-style RGB Device specification. */ 791 /* Could be an old-style RGB Device specification. */
753 char *color; 792 int size = strlen (colorname + 1);
754 int size; 793 char *color = alloca (size + 1);
755 color = colorname + 1;
756 794
757 size = strlen (color); 795 strcpy (color, colorname + 1);
758 if (size == 3 || size == 6 || size == 9 || size == 12) 796 if (size == 3 || size == 6 || size == 9 || size == 12)
759 { 797 {
760 UINT colorval; 798 UINT colorval;
@@ -808,7 +846,7 @@ x_to_w32_color (char * colorname)
808 } 846 }
809 else if (strnicmp (colorname, "rgb:", 4) == 0) 847 else if (strnicmp (colorname, "rgb:", 4) == 0)
810 { 848 {
811 char *color; 849 const char *color;
812 UINT colorval; 850 UINT colorval;
813 int i, pos; 851 int i, pos;
814 pos = 0; 852 pos = 0;
@@ -864,7 +902,7 @@ x_to_w32_color (char * colorname)
864 else if (strnicmp (colorname, "rgbi:", 5) == 0) 902 else if (strnicmp (colorname, "rgbi:", 5) == 0)
865 { 903 {
866 /* This is an RGB Intensity specification. */ 904 /* This is an RGB Intensity specification. */
867 char *color; 905 const char *color;
868 UINT colorval; 906 UINT colorval;
869 int i, pos; 907 int i, pos;
870 pos = 0; 908 pos = 0;
@@ -1068,7 +1106,7 @@ gamma_correct (struct frame *f, COLORREF *color)
1068 If ALLOC is nonzero, allocate a new colormap cell. */ 1106 If ALLOC is nonzero, allocate a new colormap cell. */
1069 1107
1070int 1108int
1071w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc) 1109w32_defined_color (FRAME_PTR f, const char *color, XColor *color_def, int alloc)
1072{ 1110{
1073 register Lisp_Object tem; 1111 register Lisp_Object tem;
1074 COLORREF w32_color_ref; 1112 COLORREF w32_color_ref;
@@ -1843,10 +1881,7 @@ w32_createwindow (struct frame *f)
1843 1881
1844 /* Do first time app init */ 1882 /* Do first time app init */
1845 1883
1846 if (!hprevinst) 1884 w32_init_class (hinst);
1847 {
1848 w32_init_class (hinst);
1849 }
1850 1885
1851 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition) 1886 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition)
1852 { 1887 {
@@ -2246,6 +2281,84 @@ unregister_hot_keys (HWND hwnd)
2246 } 2281 }
2247} 2282}
2248 2283
2284#if EMACSDEBUG
2285const char*
2286w32_name_of_message (UINT msg)
2287{
2288 unsigned i;
2289 static char buf[64];
2290 static const struct {
2291 UINT msg;
2292 const char* name;
2293 } msgnames[] = {
2294#define M(msg) { msg, # msg }
2295 M (WM_PAINT),
2296 M (WM_TIMER),
2297 M (WM_USER),
2298 M (WM_MOUSEMOVE),
2299 M (WM_LBUTTONUP),
2300 M (WM_KEYDOWN),
2301 M (WM_EMACS_KILL),
2302 M (WM_EMACS_CREATEWINDOW),
2303 M (WM_EMACS_DONE),
2304 M (WM_EMACS_CREATESCROLLBAR),
2305 M (WM_EMACS_SHOWWINDOW),
2306 M (WM_EMACS_SETWINDOWPOS),
2307 M (WM_EMACS_DESTROYWINDOW),
2308 M (WM_EMACS_TRACKPOPUPMENU),
2309 M (WM_EMACS_SETFOCUS),
2310 M (WM_EMACS_SETFOREGROUND),
2311 M (WM_EMACS_SETLOCALE),
2312 M (WM_EMACS_SETKEYBOARDLAYOUT),
2313 M (WM_EMACS_REGISTER_HOT_KEY),
2314 M (WM_EMACS_UNREGISTER_HOT_KEY),
2315 M (WM_EMACS_TOGGLE_LOCK_KEY),
2316 M (WM_EMACS_TRACK_CARET),
2317 M (WM_EMACS_DESTROY_CARET),
2318 M (WM_EMACS_SHOW_CARET),
2319 M (WM_EMACS_HIDE_CARET),
2320 M (WM_EMACS_SETCURSOR),
2321 M (WM_EMACS_PAINT),
2322 M (WM_CHAR),
2323#undef M
2324 { 0, 0 }
2325 };
2326
2327 for (i = 0; msgnames[i].name; ++i)
2328 if (msgnames[i].msg == msg)
2329 return msgnames[i].name;
2330
2331 sprintf (buf, "message 0x%04x", (unsigned)msg);
2332 return buf;
2333}
2334#endif /* EMACSDEBUG */
2335
2336/* Here's an overview of how Emacs input works on MS-Windows.
2337
2338 System messages are read and processed by w32_msg_pump below. This
2339 function runs in a separate thread. It handles a small number of
2340 custom WM_EMACS_* messages (posted by the main thread, look for
2341 PostMessage calls), and dispatches the rest to w32_wnd_proc, which
2342 is the main window procedure for the entire Emacs application.
2343
2344 w32_wnd_proc also runs in the same separate input thread. It
2345 handles some messages, mostly those that need GDI calls, by itself.
2346 For the others, it calls my_post_msg, which inserts the messages
2347 into the input queue serviced by w32_read_socket.
2348
2349 w32_read_socket runs in the main (a.k.a. "Lisp") thread, and is
2350 called synchronously from keyboard.c when it is known or suspected
2351 that some input is available. w32_read_socket either handles
2352 messages immediately, or converts them into Emacs input events and
2353 stuffs them into kbd_buffer, where kbd_buffer_get_event can get at
2354 them and process them when read_char and its callers require
2355 input.
2356
2357 Under Cygwin with the W32 toolkit, the use of /dev/windows with
2358 select(2) takes the place of w32_read_socket.
2359
2360 */
2361
2249/* Main message dispatch loop. */ 2362/* Main message dispatch loop. */
2250 2363
2251static void 2364static void
@@ -2259,6 +2372,10 @@ w32_msg_pump (deferred_msg * msg_buf)
2259 2372
2260 while ((w32_unicode_gui ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0)) 2373 while ((w32_unicode_gui ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0))
2261 { 2374 {
2375
2376 /* DebPrint (("w32_msg_pump: %s time:%u\n", */
2377 /* w32_name_of_message (msg.message), msg.time)); */
2378
2262 if (msg.hwnd == NULL) 2379 if (msg.hwnd == NULL)
2263 { 2380 {
2264 switch (msg.message) 2381 switch (msg.message)
@@ -2346,7 +2463,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2346 /* Broadcast messages make it here, so you need to be looking 2463 /* Broadcast messages make it here, so you need to be looking
2347 for something in particular for this to be useful. */ 2464 for something in particular for this to be useful. */
2348 default: 2465 default:
2349 DebPrint (("msg %x not expected by w32_msg_pump\n", msg.message)); 2466 DebPrint (("msg %x not expected by w32_msg_pump\n", msg.message));
2350#endif 2467#endif
2351 } 2468 }
2352 } 2469 }
@@ -4525,22 +4642,14 @@ If omitted or nil, that stands for the selected frame's display. */)
4525 (Lisp_Object display) 4642 (Lisp_Object display)
4526{ 4643{
4527 struct w32_display_info *dpyinfo = check_x_display_info (display); 4644 struct w32_display_info *dpyinfo = check_x_display_info (display);
4528 HDC hdc;
4529 int cap; 4645 int cap;
4530 4646
4531 hdc = GetDC (dpyinfo->root_window); 4647 /* Don't use NCOLORS: it returns incorrect results under remote
4532 if (dpyinfo->has_palette) 4648 * desktop. We force 24+ bit depths to 24-bit, both to prevent an
4533 cap = GetDeviceCaps (hdc, SIZEPALETTE); 4649 * overflow and because probably is more meaningful on Windows
4534 else 4650 * anyway. */
4535 cap = GetDeviceCaps (hdc, NUMCOLORS);
4536
4537 /* We force 24+ bit depths to 24-bit, both to prevent an overflow
4538 and because probably is more meaningful on Windows anyway */
4539 if (cap < 0)
4540 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24);
4541
4542 ReleaseDC (dpyinfo->root_window, hdc);
4543 4651
4652 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24);
4544 return make_number (cap); 4653 return make_number (cap);
4545} 4654}
4546 4655
@@ -4682,6 +4791,37 @@ If omitted or nil, that stands for the selected frame's display. */)
4682{ 4791{
4683 return Qnil; 4792 return Qnil;
4684} 4793}
4794
4795DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
4796 doc: /* Set the sound generated when the bell is rung.
4797SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
4798to use the corresponding system sound for the bell. The 'silent sound
4799prevents Emacs from making any sound at all.
4800SOUND is nil to use the normal beep. */)
4801 (Lisp_Object sound)
4802{
4803 CHECK_SYMBOL (sound);
4804
4805 if (NILP (sound))
4806 sound_type = 0xFFFFFFFF;
4807 else if (EQ (sound, intern ("asterisk")))
4808 sound_type = MB_ICONASTERISK;
4809 else if (EQ (sound, intern ("exclamation")))
4810 sound_type = MB_ICONEXCLAMATION;
4811 else if (EQ (sound, intern ("hand")))
4812 sound_type = MB_ICONHAND;
4813 else if (EQ (sound, intern ("question")))
4814 sound_type = MB_ICONQUESTION;
4815 else if (EQ (sound, intern ("ok")))
4816 sound_type = MB_OK;
4817 else if (EQ (sound, intern ("silent")))
4818 sound_type = MB_EMACS_SILENT;
4819 else
4820 sound_type = 0xFFFFFFFF;
4821
4822 return sound;
4823}
4824
4685 4825
4686int 4826int
4687x_pixel_width (register struct frame *f) 4827x_pixel_width (register struct frame *f)
@@ -4763,12 +4903,21 @@ terminate Emacs if we can't open the connection.
4763 unsigned char *xrm_option; 4903 unsigned char *xrm_option;
4764 struct w32_display_info *dpyinfo; 4904 struct w32_display_info *dpyinfo;
4765 4905
4906 CHECK_STRING (display);
4907
4908 /* Signal an error in order to encourage correct use from callers.
4909 * If we ever support multiple window systems in the same Emacs,
4910 * we'll need callers to be precise about what window system they
4911 * want. */
4912
4913 if (strcmp (SSDATA (display), "w32") != 0)
4914 error ("The name of the display in this Emacs must be \"w32\"");
4915
4766 /* If initialization has already been done, return now to avoid 4916 /* If initialization has already been done, return now to avoid
4767 overwriting critical parts of one_w32_display_info. */ 4917 overwriting critical parts of one_w32_display_info. */
4768 if (w32_in_use) 4918 if (w32_in_use)
4769 return Qnil; 4919 return Qnil;
4770 4920
4771 CHECK_STRING (display);
4772 if (! NILP (xrm_string)) 4921 if (! NILP (xrm_string))
4773 CHECK_STRING (xrm_string); 4922 CHECK_STRING (xrm_string);
4774 4923
@@ -5839,6 +5988,18 @@ Value is t if tooltip was open, nil otherwise. */)
5839 File selection dialog 5988 File selection dialog
5840 ***********************************************************************/ 5989 ***********************************************************************/
5841 5990
5991#define FILE_NAME_TEXT_FIELD edt1
5992#define FILE_NAME_COMBO_BOX cmb13
5993#define FILE_NAME_LIST lst1
5994
5995#ifdef NTGUI_UNICODE
5996#define GUISTR(x) (L ## x)
5997typedef wchar_t guichar_t;
5998#else /* !NTGUI_UNICODE */
5999#define GUISTR(x) x
6000typedef char guichar_t;
6001#endif /* NTGUI_UNICODE */
6002
5842/* Callback for altering the behavior of the Open File dialog. 6003/* Callback for altering the behavior of the Open File dialog.
5843 Makes the Filename text field contain "Current Directory" and be 6004 Makes the Filename text field contain "Current Directory" and be
5844 read-only when "Directories" is selected in the filter. This 6005 read-only when "Directories" is selected in the filter. This
@@ -5849,7 +6010,11 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5849{ 6010{
5850 if (msg == WM_NOTIFY) 6011 if (msg == WM_NOTIFY)
5851 { 6012 {
5852 OFNOTIFY * notify = (OFNOTIFY *)lParam; 6013#ifdef NTGUI_UNICODE
6014 OFNOTIFYW * notify = (OFNOTIFYW *)lParam;
6015#else /* !NTGUI_UNICODE */
6016 OFNOTIFYA * notify = (OFNOTIFYA *)lParam;
6017#endif /* NTGUI_UNICODE */
5853 /* Detect when the Filter dropdown is changed. */ 6018 /* Detect when the Filter dropdown is changed. */
5854 if (notify->hdr.code == CDN_TYPECHANGE 6019 if (notify->hdr.code == CDN_TYPECHANGE
5855 || notify->hdr.code == CDN_INITDONE) 6020 || notify->hdr.code == CDN_INITDONE)
@@ -5877,7 +6042,7 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5877 if (notify->lpOFN->nFilterIndex == 2) 6042 if (notify->lpOFN->nFilterIndex == 2)
5878 { 6043 {
5879 CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD, 6044 CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
5880 "Current Directory"); 6045 GUISTR ("Current Directory"));
5881 EnableWindow (edit_control, FALSE); 6046 EnableWindow (edit_control, FALSE);
5882 /* Note that at least on Windows 7, the above call to EnableWindow 6047 /* Note that at least on Windows 7, the above call to EnableWindow
5883 disables the window that would ordinarily have focus. If we 6048 disables the window that would ordinarily have focus. If we
@@ -5893,7 +6058,8 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5893 /* Don't override default filename on init done. */ 6058 /* Don't override default filename on init done. */
5894 if (notify->hdr.code == CDN_TYPECHANGE) 6059 if (notify->hdr.code == CDN_TYPECHANGE)
5895 CommDlg_OpenSave_SetControlText (dialog, 6060 CommDlg_OpenSave_SetControlText (dialog,
5896 FILE_NAME_TEXT_FIELD, ""); 6061 FILE_NAME_TEXT_FIELD,
6062 GUISTR (""));
5897 EnableWindow (edit_control, TRUE); 6063 EnableWindow (edit_control, TRUE);
5898 } 6064 }
5899 } 6065 }
@@ -5901,19 +6067,6 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5901 return 0; 6067 return 0;
5902} 6068}
5903 6069
5904/* Since we compile with _WIN32_WINNT set to 0x0400 (for NT4 compatibility)
5905 we end up with the old file dialogs. Define a big enough struct for the
5906 new dialog to trick GetOpenFileName into giving us the new dialogs on
5907 Windows 2000 and XP. */
5908typedef struct
5909{
5910 OPENFILENAME real_details;
5911 void * pReserved;
5912 DWORD dwReserved;
5913 DWORD FlagsEx;
5914} NEWOPENFILENAME;
5915
5916
5917DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, 6070DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
5918 doc: /* Read file name, prompting with PROMPT in directory DIR. 6071 doc: /* Read file name, prompting with PROMPT in directory DIR.
5919Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file 6072Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
@@ -5925,134 +6078,205 @@ Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
5925Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) 6078Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5926 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) 6079 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
5927{ 6080{
6081 /* Filter index: 1: All Files, 2: Directories only */
6082 static const guichar_t filter[] =
6083 GUISTR ("All Files (*.*)\0*.*\0Directories\0*|*\0");
6084
6085 Lisp_Object filename = default_filename;
5928 struct frame *f = SELECTED_FRAME (); 6086 struct frame *f = SELECTED_FRAME ();
5929 Lisp_Object file = Qnil; 6087 BOOL file_opened = FALSE;
5930 ptrdiff_t count = SPECPDL_INDEX (); 6088 Lisp_Object orig_dir = dir;
6089 Lisp_Object orig_prompt = prompt;
6090
6091 /* If we compile with _WIN32_WINNT set to 0x0400 (for NT4
6092 compatibility) we end up with the old file dialogs. Define a big
6093 enough struct for the new dialog to trick GetOpenFileName into
6094 giving us the new dialogs on newer versions of Windows. */
6095 struct {
6096#ifdef NTGUI_UNICODE
6097 OPENFILENAMEW details;
6098#else /* !NTGUI_UNICODE */
6099 OPENFILENAMEA details;
6100#endif /* NTGUI_UNICODE */
6101
6102#if _WIN32_WINNT < 0x500 /* < win2k */
6103 PVOID pvReserved;
6104 DWORD dwReserved;
6105 DWORD FlagsEx;
6106#endif /* < win2k */
6107 } new_file_details;
6108
6109#ifdef NTGUI_UNICODE
6110 wchar_t filename_buf[32*1024 + 1]; // NT kernel maximum
6111 OPENFILENAMEW * file_details = &new_file_details.details;
6112#else /* not NTGUI_UNICODE */
6113 char filename_buf[MAX_PATH + 1];
6114 OPENFILENAMEA * file_details = &new_file_details.details;
6115#endif /* NTGUI_UNICODE */
6116
5931 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 6117 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5932 char filename[MAX_PATH + 1]; 6118 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, filename);
5933 char init_dir[MAX_PATH + 1];
5934 int default_filter_index = 1; /* 1: All Files, 2: Directories only */
5935
5936 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5937 CHECK_STRING (prompt);
5938 CHECK_STRING (dir);
5939
5940 /* Create the dialog with PROMPT as title, using DIR as initial
5941 directory and using "*" as pattern. */
5942 dir = Fexpand_file_name (dir, Qnil);
5943 strncpy (init_dir, SDATA (ENCODE_FILE (dir)), MAX_PATH);
5944 init_dir[MAX_PATH] = '\0';
5945 unixtodos_filename (init_dir);
5946
5947 if (STRINGP (default_filename))
5948 {
5949 char *file_name_only;
5950 char *full_path_name = SDATA (ENCODE_FILE (default_filename));
5951 6119
5952 unixtodos_filename (full_path_name); 6120 {
6121 struct gcpro gcpro1, gcpro2;
6122 GCPRO2 (orig_dir, orig_prompt); /* There is no GCPRON, N>6. */
5953 6123
5954 file_name_only = strrchr (full_path_name, '\\'); 6124 /* Note: under NTGUI_UNICODE, we do _NOT_ use ENCODE_FILE: the
5955 if (!file_name_only) 6125 system file encoding expected by the platform APIs (e.g. Cygwin's
5956 file_name_only = full_path_name; 6126 POSIX implementation) may not be the same as the encoding expected
5957 else 6127 by the Windows "ANSI" APIs! */
5958 file_name_only++;
5959 6128
5960 strncpy (filename, file_name_only, MAX_PATH); 6129 CHECK_STRING (prompt);
5961 filename[MAX_PATH] = '\0'; 6130 CHECK_STRING (dir);
5962 }
5963 else
5964 filename[0] = '\0';
5965 6131
5966 /* The code in file_dialog_callback that attempts to set the text 6132 dir = Fexpand_file_name (dir, Qnil);
5967 of the file name edit window when handling the CDN_INITDONE
5968 WM_NOTIFY message does not work. Setting filename to "Current
5969 Directory" in the only_dir_p case here does work however. */
5970 if (filename[0] == 0 && ! NILP (only_dir_p))
5971 strcpy (filename, "Current Directory");
5972 6133
5973 { 6134 if (STRINGP (filename))
5974 NEWOPENFILENAME new_file_details; 6135 filename = Ffile_name_nondirectory (filename);
5975 BOOL file_opened = FALSE; 6136 else
5976 OPENFILENAME * file_details = &new_file_details.real_details; 6137 filename = empty_unibyte_string;
5977 6138
5978 /* Prevent redisplay. */ 6139#ifdef CYGWIN
5979 specbind (Qinhibit_redisplay, Qt); 6140 dir = Fcygwin_convert_path_to_windows (dir, Qt);
5980 block_input (); 6141 if (SCHARS (filename) > 0)
6142 filename = Fcygwin_convert_path_to_windows (filename, Qnil);
6143#endif
5981 6144
6145 CHECK_STRING (dir);
6146 CHECK_STRING (filename);
6147
6148 /* The code in file_dialog_callback that attempts to set the text
6149 of the file name edit window when handling the CDN_INITDONE
6150 WM_NOTIFY message does not work. Setting filename to "Current
6151 Directory" in the only_dir_p case here does work however. */
6152 if (SCHARS (filename) == 0 && ! NILP (only_dir_p))
6153 filename = build_string ("Current Directory");
6154
6155 /* Convert the values we've computed so far to system form. */
6156#ifdef NTGUI_UNICODE
6157 to_unicode (prompt, &prompt);
6158 to_unicode (dir, &dir);
6159 to_unicode (filename, &filename);
6160#else /* !NTGUI_UNICODE */
6161 prompt = ENCODE_FILE (prompt);
6162 dir = ENCODE_FILE (dir);
6163 filename = ENCODE_FILE (filename);
6164
6165 /* We modify these in-place, so make copies for safety. */
6166 dir = Fcopy_sequence (dir);
6167 unixtodos_filename (SDATA (dir));
6168 filename = Fcopy_sequence (filename);
6169 unixtodos_filename (SDATA (filename));
6170#endif /* NTGUI_UNICODE */
6171
6172 /* Fill in the structure for the call to GetOpenFileName below.
6173 For NTGUI_UNICODE builds (which run only on NT), we just use
6174 the actual size of the structure. For non-NTGUI_UNICODE
6175 builds, we tell the OS we're using an old version of the
6176 structure if the OS isn't new enough to support the newer
6177 version. */
5982 memset (&new_file_details, 0, sizeof (new_file_details)); 6178 memset (&new_file_details, 0, sizeof (new_file_details));
5983 /* Apparently NT4 crashes if you give it an unexpected size. 6179
5984 I'm not sure about Windows 9x, so play it safe. */
5985 if (w32_major_version > 4 && w32_major_version < 95) 6180 if (w32_major_version > 4 && w32_major_version < 95)
5986 file_details->lStructSize = sizeof (NEWOPENFILENAME); 6181 file_details->lStructSize = sizeof (new_file_details);
5987 else 6182 else
5988 file_details->lStructSize = sizeof (OPENFILENAME); 6183 file_details->lStructSize = sizeof (*file_details);
6184
6185 /* Set up the inout parameter for the selected file name. */
6186 if (SBYTES (filename) + 1 > sizeof (filename_buf))
6187 report_file_error ("filename too long", default_filename);
6188
6189 memcpy (filename_buf, SDATA (filename), SBYTES (filename) + 1);
6190 file_details->lpstrFile = filename_buf;
6191 file_details->nMaxFile = sizeof (filename_buf) / sizeof (*filename_buf);
5989 6192
5990 file_details->hwndOwner = FRAME_W32_WINDOW (f); 6193 file_details->hwndOwner = FRAME_W32_WINDOW (f);
5991 /* Undocumented Bug in Common File Dialog: 6194 /* Undocumented Bug in Common File Dialog:
5992 If a filter is not specified, shell links are not resolved. */ 6195 If a filter is not specified, shell links are not resolved. */
5993 file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0"; 6196 file_details->lpstrFilter = filter;
5994 file_details->lpstrFile = filename; 6197 file_details->lpstrInitialDir = (guichar_t*) SDATA (dir);
5995 file_details->nMaxFile = sizeof (filename); 6198 file_details->lpstrTitle = (guichar_t*) SDATA (prompt);
5996 file_details->lpstrInitialDir = init_dir; 6199 file_details->nFilterIndex = NILP (only_dir_p) ? 1 : 2;
5997 file_details->lpstrTitle = SDATA (prompt);
5998
5999 if (! NILP (only_dir_p))
6000 default_filter_index = 2;
6001
6002 file_details->nFilterIndex = default_filter_index;
6003
6004 file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR 6200 file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR
6005 | OFN_EXPLORER | OFN_ENABLEHOOK); 6201 | OFN_EXPLORER | OFN_ENABLEHOOK);
6202
6006 if (!NILP (mustmatch)) 6203 if (!NILP (mustmatch))
6007 { 6204 {
6008 /* Require that the path to the parent directory exists. */ 6205 /* Require that the path to the parent directory exists. */
6009 file_details->Flags |= OFN_PATHMUSTEXIST; 6206 file_details->Flags |= OFN_PATHMUSTEXIST;
6010 /* If we are looking for a file, require that it exists. */ 6207 /* If we are looking for a file, require that it exists. */
6011 if (NILP (only_dir_p)) 6208 if (NILP (only_dir_p))
6012 file_details->Flags |= OFN_FILEMUSTEXIST; 6209 file_details->Flags |= OFN_FILEMUSTEXIST;
6013 } 6210 }
6014 6211
6015 file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback; 6212 {
6016 6213 int count = SPECPDL_INDEX ();
6017 file_opened = GetOpenFileName (file_details); 6214 /* Prevent redisplay. */
6215 specbind (Qinhibit_redisplay, Qt);
6216 block_input ();
6217 file_details->lpfnHook = file_dialog_callback;
6018 6218
6019 unblock_input (); 6219#ifdef NTGUI_UNICODE
6220 file_opened = GetOpenFileNameW (file_details);
6221#else /* !NTGUI_UNICODE */
6222 file_opened = GetOpenFileNameA (file_details);
6223#endif /* NTGUI_UNICODE */
6224 unblock_input ();
6225 unbind_to (count, Qnil);
6226 }
6020 6227
6021 if (file_opened) 6228 if (file_opened)
6022 { 6229 {
6023 dostounix_filename (filename); 6230 /* Get an Emacs string from the value Windows gave us. */
6024 6231#ifdef NTGUI_UNICODE
6025 if (file_details->nFilterIndex == 2) 6232 filename = from_unicode (
6026 { 6233 make_unibyte_string (
6027 /* "Directories" selected - strip dummy file name. */ 6234 (char*) filename_buf,
6028 char * last = strrchr (filename, '/'); 6235 /* we get one of the two final 0 bytes for free. */
6029 *last = '\0'; 6236 1 + sizeof (wchar_t) * wcslen (filename_buf)));
6030 } 6237#else /* !NTGUI_UNICODE */
6031 6238 dostounix_filename (filename_buf);
6032 file = DECODE_FILE (build_string (filename)); 6239 filename = DECODE_FILE (build_string (filename_buf));
6240#endif /* NTGUI_UNICODE */
6241
6242#ifdef CYGWIN
6243 filename = Fcygwin_convert_path_from_windows (filename, Qt);
6244#endif /* CYGWIN */
6245
6246 /* Strip the dummy filename off the end of the string if we
6247 added it to select a directory. */
6248 if (file_details->nFilterIndex == 2)
6249 {
6250 filename = Ffile_name_directory (filename);
6251 }
6033 } 6252 }
6034 /* User canceled the dialog without making a selection. */ 6253 /* User canceled the dialog without making a selection. */
6035 else if (!CommDlgExtendedError ()) 6254 else if (!CommDlgExtendedError ())
6036 file = Qnil; 6255 filename = Qnil;
6037 /* An error occurred, fallback on reading from the mini-buffer. */ 6256 /* An error occurred, fallback on reading from the mini-buffer. */
6038 else 6257 else
6039 file = Fcompleting_read (prompt, intern ("read-file-name-internal"), 6258 filename = Fcompleting_read (
6040 dir, mustmatch, dir, Qfile_name_history, 6259 orig_prompt,
6041 default_filename, Qnil); 6260 intern ("read-file-name-internal"),
6261 orig_dir,
6262 mustmatch,
6263 orig_dir,
6264 Qfile_name_history,
6265 default_filename,
6266 Qnil);
6042 6267
6043 file = unbind_to (count, file); 6268 UNGCPRO;
6044 } 6269 }
6045 6270
6046 UNGCPRO;
6047
6048 /* Make "Cancel" equivalent to C-g. */ 6271 /* Make "Cancel" equivalent to C-g. */
6049 if (NILP (file)) 6272 if (NILP (filename))
6050 Fsignal (Qquit, Qnil); 6273 Fsignal (Qquit, Qnil);
6051 6274
6052 return unbind_to (count, file); 6275 RETURN_UNGCPRO (filename);
6053} 6276}
6054 6277
6055 6278
6279#ifdef WINDOWSNT
6056/* Moving files to the system recycle bin. 6280/* Moving files to the system recycle bin.
6057 Used by `move-file-to-trash' instead of the default moving to ~/.Trash */ 6281 Used by `move-file-to-trash' instead of the default moving to ~/.Trash */
6058DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash, 6282DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
@@ -6106,6 +6330,8 @@ DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
6106 return Qnil; 6330 return Qnil;
6107} 6331}
6108 6332
6333#endif /* WINDOWSNT */
6334
6109 6335
6110/*********************************************************************** 6336/***********************************************************************
6111 w32 specialized functions 6337 w32 specialized functions
@@ -6523,7 +6749,7 @@ The following %-sequences are provided:
6523 else 6749 else
6524 { 6750 {
6525 char buffer[16]; 6751 char buffer[16];
6526 _snprintf (buffer, 16, "%d", system_status.BatteryLifePercent); 6752 snprintf (buffer, 16, "%d", system_status.BatteryLifePercent);
6527 load_percentage = build_string (buffer); 6753 load_percentage = build_string (buffer);
6528 } 6754 }
6529 6755
@@ -6534,18 +6760,18 @@ The following %-sequences are provided:
6534 long m; 6760 long m;
6535 float h; 6761 float h;
6536 char buffer[16]; 6762 char buffer[16];
6537 _snprintf (buffer, 16, "%ld", seconds_left); 6763 snprintf (buffer, 16, "%ld", seconds_left);
6538 seconds = build_string (buffer); 6764 seconds = build_string (buffer);
6539 6765
6540 m = seconds_left / 60; 6766 m = seconds_left / 60;
6541 _snprintf (buffer, 16, "%ld", m); 6767 snprintf (buffer, 16, "%ld", m);
6542 minutes = build_string (buffer); 6768 minutes = build_string (buffer);
6543 6769
6544 h = seconds_left / 3600.0; 6770 h = seconds_left / 3600.0;
6545 _snprintf (buffer, 16, "%3.1f", h); 6771 snprintf (buffer, 16, "%3.1f", h);
6546 hours = build_string (buffer); 6772 hours = build_string (buffer);
6547 6773
6548 _snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60); 6774 snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60);
6549 remain = build_string (buffer); 6775 remain = build_string (buffer);
6550 } 6776 }
6551 6777
@@ -6707,10 +6933,10 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6707 { 6933 {
6708 /* a remote printer */ 6934 /* a remote printer */
6709 if (*ppi2->pServerName == '\\') 6935 if (*ppi2->pServerName == '\\')
6710 _snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, 6936 snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName,
6711 ppi2->pShareName); 6937 ppi2->pShareName);
6712 else 6938 else
6713 _snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, 6939 snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName,
6714 ppi2->pShareName); 6940 ppi2->pShareName);
6715 pname_buf[sizeof (pname_buf) - 1] = '\0'; 6941 pname_buf[sizeof (pname_buf) - 1] = '\0';
6716 } 6942 }
@@ -6729,6 +6955,294 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6729 return build_string (pname_buf); 6955 return build_string (pname_buf);
6730} 6956}
6731 6957
6958
6959/* Equivalent of strerror for W32 error codes. */
6960char *
6961w32_strerror (int error_no)
6962{
6963 static char buf[500];
6964 DWORD ret;
6965
6966 if (error_no == 0)
6967 error_no = GetLastError ();
6968
6969 ret = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
6970 FORMAT_MESSAGE_IGNORE_INSERTS,
6971 NULL,
6972 error_no,
6973 0, /* choose most suitable language */
6974 buf, sizeof (buf), NULL);
6975
6976 while (ret > 0 && (buf[ret - 1] == '\n' ||
6977 buf[ret - 1] == '\r' ))
6978 --ret;
6979 buf[ret] = '\0';
6980 if (!ret)
6981 sprintf (buf, "w32 error %u", error_no);
6982
6983 return buf;
6984}
6985
6986/* For convenience when debugging. (You cannot call GetLastError
6987 directly from GDB: it will crash, because it uses the __stdcall
6988 calling convention, not the _cdecl convention assumed by GDB.) */
6989DWORD
6990w32_last_error (void)
6991{
6992 return GetLastError ();
6993}
6994
6995/* Cache information describing the NT system for later use. */
6996void
6997cache_system_info (void)
6998{
6999 union
7000 {
7001 struct info
7002 {
7003 char major;
7004 char minor;
7005 short platform;
7006 } info;
7007 DWORD data;
7008 } version;
7009
7010 /* Cache the version of the operating system. */
7011 version.data = GetVersion ();
7012 w32_major_version = version.info.major;
7013 w32_minor_version = version.info.minor;
7014
7015 if (version.info.platform & 0x8000)
7016 os_subtype = OS_9X;
7017 else
7018 os_subtype = OS_NT;
7019
7020 /* Cache page size, allocation unit, processor type, etc. */
7021 GetSystemInfo (&sysinfo_cache);
7022 syspage_mask = sysinfo_cache.dwPageSize - 1;
7023
7024 /* Cache os info. */
7025 osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
7026 GetVersionEx (&osinfo_cache);
7027
7028 w32_build_number = osinfo_cache.dwBuildNumber;
7029 if (os_subtype == OS_9X)
7030 w32_build_number &= 0xffff;
7031
7032 w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
7033}
7034
7035#ifdef EMACSDEBUG
7036void
7037_DebPrint (const char *fmt, ...)
7038{
7039 char buf[1024];
7040 va_list args;
7041
7042 va_start (args, fmt);
7043 vsprintf (buf, fmt, args);
7044 va_end (args);
7045#if CYGWIN
7046 fprintf (stderr, "%s", buf);
7047#endif
7048 OutputDebugString (buf);
7049}
7050#endif
7051
7052int
7053w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
7054{
7055 int cur_state = (GetKeyState (vk_code) & 1);
7056
7057 if (NILP (new_state)
7058 || (NUMBERP (new_state)
7059 && ((XUINT (new_state)) & 1) != cur_state))
7060 {
7061#ifdef WINDOWSNT
7062 faked_key = vk_code;
7063#endif /* WINDOWSNT */
7064
7065 keybd_event ((BYTE) vk_code,
7066 (BYTE) MapVirtualKey (vk_code, 0),
7067 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
7068 keybd_event ((BYTE) vk_code,
7069 (BYTE) MapVirtualKey (vk_code, 0),
7070 KEYEVENTF_EXTENDEDKEY | 0, 0);
7071 keybd_event ((BYTE) vk_code,
7072 (BYTE) MapVirtualKey (vk_code, 0),
7073 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
7074 cur_state = !cur_state;
7075 }
7076
7077 return cur_state;
7078}
7079
7080/* Translate console modifiers to emacs modifiers.
7081 German keyboard support (Kai Morgan Zeise 2/18/95). */
7082int
7083w32_kbd_mods_to_emacs (DWORD mods, WORD key)
7084{
7085 int retval = 0;
7086
7087 /* If we recognize right-alt and left-ctrl as AltGr, and it has been
7088 pressed, first remove those modifiers. */
7089 if (!NILP (Vw32_recognize_altgr)
7090 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
7091 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
7092 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED);
7093
7094 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))
7095 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier);
7096
7097 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7098 {
7099 retval |= ctrl_modifier;
7100 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7101 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7102 retval |= meta_modifier;
7103 }
7104
7105 if (mods & LEFT_WIN_PRESSED)
7106 retval |= w32_key_to_modifier (VK_LWIN);
7107 if (mods & RIGHT_WIN_PRESSED)
7108 retval |= w32_key_to_modifier (VK_RWIN);
7109 if (mods & APPS_PRESSED)
7110 retval |= w32_key_to_modifier (VK_APPS);
7111 if (mods & SCROLLLOCK_ON)
7112 retval |= w32_key_to_modifier (VK_SCROLL);
7113
7114 /* Just in case someone wanted the original behavior, make it
7115 optional by setting w32-capslock-is-shiftlock to t. */
7116 if (NILP (Vw32_capslock_is_shiftlock)
7117 /* Keys that should _not_ be affected by CapsLock. */
7118 && ( (key == VK_BACK)
7119 || (key == VK_TAB)
7120 || (key == VK_CLEAR)
7121 || (key == VK_RETURN)
7122 || (key == VK_ESCAPE)
7123 || ((key >= VK_SPACE) && (key <= VK_HELP))
7124 || ((key >= VK_NUMPAD0) && (key <= VK_F24))
7125 || ((key >= VK_NUMPAD_CLEAR) && (key <= VK_NUMPAD_DELETE))
7126 ))
7127 {
7128 /* Only consider shift state. */
7129 if ((mods & SHIFT_PRESSED) != 0)
7130 retval |= shift_modifier;
7131 }
7132 else
7133 {
7134 /* Ignore CapsLock state if not enabled. */
7135 if (NILP (Vw32_enable_caps_lock))
7136 mods &= ~CAPSLOCK_ON;
7137 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0)
7138 retval |= shift_modifier;
7139 }
7140
7141 return retval;
7142}
7143
7144/* The return code indicates key code size. cpID is the codepage to
7145 use for translation to Unicode; -1 means use the current console
7146 input codepage. */
7147int
7148w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
7149{
7150 unsigned int key_code = event->wVirtualKeyCode;
7151 unsigned int mods = event->dwControlKeyState;
7152 BYTE keystate[256];
7153 static BYTE ansi_code[4];
7154 static int isdead = 0;
7155
7156 if (isdead == 2)
7157 {
7158 event->uChar.AsciiChar = ansi_code[2];
7159 isdead = 0;
7160 return 1;
7161 }
7162 if (event->uChar.AsciiChar != 0)
7163 return 1;
7164
7165 memset (keystate, 0, sizeof (keystate));
7166 keystate[key_code] = 0x80;
7167 if (mods & SHIFT_PRESSED)
7168 keystate[VK_SHIFT] = 0x80;
7169 if (mods & CAPSLOCK_ON)
7170 keystate[VK_CAPITAL] = 1;
7171 /* If we recognize right-alt and left-ctrl as AltGr, set the key
7172 states accordingly before invoking ToAscii. */
7173 if (!NILP (Vw32_recognize_altgr)
7174 && (mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED))
7175 {
7176 keystate[VK_CONTROL] = 0x80;
7177 keystate[VK_LCONTROL] = 0x80;
7178 keystate[VK_MENU] = 0x80;
7179 keystate[VK_RMENU] = 0x80;
7180 }
7181
7182#if 0
7183 /* Because of an OS bug, ToAscii corrupts the stack when called to
7184 convert a dead key in console mode on NT4. Unfortunately, trying
7185 to check for dead keys using MapVirtualKey doesn't work either -
7186 these functions apparently use internal information about keyboard
7187 layout which doesn't get properly updated in console programs when
7188 changing layout (though apparently it gets partly updated,
7189 otherwise ToAscii wouldn't crash). */
7190 if (is_dead_key (event->wVirtualKeyCode))
7191 return 0;
7192#endif
7193
7194 /* On NT, call ToUnicode instead and then convert to the current
7195 console input codepage. */
7196 if (os_subtype == OS_NT)
7197 {
7198 WCHAR buf[128];
7199
7200 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode,
7201 keystate, buf, 128, 0);
7202 if (isdead > 0)
7203 {
7204 /* When we are called from the GUI message processing code,
7205 we are passed the current keyboard codepage, a positive
7206 number, to use below. */
7207 if (cpId == -1)
7208 cpId = GetConsoleCP ();
7209
7210 event->uChar.UnicodeChar = buf[isdead - 1];
7211 isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
7212 ansi_code, 4, NULL, NULL);
7213 }
7214 else
7215 isdead = 0;
7216 }
7217 else
7218 {
7219 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode,
7220 keystate, (LPWORD) ansi_code, 0);
7221 }
7222
7223 if (isdead == 0)
7224 return 0;
7225 event->uChar.AsciiChar = ansi_code[0];
7226 return isdead;
7227}
7228
7229
7230void
7231w32_sys_ring_bell (struct frame *f)
7232{
7233 if (sound_type == 0xFFFFFFFF)
7234 {
7235 Beep (666, 100);
7236 }
7237 else if (sound_type == MB_EMACS_SILENT)
7238 {
7239 /* Do nothing. */
7240 }
7241 else
7242 MessageBeep (sound_type);
7243}
7244
7245
6732/*********************************************************************** 7246/***********************************************************************
6733 Initialization 7247 Initialization
6734 ***********************************************************************/ 7248 ***********************************************************************/
@@ -7095,6 +7609,7 @@ only be necessary if the default setting causes problems. */);
7095 7609
7096 defsubr (&Sfile_system_info); 7610 defsubr (&Sfile_system_info);
7097 defsubr (&Sdefault_printer_name); 7611 defsubr (&Sdefault_printer_name);
7612 defsubr (&Sset_message_beep);
7098 7613
7099 check_window_system_func = check_w32; 7614 check_window_system_func = check_w32;
7100 7615
@@ -7111,7 +7626,9 @@ only be necessary if the default setting causes problems. */);
7111 staticpro (&last_show_tip_args); 7626 staticpro (&last_show_tip_args);
7112 7627
7113 defsubr (&Sx_file_dialog); 7628 defsubr (&Sx_file_dialog);
7629#ifdef WINDOWSNT
7114 defsubr (&Ssystem_move_file_to_trash); 7630 defsubr (&Ssystem_move_file_to_trash);
7631#endif
7115} 7632}
7116 7633
7117 7634
@@ -7193,9 +7710,3 @@ emacs_abort (void)
7193 } 7710 }
7194} 7711}
7195 7712
7196/* For convenience when debugging. */
7197int
7198w32_last_error (void)
7199{
7200 return GetLastError ();
7201}
diff --git a/src/w32font.c b/src/w32font.c
index 833b7cdfb25..d7d25d89939 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -18,6 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <windows.h> 20#include <windows.h>
21#include <stdio.h>
21#include <math.h> 22#include <math.h>
22#include <ctype.h> 23#include <ctype.h>
23#include <commdlg.h> 24#include <commdlg.h>
@@ -1434,6 +1435,9 @@ w32font_coverage_ok (FONTSIGNATURE * coverage, BYTE charset)
1434 return 1; 1435 return 1;
1435} 1436}
1436 1437
1438#ifndef WINDOWSNT
1439#define _strlwr strlwr
1440#endif /* !WINDOWSNT */
1437 1441
1438static int 1442static int
1439check_face_name (LOGFONT *font, char *full_name) 1443check_face_name (LOGFONT *font, char *full_name)
diff --git a/src/w32heap.c b/src/w32heap.c
index 8b9b19ea35d..311e1064434 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -23,65 +23,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25 25
26#include "w32common.h"
26#include "w32heap.h" 27#include "w32heap.h"
27#include "lisp.h" /* for VALMASK */ 28#include "lisp.h" /* for VALMASK */
28 29
29#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL))) 30#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
30 31
31/* This gives us the page size and the size of the allocation unit on NT. */
32SYSTEM_INFO sysinfo_cache;
33
34/* This gives us version, build, and platform identification. */
35OSVERSIONINFO osinfo_cache;
36
37size_t syspage_mask = 0;
38
39/* The major and minor versions of NT. */
40int w32_major_version;
41int w32_minor_version;
42int w32_build_number;
43
44/* Distinguish between Windows NT and Windows 95. */
45int os_subtype;
46
47/* Cache information describing the NT system for later use. */
48void
49cache_system_info (void)
50{
51 union
52 {
53 struct info
54 {
55 char major;
56 char minor;
57 short platform;
58 } info;
59 DWORD data;
60 } version;
61
62 /* Cache the version of the operating system. */
63 version.data = GetVersion ();
64 w32_major_version = version.info.major;
65 w32_minor_version = version.info.minor;
66
67 if (version.info.platform & 0x8000)
68 os_subtype = OS_9X;
69 else
70 os_subtype = OS_NT;
71
72 /* Cache page size, allocation unit, processor type, etc. */
73 GetSystemInfo (&sysinfo_cache);
74 syspage_mask = sysinfo_cache.dwPageSize - 1;
75
76 /* Cache os info. */
77 osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
78 GetVersionEx (&osinfo_cache);
79
80 w32_build_number = osinfo_cache.dwBuildNumber;
81 if (os_subtype == OS_9X)
82 w32_build_number &= 0xffff;
83}
84
85/* Emulate getpagesize. */ 32/* Emulate getpagesize. */
86int 33int
87getpagesize (void) 34getpagesize (void)
diff --git a/src/w32heap.h b/src/w32heap.h
index aae4845b4cc..1630864875f 100644
--- a/src/w32heap.h
+++ b/src/w32heap.h
@@ -24,9 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 24
25#include <windows.h> 25#include <windows.h>
26 26
27#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
28#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
29
30/* 27/*
31 * Heap related stuff. 28 * Heap related stuff.
32 */ 29 */
@@ -34,28 +31,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
34#define get_committed_heap_size() (get_data_end () - get_data_start ()) 31#define get_committed_heap_size() (get_data_end () - get_data_start ())
35#define get_heap_start() get_data_start () 32#define get_heap_start() get_data_start ()
36#define get_heap_end() get_data_end () 33#define get_heap_end() get_data_end ()
37#define get_page_size() sysinfo_cache.dwPageSize
38#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
39#define get_processor_type() sysinfo_cache.dwProcessorType
40#define get_w32_major_version() w32_major_version
41#define get_w32_minor_version() w32_minor_version
42 34
43extern unsigned char *get_data_start (void); 35extern unsigned char *get_data_start (void);
44extern unsigned char *get_data_end (void); 36extern unsigned char *get_data_end (void);
45extern size_t reserved_heap_size; 37extern size_t reserved_heap_size;
46extern SYSTEM_INFO sysinfo_cache;
47extern OSVERSIONINFO osinfo_cache;
48extern BOOL using_dynamic_heap; 38extern BOOL using_dynamic_heap;
49extern int w32_major_version;
50extern int w32_minor_version;
51extern int w32_build_number;
52
53enum {
54 OS_9X = 1,
55 OS_NT
56};
57
58extern int os_subtype;
59 39
60/* Emulation of Unix sbrk(). */ 40/* Emulation of Unix sbrk(). */
61extern void *sbrk (ptrdiff_t size); 41extern void *sbrk (ptrdiff_t size);
@@ -66,9 +46,6 @@ extern void init_heap (void);
66/* Round the heap to this size. */ 46/* Round the heap to this size. */
67extern void round_heap (size_t size); 47extern void round_heap (size_t size);
68 48
69/* Cache system info, e.g., the NT page size. */
70extern void cache_system_info (void);
71
72/* ----------------------------------------------------------------- */ 49/* ----------------------------------------------------------------- */
73/* Useful routines for manipulating memory-mapped files. */ 50/* Useful routines for manipulating memory-mapped files. */
74 51
diff --git a/src/w32inevt.c b/src/w32inevt.c
index ebb95dcace5..c322d3a0b44 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -70,6 +70,9 @@ w32_read_console_input (HANDLE h, INPUT_RECORD *rec, DWORD recsize,
70 : ReadConsoleInputA (h, rec, recsize, waiting)); 70 : ReadConsoleInputA (h, rec, recsize, waiting));
71} 71}
72 72
73/* Set by w32_console_toggle_lock_key. */
74int faked_key;
75
73static int 76static int
74fill_queue (BOOL block) 77fill_queue (BOOL block)
75{ 78{
@@ -110,67 +113,7 @@ get_frame (void)
110 113
111/* Translate console modifiers to emacs modifiers. 114/* Translate console modifiers to emacs modifiers.
112 German keyboard support (Kai Morgan Zeise 2/18/95). */ 115 German keyboard support (Kai Morgan Zeise 2/18/95). */
113int
114w32_kbd_mods_to_emacs (DWORD mods, WORD key)
115{
116 int retval = 0;
117
118 /* If we recognize right-alt and left-ctrl as AltGr, and it has been
119 pressed, first remove those modifiers. */
120 if (!NILP (Vw32_recognize_altgr)
121 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
122 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
123 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED);
124 116
125 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))
126 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier);
127
128 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
129 {
130 retval |= ctrl_modifier;
131 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
132 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
133 retval |= meta_modifier;
134 }
135
136 if (mods & LEFT_WIN_PRESSED)
137 retval |= w32_key_to_modifier (VK_LWIN);
138 if (mods & RIGHT_WIN_PRESSED)
139 retval |= w32_key_to_modifier (VK_RWIN);
140 if (mods & APPS_PRESSED)
141 retval |= w32_key_to_modifier (VK_APPS);
142 if (mods & SCROLLLOCK_ON)
143 retval |= w32_key_to_modifier (VK_SCROLL);
144
145 /* Just in case someone wanted the original behavior, make it
146 optional by setting w32-capslock-is-shiftlock to t. */
147 if (NILP (Vw32_capslock_is_shiftlock)
148 /* Keys that should _not_ be affected by CapsLock. */
149 && ( (key == VK_BACK)
150 || (key == VK_TAB)
151 || (key == VK_CLEAR)
152 || (key == VK_RETURN)
153 || (key == VK_ESCAPE)
154 || ((key >= VK_SPACE) && (key <= VK_HELP))
155 || ((key >= VK_NUMPAD0) && (key <= VK_F24))
156 || ((key >= VK_NUMPAD_CLEAR) && (key <= VK_NUMPAD_DELETE))
157 ))
158 {
159 /* Only consider shift state. */
160 if ((mods & SHIFT_PRESSED) != 0)
161 retval |= shift_modifier;
162 }
163 else
164 {
165 /* Ignore CapsLock state if not enabled. */
166 if (NILP (Vw32_enable_caps_lock))
167 mods &= ~CAPSLOCK_ON;
168 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0)
169 retval |= shift_modifier;
170 }
171
172 return retval;
173}
174 117
175#if 0 118#if 0
176/* Return nonzero if the virtual key is a dead key. */ 119/* Return nonzero if the virtual key is a dead key. */
@@ -187,90 +130,7 @@ is_dead_key (int wparam)
187/* The return code indicates key code size. cpID is the codepage to 130/* The return code indicates key code size. cpID is the codepage to
188 use for translation to Unicode; -1 means use the current console 131 use for translation to Unicode; -1 means use the current console
189 input codepage. */ 132 input codepage. */
190int
191w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
192{
193 unsigned int key_code = event->wVirtualKeyCode;
194 unsigned int mods = event->dwControlKeyState;
195 BYTE keystate[256];
196 static BYTE ansi_code[4];
197 static int isdead = 0;
198 133
199 if (isdead == 2)
200 {
201 event->uChar.AsciiChar = ansi_code[2];
202 isdead = 0;
203 return 1;
204 }
205 if (event->uChar.AsciiChar != 0)
206 return 1;
207
208 memset (keystate, 0, sizeof (keystate));
209 keystate[key_code] = 0x80;
210 if (mods & SHIFT_PRESSED)
211 keystate[VK_SHIFT] = 0x80;
212 if (mods & CAPSLOCK_ON)
213 keystate[VK_CAPITAL] = 1;
214 /* If we recognize right-alt and left-ctrl as AltGr, set the key
215 states accordingly before invoking ToAscii. */
216 if (!NILP (Vw32_recognize_altgr)
217 && (mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED))
218 {
219 keystate[VK_CONTROL] = 0x80;
220 keystate[VK_LCONTROL] = 0x80;
221 keystate[VK_MENU] = 0x80;
222 keystate[VK_RMENU] = 0x80;
223 }
224
225#if 0
226 /* Because of an OS bug, ToAscii corrupts the stack when called to
227 convert a dead key in console mode on NT4. Unfortunately, trying
228 to check for dead keys using MapVirtualKey doesn't work either -
229 these functions apparently use internal information about keyboard
230 layout which doesn't get properly updated in console programs when
231 changing layout (though apparently it gets partly updated,
232 otherwise ToAscii wouldn't crash). */
233 if (is_dead_key (event->wVirtualKeyCode))
234 return 0;
235#endif
236
237 /* On NT, call ToUnicode instead and then convert to the current
238 console input codepage. */
239 if (os_subtype == OS_NT)
240 {
241 WCHAR buf[128];
242
243 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode,
244 keystate, buf, 128, 0);
245 if (isdead > 0)
246 {
247 /* When we are called from the GUI message processing code,
248 we are passed the current keyboard codepage, a positive
249 number, to use below. */
250 if (cpId == -1)
251 cpId = GetConsoleCP ();
252
253 event->uChar.UnicodeChar = buf[isdead - 1];
254 isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
255 ansi_code, 4, NULL, NULL);
256 }
257 else
258 isdead = 0;
259 }
260 else
261 {
262 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode,
263 keystate, (LPWORD) ansi_code, 0);
264 }
265
266 if (isdead == 0)
267 return 0;
268 event->uChar.AsciiChar = ansi_code[0];
269 return isdead;
270}
271
272
273static int faked_key = 0;
274 134
275/* return code -1 means that event_queue_ptr won't be incremented. 135/* return code -1 means that event_queue_ptr won't be incremented.
276 In other word, this event makes two key codes. (by himi) */ 136 In other word, this event makes two key codes. (by himi) */
@@ -531,32 +391,6 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
531 return 1; 391 return 1;
532} 392}
533 393
534int
535w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
536{
537 int cur_state = (GetKeyState (vk_code) & 1);
538
539 if (NILP (new_state)
540 || (NUMBERP (new_state)
541 && ((XUINT (new_state)) & 1) != cur_state))
542 {
543 faked_key = vk_code;
544
545 keybd_event ((BYTE) vk_code,
546 (BYTE) MapVirtualKey (vk_code, 0),
547 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
548 keybd_event ((BYTE) vk_code,
549 (BYTE) MapVirtualKey (vk_code, 0),
550 KEYEVENTF_EXTENDEDKEY | 0, 0);
551 keybd_event ((BYTE) vk_code,
552 (BYTE) MapVirtualKey (vk_code, 0),
553 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
554 cur_state = !cur_state;
555 }
556
557 return cur_state;
558}
559
560/* Mouse position hook. */ 394/* Mouse position hook. */
561void 395void
562w32_console_mouse_position (FRAME_PTR *f, 396w32_console_mouse_position (FRAME_PTR *f,
diff --git a/src/w32menu.c b/src/w32menu.c
index 0a10f1f0893..36bf9574fdc 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <signal.h> 22#include <signal.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <mbstring.h> 24#include <setjmp.h>
25 25
26#include "lisp.h" 26#include "lisp.h"
27#include "keyboard.h" 27#include "keyboard.h"
@@ -40,6 +40,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40 if this is not done before the other system files. */ 40 if this is not done before the other system files. */
41#include "w32term.h" 41#include "w32term.h"
42 42
43/* Cygwin does not support the multibyte string functions declared in
44 * mbstring.h below --- but that's okay: because Cygwin is
45 * UNICODE-only, we don't need to use these functions anyway. */
46
47#ifndef NTGUI_UNICODE
48#include <mbstring.h>
49#endif /* !NTGUI_UNICODE */
50
43/* Load sys/types.h if not already loaded. 51/* Load sys/types.h if not already loaded.
44 In some systems loading it twice is suicidal. */ 52 In some systems loading it twice is suicidal. */
45#ifndef makedev 53#ifndef makedev
@@ -48,7 +56,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48 56
49#include "dispextern.h" 57#include "dispextern.h"
50 58
51#include "w32heap.h" /* for osinfo_cache */ 59#include "w32common.h" /* for osinfo_cache */
52 60
53#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ 61#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
54 62
@@ -78,10 +86,17 @@ typedef int (WINAPI * MessageBoxW_Proc) (
78 IN WCHAR *caption, 86 IN WCHAR *caption,
79 IN UINT type); 87 IN UINT type);
80 88
89#ifdef NTGUI_UNICODE
90#define get_menu_item_info GetMenuItemInfoA
91#define set_menu_item_info SetMenuItemInfoA
92#define unicode_append_menu AppendMenuW
93#define unicode_message_box MessageBoxW
94#else /* !NTGUI_UNICODE */
81GetMenuItemInfoA_Proc get_menu_item_info = NULL; 95GetMenuItemInfoA_Proc get_menu_item_info = NULL;
82SetMenuItemInfoA_Proc set_menu_item_info = NULL; 96SetMenuItemInfoA_Proc set_menu_item_info = NULL;
83AppendMenuW_Proc unicode_append_menu = NULL; 97AppendMenuW_Proc unicode_append_menu = NULL;
84MessageBoxW_Proc unicode_message_box = NULL; 98MessageBoxW_Proc unicode_message_box = NULL;
99#endif /* NTGUI_UNICODE */
85 100
86Lisp_Object Qdebug_on_next_call; 101Lisp_Object Qdebug_on_next_call;
87 102
@@ -98,6 +113,7 @@ static void utf8to16 (unsigned char *, int, WCHAR *);
98static int fill_in_menu (HMENU, widget_value *); 113static int fill_in_menu (HMENU, widget_value *);
99 114
100void w32_free_menu_strings (HWND); 115void w32_free_menu_strings (HWND);
116
101 117
102 118
103/* This is set nonzero after the user activates the menu bar, and set 119/* This is set nonzero after the user activates the menu bar, and set
@@ -1405,6 +1421,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1405 nlen++; 1421 nlen++;
1406 } 1422 }
1407 } 1423 }
1424#ifndef NTGUI_UNICODE
1408 else 1425 else
1409 { 1426 {
1410 /* If encoded with the system codepage, use multibyte string 1427 /* If encoded with the system codepage, use multibyte string
@@ -1415,6 +1432,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1415 nlen++; 1432 nlen++;
1416 } 1433 }
1417 } 1434 }
1435#endif /* !NTGUI_UNICODE */
1418 1436
1419 if (nlen > orig_len) 1437 if (nlen > orig_len)
1420 { 1438 {
@@ -1429,6 +1447,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1429 *q++ = *p; 1447 *q++ = *p;
1430 *q++ = *p++; 1448 *q++ = *p++;
1431 } 1449 }
1450#ifndef NTGUI_UNICODE
1432 else 1451 else
1433 { 1452 {
1434 if (_mbsnextc (p) == '&') 1453 if (_mbsnextc (p) == '&')
@@ -1440,6 +1459,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1440 p = _mbsinc (p); 1459 p = _mbsinc (p);
1441 q = _mbsinc (q); 1460 q = _mbsinc (q);
1442 } 1461 }
1462#endif /* !NTGUI_UNICODE */
1443 } 1463 }
1444 *q = '\0'; 1464 *q = '\0';
1445 } 1465 }
@@ -1486,6 +1506,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1486 item != NULL ? (UINT_PTR) item 1506 item != NULL ? (UINT_PTR) item
1487 : (UINT_PTR) wv->call_data, 1507 : (UINT_PTR) wv->call_data,
1488 utf16_string); 1508 utf16_string);
1509
1510#ifndef NTGUI_UNICODE /* Fallback does not apply when always UNICODE */
1489 if (!return_value) 1511 if (!return_value)
1490 { 1512 {
1491 /* On W9x/ME, Unicode menus are not supported, though AppendMenuW 1513 /* On W9x/ME, Unicode menus are not supported, though AppendMenuW
@@ -1504,6 +1526,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1504 if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT) 1526 if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT)
1505 unicode_append_menu = NULL; 1527 unicode_append_menu = NULL;
1506 } 1528 }
1529#endif /* NTGUI_UNICODE */
1507 1530
1508 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW)) 1531 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW))
1509 local_free (out_string); 1532 local_free (out_string);
@@ -1723,10 +1746,12 @@ syms_of_w32menu (void)
1723void 1746void
1724globals_of_w32menu (void) 1747globals_of_w32menu (void)
1725{ 1748{
1749#ifndef NTGUI_UNICODE
1726 /* See if Get/SetMenuItemInfo functions are available. */ 1750 /* See if Get/SetMenuItemInfo functions are available. */
1727 HMODULE user32 = GetModuleHandle ("user32.dll"); 1751 HMODULE user32 = GetModuleHandle ("user32.dll");
1728 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); 1752 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
1729 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); 1753 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
1730 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW"); 1754 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
1731 unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW"); 1755 unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW");
1756#endif /* !NTGUI_UNICODE */
1732} 1757}
diff --git a/src/w32proc.c b/src/w32proc.c
index d032b21c59e..7e8183b0e82 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -51,6 +51,7 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
51 51
52#include "lisp.h" 52#include "lisp.h"
53#include "w32.h" 53#include "w32.h"
54#include "w32common.h"
54#include "w32heap.h" 55#include "w32heap.h"
55#include "systime.h" 56#include "systime.h"
56#include "syswait.h" 57#include "syswait.h"
@@ -67,20 +68,6 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
67 68
68Lisp_Object Qhigh, Qlow; 69Lisp_Object Qhigh, Qlow;
69 70
70#ifdef EMACSDEBUG
71void
72_DebPrint (const char *fmt, ...)
73{
74 char buf[1024];
75 va_list args;
76
77 va_start (args, fmt);
78 vsprintf (buf, fmt, args);
79 va_end (args);
80 OutputDebugString (buf);
81}
82#endif
83
84typedef void (_CALLBACK_ *signal_handler) (int); 71typedef void (_CALLBACK_ *signal_handler) (int);
85 72
86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ 73/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */
diff --git a/src/w32select.c b/src/w32select.c
index 66f9f7ab041..1b10c74cfe9 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -75,12 +75,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
75#include <config.h> 75#include <config.h>
76#include "lisp.h" 76#include "lisp.h"
77#include "w32term.h" /* for all of the w32 includes */ 77#include "w32term.h" /* for all of the w32 includes */
78#include "w32heap.h" /* os_subtype */ 78#include "w32common.h" /* os_subtype */
79#include "keyboard.h"
79#include "blockinput.h" 80#include "blockinput.h"
80#include "charset.h" 81#include "charset.h"
81#include "coding.h" 82#include "coding.h"
82#include "composite.h" 83#include "composite.h"
83 84
85#ifdef CYGWIN
86#include <string.h>
87#include <stdio.h>
88#define _memccpy memccpy
89#endif
84 90
85static HGLOBAL convert_to_handle_as_ascii (void); 91static HGLOBAL convert_to_handle_as_ascii (void);
86static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system); 92static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system);
@@ -388,7 +394,6 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
388 with global variables and calling strange looking functions. Is 394 with global variables and calling strange looking functions. Is
389 this really the right way to run Lisp callbacks? */ 395 this really the right way to run Lisp callbacks? */
390 396
391 extern int waiting_for_input; /* from keyboard.c */
392 int owfi; 397 int owfi;
393 398
394 block_input (); 399 block_input ();
diff --git a/src/w32select.h b/src/w32select.h
new file mode 100644
index 00000000000..4f4de59f7fe
--- /dev/null
+++ b/src/w32select.h
@@ -0,0 +1,28 @@
1/* Selection processing for Emacs on the Microsoft W32 API.
2
3Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef W32SELECT_H
21#define W32SELECT_H
22#include <windows.h>
23
24extern void syms_of_w32select (void);
25extern void globals_of_w32select (void);
26extern void term_w32select (void);
27
28#endif
diff --git a/src/w32term.c b/src/w32term.c
index 1cc8bd2adef..4cc0b860947 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -51,7 +51,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51#include "atimer.h" 51#include "atimer.h"
52#include "keymap.h" 52#include "keymap.h"
53 53
54#ifdef WINDOWSNT
54#include "w32heap.h" 55#include "w32heap.h"
56#endif
57
58#ifndef WINDOWSNT
59#include <io.h> /* for get_osfhandle */
60#endif
61
55#include <shellapi.h> 62#include <shellapi.h>
56 63
57#include "font.h" 64#include "font.h"
@@ -121,7 +128,7 @@ typedef struct tagGLYPHSET
121 WCRANGE ranges[1]; 128 WCRANGE ranges[1];
122} GLYPHSET; 129} GLYPHSET;
123 130
124#endif 131#endif /* compiling for pre-Win2k */
125 132
126/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */ 133/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
127BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD); 134BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
@@ -190,6 +197,10 @@ static int volatile input_signal_count;
190static int input_signal_count; 197static int input_signal_count;
191#endif 198#endif
192 199
200#ifdef CYGWIN
201int w32_message_fd = -1;
202#endif /* CYGWIN */
203
193static void x_update_window_end (struct window *, int, int); 204static void x_update_window_end (struct window *, int, int);
194static void w32_handle_tool_bar_click (struct frame *, 205static void w32_handle_tool_bar_click (struct frame *,
195 struct input_event *); 206 struct input_event *);
@@ -4138,6 +4149,9 @@ static char dbcs_lead = 0;
4138 This routine is called by the SIGIO handler. 4149 This routine is called by the SIGIO handler.
4139 We return as soon as there are no more events to be read. 4150 We return as soon as there are no more events to be read.
4140 4151
4152 For an overview of how Emacs input works on MS-Windows, see the
4153 commentary before w32_msg_pump in w32fns.c.
4154
4141 We return the number of characters stored into the buffer, 4155 We return the number of characters stored into the buffer,
4142 thus pretending to be `read'. 4156 thus pretending to be `read'.
4143 4157
@@ -4160,18 +4174,26 @@ w32_read_socket (struct terminal *terminal,
4160 struct frame *f; 4174 struct frame *f;
4161 struct w32_display_info *dpyinfo = &one_w32_display_info; 4175 struct w32_display_info *dpyinfo = &one_w32_display_info;
4162 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 4176 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
4177 static char buf[1];
4163 4178
4164 block_input (); 4179 block_input ();
4165 4180
4166 /* So people can tell when we have read the available input. */ 4181 /* So people can tell when we have read the available input. */
4167 input_signal_count++; 4182 input_signal_count++;
4168 4183
4184 /* Process any incoming thread messages. */
4185 drain_message_queue ();
4186
4169 /* TODO: ghostscript integration. */ 4187 /* TODO: ghostscript integration. */
4170 while (get_next_msg (&msg, FALSE)) 4188 while (get_next_msg (&msg, FALSE))
4171 { 4189 {
4172 struct input_event inev; 4190 struct input_event inev;
4173 int do_help = 0; 4191 int do_help = 0;
4174 4192
4193 /* DebPrint (("w32_read_socket: %s time:%u\n", */
4194 /* w32_name_of_message (msg.msg.message), */
4195 /* msg.msg.time)); */
4196
4175 EVENT_INIT (inev); 4197 EVENT_INIT (inev);
4176 inev.kind = NO_EVENT; 4198 inev.kind = NO_EVENT;
4177 inev.arg = Qnil; 4199 inev.arg = Qnil;
@@ -6304,8 +6326,15 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6304 w32_defined_color (0, "black", &color, 1); 6326 w32_defined_color (0, "black", &color, 1);
6305 } 6327 }
6306 6328
6307 /* Add the default keyboard. */ 6329#ifdef WINDOWSNT
6330 /* Add the default keyboard. When !WINDOWSNT, we're using the
6331 standard Emacs console handling machinery and don't need an
6332 explicit FD here. */
6308 add_keyboard_wait_descriptor (0); 6333 add_keyboard_wait_descriptor (0);
6334#elif CYGWIN
6335 /* /dev/windows wakes us up when we have a thread message pending. */
6336 add_keyboard_wait_descriptor (w32_message_fd);
6337#endif
6309 6338
6310 /* Create Fringe Bitmaps and store them for later use. 6339 /* Create Fringe Bitmaps and store them for later use.
6311 6340
@@ -6316,15 +6345,6 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6316 the bitmaps. */ 6345 the bitmaps. */
6317 w32_init_fringe (terminal->rif); 6346 w32_init_fringe (terminal->rif);
6318 6347
6319#ifdef F_SETOWN
6320 fcntl (connection, F_SETOWN, getpid ());
6321#endif /* ! defined (F_SETOWN) */
6322
6323#ifdef SIGIO
6324 if (interrupt_input)
6325 init_sigio (connection);
6326#endif /* ! defined (SIGIO) */
6327
6328 unblock_input (); 6348 unblock_input ();
6329 6349
6330 return dpyinfo; 6350 return dpyinfo;
@@ -6374,6 +6394,7 @@ x_delete_display (struct w32_display_info *dpyinfo)
6374 6394
6375 w32_reset_fringes (); 6395 w32_reset_fringes ();
6376} 6396}
6397
6377 6398
6378/* Set up use of W32. */ 6399/* Set up use of W32. */
6379 6400
@@ -6411,6 +6432,11 @@ w32_initialize (void)
6411 set_user_model (L"GNU.Emacs"); 6432 set_user_model (L"GNU.Emacs");
6412 } 6433 }
6413 6434
6435#ifdef CYGWIN
6436 if ((w32_message_fd = open ("/dev/windows", O_RDWR | O_CLOEXEC)) == -1)
6437 fatal ("opening /dev/windows: %s", strerror (errno));
6438#endif /* CYGWIN */
6439
6414 /* Initialize w32_use_visible_system_caret based on whether a screen 6440 /* Initialize w32_use_visible_system_caret based on whether a screen
6415 reader is in use. */ 6441 reader is in use. */
6416 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0, 6442 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
@@ -6571,4 +6597,6 @@ With MS Windows or Nextstep, the value is t. */);
6571 6597
6572 staticpro (&last_mouse_motion_frame); 6598 staticpro (&last_mouse_motion_frame);
6573 last_mouse_motion_frame = Qnil; 6599 last_mouse_motion_frame = Qnil;
6600
6601 Fprovide (intern_c_string ("w32"), Qnil);
6574} 6602}
diff --git a/src/w32term.h b/src/w32term.h
index fcaccc4d624..83f9e7b98dc 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19/* Added by Kevin Gallo */ 19/* Added by Kevin Gallo */
20 20
21#include "w32gui.h" 21#include "w32gui.h"
22#include "frame.h"
23#include "atimer.h"
22 24
23 25
24#define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0) 26#define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
@@ -195,11 +197,45 @@ Lisp_Object display_x_get_resource (struct w32_display_info *,
195 Lisp_Object, Lisp_Object, 197 Lisp_Object, Lisp_Object,
196 Lisp_Object, Lisp_Object); 198 Lisp_Object, Lisp_Object);
197 199
200extern void x_focus_on_frame (struct frame *f);
201
202/* also defined in xterm.h XXX: factor out to common header */
203
198extern struct w32_display_info *w32_term_init (Lisp_Object, 204extern struct w32_display_info *w32_term_init (Lisp_Object,
199 char *, char *); 205 char *, char *);
200 206extern void check_w32 (void);
207extern int w32_defined_color (FRAME_PTR f, const char *color,
208 XColor *color_def, int alloc);
209extern void x_set_window_size (struct frame *f, int change_grav,
210 int cols, int rows);
201extern int x_display_pixel_height (struct w32_display_info *); 211extern int x_display_pixel_height (struct w32_display_info *);
202extern int x_display_pixel_width (struct w32_display_info *); 212extern int x_display_pixel_width (struct w32_display_info *);
213extern void x_sync (struct frame *);
214extern Lisp_Object x_get_focus_frame (struct frame *);
215extern void x_set_mouse_position (struct frame *f, int h, int v);
216extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
217extern void x_make_frame_visible (struct frame *f);
218extern void x_make_frame_invisible (struct frame *f);
219extern void x_iconify_frame (struct frame *f);
220extern int x_char_width (struct frame *f);
221extern int x_char_height (struct frame *f);
222extern int x_pixel_width (struct frame *f);
223extern int x_pixel_height (struct frame *f);
224extern void x_set_frame_alpha (struct frame *f);
225extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
226extern void x_set_tool_bar_lines (struct frame *f,
227 Lisp_Object value,
228 Lisp_Object oldval);
229extern void x_activate_menubar (struct frame *);
230extern int x_bitmap_icon (struct frame *, Lisp_Object);
231extern void initialize_frame_menubar (struct frame *);
232extern void x_free_frame_resources (struct frame *);
233extern void x_real_positions (struct frame *, int *, int *);
234
235/* w32inevt.c */
236extern int w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId);
237extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
238
203 239
204extern Lisp_Object x_get_focus_frame (struct frame *); 240extern Lisp_Object x_get_focus_frame (struct frame *);
205 241
@@ -584,7 +620,8 @@ do { \
584#define WM_EMACS_SETCURSOR (WM_EMACS_START + 19) 620#define WM_EMACS_SETCURSOR (WM_EMACS_START + 19)
585#define WM_EMACS_PAINT (WM_EMACS_START + 20) 621#define WM_EMACS_PAINT (WM_EMACS_START + 20)
586#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 21) 622#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 21)
587#define WM_EMACS_END (WM_EMACS_START + 22) 623#define WM_EMACS_INPUT_READY (WM_EMACS_START + 22)
624#define WM_EMACS_END (WM_EMACS_START + 23)
588 625
589#define WND_FONTWIDTH_INDEX (0) 626#define WND_FONTWIDTH_INDEX (0)
590#define WND_LINEHEIGHT_INDEX (4) 627#define WND_LINEHEIGHT_INDEX (4)
@@ -606,6 +643,8 @@ typedef struct W32Msg {
606 RECT rect; 643 RECT rect;
607} W32Msg; 644} W32Msg;
608 645
646extern BOOL prepend_msg (W32Msg *lpmsg);
647
609/* Structure for recording message when input thread must return a 648/* Structure for recording message when input thread must return a
610 result that depends on lisp thread to compute. Lisp thread can 649 result that depends on lisp thread to compute. Lisp thread can
611 complete deferred messages out of order. */ 650 complete deferred messages out of order. */
@@ -709,3 +748,19 @@ extern HWND w32_system_caret_hwnd;
709extern int w32_system_caret_height; 748extern int w32_system_caret_height;
710extern int w32_system_caret_x; 749extern int w32_system_caret_x;
711extern int w32_system_caret_y; 750extern int w32_system_caret_y;
751
752#if EMACSDEBUG
753extern const char*
754w32_name_of_message (UINT msg);
755#endif /* EMACSDEBUG */
756
757extern void syms_of_w32term (void);
758extern void syms_of_w32menu (void);
759extern void syms_of_w32fns (void);
760
761extern void globals_of_w32menu (void);
762extern void globals_of_w32fns (void);
763
764#ifdef CYGWIN
765extern int w32_message_fd;
766#endif /* CYGWIN */
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 018dd14cb80..cb452571665 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#include <config.h> 19#include <config.h>
20#include <signal.h> 20#include <signal.h>
21#include <stdio.h> 21#include <stdio.h>
22
22#include "lisp.h" 23#include "lisp.h"
23#include "keyboard.h" 24#include "keyboard.h"
24#include "frame.h" 25#include "frame.h"
@@ -32,7 +33,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#define myfree(lp) GlobalFreePtr (lp) 33#define myfree(lp) GlobalFreePtr (lp)
33 34
34CRITICAL_SECTION critsect; 35CRITICAL_SECTION critsect;
36
37#ifdef WINDOWSNT
35extern HANDLE keyboard_handle; 38extern HANDLE keyboard_handle;
39#endif /* WINDOWSNT */
40
36HANDLE input_available = NULL; 41HANDLE input_available = NULL;
37HANDLE interrupt_handle = NULL; 42HANDLE interrupt_handle = NULL;
38 43
@@ -43,7 +48,11 @@ init_crit (void)
43 48
44 /* For safety, input_available should only be reset by get_next_msg 49 /* For safety, input_available should only be reset by get_next_msg
45 when the input queue is empty, so make it a manual reset event. */ 50 when the input queue is empty, so make it a manual reset event. */
46 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL); 51 input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
52
53#ifdef WINDOWSNT
54 keyboard_handle = input_available;
55#endif /* WINDOWSNT */
47 56
48 /* interrupt_handle is signaled when quit (C-g) is detected, so that 57 /* interrupt_handle is signaled when quit (C-g) is detected, so that
49 blocking system calls can be interrupted. We make it a manual 58 blocking system calls can be interrupted. We make it a manual
@@ -240,6 +249,22 @@ get_next_msg (W32Msg * lpmsg, BOOL bWait)
240 return (bRet); 249 return (bRet);
241} 250}
242 251
252extern char * w32_strerror (int error_no);
253
254/* Tell the main thread that we have input available; if the main
255 thread is blocked in select(), we wake it up here. */
256static void
257notify_msg_ready (void)
258{
259 SetEvent (input_available);
260
261#ifdef CYGWIN
262 /* Wakes up the main thread, which is blocked select()ing for /dev/windows,
263 among other files. */
264 (void) PostThreadMessage (dwMainThreadId, WM_EMACS_INPUT_READY, 0, 0);
265#endif /* CYGWIN */
266}
267
243BOOL 268BOOL
244post_msg (W32Msg * lpmsg) 269post_msg (W32Msg * lpmsg)
245{ 270{
@@ -263,8 +288,7 @@ post_msg (W32Msg * lpmsg)
263 } 288 }
264 289
265 lpTail = lpNew; 290 lpTail = lpNew;
266 SetEvent (input_available); 291 notify_msg_ready ();
267
268 leave_crit (); 292 leave_crit ();
269 293
270 return (TRUE); 294 return (TRUE);
@@ -285,7 +309,7 @@ prepend_msg (W32Msg *lpmsg)
285 nQueue++; 309 nQueue++;
286 lpNew->lpNext = lpHead; 310 lpNew->lpNext = lpHead;
287 lpHead = lpNew; 311 lpHead = lpNew;
288 312 notify_msg_ready ();
289 leave_crit (); 313 leave_crit ();
290 314
291 return (TRUE); 315 return (TRUE);
diff --git a/src/window.c b/src/window.c
index 3b974616e38..61d2a8b073f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -43,7 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
43#ifdef HAVE_X_WINDOWS 43#ifdef HAVE_X_WINDOWS
44#include "xterm.h" 44#include "xterm.h"
45#endif /* HAVE_X_WINDOWS */ 45#endif /* HAVE_X_WINDOWS */
46#ifdef WINDOWSNT 46#ifdef HAVE_NTGUI
47#include "w32term.h" 47#include "w32term.h"
48#endif 48#endif
49#ifdef MSDOS 49#ifdef MSDOS
diff --git a/src/xdisp.c b/src/xdisp.c
index 635e7ecd0b2..1e61a74068b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -302,7 +302,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
302#ifdef HAVE_X_WINDOWS 302#ifdef HAVE_X_WINDOWS
303#include "xterm.h" 303#include "xterm.h"
304#endif 304#endif
305#ifdef WINDOWSNT 305#ifdef HAVE_NTGUI
306#include "w32term.h" 306#include "w32term.h"
307#endif 307#endif
308#ifdef HAVE_NS 308#ifdef HAVE_NS
@@ -29379,9 +29379,10 @@ start_hourglass (void)
29379 else 29379 else
29380 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0); 29380 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0);
29381 29381
29382#ifdef WINDOWSNT 29382#ifdef HAVE_NTGUI
29383 extern void w32_note_current_window (void);
29383 w32_note_current_window (); 29384 w32_note_current_window ();
29384#endif 29385#endif /* HAVE_NTGUI */
29385 29386
29386 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 29387 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
29387 show_hourglass, NULL); 29388 show_hourglass, NULL);
diff --git a/src/xfaces.c b/src/xfaces.c
index f861dde2d15..3e6e9dc8ec0 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -227,13 +227,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
227#ifdef HAVE_WINDOW_SYSTEM 227#ifdef HAVE_WINDOW_SYSTEM
228#include TERM_HEADER 228#include TERM_HEADER
229#include "fontset.h" 229#include "fontset.h"
230#ifdef WINDOWSNT 230#ifdef HAVE_NTGUI
231#undef FRAME_X_DISPLAY_INFO 231#undef FRAME_X_DISPLAY_INFO
232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO 232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
233#define x_display_info w32_display_info 233#define x_display_info w32_display_info
234#define check_x check_w32 234#define check_x check_w32
235#define GCGraphicsExposures 0 235#define GCGraphicsExposures 0
236#endif /* WINDOWSNT */ 236#endif /* HAVE_NTGUI */
237 237
238#ifdef HAVE_NS 238#ifdef HAVE_NS
239#undef FRAME_X_DISPLAY_INFO 239#undef FRAME_X_DISPLAY_INFO
@@ -625,7 +625,7 @@ x_free_gc (struct frame *f, GC gc)
625 625
626#endif /* HAVE_X_WINDOWS */ 626#endif /* HAVE_X_WINDOWS */
627 627
628#ifdef WINDOWSNT 628#ifdef HAVE_NTGUI
629/* W32 emulation of GCs */ 629/* W32 emulation of GCs */
630 630
631static GC 631static GC
@@ -649,7 +649,7 @@ x_free_gc (struct frame *f, GC gc)
649 xfree (gc); 649 xfree (gc);
650} 650}
651 651
652#endif /* WINDOWSNT */ 652#endif /* HAVE_NTGUI */
653 653
654#ifdef HAVE_NS 654#ifdef HAVE_NS
655/* NS emulation of GCs */ 655/* NS emulation of GCs */
@@ -719,7 +719,7 @@ init_frame_faces (struct frame *f)
719#ifdef HAVE_X_WINDOWS 719#ifdef HAVE_X_WINDOWS
720 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f)) 720 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f))
721#endif 721#endif
722#ifdef WINDOWSNT 722#ifdef HAVE_NTGUI
723 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f)) 723 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f))
724#endif 724#endif
725#ifdef HAVE_NS 725#ifdef HAVE_NS
@@ -1098,7 +1098,7 @@ defined_color (struct frame *f, const char *color_name, XColor *color_def,
1098 else if (FRAME_X_P (f)) 1098 else if (FRAME_X_P (f))
1099 return x_defined_color (f, color_name, color_def, alloc); 1099 return x_defined_color (f, color_name, color_def, alloc);
1100#endif 1100#endif
1101#ifdef WINDOWSNT 1101#ifdef HAVE_NTGUI
1102 else if (FRAME_W32_P (f)) 1102 else if (FRAME_W32_P (f))
1103 return w32_defined_color (f, color_name, color_def, alloc); 1103 return w32_defined_color (f, color_name, color_def, alloc);
1104#endif 1104#endif
@@ -3245,7 +3245,7 @@ FRAME 0 means change the face on all frames, and change the default
3245 param = Qbackground_color; 3245 param = Qbackground_color;
3246 } 3246 }
3247#ifdef HAVE_WINDOW_SYSTEM 3247#ifdef HAVE_WINDOW_SYSTEM
3248#ifndef WINDOWSNT 3248#ifndef HAVE_NTGUI
3249 else if (EQ (face, Qscroll_bar)) 3249 else if (EQ (face, Qscroll_bar))
3250 { 3250 {
3251 /* Changing the colors of `scroll-bar' sets frame parameters 3251 /* Changing the colors of `scroll-bar' sets frame parameters
@@ -3255,7 +3255,7 @@ FRAME 0 means change the face on all frames, and change the default
3255 else if (EQ (attr, QCbackground)) 3255 else if (EQ (attr, QCbackground))
3256 param = Qscroll_bar_background; 3256 param = Qscroll_bar_background;
3257 } 3257 }
3258#endif /* not WINDOWSNT */ 3258#endif /* not HAVE_NTGUI */
3259 else if (EQ (face, Qborder)) 3259 else if (EQ (face, Qborder))
3260 { 3260 {
3261 /* Changing background color of `border' sets frame parameter 3261 /* Changing background color of `border' sets frame parameter
@@ -6362,7 +6362,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6362 if (num >= 0 && name[num] == '\n') 6362 if (num >= 0 && name[num] == '\n')
6363 name[num] = 0; 6363 name[num] = 0;
6364 cmap = Fcons (Fcons (build_string (name), 6364 cmap = Fcons (Fcons (build_string (name),
6365#ifdef WINDOWSNT 6365#ifdef HAVE_NTGUI
6366 make_number (RGB (red, green, blue))), 6366 make_number (RGB (red, green, blue))),
6367#else 6367#else
6368 make_number ((red << 16) | (green << 8) | blue)), 6368 make_number ((red << 16) | (green << 8) | blue)),
diff --git a/src/xsettings.c b/src/xsettings.c
index 7c68ff295cf..d23070791d8 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -29,7 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include "keyboard.h" 29#include "keyboard.h"
30#include "blockinput.h" 30#include "blockinput.h"
31#include "termhooks.h" 31#include "termhooks.h"
32#include "termopts.h"
33 32
34#include <X11/Xproto.h> 33#include <X11/Xproto.h>
35 34
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 8067899f931..289aac8492b 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -35,7 +35,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include "sysselect.h" 35#include "sysselect.h"
36#include "frame.h" 36#include "frame.h"
37#include "termhooks.h" 37#include "termhooks.h"
38#include "termopts.h"
39#include "xterm.h" 38#include "xterm.h"
40#include "process.h" 39#include "process.h"
41#include "keyboard.h" 40#include "keyboard.h"