aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-07-14 11:04:49 +0200
committerJoakim Verona2013-07-14 11:04:49 +0200
commit0bb9bb0841d89fff09820a57369df4cb01b16b43 (patch)
tree832bf9fa8415eef0ce464d22b3ee1300cfa90bb1
parent3718127221fbbc31f8ebd027ab7c95403dbe9118 (diff)
parent3af1c8684ed6e48fbc21481d129e9aa164752c6e (diff)
downloademacs-0bb9bb0841d89fff09820a57369df4cb01b16b43.tar.gz
emacs-0bb9bb0841d89fff09820a57369df4cb01b16b43.zip
Merge branch 'trunk' into xwidget
Conflicts: src/xdisp.c
-rw-r--r--ChangeLog66
-rw-r--r--Makefile.in2
-rw-r--r--admin/ChangeLog33
-rw-r--r--admin/FOR-RELEASE14
-rw-r--r--admin/admin.el132
-rwxr-xr-xadmin/merge-gnulib10
-rw-r--r--admin/notes/changelogs7
-rw-r--r--autogen/Makefile.in93
-rw-r--r--autogen/aclocal.m43
-rw-r--r--autogen/config.in91
-rwxr-xr-xautogen/configure558
-rw-r--r--configure.ac99
-rw-r--r--doc/emacs/ChangeLog8
-rw-r--r--doc/emacs/help.texi2
-rw-r--r--doc/emacs/maintaining.texi2
-rw-r--r--doc/emacs/programs.texi8
-rw-r--r--doc/lispintro/ChangeLog9
-rw-r--r--doc/lispintro/emacs-lisp-intro.texi21
-rw-r--r--doc/lispref/ChangeLog23
-rw-r--r--doc/lispref/debugging.texi2
-rw-r--r--doc/lispref/elisp.texi21
-rw-r--r--doc/lispref/files.texi6
-rw-r--r--doc/lispref/nonascii.texi3
-rw-r--r--doc/lispref/package.texi2
-rw-r--r--doc/lispref/syntax.texi5
-rw-r--r--doc/lispref/text.texi12
-rw-r--r--doc/misc/ChangeLog59
-rw-r--r--doc/misc/bovine.texi2
-rw-r--r--doc/misc/cc-mode.texi2
-rw-r--r--doc/misc/dbus.texi7
-rw-r--r--doc/misc/eudc.texi19
-rw-r--r--doc/misc/gnus-faq.texi29
-rw-r--r--doc/misc/gnus.texi51
-rw-r--r--doc/misc/mh-e.texi33
-rw-r--r--doc/misc/newsticker.texi2
-rw-r--r--doc/misc/nxml-mode.texi4
-rw-r--r--doc/misc/org.texi2
-rw-r--r--doc/misc/pgg.texi5
-rw-r--r--doc/misc/texinfo.tex38
-rw-r--r--doc/misc/url.texi2
-rw-r--r--doc/misc/wisent.texi3
-rw-r--r--etc/ChangeLog23
-rw-r--r--etc/NEWS131
-rw-r--r--lib-src/ChangeLog18
-rw-r--r--lib-src/ebrowse.c12
-rw-r--r--lib-src/emacsclient.c11
-rw-r--r--lib-src/make-docfile.c2
-rw-r--r--lib/binary-io.c3
-rw-r--r--lib/binary-io.h72
-rw-r--r--lib/fcntl.c311
-rw-r--r--lib/getdtablesize.c86
-rw-r--r--lib/gnulib.mk43
-rw-r--r--lib/ignore-value.h48
-rw-r--r--lib/pipe2.c168
-rw-r--r--lib/stdalign.in.h39
-rw-r--r--lib/verify.h112
-rw-r--r--lisp/ChangeLog447
-rw-r--r--lisp/autoinsert.el5
-rw-r--r--lisp/autorevert.el158
-rw-r--r--lisp/buff-menu.el10
-rw-r--r--lisp/calendar/todo-mode.el539
-rw-r--r--lisp/cedet/ChangeLog2
-rw-r--r--lisp/desktop.el39
-rw-r--r--lisp/doc-view.el14
-rw-r--r--lisp/edmacro.el73
-rw-r--r--lisp/emacs-lisp/.gitignore2
-rw-r--r--lisp/emacs-lisp/cl-macs.el12
-rw-r--r--lisp/emacs-lisp/edebug.el26
-rw-r--r--lisp/emacs-lisp/ert.el173
-rw-r--r--lisp/emacs-lisp/map-ynp.el5
-rw-r--r--lisp/emacs-lisp/pcase.el17
-rw-r--r--lisp/emulation/viper-cmd.el101
-rw-r--r--lisp/emulation/viper-keym.el2
-rw-r--r--lisp/emulation/viper.el66
-rw-r--r--lisp/faces.el7
-rw-r--r--lisp/filenotify.el324
-rw-r--r--lisp/files.el10
-rw-r--r--lisp/filesets.el6
-rw-r--r--lisp/frame.el28
-rw-r--r--lisp/gnus/ChangeLog57
-rw-r--r--lisp/gnus/auth-source.el4
-rw-r--r--lisp/gnus/gnus-art.el3
-rw-r--r--lisp/gnus/gnus-msg.el1
-rw-r--r--lisp/gnus/gnus-registry.el23
-rw-r--r--lisp/gnus/gnus-start.el5
-rw-r--r--lisp/gnus/gnus-sum.el27
-rw-r--r--lisp/gnus/gnus.el4
-rw-r--r--lisp/gnus/message.el2
-rw-r--r--lisp/gnus/mm-view.el22
-rw-r--r--lisp/gnus/nnir.el6
-rw-r--r--lisp/gnus/nnml.el5
-rw-r--r--lisp/ibuffer.el1
-rw-r--r--lisp/ido.el152
-rw-r--r--lisp/info-xref.el23
-rw-r--r--lisp/info.el43
-rw-r--r--lisp/international/mule.el24
-rw-r--r--lisp/net/shr.el1
-rw-r--r--lisp/net/tramp-cache.el6
-rw-r--r--lisp/net/tramp-gvfs.el3
-rw-r--r--lisp/net/tramp-sh.el175
-rw-r--r--lisp/net/tramp.el147
-rw-r--r--lisp/progmodes/cc-engine.el32
-rw-r--r--lisp/progmodes/cfengine.el4
-rw-r--r--lisp/progmodes/ebrowse.el23
-rw-r--r--lisp/progmodes/gdb-mi.el23
-rw-r--r--lisp/progmodes/python.el9
-rw-r--r--lisp/progmodes/ruby-mode.el108
-rw-r--r--lisp/shadowfile.el23
-rw-r--r--lisp/simple.el202
-rw-r--r--lisp/subr.el56
-rw-r--r--lisp/thumbs.el18
-rw-r--r--lisp/vc/ediff.el73
-rw-r--r--lisp/wid-edit.el11
-rw-r--r--lisp/window.el19
-rw-r--r--m4/fcntl.m495
-rw-r--r--m4/getdtablesize.m417
-rw-r--r--m4/gnulib-comp.m455
-rw-r--r--m4/pipe2.m418
-rw-r--r--m4/stdalign.m43
-rw-r--r--nt/ChangeLog14
-rw-r--r--nt/gnulib.mk3
-rw-r--r--nt/inc/ms-w32.h1
-rw-r--r--nt/inc/sys/socket.h4
-rw-r--r--nt/mingw-cfg.site5
-rw-r--r--src/ChangeLog475
-rw-r--r--src/alloc.c6
-rw-r--r--src/atimer.c2
-rw-r--r--src/buffer.c10
-rw-r--r--src/bytecode.c7
-rw-r--r--src/callproc.c159
-rw-r--r--src/coding.c2
-rw-r--r--src/cygw32.c2
-rw-r--r--src/data.c3
-rw-r--r--src/dbusbind.c8
-rw-r--r--src/deps.mk2
-rw-r--r--src/dired.c2
-rw-r--r--src/dispextern.h8
-rw-r--r--src/dispnew.c22
-rw-r--r--src/emacs.c100
-rw-r--r--src/eval.c71
-rw-r--r--src/fileio.c153
-rw-r--r--src/filelock.c20
-rw-r--r--src/fns.c26
-rw-r--r--src/frame.c11
-rw-r--r--src/gfilenotify.c14
-rw-r--r--src/gnutls.h2
-rw-r--r--src/image.c104
-rw-r--r--src/inotify.c61
-rw-r--r--src/keyboard.c7
-rw-r--r--src/lisp.h26
-rw-r--r--src/lread.c101
-rw-r--r--src/makefile.w32-in2
-rw-r--r--src/nsfns.m127
-rw-r--r--src/nsfont.m1
-rw-r--r--src/nsmenu.m6
-rw-r--r--src/nsterm.h6
-rw-r--r--src/nsterm.m33
-rw-r--r--src/print.c17
-rw-r--r--src/process.c159
-rw-r--r--src/process.h8
-rw-r--r--src/profiler.c12
-rw-r--r--src/ralloc.c2
-rw-r--r--src/regex.c33
-rw-r--r--src/regex.h46
-rw-r--r--src/search.c2
-rw-r--r--src/sheap.c4
-rw-r--r--src/sound.c2
-rw-r--r--src/syntax.c272
-rw-r--r--src/syntax.h296
-rw-r--r--src/sysdep.c263
-rw-r--r--src/sysstdio.h2
-rw-r--r--src/systime.h23
-rw-r--r--src/term.c53
-rw-r--r--src/termcap.c114
-rw-r--r--src/termhooks.h2
-rw-r--r--src/terminal.c4
-rw-r--r--src/undo.c7
-rw-r--r--src/unexaix.c26
-rw-r--r--src/unexcoff.c22
-rw-r--r--src/unexcw.c10
-rw-r--r--src/unexelf.c17
-rw-r--r--src/unexhp9k800.c9
-rw-r--r--src/unexmacosx.c9
-rw-r--r--src/w32.c15
-rw-r--r--src/w32.h2
-rw-r--r--src/w32fns.c281
-rw-r--r--src/w32term.c34
-rw-r--r--src/window.c12
-rw-r--r--src/xdisp.c130
-rw-r--r--src/xfaces.c5
-rw-r--r--src/xrdb.c5
-rw-r--r--src/xsettings.c6
-rw-r--r--src/xterm.c126
-rw-r--r--src/xterm.h2
-rw-r--r--test/ChangeLog100
-rw-r--r--test/automated/add-log-tests.el1
-rw-r--r--test/automated/advice-tests.el2
-rw-r--r--test/automated/cl-lib.el198
-rw-r--r--test/automated/decoder-tests.el5
-rw-r--r--test/automated/ert-tests.el171
-rw-r--r--test/automated/file-notify-tests.el263
-rw-r--r--test/automated/files.el3
-rw-r--r--test/automated/flymake-tests.el3
-rw-r--r--test/automated/icalendar-tests.el3
-rw-r--r--test/automated/imenu-test.el1
-rw-r--r--test/automated/inotify-test.el5
-rwxr-xr-xtest/automated/package-test.el7
-rwxr-xr-xtest/automated/package-x-test.el1
-rw-r--r--test/automated/python-tests.el52
-rw-r--r--test/automated/ruby-mode-tests.el33
-rw-r--r--test/automated/undo-tests.el26
-rw-r--r--test/automated/xml-parse-tests.el1
212 files changed, 7327 insertions, 3344 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e4156c3c79..967284b485d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,67 @@
12013-07-13 Paul Eggert <eggert@cs.ucla.edu>
2
3 * configure.ac: Simplify --with-file-notification handling.
4
52013-07-12 Glenn Morris <rgm@gnu.org>
6
7 * configure.ac: If with-file-notification=yes, if gfile not found,
8 go on to try inotify (not on MS Windows or Nextstep).
9
102013-07-12 Paul Eggert <eggert@cs.ucla.edu>
11
12 Fix races with threads and file descriptors.
13 * configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close.
14
152013-07-10 Paul Eggert <eggert@cs.ucla.edu>
16
17 * Makefile.in (removenullpaths): Remove adjacent null paths (Bug#14835).
18
192013-07-09 Peter Rosin <peda@lysator.liu.se> (tiny change>
20
21 * configure.ac (HAVE_W32): Avoid nested functions (the second
22 argument of AC_LANG_PROGRAM is already expanded inside a
23 function). (Bug#14830)
24
252013-07-09 Paul Eggert <eggert@cs.ucla.edu>
26
27 Port recent close-on-exec changes to Cygwin (Bug#14821).
28 * lib/binary-io.c, lib/binary-io.h: New files.
29 Merge from gnulib, incorporating:
30 2013-07-09 accept4, dup3, pipe2: port to Cygwin
31 * lib/pipe2.c: Update from gnulib, as part of this merge.
32 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
33
34 Handle errno and exit status a bit more carefully.
35 * lib/ignore-value.h: Remove this gnulib-imported file.
36 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
37
382013-07-08 Magnus Henoch <magnus.henoch@gmail.com> (tiny change)
39
40 * configure.ac (HAVE_IMAGEMAGICK): Check on NS also (Bug#14798).
41
422013-07-08 Paul Eggert <eggert@cs.ucla.edu>
43
44 Try to fix FreeBSD 9.1 porting problem (Bug#14812).
45 This incorporates the following merge from gnulib:
46 2013-07-07 stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
47
482013-07-07 Paul Eggert <eggert@cs.ucla.edu>
49
50 Port to Ubuntu 10 (Bug#14803).
51 * configure.ac (accept4): New function to check for.
52
53 Make file descriptors close-on-exec when possible (Bug#14803).
54 * configure.ac (mkostemp): New function to check for.
55 (PTY_OPEN): Pass O_CLOEXEC to posix_openpt.
56 * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4:
57 * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib.
58 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
59
602013-07-03 Christoph Egger <christoph@debian.org> (tiny change)
61
62 * configure.ac (emacs_broken_SIGIO): Set on gnu-kfreebsd to avoid hang.
63 http://bugs.debian.org/712974
64
12013-07-02 Paul Eggert <eggert@cs.ucla.edu> 652013-07-02 Paul Eggert <eggert@cs.ucla.edu>
2 66
3 Remove some unused macros from 'configure'. 67 Remove some unused macros from 'configure'.
@@ -31,7 +95,7 @@
31 * Makefile.in (install-arch-indep): Do not create directories passed 95 * Makefile.in (install-arch-indep): Do not create directories passed
32 with --enable-locallisppath. 96 with --enable-locallisppath.
33 97
342013-06-24 Glenn Morris <rgm@fencepost.gnu.org> 982013-06-24 Glenn Morris <rgm@gnu.org>
35 99
36 * configure.ac: Include X11/X.h when testing for Xft.h. (Bug#14684) 100 * configure.ac: Include X11/X.h when testing for Xft.h. (Bug#14684)
37 101
diff --git a/Makefile.in b/Makefile.in
index 4afe6746cfc..a5accbf04a9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -293,7 +293,7 @@ all: ${SUBDIR}
293 293
294.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 FRC 294.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 FRC
295 295
296removenullpaths=sed -e 's/^://g' -e 's/:$$//g' -e 's/::/:/g' 296removenullpaths=sed -e 's/^:*//' -e 's/:*$$//g' -e 's/::*/:/g'
297 297
298# Generate epaths.h from epaths.in. This target is invoked by `configure'. 298# Generate epaths.h from epaths.in. This target is invoked by `configure'.
299# See comments in configure.ac for why it is done this way, as opposed 299# See comments in configure.ac for why it is done this way, as opposed
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 8746657517e..cbcd698e8b1 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,36 @@
12013-07-12 Glenn Morris <rgm@gnu.org>
2
3 * admin.el (manual-style-string): Use non-abbreviated url.
4
52013-07-09 Paul Eggert <eggert@cs.ucla.edu>
6
7 Port recent close-on-exec changes to Cygwin (Bug#14821).
8 * merge-gnulib (GNULIB_TOOL_FLAGS): Don't avoid binary-io.
9
10 Handle error numbers a bit more reliably.
11 * merge-gnulib (GNULIB_MODULES): Remove ignore-value.
12
132013-07-07 Paul Eggert <eggert@cs.ucla.edu>
14
15 Make file descriptors close-on-exec when possible (Bug#14803).
16 * merge-gnulib (GNULIB_MODULES): Add fcntl, pipe2.
17 (GNULIB_TOOL_FLAGS): Avoid binary-io, close. Do not avoid fcntl.
18
192013-07-06 Glenn Morris <rgm@gnu.org>
20
21 * admin.el (manual-misc-manuals): New function.
22 (make-manuals): Avoid hard-coding list of misc manuals.
23 Add the option to only make certain type(s) of output.
24 (manual-misc-html): Special-case ccmode and efaq.
25 (manual-html-mono, manual-html-node, manual-pdf, manual-ps):
26 Move creation of output directory here from make-manuals.
27 (manual-html-fix-index-2): Avoid dynamic reference to `f'.
28
292013-07-05 Glenn Morris <rgm@gnu.org>
30
31 * admin.el (make-manuals): Use a standard location for lispintro.
32 Use a pdf/ subdirectory for pdf versions.
33
12013-06-29 Glenn Morris <rgm@gnu.org> 342013-06-29 Glenn Morris <rgm@gnu.org>
2 35
3 * admin.el (make-manuals): Don't bother with txt or dvi any more. 36 * admin.el (make-manuals): Don't bother with txt or dvi any more.
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 0821593955e..53186b21688 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -18,6 +18,20 @@ in the web pages repository. E.g.:
18Redirect /software/emacs/manual/html_mono/automake.html /software/automake/manual/automake.html 18Redirect /software/emacs/manual/html_mono/automake.html /software/automake/manual/automake.html
19Redirect /software/emacs/manual/html_node/automake/ /software/automake/manual/html_node/ 19Redirect /software/emacs/manual/html_node/automake/ /software/automake/manual/html_node/
20 20
21Another tool you can use to check links is gnu.org's linc.py:
22http://www.gnu.org/server/source/
23
24You run this something like:
25
26cd /path/to/cvs/emacs-www
27linc.py -o /path/to/output-dir --url http://www.gnu.org/software/emacs/ .
28
29Be warned that it is really, really slow (as in, can take ~ a full day
30to check the manual/ directory). It is probably best to run it on a
31single directory at a time from eg manual/html_node. It is very
32inefficient, but may reveal a few things that info-xref does not.
33
34
21make emacs.dvi, elisp.dvi, and deal with any errors (undefined 35make emacs.dvi, elisp.dvi, and deal with any errors (undefined
22references etc) in the output. Break any overfull lines. 36references etc) in the output. Break any overfull lines.
23Underfull hboxes are not serious, but it can be nice to get rid of 37Underfull hboxes are not serious, but it can be nice to get rid of
diff --git a/admin/admin.el b/admin/admin.el
index 2bc4955810d..9c0015fc413 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -193,58 +193,82 @@ Root must be the root of an Emacs source tree."
193 193
194;;; Various bits of magic for generating the web manuals 194;;; Various bits of magic for generating the web manuals
195 195
196(defun make-manuals (root) 196(defun manual-misc-manuals (root)
197 "Generate the web manuals for the Emacs webpage." 197 "Return doc/misc manuals as list of strings."
198 (interactive "DEmacs root directory: ") 198 ;; Like `make -C doc/misc echo-info', but works if unconfigured.
199 (with-temp-buffer
200 (insert-file-contents (expand-file-name "doc/misc/Makefile.in" root))
201 (search-forward "INFO_TARGETS = ")
202 (let ((start (point))
203 res)
204 (end-of-line)
205 (while (and (looking-back "\\\\")
206 (zerop (forward-line 1)))
207 (end-of-line))
208 (split-string (replace-regexp-in-string
209 "\\(\\\\\\|\\.info\\)" ""
210 (buffer-substring start (point)))))))
211
212(defun make-manuals (root &optional type)
213 "Generate the web manuals for the Emacs webpage.
214Interactively with a prefix argument, prompt for TYPE.
215Optional argument TYPE is type of output (nil means all)."
216 (interactive (let ((root (read-directory-name "Emacs root directory: "
217 source-directory nil t)))
218 (list root
219 (if current-prefix-arg
220 (completing-read
221 "Type: "
222 (append
223 '("misc" "pdf" "ps")
224 (let (res)
225 (dolist (i '("emacs" "elisp" "eintr") res)
226 (dolist (j '("" "-mono" "-node" "-ps" "-pdf"))
227 (push (concat i j) res))))
228 (manual-misc-manuals root)))))))
199 (let* ((dest (expand-file-name "manual" root)) 229 (let* ((dest (expand-file-name "manual" root))
200 (html-node-dir (expand-file-name "html_node" dest)) 230 (html-node-dir (expand-file-name "html_node" dest))
201 (html-mono-dir (expand-file-name "html_mono" dest)) 231 (html-mono-dir (expand-file-name "html_mono" dest))
202 (ps-dir (expand-file-name "ps" dest))) 232 (ps-dir (expand-file-name "ps" dest))
233 (pdf-dir (expand-file-name "pdf" dest))
234 (emacs (expand-file-name "doc/emacs/emacs.texi" root))
235 (elisp (expand-file-name "doc/lispref/elisp.texi" root))
236 (eintr (expand-file-name "doc/lispintro/emacs-lisp-intro.texi" root))
237 (misc (manual-misc-manuals root)))
238 ;; TODO this makes it non-continuable.
239 ;; Instead, delete the individual dest directory each time.
203 (when (file-directory-p dest) 240 (when (file-directory-p dest)
204 (if (y-or-n-p (format "Directory %s exists, delete it first?" dest)) 241 (if (y-or-n-p (format "Directory %s exists, delete it first? " dest))
205 (delete-directory dest t) 242 (delete-directory dest t)
206 (error "Aborted"))) 243 (user-error "Aborted")))
207 (make-directory dest) 244 (if (member type '(nil "emacs" "emacs-node"))
208 (make-directory html-node-dir) 245 (manual-html-node emacs (expand-file-name "emacs" html-node-dir)))
209 (make-directory html-mono-dir) 246 (if (member type '(nil "emacs" "emacs-mono"))
210 (make-directory ps-dir) 247 (manual-html-mono emacs (expand-file-name "emacs.html" html-mono-dir)))
211 ;; Emacs manual 248 (if (member type '(nil "emacs" "emacs-pdf" "pdf"))
212 (let ((texi (expand-file-name "doc/emacs/emacs.texi" root))) 249 (manual-pdf emacs (expand-file-name "emacs.pdf" pdf-dir)))
213 (manual-html-node texi (expand-file-name "emacs" html-node-dir)) 250 (if (member type '(nil "emacs" "emacs-ps" "ps"))
214 (manual-html-mono texi (expand-file-name "emacs.html" html-mono-dir)) 251 (manual-ps emacs (expand-file-name "emacs.ps" ps-dir)))
215 (manual-pdf texi (expand-file-name "emacs.pdf" dest)) 252 (if (member type '(nil "elisp" "elisp-node"))
216 (manual-ps texi (expand-file-name "emacs.ps" ps-dir))) 253 (manual-html-node elisp (expand-file-name "elisp" html-node-dir)))
217 ;; Lisp manual 254 (if (member type '(nil "elisp" "elisp-mono"))
218 (let ((texi (expand-file-name "doc/lispref/elisp.texi" root))) 255 (manual-html-mono elisp (expand-file-name "elisp.html" html-mono-dir)))
219 (manual-html-node texi (expand-file-name "elisp" html-node-dir)) 256 (if (member type '(nil "elisp" "elisp-pdf" "pdf"))
220 (manual-html-mono texi (expand-file-name "elisp.html" html-mono-dir)) 257 (manual-pdf elisp (expand-file-name "elisp.pdf" pdf-dir)))
221 (manual-pdf texi (expand-file-name "elisp.pdf" dest)) 258 (if (member type '(nil "elisp" "elisp-ps" "ps"))
222 (manual-ps texi (expand-file-name "elisp.ps" ps-dir))) 259 (manual-ps elisp (expand-file-name "elisp.ps" ps-dir)))
223 (let ((texi (expand-file-name "doc/lispintro/emacs-lisp-intro.texi" root)) 260 (if (member type '(nil "eintr" "eintr-node"))
224 (dest (expand-file-name "emacs-lisp-intro" dest)) 261 (manual-html-node eintr (expand-file-name "eintr" html-node-dir)))
225 dest2) 262 (if (member type '(nil "eintr" "eintr-node"))
226 ;; Mimic the atypical directory layout used for emacs-lisp-intro. 263 (manual-html-mono eintr (expand-file-name "eintr.html" html-mono-dir)))
227 (make-directory dest) 264 (if (member type '(nil "eintr" "eintr-pdf" "pdf"))
228 (make-directory (setq dest2 (expand-file-name "html_node" dest))) 265 (manual-pdf eintr (expand-file-name "eintr.pdf" pdf-dir)))
229 (manual-html-node texi dest2) 266 (if (member type '(nil "eintr" "eintr-ps" "ps"))
230 (make-directory (setq dest2 (expand-file-name "html_mono" dest))) 267 (manual-ps eintr (expand-file-name "eintr.ps" ps-dir)))
231 (manual-html-mono texi (expand-file-name "emacs-lisp-intro.html" dest2))
232 (manual-pdf texi (expand-file-name "emacs-lisp-intro.pdf" dest))
233 (make-directory (setq dest2 (expand-file-name "ps" dest)))
234 (manual-ps texi (expand-file-name "emacs-lisp-intro.ps" dest2)))
235 ;; Misc manuals 268 ;; Misc manuals
236 (let ((manuals '("ada-mode" "auth" "autotype" "bovine" "calc" "cc-mode" 269 (dolist (manual misc)
237 "cl" "dbus" "dired-x" "ebrowse" "ede" "ediff" 270 (if (member type `(nil ,manual "misc"))
238 "edt" "eieio" "emacs-gnutls" "emacs-mime" "epa" "erc" "ert" 271 (manual-misc-html manual root html-node-dir html-mono-dir)))
239 "eshell" "eudc" "faq" "flymake" "forms"
240 "gnus" "htmlfontify" "idlwave" "info"
241 "mairix-el" "message" "mh-e" "newsticker"
242 "nxml-mode" "org" "pcl-cvs" "pgg" "rcirc"
243 "reftex" "remember" "sasl" "sc" "semantic"
244 "ses" "sieve" "smtpmail" "speedbar" "srecode" "tramp"
245 "url" "vip" "viper" "widget" "wisent" "woman")))
246 (dolist (manual manuals)
247 (manual-misc-html manual root html-node-dir html-mono-dir)))
248 (message "Manuals created in %s" dest))) 272 (message "Manuals created in %s" dest)))
249 273
250(defconst manual-doctype-string 274(defconst manual-doctype-string
@@ -259,10 +283,15 @@ Root must be the root of an Emacs source tree."
259<meta name=\"DC.title\" content=\"gnu.org\">\n\n") 283<meta name=\"DC.title\" content=\"gnu.org\">\n\n")
260 284
261(defconst manual-style-string "<style type=\"text/css\"> 285(defconst manual-style-string "<style type=\"text/css\">
262@import url('/s/emacs/manual.css');\n</style>\n") 286@import url('/software/emacs/manual.css');\n</style>\n")
263 287
264(defun manual-misc-html (name root html-node-dir html-mono-dir) 288(defun manual-misc-html (name root html-node-dir html-mono-dir)
265 (let ((texi (expand-file-name (format "doc/misc/%s.texi" name) root))) 289 ;; Hack to deal with the cases where .texi creates a different .info.
290 ;; Blech. TODO Why not just rename the .texi files?
291 (let* ((texiname (cond ((equal name "ccmode") "cc-mode")
292 ((equal name "efaq") "faq")
293 (t name)))
294 (texi (expand-file-name (format "doc/misc/%s.texi" texiname) root)))
266 (manual-html-node texi (expand-file-name name html-node-dir)) 295 (manual-html-node texi (expand-file-name name html-node-dir))
267 (manual-html-mono texi (expand-file-name (concat name ".html") 296 (manual-html-mono texi (expand-file-name (concat name ".html")
268 html-mono-dir)))) 297 html-mono-dir))))
@@ -272,6 +301,7 @@ Root must be the root of an Emacs source tree."
272This function also edits the HTML files so that they validate as 301This function also edits the HTML files so that they validate as
273HTML 4.01 Transitional, and pulls in the gnu.org stylesheet using 302HTML 4.01 Transitional, and pulls in the gnu.org stylesheet using
274the @import directive." 303the @import directive."
304 (make-directory (or (file-name-directory dest) ".") t)
275 (call-process "makeinfo" nil nil nil 305 (call-process "makeinfo" nil nil nil
276 "-D" "WWW_GNU_ORG" 306 "-D" "WWW_GNU_ORG"
277 "-I" (expand-file-name "../emacs" 307 "-I" (expand-file-name "../emacs"
@@ -298,6 +328,7 @@ HTML 4.01 Transitional, and pulls in the gnu.org stylesheet using
298the @import directive." 328the @import directive."
299 (unless (file-exists-p texi-file) 329 (unless (file-exists-p texi-file)
300 (error "Manual file %s not found" texi-file)) 330 (error "Manual file %s not found" texi-file))
331 (make-directory dir t)
301 (call-process "makeinfo" nil nil nil 332 (call-process "makeinfo" nil nil nil
302 "-D" "WWW_GNU_ORG" 333 "-D" "WWW_GNU_ORG"
303 "-I" (expand-file-name "../emacs" 334 "-I" (expand-file-name "../emacs"
@@ -334,6 +365,7 @@ the @import directive."
334 365
335(defun manual-pdf (texi-file dest) 366(defun manual-pdf (texi-file dest)
336 "Run texi2pdf on TEXI-FILE, emitting pdf output to DEST." 367 "Run texi2pdf on TEXI-FILE, emitting pdf output to DEST."
368 (make-directory (or (file-name-directory dest) ".") t)
337 (let ((default-directory (file-name-directory texi-file))) 369 (let ((default-directory (file-name-directory texi-file)))
338 (call-process "texi2pdf" nil nil nil 370 (call-process "texi2pdf" nil nil nil
339 "-I" "../emacs" "-I" "../misc" 371 "-I" "../emacs" "-I" "../misc"
@@ -341,6 +373,7 @@ the @import directive."
341 373
342(defun manual-ps (texi-file dest) 374(defun manual-ps (texi-file dest)
343 "Generate a PostScript version of TEXI-FILE as DEST." 375 "Generate a PostScript version of TEXI-FILE as DEST."
376 (make-directory (or (file-name-directory dest) ".") t)
344 (let ((dvi-dest (concat (file-name-sans-extension dest) ".dvi")) 377 (let ((dvi-dest (concat (file-name-sans-extension dest) ".dvi"))
345 (default-directory (file-name-directory texi-file))) 378 (default-directory (file-name-directory texi-file)))
346 (call-process "texi2dvi" nil nil nil 379 (call-process "texi2dvi" nil nil nil
@@ -452,7 +485,8 @@ the @import directive."
452 (setq done t)) 485 (setq done t))
453 (t 486 (t
454 (if (eobp) 487 (if (eobp)
455 (error "Parse error in %s" f)) ; f is bound in manual-html-node 488 (error "Parse error in %s"
489 (file-name-nondirectory buffer-file-name)))
456 (unless open-td 490 (unless open-td
457 (setq done t)))) 491 (setq done t))))
458 (forward-line 1)))) 492 (forward-line 1))))
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index c8bfe0dacc3..82e0cd77fca 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -29,11 +29,11 @@ GNULIB_MODULES='
29 alloca-opt c-ctype c-strcase 29 alloca-opt c-ctype c-strcase
30 careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 30 careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
31 dtoastr dtotimespec dup2 environ execinfo faccessat 31 dtoastr dtotimespec dup2 environ execinfo faccessat
32 fcntl-h fdatasync fdopendir filemode fstatat fsync 32 fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync
33 getloadavg getopt-gnu gettime gettimeofday 33 getloadavg getopt-gnu gettime gettimeofday
34 ignore-value intprops largefile lstat 34 intprops largefile lstat
35 manywarnings memrchr mktime 35 manywarnings memrchr mktime
36 pselect pthread_sigmask putenv qacl readlink readlinkat 36 pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat
37 sig2str socklen stat-time stdalign stdarg stdbool stdio 37 sig2str socklen stat-time stdalign stdarg stdbool stdio
38 strftime strtoimax strtoumax symlink sys_stat 38 strftime strtoimax strtoumax symlink sys_stat
39 sys_time time timer-time timespec-add timespec-sub unsetenv utimens 39 sys_time time timer-time timespec-add timespec-sub unsetenv utimens
@@ -41,8 +41,8 @@ GNULIB_MODULES='
41' 41'
42 42
43GNULIB_TOOL_FLAGS=' 43GNULIB_TOOL_FLAGS='
44 --avoid=dup 44 --avoid=close --avoid=dup
45 --avoid=fchdir --avoid=fcntl --avoid=fstat 45 --avoid=fchdir --avoid=fstat
46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow 46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow
47 --avoid=open --avoid=openat-die --avoid=opendir 47 --avoid=open --avoid=openat-die --avoid=opendir
48 --avoid=raise 48 --avoid=raise
diff --git a/admin/notes/changelogs b/admin/notes/changelogs
index ae9ce40aa0a..1025cfc217f 100644
--- a/admin/notes/changelogs
+++ b/admin/notes/changelogs
@@ -3,9 +3,10 @@ entry in their name, not yours.
3 3
4 4
5http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00793.html 5http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00793.html
6http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg00485.html 6 There is no need to make change log entries for files such as NEWS,
7 There is no need to make trivial change log entries for files such 7 MAINTAINERS, and FOR-RELEASE.
8 as NEWS, MAINTAINERS, and FOR-RELEASE. 8"There is no need" means you don't have to, but you can if you want to.
9
9 10
10http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01135.html 11http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01135.html
11 There is no need to indicate regeneration of files such as configure 12 There is no need to indicate regeneration of files such as configure
diff --git a/autogen/Makefile.in b/autogen/Makefile.in
index 99805dd1fe8..d471a9eeb18 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -59,7 +59,7 @@
59# the same distribution terms as the rest of that program. 59# the same distribution terms as the rest of that program.
60# 60#
61# Generated by gnulib-tool. 61# Generated by gnulib-tool.
62# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dup --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings memrchr mktime pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 62# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
63 63
64VPATH = @srcdir@ 64VPATH = @srcdir@
65pkgdatadir = $(datadir)/@PACKAGE@ 65pkgdatadir = $(datadir)/@PACKAGE@
@@ -192,19 +192,20 @@ DIST_COMMON = $(srcdir)/../nt/gnulib.mk $(srcdir)/Makefile.am \
192@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.h dup2.c errno.in.h \ 192@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.h dup2.c errno.in.h \
193@BUILDING_FOR_WINDOWSNT_FALSE@ euidaccess.c execinfo.c \ 193@BUILDING_FOR_WINDOWSNT_FALSE@ euidaccess.c execinfo.c \
194@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.in.h at-func.c \ 194@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.in.h at-func.c \
195@BUILDING_FOR_WINDOWSNT_FALSE@ faccessat.c fcntl.in.h \ 195@BUILDING_FOR_WINDOWSNT_FALSE@ faccessat.c fcntl.c fcntl.in.h \
196@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \ 196@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \
197@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.h fpending.c fpending.h \ 197@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.h fpending.c fpending.h \
198@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c fstatat.c fsync.c \ 198@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c fstatat.c fsync.c \
199@BUILDING_FOR_WINDOWSNT_FALSE@ getgroups.c getloadavg.c \ 199@BUILDING_FOR_WINDOWSNT_FALSE@ getdtablesize.c getgroups.c \
200@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt.in.h getopt1.c \ 200@BUILDING_FOR_WINDOWSNT_FALSE@ getloadavg.c getopt.c \
201@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.in.h getopt1.c \
201@BUILDING_FOR_WINDOWSNT_FALSE@ getopt_int.h gettimeofday.c \ 202@BUILDING_FOR_WINDOWSNT_FALSE@ getopt_int.h gettimeofday.c \
202@BUILDING_FOR_WINDOWSNT_FALSE@ group-member.c ignore-value.h \ 203@BUILDING_FOR_WINDOWSNT_FALSE@ group-member.c intprops.h \
203@BUILDING_FOR_WINDOWSNT_FALSE@ intprops.h inttypes.in.h lstat.c \ 204@BUILDING_FOR_WINDOWSNT_FALSE@ inttypes.in.h lstat.c memrchr.c \
204@BUILDING_FOR_WINDOWSNT_FALSE@ memrchr.c mktime-internal.h \ 205@BUILDING_FOR_WINDOWSNT_FALSE@ mktime-internal.h mktime.c \
205@BUILDING_FOR_WINDOWSNT_FALSE@ mktime.c openat.h pathmax.h \ 206@BUILDING_FOR_WINDOWSNT_FALSE@ openat.h pathmax.h pselect.c \
206@BUILDING_FOR_WINDOWSNT_FALSE@ pselect.c pthread_sigmask.c \ 207@BUILDING_FOR_WINDOWSNT_FALSE@ pthread_sigmask.c putenv.c \
207@BUILDING_FOR_WINDOWSNT_FALSE@ putenv.c acl-internal.h acl.h \ 208@BUILDING_FOR_WINDOWSNT_FALSE@ acl-internal.h acl.h \
208@BUILDING_FOR_WINDOWSNT_FALSE@ acl_entries.c readlink.c \ 209@BUILDING_FOR_WINDOWSNT_FALSE@ acl_entries.c readlink.c \
209@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c readlinkat.c \ 210@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c readlinkat.c \
210@BUILDING_FOR_WINDOWSNT_FALSE@ root-uid.h sig2str.c sig2str.h \ 211@BUILDING_FOR_WINDOWSNT_FALSE@ root-uid.h sig2str.c sig2str.h \
@@ -239,10 +240,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
239 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/euidaccess.m4 \ 240 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/euidaccess.m4 \
240 $(top_srcdir)/m4/execinfo.m4 $(top_srcdir)/m4/extensions.m4 \ 241 $(top_srcdir)/m4/execinfo.m4 $(top_srcdir)/m4/extensions.m4 \
241 $(top_srcdir)/m4/extern-inline.m4 \ 242 $(top_srcdir)/m4/extern-inline.m4 \
242 $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fcntl_h.m4 \ 243 $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fcntl.m4 \
243 $(top_srcdir)/m4/fdatasync.m4 $(top_srcdir)/m4/fdopendir.m4 \ 244 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdatasync.m4 \
244 $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/fpending.m4 \ 245 $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/filemode.m4 \
245 $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/fsync.m4 \ 246 $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fstatat.m4 \
247 $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/getdtablesize.m4 \
246 $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/getloadavg.m4 \ 248 $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/getloadavg.m4 \
247 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \ 249 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
248 $(top_srcdir)/m4/gettimeofday.m4 \ 250 $(top_srcdir)/m4/gettimeofday.m4 \
@@ -255,7 +257,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
255 $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memrchr.m4 \ 257 $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memrchr.m4 \
256 $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/multiarch.m4 \ 258 $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/multiarch.m4 \
257 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ 259 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
258 $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/pselect.m4 \ 260 $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/pipe2.m4 \
261 $(top_srcdir)/m4/pselect.m4 \
259 $(top_srcdir)/m4/pthread_sigmask.m4 $(top_srcdir)/m4/putenv.m4 \ 262 $(top_srcdir)/m4/pthread_sigmask.m4 $(top_srcdir)/m4/putenv.m4 \
260 $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ 263 $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \
261 $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/sha1.m4 \ 264 $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/sha1.m4 \
@@ -288,16 +291,18 @@ CONFIG_CLEAN_VPATH_FILES =
288LIBRARIES = $(noinst_LIBRARIES) 291LIBRARIES = $(noinst_LIBRARIES)
289libgnu_a_AR = $(AR) $(ARFLAGS) 292libgnu_a_AR = $(AR) $(ARFLAGS)
290am__DEPENDENCIES_1 = 293am__DEPENDENCIES_1 =
291am__libgnu_a_SOURCES_DIST = allocator.c c-ctype.h c-ctype.c \ 294am__libgnu_a_SOURCES_DIST = allocator.c binary-io.h binary-io.c \
292 c-strcase.h c-strcasecmp.c c-strncasecmp.c careadlinkat.c \ 295 c-ctype.h c-ctype.c c-strcase.h c-strcasecmp.c c-strncasecmp.c \
293 close-stream.c md5.c sha1.c sha256.c sha512.c dtoastr.c \ 296 careadlinkat.c close-stream.c md5.c sha1.c sha256.c sha512.c \
294 dtotimespec.c filemode.c gettext.h gettime.c acl-errno-valid.c \ 297 dtoastr.c dtotimespec.c filemode.c gettext.h gettime.c pipe2.c \
295 file-has-acl.c qcopy-acl.c qset-acl.c stat-time.c strftime.c \ 298 acl-errno-valid.c file-has-acl.c qcopy-acl.c qset-acl.c \
296 timespec.c timespec-add.c timespec-sub.c u64.c unistd.c \ 299 stat-time.c strftime.c timespec.c timespec-add.c \
297 utimens.c openat-die.c save-cwd.c 300 timespec-sub.c u64.c unistd.c utimens.c openat-die.c \
301 save-cwd.c
298am__objects_1 = 302am__objects_1 =
299@BUILDING_FOR_WINDOWSNT_FALSE@am_libgnu_a_OBJECTS = \ 303@BUILDING_FOR_WINDOWSNT_FALSE@am_libgnu_a_OBJECTS = \
300@BUILDING_FOR_WINDOWSNT_FALSE@ allocator.$(OBJEXT) \ 304@BUILDING_FOR_WINDOWSNT_FALSE@ allocator.$(OBJEXT) \
305@BUILDING_FOR_WINDOWSNT_FALSE@ binary-io.$(OBJEXT) \
301@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.$(OBJEXT) \ 306@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.$(OBJEXT) \
302@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.$(OBJEXT) \ 307@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.$(OBJEXT) \
303@BUILDING_FOR_WINDOWSNT_FALSE@ c-strncasecmp.$(OBJEXT) \ 308@BUILDING_FOR_WINDOWSNT_FALSE@ c-strncasecmp.$(OBJEXT) \
@@ -311,6 +316,7 @@ am__objects_1 =
311@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.$(OBJEXT) \ 316@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.$(OBJEXT) \
312@BUILDING_FOR_WINDOWSNT_FALSE@ $(am__objects_1) \ 317@BUILDING_FOR_WINDOWSNT_FALSE@ $(am__objects_1) \
313@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.$(OBJEXT) \ 318@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.$(OBJEXT) \
319@BUILDING_FOR_WINDOWSNT_FALSE@ pipe2.$(OBJEXT) \
314@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.$(OBJEXT) \ 320@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.$(OBJEXT) \
315@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.$(OBJEXT) \ 321@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.$(OBJEXT) \
316@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.$(OBJEXT) \ 322@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.$(OBJEXT) \
@@ -346,13 +352,13 @@ am__objects_1 =
346@BUILDING_FOR_WINDOWSNT_TRUE@ u64.$(OBJEXT) utimens.$(OBJEXT) \ 352@BUILDING_FOR_WINDOWSNT_TRUE@ u64.$(OBJEXT) utimens.$(OBJEXT) \
347@BUILDING_FOR_WINDOWSNT_TRUE@ $(am__objects_1) 353@BUILDING_FOR_WINDOWSNT_TRUE@ $(am__objects_1)
348am__EXTRA_libgnu_a_SOURCES_DIST = openat-proc.c ftoastr.c dup2.c \ 354am__EXTRA_libgnu_a_SOURCES_DIST = openat-proc.c ftoastr.c dup2.c \
349 euidaccess.c execinfo.c at-func.c faccessat.c fdatasync.c \ 355 euidaccess.c execinfo.c at-func.c faccessat.c fcntl.c \
350 fdopendir.c fpending.c fstatat.c fsync.c getgroups.c \ 356 fdatasync.c fdopendir.c fpending.c fstatat.c fsync.c \
351 getloadavg.c getopt.c getopt1.c gettimeofday.c group-member.c \ 357 getdtablesize.c getgroups.c getloadavg.c getopt.c getopt1.c \
352 lstat.c memrchr.c mktime.c pselect.c pthread_sigmask.c \ 358 gettimeofday.c group-member.c lstat.c memrchr.c mktime.c \
353 putenv.c acl_entries.c readlink.c readlinkat.c sig2str.c \ 359 pselect.c pthread_sigmask.c putenv.c acl_entries.c readlink.c \
354 stat.c strtoimax.c strtol.c strtoll.c strtoul.c strtoull.c \ 360 readlinkat.c sig2str.c stat.c strtoimax.c strtol.c strtoll.c \
355 strtoumax.c symlink.c time_r.c unsetenv.c 361 strtoul.c strtoull.c strtoumax.c symlink.c time_r.c unsetenv.c
356libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS) 362libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
357depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp 363depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
358am__depfiles_maybe = depfiles 364am__depfiles_maybe = depfiles
@@ -1230,20 +1236,22 @@ noinst_LIBRARIES = $(am__append_2) $(am__append_7)
1230SUFFIXES = 1236SUFFIXES =
1231AM_CFLAGS = $(PROFILING_CFLAGS) $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) 1237AM_CFLAGS = $(PROFILING_CFLAGS) $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
1232DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src 1238DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src
1233@BUILDING_FOR_WINDOWSNT_FALSE@libgnu_a_SOURCES = allocator.c c-ctype.h \ 1239@BUILDING_FOR_WINDOWSNT_FALSE@libgnu_a_SOURCES = allocator.c \
1234@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.c c-strcase.h \ 1240@BUILDING_FOR_WINDOWSNT_FALSE@ binary-io.h binary-io.c \
1241@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.h c-ctype.c c-strcase.h \
1235@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.c c-strncasecmp.c \ 1242@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.c c-strncasecmp.c \
1236@BUILDING_FOR_WINDOWSNT_FALSE@ careadlinkat.c close-stream.c \ 1243@BUILDING_FOR_WINDOWSNT_FALSE@ careadlinkat.c close-stream.c \
1237@BUILDING_FOR_WINDOWSNT_FALSE@ md5.c sha1.c sha256.c sha512.c \ 1244@BUILDING_FOR_WINDOWSNT_FALSE@ md5.c sha1.c sha256.c sha512.c \
1238@BUILDING_FOR_WINDOWSNT_FALSE@ dtoastr.c dtotimespec.c \ 1245@BUILDING_FOR_WINDOWSNT_FALSE@ dtoastr.c dtotimespec.c \
1239@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.c $(am__append_10) \ 1246@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.c $(am__append_10) \
1240@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.c acl-errno-valid.c \ 1247@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.c pipe2.c \
1241@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.c qcopy-acl.c \ 1248@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.c file-has-acl.c \
1242@BUILDING_FOR_WINDOWSNT_FALSE@ qset-acl.c stat-time.c \ 1249@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.c qset-acl.c \
1243@BUILDING_FOR_WINDOWSNT_FALSE@ strftime.c timespec.c \ 1250@BUILDING_FOR_WINDOWSNT_FALSE@ stat-time.c strftime.c \
1244@BUILDING_FOR_WINDOWSNT_FALSE@ timespec-add.c timespec-sub.c \ 1251@BUILDING_FOR_WINDOWSNT_FALSE@ timespec.c timespec-add.c \
1245@BUILDING_FOR_WINDOWSNT_FALSE@ u64.c unistd.c utimens.c \ 1252@BUILDING_FOR_WINDOWSNT_FALSE@ timespec-sub.c u64.c unistd.c \
1246@BUILDING_FOR_WINDOWSNT_FALSE@ openat-die.c save-cwd.c 1253@BUILDING_FOR_WINDOWSNT_FALSE@ utimens.c openat-die.c \
1254@BUILDING_FOR_WINDOWSNT_FALSE@ save-cwd.c
1247@BUILDING_FOR_WINDOWSNT_TRUE@libgnu_a_SOURCES = c-ctype.h c-ctype.c \ 1255@BUILDING_FOR_WINDOWSNT_TRUE@libgnu_a_SOURCES = c-ctype.h c-ctype.c \
1248@BUILDING_FOR_WINDOWSNT_TRUE@ c-strcase.h c-strcasecmp.c \ 1256@BUILDING_FOR_WINDOWSNT_TRUE@ c-strcase.h c-strcasecmp.c \
1249@BUILDING_FOR_WINDOWSNT_TRUE@ c-strncasecmp.c close-stream.c \ 1257@BUILDING_FOR_WINDOWSNT_TRUE@ c-strncasecmp.c close-stream.c \
@@ -1262,9 +1270,10 @@ DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src
1262@BUILDING_FOR_WINDOWSNT_FALSE@EXTRA_libgnu_a_SOURCES = openat-proc.c \ 1270@BUILDING_FOR_WINDOWSNT_FALSE@EXTRA_libgnu_a_SOURCES = openat-proc.c \
1263@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.c dup2.c euidaccess.c \ 1271@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.c dup2.c euidaccess.c \
1264@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.c at-func.c faccessat.c \ 1272@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.c at-func.c faccessat.c \
1265@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \ 1273@BUILDING_FOR_WINDOWSNT_FALSE@ fcntl.c fdatasync.c fdopendir.c \
1266@BUILDING_FOR_WINDOWSNT_FALSE@ fpending.c at-func.c fstatat.c \ 1274@BUILDING_FOR_WINDOWSNT_FALSE@ fpending.c at-func.c fstatat.c \
1267@BUILDING_FOR_WINDOWSNT_FALSE@ fsync.c getgroups.c getloadavg.c \ 1275@BUILDING_FOR_WINDOWSNT_FALSE@ fsync.c getdtablesize.c \
1276@BUILDING_FOR_WINDOWSNT_FALSE@ getgroups.c getloadavg.c \
1268@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt1.c \ 1277@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt1.c \
1269@BUILDING_FOR_WINDOWSNT_FALSE@ gettimeofday.c group-member.c \ 1278@BUILDING_FOR_WINDOWSNT_FALSE@ gettimeofday.c group-member.c \
1270@BUILDING_FOR_WINDOWSNT_FALSE@ lstat.c memrchr.c mktime.c \ 1279@BUILDING_FOR_WINDOWSNT_FALSE@ lstat.c memrchr.c mktime.c \
@@ -1361,6 +1370,7 @@ distclean-compile:
1361@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@ 1370@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@
1362@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocator.Po@am__quote@ 1371@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocator.Po@am__quote@
1363@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@ 1372@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@
1373@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binary-io.Po@am__quote@
1364@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Po@am__quote@ 1374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Po@am__quote@
1365@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Po@am__quote@ 1375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Po@am__quote@
1366@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Po@am__quote@ 1376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Po@am__quote@
@@ -1372,6 +1382,7 @@ distclean-compile:
1372@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/euidaccess.Po@am__quote@ 1382@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/euidaccess.Po@am__quote@
1373@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execinfo.Po@am__quote@ 1383@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execinfo.Po@am__quote@
1374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faccessat.Po@am__quote@ 1384@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faccessat.Po@am__quote@
1385@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@
1375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdatasync.Po@am__quote@ 1386@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdatasync.Po@am__quote@
1376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@ 1387@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@
1377@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@ 1388@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@
@@ -1380,6 +1391,7 @@ distclean-compile:
1380@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@ 1391@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@
1381@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsync.Po@am__quote@ 1392@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsync.Po@am__quote@
1382@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ 1393@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
1394@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdtablesize.Po@am__quote@
1383@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgroups.Po@am__quote@ 1395@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgroups.Po@am__quote@
1384@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@ 1396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@
1385@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ 1397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@@ -1393,6 +1405,7 @@ distclean-compile:
1393@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@ 1405@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
1394@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@ 1406@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@
1395@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@ 1407@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@
1408@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe2.Po@am__quote@
1396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pselect.Po@am__quote@ 1409@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pselect.Po@am__quote@
1397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_sigmask.Po@am__quote@ 1410@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_sigmask.Po@am__quote@
1398@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putenv.Po@am__quote@ 1411@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putenv.Po@am__quote@
diff --git a/autogen/aclocal.m4 b/autogen/aclocal.m4
index eb324b06b37..c9e796a081f 100644
--- a/autogen/aclocal.m4
+++ b/autogen/aclocal.m4
@@ -999,6 +999,7 @@ m4_include([m4/execinfo.m4])
999m4_include([m4/extensions.m4]) 999m4_include([m4/extensions.m4])
1000m4_include([m4/extern-inline.m4]) 1000m4_include([m4/extern-inline.m4])
1001m4_include([m4/faccessat.m4]) 1001m4_include([m4/faccessat.m4])
1002m4_include([m4/fcntl.m4])
1002m4_include([m4/fcntl_h.m4]) 1003m4_include([m4/fcntl_h.m4])
1003m4_include([m4/fdatasync.m4]) 1004m4_include([m4/fdatasync.m4])
1004m4_include([m4/fdopendir.m4]) 1005m4_include([m4/fdopendir.m4])
@@ -1006,6 +1007,7 @@ m4_include([m4/filemode.m4])
1006m4_include([m4/fpending.m4]) 1007m4_include([m4/fpending.m4])
1007m4_include([m4/fstatat.m4]) 1008m4_include([m4/fstatat.m4])
1008m4_include([m4/fsync.m4]) 1009m4_include([m4/fsync.m4])
1010m4_include([m4/getdtablesize.m4])
1009m4_include([m4/getgroups.m4]) 1011m4_include([m4/getgroups.m4])
1010m4_include([m4/getloadavg.m4]) 1012m4_include([m4/getloadavg.m4])
1011m4_include([m4/getopt.m4]) 1013m4_include([m4/getopt.m4])
@@ -1027,6 +1029,7 @@ m4_include([m4/multiarch.m4])
1027m4_include([m4/nocrash.m4]) 1029m4_include([m4/nocrash.m4])
1028m4_include([m4/off_t.m4]) 1030m4_include([m4/off_t.m4])
1029m4_include([m4/pathmax.m4]) 1031m4_include([m4/pathmax.m4])
1032m4_include([m4/pipe2.m4])
1030m4_include([m4/pselect.m4]) 1033m4_include([m4/pselect.m4])
1031m4_include([m4/pthread_sigmask.m4]) 1034m4_include([m4/pthread_sigmask.m4])
1032m4_include([m4/putenv.m4]) 1035m4_include([m4/putenv.m4])
diff --git a/autogen/config.in b/autogen/config.in
index 94185b160ca..3fe82ce0f92 100644
--- a/autogen/config.in
+++ b/autogen/config.in
@@ -90,9 +90,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
90/* Name of the default sound device. */ 90/* Name of the default sound device. */
91#undef DEFAULT_SOUND_DEVICE 91#undef DEFAULT_SOUND_DEVICE
92 92
93/* Character that separates a device in a file name. */
94#undef DEVICE_SEP
95
96/* Define to 1 for DGUX with <sys/dg_sys_info.h>. */ 93/* Define to 1 for DGUX with <sys/dg_sys_info.h>. */
97#undef DGUX 94#undef DGUX
98 95
@@ -123,6 +120,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
123 enabled. */ 120 enabled. */
124#undef ENABLE_CHECKING 121#undef ENABLE_CHECKING
125 122
123/* Define this to 1 if F_DUPFD behavior does not match POSIX */
124#undef FCNTL_DUPFD_BUGGY
125
126/* Letter to use in finding device name of first PTY, if PTYs are supported. 126/* Letter to use in finding device name of first PTY, if PTYs are supported.
127 */ 127 */
128#undef FIRST_PTY_LETTER 128#undef FIRST_PTY_LETTER
@@ -209,6 +209,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
209 startup, if using GTK. */ 209 startup, if using GTK. */
210#undef G_SLICE_ALWAYS_MALLOC 210#undef G_SLICE_ALWAYS_MALLOC
211 211
212/* Define to 1 if you have the `accept4' function. */
213#undef HAVE_ACCEPT4
214
212/* Define to 1 if you have the `access' function. */ 215/* Define to 1 if you have the `access' function. */
213#undef HAVE_ACCESS 216#undef HAVE_ACCESS
214 217
@@ -281,9 +284,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
281/* Define to 1 if the ACL type ACL_TYPE_EXTENDED exists. */ 284/* Define to 1 if the ACL type ACL_TYPE_EXTENDED exists. */
282#undef HAVE_ACL_TYPE_EXTENDED 285#undef HAVE_ACL_TYPE_EXTENDED
283 286
284/* Define to 1 if the file /usr/lpp/X11/bin/smt.exp exists. */
285#undef HAVE_AIX_SMT_EXP
286
287/* Define to 1 if you have 'alloca' after including <alloca.h>, a header that 287/* Define to 1 if you have 'alloca' after including <alloca.h>, a header that
288 may be supplied by this distribution. */ 288 may be supplied by this distribution. */
289#undef HAVE_ALLOCA 289#undef HAVE_ALLOCA
@@ -412,12 +412,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
412 don't. */ 412 don't. */
413#undef HAVE_DECL___SYS_SIGLIST 413#undef HAVE_DECL___SYS_SIGLIST
414 414
415/* Define to 1 if you have the <des.h> header file. */
416#undef HAVE_DES_H
417
418/* Define to 1 if dynamic ptys are supported. */
419#undef HAVE_DEV_PTMX
420
421/* Define to 1 if you have the `difftime' function. */ 415/* Define to 1 if you have the `difftime' function. */
422#undef HAVE_DIFFTIME 416#undef HAVE_DIFFTIME
423 417
@@ -451,6 +445,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
451/* Define to 1 if you have the `facl' function. */ 445/* Define to 1 if you have the `facl' function. */
452#undef HAVE_FACL 446#undef HAVE_FACL
453 447
448/* Define to 1 if you have the `fcntl' function. */
449#undef HAVE_FCNTL
450
454/* Define to 1 if you have the `fdatasync' function. */ 451/* Define to 1 if you have the `fdatasync' function. */
455#undef HAVE_FDATASYNC 452#undef HAVE_FDATASYNC
456 453
@@ -499,6 +496,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
499/* Define to 1 if you have the `getdelim' function. */ 496/* Define to 1 if you have the `getdelim' function. */
500#undef HAVE_GETDELIM 497#undef HAVE_GETDELIM
501 498
499/* Define to 1 if you have the `getdtablesize' function. */
500#undef HAVE_GETDTABLESIZE
501
502/* Define to 1 if you have the `getgrent' function. */ 502/* Define to 1 if you have the `getgrent' function. */
503#undef HAVE_GETGRENT 503#undef HAVE_GETGRENT
504 504
@@ -559,13 +559,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
559/* Define if using GnuTLS. */ 559/* Define if using GnuTLS. */
560#undef HAVE_GNUTLS 560#undef HAVE_GNUTLS
561 561
562/* Define if using GnuTLS certificate verification callbacks. */
563#undef HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY
564
565/* Define to 1 if you have the `gnutls_certificate_set_verify_function'
566 function. */
567#undef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION
568
569/* Define to 1 if you have the gpm library (-lgpm). */ 562/* Define to 1 if you have the gpm library (-lgpm). */
570#undef HAVE_GPM 563#undef HAVE_GPM
571 564
@@ -635,15 +628,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
635/* Define to 1 if you have the jpeg library (-ljpeg). */ 628/* Define to 1 if you have the jpeg library (-ljpeg). */
636#undef HAVE_JPEG 629#undef HAVE_JPEG
637 630
638/* Define to 1 if you have the <kerberosIV/des.h> header file. */
639#undef HAVE_KERBEROSIV_DES_H
640
641/* Define to 1 if you have the <kerberosIV/krb.h> header file. */ 631/* Define to 1 if you have the <kerberosIV/krb.h> header file. */
642#undef HAVE_KERBEROSIV_KRB_H 632#undef HAVE_KERBEROSIV_KRB_H
643 633
644/* Define to 1 if you have the <kerberos/des.h> header file. */
645#undef HAVE_KERBEROS_DES_H
646
647/* Define to 1 if you have the <kerberos/krb.h> header file. */ 634/* Define to 1 if you have the <kerberos/krb.h> header file. */
648#undef HAVE_KERBEROS_KRB_H 635#undef HAVE_KERBEROS_KRB_H
649 636
@@ -662,18 +649,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
662/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ 649/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
663#undef HAVE_LANGINFO_CODESET 650#undef HAVE_LANGINFO_CODESET
664 651
665/* Define to 1 if you have the `com_err' library (-lcom_err). */
666#undef HAVE_LIBCOM_ERR
667
668/* Define to 1 if you have the `crypto' library (-lcrypto). */
669#undef HAVE_LIBCRYPTO
670
671/* Define to 1 if you have the `des' library (-ldes). */
672#undef HAVE_LIBDES
673
674/* Define to 1 if you have the `des425' library (-ldes425). */
675#undef HAVE_LIBDES425
676
677/* Define to 1 if you have the `dgc' library (-ldgc). */ 652/* Define to 1 if you have the `dgc' library (-ldgc). */
678#undef HAVE_LIBDGC 653#undef HAVE_LIBDGC
679 654
@@ -683,21 +658,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
683/* Define to 1 if you have the <libgen.h> header file. */ 658/* Define to 1 if you have the <libgen.h> header file. */
684#undef HAVE_LIBGEN_H 659#undef HAVE_LIBGEN_H
685 660
686/* Define to 1 if you have the hesiod library (-lhesiod). */
687#undef HAVE_LIBHESIOD
688
689/* Define to 1 if you have the `k5crypto' library (-lk5crypto). */
690#undef HAVE_LIBK5CRYPTO
691
692/* Define to 1 if you have the `krb' library (-lkrb). */
693#undef HAVE_LIBKRB
694
695/* Define to 1 if you have the `krb4' library (-lkrb4). */
696#undef HAVE_LIBKRB4
697
698/* Define to 1 if you have the `krb5' library (-lkrb5). */
699#undef HAVE_LIBKRB5
700
701/* Define to 1 if you have the `kstat' library (-lkstat). */ 661/* Define to 1 if you have the `kstat' library (-lkstat). */
702#undef HAVE_LIBKSTAT 662#undef HAVE_LIBKSTAT
703 663
@@ -722,9 +682,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
722/* Define to 1 if you have the `pthreads' library (-lpthreads). */ 682/* Define to 1 if you have the `pthreads' library (-lpthreads). */
723#undef HAVE_LIBPTHREADS 683#undef HAVE_LIBPTHREADS
724 684
725/* Define to 1 if you have the resolv library (-lresolv). */
726#undef HAVE_LIBRESOLV
727
728/* Define to 1 if using SELinux. */ 685/* Define to 1 if using SELinux. */
729#undef HAVE_LIBSELINUX 686#undef HAVE_LIBSELINUX
730 687
@@ -737,9 +694,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
737/* Define to 1 if you have the `Xmu' library (-lXmu). */ 694/* Define to 1 if you have the `Xmu' library (-lXmu). */
738#undef HAVE_LIBXMU 695#undef HAVE_LIBXMU
739 696
740/* Define to 1 if you have the <linux/version.h> header file. */
741#undef HAVE_LINUX_VERSION_H
742
743/* Define to 1 if you have the `localtime_r' function. */ 697/* Define to 1 if you have the `localtime_r' function. */
744#undef HAVE_LOCALTIME_R 698#undef HAVE_LOCALTIME_R
745 699
@@ -796,15 +750,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
796 systems that support xmenu.c. */ 750 systems that support xmenu.c. */
797#undef HAVE_MENUS 751#undef HAVE_MENUS
798 752
753/* Define to 1 if you have the `mkostemp' function. */
754#undef HAVE_MKOSTEMP
755
799/* Define to 1 if you have the `mkstemp' function. */ 756/* Define to 1 if you have the `mkstemp' function. */
800#undef HAVE_MKSTEMP 757#undef HAVE_MKSTEMP
801 758
802/* Define to 1 if you have a working `mmap' system call. */ 759/* Define to 1 if you have a working `mmap' system call. */
803#undef HAVE_MMAP 760#undef HAVE_MMAP
804 761
805/* Define to 1 if you have the <mmsystem.h> header file. */
806#undef HAVE_MMSYSTEM_H
807
808/* Define to 1 if you have the `nanotime' function. */ 762/* Define to 1 if you have the `nanotime' function. */
809#undef HAVE_NANOTIME 763#undef HAVE_NANOTIME
810 764
@@ -830,6 +784,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
830/* Define to 1 if personality LINUX32 can be set. */ 784/* Define to 1 if personality LINUX32 can be set. */
831#undef HAVE_PERSONALITY_LINUX32 785#undef HAVE_PERSONALITY_LINUX32
832 786
787/* Define to 1 if you have the `pipe2' function. */
788#undef HAVE_PIPE2
789
833/* Define to 1 if you have the png library (-lpng). */ 790/* Define to 1 if you have the png library (-lpng). */
834#undef HAVE_PNG 791#undef HAVE_PNG
835 792
@@ -939,9 +896,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
939/* Define to 1 if you have the <soundcard.h> header file. */ 896/* Define to 1 if you have the <soundcard.h> header file. */
940#undef HAVE_SOUNDCARD_H 897#undef HAVE_SOUNDCARD_H
941 898
942/* Define to 1 if `speed_t' is declared by <termios.h>. */
943#undef HAVE_SPEED_T
944
945/* Define to 1 if you have the `statacl' function. */ 899/* Define to 1 if you have the `statacl' function. */
946#undef HAVE_STATACL 900#undef HAVE_STATACL
947 901
@@ -1128,9 +1082,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1128/* Define to 1 if you have the `utimensat' function. */ 1082/* Define to 1 if you have the `utimensat' function. */
1129#undef HAVE_UTIMENSAT 1083#undef HAVE_UTIMENSAT
1130 1084
1131/* Define to 1 if you have the `utimes' function. */
1132#undef HAVE_UTIMES
1133
1134/* Define to 1 if you have the <utime.h> header file. */ 1085/* Define to 1 if you have the <utime.h> header file. */
1135#undef HAVE_UTIME_H 1086#undef HAVE_UTIME_H
1136 1087
@@ -1561,9 +1512,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1561/* Define if the system is compatible with System III. */ 1512/* Define if the system is compatible with System III. */
1562#undef USG 1513#undef USG
1563 1514
1564/* Define if the system is compatible with System V. */
1565#undef USG5
1566
1567/* Define if the system is compatible with System V Release 4. */ 1515/* Define if the system is compatible with System V Release 4. */
1568#undef USG5_4 1516#undef USG5_4
1569 1517
@@ -1797,9 +1745,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1797/* Define to enable asynchronous subprocesses. */ 1745/* Define to enable asynchronous subprocesses. */
1798#undef subprocesses 1746#undef subprocesses
1799 1747
1800/* Define to any substitute for sys_siglist. */
1801#undef sys_siglist
1802
1803/* Define as a marker that can be attached to declarations that might not 1748/* Define as a marker that can be attached to declarations that might not
1804 be used. This helps to reduce warnings, such as from 1749 be used. This helps to reduce warnings, such as from
1805 GCC -Wunused-parameter. */ 1750 GCC -Wunused-parameter. */
diff --git a/autogen/configure b/autogen/configure
index 4feb8ace937..50786ead7a5 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -614,8 +614,6 @@ LIBGNU_LIBDEPS
614gltests_WITNESS 614gltests_WITNESS
615gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE 615gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE
616gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE 616gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE
617gl_GNULIB_ENABLED_verify_FALSE
618gl_GNULIB_ENABLED_verify_TRUE
619gl_GNULIB_ENABLED_strtoull_FALSE 617gl_GNULIB_ENABLED_strtoull_FALSE
620gl_GNULIB_ENABLED_strtoull_TRUE 618gl_GNULIB_ENABLED_strtoull_TRUE
621gl_GNULIB_ENABLED_strtoll_FALSE 619gl_GNULIB_ENABLED_strtoll_FALSE
@@ -634,6 +632,8 @@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE
634gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE 632gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE
635gl_GNULIB_ENABLED_getgroups_FALSE 633gl_GNULIB_ENABLED_getgroups_FALSE
636gl_GNULIB_ENABLED_getgroups_TRUE 634gl_GNULIB_ENABLED_getgroups_TRUE
635gl_GNULIB_ENABLED_getdtablesize_FALSE
636gl_GNULIB_ENABLED_getdtablesize_TRUE
637gl_GNULIB_ENABLED_euidaccess_FALSE 637gl_GNULIB_ENABLED_euidaccess_FALSE
638gl_GNULIB_ENABLED_euidaccess_TRUE 638gl_GNULIB_ENABLED_euidaccess_TRUE
639gl_GNULIB_ENABLED_dosname_FALSE 639gl_GNULIB_ENABLED_dosname_FALSE
@@ -3352,7 +3352,6 @@ $as_echo "$as_me: creating cache $cache_file" >&6;}
3352 >$cache_file 3352 >$cache_file
3353fi 3353fi
3354 3354
3355as_fn_append ac_header_list " linux/version.h"
3356as_fn_append ac_header_list " sys/systeminfo.h" 3355as_fn_append ac_header_list " sys/systeminfo.h"
3357as_fn_append ac_header_list " coff.h" 3356as_fn_append ac_header_list " coff.h"
3358as_fn_append ac_header_list " pty.h" 3357as_fn_append ac_header_list " pty.h"
@@ -3374,6 +3373,7 @@ as_fn_append ac_func_list " readlinkat"
3374as_fn_append ac_header_list " dirent.h" 3373as_fn_append ac_header_list " dirent.h"
3375as_fn_append ac_header_list " execinfo.h" 3374as_fn_append ac_header_list " execinfo.h"
3376as_fn_append ac_func_list " faccessat" 3375as_fn_append ac_func_list " faccessat"
3376as_fn_append ac_func_list " fcntl"
3377as_fn_append ac_func_list " fdopendir" 3377as_fn_append ac_func_list " fdopendir"
3378as_fn_append ac_header_list " stdio_ext.h" 3378as_fn_append ac_header_list " stdio_ext.h"
3379as_fn_append ac_func_list " __fpending" 3379as_fn_append ac_func_list " __fpending"
@@ -3388,6 +3388,7 @@ as_fn_append ac_header_list " wchar.h"
3388as_fn_append ac_header_list " stdint.h" 3388as_fn_append ac_header_list " stdint.h"
3389as_fn_append ac_header_list " inttypes.h" 3389as_fn_append ac_header_list " inttypes.h"
3390as_fn_append ac_func_list " lstat" 3390as_fn_append ac_func_list " lstat"
3391as_fn_append ac_func_list " pipe2"
3391as_fn_append ac_header_list " sys/select.h" 3392as_fn_append ac_header_list " sys/select.h"
3392as_fn_append ac_func_list " pselect" 3393as_fn_append ac_func_list " pselect"
3393as_fn_append ac_func_list " pthread_sigmask" 3394as_fn_append ac_func_list " pthread_sigmask"
@@ -3403,6 +3404,7 @@ as_fn_append ac_func_list " futimesat"
3403as_fn_append ac_func_list " futimens" 3404as_fn_append ac_func_list " futimens"
3404as_fn_append ac_func_list " utimensat" 3405as_fn_append ac_func_list " utimensat"
3405as_fn_append ac_func_list " lutimes" 3406as_fn_append ac_func_list " lutimes"
3407as_fn_append ac_func_list " getdtablesize"
3406# Check that the precious variables saved in the cache have kept the same 3408# Check that the precious variables saved in the cache have kept the same
3407# value. 3409# value.
3408ac_cache_corrupted=false 3410ac_cache_corrupted=false
@@ -4349,7 +4351,8 @@ if test "${with_file_notification+set}" = set; then :
4349 w | w3 | w32 ) val=w32 ;; 4351 w | w3 | w32 ) val=w32 ;;
4350 * ) as_fn_error "\`--with-file-notification=$withval' is invalid; 4352 * ) as_fn_error "\`--with-file-notification=$withval' is invalid;
4351this option's value should be \`yes', \`no', \`gfile', \`inotify' or \`w32'. 4353this option's value should be \`yes', \`no', \`gfile', \`inotify' or \`w32'.
4352\`yes' is a synonym for \`w32' on MS-Windows, and for \`gfile' otherwise." "$LINENO" 5 4354\`yes' is a synonym for \`w32' on MS-Windows, for \`no' on Nextstep,
4355otherwise for the first of \`gfile' or \`inotify' that is usable." "$LINENO" 5
4353 ;; 4356 ;;
4354 esac 4357 esac
4355 with_file_notification=$val 4358 with_file_notification=$val
@@ -7226,6 +7229,7 @@ esac
7226 # Code from module alloca-opt: 7229 # Code from module alloca-opt:
7227 # Code from module allocator: 7230 # Code from module allocator:
7228 # Code from module at-internal: 7231 # Code from module at-internal:
7232 # Code from module binary-io:
7229 # Code from module c-ctype: 7233 # Code from module c-ctype:
7230 # Code from module c-strcase: 7234 # Code from module c-strcase:
7231 # Code from module careadlinkat: 7235 # Code from module careadlinkat:
@@ -7248,6 +7252,7 @@ esac
7248 7252
7249 # Code from module extern-inline: 7253 # Code from module extern-inline:
7250 # Code from module faccessat: 7254 # Code from module faccessat:
7255 # Code from module fcntl:
7251 # Code from module fcntl-h: 7256 # Code from module fcntl-h:
7252 # Code from module fdatasync: 7257 # Code from module fdatasync:
7253 # Code from module fdopendir: 7258 # Code from module fdopendir:
@@ -7255,6 +7260,7 @@ esac
7255 # Code from module fpending: 7260 # Code from module fpending:
7256 # Code from module fstatat: 7261 # Code from module fstatat:
7257 # Code from module fsync: 7262 # Code from module fsync:
7263 # Code from module getdtablesize:
7258 # Code from module getgroups: 7264 # Code from module getgroups:
7259 # Code from module getloadavg: 7265 # Code from module getloadavg:
7260 # Code from module getopt-gnu: 7266 # Code from module getopt-gnu:
@@ -7263,7 +7269,6 @@ esac
7263 # Code from module gettime: 7269 # Code from module gettime:
7264 # Code from module gettimeofday: 7270 # Code from module gettimeofday:
7265 # Code from module group-member: 7271 # Code from module group-member:
7266 # Code from module ignore-value:
7267 # Code from module include_next: 7272 # Code from module include_next:
7268 # Code from module intprops: 7273 # Code from module intprops:
7269 # Code from module inttypes-incomplete: 7274 # Code from module inttypes-incomplete:
@@ -7277,6 +7282,7 @@ esac
7277 # Code from module nocrash: 7282 # Code from module nocrash:
7278 # Code from module openat-h: 7283 # Code from module openat-h:
7279 # Code from module pathmax: 7284 # Code from module pathmax:
7285 # Code from module pipe2:
7280 # Code from module pselect: 7286 # Code from module pselect:
7281 # Code from module pthread_sigmask: 7287 # Code from module pthread_sigmask:
7282 # Code from module putenv: 7288 # Code from module putenv:
@@ -8991,7 +8997,7 @@ fi
8991 8997
8992if test "${with_sound}" != "no"; then 8998if test "${with_sound}" != "no"; then
8993 # Sound support for GNU/Linux, the free BSDs, and MinGW. 8999 # Sound support for GNU/Linux, the free BSDs, and MinGW.
8994 for ac_header in machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h 9000 for ac_header in machine/soundcard.h sys/soundcard.h soundcard.h
8995do : 9001do :
8996 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` 9002 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
8997ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " 9003ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
@@ -9213,8 +9219,6 @@ done
9213 9219
9214 9220
9215 9221
9216
9217
9218{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if personality LINUX32 can be set" >&5 9222{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if personality LINUX32 can be set" >&5
9219$as_echo_n "checking if personality LINUX32 can be set... " >&6; } 9223$as_echo_n "checking if personality LINUX32 can be set... " >&6; }
9220cat confdefs.h - <<_ACEOF >conftest.$ac_ext 9224cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9318,11 +9322,6 @@ cat >>confdefs.h <<_ACEOF
9318#define HAVE_DECL___SYS_SIGLIST $ac_have_decl 9322#define HAVE_DECL___SYS_SIGLIST $ac_have_decl
9319_ACEOF 9323_ACEOF
9320 9324
9321 if test $ac_cv_have_decl___sys_siglist = yes; then
9322
9323$as_echo "#define sys_siglist __sys_siglist" >>confdefs.h
9324
9325 fi
9326fi 9325fi
9327{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 9326{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
9328$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } 9327$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
@@ -9366,37 +9365,6 @@ $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
9366fi 9365fi
9367 9366
9368 9367
9369{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for speed_t" >&5
9370$as_echo_n "checking for speed_t... " >&6; }
9371if test "${emacs_cv_speed_t+set}" = set; then :
9372 $as_echo_n "(cached) " >&6
9373else
9374 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9375/* end confdefs.h. */
9376#include <termios.h>
9377int
9378main ()
9379{
9380speed_t x = 1;
9381 ;
9382 return 0;
9383}
9384_ACEOF
9385if ac_fn_c_try_compile "$LINENO"; then :
9386 emacs_cv_speed_t=yes
9387else
9388 emacs_cv_speed_t=no
9389fi
9390rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9391fi
9392{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_speed_t" >&5
9393$as_echo "$emacs_cv_speed_t" >&6; }
9394if test $emacs_cv_speed_t = yes; then
9395
9396$as_echo "#define HAVE_SPEED_T 1" >>confdefs.h
9397
9398fi
9399
9400 9368
9401 9369
9402 9370
@@ -10118,8 +10086,8 @@ $as_echo_n "checking whether Windows API headers are recent enough... " >&6; }
10118int 10086int
10119main () 10087main ()
10120{ 10088{
10121void test(PIMAGE_NT_HEADERS pHeader) 10089PIMAGE_NT_HEADERS pHeader;
10122 {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} 10090 PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)
10123 ; 10091 ;
10124 return 0; 10092 return 0;
10125} 10093}
@@ -11216,7 +11184,7 @@ $as_echo "#define HAVE_RSVG 1" >>confdefs.h
11216fi 11184fi
11217 11185
11218HAVE_IMAGEMAGICK=no 11186HAVE_IMAGEMAGICK=no
11219if test "${HAVE_X11}" = "yes"; then 11187if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
11220 if test "${with_imagemagick}" != "no"; then 11188 if test "${with_imagemagick}" != "no"; then
11221 ## 6.2.8 is the earliest version known to work, but earlier versions 11189 ## 6.2.8 is the earliest version known to work, but earlier versions
11222 ## might work - let us know if you find one. 11190 ## might work - let us know if you find one.
@@ -11960,7 +11928,6 @@ fi
11960 11928
11961 11929
11962HAVE_GNUTLS=no 11930HAVE_GNUTLS=no
11963HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=no
11964if test "${with_gnutls}" = "yes" ; then 11931if test "${with_gnutls}" = "yes" ; then
11965 11932
11966 succeeded=no 11933 succeeded=no
@@ -12019,33 +11986,12 @@ $as_echo "#define HAVE_GNUTLS 1" >>confdefs.h
12019 11986
12020 fi 11987 fi
12021 11988
12022 OLD_CFLAGS=$CFLAGS
12023 OLD_LIBS=$LIBS
12024 CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
12025 LIBS="$LIBGNUTLS_LIBS $LIBS"
12026 for ac_func in gnutls_certificate_set_verify_function
12027do :
12028 ac_fn_c_check_func "$LINENO" "gnutls_certificate_set_verify_function" "ac_cv_func_gnutls_certificate_set_verify_function"
12029if test "x$ac_cv_func_gnutls_certificate_set_verify_function" = x""yes; then :
12030 cat >>confdefs.h <<_ACEOF
12031#define HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION 1
12032_ACEOF
12033 HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=yes
12034fi
12035done
12036
12037
12038 if test "${HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY}" = "yes"; then
12039
12040$as_echo "#define HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY 1" >>confdefs.h
12041
12042 fi
12043
12044 # Windows loads GnuTLS dynamically 11989 # Windows loads GnuTLS dynamically
12045 if test "${opsys}" = "mingw32"; then 11990 if test "${opsys}" = "mingw32"; then
12046 CFLAGS=$OLD_CFLAGS
12047 LIBS=$OLD_LIBS
12048 LIBGNUTLS_LIBS= 11991 LIBGNUTLS_LIBS=
11992 else
11993 CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
11994 LIBS="$LIBGNUTLS_LIBS $LIBS"
12049 fi 11995 fi
12050fi 11996fi
12051 11997
@@ -12055,17 +12001,29 @@ fi
12055NOTIFY_OBJ= 12001NOTIFY_OBJ=
12056NOTIFY_SUMMARY=no 12002NOTIFY_SUMMARY=no
12057 12003
12058if test "${with_file_notification}" = "yes"; then 12004if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
12059 if test "${opsys}" = "mingw32"; then 12005 with_file_notification=no
12060 with_file_notification=w32
12061 else
12062 if test "${with_ns}" != yes; then
12063 with_file_notification=gfile
12064 fi
12065 fi
12066fi 12006fi
12067 12007
12068if test "${with_file_notification}" = "gfile"; then 12008case $with_file_notification,$opsys in
12009 w32,* | yes,mingw32)
12010 ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
12011if test "x$ac_cv_header_windows_h" = x""yes; then :
12012
12013fi
12014
12015
12016 if test "$ac_cv_header_windows_h" = yes ; then
12017
12018$as_echo "#define HAVE_W32NOTIFY 1" >>confdefs.h
12019
12020 NOTIFY_OBJ=w32notify.o
12021 NOTIFY_SUMMARY="yes (w32)"
12022 fi ;;
12023esac
12024
12025case $with_file_notification,$NOTIFY_OBJ in
12026 gfile, | yes,)
12069 12027
12070 succeeded=no 12028 succeeded=no
12071 12029
@@ -12117,51 +12075,44 @@ $as_echo "no" >&6; }
12117 HAVE_GFILENOTIFY=no 12075 HAVE_GFILENOTIFY=no
12118 fi 12076 fi
12119 12077
12120 if test "$HAVE_GFILENOTIFY" = "yes"; then 12078 if test "$HAVE_GFILENOTIFY" = "yes"; then
12121 12079
12122$as_echo "#define HAVE_GFILENOTIFY 1" >>confdefs.h 12080$as_echo "#define HAVE_GFILENOTIFY 1" >>confdefs.h
12123 12081
12124 NOTIFY_OBJ=gfilenotify.o 12082 NOTIFY_OBJ=gfilenotify.o
12125 NOTIFY_SUMMARY="yes -lgio (gfile)" 12083 NOTIFY_SUMMARY="yes -lgio (gfile)"
12126 fi 12084 fi ;;
12127fi 12085esac
12128if test "${with_file_notification}" = "inotify"; then 12086
12129 ac_fn_c_check_header_mongrel "$LINENO" "sys/inotify.h" "ac_cv_header_sys_inotify_h" "$ac_includes_default" 12087case $with_file_notification,$NOTIFY_OBJ in
12088 inotify, | yes,)
12089 ac_fn_c_check_header_mongrel "$LINENO" "sys/inotify.h" "ac_cv_header_sys_inotify_h" "$ac_includes_default"
12130if test "x$ac_cv_header_sys_inotify_h" = x""yes; then : 12090if test "x$ac_cv_header_sys_inotify_h" = x""yes; then :
12131 12091
12132fi 12092fi
12133 12093
12134 12094
12135 if test "$ac_cv_header_sys_inotify_h" = yes ; then 12095 if test "$ac_cv_header_sys_inotify_h" = yes ; then
12136 ac_fn_c_check_func "$LINENO" "inotify_init1" "ac_cv_func_inotify_init1" 12096 ac_fn_c_check_func "$LINENO" "inotify_init1" "ac_cv_func_inotify_init1"
12137if test "x$ac_cv_func_inotify_init1" = x""yes; then : 12097if test "x$ac_cv_func_inotify_init1" = x""yes; then :
12138 12098
12139fi 12099fi
12140 12100
12141 if test "$ac_cv_func_inotify_init1" = yes; then 12101 if test "$ac_cv_func_inotify_init1" = yes; then
12142 12102
12143$as_echo "#define HAVE_INOTIFY 1" >>confdefs.h 12103$as_echo "#define HAVE_INOTIFY 1" >>confdefs.h
12144 12104
12145 NOTIFY_OBJ=inotify.o 12105 NOTIFY_OBJ=inotify.o
12146 NOTIFY_SUMMARY="yes -lglibc (inotify)" 12106 NOTIFY_SUMMARY="yes -lglibc (inotify)"
12147 fi 12107 fi
12148 fi 12108 fi ;;
12149fi 12109esac
12150if test "${with_file_notification}" = "w32"; then
12151 ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
12152if test "x$ac_cv_header_windows_h" = x""yes; then :
12153
12154fi
12155
12156
12157 if test "$ac_cv_header_windows_h" = yes ; then
12158 12110
12159$as_echo "#define HAVE_W32NOTIFY 1" >>confdefs.h 12111case $with_file_notification,$NOTIFY_OBJ in
12112 yes,* | no,* | *,?*) ;;
12113 *) as_fn_error "File notification \`$with_file_notification' requested but requirements not found." "$LINENO" 5 ;;
12114esac
12160 12115
12161 NOTIFY_OBJ=w32notify.o
12162 NOTIFY_SUMMARY="yes (w32)"
12163 fi
12164fi
12165if test -n "$NOTIFY_OBJ"; then 12116if test -n "$NOTIFY_OBJ"; then
12166 12117
12167$as_echo "#define USE_FILE_NOTIFY 1" >>confdefs.h 12118$as_echo "#define USE_FILE_NOTIFY 1" >>confdefs.h
@@ -14716,14 +14667,14 @@ esac
14716 14667
14717 14668
14718 14669
14719for ac_func in gethostname \ 14670for ac_func in accept4 gethostname \
14720getrusage get_current_dir_name \ 14671getrusage get_current_dir_name \
14721lrand48 \ 14672lrand48 \
14722select getpagesize setlocale \ 14673select getpagesize setlocale \
14723utimes getrlimit setrlimit shutdown getaddrinfo \ 14674getrlimit setrlimit shutdown getaddrinfo \
14724strsignal setitimer \ 14675strsignal setitimer \
14725sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ 14676sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
14726gai_strerror mkstemp getline getdelim sync \ 14677gai_strerror mkostemp mkstemp getline getdelim sync \
14727difftime posix_memalign \ 14678difftime posix_memalign \
14728getpwent endpwent getgrent endgrent \ 14679getpwent endpwent getgrent endgrent \
14729touchlock \ 14680touchlock \
@@ -15293,9 +15244,6 @@ fi
15293 15244
15294 15245
15295 if test x"$hesiod" = xyes; then 15246 if test x"$hesiod" = xyes; then
15296
15297$as_echo "#define HAVE_LIBHESIOD 1" >>confdefs.h
15298
15299 LIBHESIOD=-lhesiod 15247 LIBHESIOD=-lhesiod
15300 fi 15248 fi
15301fi 15249fi
@@ -15303,9 +15251,6 @@ fi
15303 15251
15304# Do we need libresolv (due to res_init or Hesiod)? 15252# Do we need libresolv (due to res_init or Hesiod)?
15305if test "$resolv" = yes && test $opsys != darwin; then 15253if test "$resolv" = yes && test $opsys != darwin; then
15306
15307$as_echo "#define HAVE_LIBRESOLV 1" >>confdefs.h
15308
15309 LIBRESOLV=-lresolv 15254 LIBRESOLV=-lresolv
15310else 15255else
15311 LIBRESOLV= 15256 LIBRESOLV=
@@ -15365,9 +15310,6 @@ fi
15365 if test $have_com_err = yes; then 15310 if test $have_com_err = yes; then
15366 COM_ERRLIB=-lcom_err 15311 COM_ERRLIB=-lcom_err
15367 LIBS="$COM_ERRLIB $LIBS" 15312 LIBS="$COM_ERRLIB $LIBS"
15368
15369$as_echo "#define HAVE_LIBCOM_ERR 1" >>confdefs.h
15370
15371 fi 15313 fi
15372 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lcrypto" >&5 15314 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lcrypto" >&5
15373$as_echo_n "checking for mit_des_cbc_encrypt in -lcrypto... " >&6; } 15315$as_echo_n "checking for mit_des_cbc_encrypt in -lcrypto... " >&6; }
@@ -15414,9 +15356,6 @@ fi
15414 if test $have_crypto = yes; then 15356 if test $have_crypto = yes; then
15415 CRYPTOLIB=-lcrypto 15357 CRYPTOLIB=-lcrypto
15416 LIBS="$CRYPTOLIB $LIBS" 15358 LIBS="$CRYPTOLIB $LIBS"
15417
15418$as_echo "#define HAVE_LIBCRYPTO 1" >>confdefs.h
15419
15420 fi 15359 fi
15421 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lk5crypto" >&5 15360 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lk5crypto" >&5
15422$as_echo_n "checking for mit_des_cbc_encrypt in -lk5crypto... " >&6; } 15361$as_echo_n "checking for mit_des_cbc_encrypt in -lk5crypto... " >&6; }
@@ -15463,9 +15402,6 @@ fi
15463 if test $have_k5crypto = yes; then 15402 if test $have_k5crypto = yes; then
15464 CRYPTOLIB=-lk5crypto 15403 CRYPTOLIB=-lk5crypto
15465 LIBS="$CRYPTOLIB $LIBS" 15404 LIBS="$CRYPTOLIB $LIBS"
15466
15467$as_echo "#define HAVE_LIBK5CRYPTO 1" >>confdefs.h
15468
15469 fi 15405 fi
15470 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb5_init_context in -lkrb5" >&5 15406 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb5_init_context in -lkrb5" >&5
15471$as_echo_n "checking for krb5_init_context in -lkrb5... " >&6; } 15407$as_echo_n "checking for krb5_init_context in -lkrb5... " >&6; }
@@ -15512,9 +15448,6 @@ fi
15512 if test $have_krb5=yes; then 15448 if test $have_krb5=yes; then
15513 KRB5LIB=-lkrb5 15449 KRB5LIB=-lkrb5
15514 LIBS="$KRB5LIB $LIBS" 15450 LIBS="$KRB5LIB $LIBS"
15515
15516$as_echo "#define HAVE_LIBKRB5 1" >>confdefs.h
15517
15518 fi 15451 fi
15519 if test "${with_kerberos5}" = no; then 15452 if test "${with_kerberos5}" = no; then
15520 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes425" >&5 15453 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes425" >&5
@@ -15562,9 +15495,6 @@ fi
15562 if test $have_des425 = yes; then 15495 if test $have_des425 = yes; then
15563 DESLIB=-ldes425 15496 DESLIB=-ldes425
15564 LIBS="$DESLIB $LIBS" 15497 LIBS="$DESLIB $LIBS"
15565
15566$as_echo "#define HAVE_LIBDES425 1" >>confdefs.h
15567
15568 else 15498 else
15569 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes" >&5 15499 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes" >&5
15570$as_echo_n "checking for des_cbc_encrypt in -ldes... " >&6; } 15500$as_echo_n "checking for des_cbc_encrypt in -ldes... " >&6; }
@@ -15611,9 +15541,6 @@ fi
15611 if test $have_des = yes; then 15541 if test $have_des = yes; then
15612 DESLIB=-ldes 15542 DESLIB=-ldes
15613 LIBS="$DESLIB $LIBS" 15543 LIBS="$DESLIB $LIBS"
15614
15615$as_echo "#define HAVE_LIBDES 1" >>confdefs.h
15616
15617 fi 15544 fi
15618 fi 15545 fi
15619 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb4" >&5 15546 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb4" >&5
@@ -15661,9 +15588,6 @@ fi
15661 if test $have_krb4 = yes; then 15588 if test $have_krb4 = yes; then
15662 KRB4LIB=-lkrb4 15589 KRB4LIB=-lkrb4
15663 LIBS="$KRB4LIB $LIBS" 15590 LIBS="$KRB4LIB $LIBS"
15664
15665$as_echo "#define HAVE_LIBKRB4 1" >>confdefs.h
15666
15667 else 15591 else
15668 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb" >&5 15592 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb" >&5
15669$as_echo_n "checking for krb_get_cred in -lkrb... " >&6; } 15593$as_echo_n "checking for krb_get_cred in -lkrb... " >&6; }
@@ -15710,9 +15634,6 @@ fi
15710 if test $have_krb = yes; then 15634 if test $have_krb = yes; then
15711 KRB4LIB=-lkrb 15635 KRB4LIB=-lkrb
15712 LIBS="$KRB4LIB $LIBS" 15636 LIBS="$KRB4LIB $LIBS"
15713
15714$as_echo "#define HAVE_LIBKRB 1" >>confdefs.h
15715
15716 fi 15637 fi
15717 fi 15638 fi
15718 fi 15639 fi
@@ -15751,44 +15672,6 @@ fi
15751done 15672done
15752 15673
15753 else 15674 else
15754 for ac_header in des.h
15755do :
15756 ac_fn_c_check_header_mongrel "$LINENO" "des.h" "ac_cv_header_des_h" "$ac_includes_default"
15757if test "x$ac_cv_header_des_h" = x""yes; then :
15758 cat >>confdefs.h <<_ACEOF
15759#define HAVE_DES_H 1
15760_ACEOF
15761
15762else
15763 for ac_header in kerberosIV/des.h
15764do :
15765 ac_fn_c_check_header_mongrel "$LINENO" "kerberosIV/des.h" "ac_cv_header_kerberosIV_des_h" "$ac_includes_default"
15766if test "x$ac_cv_header_kerberosIV_des_h" = x""yes; then :
15767 cat >>confdefs.h <<_ACEOF
15768#define HAVE_KERBEROSIV_DES_H 1
15769_ACEOF
15770
15771else
15772 for ac_header in kerberos/des.h
15773do :
15774 ac_fn_c_check_header_mongrel "$LINENO" "kerberos/des.h" "ac_cv_header_kerberos_des_h" "$ac_includes_default"
15775if test "x$ac_cv_header_kerberos_des_h" = x""yes; then :
15776 cat >>confdefs.h <<_ACEOF
15777#define HAVE_KERBEROS_DES_H 1
15778_ACEOF
15779
15780fi
15781
15782done
15783
15784fi
15785
15786done
15787
15788fi
15789
15790done
15791
15792 for ac_header in krb.h 15675 for ac_header in krb.h
15793do : 15676do :
15794 ac_fn_c_check_header_mongrel "$LINENO" "krb.h" "ac_cv_header_krb_h" "$ac_includes_default" 15677 ac_fn_c_check_header_mongrel "$LINENO" "krb.h" "ac_cv_header_krb_h" "$ac_includes_default"
@@ -15958,25 +15841,6 @@ $as_echo "#define HAVE_INET_SOCKETS 1" >>confdefs.h
15958 15841
15959fi 15842fi
15960 15843
15961if test -f /usr/lpp/X11/bin/smt.exp; then
15962
15963$as_echo "#define HAVE_AIX_SMT_EXP 1" >>confdefs.h
15964
15965fi
15966
15967{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system supports dynamic ptys" >&5
15968$as_echo_n "checking whether system supports dynamic ptys... " >&6; }
15969if test -d /dev/pts && ls -d /dev/ptmx > /dev/null 2>&1 ; then
15970 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15971$as_echo "yes" >&6; }
15972
15973$as_echo "#define HAVE_DEV_PTMX 1" >>confdefs.h
15974
15975else
15976 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15977$as_echo "no" >&6; }
15978fi
15979
15980case $canonical in 15844case $canonical in
15981 *-solaris2.4 | *-solaris2.4.*) 15845 *-solaris2.4 | *-solaris2.4.*)
15982 : ${ac_cv_func_vfork_works=no};; 15846 : ${ac_cv_func_vfork_works=no};;
@@ -16409,12 +16273,9 @@ $as_echo "#define USER_FULL_NAME pw->pw_gecos" >>confdefs.h
16409$as_echo "#define DIRECTORY_SEP '/'" >>confdefs.h 16273$as_echo "#define DIRECTORY_SEP '/'" >>confdefs.h
16410 16274
16411 16275
16412
16413if test "${opsys}" = "mingw32"; then 16276if test "${opsys}" = "mingw32"; then
16414 $as_echo "#define DEVICE_SEP ':'" >>confdefs.h
16415
16416 16277
16417$as_echo "#define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)" >>confdefs.h 16278$as_echo "#define IS_DEVICE_SEP(_c_) ((_c_) == ':')" >>confdefs.h
16418 16279
16419 16280
16420 16281
@@ -16466,7 +16327,7 @@ esac
16466emacs_broken_SIGIO=no 16327emacs_broken_SIGIO=no
16467 16328
16468case $opsys in 16329case $opsys in
16469 hpux* | irix6-5 | openbsd | sol2* | unixware ) 16330 hpux* | irix6-5 | openbsd | sol2* | unixware | gnu-kfreebsd )
16470 emacs_broken_SIGIO=yes 16331 emacs_broken_SIGIO=yes
16471 ;; 16332 ;;
16472 16333
@@ -16581,10 +16442,10 @@ $as_echo "#define UNIX98_PTYS 1" >>confdefs.h
16581 16442
16582 $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h 16443 $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h
16583 16444
16584 $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h 16445 $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h
16585 16446
16586 if test "x$ac_cv_func_posix_openpt" = xyes; then 16447 if test "x$ac_cv_func_posix_openpt" = xyes; then
16587 $as_echo "#define PTY_OPEN fd = posix_openpt (O_RDWR | O_NOCTTY)" >>confdefs.h 16448 $as_echo "#define PTY_OPEN fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)" >>confdefs.h
16588 16449
16589 $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h 16450 $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
16590 16451
@@ -16898,13 +16759,10 @@ esac
16898 16759
16899 16760
16900 16761
16901
16902case $opsys in 16762case $opsys in
16903 aix4-2) 16763 aix4-2)
16904 $as_echo "#define USG /**/" >>confdefs.h 16764 $as_echo "#define USG /**/" >>confdefs.h
16905 16765
16906 $as_echo "#define USG5 /**/" >>confdefs.h
16907
16908 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 16766 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16909/* end confdefs.h. */ 16767/* end confdefs.h. */
16910 16768
@@ -16953,8 +16811,6 @@ $as_echo "#define GNU_LINUX /**/" >>confdefs.h
16953 hpux*) 16811 hpux*)
16954 $as_echo "#define USG /**/" >>confdefs.h 16812 $as_echo "#define USG /**/" >>confdefs.h
16955 16813
16956 $as_echo "#define USG5 /**/" >>confdefs.h
16957
16958 16814
16959$as_echo "#define HPUX /**/" >>confdefs.h 16815$as_echo "#define HPUX /**/" >>confdefs.h
16960 16816
@@ -16963,8 +16819,6 @@ $as_echo "#define HPUX /**/" >>confdefs.h
16963 irix6-5) 16819 irix6-5)
16964 $as_echo "#define USG /**/" >>confdefs.h 16820 $as_echo "#define USG /**/" >>confdefs.h
16965 16821
16966 $as_echo "#define USG5 /**/" >>confdefs.h
16967
16968 $as_echo "#define USG5_4 /**/" >>confdefs.h 16822 $as_echo "#define USG5_4 /**/" >>confdefs.h
16969 16823
16970 16824
@@ -16988,8 +16842,6 @@ $as_echo "#define EMACSDEBUG 1" >>confdefs.h
16988 sol2*) 16842 sol2*)
16989 $as_echo "#define USG /**/" >>confdefs.h 16843 $as_echo "#define USG /**/" >>confdefs.h
16990 16844
16991 $as_echo "#define USG5 /**/" >>confdefs.h
16992
16993 $as_echo "#define USG5_4 /**/" >>confdefs.h 16845 $as_echo "#define USG5_4 /**/" >>confdefs.h
16994 16846
16995 16847
@@ -17000,8 +16852,6 @@ $as_echo "#define SOLARIS2 /**/" >>confdefs.h
17000 unixware) 16852 unixware)
17001 $as_echo "#define USG /**/" >>confdefs.h 16853 $as_echo "#define USG /**/" >>confdefs.h
17002 16854
17003 $as_echo "#define USG5 /**/" >>confdefs.h
17004
17005 $as_echo "#define USG5_4 /**/" >>confdefs.h 16855 $as_echo "#define USG5_4 /**/" >>confdefs.h
17006 16856
17007 ;; 16857 ;;
@@ -18564,6 +18414,8 @@ $as_echo "$gl_cv_header_errno_h_EOVERFLOW" >&6; }
18564 REPLACE_OPENAT=0; 18414 REPLACE_OPENAT=0;
18565 18415
18566 18416
18417
18418
18567ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" 18419ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
18568if test "x$ac_cv_type_mode_t" = x""yes; then : 18420if test "x$ac_cv_type_mode_t" = x""yes; then :
18569 18421
@@ -20854,6 +20706,8 @@ cat >>confdefs.h <<_ACEOF
20854_ACEOF 20706_ACEOF
20855 20707
20856 20708
20709
20710
20857 GNULIB_PSELECT=0; 20711 GNULIB_PSELECT=0;
20858 GNULIB_SELECT=0; 20712 GNULIB_SELECT=0;
20859 HAVE_PSELECT=1; 20713 HAVE_PSELECT=1;
@@ -22053,6 +21907,8 @@ _ACEOF
22053 21907
22054 21908
22055 21909
21910
21911
22056 if false; then 21912 if false; then
22057 GL_COND_LIBTOOL_TRUE= 21913 GL_COND_LIBTOOL_TRUE=
22058 GL_COND_LIBTOOL_FALSE='#' 21914 GL_COND_LIBTOOL_FALSE='#'
@@ -22603,6 +22459,169 @@ _ACEOF
22603 22459
22604 22460
22605 22461
22462 if test $ac_cv_func_fcntl = no; then
22463
22464
22465
22466 if test $ac_cv_func_fcntl = no; then
22467 HAVE_FCNTL=0
22468 else
22469 REPLACE_FCNTL=1
22470 fi
22471
22472 else
22473 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5
22474$as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; }
22475if test "${gl_cv_func_fcntl_f_dupfd_works+set}" = set; then :
22476 $as_echo_n "(cached) " >&6
22477else
22478 if test "$cross_compiling" = yes; then :
22479 # Guess that it works on glibc systems
22480 case $host_os in #((
22481 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
22482 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
22483 esac
22484else
22485 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22486/* end confdefs.h. */
22487
22488#include <fcntl.h>
22489#include <errno.h>
22490
22491int
22492main ()
22493{
22494int result = 0;
22495 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
22496 if (errno != EINVAL) result |= 2;
22497 return result;
22498
22499 ;
22500 return 0;
22501}
22502_ACEOF
22503if ac_fn_c_try_run "$LINENO"; then :
22504 gl_cv_func_fcntl_f_dupfd_works=yes
22505else
22506 gl_cv_func_fcntl_f_dupfd_works=no
22507fi
22508rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
22509 conftest.$ac_objext conftest.beam conftest.$ac_ext
22510fi
22511
22512fi
22513{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5
22514$as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; }
22515 case $gl_cv_func_fcntl_f_dupfd_works in
22516 *yes) ;;
22517 *)
22518
22519
22520 if test $ac_cv_func_fcntl = no; then
22521 HAVE_FCNTL=0
22522 else
22523 REPLACE_FCNTL=1
22524 fi
22525
22526
22527$as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h
22528 ;;
22529 esac
22530
22531 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5
22532$as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; }
22533if test "${gl_cv_func_fcntl_f_dupfd_cloexec+set}" = set; then :
22534 $as_echo_n "(cached) " >&6
22535else
22536 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22537/* end confdefs.h. */
22538
22539#include <fcntl.h>
22540#ifndef F_DUPFD_CLOEXEC
22541choke me
22542#endif
22543
22544int
22545main ()
22546{
22547
22548 ;
22549 return 0;
22550}
22551_ACEOF
22552if ac_fn_c_try_compile "$LINENO"; then :
22553 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22554/* end confdefs.h. */
22555
22556#ifdef __linux__
22557/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
22558 it to support the semantics on older kernels that failed with EINVAL. */
22559choke me
22560#endif
22561
22562int
22563main ()
22564{
22565
22566 ;
22567 return 0;
22568}
22569_ACEOF
22570if ac_fn_c_try_compile "$LINENO"; then :
22571 gl_cv_func_fcntl_f_dupfd_cloexec=yes
22572else
22573 gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"
22574fi
22575rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22576else
22577 gl_cv_func_fcntl_f_dupfd_cloexec=no
22578fi
22579rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22580fi
22581{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5
22582$as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; }
22583 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
22584
22585
22586
22587 if test $ac_cv_func_fcntl = no; then
22588 HAVE_FCNTL=0
22589 else
22590 REPLACE_FCNTL=1
22591 fi
22592
22593 fi
22594 fi
22595
22596
22597 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
22598
22599
22600
22601
22602
22603
22604
22605
22606 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
22607
22608 fi
22609
22610
22611
22612
22613
22614 GNULIB_FCNTL=1
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22606 22625
22607 22626
22608 22627
@@ -24312,6 +24331,27 @@ $as_echo "$gl_cv_func_working_mktime" >&6; }
24312 24331
24313 24332
24314 24333
24334
24335 if test $ac_cv_func_pipe2 != yes; then
24336 HAVE_PIPE2=0
24337 fi
24338
24339
24340
24341
24342
24343
24344 GNULIB_PIPE2=1
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24315 if test $ac_cv_func_pselect = yes; then 24355 if test $ac_cv_func_pselect = yes; then
24316 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signature of pselect conforms to POSIX" >&5 24356 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signature of pselect conforms to POSIX" >&5
24317$as_echo_n "checking whether signature of pselect conforms to POSIX... " >&6; } 24357$as_echo_n "checking whether signature of pselect conforms to POSIX... " >&6; }
@@ -25799,7 +25839,8 @@ else
25799 25839
25800 /* Test _Alignas only on platforms where gnulib can help. */ 25840 /* Test _Alignas only on platforms where gnulib can help. */
25801 #if \ 25841 #if \
25802 (__GNUC__ || __IBMC__ || __IBMCPP__ \ 25842 ((defined __cplusplus && 201103 <= __cplusplus) \
25843 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
25803 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 25844 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
25804 struct alignas_test { char c; char alignas (8) alignas_8; }; 25845 struct alignas_test { char c; char alignas (8) alignas_8; };
25805 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 25846 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
@@ -27422,6 +27463,7 @@ $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
27422 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false 27463 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
27423 gl_gnulib_enabled_dosname=false 27464 gl_gnulib_enabled_dosname=false
27424 gl_gnulib_enabled_euidaccess=false 27465 gl_gnulib_enabled_euidaccess=false
27466 gl_gnulib_enabled_getdtablesize=false
27425 gl_gnulib_enabled_getgroups=false 27467 gl_gnulib_enabled_getgroups=false
27426 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false 27468 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
27427 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false 27469 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
@@ -27431,7 +27473,6 @@ $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
27431 gl_gnulib_enabled_stat=false 27473 gl_gnulib_enabled_stat=false
27432 gl_gnulib_enabled_strtoll=false 27474 gl_gnulib_enabled_strtoll=false
27433 gl_gnulib_enabled_strtoull=false 27475 gl_gnulib_enabled_strtoull=false
27434 gl_gnulib_enabled_verify=false
27435 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false 27476 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
27436 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () 27477 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
27437 { 27478 {
@@ -27711,6 +27752,43 @@ done
27711 fi 27752 fi
27712 fi 27753 fi
27713 } 27754 }
27755 func_gl_gnulib_m4code_getdtablesize ()
27756 {
27757 if ! $gl_gnulib_enabled_getdtablesize; then
27758
27759
27760
27761 if test $ac_cv_func_getdtablesize != yes; then
27762 HAVE_GETDTABLESIZE=0
27763 fi
27764
27765 if test $HAVE_GETDTABLESIZE = 0; then
27766
27767
27768
27769
27770
27771
27772
27773
27774 gl_LIBOBJS="$gl_LIBOBJS getdtablesize.$ac_objext"
27775
27776 :
27777 fi
27778
27779
27780
27781
27782
27783 GNULIB_GETDTABLESIZE=1
27784
27785
27786
27787
27788
27789 gl_gnulib_enabled_getdtablesize=true
27790 fi
27791 }
27714 func_gl_gnulib_m4code_getgroups () 27792 func_gl_gnulib_m4code_getgroups ()
27715 { 27793 {
27716 if ! $gl_gnulib_enabled_getgroups; then 27794 if ! $gl_gnulib_enabled_getgroups; then
@@ -28133,9 +28211,6 @@ $as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h
28133 if test $REPLACE_STAT = 1; then 28211 if test $REPLACE_STAT = 1; then
28134 func_gl_gnulib_m4code_pathmax 28212 func_gl_gnulib_m4code_pathmax
28135 fi 28213 fi
28136 if test $REPLACE_STAT = 1; then
28137 func_gl_gnulib_m4code_verify
28138 fi
28139 fi 28214 fi
28140 } 28215 }
28141 func_gl_gnulib_m4code_strtoll () 28216 func_gl_gnulib_m4code_strtoll ()
@@ -28242,12 +28317,6 @@ done
28242 gl_gnulib_enabled_strtoull=true 28317 gl_gnulib_enabled_strtoull=true
28243 fi 28318 fi
28244 } 28319 }
28245 func_gl_gnulib_m4code_verify ()
28246 {
28247 if ! $gl_gnulib_enabled_verify; then
28248 gl_gnulib_enabled_verify=true
28249 fi
28250 }
28251 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () 28320 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
28252 { 28321 {
28253 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 28322 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
@@ -28266,6 +28335,9 @@ done
28266 if test $HAVE_FACCESSAT = 0; then 28335 if test $HAVE_FACCESSAT = 0; then
28267 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 28336 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
28268 fi 28337 fi
28338 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
28339 func_gl_gnulib_m4code_getdtablesize
28340 fi
28269 if test $HAVE_FDOPENDIR = 0; then 28341 if test $HAVE_FDOPENDIR = 0; then
28270 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 28342 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
28271 fi 28343 fi
@@ -28302,15 +28374,9 @@ done
28302 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then 28374 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
28303 func_gl_gnulib_m4code_strtoll 28375 func_gl_gnulib_m4code_strtoll
28304 fi 28376 fi
28305 if test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
28306 func_gl_gnulib_m4code_verify
28307 fi
28308 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then 28377 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then
28309 func_gl_gnulib_m4code_strtoull 28378 func_gl_gnulib_m4code_strtoull
28310 fi 28379 fi
28311 if test $ac_cv_func_strtoumax = no; then
28312 func_gl_gnulib_m4code_verify
28313 fi
28314 28380
28315 if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then 28381 if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then
28316 gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE= 28382 gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE=
@@ -28336,6 +28402,14 @@ else
28336 gl_GNULIB_ENABLED_euidaccess_FALSE= 28402 gl_GNULIB_ENABLED_euidaccess_FALSE=
28337fi 28403fi
28338 28404
28405 if $gl_gnulib_enabled_getdtablesize; then
28406 gl_GNULIB_ENABLED_getdtablesize_TRUE=
28407 gl_GNULIB_ENABLED_getdtablesize_FALSE='#'
28408else
28409 gl_GNULIB_ENABLED_getdtablesize_TRUE='#'
28410 gl_GNULIB_ENABLED_getdtablesize_FALSE=
28411fi
28412
28339 if $gl_gnulib_enabled_getgroups; then 28413 if $gl_gnulib_enabled_getgroups; then
28340 gl_GNULIB_ENABLED_getgroups_TRUE= 28414 gl_GNULIB_ENABLED_getgroups_TRUE=
28341 gl_GNULIB_ENABLED_getgroups_FALSE='#' 28415 gl_GNULIB_ENABLED_getgroups_FALSE='#'
@@ -28408,14 +28482,6 @@ else
28408 gl_GNULIB_ENABLED_strtoull_FALSE= 28482 gl_GNULIB_ENABLED_strtoull_FALSE=
28409fi 28483fi
28410 28484
28411 if $gl_gnulib_enabled_verify; then
28412 gl_GNULIB_ENABLED_verify_TRUE=
28413 gl_GNULIB_ENABLED_verify_FALSE='#'
28414else
28415 gl_GNULIB_ENABLED_verify_TRUE='#'
28416 gl_GNULIB_ENABLED_verify_FALSE=
28417fi
28418
28419 if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 28485 if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
28420 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE= 28486 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE=
28421 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE='#' 28487 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE='#'
@@ -28877,6 +28943,10 @@ if test -z "${gl_GNULIB_ENABLED_euidaccess_TRUE}" && test -z "${gl_GNULIB_ENABLE
28877 as_fn_error "conditional \"gl_GNULIB_ENABLED_euidaccess\" was never defined. 28943 as_fn_error "conditional \"gl_GNULIB_ENABLED_euidaccess\" was never defined.
28878Usually this means the macro was only invoked conditionally." "$LINENO" 5 28944Usually this means the macro was only invoked conditionally." "$LINENO" 5
28879fi 28945fi
28946if test -z "${gl_GNULIB_ENABLED_getdtablesize_TRUE}" && test -z "${gl_GNULIB_ENABLED_getdtablesize_FALSE}"; then
28947 as_fn_error "conditional \"gl_GNULIB_ENABLED_getdtablesize\" was never defined.
28948Usually this means the macro was only invoked conditionally." "$LINENO" 5
28949fi
28880if test -z "${gl_GNULIB_ENABLED_getgroups_TRUE}" && test -z "${gl_GNULIB_ENABLED_getgroups_FALSE}"; then 28950if test -z "${gl_GNULIB_ENABLED_getgroups_TRUE}" && test -z "${gl_GNULIB_ENABLED_getgroups_FALSE}"; then
28881 as_fn_error "conditional \"gl_GNULIB_ENABLED_getgroups\" was never defined. 28951 as_fn_error "conditional \"gl_GNULIB_ENABLED_getgroups\" was never defined.
28882Usually this means the macro was only invoked conditionally." "$LINENO" 5 28952Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -28913,10 +28983,6 @@ if test -z "${gl_GNULIB_ENABLED_strtoull_TRUE}" && test -z "${gl_GNULIB_ENABLED_
28913 as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoull\" was never defined. 28983 as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoull\" was never defined.
28914Usually this means the macro was only invoked conditionally." "$LINENO" 5 28984Usually this means the macro was only invoked conditionally." "$LINENO" 5
28915fi 28985fi
28916if test -z "${gl_GNULIB_ENABLED_verify_TRUE}" && test -z "${gl_GNULIB_ENABLED_verify_FALSE}"; then
28917 as_fn_error "conditional \"gl_GNULIB_ENABLED_verify\" was never defined.
28918Usually this means the macro was only invoked conditionally." "$LINENO" 5
28919fi
28920if test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE}" && test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE}"; then 28986if test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE}" && test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE}"; then
28921 as_fn_error "conditional \"gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec\" was never defined. 28987 as_fn_error "conditional \"gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec\" was never defined.
28922Usually this means the macro was only invoked conditionally." "$LINENO" 5 28988Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index 82138f09a2f..4458ea3de70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -211,7 +211,8 @@ AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
211 w | w3 | w32 ) val=w32 ;; 211 w | w3 | w32 ) val=w32 ;;
212 * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid; 212 * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid;
213this option's value should be `yes', `no', `gfile', `inotify' or `w32'. 213this option's value should be `yes', `no', `gfile', `inotify' or `w32'.
214`yes' is a synonym for `w32' on MS-Windows, and for `gfile' otherwise.]) 214`yes' is a synonym for `w32' on MS-Windows, for `no' on Nextstep,
215otherwise for the first of `gfile' or `inotify' that is usable.])
215 ;; 216 ;;
216 esac 217 esac
217 with_file_notification=$val 218 with_file_notification=$val
@@ -1637,8 +1638,8 @@ if test "${opsys}" = "mingw32"; then
1637 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1638 #include <windows.h> 1639 #include <windows.h>
1639 #include <usp10.h>]], 1640 #include <usp10.h>]],
1640 [[void test(PIMAGE_NT_HEADERS pHeader) 1641 [[PIMAGE_NT_HEADERS pHeader;
1641 {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])], 1642 PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
1642 [emacs_cv_w32api=yes 1643 [emacs_cv_w32api=yes
1643 HAVE_W32=yes], 1644 HAVE_W32=yes],
1644 emacs_cv_w32api=no) 1645 emacs_cv_w32api=no)
@@ -2043,7 +2044,7 @@ if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" =
2043fi 2044fi
2044 2045
2045HAVE_IMAGEMAGICK=no 2046HAVE_IMAGEMAGICK=no
2046if test "${HAVE_X11}" = "yes"; then 2047if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
2047 if test "${with_imagemagick}" != "no"; then 2048 if test "${with_imagemagick}" != "no"; then
2048 ## 6.2.8 is the earliest version known to work, but earlier versions 2049 ## 6.2.8 is the earliest version known to work, but earlier versions
2049 ## might work - let us know if you find one. 2050 ## might work - let us know if you find one.
@@ -2351,51 +2352,57 @@ AC_SUBST(LIBGNUTLS_CFLAGS)
2351NOTIFY_OBJ= 2352NOTIFY_OBJ=
2352NOTIFY_SUMMARY=no 2353NOTIFY_SUMMARY=no
2353 2354
2354dnl Set defaults of $with_file_notification. 2355dnl FIXME? Don't auto-detect on NS, but do allow someone to specify
2355if test "${with_file_notification}" = "yes"; then 2356dnl a particular library. This doesn't make much sense?
2356 if test "${opsys}" = "mingw32"; then 2357if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
2357 with_file_notification=w32 2358 with_file_notification=no
2358 else
2359 if test "${with_ns}" != yes; then
2360 with_file_notification=gfile
2361 fi
2362 fi
2363fi 2359fi
2364 2360
2361dnl MS Windows native file monitor is available for mingw32 only.
2362case $with_file_notification,$opsys in
2363 w32,* | yes,mingw32)
2364 AC_CHECK_HEADER(windows.h)
2365 if test "$ac_cv_header_windows_h" = yes ; then
2366 AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2367 NOTIFY_OBJ=w32notify.o
2368 NOTIFY_SUMMARY="yes (w32)"
2369 fi ;;
2370esac
2371
2365dnl g_file_monitor exists since glib 2.18. G_FILE_MONITOR_EVENT_MOVED 2372dnl g_file_monitor exists since glib 2.18. G_FILE_MONITOR_EVENT_MOVED
2366dnl has been added in glib 2.24. It has been tested under 2373dnl has been added in glib 2.24. It has been tested under
2367dnl GNU/Linux only. We take precedence over inotify, but this makes 2374dnl GNU/Linux only. We take precedence over inotify, but this makes
2368dnl only sense when glib has been compiled with inotify support. How 2375dnl only sense when glib has been compiled with inotify support. How
2369dnl to check? 2376dnl to check?
2370if test "${with_file_notification}" = "gfile"; then 2377case $with_file_notification,$NOTIFY_OBJ in
2371 PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no) 2378 gfile, | yes,)
2372 if test "$HAVE_GFILENOTIFY" = "yes"; then 2379 PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no)
2373 AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.]) 2380 if test "$HAVE_GFILENOTIFY" = "yes"; then
2374 NOTIFY_OBJ=gfilenotify.o 2381 AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2375 NOTIFY_SUMMARY="yes -lgio (gfile)" 2382 NOTIFY_OBJ=gfilenotify.o
2376 fi 2383 NOTIFY_SUMMARY="yes -lgio (gfile)"
2377fi 2384 fi ;;
2385esac
2386
2378dnl inotify is only available on GNU/Linux. 2387dnl inotify is only available on GNU/Linux.
2379if test "${with_file_notification}" = "inotify"; then 2388case $with_file_notification,$NOTIFY_OBJ in
2380 AC_CHECK_HEADER(sys/inotify.h) 2389 inotify, | yes,)
2381 if test "$ac_cv_header_sys_inotify_h" = yes ; then 2390 AC_CHECK_HEADER(sys/inotify.h)
2382 AC_CHECK_FUNC(inotify_init1) 2391 if test "$ac_cv_header_sys_inotify_h" = yes ; then
2383 if test "$ac_cv_func_inotify_init1" = yes; then 2392 AC_CHECK_FUNC(inotify_init1)
2384 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.]) 2393 if test "$ac_cv_func_inotify_init1" = yes; then
2385 NOTIFY_OBJ=inotify.o 2394 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2386 NOTIFY_SUMMARY="yes -lglibc (inotify)" 2395 NOTIFY_OBJ=inotify.o
2387 fi 2396 NOTIFY_SUMMARY="yes -lglibc (inotify)"
2388 fi 2397 fi
2389fi 2398 fi ;;
2390dnl MS Windows native file monitor is available for mingw32 only. 2399esac
2391if test "${with_file_notification}" = "w32"; then 2400
2392 AC_CHECK_HEADER(windows.h) 2401case $with_file_notification,$NOTIFY_OBJ in
2393 if test "$ac_cv_header_windows_h" = yes ; then 2402 yes,* | no,* | *,?*) ;;
2394 AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.]) 2403 *) AC_MSG_ERROR([File notification `$with_file_notification' requested but requirements not found.]) ;;
2395 NOTIFY_OBJ=w32notify.o 2404esac
2396 NOTIFY_SUMMARY="yes (w32)" 2405
2397 fi
2398fi
2399if test -n "$NOTIFY_OBJ"; then 2406if test -n "$NOTIFY_OBJ"; then
2400 AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.]) 2407 AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
2401fi 2408fi
@@ -3276,14 +3283,14 @@ esac
3276AC_SUBST(BLESSMAIL_TARGET) 3283AC_SUBST(BLESSMAIL_TARGET)
3277 3284
3278 3285
3279AC_CHECK_FUNCS(gethostname \ 3286AC_CHECK_FUNCS(accept4 gethostname \
3280getrusage get_current_dir_name \ 3287getrusage get_current_dir_name \
3281lrand48 \ 3288lrand48 \
3282select getpagesize setlocale \ 3289select getpagesize setlocale \
3283getrlimit setrlimit shutdown getaddrinfo \ 3290getrlimit setrlimit shutdown getaddrinfo \
3284strsignal setitimer \ 3291strsignal setitimer \
3285sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ 3292sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
3286gai_strerror mkstemp getline getdelim sync \ 3293gai_strerror mkostemp mkstemp getline getdelim sync \
3287difftime posix_memalign \ 3294difftime posix_memalign \
3288getpwent endpwent getgrent endgrent \ 3295getpwent endpwent getgrent endgrent \
3289touchlock \ 3296touchlock \
@@ -3801,7 +3808,7 @@ emacs_broken_SIGIO=no
3801case $opsys in 3808case $opsys in
3802 dnl SIGIO exists, but the feature doesn't work in the way Emacs needs. 3809 dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
3803 dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>. 3810 dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
3804 hpux* | irix6-5 | openbsd | sol2* | unixware ) 3811 hpux* | irix6-5 | openbsd | sol2* | unixware | gnu-kfreebsd )
3805 emacs_broken_SIGIO=yes 3812 emacs_broken_SIGIO=yes
3806 ;; 3813 ;;
3807 3814
@@ -3970,10 +3977,10 @@ case $opsys in
3970 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)]) 3977 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
3971 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD 3978 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD
3972 dnl to prevent sigchld_handler from intercepting the child's death. 3979 dnl to prevent sigchld_handler from intercepting the child's death.
3973 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) 3980 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
3974 dnl if HAVE_POSIX_OPENPT 3981 dnl if HAVE_POSIX_OPENPT
3975 if test "x$ac_cv_func_posix_openpt" = xyes; then 3982 if test "x$ac_cv_func_posix_openpt" = xyes; then
3976 AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_NOCTTY)]) 3983 AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)])
3977 AC_DEFINE(PTY_NAME_SPRINTF, []) 3984 AC_DEFINE(PTY_NAME_SPRINTF, [])
3978 dnl if HAVE_GETPT 3985 dnl if HAVE_GETPT
3979 elif test "x$ac_cv_func_getpt" = xyes; then 3986 elif test "x$ac_cv_func_getpt" = xyes; then
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index d5f3095908b..e634117f89c 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,11 @@
12013-07-03 Glenn Morris <rgm@gnu.org>
2
3 * maintaining.texi (EDE): Fix cross-reference.
4
5 * programs.texi (Program Modes): Fix emacs-xtra reference.
6
7 * help.texi (Misc Help): Index describe-syntax.
8
12013-06-29 Eli Zaretskii <eliz@gnu.org> 92013-06-29 Eli Zaretskii <eliz@gnu.org>
2 10
3 * basic.texi (Moving Point): Document visual-order-cursor-movement 11 * basic.texi (Moving Point): Document visual-order-cursor-movement
diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 75b250d0f40..e41d68a5f51 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -535,6 +535,8 @@ describes the commands and features that are changed in this mode.
535 535
536@kindex C-h b 536@kindex C-h b
537@findex describe-bindings 537@findex describe-bindings
538@kindex C-h s
539@findex describe-syntax
538 @kbd{C-h b} (@code{describe-bindings}) and @kbd{C-h s} 540 @kbd{C-h b} (@code{describe-bindings}) and @kbd{C-h s}
539(@code{describe-syntax}) show other information about the current 541(@code{describe-syntax}) show other information about the current
540environment within Emacs. @kbd{C-h b} displays a list of all the key 542environment within Emacs. @kbd{C-h b} displays a list of all the key
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 1b6374a4133..e89660dfaf5 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2346,7 +2346,7 @@ directory trees. The @dfn{project root} is the topmost directory of a
2346project. To define a new project, visit a file in the desired project 2346project. To define a new project, visit a file in the desired project
2347root and type @kbd{M-x ede-new}. This command prompts for a 2347root and type @kbd{M-x ede-new}. This command prompts for a
2348@dfn{project type}, which refers to the underlying method that EDE 2348@dfn{project type}, which refers to the underlying method that EDE
2349will use to manage the project (@pxref{Creating a Project, EDE,, ede, 2349will use to manage the project (@pxref{Creating a project, EDE,, ede,
2350Emacs Development Environment}). The most common project types are 2350Emacs Development Environment}). The most common project types are
2351@samp{Make}, which uses Makefiles, and @samp{Automake}, which uses GNU 2351@samp{Make}, which uses Makefiles, and @samp{Automake}, which uses GNU
2352Automake (@pxref{Top, Automake,, automake, Automake}). In both cases, 2352Automake (@pxref{Top, Automake,, automake, Automake}). In both cases,
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index 70eecf1c97b..8bb851e75a4 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -119,17 +119,17 @@ those specified in the mode's own mode hook (@pxref{Major Modes}).
119For instance, entering C mode runs the hooks @code{prog-mode-hook} and 119For instance, entering C mode runs the hooks @code{prog-mode-hook} and
120@code{c-mode-hook}. @xref{Hooks}, for information about hooks. 120@code{c-mode-hook}. @xref{Hooks}, for information about hooks.
121 121
122@ifinfo 122@ifnottex
123 Separate manuals are available for the modes for Ada (@pxref{Top,, 123 Separate manuals are available for the modes for Ada (@pxref{Top,,
124Ada Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba 124Ada Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba
125IDL/Pike/AWK (@pxref{Top, , CC Mode, ccmode, CC Mode}), and IDLWAVE 125IDL/Pike/AWK (@pxref{Top, , CC Mode, ccmode, CC Mode}), and IDLWAVE
126(@pxref{Top,, IDLWAVE, idlwave, IDLWAVE User Manual}). 126(@pxref{Top,, IDLWAVE, idlwave, IDLWAVE User Manual}).
127@end ifinfo 127@end ifnottex
128@ifnotinfo 128@iftex
129 The Emacs distribution contains Info manuals for the major modes for 129 The Emacs distribution contains Info manuals for the major modes for
130Ada, C/C++/Objective C/Java/Corba IDL/Pike/AWK, and IDLWAVE@. For 130Ada, C/C++/Objective C/Java/Corba IDL/Pike/AWK, and IDLWAVE@. For
131Fortran mode, @pxref{Fortran,,, emacs-xtra, Specialized Emacs Features}. 131Fortran mode, @pxref{Fortran,,, emacs-xtra, Specialized Emacs Features}.
132@end ifnotinfo 132@end iftex
133 133
134@node Defuns 134@node Defuns
135@section Top-Level Definitions, or Defuns 135@section Top-Level Definitions, or Defuns
diff --git a/doc/lispintro/ChangeLog b/doc/lispintro/ChangeLog
index a1fd9303866..4182b6a3184 100644
--- a/doc/lispintro/ChangeLog
+++ b/doc/lispintro/ChangeLog
@@ -1,3 +1,12 @@
12013-07-06 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp-intro.texi (Top):
4 Move WWW_GNU_ORG section outside @copying, update URL.
5
62013-07-03 Glenn Morris <rgm@gnu.org>
7
8 * emacs-lisp-intro.texi (edebug): Fix cross-references.
9
12013-06-19 Glenn Morris <rgm@gnu.org> 102013-06-19 Glenn Morris <rgm@gnu.org>
2 11
3 * Makefile.in (dist): Edit more configure variables. (Bug#14660) 12 * Makefile.in (dist): Edit more configure variables. (Bug#14660)
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi
index 221376e2353..dafee51a020 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -112,14 +112,6 @@ Edition @value{edition-number}, @value{update-date}
112@ifnottex 112@ifnottex
113Distributed with Emacs version @value{EMACSVER}. 113Distributed with Emacs version @value{EMACSVER}.
114@end ifnottex 114@end ifnottex
115@ifset WWW_GNU_ORG
116@html
117<p>The homepage for GNU Emacs is at
118<a href="http://www.gnu.org/software/emacs/">http://www.gnu.org/software/emacs/</a>.
119<br>To view this manual in other formats, click
120<a href="/software/emacs/emacs-lisp-intro/emacs-lisp-intro.html">here</a>.
121@end html
122@end ifset
123@sp 1 115@sp 1
124Copyright @copyright{} 1990--1995, 1997, 2001--2013 Free Software 116Copyright @copyright{} 1990--1995, 1997, 2001--2013 Free Software
125Foundation, Inc. 117Foundation, Inc.
@@ -211,6 +203,15 @@ supports it in developing GNU and promoting software freedom.''
211@node Top 203@node Top
212@top An Introduction to Programming in Emacs Lisp 204@top An Introduction to Programming in Emacs Lisp
213 205
206@ifset WWW_GNU_ORG
207@html
208<p>The homepage for GNU Emacs is at
209<a href="/software/emacs/">http://www.gnu.org/software/emacs/</a>.<br>
210To view this manual in other formats, click
211<a href="/software/emacs/manual/eintr.html">here</a>.
212@end html
213@end ifset
214
214@insertcopying 215@insertcopying
215 216
216This master menu first lists each chapter and index; then it lists 217This master menu first lists each chapter and index; then it lists
@@ -18483,7 +18484,7 @@ shows which line you are currently executing.
18483You can walk through the execution of a function, line by line, or run 18484You can walk through the execution of a function, line by line, or run
18484quickly until reaching a @dfn{breakpoint} where execution stops. 18485quickly until reaching a @dfn{breakpoint} where execution stops.
18485 18486
18486Edebug is described in @ref{edebug, , Edebug, elisp, The GNU Emacs 18487Edebug is described in @ref{Edebug, , , elisp, The GNU Emacs
18487Lisp Reference Manual}. 18488Lisp Reference Manual}.
18488 18489
18489@need 1250 18490@need 1250
@@ -18610,7 +18611,7 @@ error or at specified stopping points; you can cause it to display the
18610changing values of various expressions; you can find out how many 18611changing values of various expressions; you can find out how many
18611times a function is called, and more. 18612times a function is called, and more.
18612 18613
18613Edebug is described in @ref{edebug, , Edebug, elisp, The GNU Emacs 18614Edebug is described in @ref{Edebug, , , elisp, The GNU Emacs
18614Lisp Reference Manual}. 18615Lisp Reference Manual}.
18615 18616
18616@need 1500 18617@need 1500
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index dc0c1564735..f8b7406c427 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,26 @@
12013-07-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Timestamp fixes for undo (Bug#14824).
4 * text.texi (Undo): Document (t . 0) and (t . -1) in buffer-undo-list.
5
62013-07-06 Eli Zaretskii <eliz@gnu.org>
7
8 * nonascii.texi (Text Representations): Document that
9 multibyte-string-p returns nil for non-string objects.
10
112013-07-06 Glenn Morris <rgm@gnu.org>
12
13 * elisp.texi (Top): Move WWW_GNU_ORG section outside @copying.
14
152013-07-03 Glenn Morris <rgm@gnu.org>
16
17 * debugging.texi (Debugging):
18 * files.texi (File Attributes, Changing Files): Fix cross-references.
19
20 * package.texi (Package Archives): Fix @url call.
21
22 * syntax.texi (Syntax Table Functions): Mention describe-syntax.
23
12013-06-29 Eli Zaretskii <eliz@gnu.org> 242013-06-29 Eli Zaretskii <eliz@gnu.org>
2 25
3 * display.texi (Bidirectional Display): Document move-point-visually. 26 * display.texi (Bidirectional Display): Document move-point-visually.
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 24629465525..335e3f802d2 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -32,7 +32,7 @@ program.
32 32
33@item 33@item
34You can use the ERT package to write regression tests for the program. 34You can use the ERT package to write regression tests for the program.
35@xref{Top,the ERT manual,, ERT, ERT: Emacs Lisp Regression Testing}. 35@xref{Top,the ERT manual,, ert, ERT: Emacs Lisp Regression Testing}.
36 36
37@item 37@item
38You can profile the program to get hints about how to make it more efficient. 38You can profile the program to get hints about how to make it more efficient.
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 9e9617c10f8..59bbdec0229 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -97,16 +97,6 @@ This is edition @value{VERSION} of the @cite{GNU Emacs Lisp Reference Manual},@*
97This is the @cite{GNU Emacs Lisp Reference Manual} 97This is the @cite{GNU Emacs Lisp Reference Manual}
98@end ifnottex 98@end ifnottex
99corresponding to Emacs version @value{EMACSVER}. 99corresponding to Emacs version @value{EMACSVER}.
100@ifset WWW_GNU_ORG
101@html
102<p>The homepage for GNU Emacs is at
103<a href="/software/emacs/">http://www.gnu.org/software/emacs/</a>.<br>
104For information on using Emacs, refer to
105the <a href="/software/emacs/manual/html_node/emacs/index.html">Emacs
106Manual</a>.<br> To view this manual in other formats,
107click <a href="/software/emacs/manual/elisp.html">here</a>.
108@end html
109@end ifset
110 100
111Copyright @copyright{} 1990--1996, 1998--2013 Free Software Foundation, Inc. 101Copyright @copyright{} 1990--1996, 1998--2013 Free Software Foundation, Inc.
112 102
@@ -167,6 +157,17 @@ Cover art by Etienne Suvasa.
167@node Top 157@node Top
168@top Emacs Lisp 158@top Emacs Lisp
169 159
160@ifset WWW_GNU_ORG
161@html
162<p>The homepage for GNU Emacs is at
163<a href="/software/emacs/">http://www.gnu.org/software/emacs/</a>.<br>
164For information on using Emacs, refer to the
165<a href="/software/emacs/manual/emacs.html">Emacs Manual</a>.<br>
166To view this manual in other formats, click
167<a href="/software/emacs/manual/elisp.html">here</a>.
168@end html
169@end ifset
170
170@insertcopying 171@insertcopying
171@end ifnottex 172@end ifnottex
172 173
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 704ecfb6446..951d55ac90f 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1115,7 +1115,7 @@ permissions} of @var{filename}, as an integer. It recursively follows
1115symbolic links in @var{filename} at all levels. If @var{filename} 1115symbolic links in @var{filename} at all levels. If @var{filename}
1116does not exist, the return value is @code{nil}. 1116does not exist, the return value is @code{nil}.
1117 1117
1118@xref{File Permissions,,, coreutils, The @sc{gnu} @code{Coreutils} 1118@xref{File permissions,,, coreutils, The @sc{gnu} @code{Coreutils}
1119Manual}, for a description of mode bits. If the low-order bit is 1, 1119Manual}, for a description of mode bits. If the low-order bit is 1,
1120then the file is executable by all users, if the second-lowest-order 1120then the file is executable by all users, if the second-lowest-order
1121bit is 1, then the file is writable by all users, etc. The highest 1121bit is 1, then the file is writable by all users, etc. The highest
@@ -1625,7 +1625,7 @@ octal numbers to enter @var{mode}. For example,
1625@noindent 1625@noindent
1626specifies that the file should be readable and writable for its owner, 1626specifies that the file should be readable and writable for its owner,
1627readable for group members, and readable for all other users. 1627readable for group members, and readable for all other users.
1628@xref{File Permissions,,, coreutils, The @sc{gnu} @code{Coreutils} 1628@xref{File permissions,,, coreutils, The @sc{gnu} @code{Coreutils}
1629Manual}, for a description of mode bit specifications. 1629Manual}, for a description of mode bit specifications.
1630 1630
1631Interactively, @var{mode} is read from the minibuffer using 1631Interactively, @var{mode} is read from the minibuffer using
@@ -1676,7 +1676,7 @@ the permissions on which the specification is based are taken from the
1676mode bits of @var{base-file}. If @var{base-file} is omitted or 1676mode bits of @var{base-file}. If @var{base-file} is omitted or
1677@code{nil}, the function uses @code{0} as the base mode bits. The 1677@code{nil}, the function uses @code{0} as the base mode bits. The
1678complete and relative specifications can be combined, as in 1678complete and relative specifications can be combined, as in
1679@code{"u+r,g+rx,o+r,g-w"}. @xref{File Permissions,,, coreutils, The 1679@code{"u+r,g+rx,o+r,g-w"}. @xref{File permissions,,, coreutils, The
1680@sc{gnu} @code{Coreutils} Manual}, for a description of file mode 1680@sc{gnu} @code{Coreutils} Manual}, for a description of file mode
1681specifications. 1681specifications.
1682@end defun 1682@end defun
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index e462c3b4ce4..b8b62325bb4 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -124,7 +124,8 @@ belong to the same character.
124 124
125@defun multibyte-string-p string 125@defun multibyte-string-p string
126Return @code{t} if @var{string} is a multibyte string, @code{nil} 126Return @code{t} if @var{string} is a multibyte string, @code{nil}
127otherwise. 127otherwise. This function also returns @code{nil} if @var{string} is
128some object other than a string.
128@end defun 129@end defun
129 130
130@defun string-bytes string 131@defun string-bytes string
diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi
index ad9f4fc1aea..f4d6b590c77 100644
--- a/doc/lispref/package.texi
+++ b/doc/lispref/package.texi
@@ -265,7 +265,7 @@ variable @code{load-file-name} (@pxref{Loading}). Here is an example:
265 Via the Package Menu, users may download packages from @dfn{package 265 Via the Package Menu, users may download packages from @dfn{package
266archives}. Such archives are specified by the variable 266archives}. Such archives are specified by the variable
267@code{package-archives}, whose default value contains a single entry: 267@code{package-archives}, whose default value contains a single entry:
268the archive hosted by the GNU project at @url{elpa.gnu.org}. This 268the archive hosted by the GNU project at @url{http://elpa.gnu.org}. This
269section describes how to set up and maintain a package archive. 269section describes how to set up and maintain a package archive.
270 270
271@cindex base location, package archive 271@cindex base location, package archive
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi
index dfa121103bc..6bbd7a3a7b7 100644
--- a/doc/lispref/syntax.texi
+++ b/doc/lispref/syntax.texi
@@ -506,6 +506,11 @@ This function returns the current syntax table, which is the table for
506the current buffer. 506the current buffer.
507@end defun 507@end defun
508 508
509@deffn Command describe-syntax &optional buffer
510This command displays the contents of the syntax table of
511@var{buffer} (by default, the current buffer) in a help buffer.
512@end deffn
513
509@defmac with-syntax-table table body@dots{} 514@defmac with-syntax-table table body@dots{}
510This macro executes @var{body} using @var{table} as the current syntax 515This macro executes @var{body} using @var{table} as the current syntax
511table. It returns the value of the last form in @var{body}, after 516table. It returns the value of the last form in @var{body}, after
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index c10458b39ae..7cace70ad07 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -1250,14 +1250,18 @@ reinsert it is @code{(abs @var{position})}. If @var{position} is
1250positive, point was at the beginning of the deleted text, otherwise it 1250positive, point was at the beginning of the deleted text, otherwise it
1251was at the end. 1251was at the end.
1252 1252
1253@item (t @var{sec-high} @var{sec-low} @var{microsec} @var{picosec}) 1253@item (t . @var{time-flag})
1254This kind of element indicates that an unmodified buffer became 1254This kind of element indicates that an unmodified buffer became
1255modified. The list @code{(@var{sec-high} @var{sec-low} @var{microsec} 1255modified. A @var{time-flag} of the form
1256@code{(@var{sec-high} @var{sec-low} @var{microsec}
1256@var{picosec})} represents the visited file's modification time as of 1257@var{picosec})} represents the visited file's modification time as of
1257when it was previously visited or saved, using the same format as 1258when it was previously visited or saved, using the same format as
1258@code{current-time}; see @ref{Time of Day}. @code{primitive-undo} uses those 1259@code{current-time}; see @ref{Time of Day}.
1260A @var{time-flag} of 0 means the buffer does not correspond to any file;
1261@minus{}1 means the visited file previously did not exist.
1262@code{primitive-undo} uses these
1259values to determine whether to mark the buffer as unmodified once again; 1263values to determine whether to mark the buffer as unmodified once again;
1260it does so only if the file's modification time matches those numbers. 1264it does so only if the file's status matches that of @var{time-flag}.
1261 1265
1262@item (nil @var{property} @var{value} @var{beg} . @var{end}) 1266@item (nil @var{property} @var{value} @var{beg} . @var{end})
1263This kind of element records a change in a text property. 1267This kind of element records a change in a text property.
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index d0f229a9c9e..2fe1914f926 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,62 @@
12013-07-08 Tassilo Horn <tsdh@gnu.org>
2
3 * gnus.texi (lines): Correct description of
4 `gnus-registry-track-extra's default value. Mention
5 `gnus-registry-remove-extra-data'.
6
72013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
8
9 * gnus.texi (Group Parameters): Mention regexp
10 substitutions (bug#11688).
11
122013-07-06 Nathan Trapuzzano <nbtrap@nbtrap.com> (tiny change)
13
14 * gnus.texi (Generic Marking Commands): Fix grammar (bug#13368).
15
162013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
17
18 * gnus.texi (Emacsen): Fix version.
19
20 * gnus-faq.texi (FAQ 1-6): Mention the correct Emacs version.
21
222013-07-06 Glenn Morris <rgm@gnu.org>
23
24 * mh-e.texi: Fix external links.
25 (Using This Manual): Printed elisp manuals no longer available.
26
27 * newsticker.texi (Overview): Update URL.
28
29 * nxml-mode.texi (Introduction): Update URL.
30
31 * org.texi (JavaScript support): Fix URL.
32
33 * wisent.texi (Wisent Overview): Remove incorrect, unnecessary uref.
34
35 * eudc.texi (CCSO PH/QI): Remove defunct URL.
36
37 * dbus.texi (Introspection): Update URL to a less defunct one.
38
39 * gnus.texi (Top): Restrict "Other related manuals" to info output.
40 (Foreign Groups): Use @indicateurl for examples.
41 (Direct Functions): Remove defunct URL.
42 (RSS): Update URL.
43
44 * gnus-faq.texi (FAQ 5-8, FAQ 6-3): Remove defunct URLs.
45 (FAQ 7-1): Update URL.
46
47 * pgg.texi (Top, Overview): Add note about obsolescence.
48
492013-07-03 Paul Eggert <eggert@cs.ucla.edu>
50
51 * texinfo.tex: Merge from gnulib.
52
532013-07-03 Glenn Morris <rgm@gnu.org>
54
55 * bovine.texi (top):
56 * cc-mode.texi (AWK Mode Font Locking):
57 * mh-e.texi (Preface):
58 * url.texi (URI Parsing): Fix cross-references to other manuals.
59
12013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org> 602013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 61
3 * gnus.texi (Client-Side IMAP Splitting): 62 * gnus.texi (Client-Side IMAP Splitting):
diff --git a/doc/misc/bovine.texi b/doc/misc/bovine.texi
index 978345e5cc8..81ec2eb80ec 100644
--- a/doc/misc/bovine.texi
+++ b/doc/misc/bovine.texi
@@ -76,7 +76,7 @@ The @dfn{bovine} parser is the original @semantic{} parser, and is an
76implementation of an @acronym{LL} parser. It is good for simple 76implementation of an @acronym{LL} parser. It is good for simple
77languages. It has many conveniences making grammar writing easy. The 77languages. It has many conveniences making grammar writing easy. The
78conveniences make it less powerful than a Bison-like @acronym{LALR} 78conveniences make it less powerful than a Bison-like @acronym{LALR}
79parser. For more information, @inforef{top, the Wisent Parser Manual, 79parser. For more information, @inforef{Top, The Wisent Parser Manual,
80wisent}. 80wisent}.
81 81
82Bovine @acronym{LL} grammars are stored in files with a @file{.by} 82Bovine @acronym{LL} grammars are stored in files with a @file{.by}
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index 4fa4e12cf88..4cc5d9c5767 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -2111,7 +2111,7 @@ contributing it: send a note to @email{bug-cc-mode@@gnu.org}.
2111@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2111@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2112 2112
2113The general appearance of font-locking in AWK mode is much like in any 2113The general appearance of font-locking in AWK mode is much like in any
2114other programming mode. @xref{Faces For Font Lock,,,elisp, GNU Emacs 2114other programming mode. @xref{Faces for Font Lock,,,elisp, GNU Emacs
2115Lisp Reference Manual}. 2115Lisp Reference Manual}.
2116 2116
2117The following faces are, however, used in a non-standard fashion in 2117The following faces are, however, used in a non-standard fashion in
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index c40a5e313f5..52c3c883cc8 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -403,8 +403,11 @@ Every dictionary entry has a string as key, and a variant as value.
403The interface offers also a signal, which returns 2 parameters: an 403The interface offers also a signal, which returns 2 parameters: an
404integer, and an array consisting of elements which are a struct of a 404integer, and an array consisting of elements which are a struct of a
405string and 2 boolean values.@footnote{ The interfaces of the service 405string and 2 boolean values.@footnote{ The interfaces of the service
406@samp{org.freedesktop.Hal} are described at 406@samp{org.freedesktop.Hal} are described in
407@uref{http://people.freedesktop.org/~david/hal-spec/hal-spec.html#interfaces}.} 407@c Previous link is gone. Since HAL is now obsolete, this URL
408@c (unchanged in ~ 4 years) feels like it might go too...
409@uref{http://people.freedesktop.org/~dkukawka/hal-spec-git/hal-spec.html#interfaces,
410the HAL specification}.}
408@end defun 411@end defun
409 412
410@defun dbus-introspect-xml bus service path 413@defun dbus-introspect-xml bus service path
diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi
index 5b06cc7f11a..747494ffbde 100644
--- a/doc/misc/eudc.texi
+++ b/doc/misc/eudc.texi
@@ -150,14 +150,17 @@ phone number, email, academic information or any other details it was
150configured to. Nowadays this system is not widely used. 150configured to. Nowadays this system is not widely used.
151 151
152The system consists of two parts: a database server traditionally called 152The system consists of two parts: a database server traditionally called
153@samp{qi} and a command-line client called @samp{ph}. As of 2010, the 153@samp{qi} and a command-line client called @samp{ph}.
154code can still be downloaded from @url{http://www-dev.cites.uiuc.edu/ph/}. 154@ignore
155 155Until 2010, the code could be downloaded from
156The original command-line @samp{ph} client that comes with the 156@url{http://www-dev.cites.uiuc.edu/ph/}.
157@samp{ph/qi} distribution provides additional features like the 157@end ignore
158possibility to communicate with the server in login-mode which makes it 158
159possible to change records in the database. This is not implemented in 159The original command-line @samp{ph} client that came with the
160EUDC. 160@samp{ph/qi} distribution provided additional features that are
161not implemented in EUDC, like the possibility to communicate with the
162server in login-mode, which made it possible to change records in the
163database.
161 164
162 165
163@node BBDB 166@node BBDB
diff --git a/doc/misc/gnus-faq.texi b/doc/misc/gnus-faq.texi
index cb900626670..1a0469c14f4 100644
--- a/doc/misc/gnus-faq.texi
+++ b/doc/misc/gnus-faq.texi
@@ -222,10 +222,9 @@ Which version of Emacs do I need?
222 222
223@subsubheading Answer 223@subsubheading Answer
224 224
225Gnus 5.10 requires an Emacs version that is greater than or equal 225Gnus 5.13 requires an Emacs version that is greater than or equal
226to Emacs 20.7 or XEmacs 21.1. 226to Emacs 23.1 or XEmacs 21.1, although there are some features that
227The development versions of Gnus (aka No Gnus) requires Emacs 21 227only work on Emacs 24.
228or XEmacs 21.4.
229 228
230@node FAQ 1-7 229@node FAQ 1-7
231@subsubheading Question 1.7 230@subsubheading Question 1.7
@@ -1518,8 +1517,9 @@ cat file.face | sed 's/\\/\\\\/g;s/\"/\\\"/g;' > file.face.quoted
1518 1517
1519If you can't use compface, there's an online X-face converter at 1518If you can't use compface, there's an online X-face converter at
1520@uref{http://www.dairiki.org/xface/}. 1519@uref{http://www.dairiki.org/xface/}.
1521If you use MS Windows, you could also use the WinFace program from 1520If you use MS Windows, you could also use the WinFace program,
1522@uref{http://www.xs4all.nl/~walterln/winface/}. 1521which used to be available from
1522@indicateurl{http://www.xs4all.nl/~walterln/winface/}.
1523Now you only have to tell Gnus to include the X-face in your postings by saying 1523Now you only have to tell Gnus to include the X-face in your postings by saying
1524 1524
1525@example 1525@example
@@ -1812,15 +1812,20 @@ too.
1812Of course you can also use grep to search through your 1812Of course you can also use grep to search through your
1813local mail, but this is both slow for big archives and 1813local mail, but this is both slow for big archives and
1814inconvenient since you are not displaying the found mail 1814inconvenient since you are not displaying the found mail
1815in Gnus. Here comes nnir into action. Nnir is a front end 1815in Gnus. Here nnir comes into action. Nnir is a front end
1816to search engines like swish-e or swish++ and 1816to search engines like swish-e or swish++ and
1817others. You index your mail with one of those search 1817others. You index your mail with one of those search
1818engines and with the help of nnir you can search through 1818engines and with the help of nnir you can search through
1819the indexed mail and generate a temporary group with all 1819the indexed mail and generate a temporary group with all
1820messages which met your search criteria. If this sound 1820messages which met your search criteria. If this sounds
1821cool to you get nnir.el from 1821cool to you, get nnir.el from
1822@c FIXME Isn't this file in Gnus?
1823@ignore
1824@c Dead link 2013/7.
1822@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/} 1825@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/}
1823or @uref{ftp://ftp.is.informatik.uni-duisburg.de/pub/src/emacs/}. 1826or
1827@end ignore
1828@uref{ftp://ftp.is.informatik.uni-duisburg.de/pub/src/emacs/}.
1824Instructions on how to use it are at the top of the file. 1829Instructions on how to use it are at the top of the file.
1825 1830
1826@node FAQ 6-4 1831@node FAQ 6-4
@@ -1943,7 +1948,7 @@ the easiest solution is a small nntp server like
1943@uref{http://infa.abo.fi/~patrik/sn/, sn}, 1948@uref{http://infa.abo.fi/~patrik/sn/, sn},
1944of course you can also install a full featured news 1949of course you can also install a full featured news
1945server like 1950server like
1946@uref{http://www.isc.org/products/INN/, inn}. 1951@uref{http://www.isc.org/software/inn/, inn}.
1947Then you want to fetch your Mail, popular choices 1952Then you want to fetch your Mail, popular choices
1948are @uref{http://www.catb.org/~esr/fetchmail/, fetchmail} 1953are @uref{http://www.catb.org/~esr/fetchmail/, fetchmail}
1949and @uref{http://pyropus.ca/software/getmail/, getmail}. 1954and @uref{http://pyropus.ca/software/getmail/, getmail}.
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 6df72f87fc7..e5ba2c19eec 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -420,6 +420,9 @@ This manual corresponds to Gnus v5.13
420* Index:: Variable, function and concept index. 420* Index:: Variable, function and concept index.
421* Key Index:: Key Index. 421* Key Index:: Key Index.
422 422
423@c Doesn't work right in html.
424@c FIXME Do this in a more standard way.
425@ifinfo
423Other related manuals 426Other related manuals
424 427
425* Message:(message). Composing messages. 428* Message:(message). Composing messages.
@@ -427,6 +430,7 @@ Other related manuals
427* Sieve:(sieve). Managing Sieve scripts in Emacs. 430* Sieve:(sieve). Managing Sieve scripts in Emacs.
428* EasyPG:(epa). @acronym{PGP/MIME} with Gnus. 431* EasyPG:(epa). @acronym{PGP/MIME} with Gnus.
429* SASL:(sasl). @acronym{SASL} authentication in Emacs. 432* SASL:(sasl). @acronym{SASL} authentication in Emacs.
433@end ifinfo
430 434
431@detailmenu 435@detailmenu
432 --- The Detailed Node Listing --- 436 --- The Detailed Node Listing ---
@@ -2712,11 +2716,11 @@ the article range.
2712This command is similar to @code{gnus-read-ephemeral-gmane-group}, but 2716This command is similar to @code{gnus-read-ephemeral-gmane-group}, but
2713the group name and the article number and range are constructed from a 2717the group name and the article number and range are constructed from a
2714given @acronym{URL}. Supported @acronym{URL} formats include: 2718given @acronym{URL}. Supported @acronym{URL} formats include:
2715@url{http://thread.gmane.org/gmane.foo.bar/12300/focus=12399}, 2719@indicateurl{http://thread.gmane.org/gmane.foo.bar/12300/focus=12399},
2716@url{http://thread.gmane.org/gmane.foo.bar/12345/}, 2720@indicateurl{http://thread.gmane.org/gmane.foo.bar/12345/},
2717@url{http://article.gmane.org/gmane.foo.bar/12345/}, 2721@indicateurl{http://article.gmane.org/gmane.foo.bar/12345/},
2718@url{http://permalink.gmane.org/gmane.foo.bar/12345/}, and 2722@indicateurl{http://permalink.gmane.org/gmane.foo.bar/12345/}, and
2719@url{http://news.gmane.org/group/gmane.foo.bar/thread=12345}. 2723@indicateurl{http://news.gmane.org/group/gmane.foo.bar/thread=12345}.
2720 2724
2721@item gnus-read-ephemeral-emacs-bug-group 2725@item gnus-read-ephemeral-emacs-bug-group
2722@findex gnus-read-ephemeral-emacs-bug-group 2726@findex gnus-read-ephemeral-emacs-bug-group
@@ -3087,6 +3091,12 @@ if address "sender" ["name@@one.org", "else@@two.org"] @{
3087@} 3091@}
3088@end example 3092@end example
3089 3093
3094You can also use regexp expansions in the rules:
3095
3096@example
3097(sieve header :regex "list-id" "<c++std-\\1.accu.org>")
3098@end example
3099
3090See @pxref{Sieve Commands} for commands and variables that might be of 3100See @pxref{Sieve Commands} for commands and variables that might be of
3091interest in relation to the sieve parameter. 3101interest in relation to the sieve parameter.
3092 3102
@@ -6376,10 +6386,10 @@ The default is @code{t}.
6376@node Generic Marking Commands 6386@node Generic Marking Commands
6377@subsection Generic Marking Commands 6387@subsection Generic Marking Commands
6378 6388
6379Some people would like the command that ticks an article (@kbd{!}) go to 6389Some people would like the command that ticks an article (@kbd{!}) to
6380the next article. Others would like it to go to the next unread 6390go to the next article. Others would like it to go to the next unread
6381article. Yet others would like it to stay on the current article. And 6391article. Yet others would like it to stay on the current article.
6382even though I haven't heard of anybody wanting it to go to the 6392And even though I haven't heard of anybody wanting it to go to the
6383previous (unread) article, I'm sure there are people that want that as 6393previous (unread) article, I'm sure there are people that want that as
6384well. 6394well.
6385 6395
@@ -13809,9 +13819,12 @@ installed. You then define a server as follows:
13809@findex nntp-open-ssl-stream 13819@findex nntp-open-ssl-stream
13810@item nntp-open-ssl-stream 13820@item nntp-open-ssl-stream
13811Opens a connection to a server over a @dfn{secure} channel. To use 13821Opens a connection to a server over a @dfn{secure} channel. To use
13812this you must have @uref{http://www.openssl.org, OpenSSL} or 13822this you must have @uref{http://www.openssl.org, OpenSSL}
13813@uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL, SSLeay} installed. You 13823@ignore
13814then define a server as follows: 13824@c Defunct URL, ancient package, so don't mention it.
13825or @uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL, SSLeay}
13826@end ignore
13827installed. You then define a server as follows:
13815 13828
13816@lisp 13829@lisp
13817;; @r{"snews" is port 563 and is predefined in our @file{/etc/services}} 13830;; @r{"snews" is port 563 and is predefined in our @file{/etc/services}}
@@ -16953,7 +16966,7 @@ Some web sites have an RDF Site Summary (@acronym{RSS}).
16953@acronym{RSS} is a format for summarizing headlines from news related 16966@acronym{RSS} is a format for summarizing headlines from news related
16954sites (such as BBC or CNN). But basically anything list-like can be 16967sites (such as BBC or CNN). But basically anything list-like can be
16955presented as an @acronym{RSS} feed: weblogs, changelogs or recent 16968presented as an @acronym{RSS} feed: weblogs, changelogs or recent
16956changes to a wiki (e.g., @url{http://cliki.net/recent-changes.rdf}). 16969changes to a wiki (e.g., @url{http://cliki.net/site/recent-changes}).
16957 16970
16958@acronym{RSS} has a quite regular and nice interface, and it's 16971@acronym{RSS} has a quite regular and nice interface, and it's
16959possible to get the information Gnus needs to keep groups updated. 16972possible to get the information Gnus needs to keep groups updated.
@@ -25993,9 +26006,13 @@ following variables.
25993 26006
25994@defvar gnus-registry-track-extra 26007@defvar gnus-registry-track-extra
25995This is a list of symbols, so it's best to change it from the 26008This is a list of symbols, so it's best to change it from the
25996Customize interface. By default it's @code{(subject sender)}, which 26009Customize interface. By default it's @code{(subject sender recipient)},
25997may work for you. It can be annoying if your mail flow is large and 26010which may work for you. It can be annoying if your mail flow is large
25998people don't stick to the same groups. 26011and people don't stick to the same groups.
26012
26013When you decide to stop tracking any of those extra data, you can use
26014the command @code{gnus-registry-remove-extra-data} to purge it from
26015the existing registry entries.
25999@end defvar 26016@end defvar
26000 26017
26001@defvar gnus-registry-split-strategy 26018@defvar gnus-registry-split-strategy
@@ -26568,7 +26585,7 @@ This version of Gnus should work on:
26568@itemize @bullet 26585@itemize @bullet
26569 26586
26570@item 26587@item
26571Emacs 21.1 and up. 26588Emacs 23.1 and up.
26572 26589
26573@item 26590@item
26574XEmacs 21.4 and up. 26591XEmacs 21.4 and up.
diff --git a/doc/misc/mh-e.texi b/doc/misc/mh-e.texi
index 154120f2e3b..a0ea0fe6de9 100644
--- a/doc/misc/mh-e.texi
+++ b/doc/misc/mh-e.texi
@@ -233,7 +233,7 @@ read an online tutorial by starting GNU Emacs and typing @kbd{C-h t}
233@cite{GNU Emacs Manual}, 233@cite{GNU Emacs Manual},
234@end iftex 234@end iftex
235@ifinfo 235@ifinfo
236@ref{top, , GNU Emacs Manual, emacs, GNU Emacs Manual}, 236@ref{Top, , GNU Emacs Manual, emacs, GNU Emacs Manual},
237@end ifinfo 237@end ifinfo
238@ifhtml 238@ifhtml
239@uref{http://www.gnu.org/software/emacs/manual/html_node/emacs/, 239@uref{http://www.gnu.org/software/emacs/manual/html_node/emacs/,
@@ -1121,38 +1121,23 @@ exist,
1121@footnote{The @cite{GNU Emacs Lisp Reference Manual} may be available 1121@footnote{The @cite{GNU Emacs Lisp Reference Manual} may be available
1122online in the Info system by typing @kbd{C-h i m Emacs Lisp 1122online in the Info system by typing @kbd{C-h i m Emacs Lisp
1123@key{RET}}. It is also available online at @* 1123@key{RET}}. It is also available online at @*
1124@uref{http://www.gnu.org/savannah-checkouts/gnu/emacs/manual/html_node/elisp/}. 1124@uref{http://www.gnu.org/software/emacs/manual/elisp.html}.}
1125You can also order a printed manual, which has the desirable
1126side-effect of helping to support the Free Software Foundation which
1127made all this great software available. You can find an order form by
1128running @kbd{C-h C-d}, or you can request an order form from @i{gnu at
1129gnu.org}.}
1130@end iftex 1125@end iftex
1131@ifinfo 1126@ifinfo
1132@footnote{@xref{Top, The GNU Emacs Lisp Reference Manual, , elisp, GNU 1127@footnote{@xref{Top, The GNU Emacs Lisp Reference Manual, , elisp, GNU
1133Emacs Lisp Reference Manual}, which may be available online in the 1128Emacs Lisp Reference Manual}, which may be available online in the
1134Info system. It is also available online at 1129Info system. It is also available online at
1135@uref{http://www.gnu.org/savannah-checkouts/gnu/emacs/manual/html_node/elisp/}. 1130@uref{http://www.gnu.org/software/emacs/manual/elisp.html}.}
1136You can also order a printed manual, which has the desirable
1137side-effect of helping to support the Free Software Foundation which
1138made all this great software available. You can find an order form by
1139running @kbd{C-h C-d}, or you can request an order form from @i{gnu at
1140gnu.org}.}
1141@end ifinfo 1131@end ifinfo
1142@ifhtml 1132@ifhtml
1143@footnote{The 1133@footnote{The
1144@uref{http://www.gnu.org/savannah-checkouts/gnu/emacs/manual/html_node/elisp/, 1134@uref{http://www.gnu.org/software/emacs/manual/elisp.html,
1145The GNU Emacs Lisp Reference Manual} may also be available online in 1135The GNU Emacs Lisp Reference Manual} may also be available online in
1146the Info system by typing @kbd{C-h i m Emacs Lisp @key{RET}}. You can 1136the Info system by typing @kbd{C-h i m Emacs Lisp @key{RET}}.}
1147also order a printed manual, which has the desirable side-effect of
1148helping to support the Free Software Foundation which made all this
1149great software available. You can find an order form by running
1150@kbd{C-h C-d}, or you can request an order form from @i{gnu at
1151gnu.org}.}
1152@end ifhtml 1137@end ifhtml
1153and you can look at the code itself for examples. Look in the Emacs 1138and you can look at the code itself for examples. Look in the Emacs
1154Lisp directory on your system (such as 1139Lisp directory on your system (such as
1155@file{/usr/local/lib/emacs/lisp/mh-e}) and find all the @file{mh-*.el} 1140@file{/usr/local/share/emacs/lisp/mh-e}) and find all the @file{mh-*.el}
1156files there. When calling MH-E and other Emacs Lisp functions directly 1141files there. When calling MH-E and other Emacs Lisp functions directly
1157from Emacs Lisp code, you'll need to know the correct arguments. Use 1142from Emacs Lisp code, you'll need to know the correct arguments. Use
1158the online help for this. For example, try @kbd{C-h f 1143the online help for this. For example, try @kbd{C-h f
@@ -2848,7 +2833,7 @@ See @cite{The PGG Manual}.
2848@end ifinfo 2833@end ifinfo
2849@ifhtml 2834@ifhtml
2850See 2835See
2851@uref{http://www.dk.xemacs.org/Documentation/packages/html/pgg.html, 2836@uref{http://www.gnu.org/software/emacs/manual/pgg.html,
2852@cite{The PGG Manual}}. 2837@cite{The PGG Manual}}.
2853@end ifhtml 2838@end ifhtml
2854 2839
@@ -5058,7 +5043,7 @@ for the next hook function. The standard prefix
5058@vindex mh-yank-behavior 5043@vindex mh-yank-behavior
5059 5044
5060For example, if you use the hook function 5045For example, if you use the hook function
5061@uref{http://shasta.cs.uiuc.edu/~lrclause/tc.html, 5046@uref{http://www.emacswiki.org/emacs/TrivialCite,
5062@code{trivial-cite}} (which is NOT part of Emacs), set 5047@code{trivial-cite}} (which is NOT part of Emacs), set
5063@code{mh-yank-behavior} to @samp{Body and Header}. 5048@code{mh-yank-behavior} to @samp{Body and Header}.
5064 5049
@@ -5615,7 +5600,7 @@ See @cite{The PGG Manual}.
5615@end ifinfo 5600@end ifinfo
5616@ifhtml 5601@ifhtml
5617See 5602See
5618@uref{http://www.dk.xemacs.org/Documentation/packages/html/pgg.html, 5603@uref{http://www.gnu.org/software/emacs/manual/pgg.html,
5619@cite{The PGG Manual}}. 5604@cite{The PGG Manual}}.
5620@end ifhtml 5605@end ifhtml
5621 5606
diff --git a/doc/misc/newsticker.texi b/doc/misc/newsticker.texi
index 8f37453524c..ab3bffc2ce9 100644
--- a/doc/misc/newsticker.texi
+++ b/doc/misc/newsticker.texi
@@ -89,7 +89,7 @@ works with the following RSS formats:
89as well as the following Atom formats: 89as well as the following Atom formats:
90@item Atom 0.3 90@item Atom 0.3
91@item Atom 1.0 (see 91@item Atom 1.0 (see
92@uref{http://www.ietf.org/internet-drafts/draft-ietf-atompub-format-11.txt}). 92@uref{https://datatracker.ietf.org/doc/rfc4287/}).
93@end itemize 93@end itemize
94 94
95That makes Newsticker.el an ``Atom aggregator'', ``RSS reader'', ``Feed 95That makes Newsticker.el an ``Atom aggregator'', ``RSS reader'', ``Feed
diff --git a/doc/misc/nxml-mode.texi b/doc/misc/nxml-mode.texi
index 13e91d12819..8c81b6fbd20 100644
--- a/doc/misc/nxml-mode.texi
+++ b/doc/misc/nxml-mode.texi
@@ -86,7 +86,11 @@ convert a RELAX NG XML syntax schema to an RNC schema.
86 86
87@noindent To convert a RELAX NG XML syntax (@samp{.rng}) schema to a RNC 87@noindent To convert a RELAX NG XML syntax (@samp{.rng}) schema to a RNC
88one, you can also use the XSLT stylesheet from 88one, you can also use the XSLT stylesheet from
89@url{https://github.com/oleg-pavliv/emacs/tree/master/xsl}.
90@ignore
91@c Original location, now defunct.
89@url{http://www.pantor.com/download.html}. 92@url{http://www.pantor.com/download.html}.
93@end ignore
90 94
91To convert a W3C XML Schema to an RNC schema, you need first to convert it 95To convert a W3C XML Schema to an RNC schema, you need first to convert it
92to RELAX NG XML syntax using the RELAX NG converter tool @code{rngconv} 96to RELAX NG XML syntax using the RELAX NG converter tool @code{rngconv}
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 1d7de18ada6..832976e9ea0 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -10393,7 +10393,7 @@ view type is a @emph{folding} view much like Org provides inside Emacs. The
10393script is available at @url{http://orgmode.org/org-info.js} and you can find 10393script is available at @url{http://orgmode.org/org-info.js} and you can find
10394the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}. 10394the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
10395We host the script at our site, but if you use it a lot, you might 10395We host the script at our site, but if you use it a lot, you might
10396not want to be dependent on @url{orgmode.org} and prefer to install a local 10396not want to be dependent on @url{http://orgmode.org} and prefer to install a local
10397copy on your own web server. 10397copy on your own web server.
10398 10398
10399To use the script, you need to make sure that the @file{org-jsinfo.el} module 10399To use the script, you need to make sure that the @file{org-jsinfo.el} module
diff --git a/doc/misc/pgg.texi b/doc/misc/pgg.texi
index a18a22e649f..370998c855a 100644
--- a/doc/misc/pgg.texi
+++ b/doc/misc/pgg.texi
@@ -54,6 +54,8 @@ modify this GNU manual.''
54PGG is an interface library between Emacs 54PGG is an interface library between Emacs
55and various tools for secure communication. PGG also provides a simple 55and various tools for secure communication. PGG also provides a simple
56user interface to encrypt, decrypt, sign, and verify MIME messages. 56user interface to encrypt, decrypt, sign, and verify MIME messages.
57This package is obsolete; for new code we recommend EasyPG instead.
58@xref{Top,, EasyPG, epa, EasyPG Assistant User's Manual}.
57 59
58@ifnottex 60@ifnottex
59@insertcopying 61@insertcopying
@@ -78,6 +80,9 @@ communication. Even though Mailcrypt has similar feature, it does not
78deal with detached PGP messages, normally used in PGP/MIME 80deal with detached PGP messages, normally used in PGP/MIME
79infrastructure. This was the main reason why I wrote the new library. 81infrastructure. This was the main reason why I wrote the new library.
80 82
83Note that the PGG library is now obsolete, replaced by EasyPG.
84@xref{Top,, EasyPG, epa, EasyPG Assistant User's Manual}.
85
81PGP/MIME is an application of MIME Object Security Services (RFC1848). 86PGP/MIME is an application of MIME Object Security Services (RFC1848).
82The standard is documented in RFC2015. 87The standard is documented in RFC2015.
83 88
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index 85f184cc4cb..3427d2ad0e3 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
3% Load plain if necessary, i.e., if running under initex. 3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5% 5%
6\def\texinfoversion{2013-02-01.11} 6\def\texinfoversion{2013-06-23.10}
7% 7%
8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, 8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -2475,14 +2475,14 @@ end
2475} 2475}
2476 2476
2477% We *must* turn on hyphenation at `-' and `_' in @code. 2477% We *must* turn on hyphenation at `-' and `_' in @code.
2478% (But see \codedashfinish below.)
2478% Otherwise, it is too hard to avoid overfull hboxes 2479% Otherwise, it is too hard to avoid overfull hboxes
2479% in the Emacs manual, the Library manual, etc. 2480% in the Emacs manual, the Library manual, etc.
2480% 2481%
2481% Unfortunately, TeX uses one parameter (\hyphenchar) to control 2482% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2482% both hyphenation at - and hyphenation within words. 2483% both hyphenation at - and hyphenation within words.
2483% We must therefore turn them both off (\tclose does that) 2484% We must therefore turn them both off (\tclose does that)
2484% and arrange explicitly to hyphenate at a dash. 2485% and arrange explicitly to hyphenate at a dash. -- rms.
2485% -- rms.
2486{ 2486{
2487 \catcode`\-=\active \catcode`\_=\active 2487 \catcode`\-=\active \catcode`\_=\active
2488 \catcode`\'=\active \catcode`\`=\active 2488 \catcode`\'=\active \catcode`\`=\active
@@ -2499,14 +2499,33 @@ end
2499 \let-\normaldash 2499 \let-\normaldash
2500 \let_\realunder 2500 \let_\realunder
2501 \fi 2501 \fi
2502 % Given -foo (with a single dash), we do not want to allow a break
2503 % after the hyphen.
2504 \global\let\codedashprev=\codedash
2505 %
2502 \codex 2506 \codex
2503 } 2507 }
2508 %
2509 \gdef\codedash{\futurelet\next\codedashfinish}
2510 \gdef\codedashfinish{%
2511 \normaldash % always output the dash character itself.
2512 %
2513 % Now, output a discretionary to allow a line break, unless
2514 % (a) the next character is a -, or
2515 % (b) the preceding character is a -.
2516 % E.g., given --posix, we do not want to allow a break after either -.
2517 % Given --foo-bar, we do want to allow a break between the - and the b.
2518 \ifx\next\codedash \else
2519 \ifx\codedashprev\codedash
2520 \else \discretionary{}{}{}\fi
2521 \fi
2522 \global\let\codedashprev=\next
2523 }
2504} 2524}
2505 2525\def\normaldash{-}
2526%
2506\def\codex #1{\tclose{#1}\endgroup} 2527\def\codex #1{\tclose{#1}\endgroup}
2507 2528
2508\def\normaldash{-}
2509\def\codedash{-\discretionary{}{}{}}
2510\def\codeunder{% 2529\def\codeunder{%
2511 % this is all so @math{@code{var_name}+1} can work. In math mode, _ 2530 % this is all so @math{@code{var_name}+1} can work. In math mode, _
2512 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) 2531 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
@@ -4211,8 +4230,9 @@ end
4211 4230
4212% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined 4231% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4213% with @set. 4232% with @set.
4214% 4233%
4215% To get special treatment of `@end ifset,' call \makeond and the redefine. 4234% To get the special treatment we need for `@end ifset,' we call
4235% \makecond and then redefine.
4216% 4236%
4217\makecond{ifset} 4237\makecond{ifset}
4218\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} 4238\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
@@ -6402,7 +6422,7 @@ end
6402\newdimen\nonfillparindent 6422\newdimen\nonfillparindent
6403\def\nonfillstart{% 6423\def\nonfillstart{%
6404 \aboveenvbreak 6424 \aboveenvbreak
6405 \hfuzz = 12pt % Don't be fussy 6425 \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
6406 \sepspaces % Make spaces be word-separators rather than space tokens. 6426 \sepspaces % Make spaces be word-separators rather than space tokens.
6407 \let\par = \lisppar % don't ignore blank lines 6427 \let\par = \lisppar % don't ignore blank lines
6408 \obeylines % each line of input is a line of output 6428 \obeylines % each line of input is a line of output
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index 49f8f3f0959..fdec68b1c61 100644
--- a/doc/misc/url.texi
+++ b/doc/misc/url.texi
@@ -138,7 +138,7 @@ Given a parsed URI, this function returns the corresponding URI string.
138 The return value of @code{url-generic-parse-url}, and the argument 138 The return value of @code{url-generic-parse-url}, and the argument
139expected by @code{url-recreate-url}, is a @dfn{parsed URI}: a CL 139expected by @code{url-recreate-url}, is a @dfn{parsed URI}: a CL
140structure whose slots hold the various components of the URI@. 140structure whose slots hold the various components of the URI@.
141@xref{top,the CL Manual,,cl,GNU Emacs Common Lisp Emulation}, for 141@xref{Top,the CL Manual,,cl,GNU Emacs Common Lisp Emulation}, for
142details about CL structures. Most of the other functions in the 142details about CL structures. Most of the other functions in the
143@code{url} library act on parsed URIs. 143@code{url} library act on parsed URIs.
144 144
diff --git a/doc/misc/wisent.texi b/doc/misc/wisent.texi
index d8557b84a4f..c0f18f6363a 100644
--- a/doc/misc/wisent.texi
+++ b/doc/misc/wisent.texi
@@ -113,9 +113,6 @@ of GNU Bison 1.28 & 1.31.
113 113
114For more details on the basic concepts for understanding Wisent, it is 114For more details on the basic concepts for understanding Wisent, it is
115worthwhile to read the @ref{Top, Bison Manual, , bison}. 115worthwhile to read the @ref{Top, Bison Manual, , bison}.
116@ifhtml
117@uref{http://www.gnu.org/manual/bison/html_node/index.html}.
118@end ifhtml
119 116
120Wisent can generate compilers compatible with the @semantic{} tool set. 117Wisent can generate compilers compatible with the @semantic{} tool set.
121See the @ref{Top, Semantic Manual, , semantic}. 118See the @ref{Top, Semantic Manual, , semantic}.
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 93ba05bc377..02b13e12945 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,26 @@
12013-07-13 Eli Zaretskii <eliz@gnu.org>
2
3 * NEWS: Document prefer-utf-8 and the new attributes
4 :inhibit-null-byte-detection, :inhibit-iso-escape-detection, and
5 :prefer-utf-8.
6
72013-07-13 Leo Liu <sdl.web@gmail.com>
8
9 * NEWS: Mention new value for ido-use-virtual-buffers.
10
112013-07-10 Paul Eggert <eggert@cs.ucla.edu>
12
13 Timestamp fixes for undo (Bug#14824).
14 * NEWS: Changes to visited-file-modtime, set-visited-file-modtime.
15
162013-07-08 Jan Djärv <jan.h.d@swipnet.se>
17
18 * NEWS: NS can be built with ImageMagick.
19
202013-07-06 Juanma Barranquero <lekktu@gmail.com>
21
22 * NEWS: Document new "generic commands" support.
23
12013-06-27 Juanma Barranquero <lekktu@gmail.com> 242013-06-27 Juanma Barranquero <lekktu@gmail.com>
2 25
3 * NEWS: Document new Desktop option `desktop-save-windows'. 26 * NEWS: Document new Desktop option `desktop-save-windows'.
diff --git a/etc/NEWS b/etc/NEWS
index f83d82417dd..03174a0137f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -15,10 +15,10 @@ You can narrow news to a specific version by calling `view-emacs-news'
15with a prefix argument or by typing C-u C-h C-n. 15with a prefix argument or by typing C-u C-h C-n.
16 16
17Temporary note: 17Temporary note:
18+++ indicates that the appropriate manual has already been updated. 18+++ indicates that all necessary updates to the manuals in doc/ are complete.
19--- means no change in the manuals is called for. 19--- means no change in the manuals is needed.
20When you add a new item, please add it without either +++ or --- 20When you add a new item, use the appropriate mark if you know it applies,
21so we will look at it and add it to the manual. 21otherwise leave it unmarked.
22 22
23 23
24* Installation Changes in Emacs 24.4 24* Installation Changes in Emacs 24.4
@@ -29,37 +29,22 @@ build time, like libacl on GNU/Linux. To prevent this, use the
29configure option `--disable-acl'. 29configure option `--disable-acl'.
30 30
31** Emacs can be compiled with file notification support. 31** Emacs can be compiled with file notification support.
32The configure option `--with-file-notification=LIB' enables file 32This happens by default if a suitable system library is found at
33notification support in Emacs. This option's value should be `yes', 33build time. To prevent this, use the configure option
34`no', `gfile', `inotify' or `w32'. `yes' is a synonym for `w32' on 34`--with-file-notification-no'. See below for file-notify features.
35MS-Windows, and for `gfile' otherwise. The default value is `yes'. 35FIXME? This feature is not available for the Nextstep port. (?)
36 36
37** The configure option --with-crt-dir has been removed. 37** The configure option --with-crt-dir has been removed.
38It is no longer needed, as the crt*.o files are no longer linked 38It is no longer needed, as the crt*.o files are no longer linked
39specially. 39specially.
40 40
41** Emacs for MS-Windows can now be built by running the configure script
42using the MSYS environment and MinGW development tools.
43This is from now on the preferred method of building Emacs on
44MS-Windows. The Windows-specific configure.bat and makefile.w32-in
45files are deprecated. See the file nt/INSTALL.MSYS for detailed
46instructions.
47
48Using the Posix configure script and Makefile's also means a change in
49the directory structure of the Emacs installation on Windows. It is
50now the same as on GNU and Unix systems. In particular, the auxiliary
51programs, such as cmdproxy.exe and hexl.exe, are in
52libexec/emacs/VERSION/i686-pc-mingw32 (where VERSION is the Emacs
53version), version-independent site-lisp is in share/emacs/site-lisp,
54version-specific Lisp files are in share/emacs/VERSION/lisp and in
55share/emacs/VERSION/site-lisp, Info docs are in share/info, and data
56files are in share/emacs/VERSION/etc. (Emacs knows about all these
57directories and will find the files in there automatically; there's no
58need to set any variables due to this change.)
59
60** Directories passed to configure option `--enable-locallisppath' are 41** Directories passed to configure option `--enable-locallisppath' are
61no longer created during installation. 42no longer created during installation.
62 43
44---
45** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support.
46pkg-config is required to find ImageMagick libraries.
47
63 48
64* Startup Changes in Emacs 24.4 49* Startup Changes in Emacs 24.4
65 50
@@ -125,6 +110,18 @@ used to conveniently prepend/append new face attributes to text.
125`frame-monitor-attributes' can be used to obtain information about 110`frame-monitor-attributes' can be used to obtain information about
126each physical monitor on multi-monitor setups. 111each physical monitor on multi-monitor setups.
127 112
113*** The functions `display-pixel-width' and `display-pixel-height' now
114behave consistently among the platforms: they return the pixel width
115or height for all physical monitors associated with the given display
116as just they were on X11. To get information for each physical
117monitor, use the new functions above. Similar notes also apply to
118`x-display-pixel-width', `x-display-pixel-height', `display-mm-width',
119`display-mm-height', `x-display-mm-width', and `x-display-mm-height'.
120
121** New macro `alternatives-define' can be used to define generic commands.
122Generic commands are interactive functions whose implementation can be
123selected among several alternatives, as a matter of user preference.
124
128 125
129* Editing Changes in Emacs 24.4 126* Editing Changes in Emacs 24.4
130 127
@@ -177,6 +174,8 @@ You can use the new function `remember-store-in-files' within the
177 174
178See `remember-data-directory' and `remember-directory-file-name-format' 175See `remember-data-directory' and `remember-directory-file-name-format'
179for new options related to this function. 176for new options related to this function.
177
178** `ido-use-virtual-buffers' takes a new value 'auto.
180** `ido-decorations' has been slightly extended to give a bit more control. 179** `ido-decorations' has been slightly extended to give a bit more control.
181 180
182** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>. 181** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>.
@@ -218,6 +217,10 @@ The default separator is changed to allow surrounding spaces around the comma.
218 217
219*** Battery information via the BSD `apm' utility is now supported. 218*** Battery information via the BSD `apm' utility is now supported.
220 219
220** Buffer Menu
221
222*** `M-s a C-o' shows lines matching a regexp in marked buffers using Occur.
223
221** Calendar and Diary 224** Calendar and Diary
222 225
223+++ 226+++
@@ -252,7 +255,7 @@ on the given date.
252*** `desktop-auto-save-timeout' defines the number of seconds between 255*** `desktop-auto-save-timeout' defines the number of seconds between
253auto-saves of the desktop. 256auto-saves of the desktop.
254 257
255*** `desktop-restore-frames enables saving and restoring the window/frame 258*** `desktop-restore-frames' enables saving and restoring the window/frame
256configuration. 259configuration.
257 260
258** Dired 261** Dired
@@ -407,6 +410,10 @@ when possible.
407*** Handlers for `file-acl' and `set-file-acl' for remote machines 410*** Handlers for `file-acl' and `set-file-acl' for remote machines
408which support POSIX ACLs. 411which support POSIX ACLs.
409 412
413+++
414*** Handlers for `file-notify-add-watch' and `file-notify-rm-watch'
415for remote machines which support filesystem notifications.
416
410** VHDL mode 417** VHDL mode
411 418
412*** New options: `vhdl-actual-generic-name', `vhdl-beautify-options'. 419*** New options: `vhdl-actual-generic-name', `vhdl-beautify-options'.
@@ -416,13 +423,13 @@ which support POSIX ACLs.
416** Woman 423** Woman
417 424
418*** The commands `woman-default-faces' and `woman-monochrome-faces' 425*** The commands `woman-default-faces' and `woman-monochrome-faces'
419are obsolete. Customize the `woman-* faces instead. 426are obsolete. Customize the `woman-*' faces instead.
420 427
421** Eshell 428** Eshell
422 429
423*** Added Eshell-TRAMP module 430*** Added Eshell-Tramp module
424External su and sudo commands are now the default; the internal, 431External su and sudo commands are now the default; the internal,
425TRAMP-using variants can still be used by enabling the eshell-tramp 432Tramp-using variants can still be used by enabling the eshell-tramp
426module. 433module.
427 434
428** New term.el option `term-suppress-hard-newline'. 435** New term.el option `term-suppress-hard-newline'.
@@ -462,6 +469,10 @@ It is layered as:
462- advice-add/advice-remove to add/remove a piece of advice on a named function, 469- advice-add/advice-remove to add/remove a piece of advice on a named function,
463 much like `defadvice' does. 470 much like `defadvice' does.
464 471
472** The package file-notify.el provides an interface for file system
473notifications. It requires, that Emacs is compiled with one of the
474low-level libraries gfilenotify.c, inotify.c or w32notify.c.
475
465 476
466* Incompatible Lisp Changes in Emacs 24.4 477* Incompatible Lisp Changes in Emacs 24.4
467 478
@@ -509,9 +520,14 @@ alist of extended attributes as returned by the new function
509`file-extended-attributes'. The attributes can be applied to another 520`file-extended-attributes'. The attributes can be applied to another
510file using `set-file-extended-attributes'. 521file using `set-file-extended-attributes'.
511 522
523** `visited-file-modtime' now returns -1 for nonexistent files.
524Formerly it returned a list (-1 LOW USEC PSEC), but this was ambiguous
525in the presence of files with negative time stamps.
512 526
513* Lisp Changes in Emacs 24.4 527* Lisp Changes in Emacs 24.4
514 528
529** New hook `tty-setup-hook'.
530
515+++ 531+++
516** New macro with-eval-after-load. Like eval-after-load, but better behaved. 532** New macro with-eval-after-load. Like eval-after-load, but better behaved.
517 533
@@ -583,6 +599,38 @@ Emacs uses `image-default-frame-delay'.
583*** New functions `image-current-frame' and `image-show-frame' for getting 599*** New functions `image-current-frame' and `image-show-frame' for getting
584and setting the current frame of a multi-frame image. 600and setting the current frame of a multi-frame image.
585 601
602** Changes in encoding and decoding of text
603
604---
605*** New coding-system `prefer-utf-8'.
606This is like `undecided' but prefers UTF-8 on decoding if the text to
607be decoded does not contain any invalid UTF-8 sequences. On encoding,
608any non-ASCII characters are automatically encoded as UTF-8.
609
610---
611*** New attributes of coding-systems whose type is `undecided'.
612Two new attributes, `:inhibit-null-byte-detection' and
613`:inhibit-iso-escape-detection', determine how to detect encoding of
614text that includes null bytes and ISO-2022 escape sequences,
615respectively. Each of these attributes can be either nil, zero, or
616t. If it is t, decoding text ignores null bytes and, respectively,
617ISO-2022 sequences. If it is nil, null bytes cause text to be decoded
618with no-conversion and ISO-2022 sequences cause Emacs to assume the
619text is encoded in one of the ISO-2022 encodings, such as
620iso-2022-7bit. If the value is zero, Emacs consults the variables
621inhibit-null-byte-detection and inhibit-iso-escape-detection, which
622see.
623The new attribute `:prefer-utf-8', if non-nil, causes Emacs to prefer
624UTF-8 encoding and decoding, whenever possible.
625
626These attributes are only meaningful for coding-systems of type
627`undecided'. (The type of a coding-system is determined by its
628`:coding-type' attribute and can be accessed by calling the
629`coding-system-type' function.)
630
631** The function `set-visited-file-modtime' now accepts a 0 or -1 argument
632with the same interpretation as the returned value of `visited-file-modtime'.
633
586** time-to-seconds is not obsolete any more. 634** time-to-seconds is not obsolete any more.
587** New function special-form-p. 635** New function special-form-p.
588** Docstrings can be made dynamic by adding a `dynamic-docstring-function' 636** Docstrings can be made dynamic by adding a `dynamic-docstring-function'
@@ -626,6 +674,25 @@ meant to be used by other packages.
626 674
627* Changes in Emacs 24.4 on Non-Free Operating Systems 675* Changes in Emacs 24.4 on Non-Free Operating Systems
628 676
677** Emacs for MS-Windows can now be built by running the configure script
678using the MSYS environment and MinGW development tools.
679This is from now on the preferred method of building Emacs on
680MS-Windows. The Windows-specific configure.bat and makefile.w32-in
681files are deprecated. See the file nt/INSTALL.MSYS for detailed
682instructions.
683
684Using the Posix configure script and Makefile's also means a change in
685the directory structure of the Emacs installation on Windows. It is
686now the same as on GNU and Unix systems. In particular, the auxiliary
687programs, such as cmdproxy.exe and hexl.exe, are in
688libexec/emacs/VERSION/i686-pc-mingw32 (where VERSION is the Emacs
689version), version-independent site-lisp is in share/emacs/site-lisp,
690version-specific Lisp files are in share/emacs/VERSION/lisp and in
691share/emacs/VERSION/site-lisp, Info docs are in share/info, and data
692files are in share/emacs/VERSION/etc. (Emacs knows about all these
693directories and will find the files in there automatically; there's no
694need to set any variables due to this change.)
695
629+++ 696+++
630** The "generate a backtrace on fatal error" feature now works on MS Windows. 697** The "generate a backtrace on fatal error" feature now works on MS Windows.
631The backtrace is written to the 'emacs_backtrace.txt' file in the 698The backtrace is written to the 'emacs_backtrace.txt' file in the
@@ -1034,7 +1101,7 @@ file at point.
1034`DEL' (`dired-unmark-backward'), and `d' (`dired-flag-file-deletion') 1101`DEL' (`dired-unmark-backward'), and `d' (`dired-flag-file-deletion')
1035mark/unmark/flag all files in the active region. 1102mark/unmark/flag all files in the active region.
1036 1103
1037*** The minibuffer default for `=' (`dired-diff) has changed. 1104*** The minibuffer default for `=' (`dired-diff') has changed.
1038It is now the backup file for the file at point, if one exists. 1105It is now the backup file for the file at point, if one exists.
1039In Transient Mark mode the default is the file at the active mark. 1106In Transient Mark mode the default is the file at the active mark.
1040 1107
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 4a43a741e54..f41c23df5d2 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,15 @@
12013-07-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Port to C89.
4 * ebrowse.c (USAGE): Remove macro with too-long string literal ...
5 (usage_message): ... and replace it with this new static constant
6 containing multiple literals. All uses changed.
7 * emacsclient.c (print_help_and_exit):
8 Rewrite to avoid string literals longer than the C89 limits.
9 (start_daemon_and_retry_set_socket):
10 Rewrite to avoid non-constant array initializer.
11 * make-docfile.c (enum global_type): Omit trailing comma.
12
12013-07-02 Paul Eggert <eggert@cs.ucla.edu> 132013-07-02 Paul Eggert <eggert@cs.ucla.edu>
2 14
3 Prefer plain 'static' to 'static inline' (Bug#12541). 15 Prefer plain 'static' to 'static inline' (Bug#12541).
@@ -6134,7 +6146,7 @@
6134 6146
61351995-06-13 Geoff Voelker <voelker@cs.washington.edu> 61471995-06-13 Geoff Voelker <voelker@cs.washington.edu>
6136 6148
6137 * etags.c (process_file,absolute_filename): Handle filenames 6149 * etags.c (process_file, absolute_filename): Handle filenames
6138 starting with a drive letter. 6150 starting with a drive letter.
6139 6151
6140 * makefile.nt (install): Copy wakeup.exe properly. 6152 * makefile.nt (install): Copy wakeup.exe properly.
@@ -6161,12 +6173,12 @@
61611995-05-25 Geoff Voelker <voelker@cs.washington.edu> 61731995-05-25 Geoff Voelker <voelker@cs.washington.edu>
6162 6174
6163 * makefile.nt (LIBS): Use BASE_LIBS. 6175 * makefile.nt (LIBS): Use BASE_LIBS.
6164 (make-docfile.exe,hexl.exe,wakeup.exe,etags.exe): Don't depend 6176 (make-docfile.exe, hexl.exe, wakeup.exe, etags.exe): Don't depend
6165 upon LIBS. 6177 upon LIBS.
6166 (DOC): Use del instead of rm. 6178 (DOC): Use del instead of rm.
6167 (DOC) [WINDOWS95]: Use DOC. 6179 (DOC) [WINDOWS95]: Use DOC.
6168 (clean): Handle MSVC aux files. 6180 (clean): Handle MSVC aux files.
6169 (config.h,paths.h): Use $(CP) instead of cp. 6181 (config.h, paths.h): Use $(CP) instead of cp.
6170 (config.h): Use $(CONFIG_H) 6182 (config.h): Use $(CONFIG_H)
6171 (make-docfile.obj): Depend upon config.h. 6183 (make-docfile.obj): Depend upon config.h.
6172 Clean up comments. 6184 Clean up comments.
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 407f769afc8..216865c3800 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -3481,7 +3481,9 @@ open_file (char *file)
3481 3481
3482/* Display usage information and exit program. */ 3482/* Display usage information and exit program. */
3483 3483
3484#define USAGE "\ 3484static char const *const usage_message[] =
3485 {
3486 "\
3485Usage: ebrowse [options] {files}\n\ 3487Usage: ebrowse [options] {files}\n\
3486\n\ 3488\n\
3487 -a, --append append output to existing file\n\ 3489 -a, --append append output to existing file\n\
@@ -3489,6 +3491,8 @@ Usage: ebrowse [options] {files}\n\
3489 -I, --search-path=LIST set search path for input files\n\ 3491 -I, --search-path=LIST set search path for input files\n\
3490 -m, --min-regexp-length=N set minimum regexp length to N\n\ 3492 -m, --min-regexp-length=N set minimum regexp length to N\n\
3491 -M, --max-regexp-length=N set maximum regexp length to N\n\ 3493 -M, --max-regexp-length=N set maximum regexp length to N\n\
3494",
3495 "\
3492 -n, --no-nested-classes exclude nested classes\n\ 3496 -n, --no-nested-classes exclude nested classes\n\
3493 -o, --output-file=FILE set output file name to FILE\n\ 3497 -o, --output-file=FILE set output file name to FILE\n\
3494 -p, --position-info print info about position in file\n\ 3498 -p, --position-info print info about position in file\n\
@@ -3498,12 +3502,16 @@ Usage: ebrowse [options] {files}\n\
3498 -x, --no-regexps don't record regular expressions\n\ 3502 -x, --no-regexps don't record regular expressions\n\
3499 --help display this help\n\ 3503 --help display this help\n\
3500 --version display version info\n\ 3504 --version display version info\n\
3505\n\
3501" 3506"
3507 };
3502 3508
3503static _Noreturn void 3509static _Noreturn void
3504usage (int error) 3510usage (int error)
3505{ 3511{
3506 puts (USAGE); 3512 int i;
3513 for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
3514 fputs (usage_message[i], stdout);
3507 exit (error ? EXIT_FAILURE : EXIT_SUCCESS); 3515 exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
3508} 3516}
3509 3517
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 898e8d69b07..74ccfa26259 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -630,7 +630,7 @@ print_help_and_exit (void)
630 Please try to preserve them; otherwise the output is very hard to read 630 Please try to preserve them; otherwise the output is very hard to read
631 when using emacsclientw. */ 631 when using emacsclientw. */
632 message (FALSE, 632 message (FALSE,
633 "Usage: %s [OPTIONS] FILE...\n\ 633 "Usage: %s [OPTIONS] FILE...\n%s%s%s", progname, "\
634Tell the Emacs server to visit the specified files.\n\ 634Tell the Emacs server to visit the specified files.\n\
635Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ 635Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
636\n\ 636\n\
@@ -640,6 +640,7 @@ The following OPTIONS are accepted:\n\
640-nw, -t, --tty Open a new Emacs frame on the current terminal\n\ 640-nw, -t, --tty Open a new Emacs frame on the current terminal\n\
641-c, --create-frame Create a new frame instead of trying to\n\ 641-c, --create-frame Create a new frame instead of trying to\n\
642 use the current Emacs frame\n\ 642 use the current Emacs frame\n\
643", "\
643-F ALIST, --frame-parameters=ALIST\n\ 644-F ALIST, --frame-parameters=ALIST\n\
644 Set the parameters of a new frame\n\ 645 Set the parameters of a new frame\n\
645-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ 646-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
@@ -647,6 +648,7 @@ The following OPTIONS are accepted:\n\
647-q, --quiet Don't display messages on success\n\ 648-q, --quiet Don't display messages on success\n\
648-d DISPLAY, --display=DISPLAY\n\ 649-d DISPLAY, --display=DISPLAY\n\
649 Visit the file in the given display\n\ 650 Visit the file in the given display\n\
651", "\
650--parent-id=ID Open in parent window ID, via XEmbed\n" 652--parent-id=ID Open in parent window ID, via XEmbed\n"
651#ifndef NO_SOCKETS_IN_FILE_SYSTEM 653#ifndef NO_SOCKETS_IN_FILE_SYSTEM
652"-s SOCKET, --socket-name=SOCKET\n\ 654"-s SOCKET, --socket-name=SOCKET\n\
@@ -661,7 +663,7 @@ The following OPTIONS are accepted:\n\
661 mode and try connecting again\n" 663 mode and try connecting again\n"
662#endif /* not WINDOWSNT */ 664#endif /* not WINDOWSNT */
663"\n\ 665"\n\
664Report bugs with M-x report-emacs-bug.\n", progname); 666Report bugs with M-x report-emacs-bug.\n");
665 exit (EXIT_SUCCESS); 667 exit (EXIT_SUCCESS);
666} 668}
667 669
@@ -1509,7 +1511,10 @@ start_daemon_and_retry_set_socket (void)
1509 { 1511 {
1510 char emacs[] = "emacs"; 1512 char emacs[] = "emacs";
1511 char daemon_option[] = "--daemon"; 1513 char daemon_option[] = "--daemon";
1512 char *d_argv[] = {emacs, daemon_option, 0 }; 1514 char *d_argv[3];
1515 d_argv[0] = emacs;
1516 d_argv[1] = daemon_option;
1517 d_argv[2] = 0;
1513 if (socket_name != NULL) 1518 if (socket_name != NULL)
1514 { 1519 {
1515 /* Pass --daemon=socket_name as argument. */ 1520 /* Pass --daemon=socket_name as argument. */
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 9bc91bc4f77..73d1a0eb31d 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -555,7 +555,7 @@ enum global_type
555 LISP_OBJECT, 555 LISP_OBJECT,
556 EMACS_INTEGER, 556 EMACS_INTEGER,
557 BOOLEAN, 557 BOOLEAN,
558 FUNCTION, 558 FUNCTION
559}; 559};
560 560
561/* A single global. */ 561/* A single global. */
diff --git a/lib/binary-io.c b/lib/binary-io.c
new file mode 100644
index 00000000000..8bbdb44d121
--- /dev/null
+++ b/lib/binary-io.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define BINARY_IO_INLINE _GL_EXTERN_INLINE
3#include "binary-io.h"
diff --git a/lib/binary-io.h b/lib/binary-io.h
new file mode 100644
index 00000000000..317fe3d3c20
--- /dev/null
+++ b/lib/binary-io.h
@@ -0,0 +1,72 @@
1/* Binary mode I/O.
2 Copyright (C) 2001, 2003, 2005, 2008-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _BINARY_H
18#define _BINARY_H
19
20/* For systems that distinguish between text and binary I/O.
21 O_BINARY is guaranteed by the gnulib <fcntl.h>. */
22#include <fcntl.h>
23
24/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
25 so we include it here first. */
26#include <stdio.h>
27
28_GL_INLINE_HEADER_BEGIN
29#ifndef BINARY_IO_INLINE
30# define BINARY_IO_INLINE _GL_INLINE
31#endif
32
33/* set_binary_mode (fd, mode)
34 sets the binary/text I/O mode of file descriptor fd to the given mode
35 (must be O_BINARY or O_TEXT) and returns the previous mode. */
36#if O_BINARY
37# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
38# include <io.h> /* declares setmode() */
39# define set_binary_mode setmode
40# else
41# define set_binary_mode _setmode
42# undef fileno
43# define fileno _fileno
44# endif
45#else
46 /* On reasonable systems, binary I/O is the only choice. */
47 /* Use a function rather than a macro, to avoid gcc warnings
48 "warning: statement with no effect". */
49BINARY_IO_INLINE int
50set_binary_mode (int fd, int mode)
51{
52 (void) fd;
53 (void) mode;
54 return O_BINARY;
55}
56#endif
57
58/* SET_BINARY (fd);
59 changes the file descriptor fd to perform binary I/O. */
60#ifdef __DJGPP__
61# include <unistd.h> /* declares isatty() */
62 /* Avoid putting stdin/stdout in binary mode if it is connected to
63 the console, because that would make it impossible for the user
64 to interrupt the program through Ctrl-C or Ctrl-Break. */
65# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0))
66#else
67# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
68#endif
69
70_GL_INLINE_HEADER_END
71
72#endif /* _BINARY_H */
diff --git a/lib/fcntl.c b/lib/fcntl.c
new file mode 100644
index 00000000000..735fa66f4d7
--- /dev/null
+++ b/lib/fcntl.c
@@ -0,0 +1,311 @@
1/* Provide file descriptor control.
2
3 Copyright (C) 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Eric Blake <ebb9@byu.net>. */
19
20#include <config.h>
21
22/* Specification. */
23#include <fcntl.h>
24
25#include <errno.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <unistd.h>
29
30#if !HAVE_FCNTL
31# define rpl_fcntl fcntl
32#endif
33#undef fcntl
34
35#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
36/* Get declarations of the native Windows API functions. */
37# define WIN32_LEAN_AND_MEAN
38# include <windows.h>
39
40/* Get _get_osfhandle. */
41# include "msvc-nothrow.h"
42
43/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
44# define OPEN_MAX_MAX 0x10000
45
46/* Duplicate OLDFD into the first available slot of at least NEWFD,
47 which must be positive, with FLAGS determining whether the duplicate
48 will be inheritable. */
49static int
50dupfd (int oldfd, int newfd, int flags)
51{
52 /* Mingw has no way to create an arbitrary fd. Iterate until all
53 file descriptors less than newfd are filled up. */
54 HANDLE curr_process = GetCurrentProcess ();
55 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
56 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
57 unsigned int fds_to_close_bound = 0;
58 int result;
59 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
60 int mode;
61
62 if (newfd < 0 || getdtablesize () <= newfd)
63 {
64 errno = EINVAL;
65 return -1;
66 }
67 if (old_handle == INVALID_HANDLE_VALUE
68 || (mode = setmode (oldfd, O_BINARY)) == -1)
69 {
70 /* oldfd is not open, or is an unassigned standard file
71 descriptor. */
72 errno = EBADF;
73 return -1;
74 }
75 setmode (oldfd, mode);
76 flags |= mode;
77
78 for (;;)
79 {
80 HANDLE new_handle;
81 int duplicated_fd;
82 unsigned int index;
83
84 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
85 old_handle, /* SourceHandle */
86 curr_process, /* TargetProcessHandle */
87 (PHANDLE) &new_handle, /* TargetHandle */
88 (DWORD) 0, /* DesiredAccess */
89 inherit, /* InheritHandle */
90 DUPLICATE_SAME_ACCESS)) /* Options */
91 {
92 /* TODO: Translate GetLastError () into errno. */
93 errno = EMFILE;
94 result = -1;
95 break;
96 }
97 duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
98 if (duplicated_fd < 0)
99 {
100 CloseHandle (new_handle);
101 errno = EMFILE;
102 result = -1;
103 break;
104 }
105 if (newfd <= duplicated_fd)
106 {
107 result = duplicated_fd;
108 break;
109 }
110
111 /* Set the bit duplicated_fd in fds_to_close[]. */
112 index = (unsigned int) duplicated_fd / CHAR_BIT;
113 if (fds_to_close_bound <= index)
114 {
115 if (sizeof fds_to_close <= index)
116 /* Need to increase OPEN_MAX_MAX. */
117 abort ();
118 memset (fds_to_close + fds_to_close_bound, '\0',
119 index + 1 - fds_to_close_bound);
120 fds_to_close_bound = index + 1;
121 }
122 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
123 }
124
125 /* Close the previous fds that turned out to be too small. */
126 {
127 int saved_errno = errno;
128 unsigned int duplicated_fd;
129
130 for (duplicated_fd = 0;
131 duplicated_fd < fds_to_close_bound * CHAR_BIT;
132 duplicated_fd++)
133 if ((fds_to_close[duplicated_fd / CHAR_BIT]
134 >> (duplicated_fd % CHAR_BIT))
135 & 1)
136 close (duplicated_fd);
137
138 errno = saved_errno;
139 }
140
141# if REPLACE_FCHDIR
142 if (0 <= result)
143 result = _gl_register_dup (oldfd, result);
144# endif
145 return result;
146}
147#endif /* W32 */
148
149/* Perform the specified ACTION on the file descriptor FD, possibly
150 using the argument ARG further described below. This replacement
151 handles the following actions, and forwards all others on to the
152 native fcntl. An unrecognized ACTION returns -1 with errno set to
153 EINVAL.
154
155 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
156 If successful, return the duplicate, which will be inheritable;
157 otherwise return -1 and set errno.
158
159 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
160 target fd. If successful, return the duplicate, which will not be
161 inheritable; otherwise return -1 and set errno.
162
163 F_GETFD - ARG need not be present. If successful, return a
164 non-negative value containing the descriptor flags of FD (only
165 FD_CLOEXEC is portable, but other flags may be present); otherwise
166 return -1 and set errno. */
167
168int
169rpl_fcntl (int fd, int action, /* arg */...)
170{
171 va_list arg;
172 int result = -1;
173 va_start (arg, action);
174 switch (action)
175 {
176
177#if !HAVE_FCNTL
178 case F_DUPFD:
179 {
180 int target = va_arg (arg, int);
181 result = dupfd (fd, target, 0);
182 break;
183 }
184#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
185 case F_DUPFD:
186 {
187 int target = va_arg (arg, int);
188 /* Detect invalid target; needed for cygwin 1.5.x. */
189 if (target < 0 || getdtablesize () <= target)
190 errno = EINVAL;
191 else
192 {
193 /* Haiku alpha 2 loses fd flags on original. */
194 int flags = fcntl (fd, F_GETFD);
195 if (flags < 0)
196 {
197 result = -1;
198 break;
199 }
200 result = fcntl (fd, action, target);
201 if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
202 {
203 int saved_errno = errno;
204 close (result);
205 result = -1;
206 errno = saved_errno;
207 }
208# if REPLACE_FCHDIR
209 if (0 <= result)
210 result = _gl_register_dup (fd, result);
211# endif
212 }
213 break;
214 } /* F_DUPFD */
215#endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */
216
217 case F_DUPFD_CLOEXEC:
218 {
219 int target = va_arg (arg, int);
220
221#if !HAVE_FCNTL
222 result = dupfd (fd, target, O_CLOEXEC);
223 break;
224#else /* HAVE_FCNTL */
225 /* Try the system call first, if the headers claim it exists
226 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
227 may be running with a glibc that has the macro but with an
228 older kernel that does not support it. Cache the
229 information on whether the system call really works, but
230 avoid caching failure if the corresponding F_DUPFD fails
231 for any reason. 0 = unknown, 1 = yes, -1 = no. */
232 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
233 if (0 <= have_dupfd_cloexec)
234 {
235 result = fcntl (fd, action, target);
236 if (0 <= result || errno != EINVAL)
237 {
238 have_dupfd_cloexec = 1;
239# if REPLACE_FCHDIR
240 if (0 <= result)
241 result = _gl_register_dup (fd, result);
242# endif
243 }
244 else
245 {
246 result = rpl_fcntl (fd, F_DUPFD, target);
247 if (result < 0)
248 break;
249 have_dupfd_cloexec = -1;
250 }
251 }
252 else
253 result = rpl_fcntl (fd, F_DUPFD, target);
254 if (0 <= result && have_dupfd_cloexec == -1)
255 {
256 int flags = fcntl (result, F_GETFD);
257 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
258 {
259 int saved_errno = errno;
260 close (result);
261 errno = saved_errno;
262 result = -1;
263 }
264 }
265 break;
266#endif /* HAVE_FCNTL */
267 } /* F_DUPFD_CLOEXEC */
268
269#if !HAVE_FCNTL
270 case F_GETFD:
271 {
272# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
273 HANDLE handle = (HANDLE) _get_osfhandle (fd);
274 DWORD flags;
275 if (handle == INVALID_HANDLE_VALUE
276 || GetHandleInformation (handle, &flags) == 0)
277 errno = EBADF;
278 else
279 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
280# else /* !W32 */
281 /* Use dup2 to reject invalid file descriptors. No way to
282 access this information, so punt. */
283 if (0 <= dup2 (fd, fd))
284 result = 0;
285# endif /* !W32 */
286 break;
287 } /* F_GETFD */
288#endif /* !HAVE_FCNTL */
289
290 /* Implementing F_SETFD on mingw is not trivial - there is no
291 API for changing the O_NOINHERIT bit on an fd, and merely
292 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
293 can lead to odd state. It may be possible by duplicating the
294 handle, using _open_osfhandle with the right flags, then
295 using dup2 to move the duplicate onto the original, but that
296 is not supported for now. */
297
298 default:
299 {
300#if HAVE_FCNTL
301 void *p = va_arg (arg, void *);
302 result = fcntl (fd, action, p);
303#else
304 errno = EINVAL;
305#endif
306 break;
307 }
308 }
309 va_end (arg);
310 return result;
311}
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
new file mode 100644
index 00000000000..9947405af61
--- /dev/null
+++ b/lib/getdtablesize.c
@@ -0,0 +1,86 @@
1/* getdtablesize() function for platforms that don't have it.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25#include <stdio.h>
26
27#include "msvc-inval.h"
28
29#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
30static int
31_setmaxstdio_nothrow (int newmax)
32{
33 int result;
34
35 TRY_MSVC_INVAL
36 {
37 result = _setmaxstdio (newmax);
38 }
39 CATCH_MSVC_INVAL
40 {
41 result = -1;
42 }
43 DONE_MSVC_INVAL;
44
45 return result;
46}
47# define _setmaxstdio _setmaxstdio_nothrow
48#endif
49
50/* Cache for the previous getdtablesize () result. */
51static int dtablesize;
52
53int
54getdtablesize (void)
55{
56 if (dtablesize == 0)
57 {
58 /* We are looking for the number N such that the valid file descriptors
59 are 0..N-1. It can be obtained through a loop as follows:
60 {
61 int fd;
62 for (fd = 3; fd < 65536; fd++)
63 if (dup2 (0, fd) == -1)
64 break;
65 return fd;
66 }
67 On Windows XP, the result is 2048.
68 The drawback of this loop is that it allocates memory for a libc
69 internal array that is never freed.
70
71 The number N can also be obtained as the upper bound for
72 _getmaxstdio (). _getmaxstdio () returns the maximum number of open
73 FILE objects. The sanity check in _setmaxstdio reveals the maximum
74 number of file descriptors. This too allocates memory, but it is
75 freed when we call _setmaxstdio with the original value. */
76 int orig_max_stdio = _getmaxstdio ();
77 unsigned int bound;
78 for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
79 ;
80 _setmaxstdio (orig_max_stdio);
81 dtablesize = bound;
82 }
83 return dtablesize;
84}
85
86#endif
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 4a84b1db261..d053e15efc1 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dup --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings memrchr mktime pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -75,6 +75,12 @@ EXTRA_libgnu_a_SOURCES += openat-proc.c
75 75
76## end gnulib module at-internal 76## end gnulib module at-internal
77 77
78## begin gnulib module binary-io
79
80libgnu_a_SOURCES += binary-io.h binary-io.c
81
82## end gnulib module binary-io
83
78## begin gnulib module c-ctype 84## begin gnulib module c-ctype
79 85
80libgnu_a_SOURCES += c-ctype.h c-ctype.c 86libgnu_a_SOURCES += c-ctype.h c-ctype.c
@@ -296,6 +302,15 @@ EXTRA_libgnu_a_SOURCES += at-func.c faccessat.c
296 302
297## end gnulib module faccessat 303## end gnulib module faccessat
298 304
305## begin gnulib module fcntl
306
307
308EXTRA_DIST += fcntl.c
309
310EXTRA_libgnu_a_SOURCES += fcntl.c
311
312## end gnulib module fcntl
313
299## begin gnulib module fcntl-h 314## begin gnulib module fcntl-h
300 315
301BUILT_SOURCES += fcntl.h 316BUILT_SOURCES += fcntl.h
@@ -384,6 +399,17 @@ EXTRA_libgnu_a_SOURCES += fsync.c
384 399
385## end gnulib module fsync 400## end gnulib module fsync
386 401
402## begin gnulib module getdtablesize
403
404if gl_GNULIB_ENABLED_getdtablesize
405
406endif
407EXTRA_DIST += getdtablesize.c
408
409EXTRA_libgnu_a_SOURCES += getdtablesize.c
410
411## end gnulib module getdtablesize
412
387## begin gnulib module getgroups 413## begin gnulib module getgroups
388 414
389if gl_GNULIB_ENABLED_getgroups 415if gl_GNULIB_ENABLED_getgroups
@@ -465,13 +491,6 @@ EXTRA_libgnu_a_SOURCES += group-member.c
465 491
466## end gnulib module group-member 492## end gnulib module group-member
467 493
468## begin gnulib module ignore-value
469
470
471EXTRA_DIST += ignore-value.h
472
473## end gnulib module ignore-value
474
475## begin gnulib module intprops 494## begin gnulib module intprops
476 495
477 496
@@ -568,6 +587,12 @@ EXTRA_DIST += pathmax.h
568 587
569## end gnulib module pathmax 588## end gnulib module pathmax
570 589
590## begin gnulib module pipe2
591
592libgnu_a_SOURCES += pipe2.c
593
594## end gnulib module pipe2
595
571## begin gnulib module pselect 596## begin gnulib module pselect
572 597
573 598
@@ -1704,9 +1729,7 @@ EXTRA_DIST += utimens.h
1704 1729
1705## begin gnulib module verify 1730## begin gnulib module verify
1706 1731
1707if gl_GNULIB_ENABLED_verify
1708 1732
1709endif
1710EXTRA_DIST += verify.h 1733EXTRA_DIST += verify.h
1711 1734
1712## end gnulib module verify 1735## end gnulib module verify
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
deleted file mode 100644
index ebd6bf42f56..00000000000
--- a/lib/ignore-value.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/* ignore a function return without a compiler warning
2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Jim Meyering, Eric Blake and Pádraig Brady. */
19
20/* Use "ignore_value" to avoid a warning when using a function declared with
21 gcc's warn_unused_result attribute, but for which you really do want to
22 ignore the result. Traditionally, people have used a "(void)" cast to
23 indicate that a function's return value is deliberately unused. However,
24 if the function is declared with __attribute__((warn_unused_result)),
25 gcc issues a warning even with the cast.
26
27 Caution: most of the time, you really should heed gcc's warning, and
28 check the return value. However, in those exceptional cases in which
29 you're sure you know what you're doing, use this function.
30
31 For the record, here's one of the ignorable warnings:
32 "copy.c:233: warning: ignoring return value of 'fchown',
33 declared with attribute warn_unused_result". */
34
35#ifndef _GL_IGNORE_VALUE_H
36#define _GL_IGNORE_VALUE_H
37
38/* The __attribute__((__warn_unused_result__)) feature
39 is available in gcc versions 3.4 and newer,
40 while the typeof feature has been available since 2.7 at least. */
41#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
42# define ignore_value(x) \
43 (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
44#else
45# define ignore_value(x) ((void) (x))
46#endif
47
48#endif
diff --git a/lib/pipe2.c b/lib/pipe2.c
new file mode 100644
index 00000000000..211d75545c0
--- /dev/null
+++ b/lib/pipe2.c
@@ -0,0 +1,168 @@
1/* Create a pipe, with specific opening flags.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#include <errno.h>
23#include <fcntl.h>
24
25#include "binary-io.h"
26#include "verify.h"
27
28#if GNULIB_defined_O_NONBLOCK
29# include "nonblocking.h"
30#endif
31
32#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
33/* Native Windows API. */
34
35# include <io.h>
36
37#endif
38
39int
40pipe2 (int fd[2], int flags)
41{
42 /* Mingw _pipe() corrupts fd on failure; also, if we succeed at
43 creating the pipe but later fail at changing fcntl, we want
44 to leave fd unchanged: http://austingroupbugs.net/view.php?id=467 */
45 int tmp[2];
46 tmp[0] = fd[0];
47 tmp[1] = fd[1];
48
49#if HAVE_PIPE2
50# undef pipe2
51 /* Try the system call first, if it exists. (We may be running with a glibc
52 that has the function but with an older kernel that lacks it.) */
53 {
54 /* Cache the information whether the system call really exists. */
55 static int have_pipe2_really; /* 0 = unknown, 1 = yes, -1 = no */
56 if (have_pipe2_really >= 0)
57 {
58 int result = pipe2 (fd, flags);
59 if (!(result < 0 && errno == ENOSYS))
60 {
61 have_pipe2_really = 1;
62 return result;
63 }
64 have_pipe2_really = -1;
65 }
66 }
67#endif
68
69 /* Check the supported flags. */
70 if ((flags & ~(O_CLOEXEC | O_NONBLOCK | O_BINARY | O_TEXT)) != 0)
71 {
72 errno = EINVAL;
73 return -1;
74 }
75
76#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
77/* Native Windows API. */
78
79 if (_pipe (fd, 4096, flags & ~O_NONBLOCK) < 0)
80 {
81 fd[0] = tmp[0];
82 fd[1] = tmp[1];
83 return -1;
84 }
85
86 /* O_NONBLOCK handling.
87 On native Windows platforms, O_NONBLOCK is defined by gnulib. Use the
88 functions defined by the gnulib module 'nonblocking'. */
89# if GNULIB_defined_O_NONBLOCK
90 if (flags & O_NONBLOCK)
91 {
92 if (set_nonblocking_flag (fd[0], true) != 0
93 || set_nonblocking_flag (fd[1], true) != 0)
94 goto fail;
95 }
96# else
97 {
98 verify (O_NONBLOCK == 0);
99 }
100# endif
101
102 return 0;
103
104#else
105/* Unix API. */
106
107 if (pipe (fd) < 0)
108 return -1;
109
110 /* POSIX <http://www.opengroup.org/onlinepubs/9699919799/functions/pipe.html>
111 says that initially, the O_NONBLOCK and FD_CLOEXEC flags are cleared on
112 both fd[0] and fd[1]. */
113
114 /* O_NONBLOCK handling.
115 On Unix platforms, O_NONBLOCK is defined by the system. Use fcntl(). */
116 if (flags & O_NONBLOCK)
117 {
118 int fcntl_flags;
119
120 if ((fcntl_flags = fcntl (fd[1], F_GETFL, 0)) < 0
121 || fcntl (fd[1], F_SETFL, fcntl_flags | O_NONBLOCK) == -1
122 || (fcntl_flags = fcntl (fd[0], F_GETFL, 0)) < 0
123 || fcntl (fd[0], F_SETFL, fcntl_flags | O_NONBLOCK) == -1)
124 goto fail;
125 }
126
127 if (flags & O_CLOEXEC)
128 {
129 int fcntl_flags;
130
131 if ((fcntl_flags = fcntl (fd[1], F_GETFD, 0)) < 0
132 || fcntl (fd[1], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1
133 || (fcntl_flags = fcntl (fd[0], F_GETFD, 0)) < 0
134 || fcntl (fd[0], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1)
135 goto fail;
136 }
137
138# if O_BINARY
139 if (flags & O_BINARY)
140 {
141 set_binary_mode (fd[1], O_BINARY);
142 set_binary_mode (fd[0], O_BINARY);
143 }
144 else if (flags & O_TEXT)
145 {
146 set_binary_mode (fd[1], O_TEXT);
147 set_binary_mode (fd[0], O_TEXT);
148 }
149# endif
150
151 return 0;
152
153#endif
154
155#if GNULIB_defined_O_NONBLOCK || \
156 !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
157 fail:
158 {
159 int saved_errno = errno;
160 close (fd[0]);
161 close (fd[1]);
162 fd[0] = tmp[0];
163 fd[1] = tmp[1];
164 errno = saved_errno;
165 return -1;
166 }
167#endif
168}
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index c3a67321b0e..7254a3dec17 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -41,13 +41,28 @@
41 are 4 unless the option '-malign-double' is used. 41 are 4 unless the option '-malign-double' is used.
42 42
43 The result cannot be used as a value for an 'enum' constant, if you 43 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ 44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
45
46 Include <stddef.h> for offsetof. */
45#include <stddef.h> 47#include <stddef.h>
46#if defined __cplusplus 48
49/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
50 standard headers, defines conflicting implementations of _Alignas
51 and _Alignof that are no better than ours; override them. */
52#undef _Alignas
53#undef _Alignof
54
55#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
56# ifdef __cplusplus
57# if 201103 <= __cplusplus
58# define _Alignof(type) alignof (type)
59# else
47 template <class __t> struct __alignof_helper { char __a; __t __b; }; 60 template <class __t> struct __alignof_helper { char __a; __t __b; };
48# define _Alignof(type) offsetof (__alignof_helper<type>, __b) 61# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
49#else 62# endif
50# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) 63# else
64# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
65# endif
51#endif 66#endif
52#define alignof _Alignof 67#define alignof _Alignof
53#define __alignof_is_defined 1 68#define __alignof_is_defined 1
@@ -77,12 +92,16 @@
77 92
78 */ 93 */
79 94
80#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C 95#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
81# define _Alignas(a) __attribute__ ((__aligned__ (a))) 96# if defined __cplusplus && 201103 <= __cplusplus
82#elif 1300 <= _MSC_VER 97# define _Alignas(a) alignas (a)
83# define _Alignas(a) __declspec (align (a)) 98# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C
99# define _Alignas(a) __attribute__ ((__aligned__ (a)))
100# elif 1300 <= _MSC_VER
101# define _Alignas(a) __declspec (align (a))
102# endif
84#endif 103#endif
85#ifdef _Alignas 104#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__)
86# define alignas _Alignas 105# define alignas _Alignas
87# define __alignas_is_defined 1 106# define __alignas_is_defined 1
88#endif 107#endif
diff --git a/lib/verify.h b/lib/verify.h
index 03492efcd3f..d42d0750ee1 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -18,7 +18,7 @@
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ 18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19 19
20#ifndef _GL_VERIFY_H 20#ifndef _GL_VERIFY_H
21# define _GL_VERIFY_H 21#define _GL_VERIFY_H
22 22
23 23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. 24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
@@ -31,16 +31,24 @@
31 Use this only with GCC. If we were willing to slow 'configure' 31 Use this only with GCC. If we were willing to slow 'configure'
32 down we could also use it with other compilers, but since this 32 down we could also use it with other compilers, but since this
33 affects only the quality of diagnostics, why bother? */ 33 affects only the quality of diagnostics, why bother? */
34# if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ 34#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ 35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
36 && !defined __cplusplus) 36 && !defined __cplusplus)
37# define _GL_HAVE__STATIC_ASSERT 1 37# define _GL_HAVE__STATIC_ASSERT 1
38# endif 38#endif
39/* The condition (99 < __GNUC__) is temporary, until we know about the 39/* The condition (99 < __GNUC__) is temporary, until we know about the
40 first G++ release that supports static_assert. */ 40 first G++ release that supports static_assert. */
41# if (99 < __GNUC__) && defined __cplusplus 41#if (99 < __GNUC__) && defined __cplusplus
42# define _GL_HAVE_STATIC_ASSERT 1 42# define _GL_HAVE_STATIC_ASSERT 1
43# endif 43#endif
44
45/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
46 system headers, defines a conflicting _Static_assert that is no
47 better than ours; override it. */
48#ifndef _GL_HAVE_STATIC_ASSERT
49# include <stddef.h>
50# undef _Static_assert
51#endif
44 52
45/* Each of these macros verifies that its argument R is nonzero. To 53/* Each of these macros verifies that its argument R is nonzero. To
46 be portable, R should be an integer constant expression. Unlike 54 be portable, R should be an integer constant expression. Unlike
@@ -143,50 +151,50 @@
143 Use a template type to work around the problem. */ 151 Use a template type to work around the problem. */
144 152
145/* Concatenate two preprocessor tokens. */ 153/* Concatenate two preprocessor tokens. */
146# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) 154#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
147# define _GL_CONCAT0(x, y) x##y 155#define _GL_CONCAT0(x, y) x##y
148 156
149/* _GL_COUNTER is an integer, preferably one that changes each time we 157/* _GL_COUNTER is an integer, preferably one that changes each time we
150 use it. Use __COUNTER__ if it works, falling back on __LINE__ 158 use it. Use __COUNTER__ if it works, falling back on __LINE__
151 otherwise. __LINE__ isn't perfect, but it's better than a 159 otherwise. __LINE__ isn't perfect, but it's better than a
152 constant. */ 160 constant. */
153# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ 161#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
154# define _GL_COUNTER __COUNTER__ 162# define _GL_COUNTER __COUNTER__
155# else 163#else
156# define _GL_COUNTER __LINE__ 164# define _GL_COUNTER __LINE__
157# endif 165#endif
158 166
159/* Generate a symbol with the given prefix, making it unique if 167/* Generate a symbol with the given prefix, making it unique if
160 possible. */ 168 possible. */
161# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) 169#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
162 170
163/* Verify requirement R at compile-time, as an integer constant expression 171/* Verify requirement R at compile-time, as an integer constant expression
164 that returns 1. If R is false, fail at compile-time, preferably 172 that returns 1. If R is false, fail at compile-time, preferably
165 with a diagnostic that includes the string-literal DIAGNOSTIC. */ 173 with a diagnostic that includes the string-literal DIAGNOSTIC. */
166 174
167# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ 175#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
168 (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) 176 (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
169 177
170# ifdef __cplusplus 178#ifdef __cplusplus
171# if !GNULIB_defined_struct__gl_verify_type 179# if !GNULIB_defined_struct__gl_verify_type
172template <int w> 180template <int w>
173 struct _gl_verify_type { 181 struct _gl_verify_type {
174 unsigned int _gl_verify_error_if_negative: w; 182 unsigned int _gl_verify_error_if_negative: w;
175 }; 183 };
176# define GNULIB_defined_struct__gl_verify_type 1 184# define GNULIB_defined_struct__gl_verify_type 1
177# endif
178# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
179 _gl_verify_type<(R) ? 1 : -1>
180# elif defined _GL_HAVE__STATIC_ASSERT
181# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
182 struct { \
183 _Static_assert (R, DIAGNOSTIC); \
184 int _gl_dummy; \
185 }
186# else
187# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
188 struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
189# endif 185# endif
186# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
187 _gl_verify_type<(R) ? 1 : -1>
188#elif defined _GL_HAVE__STATIC_ASSERT
189# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
190 struct { \
191 _Static_assert (R, DIAGNOSTIC); \
192 int _gl_dummy; \
193 }
194#else
195# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
196 struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
197#endif
190 198
191/* Verify requirement R at compile-time, as a declaration without a 199/* Verify requirement R at compile-time, as a declaration without a
192 trailing ';'. If R is false, fail at compile-time, preferably 200 trailing ';'. If R is false, fail at compile-time, preferably
@@ -195,23 +203,23 @@ template <int w>
195 Unfortunately, unlike C11, this implementation must appear as an 203 Unfortunately, unlike C11, this implementation must appear as an
196 ordinary declaration, and cannot appear inside struct { ... }. */ 204 ordinary declaration, and cannot appear inside struct { ... }. */
197 205
198# ifdef _GL_HAVE__STATIC_ASSERT 206#ifdef _GL_HAVE__STATIC_ASSERT
199# define _GL_VERIFY _Static_assert 207# define _GL_VERIFY _Static_assert
200# else 208#else
201# define _GL_VERIFY(R, DIAGNOSTIC) \ 209# define _GL_VERIFY(R, DIAGNOSTIC) \
202 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 210 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
203 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 211 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
204# endif 212#endif
205 213
206/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 214/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
207# ifdef _GL_STATIC_ASSERT_H 215#ifdef _GL_STATIC_ASSERT_H
208# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert 216# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
209# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) 217# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
210# endif 218# endif
211# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert 219# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
212# define static_assert _Static_assert /* C11 requires this #define. */ 220# define static_assert _Static_assert /* C11 requires this #define. */
213# endif
214# endif 221# endif
222#endif
215 223
216/* @assert.h omit start@ */ 224/* @assert.h omit start@ */
217 225
@@ -229,18 +237,18 @@ template <int w>
229 237
230 verify_true is obsolescent; please use verify_expr instead. */ 238 verify_true is obsolescent; please use verify_expr instead. */
231 239
232# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") 240#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
233 241
234/* Verify requirement R at compile-time. Return the value of the 242/* Verify requirement R at compile-time. Return the value of the
235 expression E. */ 243 expression E. */
236 244
237# define verify_expr(R, E) \ 245#define verify_expr(R, E) \
238 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) 246 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
239 247
240/* Verify requirement R at compile-time, as a declaration without a 248/* Verify requirement R at compile-time, as a declaration without a
241 trailing ';'. */ 249 trailing ';'. */
242 250
243# define verify(R) _GL_VERIFY (R, "verify (" #R ")") 251#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
244 252
245/* @assert.h omit end@ */ 253/* @assert.h omit end@ */
246 254
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 86a27f9b5bd..5451abc2119 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,441 @@
12013-07-13 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight
4 conversion methods on Kernel.
5
62013-07-13 Alan Mackenzie <acm@muc.de>
7
8 * progmodes/cc-engine.el (c-forward-decl-or-cast-1): Label CASE 13
9 and comment it out. This out-commenting enables certain C++
10 declarations to be parsed correctly.
11
122013-07-13 Eli Zaretskii <eliz@gnu.org>
13
14 * international/mule.el (define-coding-system): Doc fix.
15
16 * simple.el (default-font-height): Don't call font-info if the
17 frame's default font didn't change since the frame was created.
18 (Bug#14838)
19
202013-07-13 Leo Liu <sdl.web@gmail.com>
21
22 * ido.el (ido-read-file-name): Guard against non-symbol value.
23
242013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org>
25
26 * progmodes/python.el (python-imenu--build-tree): Fix corner case
27 in nested defuns.
28
292013-07-13 Leo Liu <sdl.web@gmail.com>
30
31 * ido.el (ido-exhibit): Handle ido-enter-matching-directory before
32 ido-set-matches call. (Bug#6852)
33
342013-07-12 Dmitry Gutov <dgutov@yandex.ru>
35
36 * progmodes/ruby-mode.el (ruby-percent-literals-beg-re):
37 (ruby-syntax-expansion-allowed-p): Support array of symbols, for
38 Ruby 2.0.
39 (ruby-font-lock-keywords): Distinguish calls to functions with
40 module-like names from module references. Highlight character
41 literals.
42
432013-07-12 Sergio Durigan Junior <sergiodj@riseup.net> (tiny change)
44
45 * progmodes/gdb-mi.el (gdb-strip-string-backslash): New function.
46 (gdb-send): Handle continued commands. (Bug#14847)
47
482013-07-12 Juanma Barranquero <lekktu@gmail.com>
49
50 * desktop.el (desktop--v2s): Remove unused local variable.
51 (desktop-save-buffer): Make defvar-local; adjust docstring.
52 (desktop-auto-save-timeout, desktop-owner): Use ignore-errors.
53 (desktop-clear, desktop-save-buffer-p): Use string-match-p.
54
552013-07-12 Andreas Schwab <schwab@linux-m68k.org>
56
57 * emacs-lisp/map-ynp.el (map-y-or-n-p): Fix last change.
58
592013-07-12 Eli Zaretskii <eliz@gnu.org>
60
61 * simple.el (next-line, previous-line): Document TRY-VSCROLL and ARG.
62 (Bug#14842)
63
642013-07-12 Glenn Morris <rgm@gnu.org>
65
66 * doc-view.el: Require cl-lib at runtime too.
67 (doc-view-remove-if): Remove.
68 (doc-view-search-next-match, doc-view-search-previous-match):
69 Use cl-remove-if.
70
71 * edmacro.el: Require cl-lib at runtime too.
72 (edmacro-format-keys, edmacro-parse-keys): Use cl-mismatch, cl-subseq.
73 (edmacro-mismatch, edmacro-subseq): Remove.
74
75 * shadowfile.el: Require cl-lib.
76 (shadow-remove-if): Remove.
77 (shadow-set-cluster, shadow-shadows-of-1, shadow-remove-from-todo):
78 Use cl-remove-if.
79
80 * wid-edit.el: Require cl-lib.
81 (widget-choose): Use cl-remove-if.
82 (widget-remove-if): Remove.
83
84 * progmodes/ebrowse.el: Require cl-lib at runtime too.
85 (ebrowse-delete-if-not): Remove.
86 (ebrowse-browser-buffer-list, ebrowse-member-buffer-list)
87 (ebrowse-tree-buffer-list, ebrowse-same-tree-member-buffer-list):
88 Use cl-delete-if-not.
89
902013-07-12 Juanma Barranquero <lekktu@gmail.com>
91
92 * emacs-lisp/cl-macs.el (cl-multiple-value-bind, cl-multiple-value-setq)
93 (cl-the, cl-declare, cl-defstruct): Fix typos in docstrings.
94
952013-07-12 Leo Liu <sdl.web@gmail.com>
96
97 * ido.el (dired-do-copy, dired): Set 'ido property. (Bug#11954)
98
992013-07-11 Glenn Morris <rgm@gnu.org>
100
101 * emacs-lisp/edebug.el: Require cl-lib at run-time too.
102 (edebug-gensym-index, edebug-gensym):
103 Remove reimplementation of cl-gensym.
104 (edebug-make-enter-wrapper, edebug-make-form-wrapper): Use cl-gensym.
105
106 * thumbs.el: Require cl-lib at run-time too.
107 (thumbs-gensym-counter, thumbs-gensym):
108 Remove reimplementation of cl-gensym.
109 (thumbs-temp-file): Use cl-gensym.
110
111 * emacs-lisp/ert.el: Require cl-lib at runtime too.
112 (ert--cl-do-remf, ert--remprop, ert--remove-if-not)
113 (ert--intersection, ert--set-difference, ert--set-difference-eq)
114 (ert--union, ert--gensym-counter, ert--gensym-counter)
115 (ert--coerce-to-vector, ert--remove*, ert--string-position)
116 (ert--mismatch, ert--subseq): Remove reimplementations of cl funcs.
117 (ert-make-test-unbound, ert--expand-should-1)
118 (ert--expand-should, ert--should-error-handle-error)
119 (should-error, ert--explain-equal-rec)
120 (ert--plist-difference-explanation, ert-select-tests)
121 (ert--make-stats, ert--remove-from-list, ert--string-first-line):
122 Use cl-lib functions rather than reimplementations.
123
1242013-07-11 Michael Albinus <michael.albinus@gmx.de>
125
126 * net/tramp.el (tramp-methods): Extend docstring.
127 (tramp-connection-timeout): New defcustom.
128 (tramp-error-with-buffer): Reset timestamp only when appropriate.
129 (with-tramp-progress-reporter): Simplify.
130 (tramp-process-actions): Improve messages.
131
132 * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
133 * net/tramp-sh.el (tramp-maybe-open-connection):
134 Use `tramp-connection-timeout'.
135 (tramp-methods) [su, sudo, ksu]: Add method specific timeouts.
136 (Bug#14808)
137
1382013-07-11 Leo Liu <sdl.web@gmail.com>
139
140 * ido.el (ido-read-file-name): Conform to the requirements of
141 read-file-name. (Bug#11861)
142 (ido-read-directory-name): Conform to the requirements of
143 read-directory-name.
144
1452013-07-11 Juanma Barranquero <lekktu@gmail.com>
146
147 * subr.el (delay-warning): New function.
148
1492013-07-10 Eli Zaretskii <eliz@gnu.org>
150
151 * simple.el (default-line-height): New function.
152 (line-move-partial, line-move): Use it instead of computing the
153 line height inline.
154 (line-move-partial): Always compute ROWH. If the last line is
155 partially-visible, but its text is completely visible, allow
156 cursor to enter such a partially-visible line.
157
1582013-07-10 Michael Albinus <michael.albinus@gmx.de>
159
160 Improve error messages. (Bug#14808)
161
162 * net/tramp.el (tramp-current-connection): New defvar, moved from
163 tramp-sh.el.
164 (tramp-message-show-progress-reporter-message): Removed, not
165 needed anymore.
166 (tramp-error-with-buffer): Show message in minibuffer. Discard
167 input before waiting. Reset connection timestamp.
168 (with-tramp-progress-reporter): Improve messages.
169 (tramp-process-actions): Use progress reporter. Delete process in
170 case of error. Improve messages.
171
172 * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use
173 condition-case. Call `tramp-error-with-buffer' with vector and buffer.
174 (tramp-current-connection): Removed.
175 (tramp-maybe-open-connection): The car of
176 `tramp-current-connection' are the first 3 slots of the vector.
177
1782013-07-10 Teodor Zlatanov <tzz@lifelogs.com>
179
180 * progmodes/cfengine.el (cfengine3-indent-line): Do not indent
181 inside continued strings.
182
1832013-07-10 Paul Eggert <eggert@cs.ucla.edu>
184
185 Timestamp fixes for undo (Bug#14824).
186 * files.el (clear-visited-file-modtime): Move here from fileio.c.
187
1882013-07-10 Leo Liu <sdl.web@gmail.com>
189
190 * files.el (require-final-newline): Allow safe local value.
191 (Bug#14834)
192
1932013-07-09 Leo Liu <sdl.web@gmail.com>
194
195 * ido.el (ido-read-directory-name): Handle fallback.
196 (ido-read-file-name): Update DIR to ido-current-directory.
197 (Bug#1516)
198 (ido-add-virtual-buffers-to-list): Robustify. (Bug#14552)
199
2002013-07-09 Dmitry Gutov <dgutov@yandex.ru>
201
202 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Remove extra
203 "autoload". Remove "warn lower camel case" section, previously
204 commented out. Highlight negation char. Do not highlight the
205 target in singleton method definitions.
206
2072013-07-08 Stefan Monnier <monnier@iro.umontreal.ca>
208
209 * faces.el (tty-setup-hook): Declare the hook.
210
211 * emacs-lisp/pcase.el (pcase--split-pred): Add `vars' argument to try
212 and detect when a guard/pred depends on local vars (bug#14773).
213 (pcase--u1): Adjust caller.
214
2152013-07-08 Eli Zaretskii <eliz@gnu.org>
216
217 * simple.el (line-move-partial, line-move): Account for
218 line-spacing.
219 (line-move-partial): Avoid setting vscroll when the last
220 partially-visible line in window is of default height.
221
2222013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
223
224 * net/shr.el (shr-map): Reinstate the `u' key binding, since it's
225 been used a while.
226
2272013-07-07 Juanma Barranquero <lekktu@gmail.com>
228
229 * subr.el (read-quoted-char): Remove unused local variable `char'.
230
2312013-07-07 Michael Kifer <kifer@cs.stonybrook.edu>
232
233 * ediff.el (ediff-version): Version update.
234 (ediff-files-command, ediff3-files-command, ediff-merge-command)
235 (ediff-merge-with-ancestor-command, ediff-directories-command)
236 (ediff-directories3-command, ediff-merge-directories-command)
237 (ediff-merge-directories-with-ancestor-command): New functions.
238 All are command-line interfaces to ediff: to facilitate calling
239 Emacs with the appropriate ediff functions invoked.
240
241 * viper-cmd.el (viper-del-forward-char-in-insert): New function.
242 (viper-save-kill-buffer): Check if buffer is modified.
243
244 * viper.el (viper-version): Version update.
245 (viper-emacs-state-mode-list): Add egg-status-buffer-mode.
246
2472013-07-07 Stefan Monnier <monnier@iro.umontreal.ca>
248
249 * faces.el (tty-run-terminal-initialization): Run new tty-setup-hook.
250 * viper-cmd.el (viper-envelop-ESC-key): Remove function.
251 (viper-intercept-ESC-key): Simplify.
252 * viper-keym.el (viper-ESC-key): Make it a constant, don't use kbd.
253 * viper.el (viper--tty-ESC-filter, viper--lookup-key)
254 (viper-catch-tty-ESC, viper-uncatch-tty-ESC)
255 (viper-setup-ESC-to-escape): New functions.
256 (viper-go-away, viper-set-hooks): Call viper-setup-ESC-to-escape.
257 (viper-set-hooks): Do not modify flyspell-mode-hook. (Bug#13793)
258
2592013-07-07 Eli Zaretskii <eliz@gnu.org>
260
261 * simple.el (default-font-height, window-screen-lines):
262 New functions.
263 (line-move, line-move-partial): Use them instead of
264 frame-char-height and window-text-height. This makes scrolling
265 text smoother when the buffer's default face uses a font that is
266 different from the frame's default font.
267
2682013-07-06 Jan Djärv <jan.h.d@swipnet.se>
269
270 * files.el (write-file): Do not display confirm dialog for NS,
271 it does its own dialog, which can't be cancelled (Bug#14578).
272
2732013-07-06 Eli Zaretskii <eliz@gnu.org>
274
275 * simple.el (line-move-partial): Adjust the row returned by
276 posn-at-point for the current window-vscroll. (Bug#14567)
277
2782013-07-06 Michael Albinus <michael.albinus@gmx.de>
279
280 * net/tramp-sh.el (tramp-sh-file-gvfs-monitor-dir-process-filter):
281 (tramp-sh-file-inotifywait-process-filter): Handle file names with
282 spaces.
283
2842013-07-06 Martin Rudalics <rudalics@gmx.at>
285
286 * window.el (window-state-put-stale-windows): New variable.
287 (window--state-put-2): Save list of windows without matching buffer.
288 (window-state-put): Remove "bufferless" windows if possible.
289
2902013-07-06 Juanma Barranquero <lekktu@gmail.com>
291
292 * simple.el (alternatives-define): Remove leftover :group keyword.
293 Tweak docstring.
294
2952013-07-06 Leo Liu <sdl.web@gmail.com>
296
297 * ido.el (ido-use-virtual-buffers): Allow new value 'auto.
298 (ido-enable-virtual-buffers): New variable.
299 (ido-buffer-internal, ido-toggle-virtual-buffers)
300 (ido-make-buffer-list): Use it.
301 (ido-exhibit): Support turning on and off virtual buffers
302 automatically.
303
3042013-07-06 Juanma Barranquero <lekktu@gmail.com>
305
306 * simple.el (alternatives-define): New macro.
307
3082013-07-06 Stefan Monnier <monnier@iro.umontreal.ca>
309
310 * subr.el (read-quoted-char): Use read-key.
311 (sit-for): Let read-event decode tty input (bug#14782).
312
3132013-07-05 Stephen Berman <stephen.berman@gmx.net>
314
315 * calendar/todo-mode.el: Add handling of file deletion, both by
316 mode command and externally. Fix various related bugs.
317 Clarify Commentary and improve some documentation strings and code.
318 (todo-delete-file): New command.
319 (todo-check-file): New function.
320 (todo-show): Handle external deletion of the file we're trying to
321 show (bug#14688). Replace called-interactively-p by an optional
322 prefix argument to avoid problematic interaction with catch form
323 when byte compiled (bug#14702).
324 (todo-quit): Handle external deletion of the archive's todo file.
325 Make sure the buffer that was visiting the archive file is still
326 live before trying to bury it.
327 (todo-category-completions): Handle external deletion of any
328 category completion files.
329 (todo-jump-to-category, todo-basic-insert-item): Recalculate list
330 of todo files, in case of external deletion.
331 (todo-add-file): Replace unnecessary setq by let-binding.
332 (todo-find-archive): Check whether there are any archives.
333 Replace unnecessary setq by let-binding.
334 (todo-archive-done-item): Use find-file-noselect to get the
335 archive buffer whether or not the archive already exists.
336 Remove superfluous code. Use file size instead of buffer-file-name to
337 check if the archive is new; if it is, update list of archives.
338 (todo-default-todo-file): Allow nil to be a valid value for when
339 there are no todo files.
340 (todo-reevaluate-default-file-defcustom): Use corrected definition
341 of todo-default-todo-file.
342 (todo-key-bindings-t+a+f): Add key binding for todo-delete-file.
343 (todo-delete-category, todo-show-categories-table)
344 (todo-category-number): Clarify comment.
345 (todo-filter-items): Clarify documentation string.
346 (todo-show-current-file, todo-display-as-todo-file)
347 (todo-reset-and-enable-done-separator): Tweak documentation string.
348 (todo-done-separator): Make separator length window-width, since
349 bug#2749 is now fixed.
350
3512013-07-05 Michael Albinus <michael.albinus@gmx.de>
352
353 * net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch):
354 Support both "gvfs-monitor-dir" and "inotifywait".
355 (tramp-sh-file-inotifywait-process-filter): Rename from
356 `tramp-sh-file-notify-process-filter'.
357 (tramp-sh-file-gvfs-monitor-dir-process-filter)
358 (tramp-get-remote-gvfs-monitor-dir): New defuns.
359
3602013-07-05 Leo Liu <sdl.web@gmail.com>
361
362 * autoinsert.el (auto-insert-alist): Default to lexical-binding.
363
3642013-07-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
365
366 * frame.el (display-pixel-height, display-pixel-width)
367 (display-mm-height, display-mm-width): Mention behavior on
368 multi-monitor setups in docstrings.
369 (w32-display-monitor-attributes-list): Declare function.
370 (display-monitor-attributes-list): Use it.
371
3722013-07-04 Michael Albinus <michael.albinus@gmx.de>
373
374 * filenotify.el: New package.
375
376 * autorevert.el (top): Require filenotify.el.
377 (auto-revert-notify-enabled): Remove. Use `file-notify-support'
378 instead.
379 (auto-revert-notify-rm-watch, auto-revert-notify-add-watch)
380 (auto-revert-notify-handler): Use `file-notify-*' functions.
381
382 * subr.el (file-notify-handle-event): Move function to filenotify.el.
383
384 * net/tramp.el (tramp-file-name-for-operation):
385 Handle `file-notify-add-watch' and `file-notify-rm-watch'.
386
387 * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add handler
388 for `file-notify-add-watch' and `file-notify-rm-watch'.
389 (tramp-process-sentinel): Improve trace.
390 (tramp-sh-handle-file-notify-add-watch)
391 (tramp-sh-file-notify-process-filter)
392 (tramp-sh-handle-file-notify-rm-watch)
393 (tramp-get-remote-inotifywait): New defuns.
394
3952013-07-03 Juri Linkov <juri@jurta.org>
396
397 * buff-menu.el (Buffer-menu-multi-occur): Add args and move the
398 call of `occur-read-primary-args' to interactive spec.
399
400 * ibuffer.el (ibuffer-mode-map): Bind "M-s a C-o" to
401 `ibuffer-do-occur' like in buff-menu.el. (Bug#14673)
402
4032013-07-03 Matthias Meulien <orontee@gmail.com>
404
405 * buff-menu.el (Buffer-menu-mode-map): Bind "M-s a C-o" to
406 `Buffer-menu-multi-occur'. Add it to the menu.
407 (Buffer-menu-mode): Document it in docstring.
408 (Buffer-menu-multi-occur): New command. (Bug#14673)
409
4102013-07-03 Dmitry Gutov <dgutov@yandex.ru>
411
412 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight more
413 keywords and built-ins.
414
4152013-07-03 Glenn Morris <rgm@gnu.org>
416
417 * subr.el (y-or-n-p): Handle empty prompts. (Bug#14770)
418
419 Make info-xref checks case-sensitive by default
420 * info.el (Info-find-node, Info-find-in-tag-table)
421 (Info-find-node-in-buffer, Info-find-node-2, Info-goto-node):
422 Add option for exact case matching of nodes.
423 * info-xref.el (info-xref): New custom group.
424 (info-xref-case-fold): New option.
425 (info-xref-goto-node-p): Pass info-xref-case-fold to Info-goto-node.
426
4272013-07-03 Leo Liu <sdl.web@gmail.com>
428
429 * ido.el (ido-delete-file-at-head): Respect delete-by-moving-to-trash.
430
4312013-07-03 Dmitry Gutov <dgutov@yandex.ru>
432
433 * progmodes/ruby-mode.el (ruby-move-to-block): When we're at a
434 middle of block statement initially, lower the depth. Remove
435 FIXME comment, not longer valid. Remove middle of block statement
436 detection, no need to do that anymore since we've been using
437 `ruby-parse-region' here.
438
12013-07-02 Jan Djärv <jan.h.d@swipnet.se> 4392013-07-02 Jan Djärv <jan.h.d@swipnet.se>
2 440
3 * term/ns-win.el (display-format-alist): Use .* (Bug#14765). 441 * term/ns-win.el (display-format-alist): Use .* (Bug#14765).
@@ -255,12 +693,12 @@
255 693
2562013-06-25 Rüdiger Sonderfeld <ruediger@c-plusplus.de> 6942013-06-25 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
257 695
258 * lisp/textmodes/bibtex.el (bibtex-generate-url-list): Add support 696 * textmodes/bibtex.el (bibtex-generate-url-list): Add support
259 for DOI URLs. 697 for DOI URLs.
260 698
2612013-06-25 Rüdiger Sonderfeld <ruediger@c-plusplus.de> 6992013-06-25 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
262 700
263 * lisp/textmodes/bibtex.el (bibtex-mode, bibtex-set-dialect): 701 * textmodes/bibtex.el (bibtex-mode, bibtex-set-dialect):
264 Update imenu-support when dialect changes. 702 Update imenu-support when dialect changes.
265 703
2662013-06-25 Leo Liu <sdl.web@gmail.com> 7042013-06-25 Leo Liu <sdl.web@gmail.com>
@@ -361,7 +799,7 @@
361 * emacs-lock.el (emacs-lock-mode, emacs-lock--old-mode) 799 * emacs-lock.el (emacs-lock-mode, emacs-lock--old-mode)
362 (emacs-lock--try-unlocking): Make defvar-local. 800 (emacs-lock--try-unlocking): Make defvar-local.
363 801
3642013-06-22 Glenn Morris <rgm@fencepost.gnu.org> 8022013-06-22 Glenn Morris <rgm@gnu.org>
365 803
366 * play/cookie1.el (cookie-apropos): Minor simplification. 804 * play/cookie1.el (cookie-apropos): Minor simplification.
367 805
@@ -827,7 +1265,7 @@
827 1265
828 * net/shr.el (shr-map): Bind [down-mouse-1] to browse URLs. 1266 * net/shr.el (shr-map): Bind [down-mouse-1] to browse URLs.
829 1267
8302013-06-19 Glenn Morris <rgm@fencepost.gnu.org> 12682013-06-19 Glenn Morris <rgm@gnu.org>
831 1269
832 * emacs-lisp/eieio.el (defclass): Make it eval-and-compile once more. 1270 * emacs-lisp/eieio.el (defclass): Make it eval-and-compile once more.
833 1271
@@ -970,6 +1408,7 @@
9702013-06-18 Matthias Meulien <orontee@gmail.com> 14082013-06-18 Matthias Meulien <orontee@gmail.com>
971 1409
972 * tabify.el (untabify, tabify): With prefix, apply to entire buffer. 1410 * tabify.el (untabify, tabify): With prefix, apply to entire buffer.
1411 <http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00545.html>
973 1412
9742013-06-18 Glenn Morris <rgm@gnu.org> 14132013-06-18 Glenn Morris <rgm@gnu.org>
975 1414
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index c45d64e1cd9..daa654889b6 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -164,7 +164,10 @@ If this contains a %s, that will be replaced by the matching rule."
164 164
165 (("\\.el\\'" . "Emacs Lisp header") 165 (("\\.el\\'" . "Emacs Lisp header")
166 "Short description: " 166 "Short description: "
167 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str " 167 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str
168 (make-string (max 2 (- 80 (current-column) 27)) ?\s)
169 "-*- lexical-binding: t; -*-"
170 "
168 171
169;; Copyright (C) " (format-time-string "%Y") " " 172;; Copyright (C) " (format-time-string "%Y") " "
170 (getenv "ORGANIZATION") | (progn user-full-name) " 173 (getenv "ORGANIZATION") | (progn user-full-name) "
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 4a6d4cb4cc0..00e88fc4a3d 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -103,6 +103,7 @@
103 103
104(eval-when-compile (require 'cl-lib)) 104(eval-when-compile (require 'cl-lib))
105(require 'timer) 105(require 'timer)
106(require 'filenotify)
106 107
107;; Custom Group: 108;; Custom Group:
108;; 109;;
@@ -270,21 +271,17 @@ This variable becomes buffer local when set in any fashion.")
270 :type 'boolean 271 :type 'boolean
271 :version "24.4") 272 :version "24.4")
272 273
273(defconst auto-revert-notify-enabled 274(defcustom auto-revert-use-notify (and file-notify-support t)
274 (or (featurep 'gfilenotify) (featurep 'inotify) (featurep 'w32notify))
275 "Non-nil when Emacs has been compiled with file notification support.")
276
277(defcustom auto-revert-use-notify auto-revert-notify-enabled
278 "If non-nil Auto Revert Mode uses file notification functions. 275 "If non-nil Auto Revert Mode uses file notification functions.
279This requires Emacs being compiled with file notification 276This requires Emacs being compiled with file notification
280support (see `auto-revert-notify-enabled'). You should set this 277support (see `file-notify-support'). You should set this variable
281variable through Custom." 278through Custom."
282 :group 'auto-revert 279 :group 'auto-revert
283 :type 'boolean 280 :type 'boolean
284 :set (lambda (variable value) 281 :set (lambda (variable value)
285 (set-default variable (and auto-revert-notify-enabled value)) 282 (set-default variable (and file-notify-support value))
286 (unless (symbol-value variable) 283 (unless (symbol-value variable)
287 (when auto-revert-notify-enabled 284 (when file-notify-support
288 (dolist (buf (buffer-list)) 285 (dolist (buf (buffer-list))
289 (with-current-buffer buf 286 (with-current-buffer buf
290 (when (symbol-value 'auto-revert-notify-watch-descriptor) 287 (when (symbol-value 'auto-revert-notify-watch-descriptor)
@@ -502,12 +499,7 @@ will use an up-to-date value of `auto-revert-interval'"
502 (puthash key value auto-revert-notify-watch-descriptor-hash-list) 499 (puthash key value auto-revert-notify-watch-descriptor-hash-list)
503 (remhash key auto-revert-notify-watch-descriptor-hash-list) 500 (remhash key auto-revert-notify-watch-descriptor-hash-list)
504 (ignore-errors 501 (ignore-errors
505 (funcall 502 (file-notify-rm-watch auto-revert-notify-watch-descriptor)))))
506 (cond
507 ((fboundp 'gfile-rm-watch) 'gfile-rm-watch)
508 ((fboundp 'inotify-rm-watch) 'inotify-rm-watch)
509 ((fboundp 'w32notify-rm-watch) 'w32notify-rm-watch))
510 auto-revert-notify-watch-descriptor)))))
511 auto-revert-notify-watch-descriptor-hash-list) 503 auto-revert-notify-watch-descriptor-hash-list)
512 (remove-hook 'kill-buffer-hook 'auto-revert-notify-rm-watch)) 504 (remove-hook 'kill-buffer-hook 'auto-revert-notify-rm-watch))
513 (setq auto-revert-notify-watch-descriptor nil 505 (setq auto-revert-notify-watch-descriptor nil
@@ -522,100 +514,58 @@ will use an up-to-date value of `auto-revert-interval'"
522 514
523 (when (and buffer-file-name auto-revert-use-notify 515 (when (and buffer-file-name auto-revert-use-notify
524 (not auto-revert-notify-watch-descriptor)) 516 (not auto-revert-notify-watch-descriptor))
525 (let ((func 517 (setq auto-revert-notify-watch-descriptor
526 (cond 518 (ignore-errors
527 ((fboundp 'gfile-add-watch) 'gfile-add-watch) 519 (file-notify-add-watch
528 ((fboundp 'inotify-add-watch) 'inotify-add-watch) 520 (expand-file-name buffer-file-name default-directory)
529 ((fboundp 'w32notify-add-watch) 'w32notify-add-watch))) 521 '(change attribute-change) 'auto-revert-notify-handler)))
530 (aspect 522 (if auto-revert-notify-watch-descriptor
531 (cond 523 (progn
532 ((fboundp 'gfile-add-watch) '(watch-mounts)) 524 (puthash
533 ;; `attrib' is needed for file modification time. 525 auto-revert-notify-watch-descriptor
534 ((fboundp 'inotify-add-watch) '(attrib create modify moved-to)) 526 (cons (current-buffer)
535 ((fboundp 'w32notify-add-watch) '(size last-write-time)))) 527 (gethash auto-revert-notify-watch-descriptor
536 (file (if (or (fboundp 'gfile-add-watch) (fboundp 'inotify-add-watch)) 528 auto-revert-notify-watch-descriptor-hash-list))
537 (directory-file-name (expand-file-name default-directory)) 529 auto-revert-notify-watch-descriptor-hash-list)
538 (buffer-file-name)))) 530 (add-hook (make-local-variable 'kill-buffer-hook)
539 (setq auto-revert-notify-watch-descriptor 531 'auto-revert-notify-rm-watch))
540 (ignore-errors 532 ;; Fallback to file checks.
541 (funcall func file aspect 'auto-revert-notify-handler))) 533 (set (make-local-variable 'auto-revert-use-notify) nil))))
542 (if auto-revert-notify-watch-descriptor
543 (progn
544 (puthash
545 auto-revert-notify-watch-descriptor
546 (cons (current-buffer)
547 (gethash auto-revert-notify-watch-descriptor
548 auto-revert-notify-watch-descriptor-hash-list))
549 auto-revert-notify-watch-descriptor-hash-list)
550 (add-hook (make-local-variable 'kill-buffer-hook)
551 'auto-revert-notify-rm-watch))
552 ;; Fallback to file checks.
553 (set (make-local-variable 'auto-revert-use-notify) nil)))))
554
555(defun auto-revert-notify-event-p (event)
556 "Check that event is a file notification event."
557 (and (listp event)
558 (cond ((featurep 'gfilenotify)
559 (and (>= (length event) 3) (stringp (nth 2 event))))
560 ((featurep 'inotify)
561 (= (length event) 4))
562 ((featurep 'w32notify)
563 (and (= (length event) 3) (stringp (nth 2 event)))))))
564
565(defun auto-revert-notify-event-descriptor (event)
566 "Return watch descriptor of file notification event, or nil."
567 (and (auto-revert-notify-event-p event) (car event)))
568
569(defun auto-revert-notify-event-action (event)
570 "Return action of file notification event, or nil."
571 (and (auto-revert-notify-event-p event) (nth 1 event)))
572
573(defun auto-revert-notify-event-file-name (event)
574 "Return file name of file notification event, or nil."
575 (and (auto-revert-notify-event-p event)
576 (cond ((featurep 'gfilenotify) (nth 2 event))
577 ((featurep 'inotify) (nth 3 event))
578 ((featurep 'w32notify) (nth 2 event)))))
579 534
580(defun auto-revert-notify-handler (event) 535(defun auto-revert-notify-handler (event)
581 "Handle an EVENT returned from file notification." 536 "Handle an EVENT returned from file notification."
582 (when (auto-revert-notify-event-p event) 537 (ignore-errors
583 (let* ((descriptor (auto-revert-notify-event-descriptor event)) 538 (let* ((descriptor (car event))
584 (action (auto-revert-notify-event-action event)) 539 (action (nth 1 event))
585 (file (auto-revert-notify-event-file-name event)) 540 (file (nth 2 event))
541 (file1 (nth 3 event)) ;; Target of `renamed'.
586 (buffers (gethash descriptor 542 (buffers (gethash descriptor
587 auto-revert-notify-watch-descriptor-hash-list))) 543 auto-revert-notify-watch-descriptor-hash-list)))
588 (ignore-errors 544 ;; Check, that event is meant for us.
589 ;; Check, that event is meant for us. 545 (cl-assert descriptor)
590 ;; TODO: Filter events which stop watching, like `move' or `removed'. 546 ;; We do not handle `deleted', because nothing has to be refreshed.
591 (cl-assert descriptor) 547 (cl-assert (memq action '(attribute-changed changed created renamed)) t)
592 (cond 548 ;; Since we watch a directory, a file name must be returned.
593 ((featurep 'gfilenotify) 549 (cl-assert (stringp file))
594 (cl-assert (memq action '(attribute-changed changed created deleted 550 (when (eq action 'renamed) (cl-assert (stringp file1)))
595 ;; FIXME: I keep getting this action, so I 551 ;; Loop over all buffers, in order to find the intended one.
596 ;; added it here, but I have no idea what 552 (dolist (buffer buffers)
597 ;; I'm doing. --Stef 553 (when (buffer-live-p buffer)
598 changes-done-hint)) 554 (with-current-buffer buffer
599 t)) 555 (when (and (stringp buffer-file-name)
600 ((featurep 'inotify) 556 (or
601 (cl-assert (or (memq 'attrib action) 557 (and (memq action '(attribute-changed changed created))
602 (memq 'create action) 558 (string-equal
603 (memq 'modify action) 559 (file-name-nondirectory file)
604 (memq 'moved-to action)))) 560 (file-name-nondirectory buffer-file-name)))
605 ((featurep 'w32notify) (cl-assert (eq 'modified action)))) 561 (and (eq action 'renamed)
606 ;; Since we watch a directory, a file name must be returned. 562 (string-equal
607 (cl-assert (stringp file)) 563 (file-name-nondirectory file1)
608 (dolist (buffer buffers) 564 (file-name-nondirectory buffer-file-name)))))
609 (when (buffer-live-p buffer) 565 ;; Mark buffer modified.
610 (with-current-buffer buffer 566 (setq auto-revert-notify-modified-p t)
611 (when (and (stringp buffer-file-name) 567 ;; No need to check other buffers.
612 (string-equal 568 (cl-return))))))))
613 (file-name-nondirectory file)
614 (file-name-nondirectory buffer-file-name)))
615 ;; Mark buffer modified.
616 (setq auto-revert-notify-modified-p t)
617 ;; No need to check other buffers.
618 (cl-return)))))))))
619 569
620(defun auto-revert-active-p () 570(defun auto-revert-active-p ()
621 "Check if auto-revert is active (in current buffer or globally)." 571 "Check if auto-revert is active (in current buffer or globally)."
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 6c02233e1e2..1db9b7229f3 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -129,6 +129,7 @@ commands.")
129 (define-key map "T" 'Buffer-menu-toggle-files-only) 129 (define-key map "T" 'Buffer-menu-toggle-files-only)
130 (define-key map (kbd "M-s a C-s") 'Buffer-menu-isearch-buffers) 130 (define-key map (kbd "M-s a C-s") 'Buffer-menu-isearch-buffers)
131 (define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp) 131 (define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp)
132 (define-key map (kbd "M-s a C-o") 'Buffer-menu-multi-occur)
132 133
133 (define-key map [mouse-2] 'Buffer-menu-mouse-select) 134 (define-key map [mouse-2] 'Buffer-menu-mouse-select)
134 (define-key map [follow-link] 'mouse-face) 135 (define-key map [follow-link] 'mouse-face)
@@ -169,6 +170,9 @@ commands.")
169 (bindings--define-key menu-map [ir] 170 (bindings--define-key menu-map [ir]
170 '(menu-item "Isearch Marked Buffers..." Buffer-menu-isearch-buffers 171 '(menu-item "Isearch Marked Buffers..." Buffer-menu-isearch-buffers
171 :help "Search for a string through all marked buffers using Isearch")) 172 :help "Search for a string through all marked buffers using Isearch"))
173 (bindings--define-key menu-map [mo]
174 '(menu-item "Multi Occur Marked Buffers..." Buffer-menu-multi-occur
175 :help "Show lines matching a regexp in marked buffers using Occur"))
172 (bindings--define-key menu-map [s3] menu-bar-separator) 176 (bindings--define-key menu-map [s3] menu-bar-separator)
173 (bindings--define-key menu-map [by] 177 (bindings--define-key menu-map [by]
174 '(menu-item "Bury" Buffer-menu-bury 178 '(menu-item "Bury" Buffer-menu-bury
@@ -226,6 +230,7 @@ In Buffer Menu mode, the following commands are defined:
226 buffer selected before this one in another window. 230 buffer selected before this one in another window.
227\\[Buffer-menu-isearch-buffers] Incremental search in the marked buffers. 231\\[Buffer-menu-isearch-buffers] Incremental search in the marked buffers.
228\\[Buffer-menu-isearch-buffers-regexp] Isearch for regexp in the marked buffers. 232\\[Buffer-menu-isearch-buffers-regexp] Isearch for regexp in the marked buffers.
233\\[Buffer-menu-multi-occur] Show lines matching regexp in the marked buffers.
229\\[Buffer-menu-visit-tags-table] visit-tags-table this buffer. 234\\[Buffer-menu-visit-tags-table] visit-tags-table this buffer.
230\\[Buffer-menu-not-modified] Clear modified-flag on that buffer. 235\\[Buffer-menu-not-modified] Clear modified-flag on that buffer.
231\\[Buffer-menu-save] Mark that buffer to be saved, and move down. 236\\[Buffer-menu-save] Mark that buffer to be saved, and move down.
@@ -477,6 +482,11 @@ If UNMARK is non-nil, unmark them."
477 (interactive) 482 (interactive)
478 (multi-isearch-buffers-regexp (Buffer-menu-marked-buffers))) 483 (multi-isearch-buffers-regexp (Buffer-menu-marked-buffers)))
479 484
485(defun Buffer-menu-multi-occur (regexp &optional nlines)
486 "Show all lines in marked buffers containing a match for a regexp."
487 (interactive (occur-read-primary-args))
488 (multi-occur (Buffer-menu-marked-buffers) regexp nlines))
489
480 490
481(defun Buffer-menu-visit-tags-table () 491(defun Buffer-menu-visit-tags-table ()
482 "Visit the tags table in the buffer on this line. See `visit-tags-table'." 492 "Visit the tags table in the buffer on this line. See `visit-tags-table'."
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index a497f759e87..934dfb92a57 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -37,11 +37,14 @@
37;; can edit todo items, reprioritize them within their category, move 37;; can edit todo items, reprioritize them within their category, move
38;; them to another category, delete them, or mark items as done and 38;; them to another category, delete them, or mark items as done and
39;; store them separately from the not yet done items in a category. 39;; store them separately from the not yet done items in a category.
40;; You can add new todo files and categories, rename categories, move 40;; You can add new todo files, edit and delete them. You can add new
41;; them to another file or delete them. You can also display summary 41;; categories, rename and delete them, move categories to another file
42;; tables of the categories in a file and the types of items they 42;; and merge the items of two categories. You can also reorder the
43;; contain. And you can build cross-category lists of items that 43;; sequence of categories in a todo file for the purpose of
44;; satisfy various criteria. 44;; navigation. You can display summary tables of the categories in a
45;; file and the types of items they contain. And you can compile
46;; lists of existing items from multiple categories in one or more
47;; todo files, which are filtered by various criteria.
45 48
46;; To get started, load this package and type `M-x todo-show'. This 49;; To get started, load this package and type `M-x todo-show'. This
47;; will prompt you for the name of the first todo file, its first 50;; will prompt you for the name of the first todo file, its first
@@ -169,12 +172,7 @@ the value of `todo-done-separator'."
169 "Return string used as value of variable `todo-done-separator'." 172 "Return string used as value of variable `todo-done-separator'."
170 (let ((sep todo-done-separator-string)) 173 (let ((sep todo-done-separator-string))
171 (propertize (if (= 1 (length sep)) 174 (propertize (if (= 1 (length sep))
172 ;; Until bug#2749 is fixed, if separator's length 175 (make-string (window-width) (string-to-char sep))
173 ;; is window-width and todo-wrap-lines is
174 ;; non-nil, an indented empty line appears between
175 ;; the separator and the first done item.
176 ;; (make-string (window-width) (string-to-char sep))
177 (make-string (1- (window-width)) (string-to-char sep))
178 todo-done-separator-string) 176 todo-done-separator-string)
179 'face 'todo-done-sep))) 177 'face 'todo-done-sep)))
180 178
@@ -578,11 +576,12 @@ This lacks the extension and directory components."
578 (file-name-sans-extension (file-name-nondirectory file)))) 576 (file-name-sans-extension (file-name-nondirectory file))))
579 577
580(defcustom todo-default-todo-file (todo-short-file-name 578(defcustom todo-default-todo-file (todo-short-file-name
581 (car (funcall todo-files-function))) 579 (car (funcall todo-files-function)))
582 "Todo file visited by first session invocation of `todo-show'." 580 "Todo file visited by first session invocation of `todo-show'."
583 :type `(radio ,@(mapcar (lambda (f) (list 'const f)) 581 :type (when todo-files
584 (mapcar 'todo-short-file-name 582 `(radio ,@(mapcar (lambda (f) (list 'const f))
585 (funcall todo-files-function)))) 583 (mapcar 'todo-short-file-name
584 (funcall todo-files-function)))))
586 :group 'todo) 585 :group 'todo)
587 586
588(defcustom todo-show-current-file t 587(defcustom todo-show-current-file t
@@ -630,7 +629,7 @@ Otherwise, `todo-show' always visits `todo-default-todo-file'."
630 :group 'todo) 629 :group 'todo)
631 630
632;;;###autoload 631;;;###autoload
633(defun todo-show (&optional solicit-file) 632(defun todo-show (&optional solicit-file interactive)
634 "Visit a todo file and display one of its categories. 633 "Visit a todo file and display one of its categories.
635 634
636When invoked in Todo mode, prompt for which todo file to visit. 635When invoked in Todo mode, prompt for which todo file to visit.
@@ -668,117 +667,124 @@ and done items are always shown on visiting a category.
668 667
669Invoking this command in Todo Archive mode visits the 668Invoking this command in Todo Archive mode visits the
670corresponding todo file, displaying the corresponding category." 669corresponding todo file, displaying the corresponding category."
671 (interactive "P") 670 (interactive "P\np")
671 (when todo-default-todo-file
672 (todo-check-file (todo-absolute-file-name todo-default-todo-file)))
672 (catch 'shown 673 (catch 'shown
673 ;; If there is a legacy todo file but no todo file in the current 674 ;; Before initializing the first todo first, check if there is a
674 ;; format, offer to convert the legacy file and show it. 675 ;; legacy todo file and if so, offer to convert to the current
676 ;; format and make it the first new todo file.
675 (unless todo-default-todo-file 677 (unless todo-default-todo-file
676 (let ((legacy-todo-file (if (boundp 'todo-file-do) 678 (let ((legacy-todo-file (if (boundp 'todo-file-do)
677 todo-file-do 679 todo-file-do
678 (locate-user-emacs-file "todo-do" ".todo-do")))) 680 (locate-user-emacs-file "todo-do" ".todo-do"))))
679 (when (and (file-exists-p legacy-todo-file) 681 (when (and (file-exists-p legacy-todo-file)
680 (y-or-n-p (concat "Do you want to convert a copy of your " 682 (y-or-n-p (concat "Do you want to convert a copy of your "
681 "old todo file to the new format? "))) 683 "old todo file to the new format? ")))
682 (when (todo-convert-legacy-files) 684 (when (todo-convert-legacy-files)
683 (throw 'shown nil))))) 685 (throw 'shown nil)))))
684 (let* ((cat) 686 (catch 'end
685 (show-first todo-show-first) 687 (let* ((cat)
686 (file (cond ((or solicit-file 688 (show-first todo-show-first)
687 (and (called-interactively-p 'any) 689 (file (cond ((or solicit-file
688 (memq major-mode '(todo-mode 690 (and interactive
689 todo-archive-mode 691 (memq major-mode '(todo-mode
690 todo-filtered-items-mode)))) 692 todo-archive-mode
691 (if (funcall todo-files-function) 693 todo-filtered-items-mode))))
692 (todo-read-file-name "Choose a todo file to visit: " 694 (if (funcall todo-files-function)
693 nil t) 695 (todo-read-file-name "Choose a todo file to visit: "
694 (user-error "There are no todo files"))) 696 nil t)
695 ((and (eq major-mode 'todo-archive-mode) 697 (user-error "There are no todo files")))
696 ;; Called noninteractively via todo-quit 698 ((and (eq major-mode 'todo-archive-mode)
697 ;; to jump to corresponding category in 699 ;; Called noninteractively via todo-quit
698 ;; todo file. 700 ;; to jump to corresponding category in
699 (not (called-interactively-p 'any))) 701 ;; todo file.
700 (setq cat (todo-current-category)) 702 (not interactive))
701 (concat (file-name-sans-extension 703 (setq cat (todo-current-category))
702 todo-current-todo-file) ".todo")) 704 (concat (file-name-sans-extension
703 (t 705 todo-current-todo-file) ".todo"))
704 (or todo-current-todo-file 706 (t
705 (and todo-show-current-file 707 (or todo-current-todo-file
706 todo-global-current-todo-file) 708 (and todo-show-current-file
707 (todo-absolute-file-name todo-default-todo-file) 709 todo-global-current-todo-file)
708 (todo-add-file))))) 710 (todo-absolute-file-name todo-default-todo-file)
709 add-item first-file) 711 (todo-add-file)))))
710 (unless todo-default-todo-file 712 add-item first-file)
711 ;; We just initialized the first todo file, so make it the default. 713 (unless todo-default-todo-file
712 (setq todo-default-todo-file (todo-short-file-name file) 714 ;; We just initialized the first todo file, so make it the default.
713 first-file t) 715 (setq todo-default-todo-file (todo-short-file-name file)
714 (todo-reevaluate-default-file-defcustom)) 716 first-file t)
715 (unless (member file todo-visited) 717 (todo-reevaluate-default-file-defcustom))
716 ;; Can't setq t-c-t-f here, otherwise wrong file shown when 718 (unless (member file todo-visited)
717 ;; todo-show is called from todo-show-categories-table. 719 ;; Can't setq t-c-t-f here, otherwise wrong file shown when
718 (let ((todo-current-todo-file file)) 720 ;; todo-show is called from todo-show-categories-table.
719 (cond ((eq todo-show-first 'table) 721 (let ((todo-current-todo-file file))
720 (todo-show-categories-table)) 722 (cond ((eq todo-show-first 'table)
721 ((memq todo-show-first '(top diary regexp)) 723 (todo-show-categories-table))
722 (let* ((shortf (todo-short-file-name file)) 724 ((memq todo-show-first '(top diary regexp))
723 (fi-file (todo-absolute-file-name 725 (let* ((shortf (todo-short-file-name file))
724 shortf todo-show-first))) 726 (fi-file (todo-absolute-file-name
725 (when (eq todo-show-first 'regexp) 727 shortf todo-show-first)))
726 (let ((rxfiles (directory-files todo-directory t 728 (when (eq todo-show-first 'regexp)
727 ".*\\.todr$" t))) 729 (let ((rxfiles (directory-files todo-directory t
728 (when (and rxfiles (> (length rxfiles) 1)) 730 ".*\\.todr$" t)))
729 (let ((rxf (mapcar 'todo-short-file-name rxfiles))) 731 (when (and rxfiles (> (length rxfiles) 1))
730 (setq fi-file (todo-absolute-file-name 732 (let ((rxf (mapcar 'todo-short-file-name rxfiles)))
731 (completing-read 733 (setq fi-file (todo-absolute-file-name
732 "Choose a regexp items file: " 734 (completing-read
733 rxf) 'regexp)))))) 735 "Choose a regexp items file: "
734 (if (file-exists-p fi-file) 736 rxf) 'regexp))))))
735 (set-window-buffer 737 (if (file-exists-p fi-file)
736 (selected-window) 738 (set-window-buffer
737 (set-buffer (find-file-noselect fi-file 'nowarn))) 739 (selected-window)
738 (message "There is no %s file for %s" 740 (set-buffer (find-file-noselect fi-file 'nowarn)))
739 (cond ((eq todo-show-first 'top) 741 (message "There is no %s file for %s"
740 "top priorities") 742 (cond ((eq todo-show-first 'top)
741 ((eq todo-show-first 'diary) 743 "top priorities")
742 "diary items") 744 ((eq todo-show-first 'diary)
743 ((eq todo-show-first 'regexp) 745 "diary items")
744 "regexp items")) 746 ((eq todo-show-first 'regexp)
745 shortf) 747 "regexp items"))
746 (setq todo-show-first 'first))))))) 748 shortf)
747 (when (or (member file todo-visited) 749 (setq todo-show-first 'first)))))))
748 (eq todo-show-first 'first)) 750 (when (or (member file todo-visited)
749 (set-window-buffer (selected-window) 751 (eq todo-show-first 'first))
750 (set-buffer (find-file-noselect file 'nowarn))) 752 (unless (todo-check-file file) (throw 'end nil))
751 ;; When quitting an archive file, show the corresponding 753 (set-window-buffer (selected-window)
752 ;; category in the corresponding todo file, if it exists. 754 (set-buffer (find-file-noselect file 'nowarn)))
753 (when (assoc cat todo-categories) 755 ;; When quitting an archive file, show the corresponding
754 (setq todo-category-number (todo-category-number cat))) 756 ;; category in the corresponding todo file, if it exists.
755 ;; If this is a new todo file, add its first category. 757 (when (assoc cat todo-categories)
756 (when (zerop (buffer-size)) 758 (setq todo-category-number (todo-category-number cat)))
757 (let (cat-added) 759 ;; If this is a new todo file, add its first category.
758 (unwind-protect 760 (when (zerop (buffer-size))
759 (setq todo-category-number 761 (let (cat-added)
760 (todo-add-category todo-current-todo-file "") 762 (unwind-protect
761 add-item todo-add-item-if-new-category 763 (setq todo-category-number
762 cat-added t) 764 (todo-add-category todo-current-todo-file "")
763 (if cat-added 765 add-item todo-add-item-if-new-category
764 ;; If the category was added, save the file now, so we 766 cat-added t)
765 ;; don't risk having an empty todo file, which would 767 (if cat-added
766 ;; signal an error if we tried to visit it later, 768 ;; If the category was added, save the file now, so we
767 ;; since doing that looks for category boundaries. 769 ;; don't risk having an empty todo file, which would
768 (save-buffer 0) 770 ;; signal an error if we tried to visit it later,
769 ;; If user cancels before adding the category, clean up 771 ;; since doing that looks for category boundaries.
770 ;; and exit, so we have a fresh slate the next time. 772 (save-buffer 0)
771 (delete-file file) 773 ;; If user cancels before adding the category, clean up
772 (setq todo-files (delete file todo-files)) 774 ;; and exit, so we have a fresh slate the next time.
773 (when first-file 775 (delete-file file)
774 (setq todo-default-todo-file nil 776 ;; (setq todo-files (funcall todo-files-function))
775 todo-current-todo-file nil)) 777 (setq todo-files (delete file todo-files))
776 (kill-buffer) 778 (when first-file
777 (keyboard-quit))))) 779 (setq todo-default-todo-file nil
778 (save-excursion (todo-category-select)) 780 todo-current-todo-file nil)
779 (when add-item (todo-basic-insert-item))) 781 (todo-reevaluate-default-file-defcustom))
780 (setq todo-show-first show-first) 782 (kill-buffer)
781 (add-to-list 'todo-visited file)))) 783 (keyboard-quit)))))
784 (save-excursion (todo-category-select))
785 (when add-item (todo-basic-insert-item)))
786 (setq todo-show-first show-first)
787 (add-to-list 'todo-visited file)))))
782 788
783(defun todo-save () 789(defun todo-save ()
784 "Save the current todo file." 790 "Save the current todo file."
@@ -814,8 +820,15 @@ buries it and restores state as needed."
814 ;; Have to write a newly created archive to file to avoid 820 ;; Have to write a newly created archive to file to avoid
815 ;; subsequent errors. 821 ;; subsequent errors.
816 (todo-save) 822 (todo-save)
817 (todo-show) 823 (let ((todo-file (concat todo-directory
818 (bury-buffer buf)) 824 (todo-short-file-name todo-current-todo-file)
825 ".todo")))
826 (if (todo-check-file todo-file)
827 (todo-show)
828 (message "There is no todo file for this archive")))
829 ;; When todo-check-file runs in todo-show, it kills the
830 ;; buffer if the archive file was deleted externally.
831 (when (buffer-live-p buf) (bury-buffer buf)))
819 ((eq major-mode 'todo-mode) 832 ((eq major-mode 'todo-mode)
820 (todo-save) 833 (todo-save)
821 ;; If we just quit archive mode, just burying the buffer 834 ;; If we just quit archive mode, just burying the buffer
@@ -893,7 +906,7 @@ Categories mode."
893 (interactive "P") 906 (interactive "P")
894 ;; If invoked outside of Todo mode and there is not yet any Todo 907 ;; If invoked outside of Todo mode and there is not yet any Todo
895 ;; file, initialize one. 908 ;; file, initialize one.
896 (if (null todo-files) 909 (if (null (funcall todo-files-function))
897 (todo-show) 910 (todo-show)
898 (let* ((archive (eq where 'archive)) 911 (let* ((archive (eq where 'archive))
899 (cat (unless archive where)) 912 (cat (unless archive where))
@@ -1069,10 +1082,9 @@ option `todo-add-item-if-new-category' is non-nil (the default),
1069prompt for the first item. 1082prompt for the first item.
1070Noninteractively, return the name of the new file." 1083Noninteractively, return the name of the new file."
1071 (interactive) 1084 (interactive)
1072 (let ((prompt (concat "Enter name of new todo file " 1085 (let* ((prompt (concat "Enter name of new todo file "
1073 "(TAB or SPC to see current names): ")) 1086 "(TAB or SPC to see current names): "))
1074 file) 1087 (file (todo-read-file-name prompt)))
1075 (setq file (todo-read-file-name prompt))
1076 (with-current-buffer (get-buffer-create file) 1088 (with-current-buffer (get-buffer-create file)
1077 (erase-buffer) 1089 (erase-buffer)
1078 (write-region (point-min) (point-max) file nil 'nomessage nil t) 1090 (write-region (point-min) (point-max) file nil 'nomessage nil t)
@@ -1087,6 +1099,55 @@ Noninteractively, return the name of the new file."
1087 (todo-show)) 1099 (todo-show))
1088 file))) 1100 file)))
1089 1101
1102(defun todo-delete-file ()
1103 "Delete the current todo, archive or filtered items file.
1104If the todo file has a corresponding archive file, or vice versa,
1105prompt whether to delete that as well. Also kill the buffers
1106visiting the deleted files."
1107 (interactive)
1108 (let* ((file1 (buffer-file-name))
1109 (todo (eq major-mode 'todo-mode))
1110 (archive (eq major-mode 'todo-archive-mode))
1111 (filtered (eq major-mode 'todo-filtered-items-mode))
1112 (file1-sn (todo-short-file-name file1))
1113 (file2 (concat todo-directory file1-sn (cond (todo ".toda")
1114 (archive ".todo"))))
1115 (buf1 (current-buffer))
1116 (buf2 (when file2 (find-buffer-visiting file2)))
1117 (prompt1 (concat "Delete " (cond (todo "todo")
1118 (archive "archive")
1119 (filtered "filtered items"))
1120 " file \"%s\"? "))
1121 (prompt2 (concat "Also delete the corresponding "
1122 (cond (todo "archive") (archive "todo")) " file "
1123 (when buf2 "and kill the buffer visiting it? ")))
1124 (delete1 (yes-or-no-p (format prompt1 file1-sn)))
1125 (delete2 (when (and delete1 (or (file-exists-p file2) buf2))
1126 (yes-or-no-p prompt2))))
1127 (when delete1
1128 (when (file-exists-p file1) (delete-file file1))
1129 (setq todo-visited (delete file1 todo-visited))
1130 (kill-buffer buf1)
1131 (when delete2
1132 (when (file-exists-p file2) (delete-file file2))
1133 (setq todo-visited (delete file2 todo-visited))
1134 (and buf2 (kill-buffer buf2)))
1135 (setq todo-files (funcall todo-files-function)
1136 todo-archives (funcall todo-files-function t))
1137 (when (or (string= file1-sn todo-default-todo-file)
1138 (and delete2 (string= file1-sn todo-default-todo-file)))
1139 (setq todo-default-todo-file (todo-short-file-name (car todo-files))))
1140 (when (or (string= file1 todo-global-current-todo-file)
1141 (and delete2 (string= file2 todo-global-current-todo-file)))
1142 (setq todo-global-current-todo-file nil))
1143 (todo-reevaluate-filelist-defcustoms)
1144 (message (concat (cond (todo "Todo") (archive "Archive")) " file \"%s\" "
1145 (when delete2
1146 (concat "and its "
1147 (cond (todo "archive") (archive "todo"))
1148 " file "))
1149 "deleted") file1-sn))))
1150
1090(defvar todo-edit-buffer "*Todo Edit*" 1151(defvar todo-edit-buffer "*Todo Edit*"
1091 "Name of current buffer in Todo Edit mode.") 1152 "Name of current buffer in Todo Edit mode.")
1092 1153
@@ -1190,9 +1251,9 @@ category there as well."
1190 (save-excursion (todo-category-select))) 1251 (save-excursion (todo-category-select)))
1191 1252
1192(defun todo-delete-category (&optional arg) 1253(defun todo-delete-category (&optional arg)
1193 "Delete current todo category provided it is empty. 1254 "Delete current todo category provided it contains no items.
1194With ARG non-nil delete the category unconditionally, 1255With prefix ARG delete the category even if it does contain
1195i.e. including all existing todo and done items." 1256todo or done items."
1196 (interactive "P") 1257 (interactive "P")
1197 (let* ((file todo-current-todo-file) 1258 (let* ((file todo-current-todo-file)
1198 (cat (todo-current-category)) 1259 (cat (todo-current-category))
@@ -1723,7 +1784,7 @@ the new item:
1723 the item accordingly." 1784 the item accordingly."
1724 ;; If invoked outside of Todo mode and there is not yet any Todo 1785 ;; If invoked outside of Todo mode and there is not yet any Todo
1725 ;; file, initialize one. 1786 ;; file, initialize one.
1726 (if (null todo-files) 1787 (if (null (funcall todo-files-function))
1727 (todo-show) 1788 (todo-show)
1728 (let ((region (eq region-or-here 'region)) 1789 (let ((region (eq region-or-here 'region))
1729 (here (eq region-or-here 'here))) 1790 (here (eq region-or-here 'here)))
@@ -2958,31 +3019,32 @@ first visit in a session displays the first category in the
2958archive, subsequent visits return to the last category 3019archive, subsequent visits return to the last category
2959displayed." 3020displayed."
2960 (interactive) 3021 (interactive)
2961 (let* ((cat (todo-current-category)) 3022 (if (null (funcall todo-files-function t))
2962 (count (todo-get-count 'archived cat)) 3023 (message "There are no archive files")
2963 (archive (concat (file-name-sans-extension todo-current-todo-file) 3024 (let* ((cat (todo-current-category))
2964 ".toda")) 3025 (count (todo-get-count 'archived cat))
2965 place) 3026 (archive (concat (file-name-sans-extension todo-current-todo-file)
2966 (setq place (cond (ask 'other-archive) 3027 ".toda"))
2967 ((file-exists-p archive) 'this-archive) 3028 (place (cond (ask 'other-archive)
2968 (t (when (todo-y-or-n-p 3029 ((file-exists-p archive) 'this-archive)
2969 (concat "This file has no archive; " 3030 (t (when (todo-y-or-n-p
2970 "visit another archive? ")) 3031 (concat "This file has no archive; "
2971 'other-archive)))) 3032 "visit another archive? "))
2972 (when (eq place 'other-archive) 3033 'other-archive)))))
2973 (setq archive (todo-read-file-name "Choose a todo archive: " t t))) 3034 (when (eq place 'other-archive)
2974 (when (and (eq place 'this-archive) (zerop count)) 3035 (setq archive (todo-read-file-name "Choose a todo archive: " t t)))
2975 (setq place (when (todo-y-or-n-p 3036 (when (and (eq place 'this-archive) (zerop count))
2976 (concat "This category has no archived items;" 3037 (setq place (when (todo-y-or-n-p
2977 " visit archive anyway? ")) 3038 (concat "This category has no archived items;"
2978 'other-cat))) 3039 " visit archive anyway? "))
2979 (when place 3040 'other-cat)))
2980 (set-window-buffer (selected-window) 3041 (when place
2981 (set-buffer (find-file-noselect archive))) 3042 (set-window-buffer (selected-window)
2982 (if (member place '(other-archive other-cat)) 3043 (set-buffer (find-file-noselect archive)))
2983 (setq todo-category-number 1) 3044 (if (member place '(other-archive other-cat))
2984 (todo-category-number cat)) 3045 (setq todo-category-number 1)
2985 (todo-category-select)))) 3046 (todo-category-number cat))
3047 (todo-category-select)))))
2986 3048
2987(defun todo-choose-archive () 3049(defun todo-choose-archive ()
2988 "Choose an archive and visit it." 3050 "Choose an archive and visit it."
@@ -3010,9 +3072,7 @@ this category does not exist in the archive, it is created."
3010 (marked (assoc cat todo-categories-with-marks)) 3072 (marked (assoc cat todo-categories-with-marks))
3011 (afile (concat (file-name-sans-extension 3073 (afile (concat (file-name-sans-extension
3012 todo-current-todo-file) ".toda")) 3074 todo-current-todo-file) ".toda"))
3013 (archive (if (file-exists-p afile) 3075 (archive (find-file-noselect afile t))
3014 (find-file-noselect afile t)
3015 (get-buffer-create afile)))
3016 (item (and (todo-done-item-p) 3076 (item (and (todo-done-item-p)
3017 (concat (todo-item-string) "\n"))) 3077 (concat (todo-item-string) "\n")))
3018 (count 0) 3078 (count 0)
@@ -3056,7 +3116,6 @@ this category does not exist in the archive, it is created."
3056 (if (not (or marked all item)) 3116 (if (not (or marked all item))
3057 (throw 'end (message "Only done items can be archived")) 3117 (throw 'end (message "Only done items can be archived"))
3058 (with-current-buffer archive 3118 (with-current-buffer archive
3059 (unless buffer-file-name (erase-buffer))
3060 (let (buffer-read-only) 3119 (let (buffer-read-only)
3061 (widen) 3120 (widen)
3062 (goto-char (point-min)) 3121 (goto-char (point-min))
@@ -3076,11 +3135,13 @@ this category does not exist in the archive, it is created."
3076 (item))) 3135 (item)))
3077 (todo-update-count 'done (if (or marked all) count 1) cat) 3136 (todo-update-count 'done (if (or marked all) count 1) cat)
3078 (todo-update-categories-sexp) 3137 (todo-update-categories-sexp)
3079 ;; If archive is new, save to file now (using write-region in 3138 ;; If archive is new, save to file now (with
3080 ;; order not to get prompted for file to save to), to let 3139 ;; write-region to avoid prompt for file to save to)
3081 ;; auto-mode-alist take effect below. 3140 ;; to update todo-archives, and to let auto-mode-alist
3082 (unless buffer-file-name 3141 ;; take effect below on visiting the archive.
3083 (write-region nil nil afile) 3142 (unless (nth 7 (file-attributes afile))
3143 (write-region nil nil afile t t)
3144 (setq todo-archives (funcall todo-files-function t))
3084 (kill-buffer)))) 3145 (kill-buffer))))
3085 (with-current-buffer tbuf 3146 (with-current-buffer tbuf
3086 (cond 3147 (cond
@@ -3286,19 +3347,24 @@ categories display according to priority."
3286(defun todo-show-categories-table () 3347(defun todo-show-categories-table ()
3287 "Display a table of the current file's categories and item counts. 3348 "Display a table of the current file's categories and item counts.
3288 3349
3289In the initial display the categories are numbered, indicating 3350In the initial display the lines of the table are numbered,
3290their current order for navigating by \\[todo-forward-category] 3351indicating the current order of the categories when sequentially
3291and \\[todo-backward-category]. You can permanently change the 3352navigating through the todo file with `\\[todo-forward-category]'
3292order of the category at point by typing 3353and `\\[todo-backward-category]'. You can reorder the lines, and
3293\\[todo-set-category-number], \\[todo-raise-category] or 3354hence the category sequence, by typing `\\[todo-raise-category]'
3294\\[todo-lower-category]. 3355or `\\[todo-lower-category]' to raise or lower the category at
3356point, or by typing `\\[todo-set-category-number]' and entering a
3357number at the prompt or by typing `\\[todo-set-category-number]'
3358with a numeric prefix. If you save the todo file after
3359reordering the categories, the new order persists in subsequent
3360Emacs sessions.
3295 3361
3296The labels above the category names and item counts are buttons, 3362The labels above the category names and item counts are buttons,
3297and clicking these changes the display: sorted by category name 3363and clicking these changes the display: sorted by category name
3298or by the respective item counts (alternately descending or 3364or by the respective item counts (alternately descending or
3299ascending). In these displays the categories are not numbered 3365ascending). In these displays the categories are not numbered
3300and \\[todo-set-category-number], \\[todo-raise-category] and 3366and `\\[todo-set-category-number]', `\\[todo-raise-category]' and
3301\\[todo-lower-category] are disabled. (Programmatically, the 3367`\\[todo-lower-category]' are disabled. (Programmatically, the
3302sorting is triggered by passing a non-nil SORTKEY argument.) 3368sorting is triggered by passing a non-nil SORTKEY argument.)
3303 3369
3304In addition, the lines with the category names and item counts 3370In addition, the lines with the category names and item counts
@@ -4019,15 +4085,15 @@ regexp items."
4019 "Buffer type string for `todo-filter-items'.") 4085 "Buffer type string for `todo-filter-items'.")
4020 4086
4021(defun todo-filter-items (filter &optional new multifile) 4087(defun todo-filter-items (filter &optional new multifile)
4022 "Display a cross-category list of items filtered by FILTER. 4088 "Display a list of items filtered by FILTER.
4023The values of FILTER can be `top' for top priority items, a cons 4089The values of FILTER can be `top' for top priority items, a cons
4024of `top' and a number passed by the caller, `diary' for diary 4090of `top' and a number passed by the caller, `diary' for diary
4025items, or `regexp' for items matching a regular expression entered 4091items, or `regexp' for items matching a regular expression
4026by the user. The items can be from any categories in the current 4092entered by the user. The items can come from any categories in
4027todo file or, with non-nil MULTIFILE, from several files. If NEW 4093the current todo file or, with non-nil MULTIFILE, from several
4028is nil, visit an appropriate file containing the list of filtered 4094files. If NEW is nil, visit an appropriate file containing the
4029items; if there is no such file, or with non-nil NEW, build the 4095list of filtered items; if there is no such file, or with non-nil
4030list and display it. 4096NEW, build the list and display it.
4031 4097
4032See the documentation strings of the commands 4098See the documentation strings of the commands
4033`todo-filter-top-priorities', `todo-filter-diary-items', 4099`todo-filter-top-priorities', `todo-filter-diary-items',
@@ -4699,14 +4765,57 @@ short todo archive or top priorities file name, respectively."
4699 ((eq type 'regexp) ".todr") 4765 ((eq type 'regexp) ".todr")
4700 (t ".todo")))))) 4766 (t ".todo"))))))
4701 4767
4768(defun todo-check-file (file)
4769 "Check the state associated with FILE and update it if necessary.
4770If FILE exists, return t. If it does not exist and there is no
4771live buffer with its content, return nil; if there is such a
4772buffer and the user tries to show it, ask whether to restore
4773FILE, and if confirmed, do so and return t; else delete the
4774buffer, clean up the state and return nil."
4775 (setq todo-files (funcall todo-files-function))
4776 (setq todo-archives (funcall todo-files-function t))
4777 (if (file-exists-p file)
4778 t
4779 (setq todo-visited (delete file todo-visited))
4780 (let ((buf (find-buffer-visiting file)))
4781 (if (and buf
4782 (y-or-n-p
4783 (concat
4784 (format (concat "Todo file \"%s\" has been deleted but "
4785 "its content is still in a buffer!\n")
4786 (todo-short-file-name file))
4787 "Save that buffer and restore the todo file? ")))
4788 (progn
4789 (with-current-buffer buf (save-buffer))
4790 (setq todo-files (funcall todo-files-function))
4791 (setq todo-archives (funcall todo-files-function t))
4792 t)
4793 (let* ((files (append todo-files todo-archives))
4794 (tctf todo-current-todo-file)
4795 (tgctf todo-global-current-todo-file)
4796 (tdtf (todo-absolute-file-name todo-default-todo-file)))
4797 (unless (or (not todo-current-todo-file)
4798 (member todo-current-todo-file files))
4799 (setq todo-current-todo-file nil))
4800 (unless (or (not todo-global-current-todo-file)
4801 (member todo-global-current-todo-file files))
4802 (setq todo-global-current-todo-file nil))
4803 (unless (or (not todo-default-todo-file)
4804 (member todo-default-todo-file files))
4805 (setq todo-default-todo-file (todo-short-file-name
4806 (car todo-files))))
4807 (todo-reevaluate-filelist-defcustoms)
4808 (when buf (kill-buffer buf))
4809 nil)))))
4810
4702(defun todo-category-number (cat) 4811(defun todo-category-number (cat)
4703 "Return the number of category CAT in this todo file. 4812 "Return the number of category CAT in this todo file.
4704The buffer-local variable `todo-category-number' holds this 4813The buffer-local variable `todo-category-number' holds this
4705number as its value." 4814number as its value."
4706 (let ((categories (mapcar 'car todo-categories))) 4815 (let ((categories (mapcar 'car todo-categories)))
4707 (setq todo-category-number 4816 (setq todo-category-number
4708 ;; Increment by one, so that the highest priority category in Todo 4817 ;; Increment by one, so that the number of the first
4709 ;; Categories mode is numbered one rather than zero. 4818 ;; category is one rather than zero.
4710 (1+ (- (length categories) 4819 (1+ (- (length categories)
4711 (length (member cat categories))))))) 4820 (length (member cat categories)))))))
4712 4821
@@ -5384,7 +5493,27 @@ Each element of the list is a cons of a category name and the
5384file or list of files (as short file names) it is in. The files 5493file or list of files (as short file names) it is in. The files
5385are either the current (or if there is none, the default) todo 5494are either the current (or if there is none, the default) todo
5386file plus the files listed in `todo-category-completions-files', 5495file plus the files listed in `todo-category-completions-files',
5387or, with non-nil ARCHIVE, the current archive file." 5496or, with non-nil ARCHIVE, the current archive file.
5497
5498Before calculating the completions, update the value of
5499`todo-category-completions-files' in case any files named in it
5500have been removed."
5501 (let (deleted)
5502 (dolist (f todo-category-completions-files)
5503 (unless (file-exists-p (todo-absolute-file-name f))
5504 (setq todo-category-completions-files
5505 (delete f todo-category-completions-files))
5506 (push f deleted)))
5507 (when deleted
5508 (let ((pl (> (length deleted) 1))
5509 (names (mapconcat (lambda (f) (concat "\"" f "\"")) deleted ", ")))
5510 (message (concat "File" (if pl "s" "") " " names " ha" (if pl "ve" "s")
5511 " been deleted and removed from\n"
5512 "the list of category completion files")))
5513 (todo-reevaluate-category-completions-files-defcustom)
5514 (custom-set-default 'todo-category-completions-files
5515 (symbol-value 'todo-category-completions-files))
5516 (sleep-for 1.5)))
5388 (let* ((curfile (or todo-current-todo-file 5517 (let* ((curfile (or todo-current-todo-file
5389 (and todo-show-current-file 5518 (and todo-show-current-file
5390 todo-global-current-todo-file) 5519 todo-global-current-todo-file)
@@ -5435,6 +5564,7 @@ MUSTMATCH the name of an existing file must be chosen;
5435otherwise, a new file name is allowed." 5564otherwise, a new file name is allowed."
5436 (let* ((completion-ignore-case todo-completion-ignore-case) 5565 (let* ((completion-ignore-case todo-completion-ignore-case)
5437 (files (mapcar 'todo-short-file-name 5566 (files (mapcar 'todo-short-file-name
5567 ;; (funcall todo-files-function archive)))
5438 (if archive todo-archives todo-files))) 5568 (if archive todo-archives todo-files)))
5439 (file (completing-read prompt files nil mustmatch nil nil 5569 (file (completing-read prompt files nil mustmatch nil nil
5440 (if files 5570 (if files
@@ -5529,7 +5659,7 @@ categories from `todo-category-completions-files'."
5529 ;; Validate only against completion categories. 5659 ;; Validate only against completion categories.
5530 (let ((todo-categories categories)) 5660 (let ((todo-categories categories))
5531 (setq cat (todo-validate-name cat 'category))) 5661 (setq cat (todo-validate-name cat 'category)))
5532 ;; When user enters a nonexistest category name by jumping or 5662 ;; When user enters a nonexistent category name by jumping or
5533 ;; moving, confirm that it should be added, then validate. 5663 ;; moving, confirm that it should be added, then validate.
5534 (unless add 5664 (unless add
5535 (if (todo-y-or-n-p (format "Add new category \"%s\" to file \"%s\"? " 5665 (if (todo-y-or-n-p (format "Add new category \"%s\" to file \"%s\"? "
@@ -5867,13 +5997,24 @@ the empty string (i.e., no time string)."
5867 5997
5868(defun todo-reevaluate-default-file-defcustom () 5998(defun todo-reevaluate-default-file-defcustom ()
5869 "Reevaluate defcustom of `todo-default-todo-file'. 5999 "Reevaluate defcustom of `todo-default-todo-file'.
5870Called after adding or deleting a todo file." 6000Called after adding or deleting a todo file. If the value of
5871 (eval (defcustom todo-default-todo-file (car (funcall todo-files-function)) 6001`todo-default-todo-file' before calling this function was
5872 "Todo file visited by first session invocation of `todo-show'." 6002associated with an existing file, keep that value."
5873 :type `(radio ,@(mapcar (lambda (f) (list 'const f)) 6003 ;; (let ((curval todo-default-todo-file))
5874 (mapcar 'todo-short-file-name 6004 (eval
5875 (funcall todo-files-function)))) 6005 (defcustom todo-default-todo-file (todo-short-file-name
5876 :group 'todo))) 6006 (car (funcall todo-files-function)))
6007 "Todo file visited by first session invocation of `todo-show'."
6008 :type (when todo-files
6009 `(radio ,@(mapcar (lambda (f) (list 'const f))
6010 (mapcar 'todo-short-file-name
6011 (funcall todo-files-function)))))
6012 :group 'todo))
6013 ;; (when (and curval (file-exists-p (todo-absolute-file-name curval)))
6014 ;; (custom-set-default 'todo-default-todo-file curval)
6015 ;; ;; (custom-reevaluate-setting 'todo-default-todo-file)
6016 ;; )))
6017 )
5877 6018
5878(defun todo-reevaluate-category-completions-files-defcustom () 6019(defun todo-reevaluate-category-completions-files-defcustom ()
5879 "Reevaluate defcustom of `todo-category-completions-files'. 6020 "Reevaluate defcustom of `todo-category-completions-files'.
@@ -6060,6 +6201,7 @@ Filtered Items mode following todo (not done) items."
6060 ("Cu" todo-unmark-category) 6201 ("Cu" todo-unmark-category)
6061 ("Fh" todo-toggle-item-header) 6202 ("Fh" todo-toggle-item-header)
6062 ("h" todo-toggle-item-header) 6203 ("h" todo-toggle-item-header)
6204 ("Fk" todo-delete-file)
6063 ("Fe" todo-edit-file) 6205 ("Fe" todo-edit-file)
6064 ("FH" todo-toggle-item-highlighting) 6206 ("FH" todo-toggle-item-highlighting)
6065 ("H" todo-toggle-item-highlighting) 6207 ("H" todo-toggle-item-highlighting)
@@ -6226,12 +6368,13 @@ Filtered Items mode following todo (not done) items."
6226 6368
6227(defun todo-show-current-file () 6369(defun todo-show-current-file ()
6228 "Visit current instead of default todo file with `todo-show'. 6370 "Visit current instead of default todo file with `todo-show'.
6229This function is added to `pre-command-hook' when user option 6371Added to `pre-command-hook' in Todo mode when user option
6230`todo-show-current-file' is set to non-nil." 6372`todo-show-current-file' is set to non-nil."
6231 (setq todo-global-current-todo-file todo-current-todo-file)) 6373 (setq todo-global-current-todo-file todo-current-todo-file))
6232 6374
6233(defun todo-display-as-todo-file () 6375(defun todo-display-as-todo-file ()
6234 "Show todo files correctly when visited from outside of Todo mode." 6376 "Show todo files correctly when visited from outside of Todo mode.
6377Added to `find-file-hook' in Todo mode and Todo Archive mode."
6235 (and (member this-command todo-visit-files-commands) 6378 (and (member this-command todo-visit-files-commands)
6236 (= (- (point-max) (point-min)) (buffer-size)) 6379 (= (- (point-max) (point-min)) (buffer-size))
6237 (member major-mode '(todo-mode todo-archive-mode)) 6380 (member major-mode '(todo-mode todo-archive-mode))
@@ -6265,7 +6408,7 @@ This function is added to `kill-buffer-hook' in Todo mode."
6265 6408
6266(defun todo-reset-and-enable-done-separator () 6409(defun todo-reset-and-enable-done-separator ()
6267 "Show resized done items separator overlay after window change. 6410 "Show resized done items separator overlay after window change.
6268Added to `window-configuration-change-hook' in `todo-mode'." 6411Added to `window-configuration-change-hook' in Todo mode."
6269 (when (= 1 (length todo-done-separator-string)) 6412 (when (= 1 (length todo-done-separator-string))
6270 (let ((sep todo-done-separator)) 6413 (let ((sep todo-done-separator))
6271 (setq todo-done-separator (todo-done-separator)) 6414 (setq todo-done-separator (todo-done-separator))
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog
index 7a2c5755cc0..705277c97a0 100644
--- a/lisp/cedet/ChangeLog
+++ b/lisp/cedet/ChangeLog
@@ -2,7 +2,7 @@
2 2
3 * data-debug.el, cedet-idutils.el: Neuter the "Version:" header. 3 * data-debug.el, cedet-idutils.el: Neuter the "Version:" header.
4 4
52013-06-19 Glenn Morris <rgm@fencepost.gnu.org> 52013-06-19 Glenn Morris <rgm@gnu.org>
6 6
7 * semantic/idle.el (define-semantic-idle-service): 7 * semantic/idle.el (define-semantic-idle-service):
8 No need to use eval-and-compile, progn will do. 8 No need to use eval-and-compile, progn will do.
diff --git a/lisp/desktop.el b/lisp/desktop.el
index db77d7c3f5a..fcd032a64d0 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -196,9 +196,7 @@ Zero or nil means disable timer-based auto-saving."
196 (integer :tag "Seconds")) 196 (integer :tag "Seconds"))
197 :set (lambda (symbol value) 197 :set (lambda (symbol value)
198 (set-default symbol value) 198 (set-default symbol value)
199 (condition-case nil 199 (ignore-errors (desktop-auto-save-set-timer)))
200 (desktop-auto-save-set-timer)
201 (error nil)))
202 :group 'desktop 200 :group 'desktop
203 :version "24.4") 201 :version "24.4")
204 202
@@ -416,9 +414,8 @@ See `desktop-restore-eager'."
416 :version "22.1") 414 :version "22.1")
417 415
418;;;###autoload 416;;;###autoload
419(defvar desktop-save-buffer nil 417(defvar-local desktop-save-buffer nil
420 "When non-nil, save buffer status in desktop file. 418 "When non-nil, save buffer status in desktop file.
421This variable becomes buffer local when set.
422 419
423If the value is a function, it is called by `desktop-save' with argument 420If the value is a function, it is called by `desktop-save' with argument
424DESKTOP-DIRNAME to obtain auxiliary information to save in the desktop 421DESKTOP-DIRNAME to obtain auxiliary information to save in the desktop
@@ -430,7 +427,6 @@ When file names are returned, they should be formatted using the call
430Later, when `desktop-read' evaluates the desktop file, auxiliary information 427Later, when `desktop-read' evaluates the desktop file, auxiliary information
431is passed as the argument DESKTOP-BUFFER-MISC to functions in 428is passed as the argument DESKTOP-BUFFER-MISC to functions in
432`desktop-buffer-mode-handlers'.") 429`desktop-buffer-mode-handlers'.")
433(make-variable-buffer-local 'desktop-save-buffer)
434(make-obsolete-variable 'desktop-buffer-modes-to-save 430(make-obsolete-variable 'desktop-buffer-modes-to-save
435 'desktop-save-buffer "22.1") 431 'desktop-save-buffer "22.1")
436(make-obsolete-variable 'desktop-buffer-misc-functions 432(make-obsolete-variable 'desktop-buffer-misc-functions
@@ -582,15 +578,15 @@ Used to detect desktop file conflicts.")
582 "Return the PID of the Emacs process that owns the desktop file in DIRNAME. 578 "Return the PID of the Emacs process that owns the desktop file in DIRNAME.
583Return nil if no desktop file found or no Emacs process is using it. 579Return nil if no desktop file found or no Emacs process is using it.
584DIRNAME omitted or nil means use `desktop-dirname'." 580DIRNAME omitted or nil means use `desktop-dirname'."
585 (let (owner) 581 (let (owner
586 (and (file-exists-p (desktop-full-lock-name dirname)) 582 (file (desktop-full-lock-name dirname)))
587 (condition-case nil 583 (and (file-exists-p file)
588 (with-temp-buffer 584 (ignore-errors
589 (insert-file-contents-literally (desktop-full-lock-name dirname)) 585 (with-temp-buffer
590 (goto-char (point-min)) 586 (insert-file-contents-literally file)
591 (setq owner (read (current-buffer))) 587 (goto-char (point-min))
592 (integerp owner)) 588 (setq owner (read (current-buffer)))
593 (error nil)) 589 (integerp owner)))
594 owner))) 590 owner)))
595 591
596(defun desktop-claim-lock (&optional dirname) 592(defun desktop-claim-lock (&optional dirname)
@@ -636,7 +632,7 @@ Furthermore, it clears the variables listed in `desktop-globals-to-clear'."
636 (let ((bufname (buffer-name (car buffers)))) 632 (let ((bufname (buffer-name (car buffers))))
637 (or 633 (or
638 (null bufname) 634 (null bufname)
639 (string-match preserve-regexp bufname) 635 (string-match-p preserve-regexp bufname)
640 ;; Don't kill buffers made for internal purposes. 636 ;; Don't kill buffers made for internal purposes.
641 (and (not (equal bufname "")) (eq (aref bufname 0) ?\s)) 637 (and (not (equal bufname "")) (eq (aref bufname 0) ?\s))
642 (kill-buffer (car buffers)))) 638 (kill-buffer (car buffers))))
@@ -758,8 +754,7 @@ QUOTE may be `may' (value may be quoted),
758 ((consp value) 754 ((consp value)
759 (let ((p value) 755 (let ((p value)
760 newlist 756 newlist
761 use-list* 757 use-list*)
762 anynil)
763 (while (consp p) 758 (while (consp p)
764 (let ((q.sexp (desktop--v2s (car p)))) 759 (let ((q.sexp (desktop--v2s (car p))))
765 (push q.sexp newlist)) 760 (push q.sexp newlist))
@@ -841,17 +836,17 @@ MODE is the major mode.
841 dired-skip) 836 dired-skip)
842 (and (not (and (stringp desktop-buffers-not-to-save) 837 (and (not (and (stringp desktop-buffers-not-to-save)
843 (not filename) 838 (not filename)
844 (string-match desktop-buffers-not-to-save bufname))) 839 (string-match-p desktop-buffers-not-to-save bufname)))
845 (not (memq mode desktop-modes-not-to-save)) 840 (not (memq mode desktop-modes-not-to-save))
846 ;; FIXME this is broken if desktop-files-not-to-save is nil. 841 ;; FIXME this is broken if desktop-files-not-to-save is nil.
847 (or (and filename 842 (or (and filename
848 (stringp desktop-files-not-to-save) 843 (stringp desktop-files-not-to-save)
849 (not (string-match desktop-files-not-to-save filename))) 844 (not (string-match-p desktop-files-not-to-save filename)))
850 (and (memq mode '(dired-mode vc-dir-mode)) 845 (and (memq mode '(dired-mode vc-dir-mode))
851 (with-current-buffer bufname 846 (with-current-buffer bufname
852 (not (setq dired-skip 847 (not (setq dired-skip
853 (string-match desktop-files-not-to-save 848 (string-match-p desktop-files-not-to-save
854 default-directory))))) 849 default-directory)))))
855 (and (null filename) 850 (and (null filename)
856 (null dired-skip) ; bug#5755 851 (null dired-skip) ; bug#5755
857 (with-current-buffer bufname desktop-save-buffer)))))) 852 (with-current-buffer bufname desktop-save-buffer))))))
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index e4434c3a0d8..10968f7f8dd 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -136,7 +136,7 @@
136 136
137;;; Code: 137;;; Code:
138 138
139(eval-when-compile (require 'cl-lib)) 139(require 'cl-lib)
140(require 'dired) 140(require 'dired)
141(require 'image-mode) 141(require 'image-mode)
142(require 'jka-compr) 142(require 'jka-compr)
@@ -698,14 +698,6 @@ It's a subdirectory of `doc-view-cache-directory'."
698 (md5 (current-buffer))))) 698 (md5 (current-buffer)))))
699 doc-view-cache-directory))))) 699 doc-view-cache-directory)))))
700 700
701(defun doc-view-remove-if (predicate list)
702 "Return LIST with all items removed that satisfy PREDICATE."
703 (let (new-list)
704 (dolist (item list)
705 (when (not (funcall predicate item))
706 (setq new-list (cons item new-list))))
707 (nreverse new-list)))
708
709;;;###autoload 701;;;###autoload
710(defun doc-view-mode-p (type) 702(defun doc-view-mode-p (type)
711 "Return non-nil if document type TYPE is available for `doc-view'. 703 "Return non-nil if document type TYPE is available for `doc-view'.
@@ -1488,7 +1480,7 @@ If BACKWARD is non-nil, jump to the previous match."
1488(defun doc-view-search-next-match (arg) 1480(defun doc-view-search-next-match (arg)
1489 "Go to the ARGth next matching page." 1481 "Go to the ARGth next matching page."
1490 (interactive "p") 1482 (interactive "p")
1491 (let* ((next-pages (doc-view-remove-if 1483 (let* ((next-pages (cl-remove-if
1492 (lambda (i) (<= (car i) (doc-view-current-page))) 1484 (lambda (i) (<= (car i) (doc-view-current-page)))
1493 doc-view--current-search-matches)) 1485 doc-view--current-search-matches))
1494 (page (car (nth (1- arg) next-pages)))) 1486 (page (car (nth (1- arg) next-pages))))
@@ -1502,7 +1494,7 @@ If BACKWARD is non-nil, jump to the previous match."
1502(defun doc-view-search-previous-match (arg) 1494(defun doc-view-search-previous-match (arg)
1503 "Go to the ARGth previous matching page." 1495 "Go to the ARGth previous matching page."
1504 (interactive "p") 1496 (interactive "p")
1505 (let* ((prev-pages (doc-view-remove-if 1497 (let* ((prev-pages (cl-remove-if
1506 (lambda (i) (>= (car i) (doc-view-current-page))) 1498 (lambda (i) (>= (car i) (doc-view-current-page)))
1507 doc-view--current-search-matches)) 1499 doc-view--current-search-matches))
1508 (page (car (nth (1- arg) (nreverse prev-pages))))) 1500 (page (car (nth (1- arg) (nreverse prev-pages)))))
diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index 6ef2e29dc83..67992d16527 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -62,9 +62,8 @@
62;; macro in a more concise way that omits the comments. 62;; macro in a more concise way that omits the comments.
63 63
64;;; Code: 64;;; Code:
65
66(eval-when-compile (require 'cl-lib))
67 65
66(require 'cl-lib)
68(require 'kmacro) 67(require 'kmacro)
69 68
70;;; The user-level commands for editing macros. 69;;; The user-level commands for editing macros.
@@ -444,14 +443,14 @@ doubt, use whitespace."
444 (let* ((prefix 443 (let* ((prefix
445 (or (and (integerp (aref rest-mac 0)) 444 (or (and (integerp (aref rest-mac 0))
446 (memq (aref rest-mac 0) mdigs) 445 (memq (aref rest-mac 0) mdigs)
447 (memq (key-binding (edmacro-subseq rest-mac 0 1)) 446 (memq (key-binding (cl-subseq rest-mac 0 1))
448 '(digit-argument negative-argument)) 447 '(digit-argument negative-argument))
449 (let ((i 1)) 448 (let ((i 1))
450 (while (memq (aref rest-mac i) (cdr mdigs)) 449 (while (memq (aref rest-mac i) (cdr mdigs))
451 (cl-incf i)) 450 (cl-incf i))
452 (and (not (memq (aref rest-mac i) pkeys)) 451 (and (not (memq (aref rest-mac i) pkeys))
453 (prog1 (vconcat "M-" (edmacro-subseq rest-mac 0 i) " ") 452 (prog1 (vconcat "M-" (cl-subseq rest-mac 0 i) " ")
454 (cl-callf edmacro-subseq rest-mac i))))) 453 (cl-callf cl-subseq rest-mac i)))))
455 (and (eq (aref rest-mac 0) ?\C-u) 454 (and (eq (aref rest-mac 0) ?\C-u)
456 (eq (key-binding [?\C-u]) 'universal-argument) 455 (eq (key-binding [?\C-u]) 'universal-argument)
457 (let ((i 1)) 456 (let ((i 1))
@@ -459,7 +458,7 @@ doubt, use whitespace."
459 (cl-incf i)) 458 (cl-incf i))
460 (and (not (memq (aref rest-mac i) pkeys)) 459 (and (not (memq (aref rest-mac i) pkeys))
461 (prog1 (cl-loop repeat i concat "C-u ") 460 (prog1 (cl-loop repeat i concat "C-u ")
462 (cl-callf edmacro-subseq rest-mac i))))) 461 (cl-callf cl-subseq rest-mac i)))))
463 (and (eq (aref rest-mac 0) ?\C-u) 462 (and (eq (aref rest-mac 0) ?\C-u)
464 (eq (key-binding [?\C-u]) 'universal-argument) 463 (eq (key-binding [?\C-u]) 'universal-argument)
465 (let ((i 1)) 464 (let ((i 1))
@@ -469,18 +468,18 @@ doubt, use whitespace."
469 '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) 468 '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
470 (cl-incf i)) 469 (cl-incf i))
471 (and (not (memq (aref rest-mac i) pkeys)) 470 (and (not (memq (aref rest-mac i) pkeys))
472 (prog1 (vconcat "C-u " (edmacro-subseq rest-mac 1 i) " ") 471 (prog1 (vconcat "C-u " (cl-subseq rest-mac 1 i) " ")
473 (cl-callf edmacro-subseq rest-mac i))))))) 472 (cl-callf cl-subseq rest-mac i)))))))
474 (bind-len (apply 'max 1 473 (bind-len (apply 'max 1
475 (cl-loop for map in maps 474 (cl-loop for map in maps
476 for b = (lookup-key map rest-mac) 475 for b = (lookup-key map rest-mac)
477 when b collect b))) 476 when b collect b)))
478 (key (edmacro-subseq rest-mac 0 bind-len)) 477 (key (cl-subseq rest-mac 0 bind-len))
479 (fkey nil) tlen tkey 478 (fkey nil) tlen tkey
480 (bind (or (cl-loop for map in maps for b = (lookup-key map key) 479 (bind (or (cl-loop for map in maps for b = (lookup-key map key)
481 thereis (and (not (integerp b)) b)) 480 thereis (and (not (integerp b)) b))
482 (and (setq fkey (lookup-key local-function-key-map rest-mac)) 481 (and (setq fkey (lookup-key local-function-key-map rest-mac))
483 (setq tlen fkey tkey (edmacro-subseq rest-mac 0 tlen) 482 (setq tlen fkey tkey (cl-subseq rest-mac 0 tlen)
484 fkey (lookup-key local-function-key-map tkey)) 483 fkey (lookup-key local-function-key-map tkey))
485 (cl-loop for map in maps 484 (cl-loop for map in maps
486 for b = (lookup-key map fkey) 485 for b = (lookup-key map fkey)
@@ -507,7 +506,7 @@ doubt, use whitespace."
507 (> first 32) (<= first maxkey) (/= first 92) 506 (> first 32) (<= first maxkey) (/= first 92)
508 (progn 507 (progn
509 (if (> text 30) (setq text 30)) 508 (if (> text 30) (setq text 30))
510 (setq desc (concat (edmacro-subseq rest-mac 0 text))) 509 (setq desc (concat (cl-subseq rest-mac 0 text)))
511 (when (string-match "^[ACHMsS]-." desc) 510 (when (string-match "^[ACHMsS]-." desc)
512 (setq text 2) 511 (setq text 2)
513 (cl-callf substring desc 0 2)) 512 (cl-callf substring desc 0 2))
@@ -524,7 +523,7 @@ doubt, use whitespace."
524 (> text bind-len) 523 (> text bind-len)
525 (memq (aref rest-mac text) '(return 13)) 524 (memq (aref rest-mac text) '(return 13))
526 (progn 525 (progn
527 (setq desc (concat (edmacro-subseq rest-mac bind-len text))) 526 (setq desc (concat (cl-subseq rest-mac bind-len text)))
528 (commandp (intern-soft desc)))) 527 (commandp (intern-soft desc))))
529 (if (commandp (intern-soft desc)) (setq bind desc)) 528 (if (commandp (intern-soft desc)) (setq bind desc))
530 (setq desc (format "<<%s>>" desc)) 529 (setq desc (format "<<%s>>" desc))
@@ -562,14 +561,14 @@ doubt, use whitespace."
562 (setq desc (concat (edmacro-sanitize-for-string prefix) desc))) 561 (setq desc (concat (edmacro-sanitize-for-string prefix) desc)))
563 (unless (string-match " " desc) 562 (unless (string-match " " desc)
564 (let ((times 1) (pos bind-len)) 563 (let ((times 1) (pos bind-len))
565 (while (not (edmacro-mismatch rest-mac rest-mac 564 (while (not (cl-mismatch rest-mac rest-mac
566 0 bind-len pos (+ bind-len pos))) 565 0 bind-len pos (+ bind-len pos)))
567 (cl-incf times) 566 (cl-incf times)
568 (cl-incf pos bind-len)) 567 (cl-incf pos bind-len))
569 (when (> times 1) 568 (when (> times 1)
570 (setq desc (format "%d*%s" times desc)) 569 (setq desc (format "%d*%s" times desc))
571 (setq bind-len (* bind-len times))))) 570 (setq bind-len (* bind-len times)))))
572 (setq rest-mac (edmacro-subseq rest-mac bind-len)) 571 (setq rest-mac (cl-subseq rest-mac bind-len))
573 (if verbose 572 (if verbose
574 (progn 573 (progn
575 (unless (equal res "") (cl-callf concat res "\n")) 574 (unless (equal res "") (cl-callf concat res "\n"))
@@ -590,50 +589,6 @@ doubt, use whitespace."
590 (cl-incf len (length desc))))) 589 (cl-incf len (length desc)))))
591 res)) 590 res))
592 591
593(defun edmacro-mismatch (cl-seq1 cl-seq2 cl-start1 cl-end1 cl-start2 cl-end2)
594 "Compare SEQ1 with SEQ2, return index of first mismatching element.
595Return nil if the sequences match. If one sequence is a prefix of the
596other, the return value indicates the end of the shorted sequence.
597\n(fn SEQ1 SEQ2 START1 END1 START2 END2)"
598 (or cl-end1 (setq cl-end1 (length cl-seq1)))
599 (or cl-end2 (setq cl-end2 (length cl-seq2)))
600 (let ((cl-p1 (and (listp cl-seq1) (nthcdr cl-start1 cl-seq1)))
601 (cl-p2 (and (listp cl-seq2) (nthcdr cl-start2 cl-seq2))))
602 (while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
603 (eql (if cl-p1 (car cl-p1)
604 (aref cl-seq1 cl-start1))
605 (if cl-p2 (car cl-p2)
606 (aref cl-seq2 cl-start2))))
607 (setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2)
608 cl-start1 (1+ cl-start1) cl-start2 (1+ cl-start2)))
609 (and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
610 cl-start1)))
611
612(defun edmacro-subseq (seq start &optional end)
613 "Return the subsequence of SEQ from START to END.
614If END is omitted, it defaults to the length of the sequence.
615If START or END is negative, it counts from the end."
616 (if (stringp seq) (substring seq start end)
617 (let (len)
618 (and end (< end 0) (setq end (+ end (setq len (length seq)))))
619 (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
620 (cond ((listp seq)
621 (if (> start 0) (setq seq (nthcdr start seq)))
622 (if end
623 (let ((res nil))
624 (while (>= (setq end (1- end)) start)
625 (push (pop seq) res))
626 (nreverse res))
627 (copy-sequence seq)))
628 (t
629 (or end (setq end (or len (length seq))))
630 (let ((res (make-vector (max (- end start) 0) nil))
631 (i 0))
632 (while (< start end)
633 (aset res i (aref seq start))
634 (setq i (1+ i) start (1+ start)))
635 res))))))
636
637(defun edmacro-sanitize-for-string (seq) 592(defun edmacro-sanitize-for-string (seq)
638 "Convert a key sequence vector SEQ into a string. 593 "Convert a key sequence vector SEQ into a string.
639The string represents the same events; Meta is indicated by bit 7. 594The string represents the same events; Meta is indicated by bit 7.
@@ -760,7 +715,7 @@ This function assumes that the events can be stored in a string."
760 (eq (aref res 1) ?\() 715 (eq (aref res 1) ?\()
761 (eq (aref res (- (length res) 2)) ?\C-x) 716 (eq (aref res (- (length res) 2)) ?\C-x)
762 (eq (aref res (- (length res) 1)) ?\))) 717 (eq (aref res (- (length res) 1)) ?\)))
763 (setq res (edmacro-subseq res 2 -2))) 718 (setq res (cl-subseq res 2 -2)))
764 (if (and (not need-vector) 719 (if (and (not need-vector)
765 (cl-loop for ch across res 720 (cl-loop for ch across res
766 always (and (characterp ch) 721 always (and (characterp ch)
diff --git a/lisp/emacs-lisp/.gitignore b/lisp/emacs-lisp/.gitignore
deleted file mode 100644
index 133e79e817a..00000000000
--- a/lisp/emacs-lisp/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
1!*-loaddefs.el
2
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 3cf744f1245..c47c9b61030 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1957,7 +1957,7 @@ by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...).
1957 "Collect multiple return values. 1957 "Collect multiple return values.
1958FORM must return a list; the BODY is then executed with the first N elements 1958FORM must return a list; the BODY is then executed with the first N elements
1959of this list bound (`let'-style) to each of the symbols SYM in turn. This 1959of this list bound (`let'-style) to each of the symbols SYM in turn. This
1960is analogous to the Common Lisp `cl-multiple-value-bind' macro, using lists to 1960is analogous to the Common Lisp `multiple-value-bind' macro, using lists to
1961simulate true multiple return values. For compatibility, (cl-values A B C) is 1961simulate true multiple return values. For compatibility, (cl-values A B C) is
1962a synonym for (list A B C). 1962a synonym for (list A B C).
1963 1963
@@ -1975,7 +1975,7 @@ a synonym for (list A B C).
1975 "Collect multiple return values. 1975 "Collect multiple return values.
1976FORM must return a list; the first N elements of this list are stored in 1976FORM must return a list; the first N elements of this list are stored in
1977each of the symbols SYM in turn. This is analogous to the Common Lisp 1977each of the symbols SYM in turn. This is analogous to the Common Lisp
1978`cl-multiple-value-setq' macro, using lists to simulate true multiple return 1978`multiple-value-setq' macro, using lists to simulate true multiple return
1979values. For compatibility, (cl-values A B C) is a synonym for (list A B C). 1979values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
1980 1980
1981\(fn (SYM...) FORM)" 1981\(fn (SYM...) FORM)"
@@ -2002,7 +2002,7 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
2002 (cons 'progn body)) 2002 (cons 'progn body))
2003;;;###autoload 2003;;;###autoload
2004(defmacro cl-the (_type form) 2004(defmacro cl-the (_type form)
2005 "At present this ignores _TYPE and is simply equivalent to FORM." 2005 "At present this ignores TYPE and is simply equivalent to FORM."
2006 (declare (indent 1) (debug (cl-type-spec form))) 2006 (declare (indent 1) (debug (cl-type-spec form)))
2007 form) 2007 form)
2008 2008
@@ -2059,7 +2059,7 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
2059 "Declare SPECS about the current function while compiling. 2059 "Declare SPECS about the current function while compiling.
2060For instance 2060For instance
2061 2061
2062 \(cl-declare (warn 0)) 2062 (cl-declare (warn 0))
2063 2063
2064will turn off byte-compile warnings in the function. 2064will turn off byte-compile warnings in the function.
2065See Info node `(cl)Declarations' for details." 2065See Info node `(cl)Declarations' for details."
@@ -2279,8 +2279,8 @@ KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
2279Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where 2279Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
2280SDEFAULT is the default value of that slot and SOPTIONS are keyword-value 2280SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
2281pairs for that slot. 2281pairs for that slot.
2282Currently, only one keyword is supported, `:read-only'. If this has a non-nil 2282Currently, only one keyword is supported, `:read-only'. If this has a
2283value, that slot cannot be set via `setf'. 2283non-nil value, that slot cannot be set via `setf'.
2284 2284
2285\(fn NAME SLOTS...)" 2285\(fn NAME SLOTS...)"
2286 (declare (doc-string 2) (indent 1) 2286 (declare (doc-string 2) (indent 1)
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 319af588eac..36c72f3a3bd 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -53,7 +53,7 @@
53;;; Code: 53;;; Code:
54 54
55(require 'macroexp) 55(require 'macroexp)
56(eval-when-compile (require 'cl-lib)) 56(require 'cl-lib)
57(eval-when-compile (require 'pcase)) 57(eval-when-compile (require 'pcase))
58 58
59;;; Options 59;;; Options
@@ -263,26 +263,6 @@ An extant spec symbol is a symbol that is not a function and has a
263 263
264;;; Utilities 264;;; Utilities
265 265
266;; Define edebug-gensym - from old cl.el
267(defvar edebug-gensym-index 0
268 "Integer used by `edebug-gensym' to produce new names.")
269
270(defun edebug-gensym (&optional prefix)
271 "Generate a fresh uninterned symbol.
272There is an optional argument, PREFIX. PREFIX is the string
273that begins the new name. Most people take just the default,
274except when debugging needs suggest otherwise."
275 (if (null prefix)
276 (setq prefix "G"))
277 (let ((newsymbol nil)
278 (newname ""))
279 (while (not newsymbol)
280 (setq newname (concat prefix (int-to-string edebug-gensym-index)))
281 (setq edebug-gensym-index (+ edebug-gensym-index 1))
282 (if (not (intern-soft newname))
283 (setq newsymbol (make-symbol newname))))
284 newsymbol))
285
286(defun edebug-lambda-list-keywordp (object) 266(defun edebug-lambda-list-keywordp (object)
287 "Return t if OBJECT is a lambda list keyword. 267 "Return t if OBJECT is a lambda list keyword.
288A lambda list keyword is a symbol that starts with `&'." 268A lambda list keyword is a symbol that starts with `&'."
@@ -1186,7 +1166,7 @@ Maybe clear the markers and delete the symbol's edebug property?"
1186 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args. 1166 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args.
1187 ;; Do this after parsing since that may find a name. 1167 ;; Do this after parsing since that may find a name.
1188 (setq edebug-def-name 1168 (setq edebug-def-name
1189 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) 1169 (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon")))
1190 `(edebug-enter 1170 `(edebug-enter
1191 (quote ,edebug-def-name) 1171 (quote ,edebug-def-name)
1192 ,(if edebug-inside-func 1172 ,(if edebug-inside-func
@@ -1299,7 +1279,7 @@ expressions; a `progn' form will be returned enclosing these forms."
1299 1279
1300 ;; Set the name here if it was not set by edebug-make-enter-wrapper. 1280 ;; Set the name here if it was not set by edebug-make-enter-wrapper.
1301 (setq edebug-def-name 1281 (setq edebug-def-name
1302 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) 1282 (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon")))
1303 1283
1304 ;; Add this def as a dependent of containing def. Buggy. 1284 ;; Add this def as a dependent of containing def. Buggy.
1305 '(if (and edebug-containing-def-name 1285 '(if (and edebug-containing-def-name
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 656cb0a6a14..1f5edefea08 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -54,7 +54,7 @@
54 54
55;;; Code: 55;;; Code:
56 56
57(eval-when-compile (require 'cl-lib)) 57(require 'cl-lib)
58(require 'button) 58(require 'button)
59(require 'debug) 59(require 'debug)
60(require 'easymenu) 60(require 'easymenu)
@@ -87,127 +87,6 @@
87 87
88;;; Copies/reimplementations of cl functions. 88;;; Copies/reimplementations of cl functions.
89 89
90(defun ert--cl-do-remf (plist tag)
91 "Copy of `cl-do-remf'. Modify PLIST by removing TAG."
92 (let ((p (cdr plist)))
93 (while (and (cdr p) (not (eq (car (cdr p)) tag))) (setq p (cdr (cdr p))))
94 (and (cdr p) (progn (setcdr p (cdr (cdr (cdr p)))) t))))
95
96(defun ert--remprop (sym tag)
97 "Copy of `cl-remprop'. Modify SYM's plist by removing TAG."
98 (let ((plist (symbol-plist sym)))
99 (if (and plist (eq tag (car plist)))
100 (progn (setplist sym (cdr (cdr plist))) t)
101 (ert--cl-do-remf plist tag))))
102
103(defun ert--remove-if-not (ert-pred ert-list)
104 "A reimplementation of `remove-if-not'.
105
106ERT-PRED is a predicate, ERT-LIST is the input list."
107 (cl-loop for ert-x in ert-list
108 if (funcall ert-pred ert-x)
109 collect ert-x))
110
111(defun ert--intersection (a b)
112 "A reimplementation of `intersection'. Intersect the sets A and B.
113
114Elements are compared using `eql'."
115 (cl-loop for x in a
116 if (memql x b)
117 collect x))
118
119(defun ert--set-difference (a b)
120 "A reimplementation of `set-difference'. Subtract the set B from the set A.
121
122Elements are compared using `eql'."
123 (cl-loop for x in a
124 unless (memql x b)
125 collect x))
126
127(defun ert--set-difference-eq (a b)
128 "A reimplementation of `set-difference'. Subtract the set B from the set A.
129
130Elements are compared using `eq'."
131 (cl-loop for x in a
132 unless (memq x b)
133 collect x))
134
135(defun ert--union (a b)
136 "A reimplementation of `union'. Compute the union of the sets A and B.
137
138Elements are compared using `eql'."
139 (append a (ert--set-difference b a)))
140
141(eval-and-compile
142 (defvar ert--gensym-counter 0))
143
144(eval-and-compile
145 (defun ert--gensym (&optional prefix)
146 "Only allows string PREFIX, not compatible with CL."
147 (unless prefix (setq prefix "G"))
148 (make-symbol (format "%s%s"
149 prefix
150 (prog1 ert--gensym-counter
151 (cl-incf ert--gensym-counter))))))
152
153(defun ert--coerce-to-vector (x)
154 "Coerce X to a vector."
155 (when (char-table-p x) (error "Not supported"))
156 (if (vectorp x)
157 x
158 (vconcat x)))
159
160(cl-defun ert--remove* (x list &key key test)
161 "Does not support all the keywords of remove*."
162 (unless key (setq key #'identity))
163 (unless test (setq test #'eql))
164 (cl-loop for y in list
165 unless (funcall test x (funcall key y))
166 collect y))
167
168(defun ert--string-position (c s)
169 "Return the position of the first occurrence of C in S, or nil if none."
170 (cl-loop for i from 0
171 for x across s
172 when (eql x c) return i))
173
174(defun ert--mismatch (a b)
175 "Return index of first element that differs between A and B.
176
177Like `mismatch'. Uses `equal' for comparison."
178 (cond ((or (listp a) (listp b))
179 (ert--mismatch (ert--coerce-to-vector a)
180 (ert--coerce-to-vector b)))
181 ((> (length a) (length b))
182 (ert--mismatch b a))
183 (t
184 (let ((la (length a))
185 (lb (length b)))
186 (cl-assert (arrayp a) t)
187 (cl-assert (arrayp b) t)
188 (cl-assert (<= la lb) t)
189 (cl-loop for i below la
190 when (not (equal (aref a i) (aref b i))) return i
191 finally (cl-return (if (/= la lb)
192 la
193 (cl-assert (equal a b) t)
194 nil)))))))
195
196(defun ert--subseq (seq start &optional end)
197 "Return a subsequence of SEQ from START to END."
198 (when (char-table-p seq) (error "Not supported"))
199 (let ((vector (substring (ert--coerce-to-vector seq) start end)))
200 (cl-etypecase seq
201 (vector vector)
202 (string (concat vector))
203 (list (append vector nil))
204 (bool-vector (cl-loop with result
205 = (make-bool-vector (length vector) nil)
206 for i below (length vector) do
207 (setf (aref result i) (aref vector i))
208 finally (cl-return result)))
209 (char-table (cl-assert nil)))))
210
211(defun ert-equal-including-properties (a b) 90(defun ert-equal-including-properties (a b)
212 "Return t if A and B have similar structure and contents. 91 "Return t if A and B have similar structure and contents.
213 92
@@ -258,7 +137,7 @@ Emacs bug 6581 at URL `http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6581'."
258 137
259(defun ert-make-test-unbound (symbol) 138(defun ert-make-test-unbound (symbol)
260 "Make SYMBOL name no test. Return SYMBOL." 139 "Make SYMBOL name no test. Return SYMBOL."
261 (ert--remprop symbol 'ert--test) 140 (cl-remprop symbol 'ert--test)
262 symbol) 141 symbol)
263 142
264(defun ert--parse-keys-and-body (keys-and-body) 143(defun ert--parse-keys-and-body (keys-and-body)
@@ -396,8 +275,8 @@ DATA is displayed to the user and should state the reason of the failure."
396 cl-macro-environment))))) 275 cl-macro-environment)))))
397 (cond 276 (cond
398 ((or (atom form) (ert--special-operator-p (car form))) 277 ((or (atom form) (ert--special-operator-p (car form)))
399 (let ((value (ert--gensym "value-"))) 278 (let ((value (cl-gensym "value-")))
400 `(let ((,value (ert--gensym "ert-form-evaluation-aborted-"))) 279 `(let ((,value (cl-gensym "ert-form-evaluation-aborted-")))
401 ,(funcall inner-expander 280 ,(funcall inner-expander
402 `(setq ,value ,form) 281 `(setq ,value ,form)
403 `(list ',whole :form ',form :value ,value) 282 `(list ',whole :form ',form :value ,value)
@@ -410,10 +289,10 @@ DATA is displayed to the user and should state the reason of the failure."
410 (and (consp fn-name) 289 (and (consp fn-name)
411 (eql (car fn-name) 'lambda) 290 (eql (car fn-name) 'lambda)
412 (listp (cdr fn-name))))) 291 (listp (cdr fn-name)))))
413 (let ((fn (ert--gensym "fn-")) 292 (let ((fn (cl-gensym "fn-"))
414 (args (ert--gensym "args-")) 293 (args (cl-gensym "args-"))
415 (value (ert--gensym "value-")) 294 (value (cl-gensym "value-"))
416 (default-value (ert--gensym "ert-form-evaluation-aborted-"))) 295 (default-value (cl-gensym "ert-form-evaluation-aborted-")))
417 `(let ((,fn (function ,fn-name)) 296 `(let ((,fn (function ,fn-name))
418 (,args (list ,@arg-forms))) 297 (,args (list ,@arg-forms)))
419 (let ((,value ',default-value)) 298 (let ((,value ',default-value))
@@ -450,7 +329,7 @@ FORM-DESCRIPTION-FORM before it has called INNER-FORM."
450 (ert--expand-should-1 329 (ert--expand-should-1
451 whole form 330 whole form
452 (lambda (inner-form form-description-form value-var) 331 (lambda (inner-form form-description-form value-var)
453 (let ((form-description (ert--gensym "form-description-"))) 332 (let ((form-description (cl-gensym "form-description-")))
454 `(let (,form-description) 333 `(let (,form-description)
455 ,(funcall inner-expander 334 ,(funcall inner-expander
456 `(unwind-protect 335 `(unwind-protect
@@ -491,7 +370,7 @@ and aborts the current test as failed if it doesn't."
491 (list type) 370 (list type)
492 (symbol (list type))))) 371 (symbol (list type)))))
493 (cl-assert signaled-conditions) 372 (cl-assert signaled-conditions)
494 (unless (ert--intersection signaled-conditions handled-conditions) 373 (unless (cl-intersection signaled-conditions handled-conditions)
495 (ert-fail (append 374 (ert-fail (append
496 (funcall form-description-fn) 375 (funcall form-description-fn)
497 (list 376 (list
@@ -528,8 +407,8 @@ failed."
528 `(should-error ,form ,@keys) 407 `(should-error ,form ,@keys)
529 form 408 form
530 (lambda (inner-form form-description-form value-var) 409 (lambda (inner-form form-description-form value-var)
531 (let ((errorp (ert--gensym "errorp")) 410 (let ((errorp (cl-gensym "errorp"))
532 (form-description-fn (ert--gensym "form-description-fn-"))) 411 (form-description-fn (cl-gensym "form-description-fn-")))
533 `(let ((,errorp nil) 412 `(let ((,errorp nil)
534 (,form-description-fn (lambda () ,form-description-form))) 413 (,form-description-fn (lambda () ,form-description-form)))
535 (condition-case -condition- 414 (condition-case -condition-
@@ -591,7 +470,7 @@ Returns nil if they are."
591 `(proper-lists-of-different-length ,(length a) ,(length b) 470 `(proper-lists-of-different-length ,(length a) ,(length b)
592 ,a ,b 471 ,a ,b
593 first-mismatch-at 472 first-mismatch-at
594 ,(ert--mismatch a b)) 473 ,(cl-mismatch a b :test 'equal))
595 (cl-loop for i from 0 474 (cl-loop for i from 0
596 for ai in a 475 for ai in a
597 for bi in b 476 for bi in b
@@ -611,7 +490,7 @@ Returns nil if they are."
611 ,a ,b 490 ,a ,b
612 ,@(unless (char-table-p a) 491 ,@(unless (char-table-p a)
613 `(first-mismatch-at 492 `(first-mismatch-at
614 ,(ert--mismatch a b)))) 493 ,(cl-mismatch a b :test 'equal))))
615 (cl-loop for i from 0 494 (cl-loop for i from 0
616 for ai across a 495 for ai across a
617 for bi across b 496 for bi across b
@@ -656,8 +535,8 @@ key/value pairs in each list does not matter."
656 ;; work, so let's punt on it for now. 535 ;; work, so let's punt on it for now.
657 (let* ((keys-a (ert--significant-plist-keys a)) 536 (let* ((keys-a (ert--significant-plist-keys a))
658 (keys-b (ert--significant-plist-keys b)) 537 (keys-b (ert--significant-plist-keys b))
659 (keys-in-a-not-in-b (ert--set-difference-eq keys-a keys-b)) 538 (keys-in-a-not-in-b (cl-set-difference keys-a keys-b :test 'eq))
660 (keys-in-b-not-in-a (ert--set-difference-eq keys-b keys-a))) 539 (keys-in-b-not-in-a (cl-set-difference keys-b keys-a :test 'eq)))
661 (cl-flet ((explain-with-key (key) 540 (cl-flet ((explain-with-key (key)
662 (let ((value-a (plist-get a key)) 541 (let ((value-a (plist-get a key))
663 (value-b (plist-get b key))) 542 (value-b (plist-get b key)))
@@ -1090,7 +969,7 @@ contained in UNIVERSE."
1090 (cl-etypecase universe 969 (cl-etypecase universe
1091 ((member t) (mapcar #'ert-get-test 970 ((member t) (mapcar #'ert-get-test
1092 (apropos-internal selector #'ert-test-boundp))) 971 (apropos-internal selector #'ert-test-boundp)))
1093 (list (ert--remove-if-not (lambda (test) 972 (list (cl-remove-if-not (lambda (test)
1094 (and (ert-test-name test) 973 (and (ert-test-name test)
1095 (string-match selector 974 (string-match selector
1096 (ert-test-name test)))) 975 (ert-test-name test))))
@@ -1123,13 +1002,13 @@ contained in UNIVERSE."
1123 (not 1002 (not
1124 (cl-assert (eql (length operands) 1)) 1003 (cl-assert (eql (length operands) 1))
1125 (let ((all-tests (ert-select-tests 't universe))) 1004 (let ((all-tests (ert-select-tests 't universe)))
1126 (ert--set-difference all-tests 1005 (cl-set-difference all-tests
1127 (ert-select-tests (car operands) 1006 (ert-select-tests (car operands)
1128 all-tests)))) 1007 all-tests))))
1129 (or 1008 (or
1130 (cl-case (length operands) 1009 (cl-case (length operands)
1131 (0 (ert-select-tests 'nil universe)) 1010 (0 (ert-select-tests 'nil universe))
1132 (t (ert--union (ert-select-tests (car operands) universe) 1011 (t (cl-union (ert-select-tests (car operands) universe)
1133 (ert-select-tests `(or ,@(cdr operands)) 1012 (ert-select-tests `(or ,@(cdr operands))
1134 universe))))) 1013 universe)))))
1135 (tag 1014 (tag
@@ -1141,7 +1020,7 @@ contained in UNIVERSE."
1141 universe))) 1020 universe)))
1142 (satisfies 1021 (satisfies
1143 (cl-assert (eql (length operands) 1)) 1022 (cl-assert (eql (length operands) 1))
1144 (ert--remove-if-not (car operands) 1023 (cl-remove-if-not (car operands)
1145 (ert-select-tests 't universe)))))))) 1024 (ert-select-tests 't universe))))))))
1146 1025
1147(defun ert--insert-human-readable-selector (selector) 1026(defun ert--insert-human-readable-selector (selector)
@@ -1285,7 +1164,7 @@ Also changes the counters in STATS to match."
1285 "Create a new `ert--stats' object for running TESTS. 1164 "Create a new `ert--stats' object for running TESTS.
1286 1165
1287SELECTOR is the selector that was used to select TESTS." 1166SELECTOR is the selector that was used to select TESTS."
1288 (setq tests (ert--coerce-to-vector tests)) 1167 (setq tests (cl-coerce tests 'vector))
1289 (let ((map (make-hash-table :size (length tests)))) 1168 (let ((map (make-hash-table :size (length tests))))
1290 (cl-loop for i from 0 1169 (cl-loop for i from 0
1291 for test across tests 1170 for test across tests
@@ -1548,10 +1427,10 @@ This can be used as an inverse of `add-to-list'."
1548 (unless key (setq key #'identity)) 1427 (unless key (setq key #'identity))
1549 (unless test (setq test #'equal)) 1428 (unless test (setq test #'equal))
1550 (setf (symbol-value list-var) 1429 (setf (symbol-value list-var)
1551 (ert--remove* element 1430 (cl-remove element
1552 (symbol-value list-var) 1431 (symbol-value list-var)
1553 :key key 1432 :key key
1554 :test test))) 1433 :test test)))
1555 1434
1556 1435
1557;;; Some basic interactive functions. 1436;;; Some basic interactive functions.
@@ -1810,7 +1689,7 @@ BEGIN and END specify a region in the current buffer."
1810 "Return the first line of S, or S if it contains no newlines. 1689 "Return the first line of S, or S if it contains no newlines.
1811 1690
1812The return value does not include the line terminator." 1691The return value does not include the line terminator."
1813 (substring s 0 (ert--string-position ?\n s))) 1692 (substring s 0 (cl-position ?\n s)))
1814 1693
1815(defun ert-face-for-test-result (expectedp) 1694(defun ert-face-for-test-result (expectedp)
1816 "Return a face that shows whether a test result was expected or unexpected. 1695 "Return a face that shows whether a test result was expected or unexpected.
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 1919d47687b..56bfe04f9ce 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -131,8 +131,9 @@ Returns the number of actions taken."
131 (unwind-protect 131 (unwind-protect
132 (progn 132 (progn
133 (if (stringp prompter) 133 (if (stringp prompter)
134 (setq prompter (lambda (object) 134 (setq prompter (let ((prompter prompter))
135 (format prompter object)))) 135 (lambda (object)
136 (format prompter object)))))
136 (while (funcall next) 137 (while (funcall next)
137 (setq prompt (funcall prompter elt)) 138 (setq prompt (funcall prompter elt))
138 (cond ((stringp prompt) 139 (cond ((stringp prompt)
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index e000c343721..511f1480099 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -482,12 +482,19 @@ MATCH is the pattern that needs to be matched, of the form:
482 all)) 482 all))
483 '(:pcase--succeed . nil)))) 483 '(:pcase--succeed . nil))))
484 484
485(defun pcase--split-pred (upat pat) 485(defun pcase--split-pred (vars upat pat)
486 ;; FIXME: For predicates like (pred (> a)), two such predicates may
487 ;; actually refer to different variables `a'.
488 (let (test) 486 (let (test)
489 (cond 487 (cond
490 ((equal upat pat) '(:pcase--succeed . :pcase--fail)) 488 ((and (equal upat pat)
489 ;; For predicates like (pred (> a)), two such predicates may
490 ;; actually refer to different variables `a'.
491 (or (and (eq 'pred (car upat)) (symbolp (cadr upat)))
492 ;; FIXME: `vars' gives us the environment in which `upat' will
493 ;; run, but we don't have the environment in which `pat' will
494 ;; run, so we can't do a reliable verification. But let's try
495 ;; and catch at least the easy cases such as (bug#14773).
496 (not (pcase--fgrep (mapcar #'car vars) (cadr upat)))))
497 '(:pcase--succeed . :pcase--fail))
491 ((and (eq 'pred (car upat)) 498 ((and (eq 'pred (car upat))
492 (eq 'pred (car-safe pat)) 499 (eq 'pred (car-safe pat))
493 (or (member (cons (cadr upat) (cadr pat)) 500 (or (member (cons (cadr upat) (cadr pat))
@@ -589,7 +596,7 @@ Otherwise, it defers to REST which is a list of branches of the form
589 (if (eq (car upat) 'pred) (pcase--mark-used sym)) 596 (if (eq (car upat) 'pred) (pcase--mark-used sym))
590 (let* ((splitrest 597 (let* ((splitrest
591 (pcase--split-rest 598 (pcase--split-rest
592 sym (lambda (pat) (pcase--split-pred upat pat)) rest)) 599 sym (lambda (pat) (pcase--split-pred vars upat pat)) rest))
593 (then-rest (car splitrest)) 600 (then-rest (car splitrest))
594 (else-rest (cdr splitrest))) 601 (else-rest (cdr splitrest)))
595 (pcase--if (if (and (eq (car upat) 'pred) (symbolp (cadr upat))) 602 (pcase--if (if (and (eq (car upat) 'pred) (symbolp (cadr upat)))
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index e7b371365e4..c39d896f3d3 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -996,93 +996,7 @@ as a Meta key and any number of multiple escapes are allowed."
996 (suspend-emacs)) 996 (suspend-emacs))
997 (viper-change-state-to-emacs))) 997 (viper-change-state-to-emacs)))
998 998
999
1000;; Intercept ESC sequences on dumb terminals.
1001;; Based on the idea contributed by Marcelino Veiga Tuimil <mveiga@dit.upm.es>
1002
1003;; Check if last key was ESC and if so try to reread it as a function key.
1004;; But only if there are characters to read during a very short time.
1005;; Returns the last event, if any.
1006(defun viper-envelop-ESC-key ()
1007 (let ((event last-input-event)
1008 (keyseq [nil])
1009 (inhibit-quit t))
1010 (if (viper-ESC-event-p event)
1011 (progn
1012 ;; Some versions of Emacs (eg., 22.50.8 (?)) have a bug, which makes
1013 ;; even a single ESC into a fast keyseq. To guard against this, we
1014 ;; added a check if there are other events as well. Keep the next
1015 ;; line for the next time the bug reappears, so that will remember to
1016 ;; report it.
1017 ;;(if (and (viper-fast-keysequence-p) unread-command-events)
1018 (if (viper-fast-keysequence-p) ;; for Emacsen without the above bug
1019 (progn
1020 (let (minor-mode-map-alist emulation-mode-map-alists)
1021 (viper-set-unread-command-events event)
1022 (setq keyseq (read-key-sequence nil 'continue-echo))
1023 ) ; let
1024 ;; If keyseq translates into something that still has ESC
1025 ;; at the beginning, separate ESC from the rest of the seq.
1026 ;; In XEmacs we check for events that are keypress meta-key
1027 ;; and convert them into [escape key]
1028 ;;
1029 ;; This is needed for the following reason:
1030 ;; If ESC is the first symbol, we interpret it as if the
1031 ;; user typed ESC and then quickly some other symbols.
1032 ;; If ESC is not the first one, then the key sequence
1033 ;; entered was apparently translated into a function key or
1034 ;; something (e.g., one may have
1035 ;; (define-key function-key-map "\e[192z" [f11])
1036 ;; which would translate the escape-sequence generated by
1037 ;; f11 in an xterm window into the symbolic key f11.
1038 ;;
1039 ;; If `first-key' is not an ESC event, we make it into the
1040 ;; last-command-event in order to pretend that this key was
1041 ;; pressed. This is needed to allow arrow keys to be bound to
1042 ;; macros. Otherwise, viper-exec-mapped-kbd-macro will think
1043 ;; that the last event was ESC and so it'll execute whatever is
1044 ;; bound to ESC. (Viper macros can't be bound to
1045 ;; ESC-sequences).
1046 (let* ((first-key (elt keyseq 0))
1047 (key-mod (event-modifiers first-key)))
1048 (cond ((and (viper-ESC-event-p first-key)
1049 (not (viper-translate-all-ESC-keysequences)))
1050 ;; put keys following ESC on the unread list
1051 ;; and return ESC as the key-sequence
1052 (viper-set-unread-command-events (viper-subseq keyseq 1))
1053 (setq last-input-event event
1054 keyseq (if (featurep 'emacs)
1055 "\e"
1056 (vector (character-to-event ?\e)))))
1057 ((and (featurep 'xemacs)
1058 (key-press-event-p first-key)
1059 (equal '(meta) key-mod))
1060 (viper-set-unread-command-events
1061 (vconcat (vector
1062 (character-to-event (event-key first-key)))
1063 (viper-subseq keyseq 1)))
1064 (setq last-input-event event
1065 keyseq (vector (character-to-event ?\e))))
1066 ((eventp first-key)
1067 (setq last-command-event
1068 (viper-copy-event first-key)))
1069 ))
1070 ) ; end progn
1071
1072 ;; this is escape event with nothing after it
1073 ;; put in unread-command-event and then re-read
1074 (viper-set-unread-command-events event)
1075 (setq keyseq (read-key-sequence nil))
1076 ))
1077 ;; not an escape event
1078 (setq keyseq (vector event)))
1079 keyseq))
1080
1081
1082
1083;; Listen to ESC key. 999;; Listen to ESC key.
1084;; If a sequence of keys starting with ESC is issued with very short delays,
1085;; interpret these keys in Emacs mode, so ESC won't be interpreted as a Vi key.
1086(defun viper-intercept-ESC-key () 1000(defun viper-intercept-ESC-key ()
1087 "Function that implements ESC key in Viper emulation of Vi." 1001 "Function that implements ESC key in Viper emulation of Vi."
1088 (interactive) 1002 (interactive)
@@ -1090,13 +1004,7 @@ as a Meta key and any number of multiple escapes are allowed."
1090 ;; minor-mode map(s) have been temporarily disabled so the ESC 1004 ;; minor-mode map(s) have been temporarily disabled so the ESC
1091 ;; binding to viper-intercept-ESC-key doesn't hide the binding we're 1005 ;; binding to viper-intercept-ESC-key doesn't hide the binding we're
1092 ;; looking for (Bug#9146): 1006 ;; looking for (Bug#9146):
1093 (let* ((event (viper-envelop-ESC-key)) 1007 (let* ((cmd 'viper-intercept-ESC-key))
1094 (cmd (cond ((equal event viper-ESC-key)
1095 'viper-intercept-ESC-key)
1096 ((let ((emulation-mode-map-alists nil))
1097 (key-binding event)))
1098 (t
1099 (error "Viper bell")))))
1100 1008
1101 ;; call the actual function to execute ESC (if no other symbols followed) 1009 ;; call the actual function to execute ESC (if no other symbols followed)
1102 ;; or the key bound to the ESC sequence (if the sequence was issued 1010 ;; or the key bound to the ESC sequence (if the sequence was issued
@@ -4289,6 +4197,11 @@ cursor move past the beginning of line."
4289 (t 4197 (t
4290 (backward-char 1)))) 4198 (backward-char 1))))
4291 4199
4200(defun viper-del-forward-char-in-insert ()
4201 "Delete 1 char forward if in insert or replace state."
4202 (interactive)
4203 ;; don't put on kill ring
4204 (delete-char 1 nil))
4292 4205
4293 4206
4294;; join lines. 4207;; join lines.
@@ -4947,7 +4860,7 @@ Please, specify your level now: ")
4947 (interactive) 4860 (interactive)
4948 (if (< viper-expert-level 2) 4861 (if (< viper-expert-level 2)
4949 (save-buffers-kill-emacs) 4862 (save-buffers-kill-emacs)
4950 (save-buffer) 4863 (if (buffer-modified-p) (save-buffer))
4951 (kill-buffer (current-buffer)))) 4864 (kill-buffer (current-buffer))))
4952 4865
4953 4866
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 0d9d300ab1a..d33b5f4ed58 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -192,7 +192,7 @@ Enter as a sexp. Examples: \"\\C-z\", [(control ?z)]."
192 :type 'string 192 :type 'string
193 :group 'viper) 193 :group 'viper)
194 194
195(defvar viper-ESC-key (kbd "ESC") 195(defconst viper-ESC-key [escape]
196 "Key used to ESC.") 196 "Key used to ESC.")
197 197
198 198
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 7f432cdc143..266af1abf2b 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -14,7 +14,7 @@
14;; filed in the Emacs bug reporting system against this file, a copy 14;; filed in the Emacs bug reporting system against this file, a copy
15;; of the bug report be sent to the maintainer's email address. 15;; of the bug report be sent to the maintainer's email address.
16 16
17(defconst viper-version "3.14.1 of August 15, 2009" 17(defconst viper-version "3.14.2 of July 4, 2013"
18 "The current version of Viper") 18 "The current version of Viper")
19 19
20;; This file is part of GNU Emacs. 20;; This file is part of GNU Emacs.
@@ -411,6 +411,7 @@ widget."
411 dired-mode 411 dired-mode
412 efs-mode 412 efs-mode
413 tar-mode 413 tar-mode
414 egg-status-buffer-mode
414 415
415 browse-kill-ring-mode 416 browse-kill-ring-mode
416 recentf-mode 417 recentf-mode
@@ -660,7 +661,7 @@ user customization, unrelated to Viper. For instance, if the user advised
660undone. 661undone.
661It also can't undo some Viper settings." 662It also can't undo some Viper settings."
662 (interactive) 663 (interactive)
663 664 (viper-setup-ESC-to-escape nil)
664 ;; restore non-viper vars 665 ;; restore non-viper vars
665 (setq-default 666 (setq-default
666 next-line-add-newlines 667 next-line-add-newlines
@@ -825,6 +826,58 @@ It also can't undo some Viper settings."
825 (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t)) 826 (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t))
826 827
827 828
829;;; Handling of tty's ESC event
830
831;; On a tty, an ESC event can either be the user hitting the escape key, or
832;; some element of a byte sequence used to encode for example cursor keys.
833;; So we try to recognize those events that correspond to the escape key and
834;; turn them into `escape' events (same as used under GUIs). The heuristic we
835;; use to distinguish the two cases is based, as usual, on a timeout, and on
836;; the fact that the special ESC=>escape mapping only takes place if the whole
837;; last key-sequence so far is just [?\e], i.e. either we're still in
838;; read-key-sequence, or the last read-key-sequence only read [?\e], which
839;; should ideally never happen because it should have been mapped to [escape].
840
841(defun viper--tty-ESC-filter (map)
842 (if (and (equal (this-single-command-keys) [?\e])
843 (sit-for (/ viper-fast-keyseq-timeout 1000)))
844 [escape] map))
845
846(defun viper--lookup-key (map key)
847 "Kind of like `lookup-key'.
848Two differences:
849- KEY is a single key, not a sequence.
850- the result is the \"raw\" binding, so it can be a `menu-item', rather than the
851 binding contained in that menu item."
852 (catch 'found
853 (map-keymap (lambda (k b) (if (equal key k) (throw 'found b))) map)))
854
855(defun viper-catch-tty-ESC ()
856 "Setup key mappings of current terminal to turn a tty's ESC into `escape'."
857 (when (memq (terminal-live-p (frame-terminal)) '(t pc))
858 (let ((esc-binding (viper-uncatch-tty-ESC)))
859 (define-key input-decode-map
860 [?\e] `(menu-item "" ,esc-binding :filter viper--tty-ESC-filter)))))
861
862(defun viper-uncatch-tty-ESC ()
863 "Don't hack ESC into `escape' any more."
864 (let ((b (viper--lookup-key input-decode-map ?\e)))
865 (and (eq 'menu-item (car-safe b))
866 (eq 'viper--tty-ESC-filter (nth 4 b))
867 (define-key input-decode-map [?\e] (setq b (nth 2 b))))
868 b))
869
870(defun viper-setup-ESC-to-escape (enable)
871 (if enable
872 (add-hook 'tty-setup-hook 'viper-catch-tty-ESC)
873 (remove-hook 'tty-setup-hook 'viper-catch-tty-ESC))
874 (let ((seen ()))
875 (dolist (frame (frame-list))
876 (let ((terminal (frame-terminal frame)))
877 (unless (memq terminal seen)
878 (push terminal seen)
879 (with-selected-frame frame
880 (if enable (viper-catch-tty-ESC) (viper-uncatch-tty-ESC))))))))
828 881
829;; This sets major mode hooks to make them come up in vi-state. 882;; This sets major mode hooks to make them come up in vi-state.
830(defun viper-set-hooks () 883(defun viper-set-hooks ()
@@ -837,6 +890,8 @@ It also can't undo some Viper settings."
837 (if (eq (default-value 'major-mode) 'fundamental-mode) 890 (if (eq (default-value 'major-mode) 'fundamental-mode)
838 (setq-default major-mode 'viper-mode)) 891 (setq-default major-mode 'viper-mode))
839 892
893 (viper-setup-ESC-to-escape t)
894
840 (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel) 895 (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)
841 (add-hook 'find-file-hooks 'set-viper-state-in-major-mode) 896 (add-hook 'find-file-hooks 'set-viper-state-in-major-mode)
842 897
@@ -847,13 +902,6 @@ It also can't undo some Viper settings."
847 (defvar emerge-startup-hook) 902 (defvar emerge-startup-hook)
848 (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs) 903 (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs)
849 904
850 ;; Zap bad bindings in flyspell-mouse-map, which prevent ESC from working
851 ;; over misspelled words (due to the overlay keymaps)
852 (defvar flyspell-mode-hook)
853 (defvar flyspell-mouse-map)
854 (add-hook 'flyspell-mode-hook
855 (lambda ()
856 (define-key flyspell-mouse-map viper-ESC-key nil)))
857 ;; if viper is started from .emacs, it might be impossible to get certain 905 ;; if viper is started from .emacs, it might be impossible to get certain
858 ;; info about the display and windows until emacs initialization is complete 906 ;; info about the display and windows until emacs initialization is complete
859 ;; So do it via the window-setup-hook 907 ;; So do it via the window-setup-hook
diff --git a/lisp/faces.el b/lisp/faces.el
index 0a3f0551325..9a34aec2549 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2097,6 +2097,10 @@ the above example."
2097 nil)))) 2097 nil))))
2098 type) 2098 type)
2099 2099
2100(defvar tty-setup-hook nil
2101 "Hook run after running the initialization function of a new text terminal.
2102This can be used to fine tune the `input-decode-map', for example.")
2103
2100(defun tty-run-terminal-initialization (frame &optional type) 2104(defun tty-run-terminal-initialization (frame &optional type)
2101 "Run the special initialization code for the terminal type of FRAME. 2105 "Run the special initialization code for the terminal type of FRAME.
2102The optional TYPE parameter may be used to override the autodetected 2106The optional TYPE parameter may be used to override the autodetected
@@ -2122,7 +2126,8 @@ terminal type to a different value."
2122 type) 2126 type)
2123 (when (fboundp term-init-func) 2127 (when (fboundp term-init-func)
2124 (funcall term-init-func)) 2128 (funcall term-init-func))
2125 (set-terminal-parameter frame 'terminal-initted term-init-func))))) 2129 (set-terminal-parameter frame 'terminal-initted term-init-func)
2130 (run-hooks 'tty-setup-hook)))))
2126 2131
2127;; Called from C function init_display to initialize faces of the 2132;; Called from C function init_display to initialize faces of the
2128;; dumped terminal frame on startup. 2133;; dumped terminal frame on startup.
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
new file mode 100644
index 00000000000..e170db2dd5f
--- /dev/null
+++ b/lisp/filenotify.el
@@ -0,0 +1,324 @@
1;;; filenotify.el --- watch files for changes on disk
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx.de>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary
23
24;; This package is an abstraction layer from the different low-level
25;; file notification packages `gfilenotify', `inotify' and
26;; `w32notify'.
27
28;;; Code:
29
30;;;###autoload
31(defconst file-notify-support
32 (cond
33 ((featurep 'gfilenotify) 'gfilenotify)
34 ((featurep 'inotify) 'inotify)
35 ((featurep 'w32notify) 'w32notify))
36 "Non-nil when Emacs has been compiled with file notification support.
37The value is the name of the low-level file notification package
38to be used for local file systems. Remote file notifications
39could use another implementation.")
40
41(defvar file-notify-descriptors (make-hash-table :test 'equal)
42 "Hash table for registered file notification descriptors.
43A key in this hash table is the descriptor as returned from
44`gfilenotify', `inotify', `w32notify' or a file name handler.
45The value in the hash table is the cons cell (DIR FILE CALLBACK).")
46
47;; This function is used by `gfilenotify', `inotify' and `w32notify' events.
48;;;###autoload
49(defun file-notify-handle-event (event)
50 "Handle file system monitoring event.
51If EVENT is a filewatch event, call its callback.
52Otherwise, signal a `file-notify-error'."
53 (interactive "e")
54 (if (and (eq (car event) 'file-notify)
55 (>= (length event) 3))
56 (funcall (nth 2 event) (nth 1 event))
57 (signal 'file-notify-error
58 (cons "Not a valid file-notify event" event))))
59
60(defvar file-notify--pending-events nil
61 "List of pending file notification events for a future `renamed' action.
62The entries are a list (DESCRIPTOR ACTION FILE COOKIE). ACTION
63is either `moved-from' or `renamed-from'.")
64
65(defun file-notify--event-file-name (event)
66 "Return file name of file notification event, or nil."
67 (expand-file-name
68 (or (and (stringp (nth 2 event)) (nth 2 event)) "")
69 (car (gethash (car event) file-notify-descriptors))))
70
71;; Only `gfilenotify' could return two file names.
72(defun file-notify--event-file1-name (event)
73 "Return second file name of file notification event, or nil.
74This is available in case a file has been moved."
75 (and (stringp (nth 3 event))
76 (expand-file-name
77 (nth 3 event) (car (gethash (car event) file-notify-descriptors)))))
78
79;; Cookies are offered by `inotify' only.
80(defun file-notify--event-cookie (event)
81 "Return cookie of file notification event, or nil.
82This is available in case a file has been moved."
83 (nth 3 event))
84
85;; The callback function used to map between specific flags of the
86;; respective file notifications, and the ones we return.
87(defun file-notify-callback (event)
88 "Handle an EVENT returned from file notification.
89EVENT is the same one as in `file-notify-handle-event' except the
90car of that event, which is the symbol `file-notify'."
91 (let* ((desc (car event))
92 (registered (gethash desc file-notify-descriptors))
93 (pending-event (assoc desc file-notify--pending-events))
94 (actions (nth 1 event))
95 (file (file-notify--event-file-name event))
96 file1 cookie callback)
97
98 ;; Make actions a list.
99 (unless (consp actions) (setq actions (cons actions nil)))
100
101 ;; Check, that event is meant for us.
102 (unless (setq callback (nth 2 registered))
103 (setq actions nil))
104
105 ;; Loop over actions. In fact, more than one action happens only
106 ;; for `inotify'.
107 (dolist (action actions)
108
109 ;; Send pending event, if it doesn't match.
110 (when (and pending-event
111 ;; The cookie doesn't match.
112 (not (eq (file-notify--event-cookie pending-event)
113 (file-notify--event-cookie event)))
114 (or
115 ;; inotify.
116 (and (eq (nth 1 pending-event) 'moved-from)
117 (not (eq action 'moved-to)))
118 ;; w32notify.
119 (and (eq (nth 1 pending-event) 'renamed-from)
120 (not (eq action 'renamed-to)))))
121 (funcall callback
122 (list desc 'deleted
123 (file-notify--event-file-name pending-event)))
124 (setq file-notify--pending-events
125 (delete pending-event file-notify--pending-events)))
126
127 ;; Map action. We ignore all events which cannot be mapped.
128 (setq action
129 (cond
130 ;; gfilenotify.
131 ((memq action '(attribute-changed changed created deleted)) action)
132 ((eq action 'moved)
133 (setq file1 (file-notify--event-file1-name event))
134 'renamed)
135
136 ;; inotify.
137 ((eq action 'attrib) 'attribute-changed)
138 ((eq action 'create) 'created)
139 ((eq action 'modify) 'changed)
140 ((memq action '(delete 'delete-self move-self)) 'deleted)
141 ;; Make the event pending.
142 ((eq action 'moved-from)
143 (add-to-list 'file-notify--pending-events
144 (list desc action file
145 (file-notify--event-cookie event)))
146 nil)
147 ;; Look for pending event.
148 ((eq action 'moved-to)
149 (if (null pending-event)
150 'created
151 (setq file1 file
152 file (file-notify--event-file-name pending-event)
153 file-notify--pending-events
154 (delete pending-event file-notify--pending-events))
155 'renamed))
156
157 ;; w32notify.
158 ((eq action 'added) 'created)
159 ((eq action 'modified) 'changed)
160 ((eq action 'removed) 'deleted)
161 ;; Make the event pending.
162 ((eq 'renamed-from action)
163 (add-to-list 'file-notify--pending-events
164 (list desc action file
165 (file-notify--event-cookie event)))
166 nil)
167 ;; Look for pending event.
168 ((eq 'renamed-to action)
169 (if (null pending-event)
170 'created
171 (setq file1 file
172 file (file-notify--event-file-name pending-event)
173 file-notify--pending-events
174 (delete pending-event file-notify--pending-events))
175 'renamed))))
176
177 ;; Apply callback.
178 (when (and action
179 (or
180 ;; If there is no relative file name for that watch,
181 ;; we watch the whole directory.
182 (null (nth 1 registered))
183 ;; File matches.
184 (string-equal
185 (nth 1 registered) (file-name-nondirectory file))
186 ;; File1 matches.
187 (and (stringp file1)
188 (string-equal
189 (nth 1 registered) (file-name-nondirectory file1)))))
190 (if file1
191 (funcall callback (list desc action file file1))
192 (funcall callback (list desc action file)))))))
193
194(defun file-notify-add-watch (file flags callback)
195 "Add a watch for filesystem events pertaining to FILE.
196This arranges for filesystem events pertaining to FILE to be reported
197to Emacs. Use `file-notify-rm-watch' to cancel the watch.
198
199The returned value is a descriptor for the added watch. If the
200file cannot be watched for some reason, this function signals a
201`file-notify-error' error.
202
203FLAGS is a list of conditions to set what will be watched for. It can
204include the following symbols:
205
206 `change' -- watch for file changes
207 `attribute-change' -- watch for file attributes changes, like
208 permissions or modification time
209
210If FILE is a directory, 'change' watches for file creation or
211deletion in that directory.
212
213When any event happens, Emacs will call the CALLBACK function passing
214it a single argument EVENT, which is of the form
215
216 (DESCRIPTOR ACTION FILE [FILE1])
217
218DESCRIPTOR is the same object as the one returned by this function.
219ACTION is the description of the event. It could be any one of the
220following:
221
222 `created' -- FILE was created
223 `deleted' -- FILE was deleted
224 `changed' -- FILE has changed
225 `renamed' -- FILE has been renamed to FILE1
226 `attribute-changed' -- a FILE attribute was changed
227
228FILE is the name of the file whose event is being reported."
229 ;; Check arguments.
230 (unless (stringp file)
231 (signal 'wrong-type-argument (list file)))
232 (setq file (expand-file-name file))
233 (unless (and (consp flags)
234 (null (delq 'change (delq 'attribute-change (copy-tree flags)))))
235 (signal 'wrong-type-argument (list flags)))
236 (unless (functionp callback)
237 (signal 'wrong-type-argument (list callback)))
238
239 (let* ((handler (find-file-name-handler file 'file-notify-add-watch))
240 (dir (directory-file-name
241 (if (or (and (not handler) (eq file-notify-support 'w32notify))
242 (file-directory-p file))
243 file
244 (file-name-directory file))))
245 desc func l-flags)
246
247 ;; Check, whether this has been registered already.
248; (maphash
249; (lambda (key value)
250; (when (equal (cons file callback) value) (setq desc key)))
251; file-notify-descriptors)
252
253 (unless desc
254 (if handler
255 ;; A file name handler could exist even if there is no local
256 ;; file notification support.
257 (setq desc (funcall
258 handler 'file-notify-add-watch dir flags callback))
259
260 ;; Check, whether Emacs has been compiled with file
261 ;; notification support.
262 (unless file-notify-support
263 (signal 'file-notify-error
264 '("No file notification package available")))
265
266 ;; Determine low-level function to be called.
267 (setq func (cond
268 ((eq file-notify-support 'gfilenotify) 'gfile-add-watch)
269 ((eq file-notify-support 'inotify) 'inotify-add-watch)
270 ((eq file-notify-support 'w32notify) 'w32notify-add-watch)))
271
272 ;; Determine respective flags.
273 (if (eq file-notify-support 'gfilenotify)
274 (setq l-flags '(watch-mounts send-moved))
275 (when (memq 'change flags)
276 (setq
277 l-flags
278 (cond
279 ((eq file-notify-support 'inotify) '(create modify move delete))
280 ((eq file-notify-support 'w32notify)
281 '(file-name directory-name size last-write-time)))))
282 (when (memq 'attribute-change flags)
283 (add-to-list
284 'l-flags
285 (cond
286 ((eq file-notify-support 'inotify) 'attrib)
287 ((eq file-notify-support 'w32notify) 'attributes)))))
288
289 ;; Call low-level function.
290 (setq desc (funcall func dir l-flags 'file-notify-callback))))
291
292 ;; Return descriptor.
293 (puthash desc
294 (list (directory-file-name
295 (if (file-directory-p dir) dir (file-name-directory dir)))
296 (unless (file-directory-p file)
297 (file-name-nondirectory file))
298 callback)
299 file-notify-descriptors)
300 desc))
301
302(defun file-notify-rm-watch (descriptor)
303 "Remove an existing watch specified by its DESCRIPTOR.
304DESCRIPTOR should be an object returned by `file-notify-add-watch'."
305 (let ((file (car (gethash descriptor file-notify-descriptors)))
306 handler)
307
308 (when (stringp file)
309 (setq handler (find-file-name-handler file 'file-notify-rm-watch))
310 (if handler
311 (funcall handler 'file-notify-rm-watch descriptor)
312 (funcall
313 (cond
314 ((eq file-notify-support 'gfilenotify) 'gfile-rm-watch)
315 ((eq file-notify-support 'inotify) 'inotify-rm-watch)
316 ((eq file-notify-support 'w32notify) 'w32notify-rm-watch))
317 descriptor)))
318
319 (remhash descriptor file-notify-descriptors)))
320
321;; The end:
322(provide 'filenotify)
323
324;;; filenotify.el ends here
diff --git a/lisp/files.el b/lisp/files.el
index e59a9acb7b9..ff4ccec2279 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -316,6 +316,7 @@ A value of nil means don't add newlines.
316 316
317Certain major modes set this locally to the value obtained 317Certain major modes set this locally to the value obtained
318from `mode-require-final-newline'." 318from `mode-require-final-newline'."
319 :safe #'symbolp
319 :type '(choice (const :tag "When visiting" visit) 320 :type '(choice (const :tag "When visiting" visit)
320 (const :tag "When saving" t) 321 (const :tag "When saving" t)
321 (const :tag "When visiting or saving" visit-save) 322 (const :tag "When visiting or saving" visit-save)
@@ -3878,6 +3879,10 @@ Interactively, confirmation is required unless you supply a prefix argument."
3878 (or buffer-file-name (buffer-name)))))) 3879 (or buffer-file-name (buffer-name))))))
3879 (and confirm 3880 (and confirm
3880 (file-exists-p filename) 3881 (file-exists-p filename)
3882 ;; NS does its own confirm dialog.
3883 (not (and (eq (framep-on-display) 'ns)
3884 (listp last-nonmenu-event)
3885 use-dialog-box))
3881 (or (y-or-n-p (format "File `%s' exists; overwrite? " filename)) 3886 (or (y-or-n-p (format "File `%s' exists; overwrite? " filename))
3882 (error "Canceled"))) 3887 (error "Canceled")))
3883 (set-visited-file-name filename (not confirm)))) 3888 (set-visited-file-name filename (not confirm))))
@@ -4912,6 +4917,11 @@ change the additional actions you can take on files."
4912 (length autosaved-buffers) 4917 (length autosaved-buffers)
4913 (mapconcat 'identity autosaved-buffers ", ")))))))) 4918 (mapconcat 'identity autosaved-buffers ", "))))))))
4914 4919
4920(defun clear-visited-file-modtime ()
4921 "Clear out records of last mod time of visited file.
4922Next attempt to save will certainly not complain of a discrepancy."
4923 (set-visited-file-modtime 0))
4924
4915(defun not-modified (&optional arg) 4925(defun not-modified (&optional arg)
4916 "Mark current buffer as unmodified, not needing to be saved. 4926 "Mark current buffer as unmodified, not needing to be saved.
4917With prefix ARG, mark buffer as modified, so \\[save-buffer] will save. 4927With prefix ARG, mark buffer as modified, so \\[save-buffer] will save.
diff --git a/lisp/filesets.el b/lisp/filesets.el
index 978512bd3a4..fbf28dbecbc 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -149,7 +149,7 @@ is loaded before custom.el, set this variable to t.")
149(defun filesets-filter-list (lst cond-fn) 149(defun filesets-filter-list (lst cond-fn)
150 "Remove all elements not conforming to COND-FN from list LST. 150 "Remove all elements not conforming to COND-FN from list LST.
151COND-FN takes one argument: the current element." 151COND-FN takes one argument: the current element."
152; (remove* 'dummy lst :test (lambda (dummy elt) 152; (cl-remove 'dummy lst :test (lambda (dummy elt)
153; (not (funcall cond-fn elt))))) 153; (not (funcall cond-fn elt)))))
154 (let ((rv nil)) 154 (let ((rv nil))
155 (dolist (elt lst rv) 155 (dolist (elt lst rv)
@@ -175,7 +175,7 @@ Like `some', return the first value of FSS-PRED that is non-nil."
175 (let ((fss-rv (funcall fss-pred fss-this))) 175 (let ((fss-rv (funcall fss-pred fss-this)))
176 (when fss-rv 176 (when fss-rv
177 (throw 'exit fss-rv)))))) 177 (throw 'exit fss-rv))))))
178;(fset 'filesets-some 'some) ;; or use the cl function 178;(fset 'filesets-some 'cl-some) ;; or use the cl function
179 179
180(defun filesets-member (fsm-item fsm-lst &rest fsm-keys) 180(defun filesets-member (fsm-item fsm-lst &rest fsm-keys)
181 "Find the first occurrence of FSM-ITEM in FSM-LST. 181 "Find the first occurrence of FSM-ITEM in FSM-LST.
@@ -186,7 +186,7 @@ key is supported."
186 (filesets-ormap (lambda (fsm-this) 186 (filesets-ormap (lambda (fsm-this)
187 (funcall fsm-test fsm-item fsm-this)) 187 (funcall fsm-test fsm-item fsm-this))
188 fsm-lst))) 188 fsm-lst)))
189;(fset 'filesets-member 'member*) ;; or use the cl function 189;(fset 'filesets-member 'cl-member) ;; or use the cl function
190 190
191(defun filesets-sublist (lst beg &optional end) 191(defun filesets-sublist (lst beg &optional end)
192 "Get the sublist of LST from BEG to END - 1." 192 "Get the sublist of LST from BEG to END - 1."
diff --git a/lisp/frame.el b/lisp/frame.el
index 0f8fc523a1b..3ac24a509a0 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1365,7 +1365,11 @@ frame's display)."
1365 1365
1366(defun display-pixel-height (&optional display) 1366(defun display-pixel-height (&optional display)
1367 "Return the height of DISPLAY's screen in pixels. 1367 "Return the height of DISPLAY's screen in pixels.
1368For character terminals, each character counts as a single pixel." 1368For character terminals, each character counts as a single pixel.
1369For graphical terminals, note that on \"multi-monitor\" setups this
1370refers to the pixel height for all physical monitors associated
1371with DISPLAY. To get information for each physical monitor, use
1372`display-monitor-attributes-list'."
1369 (let ((frame-type (framep-on-display display))) 1373 (let ((frame-type (framep-on-display display)))
1370 (cond 1374 (cond
1371 ((memq frame-type '(x w32 ns)) 1375 ((memq frame-type '(x w32 ns))
@@ -1377,7 +1381,11 @@ For character terminals, each character counts as a single pixel."
1377 1381
1378(defun display-pixel-width (&optional display) 1382(defun display-pixel-width (&optional display)
1379 "Return the width of DISPLAY's screen in pixels. 1383 "Return the width of DISPLAY's screen in pixels.
1380For character terminals, each character counts as a single pixel." 1384For character terminals, each character counts as a single pixel.
1385For graphical terminals, note that on \"multi-monitor\" setups this
1386refers to the pixel width for all physical monitors associated
1387with DISPLAY. To get information for each physical monitor, use
1388`display-monitor-attributes-list'."
1381 (let ((frame-type (framep-on-display display))) 1389 (let ((frame-type (framep-on-display display)))
1382 (cond 1390 (cond
1383 ((memq frame-type '(x w32 ns)) 1391 ((memq frame-type '(x w32 ns))
@@ -1408,7 +1416,11 @@ displays not explicitly specified."
1408(defun display-mm-height (&optional display) 1416(defun display-mm-height (&optional display)
1409 "Return the height of DISPLAY's screen in millimeters. 1417 "Return the height of DISPLAY's screen in millimeters.
1410System values can be overridden by `display-mm-dimensions-alist'. 1418System values can be overridden by `display-mm-dimensions-alist'.
1411If the information is unavailable, value is nil." 1419If the information is unavailable, value is nil.
1420For graphical terminals, note that on \"multi-monitor\" setups this
1421refers to the height in millimeters for all physical monitors
1422associated with DISPLAY. To get information for each physical
1423monitor, use `display-monitor-attributes-list'."
1412 (and (memq (framep-on-display display) '(x w32 ns)) 1424 (and (memq (framep-on-display display) '(x w32 ns))
1413 (or (cddr (assoc (or display (frame-parameter nil 'display)) 1425 (or (cddr (assoc (or display (frame-parameter nil 'display))
1414 display-mm-dimensions-alist)) 1426 display-mm-dimensions-alist))
@@ -1420,7 +1432,11 @@ If the information is unavailable, value is nil."
1420(defun display-mm-width (&optional display) 1432(defun display-mm-width (&optional display)
1421 "Return the width of DISPLAY's screen in millimeters. 1433 "Return the width of DISPLAY's screen in millimeters.
1422System values can be overridden by `display-mm-dimensions-alist'. 1434System values can be overridden by `display-mm-dimensions-alist'.
1423If the information is unavailable, value is nil." 1435If the information is unavailable, value is nil.
1436For graphical terminals, note that on \"multi-monitor\" setups this
1437refers to the width in millimeters for all physical monitors
1438associated with DISPLAY. To get information for each physical
1439monitor, use `display-monitor-attributes-list'."
1424 (and (memq (framep-on-display display) '(x w32 ns)) 1440 (and (memq (framep-on-display display) '(x w32 ns))
1425 (or (cadr (assoc (or display (frame-parameter nil 'display)) 1441 (or (cadr (assoc (or display (frame-parameter nil 'display))
1426 display-mm-dimensions-alist)) 1442 display-mm-dimensions-alist))
@@ -1495,6 +1511,8 @@ The value is one of the symbols `static-gray', `gray-scale',
1495 1511
1496(declare-function x-display-monitor-attributes-list "xfns.c" 1512(declare-function x-display-monitor-attributes-list "xfns.c"
1497 (&optional terminal)) 1513 (&optional terminal))
1514(declare-function w32-display-monitor-attributes-list "w32fns.c"
1515 (&optional display))
1498(declare-function ns-display-monitor-attributes-list "nsfns.m" 1516(declare-function ns-display-monitor-attributes-list "nsfns.m"
1499 (&optional terminal)) 1517 (&optional terminal))
1500 1518
@@ -1530,6 +1548,8 @@ monitors."
1530 (cond 1548 (cond
1531 ((eq frame-type 'x) 1549 ((eq frame-type 'x)
1532 (x-display-monitor-attributes-list display)) 1550 (x-display-monitor-attributes-list display))
1551 ((eq frame-type 'w32)
1552 (w32-display-monitor-attributes-list display))
1533 ((eq frame-type 'ns) 1553 ((eq frame-type 'ns)
1534 (ns-display-monitor-attributes-list display)) 1554 (ns-display-monitor-attributes-list display))
1535 (t 1555 (t
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 49b45380575..eade6273e95 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,58 @@
12013-07-10 David Engster <deng@randomsample.de>
2
3 * gnus-start.el (gnus-clean-old-newsrc): Always remove 'unexist' marks
4 if `gnus-newsrc-file-version' does not match `gnus-version'. This
5 fixes a bug in Emacs trunk where the 'unexist' marks were always
6 removed at startup because "Gnus v5.13" was considered smaller than "Ma
7 Gnus v0.03".
8
92013-07-10 Tassilo Horn <tsdh@gnu.org>
10
11 * gnus.el (gnus-summary-line-format): Reference
12 `gnus-user-date-format-alist' for the &user-date; format, not
13 `gnus-summary-user-date-format-alist'.
14
152013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
16
17 * nnml.el (nnml-request-compact-group): Don't bug out if we can't
18 delete files (bug#13481).
19
202013-07-08 Tassilo Horn <tsdh@gnu.org>
21
22 * gnus-registry.el (gnus-registry-remove-extra-data): New function.
23
242013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
25
26 * gnus-art.el (gnus-block-private-groups): Allow `global' methods to
27 display images.
28
29 * gnus.el (gnus-valid-select-methods): Mark nnrss as global.
30
31 * message.el (message-cancel-news): According to
32 <mailman.216.1372942181.12400.help-gnu-emacs@gnu.org>, "cancel" is
33 preferred over "cmsg cancel" in the Subject.
34
35 * nnir.el (nnir-engines): Note that the group specs are regexps
36 (bug#13238).
37
38 * gnus-msg.el (gnus-copy-article-buffer): If the article buffer has
39 gotten read-only text properties, ensure that those aren't heeded when
40 copying stuff over (bug#13434).
41
42 * mm-view.el (mm-inline-text-html): Don't bug out on multipart messages
43 (bug#13762).
44
452013-07-05 David Kastrup <dak@gnu.org>
46
47 * auth-source.el (auth-source-netrc-parse-one): Allow empty strings in
48 authinfo file again (important for blank passwords). This had been
49 broken with 2013-06-15 change.
50
512013-07-03 Katsumi Yamaoka <yamaoka@jpl.org>
52
53 * gnus-sum.el (gnus-summary-from-or-to-or-newsgroups):
54 Revert 2013-01-14 change.
55
12013-07-02 David Engster <deng@randomsample.de> 562013-07-02 David Engster <deng@randomsample.de>
2 57
3 * gnus-sum.el (gnus-update-marks): Do not remove empty 'unexist' 58 * gnus-sum.el (gnus-update-marks): Do not remove empty 'unexist'
@@ -88,7 +143,7 @@
882013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org> 1432013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
89 144
90 * gnus-sum.el (gnus-summary-insert-old-articles): 145 * gnus-sum.el (gnus-summary-insert-old-articles):
91 Don't include unexistent messages. 146 Don't include unexisting messages.
92 147
932013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org> 1482013-07-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
94 149
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 8cef741cda2..54429b5cfda 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1048,8 +1048,8 @@ Note that the MAX parameter is used so we can exit the parse early."
1048 "Read one thing from the current buffer." 1048 "Read one thing from the current buffer."
1049 (auth-source-netrc-parse-next-interesting) 1049 (auth-source-netrc-parse-next-interesting)
1050 1050
1051 (when (or (looking-at "'\\([^']+\\)'") 1051 (when (or (looking-at "'\\([^']*\\)'")
1052 (looking-at "\"\\([^\"]+\\)\"") 1052 (looking-at "\"\\([^\"]*\\)\"")
1053 (looking-at "\\([^ \t\n]+\\)")) 1053 (looking-at "\\([^ \t\n]+\\)"))
1054 (forward-char (length (match-string 0))) 1054 (forward-char (length (match-string 0)))
1055 (auth-source-netrc-parse-next-interesting) 1055 (auth-source-netrc-parse-next-interesting)
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 5840aacd7a3..b41ff9c0550 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -6947,7 +6947,8 @@ If given a prefix, show the hidden text instead."
6947 (set-buffer buf)))))) 6947 (set-buffer buf))))))
6948 6948
6949(defun gnus-block-private-groups (group) 6949(defun gnus-block-private-groups (group)
6950 (if (gnus-news-group-p group) 6950 (if (or (gnus-news-group-p group)
6951 (gnus-member-of-valid 'global group))
6951 ;; Block nothing in news groups. 6952 ;; Block nothing in news groups.
6952 nil 6953 nil
6953 ;; Block everything anywhere else. 6954 ;; Block everything anywhere else.
diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index fce9a3633c2..e3f18662af4 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -920,6 +920,7 @@ header line with the old Message-ID."
920 (with-current-buffer article-buffer 920 (with-current-buffer article-buffer
921 (let ((gnus-newsgroup-charset (or gnus-article-charset 921 (let ((gnus-newsgroup-charset (or gnus-article-charset
922 gnus-newsgroup-charset)) 922 gnus-newsgroup-charset))
923 (inhibit-read-only t)
923 (gnus-newsgroup-ignored-charsets 924 (gnus-newsgroup-ignored-charsets
924 (or gnus-article-ignored-charsets 925 (or gnus-article-ignored-charsets
925 gnus-newsgroup-ignored-charsets))) 926 gnus-newsgroup-ignored-charsets)))
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 5a7dfd82d28..6f2fe78c3d8 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -1186,6 +1186,29 @@ data stored in the registry."
1186 (gnus-select-group-with-message-id group message-id) t) 1186 (gnus-select-group-with-message-id group message-id) t)
1187 (throw 'found t)))))))) 1187 (throw 'found t))))))))
1188 1188
1189(defun gnus-registry-remove-extra-data (extra)
1190 "Remove tracked EXTRA data from the gnus registry.
1191EXTRA is a list of symbols. Valid symbols are those contained in
1192the docs of `gnus-registry-track-extra'. This command is useful
1193when you stop tracking some extra data and now want to purge it
1194from your existing entries."
1195 (interactive (list (mapcar 'intern
1196 (completing-read-multiple
1197 "Extra data: "
1198 '("subject" "sender" "recipient")))))
1199 (when extra
1200 (let ((db gnus-registry-db))
1201 (registry-reindex db)
1202 (loop for k being the hash-keys of (oref db :data)
1203 using (hash-value v)
1204 do (let ((newv (delq nil (mapcar #'(lambda (entry)
1205 (unless (member (car entry) extra)
1206 entry))
1207 v))))
1208 (registry-delete db (list k) nil)
1209 (gnus-registry-insert db k newv)))
1210 (registry-reindex db))))
1211
1189;; TODO: a few things 1212;; TODO: a few things
1190 1213
1191(provide 'gnus-registry) 1214(provide 'gnus-registry)
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index 084af884930..94803800e0b 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -2314,8 +2314,9 @@ If FORCE is non-nil, the .newsrc file is read."
2314 (gnus-info-set-marks 2314 (gnus-info-set-marks
2315 info (delete exist (gnus-info-marks info)))))) 2315 info (delete exist (gnus-info-marks info))))))
2316 (when (or force 2316 (when (or force
2317 (< (gnus-continuum-version gnus-newsrc-file-version) 2317 (not (string= gnus-newsrc-file-version gnus-version)))
2318 (gnus-continuum-version "Ma Gnus v0.03"))) 2318 (message (concat "Removing unexist marks because newsrc "
2319 "version does not match Gnus version."))
2319 ;; Remove old `exist' marks from old nnimap groups. 2320 ;; Remove old `exist' marks from old nnimap groups.
2320 (dolist (info (cdr gnus-newsrc-alist)) 2321 (dolist (info (cdr gnus-newsrc-alist))
2321 (let ((exist (assoc 'unexist (gnus-info-marks info)))) 2322 (let ((exist (assoc 'unexist (gnus-info-marks info))))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index e136d4f8173..f3918b0a215 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -1525,7 +1525,7 @@ This list will always be a subset of gnus-newsgroup-undownloaded.")
1525 "Range of seen articles in the current newsgroup.") 1525 "Range of seen articles in the current newsgroup.")
1526 1526
1527(defvar gnus-newsgroup-unexist nil 1527(defvar gnus-newsgroup-unexist nil
1528 "Range of unexistent articles in the current newsgroup.") 1528 "Range of unexisting articles in the current newsgroup.")
1529 1529
1530(defvar gnus-newsgroup-articles nil 1530(defvar gnus-newsgroup-articles nil
1531 "List of articles in the current newsgroup.") 1531 "List of articles in the current newsgroup.")
@@ -3657,18 +3657,17 @@ buffer that was in action when the last article was fetched."
3657 (or (car (funcall gnus-extract-address-components from)) 3657 (or (car (funcall gnus-extract-address-components from))
3658 from)) 3658 from))
3659 3659
3660(defun gnus-summary-from-or-to-or-newsgroups (header from) 3660(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3661 (let ((mail-parse-charset gnus-newsgroup-charset) 3661 (let ((mail-parse-charset gnus-newsgroup-charset)
3662 (ignored-from-addresses (gnus-ignored-from-addresses)) 3662 (ignored-from-addresses (gnus-ignored-from-addresses))
3663 ;; Is it really necessary to do this next part for each summary line? 3663 ;; Is it really necessary to do this next part for each summary line?
3664 ;; Luckily, doesn't seem to slow things down much. 3664 ;; Luckily, doesn't seem to slow things down much.
3665 (mail-parse-ignored-charsets 3665 (mail-parse-ignored-charsets
3666 (with-current-buffer gnus-summary-buffer 3666 (with-current-buffer gnus-summary-buffer
3667 gnus-newsgroup-ignored-charsets)) 3667 gnus-newsgroup-ignored-charsets)))
3668 (address (cadr (gnus-extract-address-components from))))
3669 (or 3668 (or
3670 (and ignored-from-addresses 3669 (and ignored-from-addresses
3671 (string-match ignored-from-addresses address) 3670 (string-match ignored-from-addresses gnus-tmp-from)
3672 (let ((extra-headers (mail-header-extra header)) 3671 (let ((extra-headers (mail-header-extra header))
3673 to 3672 to
3674 newsgroups) 3673 newsgroups)
@@ -3683,11 +3682,13 @@ buffer that was in action when the last article was fetched."
3683 (cdr (assq 'Newsgroups extra-headers)) 3682 (cdr (assq 'Newsgroups extra-headers))
3684 (and 3683 (and
3685 (memq 'Newsgroups gnus-extra-headers) 3684 (memq 'Newsgroups gnus-extra-headers)
3686 (eq (car (gnus-find-method-for-group 3685 (eq (car (gnus-find-method-for-group
3687 gnus-newsgroup-name)) 'nntp) 3686 gnus-newsgroup-name)) 'nntp)
3688 (gnus-group-real-name gnus-newsgroup-name)))) 3687 (gnus-group-real-name gnus-newsgroup-name))))
3689 (concat gnus-summary-newsgroup-prefix newsgroups))))) 3688 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3690 (gnus-string-mark-left-to-right (gnus-summary-extract-address-component from))))) 3689 (gnus-string-mark-left-to-right
3690 (inline
3691 (gnus-summary-extract-address-component gnus-tmp-from))))))
3691 3692
3692(defun gnus-summary-insert-line (gnus-tmp-header 3693(defun gnus-summary-insert-line (gnus-tmp-header
3693 gnus-tmp-level gnus-tmp-current 3694 gnus-tmp-level gnus-tmp-current
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 9a927a1cfab..8741a03b54d 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -1628,7 +1628,7 @@ slower."
1628 ("nnfolder" mail respool address) 1628 ("nnfolder" mail respool address)
1629 ("nngateway" post-mail address prompt-address physical-address) 1629 ("nngateway" post-mail address prompt-address physical-address)
1630 ("nnweb" none) 1630 ("nnweb" none)
1631 ("nnrss" none) 1631 ("nnrss" none global)
1632 ("nnagent" post-mail) 1632 ("nnagent" post-mail)
1633 ("nnimap" post-mail address prompt-address physical-address respool 1633 ("nnimap" post-mail address prompt-address physical-address respool
1634 server-marks) 1634 server-marks)
@@ -3007,7 +3007,7 @@ with some simple extensions.
3007 summary just like information from any other summary 3007 summary just like information from any other summary
3008 specifier. 3008 specifier.
3009&user-date; Age sensitive date format. Various date format is 3009&user-date; Age sensitive date format. Various date format is
3010 defined in `gnus-summary-user-date-format-alist'. 3010 defined in `gnus-user-date-format-alist'.
3011 3011
3012 3012
3013The %U (status), %R (replied) and %z (zcore) specs have to be handled 3013The %U (status), %R (replied) and %z (zcore) specs have to be handled
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index c6f5d904677..b35eb9dca12 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -7145,7 +7145,7 @@ If ARG, allow editing of the cancellation message."
7145 (erase-buffer) 7145 (erase-buffer)
7146 (insert "Newsgroups: " newsgroups "\n" 7146 (insert "Newsgroups: " newsgroups "\n"
7147 "From: " from "\n" 7147 "From: " from "\n"
7148 "Subject: cmsg cancel " message-id "\n" 7148 "Subject: cancel " message-id "\n"
7149 "Control: cancel " message-id "\n" 7149 "Control: cancel " message-id "\n"
7150 (if distribution 7150 (if distribution
7151 (concat "Distribution: " distribution "\n") 7151 (concat "Distribution: " distribution "\n")
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index b1cba27c335..9512a411d81 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -419,16 +419,18 @@
419 (buffer-string))))) 419 (buffer-string)))))
420 420
421(defun mm-inline-text-html (handle) 421(defun mm-inline-text-html (handle)
422 (let* ((func mm-text-html-renderer) 422 (if (stringp (car handle))
423 (entry (assq func mm-text-html-renderer-alist)) 423 (mapcar 'mm-inline-text-html (cdr handle))
424 (inhibit-read-only t)) 424 (let* ((func mm-text-html-renderer)
425 (if entry 425 (entry (assq func mm-text-html-renderer-alist))
426 (setq func (cdr entry))) 426 (inhibit-read-only t))
427 (cond 427 (if entry
428 ((functionp func) 428 (setq func (cdr entry)))
429 (funcall func handle)) 429 (cond
430 (t 430 ((functionp func)
431 (apply (car func) handle (cdr func)))))) 431 (funcall func handle))
432 (t
433 (apply (car func) handle (cdr func)))))))
432 434
433(defun mm-inline-text-vcard (handle) 435(defun mm-inline-text-vcard (handle)
434 (let ((inhibit-read-only t)) 436 (let ((inhibit-read-only t))
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el
index 22dee30e8fa..4dd123bf2c7 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -548,15 +548,15 @@ that it is for notmuch, not Namazu."
548 (gmane nnir-run-gmane 548 (gmane nnir-run-gmane
549 ((gmane-author . "Gmane Author: "))) 549 ((gmane-author . "Gmane Author: ")))
550 (swish++ nnir-run-swish++ 550 (swish++ nnir-run-swish++
551 ((swish++-group . "Swish++ Group spec: "))) 551 ((swish++-group . "Swish++ Group spec (regexp): ")))
552 (swish-e nnir-run-swish-e 552 (swish-e nnir-run-swish-e
553 ((swish-e-group . "Swish-e Group spec: "))) 553 ((swish-e-group . "Swish-e Group spec (regexp): ")))
554 (namazu nnir-run-namazu 554 (namazu nnir-run-namazu
555 ()) 555 ())
556 (notmuch nnir-run-notmuch 556 (notmuch nnir-run-notmuch
557 ()) 557 ())
558 (hyrex nnir-run-hyrex 558 (hyrex nnir-run-hyrex
559 ((hyrex-group . "Hyrex Group spec: "))) 559 ((hyrex-group . "Hyrex Group spec (regexp): ")))
560 (find-grep nnir-run-find-grep 560 (find-grep nnir-run-find-grep
561 ((grep-options . "Grep options: ")))) 561 ((grep-options . "Grep options: "))))
562 "Alist of supported search engines. 562 "Alist of supported search engines.
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el
index 64e1ee11977..05d0c902340 100644
--- a/lisp/gnus/nnml.el
+++ b/lisp/gnus/nnml.el
@@ -1094,7 +1094,10 @@ Use the nov database for the current group if available."
1094 (concat group ":" new-number-string))) 1094 (concat group ":" new-number-string)))
1095 ;; Save to the new file: 1095 ;; Save to the new file:
1096 (nnmail-write-region (point-min) (point-max) newfile)) 1096 (nnmail-write-region (point-min) (point-max) newfile))
1097 (funcall nnmail-delete-file-function oldfile)) 1097 (condition-case ()
1098 (funcall nnmail-delete-file-function oldfile)
1099 (file-error
1100 (message "Couldn't delete %s" oldfile))))
1098 ;; 2/ Update all marks for this article: 1101 ;; 2/ Update all marks for this article:
1099 ;; #### NOTE: it is possible that the new article number 1102 ;; #### NOTE: it is possible that the new article number
1100 ;; #### already belongs to a range, whereas the corresponding 1103 ;; #### already belongs to a range, whereas the corresponding
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 8f7d584d00b..a4f18201a3f 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -462,6 +462,7 @@ directory, like `default-directory'."
462 (define-key map (kbd "M-g") 'ibuffer-jump-to-buffer) 462 (define-key map (kbd "M-g") 'ibuffer-jump-to-buffer)
463 (define-key map (kbd "M-s a C-s") 'ibuffer-do-isearch) 463 (define-key map (kbd "M-s a C-s") 'ibuffer-do-isearch)
464 (define-key map (kbd "M-s a M-C-s") 'ibuffer-do-isearch-regexp) 464 (define-key map (kbd "M-s a M-C-s") 'ibuffer-do-isearch-regexp)
465 (define-key map (kbd "M-s a C-o") 'ibuffer-do-occur)
465 (define-key map (kbd "DEL") 'ibuffer-unmark-backward) 466 (define-key map (kbd "DEL") 'ibuffer-unmark-backward)
466 (define-key map (kbd "M-DEL") 'ibuffer-unmark-all) 467 (define-key map (kbd "M-DEL") 'ibuffer-unmark-all)
467 (define-key map (kbd "* *") 'ibuffer-unmark-all) 468 (define-key map (kbd "* *") 'ibuffer-unmark-all)
diff --git a/lisp/ido.el b/lisp/ido.el
index 4a4ecdcdb1a..43a0cc0a665 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -782,21 +782,29 @@ remaining completion. If absent, elements 5 and 6 are used instead."
782 :group 'ido) 782 :group 'ido)
783 783
784(defcustom ido-use-virtual-buffers nil 784(defcustom ido-use-virtual-buffers nil
785 "If non-nil, refer to past buffers as well as existing ones. 785 "Specify how virtual buffers should be used.
786The value can be one of the following:
787
788 nil: No virtual buffers are used.
789 auto: Use virtual bufferw when the current input matches no
790 existing buffers.
791 t: Always use virtual buffers.
792
786Essentially it works as follows: Say you are visiting a file and 793Essentially it works as follows: Say you are visiting a file and
787the buffer gets cleaned up by midnight.el. Later, you want to 794the buffer gets cleaned up by midnight.el. Later, you want to
788switch to that buffer, but find it's no longer open. With 795switch to that buffer, but find it's no longer open. With virtual
789virtual buffers enabled, the buffer name stays in the buffer 796buffers enabled, the buffer name stays in the buffer list (using
790list (using the `ido-virtual' face, and always at the end), and if 797the `ido-virtual' face, and always at the end), and if you select
791you select it, it opens the file back up again. This allows you 798it, it opens the file back up again. This allows you to think
792to think less about whether recently opened files are still open 799less about whether recently opened files are still open or not.
793or not. Most of the time you can quit Emacs, restart, and then 800Most of the time you can quit Emacs, restart, and then switch to
794switch to a file buffer that was previously open as if it still 801a file buffer that was previously open as if it still were. This
795were. 802feature relies upon the `recentf' package, which will be enabled
796 This feature relies upon the `recentf' package, which will be 803if this variable is configured to a non-nil value."
797enabled if this variable is configured to a non-nil value." 804 :version "24.4"
798 :version "24.1" 805 :type '(choice (const :tag "Always" t)
799 :type 'boolean 806 (const :tag "Automatic" auto)
807 (const :tag "Never" nil))
800 :group 'ido) 808 :group 'ido)
801 809
802(defcustom ido-use-faces t 810(defcustom ido-use-faces t
@@ -1103,6 +1111,9 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
1103;; Don't process ido-ignore- lists once. 1111;; Don't process ido-ignore- lists once.
1104(defvar ido-process-ignore-lists-inhibit) 1112(defvar ido-process-ignore-lists-inhibit)
1105 1113
1114;; Is ido using virtual buffers?
1115(defvar ido-enable-virtual-buffers)
1116
1106;; Buffer from which ido was entered. 1117;; Buffer from which ido was entered.
1107(defvar ido-entry-buffer) 1118(defvar ido-entry-buffer)
1108 1119
@@ -2202,7 +2213,8 @@ If cursor is not at the end of the user input, move to end of input."
2202 (ido-current-directory nil) 2213 (ido-current-directory nil)
2203 (ido-directory-nonreadable nil) 2214 (ido-directory-nonreadable nil)
2204 (ido-directory-too-big nil) 2215 (ido-directory-too-big nil)
2205 (ido-use-virtual-buffers ido-use-virtual-buffers) 2216 (ido-enable-virtual-buffers (and ido-use-virtual-buffers
2217 (not (eq ido-use-virtual-buffers 'auto))))
2206 (require-match (confirm-nonexistent-file-or-buffer)) 2218 (require-match (confirm-nonexistent-file-or-buffer))
2207 (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default 2219 (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default
2208 require-match initial)) 2220 require-match initial))
@@ -2243,7 +2255,8 @@ If cursor is not at the end of the user input, move to end of input."
2243 (ido-visit-buffer buf method t))) 2255 (ido-visit-buffer buf method t)))
2244 2256
2245 ;; check for a virtual buffer reference 2257 ;; check for a virtual buffer reference
2246 ((and ido-use-virtual-buffers ido-virtual-buffers 2258 ((and ido-enable-virtual-buffers
2259 ido-virtual-buffers
2247 (setq filename (assoc buf ido-virtual-buffers))) 2260 (setq filename (assoc buf ido-virtual-buffers)))
2248 (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) 2261 (ido-visit-buffer (find-file-noselect (cdr filename)) method t))
2249 2262
@@ -2734,7 +2747,11 @@ C-x C-f ... C-d enter `dired' on current directory."
2734See `ido-use-virtual-buffers' for explanation of virtual buffer." 2747See `ido-use-virtual-buffers' for explanation of virtual buffer."
2735 (interactive) 2748 (interactive)
2736 (when (and ido-mode (eq ido-cur-item 'buffer)) 2749 (when (and ido-mode (eq ido-cur-item 'buffer))
2737 (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) 2750 (setq ido-enable-virtual-buffers
2751 (if ido-enable-virtual-buffers
2752 nil
2753 ;; Use `always' instead of t for `ido-exhibit'.
2754 'always))
2738 (setq ido-text-init ido-text) 2755 (setq ido-text-init ido-text)
2739 (setq ido-exit 'refresh) 2756 (setq ido-exit 'refresh)
2740 (exit-minibuffer))) 2757 (exit-minibuffer)))
@@ -3427,9 +3444,9 @@ it is put to the start of the list."
3427 (nconc ido-temp-list ido-current-buffers) 3444 (nconc ido-temp-list ido-current-buffers)
3428 (setq ido-temp-list ido-current-buffers)) 3445 (setq ido-temp-list ido-current-buffers))
3429 (if default 3446 (if default
3430 (setq ido-temp-list 3447 (setq ido-temp-list
3431 (cons default (delete default ido-temp-list)))) 3448 (cons default (delete default ido-temp-list))))
3432 (if ido-use-virtual-buffers 3449 (if (bound-and-true-p ido-enable-virtual-buffers)
3433 (ido-add-virtual-buffers-to-list)) 3450 (ido-add-virtual-buffers-to-list))
3434 (run-hooks 'ido-make-buffer-list-hook) 3451 (run-hooks 'ido-make-buffer-list-hook)
3435 ido-temp-list)) 3452 ido-temp-list))
@@ -3444,8 +3461,14 @@ This is to make them appear as if they were \"virtual buffers\"."
3444 (setq ido-virtual-buffers nil) 3461 (setq ido-virtual-buffers nil)
3445 (let (name) 3462 (let (name)
3446 (dolist (head recentf-list) 3463 (dolist (head recentf-list)
3447 (and (setq name (file-name-nondirectory head)) 3464 (setq name (file-name-nondirectory head))
3448 (null (get-file-buffer head)) 3465 ;; In case HEAD is a directory with trailing /. See bug#14552.
3466 (when (equal name "")
3467 (setq name (file-name-nondirectory (directory-file-name head))))
3468 (when (equal name "")
3469 (setq name head))
3470 (and (not (equal name ""))
3471 (null (get-file-buffer head))
3449 (not (assoc name ido-virtual-buffers)) 3472 (not (assoc name ido-virtual-buffers))
3450 (not (member name ido-temp-list)) 3473 (not (member name ido-temp-list))
3451 (not (ido-ignore-item-p name ido-ignore-buffers)) 3474 (not (ido-ignore-item-p name ido-ignore-buffers))
@@ -3986,6 +4009,7 @@ If cursor is not at the end of the user input, delete to end of input."
3986;;; DELETE CURRENT FILE 4009;;; DELETE CURRENT FILE
3987(defun ido-delete-file-at-head () 4010(defun ido-delete-file-at-head ()
3988 "Delete the file at the head of `ido-matches'. 4011 "Delete the file at the head of `ido-matches'.
4012Trash the file if `delete-by-moving-to-trash' is non-nil.
3989If cursor is not at the end of the user input, delete to end of input." 4013If cursor is not at the end of the user input, delete to end of input."
3990 (interactive) 4014 (interactive)
3991 (if (not (eobp)) 4015 (if (not (eobp))
@@ -3998,8 +4022,9 @@ If cursor is not at the end of the user input, delete to end of input."
3998 (file-exists-p file) 4022 (file-exists-p file)
3999 (not (file-directory-p file)) 4023 (not (file-directory-p file))
4000 (file-writable-p ido-current-directory) 4024 (file-writable-p ido-current-directory)
4001 (yes-or-no-p (concat "Delete " file "? "))) 4025 (or delete-by-moving-to-trash
4002 (delete-file file) 4026 (yes-or-no-p (concat "Delete " file "? "))))
4027 (delete-file file 'trash)
4003 ;; Check if file still exists. 4028 ;; Check if file still exists.
4004 (if (file-exists-p file) 4029 (if (file-exists-p file)
4005 ;; file could not be deleted 4030 ;; file could not be deleted
@@ -4457,11 +4482,6 @@ For details of keybindings, see `ido-find-file'."
4457 (setq ido-exit 'refresh) 4482 (setq ido-exit 'refresh)
4458 (exit-minibuffer)) 4483 (exit-minibuffer))
4459 4484
4460 ;; Update the list of matches
4461 (setq ido-text contents)
4462 (ido-set-matches)
4463 (ido-trace "new " ido-matches)
4464
4465 (when (and ido-enter-matching-directory 4485 (when (and ido-enter-matching-directory
4466 ido-matches 4486 ido-matches
4467 (or (eq ido-enter-matching-directory 'first) 4487 (or (eq ido-enter-matching-directory 'first)
@@ -4475,6 +4495,32 @@ For details of keybindings, see `ido-find-file'."
4475 (setq ido-exit 'refresh) 4495 (setq ido-exit 'refresh)
4476 (exit-minibuffer)) 4496 (exit-minibuffer))
4477 4497
4498 ;; Update the list of matches
4499 (setq ido-text contents)
4500 (ido-set-matches)
4501 (ido-trace "new " ido-matches)
4502
4503 (when (and (boundp 'ido-enable-virtual-buffers)
4504 (not (eq ido-enable-virtual-buffers 'always))
4505 (eq ido-cur-item 'buffer)
4506 (eq ido-use-virtual-buffers 'auto))
4507
4508 (when (and (not ido-enable-virtual-buffers)
4509 (not ido-matches))
4510 (setq ido-text-init ido-text)
4511 (setq ido-enable-virtual-buffers t)
4512 (setq ido-exit 'refresh)
4513 (exit-minibuffer))
4514
4515 ;; If input matches real buffers turn off virtual buffers.
4516 (when (and ido-enable-virtual-buffers
4517 ido-matches
4518 (ido-set-matches-1 (ido-make-buffer-list-1)))
4519 (setq ido-enable-virtual-buffers nil)
4520 (setq ido-text-init ido-text)
4521 (setq ido-exit 'refresh)
4522 (exit-minibuffer)))
4523
4478 (when (and (not ido-matches) 4524 (when (and (not ido-matches)
4479 (not ido-directory-nonreadable) 4525 (not ido-directory-nonreadable)
4480 (not ido-directory-too-big) 4526 (not ido-directory-too-big)
@@ -4681,9 +4727,12 @@ Modified from `icomplete-completions'."
4681 4727
4682;;; Helper functions for other programs 4728;;; Helper functions for other programs
4683 4729
4684(put 'dired-do-rename 'ido 'ignore)
4685(put 'ibuffer-find-file 'ido 'find-file) 4730(put 'ibuffer-find-file 'ido 'find-file)
4731(put 'dired 'ido 'dir)
4686(put 'dired-other-window 'ido 'dir) 4732(put 'dired-other-window 'ido 'dir)
4733;; See http://debbugs.gnu.org/11954 for reasons.
4734(put 'dired-do-copy 'ido 'ignore)
4735(put 'dired-do-rename 'ido 'ignore)
4687 4736
4688;;;###autoload 4737;;;###autoload
4689(defun ido-read-buffer (prompt &optional default require-match) 4738(defun ido-read-buffer (prompt &optional default require-match)
@@ -4711,18 +4760,20 @@ See `read-file-name' for additional parameters."
4711 (let (filename) 4760 (let (filename)
4712 (cond 4761 (cond
4713 ((or (eq predicate 'file-directory-p) 4762 ((or (eq predicate 'file-directory-p)
4714 (eq (get this-command 'ido) 'dir) 4763 (eq (and (symbolp this-command)
4764 (get this-command 'ido)) 'dir)
4715 (memq this-command ido-read-file-name-as-directory-commands)) 4765 (memq this-command ido-read-file-name-as-directory-commands))
4716 (setq filename 4766 (setq filename
4717 (ido-read-directory-name prompt dir default-filename mustmatch initial)) 4767 (ido-read-directory-name prompt dir default-filename mustmatch initial)))
4718 (if (eq ido-exit 'fallback) 4768 ((and (not (eq (and (symbolp this-command)
4719 (setq filename 'fallback))) 4769 (get this-command 'ido)) 'ignore))
4720 ((and (not (eq (get this-command 'ido) 'ignore))
4721 (not (memq this-command ido-read-file-name-non-ido)) 4770 (not (memq this-command ido-read-file-name-non-ido))
4722 (or (null predicate) (eq predicate 'file-exists-p))) 4771 (or (null predicate) (eq predicate 'file-exists-p)))
4723 (let* (ido-saved-vc-hb 4772 (let* (ido-saved-vc-hb
4724 (ido-context-switch-command 4773 (ido-context-switch-command
4725 (if (eq (get this-command 'ido) 'find-file) nil 'ignore)) 4774 (if (eq (and (symbolp this-command)
4775 (get this-command 'ido)) 'find-file)
4776 nil 'ignore))
4726 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) 4777 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
4727 (minibuffer-completing-file-name t) 4778 (minibuffer-completing-file-name t)
4728 (ido-current-directory (ido-expand-directory dir)) 4779 (ido-current-directory (ido-expand-directory dir))
@@ -4736,7 +4787,15 @@ See `read-file-name' for additional parameters."
4736 (ido-find-literal nil)) 4787 (ido-find-literal nil))
4737 (setq ido-exit nil) 4788 (setq ido-exit nil)
4738 (setq filename 4789 (setq filename
4739 (ido-read-internal 'file prompt 'ido-file-history default-filename mustmatch initial)) 4790 (ido-read-internal 'file prompt 'ido-file-history
4791 (cond ; Bug#11861.
4792 ((stringp default-filename) default-filename)
4793 ((consp default-filename) (car default-filename))
4794 ((and (not default-filename) initial)
4795 (expand-file-name initial dir))
4796 (buffer-file-name buffer-file-name))
4797 mustmatch initial))
4798 (setq dir ido-current-directory) ; See bug#1516.
4740 (cond 4799 (cond
4741 ((eq ido-exit 'fallback) 4800 ((eq ido-exit 'fallback)
4742 (setq filename 'fallback)) 4801 (setq filename 'fallback))
@@ -4768,12 +4827,21 @@ See `read-directory-name' for additional parameters."
4768 (ido-directory-too-big-p ido-current-directory))) 4827 (ido-directory-too-big-p ido-current-directory)))
4769 (ido-work-directory-index -1) 4828 (ido-work-directory-index -1)
4770 (ido-work-file-index -1)) 4829 (ido-work-file-index -1))
4771 (setq filename 4830 (setq filename (ido-read-internal
4772 (ido-read-internal 'dir prompt 'ido-file-history default-dirname mustmatch initial)) 4831 'dir prompt 'ido-file-history
4773 (if filename 4832 (or default-dirname ; Bug#11861.
4774 (if (and (stringp filename) (string-equal filename ".")) 4833 (if initial
4775 ido-current-directory 4834 (expand-file-name initial ido-current-directory)
4776 (concat ido-current-directory filename))))) 4835 ido-current-directory))
4836 mustmatch initial))
4837 (cond
4838 ((eq ido-exit 'fallback)
4839 (let ((read-file-name-function nil))
4840 (run-hook-with-args 'ido-before-fallback-functions 'read-directory-name)
4841 (read-directory-name prompt ido-current-directory
4842 default-dirname mustmatch initial)))
4843 ((equal filename ".") ido-current-directory)
4844 (t (concat ido-current-directory filename)))))
4777 4845
4778;;;###autoload 4846;;;###autoload
4779(defun ido-completing-read (prompt choices &optional _predicate require-match 4847(defun ido-completing-read (prompt choices &optional _predicate require-match
diff --git a/lisp/info-xref.el b/lisp/info-xref.el
index c38e23bab8a..21fb592ff19 100644
--- a/lisp/info-xref.el
+++ b/lisp/info-xref.el
@@ -45,7 +45,25 @@
45;;; Code: 45;;; Code:
46 46
47(require 'info) 47(require 'info)
48(eval-when-compile (require 'cl-lib)) ;; for `incf' 48(eval-when-compile (require 'cl-lib)) ; for `cl-incf'
49
50(defgroup info-xref nil
51 "Check external cross-references in Info documents."
52 :group 'docs) ; FIXME right parent?
53
54;; Should this even be an option?
55(defcustom info-xref-case-fold nil
56 "Non-nil means node checks should ignore case.
57When following cross-references, the Emacs Info reader first tries a
58case-sensitive match, then if that fails a case-insensitive one.
59The standalone Info reader does not do this, nor does this work
60for links in the html versions of Texinfo manuals. Therefore
61to ensure your cross-references work on the widest range of platforms,
62you should set this variable to nil."
63 :group 'info-xref
64 :type 'boolean
65 :version "24.4")
66
49 67
50;;----------------------------------------------------------------------------- 68;;-----------------------------------------------------------------------------
51;; vaguely generic 69;; vaguely generic
@@ -204,7 +222,8 @@ buffer's line and column of point."
204 (Info-goto-node node 222 (Info-goto-node node
205 (when (get-buffer "*info*") 223 (when (get-buffer "*info*")
206 (set-buffer "*info*") 224 (set-buffer "*info*")
207 "xref - temporary")) 225 "xref - temporary")
226 (not info-xref-case-fold))
208 t) 227 t)
209 (error nil)) 228 (error nil))
210 (unless (equal (current-buffer) oldbuf) 229 (unless (equal (current-buffer) oldbuf)
diff --git a/lisp/info.el b/lisp/info.el
index f9851a0c1e8..0e0a11753ba 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -920,10 +920,14 @@ just return nil (no error)."
920 (error "Info file %s does not exist" filename))) 920 (error "Info file %s does not exist" filename)))
921 filename)))) 921 filename))))
922 922
923(defun Info-find-node (filename nodename &optional no-going-back) 923(defun Info-find-node (filename nodename &optional no-going-back strict-case)
924 "Go to an Info node specified as separate FILENAME and NODENAME. 924 "Go to an Info node specified as separate FILENAME and NODENAME.
925NO-GOING-BACK is non-nil if recovering from an error in this function; 925NO-GOING-BACK is non-nil if recovering from an error in this function;
926it says do not attempt further (recursive) error recovery." 926it says do not attempt further (recursive) error recovery.
927
928This function first looks for a case-sensitive match for NODENAME;
929if none is found it then tries a case-insensitive match (unless
930STRICT-CASE is non-nil)."
927 (info-initialize) 931 (info-initialize)
928 (setq filename (Info-find-file filename)) 932 (setq filename (Info-find-file filename))
929 ;; Go into Info buffer. 933 ;; Go into Info buffer.
@@ -933,7 +937,7 @@ it says do not attempt further (recursive) error recovery."
933 Info-current-file 937 Info-current-file
934 (push (list Info-current-file Info-current-node (point)) 938 (push (list Info-current-file Info-current-node (point))
935 Info-history)) 939 Info-history))
936 (Info-find-node-2 filename nodename no-going-back)) 940 (Info-find-node-2 filename nodename no-going-back strict-case))
937 941
938;;;###autoload 942;;;###autoload
939(defun Info-on-current-buffer (&optional nodename) 943(defun Info-on-current-buffer (&optional nodename)
@@ -1010,7 +1014,7 @@ which the match was found."
1010 (+ (point-min) (read (current-buffer))) 1014 (+ (point-min) (read (current-buffer)))
1011 major-mode))))) 1015 major-mode)))))
1012 1016
1013(defun Info-find-in-tag-table (marker regexp) 1017(defun Info-find-in-tag-table (marker regexp &optional strict-case)
1014 "Find a node in a tag table. 1018 "Find a node in a tag table.
1015MARKER specifies the buffer and position to start searching at. 1019MARKER specifies the buffer and position to start searching at.
1016REGEXP is a regular expression matching nodes or references. Its first 1020REGEXP is a regular expression matching nodes or references. Its first
@@ -1020,10 +1024,11 @@ FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
1020where the match was found, and MODE is `major-mode' of the buffer in 1024where the match was found, and MODE is `major-mode' of the buffer in
1021which the match was found. 1025which the match was found.
1022This function tries to find a case-sensitive match first, then a 1026This function tries to find a case-sensitive match first, then a
1023case-insensitive match is tried." 1027case-insensitive match is tried (unless optional argument STRICT-CASE
1028is non-nil)."
1024 (let ((result (Info-find-in-tag-table-1 marker regexp nil))) 1029 (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
1025 (when (null (car result)) 1030 (or strict-case (car result)
1026 (setq result (Info-find-in-tag-table-1 marker regexp t))) 1031 (setq result (Info-find-in-tag-table-1 marker regexp t)))
1027 result)) 1032 result))
1028 1033
1029(defun Info-find-node-in-buffer-1 (regexp case-fold) 1034(defun Info-find-node-in-buffer-1 (regexp case-fold)
@@ -1046,17 +1051,19 @@ Value is the position at which a match was found, or nil if not found."
1046 (setq found (line-beginning-position))))))) 1051 (setq found (line-beginning-position)))))))
1047 found)) 1052 found))
1048 1053
1049(defun Info-find-node-in-buffer (regexp) 1054(defun Info-find-node-in-buffer (regexp &optional strict-case)
1050 "Find a node or anchor in the current buffer. 1055 "Find a node or anchor in the current buffer.
1051REGEXP is a regular expression matching nodes or references. Its first 1056REGEXP is a regular expression matching nodes or references. Its first
1052group should match `Node:' or `Ref:'. 1057group should match `Node:' or `Ref:'.
1053Value is the position at which a match was found, or nil if not found. 1058Value is the position at which a match was found, or nil if not found.
1054This function looks for a case-sensitive match first. If none is found, 1059This function looks for a case-sensitive match first. If none is found,
1055a case-insensitive match is tried." 1060a case-insensitive match is tried (unless optional argument STRICT-CASE
1061is non-nil)."
1056 (or (Info-find-node-in-buffer-1 regexp nil) 1062 (or (Info-find-node-in-buffer-1 regexp nil)
1057 (Info-find-node-in-buffer-1 regexp t))) 1063 (and (not strict-case)
1064 (Info-find-node-in-buffer-1 regexp t))))
1058 1065
1059(defun Info-find-node-2 (filename nodename &optional no-going-back) 1066(defun Info-find-node-2 (filename nodename &optional no-going-back strict-case)
1060 (buffer-disable-undo (current-buffer)) 1067 (buffer-disable-undo (current-buffer))
1061 (or (eq major-mode 'Info-mode) 1068 (or (eq major-mode 'Info-mode)
1062 (Info-mode)) 1069 (Info-mode))
@@ -1167,7 +1174,7 @@ a case-insensitive match is tried."
1167 ;; First, search a tag table, if any 1174 ;; First, search a tag table, if any
1168 (when (marker-position Info-tag-table-marker) 1175 (when (marker-position Info-tag-table-marker)
1169 (let* ((m Info-tag-table-marker) 1176 (let* ((m Info-tag-table-marker)
1170 (found (Info-find-in-tag-table m regexp))) 1177 (found (Info-find-in-tag-table m regexp strict-case)))
1171 1178
1172 (when found 1179 (when found
1173 ;; FOUND is (ANCHOR POS MODE). 1180 ;; FOUND is (ANCHOR POS MODE).
@@ -1194,7 +1201,7 @@ a case-insensitive match is tried."
1194 ;; buffer) to find the actual node. First, check 1201 ;; buffer) to find the actual node. First, check
1195 ;; whether the node is right where we are, in case the 1202 ;; whether the node is right where we are, in case the
1196 ;; buffer begins with a node. 1203 ;; buffer begins with a node.
1197 (let ((pos (Info-find-node-in-buffer regexp))) 1204 (let ((pos (Info-find-node-in-buffer regexp strict-case)))
1198 (when pos 1205 (when pos
1199 (goto-char pos) 1206 (goto-char pos)
1200 (throw 'foo t))) 1207 (throw 'foo t)))
@@ -1701,7 +1708,7 @@ escaped (\\\",\\\\)."
1701;; Don't autoload this function: the correct entry point for other packages 1708;; Don't autoload this function: the correct entry point for other packages
1702;; to use is `info'. --Stef 1709;; to use is `info'. --Stef
1703;; ;;;###autoload 1710;; ;;;###autoload
1704(defun Info-goto-node (nodename &optional fork) 1711(defun Info-goto-node (nodename &optional fork strict-case)
1705 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. 1712 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1706If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file 1713If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1707FILENAME; otherwise, NODENAME should be in the current Info file (or one of 1714FILENAME; otherwise, NODENAME should be in the current Info file (or one of
@@ -1711,7 +1718,11 @@ in the Info file FILENAME after the closing parenthesis in (FILENAME).
1711Empty NODENAME in (FILENAME) defaults to the Top node. 1718Empty NODENAME in (FILENAME) defaults to the Top node.
1712If FORK is non-nil (interactively with a prefix arg), show the node in 1719If FORK is non-nil (interactively with a prefix arg), show the node in
1713a new Info buffer. 1720a new Info buffer.
1714If FORK is a string, it is the name to use for the new buffer." 1721If FORK is a string, it is the name to use for the new buffer.
1722
1723This function first looks for a case-sensitive match for the node part
1724of NODENAME; if none is found it then tries a case-insensitive match
1725\(unless STRICT-CASE is non-nil)."
1715 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) 1726 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
1716 (info-initialize) 1727 (info-initialize)
1717 (if fork 1728 (if fork
@@ -1730,7 +1741,7 @@ If FORK is a string, it is the name to use for the new buffer."
1730 (if trim (setq nodename (substring nodename 0 trim)))) 1741 (if trim (setq nodename (substring nodename 0 trim))))
1731 (if transient-mark-mode (deactivate-mark)) 1742 (if transient-mark-mode (deactivate-mark))
1732 (Info-find-node (if (equal filename "") nil filename) 1743 (Info-find-node (if (equal filename "") nil filename)
1733 (if (equal nodename "") "Top" nodename)))) 1744 (if (equal nodename "") "Top" nodename) nil strict-case)))
1734 1745
1735(defvar Info-read-node-completion-table) 1746(defvar Info-read-node-completion-table)
1736 1747
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 3577e0e9152..28542835a5f 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -672,7 +672,7 @@ is unsuitable for the top-level media type \"text\".
672 672
673VALUE must be a list of symbols that control the ISO-2022 converter. 673VALUE must be a list of symbols that control the ISO-2022 converter.
674Each must be a member of the list `coding-system-iso-2022-flags' 674Each must be a member of the list `coding-system-iso-2022-flags'
675\(which see). This attribute has a meaning only when `:coding-type' 675\(which see). This attribute is meaningful only when `:coding-type'
676is `iso-2022'. 676is `iso-2022'.
677 677
678`:designation' 678`:designation'
@@ -692,7 +692,7 @@ to GN. If the list contains 96, any charsets whose whose ranges are
69296 long can be designated to GN. If the first element is a charset, 69296 long can be designated to GN. If the first element is a charset,
693that charset is initially designated to GN. 693that charset is initially designated to GN.
694 694
695This attribute has a meaning only when `:coding-type' is `iso-2022'. 695This attribute is meaningful only when `:coding-type' is `iso-2022'.
696 696
697`:bom' 697`:bom'
698 698
@@ -712,7 +712,7 @@ are 0xFF 0xFE, use the cdr part coding system of the value.
712Otherwise, treat them as bytes for a normal character. On encoding, 712Otherwise, treat them as bytes for a normal character. On encoding,
713produce BOM bytes according to the value of `:endian'. 713produce BOM bytes according to the value of `:endian'.
714 714
715This attribute has a meaning only when `:coding-type' is `utf-16' or 715This attribute is meaningful only when `:coding-type' is `utf-16' or
716`utf-8'. 716`utf-8'.
717 717
718`:endian' 718`:endian'
@@ -720,37 +720,37 @@ This attribute has a meaning only when `:coding-type' is `utf-16' or
720VALUE must be `big' or `little' specifying big-endian and 720VALUE must be `big' or `little' specifying big-endian and
721little-endian respectively. The default value is `big'. 721little-endian respectively. The default value is `big'.
722 722
723This attribute has a meaning only when `:coding-type' is `utf-16'. 723This attribute is meaningful only when `:coding-type' is `utf-16'.
724 724
725`:ccl-decoder' 725`:ccl-decoder'
726 726
727VALUE is a symbol representing the registered CCL program used for 727VALUE is a symbol representing the registered CCL program used for
728decoding. This attribute has a meaning only when `:coding-type' is 728decoding. This attribute is meaningful only when `:coding-type' is
729`ccl'. 729`ccl'.
730 730
731`:ccl-encoder' 731`:ccl-encoder'
732 732
733VALUE is a symbol representing the registered CCL program used for 733VALUE is a symbol representing the registered CCL program used for
734encoding. This attribute has a meaning only when `:coding-type' is 734encoding. This attribute is meaningful only when `:coding-type' is
735`ccl'. 735`ccl'.
736 736
737:inhibit-null-byte-detection 737`:inhibit-null-byte-detection'
738 738
739VALUE non-nil means Emacs ignore null bytes on code detection. 739VALUE non-nil means Emacs ignore null bytes on code detection.
740See the variable `inhibit-null-byte-detection'. This attribute 740See the variable `inhibit-null-byte-detection'. This attribute
741has a meaning only when `:coding-type' is `undecided'. 741is meaningful only when `:coding-type' is `undecided'.
742 742
743:inhibit-iso-escape-detection 743`:inhibit-iso-escape-detection'
744 744
745VALUE non-nil means Emacs ignores ISO-2022 escape sequences on 745VALUE non-nil means Emacs ignores ISO-2022 escape sequences on
746code detection. See the variable `inhibit-iso-escape-detection'. 746code detection. See the variable `inhibit-iso-escape-detection'.
747This attribute has a meaning only when `:coding-type' is 747This attribute is meaningful only when `:coding-type' is
748`undecided'. 748`undecided'.
749 749
750:prefer-utf-8 750`:prefer-utf-8'
751 751
752VALUE non-nil means Emacs prefers UTF-8 on code detection for 752VALUE non-nil means Emacs prefers UTF-8 on code detection for
753non-ASCII files. This attribute has a meaning only when 753non-ASCII files. This attribute is meaningful only when
754`:coding-type' is `undecided'." 754`:coding-type' is `undecided'."
755 (let* ((common-attrs (mapcar 'list 755 (let* ((common-attrs (mapcar 'list
756 '(:mnemonic 756 '(:mnemonic
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index bdc30bc9292..4506ede8722 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -145,6 +145,7 @@ cid: URL as the argument.")
145 (define-key map [follow-link] 'mouse-face) 145 (define-key map [follow-link] 'mouse-face)
146 (define-key map "I" 'shr-insert-image) 146 (define-key map "I" 'shr-insert-image)
147 (define-key map "w" 'shr-copy-url) 147 (define-key map "w" 'shr-copy-url)
148 (define-key map "u" 'shr-copy-url)
148 (define-key map "v" 'shr-browse-url) 149 (define-key map "v" 'shr-browse-url)
149 (define-key map "o" 'shr-save-contents) 150 (define-key map "o" 'shr-save-contents)
150 (define-key map "\r" 'shr-browse-url) 151 (define-key map "\r" 'shr-browse-url)
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 4c6141fe42b..f7f570590c8 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -38,9 +38,11 @@
38;; 38;;
39;; - localname is a string. This are temporary properties, which are 39;; - localname is a string. This are temporary properties, which are
40;; related to the file localname is referring to. Examples: 40;; related to the file localname is referring to. Examples:
41;; "file-exists-p" is t or nile, depending on the file existence, or 41;; "file-exists-p" is t or nil, depending on the file existence, or
42;; "file-attributes" caches the result of the function 42;; "file-attributes" caches the result of the function
43;; `file-attributes'. 43;; `file-attributes'. These entries have a timestamp, and they
44;; expire after `remote-file-name-inhibit-cache' seconds if this
45;; variable is set.
44;; 46;;
45;; - The key is a process. This are temporary properties related to 47;; - The key is a process. This are temporary properties related to
46;; an open connection. Examples: "scripts" keeps shell script 48;; an open connection. Examples: "scripts" keeps shell script
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 6ba055b8bb8..c2fdc0491b6 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1539,7 +1539,8 @@ connection if a previous connection has died for some reason."
1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint" 1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
1540 ;; file property. 1540 ;; file property.
1541 (with-timeout 1541 (with-timeout
1542 (60 1542 ((or (tramp-get-method-parameter method 'tramp-connection-timeout)
1543 tramp-connection-timeout)
1543 (if (zerop (length (tramp-file-name-user vec))) 1544 (if (zerop (length (tramp-file-name-user vec)))
1544 (tramp-error 1545 (tramp-error
1545 vec 'file-error 1546 vec 'file-error
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 387084a807b..281f497692d 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -222,21 +222,24 @@ detected as prompt when being sent on echoing hosts, therefore.")
222 (tramp-login-program "su") 222 (tramp-login-program "su")
223 (tramp-login-args (("-") ("%u"))) 223 (tramp-login-args (("-") ("%u")))
224 (tramp-remote-shell "/bin/sh") 224 (tramp-remote-shell "/bin/sh")
225 (tramp-remote-shell-args ("-c")))) 225 (tramp-remote-shell-args ("-c"))
226 (tramp-connection-timeout 10)))
226;;;###tramp-autoload 227;;;###tramp-autoload
227(add-to-list 'tramp-methods 228(add-to-list 'tramp-methods
228 '("sudo" 229 '("sudo"
229 (tramp-login-program "sudo") 230 (tramp-login-program "sudo")
230 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:"))) 231 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:")))
231 (tramp-remote-shell "/bin/sh") 232 (tramp-remote-shell "/bin/sh")
232 (tramp-remote-shell-args ("-c")))) 233 (tramp-remote-shell-args ("-c"))
234 (tramp-connection-timeout 10)))
233;;;###tramp-autoload 235;;;###tramp-autoload
234(add-to-list 'tramp-methods 236(add-to-list 'tramp-methods
235 '("ksu" 237 '("ksu"
236 (tramp-login-program "ksu") 238 (tramp-login-program "ksu")
237 (tramp-login-args (("%u") ("-q"))) 239 (tramp-login-args (("%u") ("-q")))
238 (tramp-remote-shell "/bin/sh") 240 (tramp-remote-shell "/bin/sh")
239 (tramp-remote-shell-args ("-c")))) 241 (tramp-remote-shell-args ("-c"))
242 (tramp-connection-timeout 10)))
240;;;###tramp-autoload 243;;;###tramp-autoload
241(add-to-list 'tramp-methods 244(add-to-list 'tramp-methods
242 '("krlogin" 245 '("krlogin"
@@ -862,7 +865,9 @@ of command line.")
862 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context) 865 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
863 (file-acl . tramp-sh-handle-file-acl) 866 (file-acl . tramp-sh-handle-file-acl)
864 (set-file-acl . tramp-sh-handle-set-file-acl) 867 (set-file-acl . tramp-sh-handle-set-file-acl)
865 (vc-registered . tramp-sh-handle-vc-registered)) 868 (vc-registered . tramp-sh-handle-vc-registered)
869 (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch)
870 (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch))
866 "Alist of handler functions. 871 "Alist of handler functions.
867Operations not mentioned here will be handled by the normal Emacs functions.") 872Operations not mentioned here will be handled by the normal Emacs functions.")
868 873
@@ -2669,7 +2674,7 @@ the result will be a local, non-Tramp, filename."
2669 (unless (memq (process-status proc) '(run open)) 2674 (unless (memq (process-status proc) '(run open))
2670 (let ((vec (tramp-get-connection-property proc "vector" nil))) 2675 (let ((vec (tramp-get-connection-property proc "vector" nil)))
2671 (when vec 2676 (when vec
2672 (tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event) 2677 (tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
2673 (tramp-flush-connection-property proc) 2678 (tramp-flush-connection-property proc)
2674 (tramp-flush-directory-property vec ""))))) 2679 (tramp-flush-directory-property vec "")))))
2675 2680
@@ -3376,6 +3381,122 @@ Fall back to normal file name handler if no Tramp handler exists."
3376 ;; Default file name handlers, we don't care. 3381 ;; Default file name handlers, we don't care.
3377 (t (tramp-run-real-handler operation args))))))) 3382 (t (tramp-run-real-handler operation args)))))))
3378 3383
3384(defun tramp-sh-handle-file-notify-add-watch (file-name flags callback)
3385 "Like `file-notify-add-watch' for Tramp files."
3386 (setq file-name (expand-file-name file-name))
3387 (with-parsed-tramp-file-name file-name nil
3388 (let* ((default-directory (file-name-directory file-name))
3389 command events filter p)
3390 (cond
3391 ;; gvfs-monitor-dir.
3392 ((setq command (tramp-get-remote-gvfs-monitor-dir v))
3393 (setq filter 'tramp-sh-file-gvfs-monitor-dir-process-filter
3394 p (start-file-process
3395 "gvfs-monitor-dir" (generate-new-buffer " *gvfs-monitor-dir*")
3396 command localname)))
3397 ;; inotifywait.
3398 ((setq command (tramp-get-remote-inotifywait v))
3399 (setq filter 'tramp-sh-file-inotifywait-process-filter
3400 events
3401 (cond
3402 ((and (memq 'change flags) (memq 'attribute-change flags))
3403 "create,modify,move,delete,attrib")
3404 ((memq 'change flags) "create,modify,move,delete")
3405 ((memq 'attribute-change flags) "attrib"))
3406 p (start-file-process
3407 "inotifywait" (generate-new-buffer " *inotifywait*")
3408 command "-mq" "-e" events localname)))
3409 ;; None.
3410 (t (tramp-error
3411 v 'file-notify-error
3412 "No file notification program found on %s"
3413 (file-remote-p file-name))))
3414 ;; Return the process object as watch-descriptor.
3415 (if (not (processp p))
3416 (tramp-error
3417 v 'file-notify-error "`%s' failed to start on remote host" command)
3418 (tramp-compat-set-process-query-on-exit-flag p nil)
3419 (set-process-filter p filter)
3420 p))))
3421
3422(defun tramp-sh-file-gvfs-monitor-dir-process-filter (proc string)
3423 "Read output from \"gvfs-monitor-dir\" and add corresponding file-notify events."
3424 (let ((remote-prefix
3425 (with-current-buffer (process-buffer proc)
3426 (file-remote-p default-directory)))
3427 (rest-string (tramp-compat-process-get proc 'rest-string)))
3428 (when rest-string
3429 (tramp-message proc 10 (format "Previous string:\n%s" rest-string)))
3430 (tramp-message proc 6 (format "%S\n%s" proc string))
3431 (setq string (concat rest-string string)
3432 ;; Attribute change is returned in unused wording.
3433 string (replace-regexp-in-string
3434 "ATTRIB CHANGED" "ATTRIBUTE_CHANGED" string))
3435
3436 (while (string-match
3437 (concat "^[\n\r]*"
3438 "Directory Monitor Event:[\n\r]+"
3439 "Child = \\([^\n\r]+\\)[\n\r]+"
3440 "\\(Other = \\([^\n\r]+\\)[\n\r]+\\)?"
3441 "Event = \\([^[:blank:]]+\\)[\n\r]+")
3442 string)
3443 (let ((object
3444 (list
3445 proc
3446 (intern-soft
3447 (replace-regexp-in-string
3448 "_" "-" (downcase (match-string 4 string))))
3449 ;; File names are returned as absolute paths. We must
3450 ;; add the remote prefix.
3451 (concat remote-prefix (match-string 1 string))
3452 (when (match-string 3 string)
3453 (concat remote-prefix (match-string 3 string))))))
3454 (setq string (replace-match "" nil nil string))
3455 ;; Usually, we would add an Emacs event now. Unfortunately,
3456 ;; `unread-command-events' does not accept several events at
3457 ;; once. Therefore, we apply the callback directly.
3458 (tramp-compat-funcall 'file-notify-callback object)))
3459
3460 ;; Save rest of the string.
3461 (when (zerop (length string)) (setq string nil))
3462 (when string (tramp-message proc 10 (format "Rest string:\n%s" string)))
3463 (tramp-compat-process-put proc 'rest-string string)))
3464
3465(defun tramp-sh-file-inotifywait-process-filter (proc string)
3466 "Read output from \"inotifywait\" and add corresponding file-notify events."
3467 (tramp-message proc 6 (format "%S\n%s" proc string))
3468 (dolist (line (split-string string "[\n\r]+" 'omit-nulls))
3469 ;; Check, whether there is a problem.
3470 (unless
3471 (string-match
3472 (concat "^[^[:blank:]]+"
3473 "[[:blank:]]+\\([^[:blank:]]+\\)+"
3474 "\\([[:blank:]]+\\([^\n\r]+\\)\\)?")
3475 line)
3476 (tramp-error proc 'file-notify-error "%s" line))
3477
3478 (let ((object
3479 (list
3480 proc
3481 (mapcar
3482 (lambda (x)
3483 (intern-soft (replace-regexp-in-string "_" "-" (downcase x))))
3484 (split-string (match-string 1 line) "," 'omit-nulls))
3485 (match-string 3 line))))
3486 ;; Usually, we would add an Emacs event now. Unfortunately,
3487 ;; `unread-command-events' does not accept several events at
3488 ;; once. Therefore, we apply the callback directly.
3489 (tramp-compat-funcall 'file-notify-callback object))))
3490
3491(defvar file-notify-descriptors)
3492(defun tramp-sh-handle-file-notify-rm-watch (proc)
3493 "Like `file-notify-rm-watch' for Tramp files."
3494 ;; The descriptor must be a process object.
3495 (unless (and (processp proc) (gethash proc file-notify-descriptors))
3496 (tramp-error proc 'file-notify-error "Not a valid descriptor %S" proc))
3497 (tramp-message proc 6 (format "Kill %S" proc))
3498 (kill-process proc))
3499
3379;;; Internal Functions: 3500;;; Internal Functions:
3380 3501
3381(defun tramp-maybe-send-script (vec script name) 3502(defun tramp-maybe-send-script (vec script name)
@@ -3634,12 +3755,16 @@ file exists and nonzero exit status otherwise."
3634 "Wait for shell prompt and barf if none appears. 3755 "Wait for shell prompt and barf if none appears.
3635Looks at process PROC to see if a shell prompt appears in TIMEOUT 3756Looks at process PROC to see if a shell prompt appears in TIMEOUT
3636seconds. If not, it produces an error message with the given ERROR-ARGS." 3757seconds. If not, it produces an error message with the given ERROR-ARGS."
3637 (unless 3758 (let ((vec (tramp-get-connection-property proc "vector" nil)))
3638 (tramp-wait-for-regexp 3759 (condition-case err
3639 proc timeout 3760 (tramp-wait-for-regexp
3640 (format 3761 proc timeout
3641 "\\(%s\\|%s\\)\\'" shell-prompt-pattern tramp-shell-prompt-pattern)) 3762 (format
3642 (apply 'tramp-error-with-buffer nil proc 'file-error error-args))) 3763 "\\(%s\\|%s\\)\\'" shell-prompt-pattern tramp-shell-prompt-pattern))
3764 (error
3765 (delete-process proc)
3766 (apply 'tramp-error-with-buffer
3767 (tramp-get-connection-buffer vec) vec 'file-error error-args)))))
3643 3768
3644(defun tramp-open-connection-setup-interactive-shell (proc vec) 3769(defun tramp-open-connection-setup-interactive-shell (proc vec)
3645 "Set up an interactive shell. 3770 "Set up an interactive shell.
@@ -4214,9 +4339,6 @@ Gateway hops are already opened."
4214 ;; Result. 4339 ;; Result.
4215 target-alist)) 4340 target-alist))
4216 4341
4217(defvar tramp-current-connection nil
4218 "Last connection timestamp.")
4219
4220(defun tramp-maybe-open-connection (vec) 4342(defun tramp-maybe-open-connection (vec)
4221 "Maybe open a connection VEC. 4343 "Maybe open a connection VEC.
4222Does not do anything if a connection is already open, but re-opens the 4344Does not do anything if a connection is already open, but re-opens the
@@ -4230,7 +4352,7 @@ connection if a previous connection has died for some reason."
4230 ;; If Tramp opens the same connection within a short time frame, 4352 ;; If Tramp opens the same connection within a short time frame,
4231 ;; there is a problem. We shall signal this. 4353 ;; there is a problem. We shall signal this.
4232 (unless (or (and p (processp p) (memq (process-status p) '(run open))) 4354 (unless (or (and p (processp p) (memq (process-status p) '(run open)))
4233 (not (equal (butlast (append vec nil)) 4355 (not (equal (butlast (append vec nil) 2)
4234 (car tramp-current-connection))) 4356 (car tramp-current-connection)))
4235 (> (tramp-time-diff 4357 (> (tramp-time-diff
4236 (current-time) (cdr tramp-current-connection)) 4358 (current-time) (cdr tramp-current-connection))
@@ -4315,7 +4437,7 @@ connection if a previous connection has died for some reason."
4315 (set-process-sentinel p 'tramp-process-sentinel) 4437 (set-process-sentinel p 'tramp-process-sentinel)
4316 (tramp-compat-set-process-query-on-exit-flag p nil) 4438 (tramp-compat-set-process-query-on-exit-flag p nil)
4317 (setq tramp-current-connection 4439 (setq tramp-current-connection
4318 (cons (butlast (append vec nil)) (current-time)) 4440 (cons (butlast (append vec nil) 2) (current-time))
4319 tramp-current-host (system-name)) 4441 tramp-current-host (system-name))
4320 4442
4321 (tramp-message 4443 (tramp-message
@@ -4323,8 +4445,8 @@ connection if a previous connection has died for some reason."
4323 4445
4324 ;; Check whether process is alive. 4446 ;; Check whether process is alive.
4325 (tramp-barf-if-no-shell-prompt 4447 (tramp-barf-if-no-shell-prompt
4326 p 60 4448 p 10
4327 "Couldn't find local shell prompt %s" tramp-encoding-shell) 4449 "Couldn't find local shell prompt for %s" tramp-encoding-shell)
4328 4450
4329 ;; Now do all the connections as specified. 4451 ;; Now do all the connections as specified.
4330 (while target-alist 4452 (while target-alist
@@ -4342,6 +4464,9 @@ connection if a previous connection has died for some reason."
4342 (async-args 4464 (async-args
4343 (tramp-get-method-parameter 4465 (tramp-get-method-parameter
4344 l-method 'tramp-async-args)) 4466 l-method 'tramp-async-args))
4467 (connection-timeout
4468 (tramp-get-method-parameter
4469 l-method 'tramp-connection-timeout))
4345 (gw-args 4470 (gw-args
4346 (tramp-get-method-parameter l-method 'tramp-gw-args)) 4471 (tramp-get-method-parameter l-method 'tramp-gw-args))
4347 (gw (tramp-get-file-property hop "" "gateway" nil)) 4472 (gw (tramp-get-file-property hop "" "gateway" nil))
@@ -4424,7 +4549,8 @@ connection if a previous connection has died for some reason."
4424 (tramp-message vec 3 "Sending command `%s'" command) 4549 (tramp-message vec 3 "Sending command `%s'" command)
4425 (tramp-send-command vec command t t) 4550 (tramp-send-command vec command t t)
4426 (tramp-process-actions 4551 (tramp-process-actions
4427 p vec pos tramp-actions-before-shell 60) 4552 p vec pos tramp-actions-before-shell
4553 (or connection-timeout tramp-connection-timeout))
4428 (tramp-message 4554 (tramp-message
4429 vec 3 "Found remote shell prompt on `%s'" l-host)) 4555 vec 3 "Found remote shell prompt on `%s'" l-host))
4430 ;; Next hop. 4556 ;; Next hop.
@@ -4864,6 +4990,17 @@ Return ATTR."
4864 (tramp-message vec 5 "Finding a suitable `trash' command") 4990 (tramp-message vec 5 "Finding a suitable `trash' command")
4865 (tramp-find-executable vec "trash" (tramp-get-remote-path vec)))) 4991 (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))
4866 4992
4993(defun tramp-get-remote-gvfs-monitor-dir (vec)
4994 (with-tramp-connection-property vec "gvfs-monitor-dir"
4995 (tramp-message vec 5 "Finding a suitable `gvfs-monitor-dir' command")
4996 (tramp-find-executable
4997 vec "gvfs-monitor-dir" (tramp-get-remote-path vec) t t)))
4998
4999(defun tramp-get-remote-inotifywait (vec)
5000 (with-tramp-connection-property vec "inotifywait"
5001 (tramp-message vec 5 "Finding a suitable `inotifywait' command")
5002 (tramp-find-executable vec "inotifywait" (tramp-get-remote-path vec) t t)))
5003
4867(defun tramp-get-remote-id (vec) 5004(defun tramp-get-remote-id (vec)
4868 (with-tramp-connection-property vec "id" 5005 (with-tramp-connection-property vec "id"
4869 (tramp-message vec 5 "Finding POSIX `id' command") 5006 (tramp-message vec 5 "Finding POSIX `id' command")
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4ec3a4b7829..3513701d20e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -252,6 +252,11 @@ pair of the form (KEY VALUE). The following KEYs are defined:
252 * `tramp-tmpdir' 252 * `tramp-tmpdir'
253 A directory on the remote host for temporary files. If not 253 A directory on the remote host for temporary files. If not
254 specified, \"/tmp\" is taken as default. 254 specified, \"/tmp\" is taken as default.
255 * `tramp-connection-timeout'
256 This is the maximum time to be spent for establishing a connection.
257 In general, the global default value shall be used, but for
258 some methods, like \"su\" or \"sudo\", a shorter timeout
259 might be desirable.
255 260
256What does all this mean? Well, you should specify `tramp-login-program' 261What does all this mean? Well, you should specify `tramp-login-program'
257for all methods; this program is used to log in to the remote site. Then, 262for all methods; this program is used to log in to the remote site. Then,
@@ -1034,6 +1039,13 @@ opening a connection to a remote host."
1034 :group 'tramp 1039 :group 'tramp
1035 :type '(choice (const nil) (const t) (const pty))) 1040 :type '(choice (const nil) (const t) (const pty)))
1036 1041
1042(defcustom tramp-connection-timeout 60
1043 "Defines the max time to wait for establishing a connection (in seconds).
1044This can be overwritten for different connection types in `tramp-methods'."
1045 :group 'tramp
1046 :version "24.4"
1047 :type 'integer)
1048
1037(defcustom tramp-connection-min-time-diff 5 1049(defcustom tramp-connection-min-time-diff 5
1038 "Defines seconds between two consecutive connection attempts. 1050 "Defines seconds between two consecutive connection attempts.
1039This is necessary as self defense mechanism, in order to avoid 1051This is necessary as self defense mechanism, in order to avoid
@@ -1071,6 +1083,9 @@ means to use always cached values for the directory contents."
1071(defvar tramp-current-host nil 1083(defvar tramp-current-host nil
1072 "Remote host for this *tramp* buffer.") 1084 "Remote host for this *tramp* buffer.")
1073 1085
1086(defvar tramp-current-connection nil
1087 "Last connection timestamp.")
1088
1074;;;###autoload 1089;;;###autoload
1075(defconst tramp-completion-file-name-handler-alist 1090(defconst tramp-completion-file-name-handler-alist
1076 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions) 1091 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
@@ -1464,10 +1479,6 @@ ARGS to actually emit the message (if applicable)."
1464This variable is used to disable messages from `tramp-error'. 1479This variable is used to disable messages from `tramp-error'.
1465The messages are visible anyway, because an error is raised.") 1480The messages are visible anyway, because an error is raised.")
1466 1481
1467(defvar tramp-message-show-progress-reporter-message t
1468 "Show Tramp progress reporter message in the minibuffer.
1469This variable is used to disable recursive progress reporter messages.")
1470
1471(defsubst tramp-message (vec-or-proc level fmt-string &rest args) 1482(defsubst tramp-message (vec-or-proc level fmt-string &rest args)
1472 "Emit a message depending on verbosity level. 1483 "Emit a message depending on verbosity level.
1473VEC-OR-PROC identifies the Tramp buffer to use. It can be either a 1484VEC-OR-PROC identifies the Tramp buffer to use. It can be either a
@@ -1536,23 +1547,32 @@ signal identifier to be raised, remaining args passed to
1536If BUFFER is nil, show the connection buffer. Wait for 30\", or until 1547If BUFFER is nil, show the connection buffer. Wait for 30\", or until
1537an input event arrives. The other arguments are passed to `tramp-error'." 1548an input event arrives. The other arguments are passed to `tramp-error'."
1538 (save-window-excursion 1549 (save-window-excursion
1539 (unwind-protect 1550 (let* ((buf (or (and (bufferp buffer) buffer)
1540 (apply 'tramp-error vec-or-proc signal fmt-string args) 1551 (and (processp vec-or-proc) (process-buffer vec-or-proc))
1541 (when (and vec-or-proc 1552 (and (vectorp vec-or-proc)
1542 tramp-message-show-message 1553 (tramp-get-connection-buffer vec-or-proc))))
1543 (not (zerop tramp-verbose)) 1554 (vec (or (and (vectorp vec-or-proc) vec-or-proc)
1544 (not (tramp-completion-mode-p))) 1555 (and buf (with-current-buffer buf
1545 (let ((enable-recursive-minibuffers t)) 1556 (tramp-dissect-file-name default-directory))))))
1546 (pop-to-buffer 1557 (unwind-protect
1547 (or (and (bufferp buffer) buffer) 1558 (apply 'tramp-error vec-or-proc signal fmt-string args)
1548 (and (processp vec-or-proc) (process-buffer vec-or-proc)) 1559 ;; Save exit.
1549 (tramp-get-connection-buffer vec-or-proc))) 1560 (when (and buf
1550 (when (string-equal fmt-string "Process died") 1561 tramp-message-show-message
1551 (message 1562 (not (zerop tramp-verbose))
1552 "%s\n %s" 1563 (not (tramp-completion-mode-p)))
1553 "Tramp failed to connect. If this happens repeatedly, try" 1564 (let ((enable-recursive-minibuffers t))
1554 "`M-x tramp-cleanup-this-connection'")) 1565 ;; `tramp-error' does not show messages. So we must do it
1555 (sit-for 30)))))) 1566 ;; ourselves.
1567 (message fmt-string args)
1568 ;; Show buffer.
1569 (pop-to-buffer buf)
1570 (discard-input)
1571 (sit-for 30)))
1572 ;; Reset timestamp. It would be wrong after waiting for a while.
1573 (when (equal (butlast (append vec nil) 2)
1574 (car tramp-current-connection))
1575 (setcdr tramp-current-connection (current-time)))))))
1556 1576
1557(defmacro with-parsed-tramp-file-name (filename var &rest body) 1577(defmacro with-parsed-tramp-file-name (filename var &rest body)
1558 "Parse a Tramp filename and make components available in the body. 1578 "Parse a Tramp filename and make components available in the body.
@@ -1596,16 +1616,15 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1596 1616
1597(defmacro with-tramp-progress-reporter (vec level message &rest body) 1617(defmacro with-tramp-progress-reporter (vec level message &rest body)
1598 "Executes BODY, spinning a progress reporter with MESSAGE. 1618 "Executes BODY, spinning a progress reporter with MESSAGE.
1599If LEVEL does not fit for visible messages, or if this is a 1619If LEVEL does not fit for visible messages, there are only traces
1600nested call of the macro, there are only traces without a visible 1620without a visible progress reporter."
1601progress reporter."
1602 (declare (indent 3) (debug t)) 1621 (declare (indent 3) (debug t))
1603 `(let (pr tm) 1622 `(let ((result "failed")
1623 pr tm)
1604 (tramp-message ,vec ,level "%s..." ,message) 1624 (tramp-message ,vec ,level "%s..." ,message)
1605 ;; We start a pulsing progress reporter after 3 seconds. Feature 1625 ;; We start a pulsing progress reporter after 3 seconds. Feature
1606 ;; introduced in Emacs 24.1. 1626 ;; introduced in Emacs 24.1.
1607 (when (and tramp-message-show-progress-reporter-message 1627 (when (and tramp-message-show-message
1608 tramp-message-show-message
1609 ;; Display only when there is a minimum level. 1628 ;; Display only when there is a minimum level.
1610 (<= ,level (min tramp-verbose 3))) 1629 (<= ,level (min tramp-verbose 3)))
1611 (ignore-errors 1630 (ignore-errors
@@ -1613,14 +1632,11 @@ progress reporter."
1613 tm (when pr 1632 tm (when pr
1614 (run-at-time 3 0.1 'tramp-progress-reporter-update pr))))) 1633 (run-at-time 3 0.1 'tramp-progress-reporter-update pr)))))
1615 (unwind-protect 1634 (unwind-protect
1616 ;; Execute the body. Suppress concurrent progress reporter 1635 ;; Execute the body.
1617 ;; messages. 1636 (prog1 (progn ,@body) (setq result "done"))
1618 (let ((tramp-message-show-progress-reporter-message
1619 (and tramp-message-show-progress-reporter-message (not tm))))
1620 ,@body)
1621 ;; Stop progress reporter. 1637 ;; Stop progress reporter.
1622 (if tm (tramp-compat-funcall 'cancel-timer tm)) 1638 (if tm (tramp-compat-funcall 'cancel-timer tm))
1623 (tramp-message ,vec ,level "%s...done" ,message)))) 1639 (tramp-message ,vec ,level "%s...%s" ,message result))))
1624 1640
1625(tramp-compat-font-lock-add-keywords 1641(tramp-compat-font-lock-add-keywords
1626 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>")) 1642 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>"))
@@ -1964,7 +1980,7 @@ ARGS are the arguments OPERATION has been called with."
1964 ;; Emacs 22+ only. 1980 ;; Emacs 22+ only.
1965 'set-file-times 1981 'set-file-times
1966 ;; Emacs 24+ only. 1982 ;; Emacs 24+ only.
1967 'file-acl 'file-selinux-context 1983 'file-acl 'file-notify-add-watch 'file-selinux-context
1968 'set-file-acl 'set-file-selinux-context 1984 'set-file-acl 'set-file-selinux-context
1969 ;; XEmacs only. 1985 ;; XEmacs only.
1970 'abbreviate-file-name 'create-file-buffer 1986 'abbreviate-file-name 'create-file-buffer
@@ -2018,6 +2034,10 @@ ARGS are the arguments OPERATION has been called with."
2018 ;; XEmacs only. 2034 ;; XEmacs only.
2019 'dired-print-file 'dired-shell-call-process)) 2035 'dired-print-file 'dired-shell-call-process))
2020 default-directory) 2036 default-directory)
2037 ;; PROC.
2038 ((eq operation 'file-notify-rm-watch)
2039 (with-current-buffer (process-buffer (nth 0 args))
2040 default-directory))
2021 ;; Unknown file primitive. 2041 ;; Unknown file primitive.
2022 (t (error "unknown file I/O primitive: %s" operation)))) 2042 (t (error "unknown file I/O primitive: %s" operation))))
2023 2043
@@ -3389,39 +3409,49 @@ The terminal type can be configured with `tramp-terminal-type'."
3389PROC and VEC indicate the remote connection to be used. POS, if 3409PROC and VEC indicate the remote connection to be used. POS, if
3390set, is the starting point of the region to be deleted in the 3410set, is the starting point of the region to be deleted in the
3391connection buffer." 3411connection buffer."
3392 ;; Preserve message for `progress-reporter'. 3412 ;; Enable `auth-source' and `password-cache'. We must use
3393 (tramp-compat-with-temp-message "" 3413 ;; tramp-current-* variables in case we have several hops.
3394 ;; Enable `auth-source' and `password-cache'. We must use 3414 (tramp-set-connection-property
3395 ;; tramp-current-* variables in case we have several hops. 3415 (tramp-dissect-file-name
3396 (tramp-set-connection-property 3416 (tramp-make-tramp-file-name
3397 (tramp-dissect-file-name 3417 tramp-current-method tramp-current-user tramp-current-host ""))
3398 (tramp-make-tramp-file-name 3418 "first-password-request" t)
3399 tramp-current-method tramp-current-user tramp-current-host "")) 3419 (save-restriction
3400 "first-password-request" t) 3420 (with-tramp-progress-reporter
3401 (save-restriction 3421 proc 3 "Waiting for prompts from remote shell"
3402 (let (exit) 3422 (let (exit)
3403 (while (not exit) 3423 (if timeout
3404 (tramp-message proc 3 "Waiting for prompts from remote shell") 3424 (with-timeout (timeout (setq exit 'timeout))
3405 (setq exit 3425 (while (not exit)
3406 (catch 'tramp-action 3426 (setq exit
3407 (if timeout 3427 (catch 'tramp-action
3408 (with-timeout (timeout) 3428 (tramp-process-one-action proc vec actions)))))
3409 (tramp-process-one-action proc vec actions)) 3429 (while (not exit)
3430 (setq exit
3431 (catch 'tramp-action
3410 (tramp-process-one-action proc vec actions))))) 3432 (tramp-process-one-action proc vec actions)))))
3411 (with-current-buffer (tramp-get-connection-buffer vec) 3433 (with-current-buffer (tramp-get-connection-buffer vec)
3412 (widen) 3434 (widen)
3413 (tramp-message vec 6 "\n%s" (buffer-string))) 3435 (tramp-message vec 6 "\n%s" (buffer-string)))
3414 (unless (eq exit 'ok) 3436 (unless (eq exit 'ok)
3415 (tramp-clear-passwd vec) 3437 (tramp-clear-passwd vec)
3438 (delete-process proc)
3416 (tramp-error-with-buffer 3439 (tramp-error-with-buffer
3417 nil vec 'file-error 3440 (tramp-get-connection-buffer vec) vec 'file-error
3418 (cond 3441 (cond
3419 ((eq exit 'permission-denied) "Permission denied") 3442 ((eq exit 'permission-denied) "Permission denied")
3420 ((eq exit 'process-died) "Process died") 3443 ((eq exit 'process-died)
3421 (t "Login failed")))) 3444 (concat
3422 (when (numberp pos) 3445 "Tramp failed to connect. If this happens repeatedly, try\n"
3423 (with-current-buffer (tramp-get-connection-buffer vec) 3446 " `M-x tramp-cleanup-this-connection'"))
3424 (let (buffer-read-only) (delete-region pos (point))))))))) 3447 ((eq exit 'timeout)
3448 (format
3449 "Timeout reached, see buffer `%s' for details"
3450 (tramp-get-connection-buffer vec)))
3451 (t "Login failed")))))
3452 (when (numberp pos)
3453 (with-current-buffer (tramp-get-connection-buffer vec)
3454 (let (buffer-read-only) (delete-region pos (point))))))))
3425 3455
3426:;; Utility functions: 3456:;; Utility functions:
3427 3457
@@ -4156,6 +4186,9 @@ Only works for Bourne-like shells."
4156;; * Run emerge on two remote files. Bug is described here: 4186;; * Run emerge on two remote files. Bug is described here:
4157;; <http://www.mail-archive.com/tramp-devel@nongnu.org/msg01041.html>. 4187;; <http://www.mail-archive.com/tramp-devel@nongnu.org/msg01041.html>.
4158;; (Bug#6850) 4188;; (Bug#6850)
4189;; * Use also port to distinguish connections. This is needed for
4190;; different hosts sitting behind a single router (distinguished by
4191;; different port numbers). (Tzvi Edelman)
4159 4192
4160;;; tramp.el ends here 4193;;; tramp.el ends here
4161 4194
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 9077bdbb513..a3bd000a4f3 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6892,7 +6892,7 @@ comment at the start of cc-engine.el for more info."
6892 (while (and (looking-at c-type-decl-prefix-key) 6892 (while (and (looking-at c-type-decl-prefix-key)
6893 (if (and (c-major-mode-is 'c++-mode) 6893 (if (and (c-major-mode-is 'c++-mode)
6894 (match-beginning 3)) 6894 (match-beginning 3))
6895 ;; If the second submatch matches in C++ then 6895 ;; If the third submatch matches in C++ then
6896 ;; we're looking at an identifier that's a 6896 ;; we're looking at an identifier that's a
6897 ;; prefix only if it specifies a member pointer. 6897 ;; prefix only if it specifies a member pointer.
6898 (when (setq got-identifier (c-forward-name)) 6898 (when (setq got-identifier (c-forward-name))
@@ -7193,19 +7193,23 @@ comment at the start of cc-engine.el for more info."
7193 ;; uncommon (e.g. some placements of "const" in C++) it's not worth 7193 ;; uncommon (e.g. some placements of "const" in C++) it's not worth
7194 ;; the effort to look for them.) 7194 ;; the effort to look for them.)
7195 7195
7196 (unless (or at-decl-end (looking-at "=[^=]")) 7196;;; 2008-04-16: commented out the next form, to allow the function to recognize
7197 ;; If this is a declaration it should end here or its initializer(*) 7197;;; "foo (int bar)" in CC (an implicit type (in class foo) without a semicolon)
7198 ;; should start here, so check for allowed separation tokens. Note 7198;;; as a(n almost complete) declaration, enabling it to be fontified.
7199 ;; that this rule doesn't work e.g. with a K&R arglist after a 7199 ;; CASE 13
7200 ;; function header. 7200 ;; (unless (or at-decl-end (looking-at "=[^=]"))
7201 ;; 7201 ;; If this is a declaration it should end here or its initializer(*)
7202 ;; *) Don't check for C++ style initializers using parens 7202 ;; should start here, so check for allowed separation tokens. Note
7203 ;; since those already have been matched as suffixes. 7203 ;; that this rule doesn't work e.g. with a K&R arglist after a
7204 ;; 7204 ;; function header.
7205 ;; If `at-decl-or-cast' is then we've found some other sign that 7205 ;;
7206 ;; it's a declaration or cast, so then it's probably an 7206 ;; *) Don't check for C++ style initializers using parens
7207 ;; invalid/unfinished one. 7207 ;; since those already have been matched as suffixes.
7208 (throw 'at-decl-or-cast at-decl-or-cast)) 7208 ;;
7209 ;; If `at-decl-or-cast' is then we've found some other sign that
7210 ;; it's a declaration or cast, so then it's probably an
7211 ;; invalid/unfinished one.
7212 ;; (throw 'at-decl-or-cast at-decl-or-cast))
7209 7213
7210 ;; Below are tests that only should be applied when we're certain to 7214 ;; Below are tests that only should be applied when we're certain to
7211 ;; not have parsed halfway through an expression. 7215 ;; not have parsed halfway through an expression.
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 55d5b8b0be7..85a9074760d 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -387,10 +387,10 @@ Intended as the value of `indent-line-function'."
387 (skip-chars-forward " \t") 387 (skip-chars-forward " \t")
388 (current-column))) 388 (current-column)))
389 (error nil))) 389 (error nil)))
390 ;; Inside a string and it starts before this line. 390 ;; Inside a string and it starts before this line: do nothing.
391 ((and (nth 3 parse) 391 ((and (nth 3 parse)
392 (< (nth 8 parse) (save-excursion (beginning-of-line) (point)))) 392 (< (nth 8 parse) (save-excursion (beginning-of-line) (point))))
393 (indent-line-to 0)) 393 )
394 394
395 ;; Inside a defun, but not a nested list (depth is 1). This is 395 ;; Inside a defun, but not a nested list (depth is 1). This is
396 ;; a promise, usually. 396 ;; a promise, usually.
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 4957b58d469..6a71ab330a8 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -33,12 +33,12 @@
33 33
34;;; Code: 34;;; Code:
35 35
36(require 'cl-lib)
36(require 'easymenu) 37(require 'easymenu)
37(require 'view) 38(require 'view)
38(require 'ebuff-menu) 39(require 'ebuff-menu)
39 40
40(eval-when-compile 41(eval-when-compile
41 (require 'cl-lib)
42 (require 'helper)) 42 (require 'helper))
43 43
44 44
@@ -233,19 +233,6 @@ Compare items with `eq' or TEST if specified."
233 found)) 233 found))
234 234
235 235
236(defun ebrowse-delete-if-not (predicate list)
237 "Remove elements not satisfying PREDICATE from LIST and return the result.
238This is a destructive operation."
239 (let (result)
240 (while list
241 (let ((next (cdr list)))
242 (when (funcall predicate (car list))
243 (setq result (nconc result list))
244 (setf (cdr list) nil))
245 (setq list next)))
246 result))
247
248
249(defmacro ebrowse-output (&rest body) 236(defmacro ebrowse-output (&rest body)
250 "Eval BODY with a writable current buffer. 237 "Eval BODY with a writable current buffer.
251Preserve buffer's modified state." 238Preserve buffer's modified state."
@@ -1310,17 +1297,17 @@ With PREFIX, insert that many filenames."
1310 1297
1311(defun ebrowse-browser-buffer-list () 1298(defun ebrowse-browser-buffer-list ()
1312 "Return a list of all tree or member buffers." 1299 "Return a list of all tree or member buffers."
1313 (ebrowse-delete-if-not 'ebrowse-buffer-p (buffer-list))) 1300 (cl-delete-if-not 'ebrowse-buffer-p (buffer-list)))
1314 1301
1315 1302
1316(defun ebrowse-member-buffer-list () 1303(defun ebrowse-member-buffer-list ()
1317 "Return a list of all member buffers." 1304 "Return a list of all member buffers."
1318 (ebrowse-delete-if-not 'ebrowse-member-buffer-p (buffer-list))) 1305 (cl-delete-if-not 'ebrowse-member-buffer-p (buffer-list)))
1319 1306
1320 1307
1321(defun ebrowse-tree-buffer-list () 1308(defun ebrowse-tree-buffer-list ()
1322 "Return a list of all tree buffers." 1309 "Return a list of all tree buffers."
1323 (ebrowse-delete-if-not 'ebrowse-tree-buffer-p (buffer-list))) 1310 (cl-delete-if-not 'ebrowse-tree-buffer-p (buffer-list)))
1324 1311
1325 1312
1326(defun ebrowse-known-class-trees-buffer-list () 1313(defun ebrowse-known-class-trees-buffer-list ()
@@ -1341,7 +1328,7 @@ one buffer. Prefer tree buffers over member buffers."
1341 1328
1342(defun ebrowse-same-tree-member-buffer-list () 1329(defun ebrowse-same-tree-member-buffer-list ()
1343 "Return a list of members buffers with same tree as current buffer." 1330 "Return a list of members buffers with same tree as current buffer."
1344 (ebrowse-delete-if-not 1331 (cl-delete-if-not
1345 (lambda (buffer) 1332 (lambda (buffer)
1346 (eq (buffer-local-value 'ebrowse--tree buffer) 1333 (eq (buffer-local-value 'ebrowse--tree buffer)
1347 ebrowse--tree)) 1334 ebrowse--tree))
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 2c4d6a0e3d7..10472ec5815 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1759,6 +1759,9 @@ static char *magick[] = {
1759As long as GDB is in the recursive reading loop, it does not expect 1759As long as GDB is in the recursive reading loop, it does not expect
1760commands to be prefixed by \"-interpreter-exec console\".") 1760commands to be prefixed by \"-interpreter-exec console\".")
1761 1761
1762(defun gdb-strip-string-backslash (string)
1763 (replace-regexp-in-string "\\\\$" "" string))
1764
1762(defun gdb-send (proc string) 1765(defun gdb-send (proc string)
1763 "A comint send filter for gdb." 1766 "A comint send filter for gdb."
1764 (with-current-buffer gud-comint-buffer 1767 (with-current-buffer gud-comint-buffer
@@ -1766,10 +1769,15 @@ commands to be prefixed by \"-interpreter-exec console\".")
1766 (remove-text-properties (point-min) (point-max) '(face)))) 1769 (remove-text-properties (point-min) (point-max) '(face))))
1767 ;; mimic <RET> key to repeat previous command in GDB 1770 ;; mimic <RET> key to repeat previous command in GDB
1768 (if (not (string= "" string)) 1771 (if (not (string= "" string))
1769 (setq gdb-last-command string) 1772 (if gdb-continuation
1770 (if gdb-last-command (setq string gdb-last-command))) 1773 (setq gdb-last-command (concat gdb-continuation
1771 (if (or (string-match "^-" string) 1774 (gdb-strip-string-backslash string)
1772 (> gdb-control-level 0)) 1775 " "))
1776 (setq gdb-last-command (gdb-strip-string-backslash string)))
1777 (if gdb-last-command (setq string gdb-last-command))
1778 (setq gdb-continuation nil))
1779 (if (and (not gdb-continuation) (or (string-match "^-" string)
1780 (> gdb-control-level 0)))
1773 ;; Either MI command or we are feeding GDB's recursive reading loop. 1781 ;; Either MI command or we are feeding GDB's recursive reading loop.
1774 (progn 1782 (progn
1775 (setq gdb-first-done-or-error t) 1783 (setq gdb-first-done-or-error t)
@@ -1779,10 +1787,13 @@ commands to be prefixed by \"-interpreter-exec console\".")
1779 (setq gdb-control-level (1- gdb-control-level)))) 1787 (setq gdb-control-level (1- gdb-control-level))))
1780 ;; CLI command 1788 ;; CLI command
1781 (if (string-match "\\\\$" string) 1789 (if (string-match "\\\\$" string)
1782 (setq gdb-continuation (concat gdb-continuation string "\n")) 1790 (setq gdb-continuation
1791 (concat gdb-continuation (gdb-strip-string-backslash
1792 string)
1793 " "))
1783 (setq gdb-first-done-or-error t) 1794 (setq gdb-first-done-or-error t)
1784 (let ((to-send (concat "-interpreter-exec console " 1795 (let ((to-send (concat "-interpreter-exec console "
1785 (gdb-mi-quote string) 1796 (gdb-mi-quote (concat gdb-continuation string " "))
1786 "\n"))) 1797 "\n")))
1787 (if gdb-enable-debug 1798 (if gdb-enable-debug
1788 (push (cons 'mi-send to-send) gdb-debug-log)) 1799 (push (cons 'mi-send to-send) gdb-debug-log))
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 915b52ce04d..62870f9085b 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3091,7 +3091,12 @@ you are doing."
3091 ;; Stop collecting nodes after moving to a position with 3091 ;; Stop collecting nodes after moving to a position with
3092 ;; indentation equaling min-indent. This is specially 3092 ;; indentation equaling min-indent. This is specially
3093 ;; useful for navigating nested definitions recursively. 3093 ;; useful for navigating nested definitions recursively.
3094 tree) 3094 (if (> num-children 0)
3095 tree
3096 ;; When there are no children, the collected tree is a
3097 ;; single node intended to be added in the list of defuns
3098 ;; of its parent.
3099 (car tree)))
3095 (t 3100 (t
3096 (python-imenu--build-tree 3101 (python-imenu--build-tree
3097 min-indent 3102 min-indent
@@ -3131,7 +3136,7 @@ you are doing."
3131 (cons 3136 (cons
3132 (prog1 3137 (prog1
3133 (python-imenu--build-tree 3138 (python-imenu--build-tree
3134 prev-indent indent 1 (list (cons label pos))) 3139 prev-indent indent 0 (list (cons label pos)))
3135 ;; Adjustment: after scanning backwards 3140 ;; Adjustment: after scanning backwards
3136 ;; for all deeper children, we need to 3141 ;; for all deeper children, we need to
3137 ;; continue our scan for a parent from 3142 ;; continue our scan for a parent from
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 0292e40b986..0b83921504b 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -990,13 +990,14 @@ calculating indentation on the lines after it."
990(defun ruby-move-to-block (n) 990(defun ruby-move-to-block (n)
991 "Move to the beginning (N < 0) or the end (N > 0) of the 991 "Move to the beginning (N < 0) or the end (N > 0) of the
992current block, a sibling block, or an outer block. Do that (abs N) times." 992current block, a sibling block, or an outer block. Do that (abs N) times."
993 (back-to-indentation)
993 (let ((signum (if (> n 0) 1 -1)) 994 (let ((signum (if (> n 0) 1 -1))
994 (backward (< n 0)) 995 (backward (< n 0))
995 (depth (or (nth 2 (ruby-parse-region (line-beginning-position) 996 (depth (or (nth 2 (ruby-parse-region (point) (line-end-position))) 0))
996 (line-end-position)))
997 0))
998 case-fold-search 997 case-fold-search
999 down done) 998 down done)
999 (when (looking-at ruby-block-mid-re)
1000 (setq depth (+ depth signum)))
1000 (when (< (* depth signum) 0) 1001 (when (< (* depth signum) 0)
1001 ;; Moving end -> end or beginning -> beginning. 1002 ;; Moving end -> end or beginning -> beginning.
1002 (setq depth 0)) 1003 (setq depth 0))
@@ -1033,22 +1034,16 @@ current block, a sibling block, or an outer block. Do that (abs N) times."
1033 (unless (car state) ; Line ends with unfinished string. 1034 (unless (car state) ; Line ends with unfinished string.
1034 (setq depth (+ (nth 2 state) depth)))) 1035 (setq depth (+ (nth 2 state) depth))))
1035 (cond 1036 (cond
1036 ;; Deeper indentation, we found a block. 1037 ;; Increased depth, we found a block.
1037 ;; FIXME: We can't recognize empty blocks this way.
1038 ((> (* signum depth) 0) 1038 ((> (* signum depth) 0)
1039 (setq down t)) 1039 (setq down t))
1040 ;; Block found, and same indentation as when started, stop. 1040 ;; We're at the same depth as when we started, and we've
1041 ;; encountered a block before. Stop.
1041 ((and down (zerop depth)) 1042 ((and down (zerop depth))
1042 (setq done t)) 1043 (setq done t))
1043 ;; Shallower indentation, means outer block, can stop now. 1044 ;; Lower depth, means outer block, can stop now.
1044 ((< (* signum depth) 0) 1045 ((< (* signum depth) 0)
1045 (setq done t))))) 1046 (setq done t)))))))
1046 (if done
1047 (save-excursion
1048 (back-to-indentation)
1049 ;; Not really at the first or last line of the block, move on.
1050 (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>"))
1051 (setq done nil))))))
1052 (back-to-indentation))) 1047 (back-to-indentation)))
1053 1048
1054(defun ruby-beginning-of-block (&optional arg) 1049(defun ruby-beginning-of-block (&optional arg)
@@ -1356,7 +1351,7 @@ If the result is do-end block, it will always be multiline."
1356 (progn 1351 (progn
1357 (eval-and-compile 1352 (eval-and-compile
1358 (defconst ruby-percent-literal-beg-re 1353 (defconst ruby-percent-literal-beg-re
1359 "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)" 1354 "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)"
1360 "Regexp to match the beginning of percent literal.") 1355 "Regexp to match the beginning of percent literal.")
1361 1356
1362 (defconst ruby-syntax-methods-before-regexp 1357 (defconst ruby-syntax-methods-before-regexp
@@ -1392,7 +1387,7 @@ It will be properly highlighted even when the call omits parens.")
1392 (funcall 1387 (funcall
1393 (syntax-propertize-rules 1388 (syntax-propertize-rules
1394 ;; $' $" $` .... are variables. 1389 ;; $' $" $` .... are variables.
1395 ;; ?' ?" ?` are ascii codes. 1390 ;; ?' ?" ?` are character literals (one-char strings in 1.9+).
1396 ("\\([?$]\\)[#\"'`]" 1391 ("\\([?$]\\)[#\"'`]"
1397 (1 (unless (save-excursion 1392 (1 (unless (save-excursion
1398 ;; Not within a string. 1393 ;; Not within a string.
@@ -1523,7 +1518,7 @@ It will be properly highlighted even when the call omits parens.")
1523 (save-match-data 1518 (save-match-data
1524 (save-excursion 1519 (save-excursion
1525 (goto-char (nth 8 parse-state)) 1520 (goto-char (nth 8 parse-state))
1526 (looking-at "%\\(?:[QWrx]\\|\\W\\)"))))))) 1521 (looking-at "%\\(?:[QWrxI]\\|\\W\\)")))))))
1527 1522
1528 (defun ruby-syntax-propertize-expansions (start end) 1523 (defun ruby-syntax-propertize-expansions (start end)
1529 (save-excursion 1524 (save-excursion
@@ -1726,7 +1721,7 @@ See `font-lock-syntax-table'.")
1726(defconst ruby-font-lock-keywords 1721(defconst ruby-font-lock-keywords
1727 (list 1722 (list
1728 ;; functions 1723 ;; functions
1729 '("^\\s *def\\s +\\([^( \t\n]+\\)" 1724 '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)"
1730 1 font-lock-function-name-face) 1725 1 font-lock-function-name-face)
1731 (list (concat 1726 (list (concat
1732 "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" 1727 "\\(^\\|[^.@$]\\|\\.\\.\\)\\("
@@ -1767,31 +1762,66 @@ See `font-lock-syntax-table'.")
1767 "yield") 1762 "yield")
1768 'symbols) 1763 'symbols)
1769 "\\|" 1764 "\\|"
1770 ;; keyword-like methods on Kernel and Module
1771 (regexp-opt 1765 (regexp-opt
1772 '("alias_method" 1766 ;; built-in methods on Kernel
1767 '("__callee__"
1768 "__dir__"
1769 "__method__"
1770 "abort"
1771 "at_exit"
1773 "autoload" 1772 "autoload"
1773 "autoload?"
1774 "binding"
1775 "block_given?"
1776 "caller"
1777 "catch"
1778 "eval"
1779 "exec"
1780 "exit"
1781 "exit!"
1782 "fail"
1783 "fork"
1784 "format"
1785 "lambda"
1786 "load"
1787 "loop"
1788 "open"
1789 "p"
1790 "print"
1791 "printf"
1792 "proc"
1793 "putc"
1794 "puts"
1795 "raise"
1796 "rand"
1797 "readline"
1798 "readlines"
1799 "require"
1800 "require_relative"
1801 "sleep"
1802 "spawn"
1803 "sprintf"
1804 "srand"
1805 "syscall"
1806 "system"
1807 "throw"
1808 "trap"
1809 "warn"
1810 ;; keyword-like private methods on Module
1811 "alias_method"
1774 "attr" 1812 "attr"
1775 "attr_accessor" 1813 "attr_accessor"
1776 "attr_reader" 1814 "attr_reader"
1777 "attr_writer" 1815 "attr_writer"
1778 "catch"
1779 "define_method" 1816 "define_method"
1780 "extend" 1817 "extend"
1781 "fail"
1782 "include" 1818 "include"
1783 "lambda"
1784 "loop"
1785 "module_function" 1819 "module_function"
1820 "prepend"
1786 "private" 1821 "private"
1787 "proc"
1788 "protected" 1822 "protected"
1789 "public" 1823 "public"
1790 "raise"
1791 "refine" 1824 "refine"
1792 "require"
1793 "require_relative"
1794 "throw"
1795 "using") 1825 "using")
1796 'symbols) 1826 'symbols)
1797 "\\)") 1827 "\\)")
@@ -1799,12 +1829,16 @@ See `font-lock-syntax-table'.")
1799 '(if (match-beginning 4) 1829 '(if (match-beginning 4)
1800 font-lock-builtin-face 1830 font-lock-builtin-face
1801 font-lock-keyword-face)) 1831 font-lock-keyword-face))
1832 ;; Perl-ish keywords
1833 "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
1802 ;; here-doc beginnings 1834 ;; here-doc beginnings
1803 `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 1835 `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0))
1804 'font-lock-string-face)) 1836 'font-lock-string-face))
1805 ;; variables 1837 ;; variables
1806 '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>" 1838 '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>"
1807 2 font-lock-variable-name-face) 1839 2 font-lock-variable-name-face)
1840 ;; keywords that evaluate to certain values
1841 '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face)
1808 ;; symbols 1842 ;; symbols
1809 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)" 1843 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
1810 2 font-lock-constant-face) 1844 2 font-lock-constant-face)
@@ -1815,14 +1849,22 @@ See `font-lock-syntax-table'.")
1815 0 font-lock-variable-name-face) 1849 0 font-lock-variable-name-face)
1816 ;; constants 1850 ;; constants
1817 '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 1851 '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)"
1818 1 font-lock-type-face) 1852 1 (unless (eq ?\( (char-after)) font-lock-type-face))
1819 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) 1853 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face)
1854 ;; conversion methods on Kernel
1855 (list (concat "\\(?:^\\|[^.@$]\\|\\.\\.\\)"
1856 (regexp-opt '("Array" "Complex" "Float" "Hash"
1857 "Integer" "Rational" "String") 'symbols))
1858 1 font-lock-builtin-face)
1820 ;; expression expansion 1859 ;; expression expansion
1821 '(ruby-match-expression-expansion 1860 '(ruby-match-expression-expansion
1822 2 font-lock-variable-name-face t) 1861 2 font-lock-variable-name-face t)
1823 ;; warn lower camel case 1862 ;; negation char
1824 ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)" 1863 '("[^[:alnum:]_]\\(!\\)[^=]"
1825 ; 0 font-lock-warning-face) 1864 1 font-lock-negation-char-face)
1865 ;; character literals
1866 ;; FIXME: Support longer escape sequences.
1867 '("\\?\\\\?\\S " 0 font-lock-string-face)
1826 ) 1868 )
1827 "Additional expressions to highlight in Ruby mode.") 1869 "Additional expressions to highlight in Ruby mode.")
1828 1870
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el
index ec6e6e7ff10..3e7789069f9 100644
--- a/lisp/shadowfile.el
+++ b/lisp/shadowfile.el
@@ -74,6 +74,7 @@
74 74
75;;; Code: 75;;; Code:
76 76
77(require 'cl-lib)
77(require 'ange-ftp) 78(require 'ange-ftp)
78 79
79;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -180,15 +181,6 @@ created by `shadow-define-regexp-group'.")
180 (setq list (cdr list))) 181 (setq list (cdr list)))
181 (car list)) 182 (car list))
182 183
183(defun shadow-remove-if (func list)
184 "Remove elements satisfying FUNC from LIST.
185Nondestructive; actually returns a copy of the list with the elements removed."
186 (if list
187 (if (funcall func (car list))
188 (shadow-remove-if func (cdr list))
189 (cons (car list) (shadow-remove-if func (cdr list))))
190 nil))
191
192(defun shadow-regexp-superquote (string) 184(defun shadow-regexp-superquote (string)
193 "Like `regexp-quote', but includes the ^ and $. 185 "Like `regexp-quote', but includes the ^ and $.
194This makes sure regexp matches nothing but STRING." 186This makes sure regexp matches nothing but STRING."
@@ -238,9 +230,8 @@ instead."
238Replace old definition, if any. PRIMARY and REGEXP are the 230Replace old definition, if any. PRIMARY and REGEXP are the
239information defining the cluster. For interactive use, call 231information defining the cluster. For interactive use, call
240`shadow-define-cluster' instead." 232`shadow-define-cluster' instead."
241 (let ((rest (shadow-remove-if 233 (let ((rest (cl-remove-if (lambda (x) (equal name (car x)))
242 (function (lambda (x) (equal name (car x)))) 234 shadow-clusters)))
243 shadow-clusters)))
244 (setq shadow-clusters 235 (setq shadow-clusters
245 (cons (shadow-make-cluster name primary regexp) 236 (cons (shadow-make-cluster name primary regexp)
246 rest)))) 237 rest))))
@@ -602,9 +593,8 @@ and to are absolute file names."
602Consider them as regular expressions if third arg REGEXP is true." 593Consider them as regular expressions if third arg REGEXP is true."
603 (if groups 594 (if groups
604 (let ((nonmatching 595 (let ((nonmatching
605 (shadow-remove-if 596 (cl-remove-if (lambda (x) (shadow-file-match x file regexp))
606 (function (lambda (x) (shadow-file-match x file regexp))) 597 (car groups))))
607 (car groups))))
608 (append (cond ((equal nonmatching (car groups)) nil) 598 (append (cond ((equal nonmatching (car groups)) nil)
609 (regexp 599 (regexp
610 (let ((realname (nth 2 (shadow-parse-fullname file)))) 600 (let ((realname (nth 2 (shadow-parse-fullname file))))
@@ -635,8 +625,7 @@ Consider them as regular expressions if third arg REGEXP is true."
635 "Remove PAIR from `shadow-files-to-copy'. 625 "Remove PAIR from `shadow-files-to-copy'.
636PAIR must be `eq' to one of the elements of that list." 626PAIR must be `eq' to one of the elements of that list."
637 (setq shadow-files-to-copy 627 (setq shadow-files-to-copy
638 (shadow-remove-if (function (lambda (s) (eq s pair))) 628 (cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy)))
639 shadow-files-to-copy)))
640 629
641(defun shadow-read-files () 630(defun shadow-read-files ()
642 "Visit and load `shadow-info-file' and `shadow-todo-file'. 631 "Visit and load `shadow-info-file' and `shadow-todo-file'.
diff --git a/lisp/simple.el b/lisp/simple.el
index 61f32363dbe..3e3ff485c5e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4602,6 +4602,12 @@ for it.")
4602(defun next-line (&optional arg try-vscroll) 4602(defun next-line (&optional arg try-vscroll)
4603 "Move cursor vertically down ARG lines. 4603 "Move cursor vertically down ARG lines.
4604Interactively, vscroll tall lines if `auto-window-vscroll' is enabled. 4604Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
4605Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
4606lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
4607function will not vscroll.
4608
4609ARG defaults to 1.
4610
4605If there is no character in the target line exactly under the current column, 4611If there is no character in the target line exactly under the current column,
4606the cursor is positioned after the character in that line which spans this 4612the cursor is positioned after the character in that line which spans this
4607column, or at the end of the line if it is not long enough. 4613column, or at the end of the line if it is not long enough.
@@ -4646,6 +4652,12 @@ and more reliable (no dependence on goal column, etc.)."
4646(defun previous-line (&optional arg try-vscroll) 4652(defun previous-line (&optional arg try-vscroll)
4647 "Move cursor vertically up ARG lines. 4653 "Move cursor vertically up ARG lines.
4648Interactively, vscroll tall lines if `auto-window-vscroll' is enabled. 4654Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
4655Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
4656lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
4657function will not vscroll.
4658
4659ARG defaults to 1.
4660
4649If there is no character in the target line exactly over the current column, 4661If there is no character in the target line exactly over the current column,
4650the cursor is positioned after the character in that line which spans this 4662the cursor is positioned after the character in that line which spans this
4651column, or at the end of the line if it is not long enough. 4663column, or at the end of the line if it is not long enough.
@@ -4725,33 +4737,81 @@ lines."
4725 :group 'editing-basics 4737 :group 'editing-basics
4726 :version "23.1") 4738 :version "23.1")
4727 4739
4740(defun default-font-height ()
4741 "Return the height in pixels of the current buffer's default face font."
4742 (let ((default-font (face-font 'default)))
4743 (cond
4744 ((and (display-multi-font-p)
4745 ;; Avoid calling font-info if the frame's default font was
4746 ;; not changed since the frame was created. That's because
4747 ;; font-info is expensive for some fonts, see bug #14838.
4748 (not (string= (frame-parameter nil 'font) default-font)))
4749 (aref (font-info default-font) 3))
4750 (t (frame-char-height)))))
4751
4752(defun default-line-height ()
4753 "Return the pixel height of current buffer's default-face text line.
4754
4755The value includes `line-spacing', if any, defined for the buffer
4756or the frame."
4757 (let ((dfh (default-font-height))
4758 (lsp (if (display-graphic-p)
4759 (or line-spacing
4760 (default-value 'line-spacing)
4761 (frame-parameter nil 'line-spacing)
4762 0)
4763 0)))
4764 (if (floatp lsp)
4765 (setq lsp (* dfh lsp)))
4766 (+ dfh lsp)))
4767
4768(defun window-screen-lines ()
4769 "Return the number of screen lines in the text area of the selected window.
4770
4771This is different from `window-text-height' in that this function counts
4772lines in units of the height of the font used by the default face displayed
4773in the window, not in units of the frame's default font, and also accounts
4774for `line-spacing', if any, defined for the window's buffer or frame.
4775
4776The value is a floating-point number."
4777 (let ((canonical (window-text-height))
4778 (fch (frame-char-height))
4779 (dlh (default-line-height)))
4780 (/ (* (float canonical) fch) dlh)))
4781
4728;; Returns non-nil if partial move was done. 4782;; Returns non-nil if partial move was done.
4729(defun line-move-partial (arg noerror to-end) 4783(defun line-move-partial (arg noerror to-end)
4730 (if (< arg 0) 4784 (if (< arg 0)
4731 ;; Move backward (up). 4785 ;; Move backward (up).
4732 ;; If already vscrolled, reduce vscroll 4786 ;; If already vscrolled, reduce vscroll
4733 (let ((vs (window-vscroll nil t))) 4787 (let ((vs (window-vscroll nil t))
4734 (when (> vs (frame-char-height)) 4788 (dlh (default-line-height)))
4735 (set-window-vscroll nil (- vs (frame-char-height)) t))) 4789 (when (> vs dlh)
4790 (set-window-vscroll nil (- vs dlh) t)))
4736 4791
4737 ;; Move forward (down). 4792 ;; Move forward (down).
4738 (let* ((lh (window-line-height -1)) 4793 (let* ((lh (window-line-height -1))
4794 (rowh (car lh))
4739 (vpos (nth 1 lh)) 4795 (vpos (nth 1 lh))
4740 (ypos (nth 2 lh)) 4796 (ypos (nth 2 lh))
4741 (rbot (nth 3 lh)) 4797 (rbot (nth 3 lh))
4742 (this-lh (window-line-height)) 4798 (this-lh (window-line-height))
4743 (this-height (nth 0 this-lh)) 4799 (this-height (car this-lh))
4744 (this-ypos (nth 2 this-lh)) 4800 (this-ypos (nth 2 this-lh))
4745 (fch (frame-char-height)) 4801 (dlh (default-line-height))
4746 py vs) 4802 (wslines (window-screen-lines))
4803 py vs last-line)
4804 (if (> (mod wslines 1.0) 0.0)
4805 (setq wslines (round (+ wslines 0.5))))
4747 (when (or (null lh) 4806 (when (or (null lh)
4748 (>= rbot fch) 4807 (>= rbot dlh)
4749 (<= ypos (- fch)) 4808 (<= ypos (- dlh))
4750 (null this-lh) 4809 (null this-lh)
4751 (<= this-ypos (- fch))) 4810 (<= this-ypos (- dlh)))
4752 (unless lh 4811 (unless lh
4753 (let ((wend (pos-visible-in-window-p t nil t))) 4812 (let ((wend (pos-visible-in-window-p t nil t)))
4754 (setq rbot (nth 3 wend) 4813 (setq rbot (nth 3 wend)
4814 rowh (nth 4 wend)
4755 vpos (nth 5 wend)))) 4815 vpos (nth 5 wend))))
4756 (unless this-lh 4816 (unless this-lh
4757 (let ((wstart (pos-visible-in-window-p nil nil t))) 4817 (let ((wstart (pos-visible-in-window-p nil nil t)))
@@ -4759,38 +4819,63 @@ lines."
4759 this-height (nth 4 wstart)))) 4819 this-height (nth 4 wstart))))
4760 (setq py 4820 (setq py
4761 (or (nth 1 this-lh) 4821 (or (nth 1 this-lh)
4762 (let ((ppos (posn-at-point))) 4822 (let ((ppos (posn-at-point))
4763 (cdr (or (posn-actual-col-row ppos) 4823 col-row)
4764 (posn-col-row ppos)))))) 4824 (setq col-row (posn-actual-col-row ppos))
4825 (if col-row
4826 (- (cdr col-row) (window-vscroll))
4827 (cdr (posn-col-row ppos))))))
4828 ;; VPOS > 0 means the last line is only partially visible.
4829 ;; But if the part that is visible is at least as tall as the
4830 ;; default font, that means the line is actually fully
4831 ;; readable, and something like line-spacing is hidden. So in
4832 ;; that case we accept the last line in the window as still
4833 ;; visible, and consider the margin as starting one line
4834 ;; later.
4835 (if (and vpos (> vpos 0))
4836 (if (and rowh
4837 (>= rowh (default-font-height))
4838 (< rowh dlh))
4839 (setq last-line (min (- wslines scroll-margin) vpos))
4840 (setq last-line (min (- wslines scroll-margin 1) (1- vpos)))))
4765 (cond 4841 (cond
4766 ;; If last line of window is fully visible, and vscrolling 4842 ;; If last line of window is fully visible, and vscrolling
4767 ;; more would make this line invisible, move forward. 4843 ;; more would make this line invisible, move forward.
4768 ((and (or (< (setq vs (window-vscroll nil t)) fch) 4844 ((and (or (< (setq vs (window-vscroll nil t)) dlh)
4769 (null this-height) 4845 (null this-height)
4770 (<= this-height fch)) 4846 (<= this-height dlh))
4771 (or (null rbot) (= rbot 0))) 4847 (or (null rbot) (= rbot 0)))
4772 nil) 4848 nil)
4773 ;; If cursor is not in the bottom scroll margin, and the 4849 ;; If cursor is not in the bottom scroll margin, and the
4774 ;; current line is is not too tall, move forward. 4850 ;; current line is is not too tall, move forward.
4775 ((and (or (null this-height) (<= this-height fch)) 4851 ((and (or (null this-height) (<= this-height dlh))
4776 vpos 4852 vpos
4777 (> vpos 0) 4853 (> vpos 0)
4778 (< py 4854 (< py last-line))
4779 (min (- (window-text-height) scroll-margin 1) (1- vpos))))
4780 nil) 4855 nil)
4781 ;; When already vscrolled, we vscroll some more if we can, 4856 ;; When already vscrolled, we vscroll some more if we can,
4782 ;; or clear vscroll and move forward at end of tall image. 4857 ;; or clear vscroll and move forward at end of tall image.
4783 ((> vs 0) 4858 ((> vs 0)
4784 (when (or (and rbot (> rbot 0)) 4859 (when (or (and rbot (> rbot 0))
4785 (and this-height (> this-height fch))) 4860 (and this-height (> this-height dlh)))
4786 (set-window-vscroll nil (+ vs fch) t))) 4861 (set-window-vscroll nil (+ vs dlh) t)))
4787 ;; If cursor just entered the bottom scroll margin, move forward, 4862 ;; If cursor just entered the bottom scroll margin, move forward,
4788 ;; but also vscroll one line so redisplay won't recenter. 4863 ;; but also optionally vscroll one line so redisplay won't recenter.
4789 ((and vpos 4864 ((and vpos
4790 (> vpos 0) 4865 (> vpos 0)
4791 (= py (min (- (window-text-height) scroll-margin 1) 4866 (= py last-line))
4792 (1- vpos)))) 4867 ;; Don't vscroll if the partially-visible line at window
4793 (set-window-vscroll nil (frame-char-height) t) 4868 ;; bottom has the default height (a.k.a. "just one more text
4869 ;; line"): in that case, we do want redisplay to behave
4870 ;; normally, i.e. recenter or whatever.
4871 ;;
4872 ;; Note: ROWH + RBOT from the value returned by
4873 ;; pos-visible-in-window-p give the total height of the
4874 ;; partially-visible glyph row at the end of the window. As
4875 ;; we are dealing with floats, we disregard sub-pixel
4876 ;; discrepancies between that and DLH.
4877 (if (and rowh rbot (>= (- (+ rowh rbot) dlh) 1))
4878 (set-window-vscroll nil dlh t))
4794 (line-move-1 arg noerror to-end) 4879 (line-move-1 arg noerror to-end)
4795 t) 4880 t)
4796 ;; If there are lines above the last line, scroll-up one line. 4881 ;; If there are lines above the last line, scroll-up one line.
@@ -4799,7 +4884,7 @@ lines."
4799 t) 4884 t)
4800 ;; Finally, start vscroll. 4885 ;; Finally, start vscroll.
4801 (t 4886 (t
4802 (set-window-vscroll nil (frame-char-height) t))))))) 4887 (set-window-vscroll nil dlh t)))))))
4803 4888
4804 4889
4805;; This is like line-move-1 except that it also performs 4890;; This is like line-move-1 except that it also performs
@@ -4832,11 +4917,14 @@ lines."
4832 (prog1 (line-move-visual arg noerror) 4917 (prog1 (line-move-visual arg noerror)
4833 ;; If we moved into a tall line, set vscroll to make 4918 ;; If we moved into a tall line, set vscroll to make
4834 ;; scrolling through tall images more smooth. 4919 ;; scrolling through tall images more smooth.
4835 (let ((lh (line-pixel-height))) 4920 (let ((lh (line-pixel-height))
4921 (dlh (default-line-height)))
4836 (if (and (< arg 0) 4922 (if (and (< arg 0)
4837 (< (point) (window-start)) 4923 (< (point) (window-start))
4838 (> lh (frame-char-height))) 4924 (> lh dlh))
4839 (set-window-vscroll nil (- lh (frame-char-height)) t)))) 4925 (set-window-vscroll
4926 nil
4927 (- lh dlh) t))))
4840 (line-move-1 arg noerror to-end))))) 4928 (line-move-1 arg noerror to-end)))))
4841 4929
4842;; Display-based alternative to line-move-1. 4930;; Display-based alternative to line-move-1.
@@ -7346,6 +7434,66 @@ warning using STRING as the message.")
7346 (with-eval-after-load pkg 7434 (with-eval-after-load pkg
7347 (bad-package-check pkg)))) 7435 (bad-package-check pkg))))
7348 7436
7437
7438;;; Generic dispatcher commands
7439
7440;; Macro `alternatives-define' is used to create generic commands.
7441;; Generic commands are these (like web, mail, news, encrypt, irc, etc.)
7442;; that can have different alternative implementations where choosing
7443;; among them is exclusively a matter of user preference.
7444
7445;; (alternatives-define COMMAND) creates a new interactive command
7446;; M-x COMMAND and a customizable variable COMMAND-alternatives.
7447;; Typically, the user will not need to customize this variable; packages
7448;; wanting to add alternative implementations should use
7449;;
7450;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives
7451
7452(defmacro alternatives-define (command &rest customizations)
7453 "Define new command `COMMAND'.
7454The variable `COMMAND-alternatives' will contain alternative
7455implementations of COMMAND, so that running `C-u M-x COMMAND'
7456will allow the user to chose among them.
7457CUSTOMIZATIONS, if non-nil, should be composed of alternating
7458`defcustom' keywords and values to add to the declaration of
7459`COMMAND-alternatives' (typically :group and :version)."
7460 (let* ((command-name (symbol-name command))
7461 (varalt-name (concat command-name "-alternatives"))
7462 (varalt-sym (intern varalt-name))
7463 (varimp-sym (intern (concat command-name "--implementation"))))
7464 `(progn
7465
7466 (defcustom ,varalt-sym nil
7467 ,(format "Alist of alternative implementations for the `%s' command.
7468
7469Each entry must be a pair (ALTNAME . ALTFUN), where:
7470ALTNAME - The name shown at user to describe the alternative implementation.
7471ALTFUN - The function called to implement this alternative."
7472 command-name)
7473 :type '(alist :key-type string :value-type function)
7474 ,@customizations)
7475
7476 (defvar ,varimp-sym nil "Internal use only.")
7477
7478 (defun ,command (&optional arg)
7479 ,(format "Run generic command `%s'.
7480If used for the first time, or with interactive ARG, ask the user which
7481implementation to use for `%s'. The variable `%s'
7482contains the list of implementations currently supported for this command."
7483 command-name command-name varalt-name)
7484 (interactive "P")
7485 (when (or arg (null ,varimp-sym))
7486 (let ((val (completing-read
7487 ,(format "Select implementation for command `%s': " command-name)
7488 ,varalt-sym nil t)))
7489 (unless (string-equal val "")
7490 (customize-save-variable ',varimp-sym
7491 (cdr (assoc-string val ,varalt-sym))))))
7492 (if ,varimp-sym
7493 (funcall ,varimp-sym)
7494 (message ,(format "No implementation selected for command `%s'"
7495 command-name)))))))
7496
7349(provide 'simple) 7497(provide 'simple)
7350 7498
7351;;; simple.el ends here 7499;;; simple.el ends here
diff --git a/lisp/subr.el b/lisp/subr.el
index b8a62023805..b6ee96f879e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1980,7 +1980,7 @@ any other terminator is used itself as input.
1980The optional argument PROMPT specifies a string to use to prompt the user. 1980The optional argument PROMPT specifies a string to use to prompt the user.
1981The variable `read-quoted-char-radix' controls which radix to use 1981The variable `read-quoted-char-radix' controls which radix to use
1982for numeric input." 1982for numeric input."
1983 (let ((message-log-max nil) done (first t) (code 0) char translated) 1983 (let ((message-log-max nil) done (first t) (code 0) translated)
1984 (while (not done) 1984 (while (not done)
1985 (let ((inhibit-quit first) 1985 (let ((inhibit-quit first)
1986 ;; Don't let C-h get the help message--only help function keys. 1986 ;; Don't let C-h get the help message--only help function keys.
@@ -1990,20 +1990,14 @@ for numeric input."
1990or the octal character code. 1990or the octal character code.
1991RET terminates the character code and is discarded; 1991RET terminates the character code and is discarded;
1992any other non-digit terminates the character code and is then used as input.")) 1992any other non-digit terminates the character code and is then used as input."))
1993 (setq char (read-event (and prompt (format "%s-" prompt)) t)) 1993 (setq translated (read-key (and prompt (format "%s-" prompt))))
1994 (if inhibit-quit (setq quit-flag nil))) 1994 (if inhibit-quit (setq quit-flag nil)))
1995 ;; Translate TAB key into control-I ASCII character, and so on.
1996 ;; Note: `read-char' does it using the `ascii-character' property.
1997 ;; We should try and use read-key instead.
1998 (let ((translation (lookup-key local-function-key-map (vector char))))
1999 (setq translated (if (arrayp translation)
2000 (aref translation 0)
2001 char)))
2002 (if (integerp translated) 1995 (if (integerp translated)
2003 (setq translated (char-resolve-modifiers translated))) 1996 (setq translated (char-resolve-modifiers translated)))
2004 (cond ((null translated)) 1997 (cond ((null translated))
2005 ((not (integerp translated)) 1998 ((not (integerp translated))
2006 (setq unread-command-events (list char) 1999 (setq unread-command-events
2000 (listify-key-sequence (this-single-command-raw-keys))
2007 done t)) 2001 done t))
2008 ((/= (logand translated ?\M-\^@) 0) 2002 ((/= (logand translated ?\M-\^@) 0)
2009 ;; Turn a meta-character into a character with the 0200 bit set. 2003 ;; Turn a meta-character into a character with the 0200 bit set.
@@ -2022,7 +2016,8 @@ any other non-digit terminates the character code and is then used as input."))
2022 ((and (not first) (eq translated ?\C-m)) 2016 ((and (not first) (eq translated ?\C-m))
2023 (setq done t)) 2017 (setq done t))
2024 ((not first) 2018 ((not first)
2025 (setq unread-command-events (list char) 2019 (setq unread-command-events
2020 (listify-key-sequence (this-single-command-raw-keys))
2026 done t)) 2021 done t))
2027 (t (setq code translated 2022 (t (setq code translated
2028 done t))) 2023 done t)))
@@ -2186,6 +2181,7 @@ An obsolete, but still supported form is
2186where the optional arg MILLISECONDS specifies an additional wait period, 2181where the optional arg MILLISECONDS specifies an additional wait period,
2187in milliseconds; this was useful when Emacs was built without 2182in milliseconds; this was useful when Emacs was built without
2188floating point support." 2183floating point support."
2184 (declare (advertised-calling-convention (seconds &optional nodisp) "22.1"))
2189 (if (numberp nodisp) 2185 (if (numberp nodisp)
2190 (setq seconds (+ seconds (* 1e-3 nodisp)) 2186 (setq seconds (+ seconds (* 1e-3 nodisp))
2191 nodisp obsolete) 2187 nodisp obsolete)
@@ -2200,7 +2196,10 @@ floating point support."
2200 (or nodisp (redisplay))) 2196 (or nodisp (redisplay)))
2201 (t 2197 (t
2202 (or nodisp (redisplay)) 2198 (or nodisp (redisplay))
2203 (let ((read (read-event nil nil seconds))) 2199 ;; FIXME: we should not read-event here at all, because it's much too
2200 ;; difficult to reliably "undo" a read-event by pushing it onto
2201 ;; unread-command-events.
2202 (let ((read (read-event nil t seconds)))
2204 (or (null read) 2203 (or (null read)
2205 (progn 2204 (progn
2206 ;; If last command was a prefix arg, e.g. C-u, push this event onto 2205 ;; If last command was a prefix arg, e.g. C-u, push this event onto
@@ -2210,7 +2209,6 @@ floating point support."
2210 (setq read (cons t read))) 2209 (setq read (cons t read)))
2211 (push read unread-command-events) 2210 (push read unread-command-events)
2212 nil)))))) 2211 nil))))))
2213(set-advertised-calling-convention 'sit-for '(seconds &optional nodisp) "22.1")
2214 2212
2215(defun y-or-n-p (prompt) 2213(defun y-or-n-p (prompt)
2216 "Ask user a \"y or n\" question. Return t if answer is \"y\". 2214 "Ask user a \"y or n\" question. Return t if answer is \"y\".
@@ -2240,7 +2238,8 @@ is nil and `use-dialog-box' is non-nil."
2240 (cond 2238 (cond
2241 (noninteractive 2239 (noninteractive
2242 (setq prompt (concat prompt 2240 (setq prompt (concat prompt
2243 (if (eq ?\s (aref prompt (1- (length prompt)))) 2241 (if (or (zerop (length prompt))
2242 (eq ?\s (aref prompt (1- (length prompt)))))
2244 "" " ") 2243 "" " ")
2245 "(y or n) ")) 2244 "(y or n) "))
2246 (let ((temp-prompt prompt)) 2245 (let ((temp-prompt prompt))
@@ -2257,7 +2256,8 @@ is nil and `use-dialog-box' is non-nil."
2257 (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) 2256 (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))))
2258 (t 2257 (t
2259 (setq prompt (concat prompt 2258 (setq prompt (concat prompt
2260 (if (eq ?\s (aref prompt (1- (length prompt)))) 2259 (if (or (zerop (length prompt))
2260 (eq ?\s (aref prompt (1- (length prompt)))))
2261 "" " ") 2261 "" " ")
2262 "(y or n) ")) 2262 "(y or n) "))
2263 (while 2263 (while
@@ -2449,11 +2449,12 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
2449 (recenter (/ (window-height) 2)))) 2449 (recenter (/ (window-height) 2))))
2450 (message (or message "Type %s to continue editing.") 2450 (message (or message "Type %s to continue editing.")
2451 (single-key-description exit-char)) 2451 (single-key-description exit-char))
2452 (let ((event (read-event))) 2452 (let ((event (read-key)))
2453 ;; `exit-char' can be an event, or an event description list. 2453 ;; `exit-char' can be an event, or an event description list.
2454 (or (eq event exit-char) 2454 (or (eq event exit-char)
2455 (eq event (event-convert-list exit-char)) 2455 (eq event (event-convert-list exit-char))
2456 (setq unread-command-events (list event))))) 2456 (setq unread-command-events
2457 (append (this-single-command-raw-keys))))))
2457 (delete-overlay ol)))) 2458 (delete-overlay ol))))
2458 2459
2459 2460
@@ -3852,6 +3853,7 @@ FILE should be the name of a library, with no directory name."
3852 (declare (obsolete eval-after-load "23.2")) 3853 (declare (obsolete eval-after-load "23.2"))
3853 (eval-after-load file (read))) 3854 (eval-after-load file (read)))
3854 3855
3856
3855(defun display-delayed-warnings () 3857(defun display-delayed-warnings ()
3856 "Display delayed warnings from `delayed-warnings-list'. 3858 "Display delayed warnings from `delayed-warnings-list'.
3857Used from `delayed-warnings-hook' (which see)." 3859Used from `delayed-warnings-hook' (which see)."
@@ -3885,6 +3887,12 @@ By default, this hook contains functions to consolidate the
3885warnings listed in `delayed-warnings-list', display them, and set 3887warnings listed in `delayed-warnings-list', display them, and set
3886`delayed-warnings-list' back to nil.") 3888`delayed-warnings-list' back to nil.")
3887 3889
3890(defun delay-warning (type message &optional level buffer-name)
3891 "Display a delayed warning.
3892Aside from going through `delayed-warnings-list', this is equivalent
3893to `display-warning'."
3894 (push (list type message level buffer-name) delayed-warnings-list))
3895
3888 3896
3889;;;; invisibility specs 3897;;;; invisibility specs
3890 3898
@@ -4494,20 +4502,6 @@ convenience wrapper around `make-progress-reporter' and friends.
4494 nil ,@(cdr (cdr spec))))) 4502 nil ,@(cdr (cdr spec)))))
4495 4503
4496 4504
4497;;;; Support for watching filesystem events.
4498
4499(defun file-notify-handle-event (event)
4500 "Handle file system monitoring event.
4501If EVENT is a filewatch event, call its callback.
4502Otherwise, signal a `filewatch-error'."
4503 (interactive "e")
4504 (if (and (eq (car event) 'file-notify)
4505 (>= (length event) 3))
4506 (funcall (nth 2 event) (nth 1 event))
4507 (signal 'filewatch-error
4508 (cons "Not a valid file-notify event" event))))
4509
4510
4511;;;; Comparing version strings. 4505;;;; Comparing version strings.
4512 4506
4513(defconst version-separator "." 4507(defconst version-separator "."
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 3d591303414..8032de85b01 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -57,6 +57,7 @@
57;;; Code: 57;;; Code:
58 58
59(require 'dired) 59(require 'dired)
60(require 'cl-lib) ; for cl-gensym
60 61
61;; CUSTOMIZATIONS 62;; CUSTOMIZATIONS
62 63
@@ -179,21 +180,6 @@ this value can let another user see some of your images."
179(make-variable-buffer-local 'thumbs-marked-list) 180(make-variable-buffer-local 'thumbs-marked-list)
180(put 'thumbs-marked-list 'permanent-local t) 181(put 'thumbs-marked-list 'permanent-local t)
181 182
182(defalias 'thumbs-gensym
183 (if (fboundp 'gensym)
184 'gensym
185 ;; Copied from cl-macs.el
186 (defvar thumbs-gensym-counter 0)
187 (lambda (&optional prefix)
188 "Generate a new uninterned symbol.
189The name is made by appending a number to PREFIX, default \"G\"."
190 (let ((pfix (if (stringp prefix) prefix "G"))
191 (num (if (integerp prefix) prefix
192 (prog1 thumbs-gensym-counter
193 (setq thumbs-gensym-counter
194 (1+ thumbs-gensym-counter))))))
195 (make-symbol (format "%s%d" pfix num))))))
196
197(defsubst thumbs-temp-dir () 183(defsubst thumbs-temp-dir ()
198 (file-name-as-directory (expand-file-name thumbs-temp-dir))) 184 (file-name-as-directory (expand-file-name thumbs-temp-dir)))
199 185
@@ -202,7 +188,7 @@ The name is made by appending a number to PREFIX, default \"G\"."
202 (format "%s%s-%s.jpg" 188 (format "%s%s-%s.jpg"
203 (thumbs-temp-dir) 189 (thumbs-temp-dir)
204 thumbs-temp-prefix 190 thumbs-temp-prefix
205 (thumbs-gensym "T"))) 191 (cl-gensym "T")))
206 192
207(defun thumbs-thumbsdir () 193(defun thumbs-thumbsdir ()
208 "Return the current thumbnails directory (from `thumbs-thumbsdir'). 194 "Return the current thumbnails directory (from `thumbs-thumbsdir').
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 7a8f399a6ce..e9a6a97409c 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -12,8 +12,8 @@
12;; filed in the Emacs bug reporting system against this file, a copy 12;; filed in the Emacs bug reporting system against this file, a copy
13;; of the bug report be sent to the maintainer's email address. 13;; of the bug report be sent to the maintainer's email address.
14 14
15(defconst ediff-version "2.81.4" "The current version of Ediff") 15(defconst ediff-version "2.81.5" "The current version of Ediff")
16(defconst ediff-date "December 7, 2009" "Date of last update") 16(defconst ediff-date "July 4, 2013" "Date of last update")
17 17
18 18
19;; This file is part of GNU Emacs. 19;; This file is part of GNU Emacs.
@@ -1560,6 +1560,75 @@ With optional NODE, goes to that node."
1560 (add-to-list 'debug-ignored-errors mess)) 1560 (add-to-list 'debug-ignored-errors mess))
1561 1561
1562 1562
1563
1564;;; Command line interface
1565
1566;;;###autoload
1567(defun ediff-files-command ()
1568 (let ((file-a (nth 0 command-line-args-left))
1569 (file-b (nth 1 command-line-args-left)))
1570 (setq command-line-args-left (nthcdr 2 command-line-args-left))
1571 (ediff file-a file-b)))
1572
1573;;;###autoload
1574(defun ediff3-files-command ()
1575 (let ((file-a (nth 0 command-line-args-left))
1576 (file-b (nth 1 command-line-args-left))
1577 (file-c (nth 2 command-line-args-left)))
1578 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1579 (ediff3 file-a file-b file-c)))
1580
1581;;;###autoload
1582(defun ediff-merge-command ()
1583 (let ((file-a (nth 0 command-line-args-left))
1584 (file-b (nth 1 command-line-args-left)))
1585 (setq command-line-args-left (nthcdr 2 command-line-args-left))
1586 (ediff-merge-files file-a file-b)))
1587
1588;;;###autoload
1589(defun ediff-merge-with-ancestor-command ()
1590 (let ((file-a (nth 0 command-line-args-left))
1591 (file-b (nth 1 command-line-args-left))
1592 (ancestor (nth 2 command-line-args-left)))
1593 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1594 (ediff-merge-files-with-ancestor file-a file-b ancestor)))
1595
1596;;;###autoload
1597(defun ediff-directories-command ()
1598 (let ((file-a (nth 0 command-line-args-left))
1599 (file-b (nth 1 command-line-args-left))
1600 (regexp (nth 2 command-line-args-left)))
1601 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1602 (ediff-directories file-a file-b regexp)))
1603
1604;;;###autoload
1605(defun ediff-directories3-command ()
1606 (let ((file-a (nth 0 command-line-args-left))
1607 (file-b (nth 1 command-line-args-left))
1608 (file-c (nth 2 command-line-args-left))
1609 (regexp (nth 3 command-line-args-left)))
1610 (setq command-line-args-left (nthcdr 4 command-line-args-left))
1611 (ediff-directories3 file-a file-b file-c regexp)))
1612
1613;;;###autoload
1614(defun ediff-merge-directories-command ()
1615 (let ((file-a (nth 0 command-line-args-left))
1616 (file-b (nth 1 command-line-args-left))
1617 (regexp (nth 2 command-line-args-left)))
1618 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1619 (ediff-merge-directories file-a file-b regexp)))
1620
1621;;;###autoload
1622(defun ediff-merge-directories-with-ancestor-command ()
1623 (let ((file-a (nth 0 command-line-args-left))
1624 (file-b (nth 1 command-line-args-left))
1625 (ancestor (nth 2 command-line-args-left))
1626 (regexp (nth 3 command-line-args-left)))
1627 (setq command-line-args-left (nthcdr 4 command-line-args-left))
1628 (ediff-merge-directories-with-ancestor file-a file-b ancestor regexp)))
1629
1630
1631
1563(require 'ediff-util) 1632(require 'ediff-util)
1564 1633
1565(run-hooks 'ediff-load-hook) 1634(run-hooks 'ediff-load-hook)
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 2dc1e502171..b351d896911 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -55,6 +55,7 @@
55;; See `widget.el'. 55;; See `widget.el'.
56 56
57;;; Code: 57;;; Code:
58(require 'cl-lib)
58 59
59;;; Compatibility. 60;;; Compatibility.
60 61
@@ -221,7 +222,7 @@ minibuffer."
221 ((or widget-menu-minibuffer-flag 222 ((or widget-menu-minibuffer-flag
222 (> (length items) widget-menu-max-shortcuts)) 223 (> (length items) widget-menu-max-shortcuts))
223 ;; Read the choice of name from the minibuffer. 224 ;; Read the choice of name from the minibuffer.
224 (setq items (widget-remove-if 'stringp items)) 225 (setq items (cl-remove-if 'stringp items))
225 (let ((val (completing-read (concat title ": ") items nil t))) 226 (let ((val (completing-read (concat title ": ") items nil t)))
226 (if (stringp val) 227 (if (stringp val)
227 (let ((try (try-completion val items))) 228 (let ((try (try-completion val items)))
@@ -295,14 +296,6 @@ minibuffer."
295 (error "Canceled")) 296 (error "Canceled"))
296 value)))) 297 value))))
297 298
298(defun widget-remove-if (predicate list)
299 (let (result (tail list))
300 (while tail
301 (or (funcall predicate (car tail))
302 (setq result (cons (car tail) result)))
303 (setq tail (cdr tail)))
304 (nreverse result)))
305
306;;; Widget text specifications. 299;;; Widget text specifications.
307;; 300;;
308;; These functions are for specifying text properties. 301;; These functions are for specifying text properties.
diff --git a/lisp/window.el b/lisp/window.el
index fc50bbb0d49..a2acd2a81b0 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4347,6 +4347,9 @@ value can be also stored on disk and read back in a new session."
4347(defvar window-state-put-list nil 4347(defvar window-state-put-list nil
4348 "Helper variable for `window-state-put'.") 4348 "Helper variable for `window-state-put'.")
4349 4349
4350(defvar window-state-put-stale-windows nil
4351 "Helper variable for `window-state-put'.")
4352
4350(defun window--state-put-1 (state &optional window ignore totals) 4353(defun window--state-put-1 (state &optional window ignore totals)
4351 "Helper function for `window-state-put'." 4354 "Helper function for `window-state-put'."
4352 (let ((type (car state))) 4355 (let ((type (car state)))
@@ -4429,9 +4432,14 @@ value can be also stored on disk and read back in a new session."
4429 (set-window-parameter window (car parameter) (cdr parameter)))) 4432 (set-window-parameter window (car parameter) (cdr parameter))))
4430 ;; Process buffer related state. 4433 ;; Process buffer related state.
4431 (when state 4434 (when state
4432 ;; We don't want to raise an error here so we create a buffer if 4435 ;; We don't want to raise an error in case the buffer does not
4433 ;; there's none. 4436 ;; exist anymore, so we switch to a previous one and save the
4434 (set-window-buffer window (get-buffer-create (car state))) 4437 ;; window with the intention of deleting it later if possible.
4438 (let ((buffer (get-buffer (car state))))
4439 (if buffer
4440 (set-window-buffer window buffer)
4441 (switch-to-prev-buffer window)
4442 (push window window-state-put-stale-windows)))
4435 (with-current-buffer (window-buffer window) 4443 (with-current-buffer (window-buffer window)
4436 (set-window-hscroll window (cdr (assq 'hscroll state))) 4444 (set-window-hscroll window (cdr (assq 'hscroll state)))
4437 (apply 'set-window-fringes 4445 (apply 'set-window-fringes
@@ -4491,6 +4499,7 @@ Optional argument IGNORE non-nil means ignore minimum window
4491sizes and fixed size restrictions. IGNORE equal `safe' means 4499sizes and fixed size restrictions. IGNORE equal `safe' means
4492windows can get as small as `window-safe-min-height' and 4500windows can get as small as `window-safe-min-height' and
4493`window-safe-min-width'." 4501`window-safe-min-width'."
4502 (setq window-state-put-stale-windows nil)
4494 (setq window (window-normalize-window window t)) 4503 (setq window (window-normalize-window window t))
4495 (let* ((frame (window-frame window)) 4504 (let* ((frame (window-frame window))
4496 (head (car state)) 4505 (head (car state))
@@ -4539,6 +4548,10 @@ windows can get as small as `window-safe-min-height' and
4539 (set-window-buffer window (current-buffer)) 4548 (set-window-buffer window (current-buffer))
4540 (window--state-put-1 state window nil totals) 4549 (window--state-put-1 state window nil totals)
4541 (window--state-put-2 ignore)) 4550 (window--state-put-2 ignore))
4551 (while window-state-put-stale-windows
4552 (let ((window (pop window-state-put-stale-windows)))
4553 (when (eq (window-deletable-p window) t)
4554 (delete-window window))))
4542 (window--check frame)))) 4555 (window--check frame))))
4543 4556
4544(defun display-buffer-record-window (type window buffer) 4557(defun display-buffer-record-window (type window buffer)
diff --git a/m4/fcntl.m4 b/m4/fcntl.m4
new file mode 100644
index 00000000000..5481cae4d80
--- /dev/null
+++ b/m4/fcntl.m4
@@ -0,0 +1,95 @@
1# fcntl.m4 serial 5
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 dnl haiku alpha 2 F_DUPFD has wrong errno
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
31#include <fcntl.h>
32#include <errno.h>
33]], [[int result = 0;
34 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
35 if (errno != EINVAL) result |= 2;
36 return result;
37 ]])],
38 [gl_cv_func_fcntl_f_dupfd_works=yes],
39 [gl_cv_func_fcntl_f_dupfd_works=no],
40 [# Guess that it works on glibc systems
41 case $host_os in #((
42 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
43 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
44 esac])])
45 case $gl_cv_func_fcntl_f_dupfd_works in
46 *yes) ;;
47 *) gl_REPLACE_FCNTL
48 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
49 behavior does not match POSIX]) ;;
50 esac
51
52 dnl Many systems lack F_DUPFD_CLOEXEC
53 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
54 [gl_cv_func_fcntl_f_dupfd_cloexec],
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
56#include <fcntl.h>
57#ifndef F_DUPFD_CLOEXEC
58choke me
59#endif
60 ]])],
61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
62#ifdef __linux__
63/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
64 it to support the semantics on older kernels that failed with EINVAL. */
65choke me
66#endif
67 ]])],
68 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
69 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
70 [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
71 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
72 gl_REPLACE_FCNTL
73 dnl No witness macro needed for this bug.
74 fi
75 fi
76 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
77 dnl to keep fchdir's bookkeeping up-to-date.
78 m4_ifdef([gl_FUNC_FCHDIR], [
79 gl_TEST_FCHDIR
80 if test $HAVE_FCHDIR = 0; then
81 gl_REPLACE_FCNTL
82 fi
83 ])
84])
85
86AC_DEFUN([gl_REPLACE_FCNTL],
87[
88 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
89 AC_CHECK_FUNCS_ONCE([fcntl])
90 if test $ac_cv_func_fcntl = no; then
91 HAVE_FCNTL=0
92 else
93 REPLACE_FCNTL=1
94 fi
95])
diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
new file mode 100644
index 00000000000..8f04b3b8c2a
--- /dev/null
+++ b/m4/getdtablesize.m4
@@ -0,0 +1,17 @@
1# getdtablesize.m4 serial 4
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_CHECK_FUNCS_ONCE([getdtablesize])
11 if test $ac_cv_func_getdtablesize != yes; then
12 HAVE_GETDTABLESIZE=0
13 fi
14])
15
16# Prerequisites of lib/getdtablesize.c.
17AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 344b77642b9..d7062e862de 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -41,6 +41,7 @@ AC_DEFUN([gl_EARLY],
41 # Code from module alloca-opt: 41 # Code from module alloca-opt:
42 # Code from module allocator: 42 # Code from module allocator:
43 # Code from module at-internal: 43 # Code from module at-internal:
44 # Code from module binary-io:
44 # Code from module c-ctype: 45 # Code from module c-ctype:
45 # Code from module c-strcase: 46 # Code from module c-strcase:
46 # Code from module careadlinkat: 47 # Code from module careadlinkat:
@@ -63,6 +64,7 @@ AC_DEFUN([gl_EARLY],
63 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 64 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
64 # Code from module extern-inline: 65 # Code from module extern-inline:
65 # Code from module faccessat: 66 # Code from module faccessat:
67 # Code from module fcntl:
66 # Code from module fcntl-h: 68 # Code from module fcntl-h:
67 # Code from module fdatasync: 69 # Code from module fdatasync:
68 # Code from module fdopendir: 70 # Code from module fdopendir:
@@ -70,6 +72,7 @@ AC_DEFUN([gl_EARLY],
70 # Code from module fpending: 72 # Code from module fpending:
71 # Code from module fstatat: 73 # Code from module fstatat:
72 # Code from module fsync: 74 # Code from module fsync:
75 # Code from module getdtablesize:
73 # Code from module getgroups: 76 # Code from module getgroups:
74 # Code from module getloadavg: 77 # Code from module getloadavg:
75 # Code from module getopt-gnu: 78 # Code from module getopt-gnu:
@@ -78,7 +81,6 @@ AC_DEFUN([gl_EARLY],
78 # Code from module gettime: 81 # Code from module gettime:
79 # Code from module gettimeofday: 82 # Code from module gettimeofday:
80 # Code from module group-member: 83 # Code from module group-member:
81 # Code from module ignore-value:
82 # Code from module include_next: 84 # Code from module include_next:
83 # Code from module intprops: 85 # Code from module intprops:
84 # Code from module inttypes-incomplete: 86 # Code from module inttypes-incomplete:
@@ -92,6 +94,7 @@ AC_DEFUN([gl_EARLY],
92 # Code from module nocrash: 94 # Code from module nocrash:
93 # Code from module openat-h: 95 # Code from module openat-h:
94 # Code from module pathmax: 96 # Code from module pathmax:
97 # Code from module pipe2:
95 # Code from module pselect: 98 # Code from module pselect:
96 # Code from module pthread_sigmask: 99 # Code from module pthread_sigmask:
97 # Code from module putenv: 100 # Code from module putenv:
@@ -191,6 +194,11 @@ AC_DEFUN([gl_INIT],
191 fi 194 fi
192 gl_MODULE_INDICATOR([faccessat]) 195 gl_MODULE_INDICATOR([faccessat])
193 gl_UNISTD_MODULE_INDICATOR([faccessat]) 196 gl_UNISTD_MODULE_INDICATOR([faccessat])
197 gl_FUNC_FCNTL
198 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
199 AC_LIBOBJ([fcntl])
200 fi
201 gl_FCNTL_MODULE_INDICATOR([fcntl])
194 gl_FCNTL_H 202 gl_FCNTL_H
195 gl_FUNC_FDATASYNC 203 gl_FUNC_FDATASYNC
196 if test $HAVE_FDATASYNC = 0; then 204 if test $HAVE_FDATASYNC = 0; then
@@ -273,6 +281,8 @@ AC_DEFUN([gl_INIT],
273 fi 281 fi
274 gl_TIME_MODULE_INDICATOR([mktime]) 282 gl_TIME_MODULE_INDICATOR([mktime])
275 gl_MULTIARCH 283 gl_MULTIARCH
284 gl_FUNC_PIPE2
285 gl_UNISTD_MODULE_INDICATOR([pipe2])
276 gl_FUNC_PSELECT 286 gl_FUNC_PSELECT
277 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then 287 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then
278 AC_LIBOBJ([pselect]) 288 AC_LIBOBJ([pselect])
@@ -364,6 +374,7 @@ AC_DEFUN([gl_INIT],
364 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false 374 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
365 gl_gnulib_enabled_dosname=false 375 gl_gnulib_enabled_dosname=false
366 gl_gnulib_enabled_euidaccess=false 376 gl_gnulib_enabled_euidaccess=false
377 gl_gnulib_enabled_getdtablesize=false
367 gl_gnulib_enabled_getgroups=false 378 gl_gnulib_enabled_getgroups=false
368 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false 379 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
369 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false 380 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
@@ -373,7 +384,6 @@ AC_DEFUN([gl_INIT],
373 gl_gnulib_enabled_stat=false 384 gl_gnulib_enabled_stat=false
374 gl_gnulib_enabled_strtoll=false 385 gl_gnulib_enabled_strtoll=false
375 gl_gnulib_enabled_strtoull=false 386 gl_gnulib_enabled_strtoull=false
376 gl_gnulib_enabled_verify=false
377 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false 387 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
378 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () 388 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
379 { 389 {
@@ -407,6 +417,18 @@ AC_DEFUN([gl_INIT],
407 fi 417 fi
408 fi 418 fi
409 } 419 }
420 func_gl_gnulib_m4code_getdtablesize ()
421 {
422 if ! $gl_gnulib_enabled_getdtablesize; then
423 gl_FUNC_GETDTABLESIZE
424 if test $HAVE_GETDTABLESIZE = 0; then
425 AC_LIBOBJ([getdtablesize])
426 gl_PREREQ_GETDTABLESIZE
427 fi
428 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
429 gl_gnulib_enabled_getdtablesize=true
430 fi
431 }
410 func_gl_gnulib_m4code_getgroups () 432 func_gl_gnulib_m4code_getgroups ()
411 { 433 {
412 if ! $gl_gnulib_enabled_getgroups; then 434 if ! $gl_gnulib_enabled_getgroups; then
@@ -479,9 +501,6 @@ AC_DEFUN([gl_INIT],
479 if test $REPLACE_STAT = 1; then 501 if test $REPLACE_STAT = 1; then
480 func_gl_gnulib_m4code_pathmax 502 func_gl_gnulib_m4code_pathmax
481 fi 503 fi
482 if test $REPLACE_STAT = 1; then
483 func_gl_gnulib_m4code_verify
484 fi
485 fi 504 fi
486 } 505 }
487 func_gl_gnulib_m4code_strtoll () 506 func_gl_gnulib_m4code_strtoll ()
@@ -508,12 +527,6 @@ AC_DEFUN([gl_INIT],
508 gl_gnulib_enabled_strtoull=true 527 gl_gnulib_enabled_strtoull=true
509 fi 528 fi
510 } 529 }
511 func_gl_gnulib_m4code_verify ()
512 {
513 if ! $gl_gnulib_enabled_verify; then
514 gl_gnulib_enabled_verify=true
515 fi
516 }
517 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () 530 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
518 { 531 {
519 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 532 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
@@ -532,6 +545,9 @@ AC_DEFUN([gl_INIT],
532 if test $HAVE_FACCESSAT = 0; then 545 if test $HAVE_FACCESSAT = 0; then
533 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 546 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
534 fi 547 fi
548 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
549 func_gl_gnulib_m4code_getdtablesize
550 fi
535 if test $HAVE_FDOPENDIR = 0; then 551 if test $HAVE_FDOPENDIR = 0; then
536 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 552 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
537 fi 553 fi
@@ -568,19 +584,14 @@ AC_DEFUN([gl_INIT],
568 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then 584 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
569 func_gl_gnulib_m4code_strtoll 585 func_gl_gnulib_m4code_strtoll
570 fi 586 fi
571 if test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
572 func_gl_gnulib_m4code_verify
573 fi
574 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then 587 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then
575 func_gl_gnulib_m4code_strtoull 588 func_gl_gnulib_m4code_strtoull
576 fi 589 fi
577 if test $ac_cv_func_strtoumax = no; then
578 func_gl_gnulib_m4code_verify
579 fi
580 m4_pattern_allow([^gl_GNULIB_ENABLED_]) 590 m4_pattern_allow([^gl_GNULIB_ENABLED_])
581 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b]) 591 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
582 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) 592 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
583 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) 593 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
594 AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
584 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) 595 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups])
585 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) 596 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
586 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) 597 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1])
@@ -590,7 +601,6 @@ AC_DEFUN([gl_INIT],
590 AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat]) 601 AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat])
591 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) 602 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
592 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull]) 603 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull])
593 AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify])
594 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) 604 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec])
595 # End of code from modules 605 # End of code from modules
596 m4_ifval(gl_LIBSOURCES_LIST, [ 606 m4_ifval(gl_LIBSOURCES_LIST, [
@@ -745,6 +755,8 @@ AC_DEFUN([gl_FILE_LIST], [
745 lib/allocator.c 755 lib/allocator.c
746 lib/allocator.h 756 lib/allocator.h
747 lib/at-func.c 757 lib/at-func.c
758 lib/binary-io.c
759 lib/binary-io.h
748 lib/c-ctype.c 760 lib/c-ctype.c
749 lib/c-ctype.h 761 lib/c-ctype.h
750 lib/c-strcase.h 762 lib/c-strcase.h
@@ -764,6 +776,7 @@ AC_DEFUN([gl_FILE_LIST], [
764 lib/execinfo.c 776 lib/execinfo.c
765 lib/execinfo.in.h 777 lib/execinfo.in.h
766 lib/faccessat.c 778 lib/faccessat.c
779 lib/fcntl.c
767 lib/fcntl.in.h 780 lib/fcntl.in.h
768 lib/fdatasync.c 781 lib/fdatasync.c
769 lib/fdopendir.c 782 lib/fdopendir.c
@@ -776,6 +789,7 @@ AC_DEFUN([gl_FILE_LIST], [
776 lib/fsync.c 789 lib/fsync.c
777 lib/ftoastr.c 790 lib/ftoastr.c
778 lib/ftoastr.h 791 lib/ftoastr.h
792 lib/getdtablesize.c
779 lib/getgroups.c 793 lib/getgroups.c
780 lib/getloadavg.c 794 lib/getloadavg.c
781 lib/getopt.c 795 lib/getopt.c
@@ -786,7 +800,6 @@ AC_DEFUN([gl_FILE_LIST], [
786 lib/gettime.c 800 lib/gettime.c
787 lib/gettimeofday.c 801 lib/gettimeofday.c
788 lib/group-member.c 802 lib/group-member.c
789 lib/ignore-value.h
790 lib/intprops.h 803 lib/intprops.h
791 lib/inttypes.in.h 804 lib/inttypes.in.h
792 lib/lstat.c 805 lib/lstat.c
@@ -799,6 +812,7 @@ AC_DEFUN([gl_FILE_LIST], [
799 lib/openat-proc.c 812 lib/openat-proc.c
800 lib/openat.h 813 lib/openat.h
801 lib/pathmax.h 814 lib/pathmax.h
815 lib/pipe2.c
802 lib/pselect.c 816 lib/pselect.c
803 lib/pthread_sigmask.c 817 lib/pthread_sigmask.c
804 lib/putenv.c 818 lib/putenv.c
@@ -870,6 +884,7 @@ AC_DEFUN([gl_FILE_LIST], [
870 m4/extern-inline.m4 884 m4/extern-inline.m4
871 m4/faccessat.m4 885 m4/faccessat.m4
872 m4/fcntl-o.m4 886 m4/fcntl-o.m4
887 m4/fcntl.m4
873 m4/fcntl_h.m4 888 m4/fcntl_h.m4
874 m4/fdatasync.m4 889 m4/fdatasync.m4
875 m4/fdopendir.m4 890 m4/fdopendir.m4
@@ -877,6 +892,7 @@ AC_DEFUN([gl_FILE_LIST], [
877 m4/fpending.m4 892 m4/fpending.m4
878 m4/fstatat.m4 893 m4/fstatat.m4
879 m4/fsync.m4 894 m4/fsync.m4
895 m4/getdtablesize.m4
880 m4/getgroups.m4 896 m4/getgroups.m4
881 m4/getloadavg.m4 897 m4/getloadavg.m4
882 m4/getopt.m4 898 m4/getopt.m4
@@ -897,6 +913,7 @@ AC_DEFUN([gl_FILE_LIST], [
897 m4/nocrash.m4 913 m4/nocrash.m4
898 m4/off_t.m4 914 m4/off_t.m4
899 m4/pathmax.m4 915 m4/pathmax.m4
916 m4/pipe2.m4
900 m4/pselect.m4 917 m4/pselect.m4
901 m4/pthread_sigmask.m4 918 m4/pthread_sigmask.m4
902 m4/putenv.m4 919 m4/putenv.m4
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
new file mode 100644
index 00000000000..6ccee105239
--- /dev/null
+++ b/m4/pipe2.m4
@@ -0,0 +1,18 @@
1# pipe2.m4 serial 2
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_PIPE2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 dnl Persuade glibc <unistd.h> to declare pipe2().
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
13
14 AC_CHECK_FUNCS_ONCE([pipe2])
15 if test $ac_cv_func_pipe2 != yes; then
16 HAVE_PIPE2=0
17 fi
18])
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index a866ff670b1..20be01aaf20 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -31,7 +31,8 @@ AC_DEFUN([gl_STDALIGN_H],
31 31
32 /* Test _Alignas only on platforms where gnulib can help. */ 32 /* Test _Alignas only on platforms where gnulib can help. */
33 #if \ 33 #if \
34 (__GNUC__ || __IBMC__ || __IBMCPP__ \ 34 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
35 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
36 struct alignas_test { char c; char alignas (8) alignas_8; }; 37 struct alignas_test { char c; char alignas (8) alignas_8; };
37 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 1a0746b3181..c0598dd5630 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,17 @@
12013-07-07 Eli Zaretskii <eliz@gnu.org>
2
3 * inc/sys/socket.h (F_SETFD, O_CLOEXEC, F_DUPFD_CLOEXEC)
4 (FD_CLOEXEC): New macros.
5
62013-07-07 Paul Eggert <eggert@cs.ucla.edu>
7
8 Make file descriptors close-on-exec when possible (Bug#14803).
9 * gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section;
10 otherwise, gnulib-tool complains given close-on-exec changes.
11 * inc/ms-w32.h (pipe): Remove.
12 * mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec)
13 (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars.
14
12013-06-25 Juanma Barranquero <lekktu@gmail.com> 152013-06-25 Juanma Barranquero <lekktu@gmail.com>
2 16
3 * configure.bat: Add warning to the help text about using the 17 * configure.bat: Add warning to the help text about using the
diff --git a/nt/gnulib.mk b/nt/gnulib.mk
index ac4fc2768d9..df27dcf610c 100644
--- a/nt/gnulib.mk
+++ b/nt/gnulib.mk
@@ -876,9 +876,6 @@ EXTRA_DIST += utimens.h
876 876
877## begin gnulib module verify 877## begin gnulib module verify
878 878
879if gl_GNULIB_ENABLED_verify
880
881endif
882EXTRA_DIST += verify.h 879EXTRA_DIST += verify.h
883 880
884## end gnulib module verify 881## end gnulib module verify
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 29c8e383893..3e50c78f145 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -211,7 +211,6 @@ extern struct tm * sys_localtime (const time_t *);
211#define mktemp sys_mktemp 211#define mktemp sys_mktemp
212#undef open 212#undef open
213#define open sys_open 213#define open sys_open
214#define pipe sys_pipe
215#undef read 214#undef read
216#define read sys_read 215#define read sys_read
217#define rename sys_rename 216#define rename sys_rename
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h
index 99227d75d28..93bf9f91665 100644
--- a/nt/inc/sys/socket.h
+++ b/nt/inc/sys/socket.h
@@ -123,7 +123,11 @@ int sys_sendto (int s, const char * buf, int len, int flags,
123 an fcntl function, for setting sockets to non-blocking mode. */ 123 an fcntl function, for setting sockets to non-blocking mode. */
124int fcntl (int s, int cmd, int options); 124int fcntl (int s, int cmd, int options);
125#define F_SETFL 4 125#define F_SETFL 4
126#define F_SETFD 2
126#define O_NONBLOCK 04000 127#define O_NONBLOCK 04000
128#define O_CLOEXEC O_NOINHERIT
129#define F_DUPFD_CLOEXEC 0x40000000
130#define FD_CLOEXEC 1
127 131
128/* we are providing a real h_errno variable */ 132/* we are providing a real h_errno variable */
129#undef h_errno 133#undef h_errno
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 41e4f23784e..cf55fe04ed8 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -67,6 +67,10 @@ gl_cv_func_readlink_works=yes
67gl_cv_func_symlink_works=yes 67gl_cv_func_symlink_works=yes
68ac_cv_func_readlinkat=yes 68ac_cv_func_readlinkat=yes
69ac_cv_func_faccessat=yes 69ac_cv_func_faccessat=yes
70# Implemented in w32.c
71ac_cv_func_fcntl=yes
72gl_cv_func_fcntl_f_dupfd_cloexec=yes
73gl_cv_func_fcntl_f_dupfd_works=yes
70# We don't need fdopendir 74# We don't need fdopendir
71ac_cv_func_fdopendir="not-needed" 75ac_cv_func_fdopendir="not-needed"
72gl_cv_func_fdopendir_works="no-but-not-needed-so-yes" 76gl_cv_func_fdopendir_works="no-but-not-needed-so-yes"
@@ -95,6 +99,7 @@ ac_cv_func_getloadavg=yes
95# Avoid compiling gnulib mktime 99# Avoid compiling gnulib mktime
96gl_cv_func_working_mktime=yes 100gl_cv_func_working_mktime=yes
97# Implemented in w32.c 101# Implemented in w32.c
102ac_cv_func_pipe2=yes
98ac_cv_have_decl_unsetenv=yes 103ac_cv_have_decl_unsetenv=yes
99ac_cv_func_unsetenv=yes 104ac_cv_func_unsetenv=yes
100gt_cv_func_unsetenv_ret='int' 105gt_cv_func_unsetenv_ret='int'
diff --git a/src/ChangeLog b/src/ChangeLog
index 322b8271f14..6ee0cacb520 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,476 @@
12013-07-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 * callproc.c (child_setup, relocate_fd) [!DOS_NT]:
4 * process.c (create_process) [!DOS_NT]:
5 Remove now-unnecessary calls to emacs_close.
6
72013-07-13 Eli Zaretskii <eliz@gnu.org>
8
9 * w32term.c (x_draw_hollow_cursor): Delete the brush object when
10 returning early. (Bug#14850)
11
12 * coding.c (syms_of_coding): Set up inhibit-null-byte-detection
13 and inhibit-iso-escape-detection attributes of 'undecided'.
14 (Bug#14822)
15
162013-07-13 Paul Eggert <eggert@cs.ucla.edu>
17
18 * deps.mk (sysdep.o): Remove dependency on ../lib/ignore-value.h.
19 Reported by Herbert J. Skuhra in
20 <http://lists.gnu.org/archive/html/emacs-devel/2013-07/msg00455.html>.
21
22 Don't lose top specpdl entry when memory is exhausted.
23 * eval.c (grow_specpdl): Increment specpdl top by 1 and check for
24 specpdl overflow here, to simplify callers; all callers changed.
25 Always reserve an unused entry at the stack top; this avoids
26 losing the top entry's information when memory is exhausted.
27
282013-07-12 Paul Eggert <eggert@cs.ucla.edu>
29
30 Clean up errno reporting and fix some errno-reporting bugs.
31 * callproc.c (Fcall_process):
32 * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region):
33 * process.c (create_process, Fmake_network_process):
34 * unexaix.c (report_error):
35 * unexcoff.c (report_error):
36 Be more careful about reporting the errno of failed operations.
37 The code previously reported the wrong errno sometimes.
38 Also, prefer report_file_errno to setting errno + report_file_error.
39 (Fcall_process): Look at openp return value rather than at path,
40 as that's a bit faster and clearer when there's a numeric predicate.
41 * fileio.c (report_file_errno): New function, with most of the
42 old contents of report_file_error.
43 (report_file_error): Use it.
44 (Ffile_exists_p, Ffile_accessible_directory_p):
45 Set errno to 0 when it is junk.
46 * fileio.c (Faccess_file):
47 * image.c (x_create_bitmap_from_file):
48 Use faccessat rather than opening the file, to avoid the hassle of
49 having a file descriptor open.
50 * lisp.h (report_file_errno): New decl.
51 * lread.c (Flocate_file_internal): File descriptor 0 is valid, too.
52
53 Minor EBADF fixes.
54 * process.c (create_process, wait_reading_process_output) [AIX]:
55 Remove obsolete SIGHUP-related code, as Emacs no longer disables
56 SIGHUP, so EBADF is no longer acceptable here (it wouldn't work in
57 a multithreaded environment anyway).
58 * sysdep.c (emacs_close): It's not dangerous to invoke emacs_close (-1).
59
602013-07-12 Andreas Schwab <schwab@linux-m68k.org>
61
62 * image.c (x_find_image_file): Don't close a remote file handle.
63
642013-07-12 Paul Eggert <eggert@cs.ucla.edu>
65
66 Fix races with threads and file descriptors.
67 * callproc.c (Fcall_process_region):
68 * dired.c (open_directory):
69 * emacs.c (main, Fdaemon_initialized):
70 * image.c (x_find_image_file):
71 * inotify.c (Finotify_rm_watch):
72 * lread.c (Flocate_file_internal):
73 * process.c (Fnetwork_interface_list, Fnetwork_interface_info):
74 * term.c (term_mouse_moveto, init_tty):
75 * termcap.c (tgetent):
76 * unexaix.c, unexcoff.c (report_error, report_error_1, adjust_lnnoptrs)
77 * unexaix.c, unexcoff.c, unexcw.c, unexelf.c (unexec):
78 * unexhp9k800.c, unexmacosx.c (unexec):
79 * callproc.c (Fcall_process_region):
80 Use emacs_close, not close.
81 * sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]:
82 New macro and function, which emulates the POSIX_CLOSE_RESTART macro
83 and posix_close function on current platforms (which all lack them).
84 (emacs_close): Use it. This should fix the races on GNU/Linux and
85 on AIX and on future platforms that support POSIX_CLOSE_RESTART,
86 and it should avoid closing random victim file descriptors on
87 other platforms.
88
892013-07-11 Paul Eggert <eggert@cs.ucla.edu>
90
91 * inotify.c (uninitialized): Remove. All uses replaced by -1.
92 (Finotify_add_watch): Simplify, since -1 means uninitialized now.
93 Touch up doc a bit.
94
95 * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE.
96 This is for .gdbinit xbacktrace.
97
98 * sysdep.c, term.c, termcap.c, terminal.c: Integer-related minor fixes.
99 * sysdep.c (emacs_get_tty): Return void, since nobody uses the value.
100 (emacs_set_tty): Now static.
101 * sysdep.c (emacs_set_tty, tabs_safe_p, emacs_close):
102 * term.c (tty_capable_p, tty_default_color_capabilities)
103 (get_tty_terminal, term_mouse_movement)
104 (handle_one_term_event, init_tty, maybe_fatal):
105 * termcap.c (tgetst1, struct termcap_buffer, valid_filename_p)
106 (tgetent, scan_file, name_match, compare_contin):
107 * terminal.c (get_terminal):
108 Use bool for boolean.
109 * sysdep.c (init_system_name): Don't overflow stack on huge hostname.
110 Prefer char to unsigned char if either will do.
111 * term.c (OUTPUT, turn_on_face): Omit unnecessary casts to int.
112 (tty_write_glyphs): Prefer int to unsigned.
113 (produce_glyphless_glyph): Remove 2nd (unused) int arg.
114 All callers changed.
115 * termcap.c (tprint, main) [TEST]: Remove non-working test.
116
1172013-07-10 Paul Eggert <eggert@cs.ucla.edu>
118
119 Port to C89.
120 * bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
121 (B__dummy__): New dummy symbol, to pacify C89.
122 * dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
123 they can't grok varargs macros.
124 * dispnew.c (add_window_display_history)
125 (add_frame_display_history):
126 * print.c (print_object):
127 * xdisp.c (debug_method_add):
128 Use %p printf format only for void pointers.
129 * emacs.c (usage_message): New constant, replacing ...
130 (USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
131 (main): Adjust to usage reorg.
132 * fns.c (syms_of_fns):
133 * profiler.c (syms_of_profiler):
134 Don't use non-constant struct initializers.
135 * gnutls.h (gnutls_initstage_t):
136 * lisp.h (enum Lisp_Fwd_Type):
137 * lread.c (lisp_file_lexically_bound_p):
138 * xsettings.c (anonymous enum):
139 Remove trailing comma.
140 * xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
141 * lisp.h (ENUM_BF): Use unsigned if pedantic.
142 (DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
143 (DEFUN): Use it.
144 * regex.c (const_re_char): New type, to pacify strict C89.
145 All uses of 'const re_char' replaced to use it.
146 * regex.h (_Restrict_): Rename from __restrict, to avoid clash
147 with glibc when strict C89. This change is imported from gnulib.
148 All uses changed.
149 (_Restrict_arr_): Rename from __restrict_arr, similarly.
150 * sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
151 Omit GNU_LINUX implementation, since it requires long long.
152 * xterm.c (x_draw_underwave):
153 Do not assume the traditional order of struct's members.
154 (x_term_init): Rewrite to avoid the need for non-constant structure
155 initializers.
156
157 Syntax cleanup, mostly replacing macros with functions.
158` This removes the need for the syntax_temp hack.
159 * search.c: Include syntax.h after buffer.h, since syntax.h uses BVAR.
160 * syntax.c (SYNTAX_INLINE): New macro.
161 (SYNTAX_FLAGS_COMSTART_FIRST, SYNTAX_FLAGS_COMSTART_SECOND)
162 (SYNTAX_FLAGS_COMEND_FIRST, SYNTAX_FLAGS_COMEND_SECOND)
163 (SYNTAX_FLAGS_PREFIX, SYNTAX_FLAGS_COMMENT_STYLEB)
164 (SYNTAX_FLAGS_COMMENT_STYLEC, SYNTAX_FLAGS_COMMENT_STYLEC2)
165 (SYNTAX_FLAGS_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_STYLE)
166 (SYNTAX_COMEND_FIRST): Now functions, not macros.
167 (ST_COMMENT_STYLE, ST_STRING_STYLE, INTERVALS_AT_ONCE):
168 Now constants, not macros.
169 (syntax_temp) [!__GNUC__]: Remove.
170 (SYNTAX_PREFIX): Remove; all uses replaced by syntax_prefix_flag_p.
171 (syntax_prefix_flag_p): Move implementation of SYNTAX_PREFIX here.
172 (SET_RAW_SYNTAX_ENTRY, SET_RAW_SYNTAX_ENTRY_RANGE, SYNTAX_MATCH)
173 (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
174 Move here from syntax.h; now functions, not macros. Except for the
175 last function, these are static since only syntax.c uses them.
176 (syntax_multibyte): Rename from SYNTAX_WITH_MULTIBYTE_CHECK.
177 All uses changed. Now a function, not a macro; use this fact
178 to simplify the code.
179 (scan_lists, scan_sexps_forward): Remove workarounds for ancient
180 compiler bugs; no longer relevant.
181 * syntax.h: Use INLINE_HEADER_BEGIN, INLINE_HEADER_END.
182 (SYNTAX_INLINE): New macro.
183 (struct gl_state_s, gl_state): Move earlier, so that it's in scope
184 for the new functions. Use bool for boolean member.
185 (SYNTAX_ENTRY, SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH)
186 (SYNTAX_TABLE_BYTE_TO_CHAR, UPDATE_SYNTAX_TABLE_FORWARD)
187 (UPDATE_SYNTAX_TABLE_BACKWARD, UPDATE_SYNTAX_TABLE)
188 (SETUP_BUFFER_SYNTAX_TABLE):
189 Now extern inline functions, not macros.
190 (CURRENT_SYNTAX_TABLE, SYNTAX_ENTRY_INT):
191 Remove; all uses replaced by implementation.
192 (syntax_temp) [!__GNUC__]: Remove decl.
193 (SETUP_SYNTAX_TABLE_FOR_OBJECT): New decl.
194
1952013-07-10 Jan Djärv <jan.h.d@swipnet.se>
196
197 * emacs.c (main): Fix syntax error.
198
1992013-07-10 Paul Eggert <eggert@cs.ucla.edu>
200
201 Timestamp fixes for undo (Bug#14824).
202 * atimer.c (schedule_atimer):
203 * fileio.c (Ffile_newer_than_file_p):
204 Minor cleanup: use EMACS_TIME_LT so that we can remove EMACS_TIME_GT.
205 * buffer.c (buffer-undo-list): Document (t . 0) and (t . -1).
206 * fileio.c (Fclear_visited_file_modtime): Move to lisp/files.el.
207 (syms_of_fileio): Remove Sclear_visited_file_name.
208 (Fvisited_file_modtime): Return -1, not (-1 ...), when the visited
209 file doesn't exist; this avoids an ambiguity with negative timestamps.
210 (Fset_visited_file_modtime): Accept -1 and 0 as time-list arg.
211 * systime.h (make_emacs_time, invalid_emacs_time):
212 Don't assume struct timespec layout; POSIX doesn't guarantee it.
213 (EMACS_TIME_NE, EMACS_TIME_GT, EMACS_TIME_GE): Remove.
214 * undo.c (record_first_change): Push (visited-file-modtime) onto
215 undo list rather than reimplementing it by hand, incorrectly.
216
2172013-07-09 Ken Brown <kbrown@cornell.edu>
218
219 * sheap.c (STATIC_HEAP_SIZE) [__x86_64__]: Increase to 18MB.
220
2212013-07-09 Juanma Barranquero <lekktu@gmail.com>
222
223 * makefile.w32-in ($(BLD)/emacs.$(O), $(BLD)/sysdep.$(O)): Update.
224
2252013-07-09 Paul Eggert <eggert@cs.ucla.edu>
226
227 Handle errno and exit status a bit more carefully.
228 * callproc.c (child_setup) [!DOS_NT]: Don't try to stuff an error
229 number into an exit status. Instead, use EXIT_CANCELED.
230 (child_setup) [!MSDOS]: Avoid possible deadlock with vfork.
231 * callproc.c (relocate_fd):
232 * emacs.c (close_output_streams, main):
233 * process.c (create_process):
234 * sysdep.c (sys_subshell) [!DOS_NT || !WINDOWSNT]:
235 Use emacs_perror for simplicity.
236 * callproc.c (relocate_fd, main):
237 * sysdep.c (sys_subshell):
238 Exit with EXIT_CANCELED etc., not 1, when exec setup fails.
239 (shut_down_emacs): Use emacs_write, not write.
240 * emacs.c, sysdep.c: Don't include <ignore-value.h>.
241 * fileio.c (Fcopy_file, e_write):
242 * nsterm.m (ns_select):
243 * process.c (send_process):
244 * sound.c (vox_write):
245 Use emacs_write_sig, not emacs_write.
246 * lisp.h (emacs_write_sig, emacs_perror): New decls.
247 * process.h (EXIT_CANCELED), EXIT_CANNOT_INVOKE, EXIT_ENOENT):
248 New constants.
249 * sysdep.c (emacs_backtrace): Use emacs_write, not ignore_value
250 of write.
251 (emacs_full_write): New function.
252 (emacs_write): Rewrite to use it.
253 (emacswrite_sig, emacs_perror): New functions.
254 * xrdb.c (fatal): Don't invoke perror, since errno might be garbage.
255
2562013-07-08 Magnus Henoch <magnus.henoch@gmail.com> (tiny change).
257
258 * image.c (imagemagick_load_image): Do not use MagickExportImagePixels
259 on NS even if it is present. Pixmap on NS is a void*.
260
2612013-07-07 Paul Eggert <eggert@cs.ucla.edu>
262
263 Port to Ubuntu 10 (Bug#14803).
264 Problem reported by T.V. Raman.
265 * process.c (close_on_exec, accept4, process_socket):
266 Define these if !HAVE_ACCEPT4, not if !SOCK_CLOEXEC.
267
2682013-07-07 Eli Zaretskii <eliz@gnu.org>
269
270 * w32.c (sys_dup): Declare prototype.
271
272 * filelock.c:
273 * emacs.c:
274 * callproc.c [WINDOWSNT]: Include sys/socket.h.
275
2762013-07-07 Paul Eggert <eggert@cs.ucla.edu>
277
278 Make file descriptors close-on-exec when possible (Bug#14803).
279 This simplifies Emacs a bit, since it no longer needs to worry
280 about closing file descriptors by hand in some cases.
281 It also fixes some unlikely races. Not all such races, as
282 libraries often open files internally without setting
283 close-on-exec, but it's an improvement.
284 * alloc.c (valid_pointer_p) [!WINDOWSNT]:
285 * callproc.c (Fcall_process) [!MSDOS]:
286 * emacs.c (main) [!DOS_NT]:
287 * nsterm.m (ns_term_init):
288 * process.c (create_process):
289 Use 'pipe2' with O_CLOEXEC instead of 'pipe'.
290 * emacs.c (Fcall_process_region) [HAVE_MKOSTEMP]:
291 * filelock.c (create_lock_file) [HAVE_MKOSTEMP]:
292 Prefer mkostemp with O_CLOEXEC to mkstemp.
293 * callproc.c (relocate_fd) [!WINDOWSNT]:
294 * emacs.c (main): Use F_DUPFD_CLOEXEC, not plain F_DUPFD.
295 No need to use fcntl (..., F_SETFD, FD_CLOEXEC), since we're
296 now using pipe2.
297 * filelock.c (create_lock_file) [! HAVE_MKOSTEMP]:
298 Make the resulting file descriptor close-on-exec.
299 * lisp.h, lread.c, process.c (close_load_descs, close_process_descs):
300 * lread.c (load_descriptor_list, load_descriptor_unwind):
301 Remove; no longer needed. All uses removed.
302 * process.c (SOCK_CLOEXEC): Define to 0 if not supplied by system.
303 (close_on_exec, accept4, process_socket) [!SOCK_CLOEXEC]:
304 New functions.
305 (socket) [!SOCK_CLOEXEC]: Supply a substitute.
306 (Fmake_network_process, Fnetwork_interface_list):
307 (Fnetwork_interface_info, server_accept_connection):
308 Make newly-created socket close-on-exec.
309 * sysdep.c (emacs_open, emacs_fopen):
310 Make new-created descriptor close-on-exec.
311 * w32.c (fcntl): Support F_DUPFD_CLOEXEC well enough for Emacs.
312 * w32.c, w32.h (pipe2): Rename from 'pipe', with new flags arg.
313
3142013-07-07 Jan Djärv <jan.h.d@swipnet.se>
315
316 * nsterm.m (sendEvent:): Propagate keyboard events to modal windows
317 for NS_IMPL_GNUSTEP.
318
3192013-07-07 Paul Eggert <eggert@cs.ucla.edu>
320
321 Fix openp errno handling.
322 * callproc.c (Fcall_process): Preserve openp errno around close.
323 * lread.c (openp): Set errno when returning -1, as some callers
324 expect this.
325
3262013-07-06 Jan Djärv <jan.h.d@swipnet.se>
327
328 * nsterm.m (sendEvent:): Handle NSAPP_DATA2_RUNFILEDIALOG.
329
330 * nsterm.h (NSSavePanel): Update comment.
331 (NSAPP_DATA2_RUNFILEDIALOG): Define.
332 (ns_run_file_dialog): Declare.
333
334 * nsfns.m: Remove panelOK.
335 (ns_fd_data): New.
336 (ns_run_file_dialog): New function.
337 (Fns_read_file_name): Fill in ns_fd_data, post an event and start the
338 event loop, so file dialog is popped up by ns_run_file_dialog, called
339 by sendEvent (Bug#14578).
340 (EmacsSavePanel, EmacsOpenPanel): Remove ok and cancel methods.
341
3422013-07-06 Eli Zaretskii <eliz@gnu.org>
343
344 * xdisp.c (default_line_pixel_height): New function.
345 (pos_visible_p, move_it_vertically_backward, try_scrolling)
346 (try_cursor_movement, redisplay_window, try_window)
347 (try_window_id): Use it instead of FRAME_LINE_HEIGHT. (Bug#14771)
348
349 * window.c (window_scroll_pixel_based): use
350 default_line_pixel_height.
351
352 * dispextern.h (default_line_pixel_height): Add prototype.
353
354 * frame.c (x_set_line_spacing): Accept a float value for
355 line-spacing parameter, per the documentation.
356
357 * data.c (Fmultibyte_string_p): Doc fix.
358
3592013-07-05 Paul Eggert <eggert@cs.ucla.edu>
360
361 Use emacs_open more consistently when opening files.
362 This handles EINTR more consistently now, and makes it easier
363 to introduce other uniform changes to file descriptor handling.
364 * src/systdio.h: New file.
365 * src/buffer.c (mmap_init):
366 * cygw32.c (chdir_to_default_directory):
367 * dispnew.c (Fopen_termscript):
368 * emacs.c (Fdaemon_initialized):
369 * fileio.c (Fdo_auto_save):
370 * image.c (slurp_file, png_load_body, jpeg_load_body):
371 * keyboard.c (Fopen_dribble_file):
372 * lread.c (Fload):
373 * print.c (Fredirect_debugging_output):
374 * sysdep.c (get_up_time, procfs_ttyname, procfs_get_total_memory):
375 * termcap.c (tgetent):
376 * unexaix.c, unexcoff.c (unexec, adjust_lnnoptrs):
377 * unexcw.c, unexelf.c, unexhp9k800.c, unexmacosx.c (unexec):
378 * w32term.c (w32_initialize) [CYGWIN]:
379 * xfaces.c (Fx_load_color_file):
380 Use emacs_open instead of plain open, and emacs_fopen instead of
381 plain fopen.
382 * dispnew.c, fileio.c, image.c, keyboard.c, lread.c, print.c, sysdep.c:
383 * xfaces.c: Include sysstdio.h rather than stdio.h, for emacs_fopen.
384 * callproc.c (default_output_mode): New constant.
385 (Fcall_process): Use it to call emacs_open instead of plain creat.
386 * dispnew.c (Fopen_termscript): Fix minor race in opening termscript.
387 * sysdep.c (emacs_open): Add commentary and don't call file name "path".
388 (emacs_fopen): New function.
389 * unexaix.c, unexcoff.c, unexelf.c, unexhp9k800.c, unexmacosx.c:
390 Include <lisp.h>, for emacs_open.
391 * unexelf.c (fatal): Remove decl; not needed with <lisp.h> included.
392
393 Remove duplicate #include directives.
394 * alloc.c [GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES]:
395 * xfaces.c:
396 Don't include stdio.h twice.
397 * buffer.c [USE_MMAP_FOR_BUFFERS]:
398 Don't include sys/types.h or stdio.h twice.
399 * fileio.c [WINDOWSNT | MSDOS]: Don't include fcntl.h twice.
400 * lread.c: Don't include coding.h twice.
401 * nsfont.m: Don't include frame.h twice.
402 * process.c [HAVE_RES_INIT]: Don't include <netinet/in.h> twice.
403 * ralloc.c: Don't include <unistd.h> twice.
404 * xdisp.c: Don't include font.h twice.
405 * xterm.c: Don't include fontset.h twice.
406 * xterm.h [USE_X_TOOLKIT]: Don't include X11/StringDefs.h twice.
407
4082013-07-04 Paul Eggert <eggert@cs.ucla.edu>
409
410 Scale ImageMagick images more carefully.
411 * image.c (scale_image_size) [HAVE_IMAGEMAGICK]: New function.
412 (compute_image_size): Use it. Define only if HAVE_IMAGEMAGICK.
413 Be more careful about avoiding undefined behavior after
414 integer overflow and division by zero.
415
4162013-07-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
417
418 * w32fns.c (Qgeometry, Qworkarea, Qmm_size, Qframes): New variables.
419 (syms_of_w32fns): DEFSYM them.
420 (MONITORINFOF_PRIMARY, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN)
421 (CCHDEVICENAME): Define macros if not defined.
422 (struct MONITOR_INFO_EX): New struct.
423 (MonitorEnum_Proc, EnumDisplayMonitors_Proc): New prototypes.
424 (enum_display_monitors_fn): New variable.
425 (globals_of_w32fns): Initialize it.
426 (Fx_display_pixel_width, Fx_display_pixel_height)
427 (Fx_display_mm_height, Fx_display_mm_width): Mention behavior on
428 multi-monitor setups in docstrings.
429 (Fx_display_mm_height, Fx_display_mm_width): Approximate whole
430 screen size by primary monitor's millimeter per pixel.
431 (w32_monitor_enum, w32_display_monitor_attributes_list)
432 (w32_display_monitor_attributes_list_fallback)
433 (Fw32_display_monitor_attributes_list): New functions.
434 (syms_of_w32fns): Defsubr Sw32_display_monitor_attributes_list.
435
436 * w32term.c (SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN): Define macros
437 if not defined.
438 (x_display_pixel_height, x_display_pixel_width): Use GetSystemMetrics.
439
4402013-07-04 Michael Albinus <michael.albinus@gmx.de>
441
442 * fileio.c (Qfile_notify_error): New error symbol.
443
444 * gfilenotify.c (Fgfile_add_watch, Fgfile_rm_watch):
445 * inotify.c (inotify_callback, symbol_to_inotifymask)
446 (Finotify_add_watch, Finotify_rm_watch): Use it.
447 (inotifyevent_to_event): Exchange order of cookie and file name.
448 (Finotify_add_watch): Adapt docstring.
449
450 * lisp.h (Qfile_notify_error): Declare.
451
4522013-07-04 Paul Eggert <eggert@cs.ucla.edu>
453
454 Try again to fix FreeBSD bug re multithreaded memory alloc (Bug#14569).
455 * emacs.c (main) [HAVE_PTHREAD && !SYSTEM_MALLOC && !DOUG_LEA_MALLOC]:
456 Do not clear _malloc_thread_enabled_p, undoing the previous change,
457 which did not work (see <http://bugs.gnu.org/14569#307>).
458 (main): Do not invoke malloc_enable_thread if (! CANNOT_DUMP
459 && (!noninteractive || initialized)). This attempts to thread
460 the needle between the Scylla of FreeBSD and the Charybdis of Cygwin.
461
4622013-07-04 Juanma Barranquero <lekktu@gmail.com>
463
464 * image.c (x_to_xcolors) [HAVE_NTGUI]: Remove unused var `hdc'.
465 (x_build_heuristic_mask) [HAVE_NTGUI]: Remove unused var `frame_dc'.
466
4672013-07-04 Paul Eggert <eggert@cs.ucla.edu>
468
469 Try to fix FreeBSD bug re multithreaded memory allocation (Bug#14569).
470 * emacs.c (main) [HAVE_PTHREAD && !SYSTEM_MALLOC && !DOUG_LEA_MALLOC]:
471 Clear _malloc_thread_enabled_p at startup. Reported by Ashish SHUKLA in
472 <http://lists.gnu.org/archive/html/emacs-devel/2013-07/msg00088.html>.
473
12013-07-02 Paul Eggert <eggert@cs.ucla.edu> 4742013-07-02 Paul Eggert <eggert@cs.ucla.edu>
2 475
3 * sysdep.c (sys_siglist) [HAVE_DECL___SYS_SIGLIST]: 476 * sysdep.c (sys_siglist) [HAVE_DECL___SYS_SIGLIST]:
@@ -507,7 +980,7 @@
507 (VALMASK): Also a constant, for benefit of old GDB. 980 (VALMASK): Also a constant, for benefit of old GDB.
508 (LISP_INT_TAG_P): Remove; no longer needed as the only caller 981 (LISP_INT_TAG_P): Remove; no longer needed as the only caller
509 is INTEGERP, which can fold it in. 982 is INTEGERP, which can fold it in.
510 (XLI, XIL, XHASH, XTYPE,XINT, XFASTINT, XUINT) 983 (XLI, XIL, XHASH, XTYPE, XINT, XFASTINT, XUINT)
511 (make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL) 984 (make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL)
512 (XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE) 985 (XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE)
513 (XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE) 986 (XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE)
diff --git a/src/alloc.c b/src/alloc.c
index b625e1f27e0..b71cdb98d78 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -247,10 +247,6 @@ enum mem_type
247 247
248#if GC_MARK_STACK || defined GC_MALLOC_CHECK 248#if GC_MARK_STACK || defined GC_MALLOC_CHECK
249 249
250#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
251#include <stdio.h> /* For fprintf. */
252#endif
253
254/* A unique object in pure space used to make some Lisp objects 250/* A unique object in pure space used to make some Lisp objects
255 on free lists recognizable in O(1). */ 251 on free lists recognizable in O(1). */
256 252
@@ -4745,7 +4741,7 @@ valid_pointer_p (void *p)
4745 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may 4741 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
4746 not validate p in that case. */ 4742 not validate p in that case. */
4747 4743
4748 if (pipe (fd) == 0) 4744 if (pipe2 (fd, O_CLOEXEC) == 0)
4749 { 4745 {
4750 bool valid = emacs_write (fd[1], (char *) p, 16) == 16; 4746 bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
4751 emacs_close (fd[1]); 4747 emacs_close (fd[1]);
diff --git a/src/atimer.c b/src/atimer.c
index 73c7aa5686b..bb5294670d3 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -336,7 +336,7 @@ schedule_atimer (struct atimer *t)
336 struct atimer *a = atimers, *prev = NULL; 336 struct atimer *a = atimers, *prev = NULL;
337 337
338 /* Look for the first atimer that is ripe after T. */ 338 /* Look for the first atimer that is ripe after T. */
339 while (a && EMACS_TIME_GT (t->expiration, a->expiration)) 339 while (a && EMACS_TIME_LT (a->expiration, t->expiration))
340 prev = a, a = a->next; 340 prev = a, a = a->next;
341 341
342 /* Insert T in front of the atimer found, if any. */ 342 /* Insert T in front of the atimer found, if any. */
diff --git a/src/buffer.c b/src/buffer.c
index 3bb80c66ee6..44371144687 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4612,7 +4612,6 @@ evaporate_overlays (ptrdiff_t pos)
4612 4612
4613#ifdef USE_MMAP_FOR_BUFFERS 4613#ifdef USE_MMAP_FOR_BUFFERS
4614 4614
4615#include <sys/types.h>
4616#include <sys/mman.h> 4615#include <sys/mman.h>
4617 4616
4618#ifndef MAP_ANON 4617#ifndef MAP_ANON
@@ -4627,8 +4626,6 @@ evaporate_overlays (ptrdiff_t pos)
4627#define MAP_FAILED ((void *) -1) 4626#define MAP_FAILED ((void *) -1)
4628#endif 4627#endif
4629 4628
4630#include <stdio.h>
4631
4632#if MAP_ANON == 0 4629#if MAP_ANON == 0
4633#include <fcntl.h> 4630#include <fcntl.h>
4634#endif 4631#endif
@@ -4738,7 +4735,7 @@ mmap_init (void)
4738 if (mmap_fd <= 0) 4735 if (mmap_fd <= 0)
4739 { 4736 {
4740 /* No anonymous mmap -- we need the file descriptor. */ 4737 /* No anonymous mmap -- we need the file descriptor. */
4741 mmap_fd = open ("/dev/zero", O_RDONLY); 4738 mmap_fd = emacs_open ("/dev/zero", O_RDONLY, 0);
4742 if (mmap_fd == -1) 4739 if (mmap_fd == -1)
4743 fatal ("Cannot open /dev/zero: %s", emacs_strerror (errno)); 4740 fatal ("Cannot open /dev/zero: %s", emacs_strerror (errno));
4744 } 4741 }
@@ -6107,6 +6104,11 @@ and is the visited file's modification time, as of that time. If the
6107modification time of the most recent save is different, this entry is 6104modification time of the most recent save is different, this entry is
6108obsolete. 6105obsolete.
6109 6106
6107An entry (t . 0) means means the buffer was previously unmodified but
6108its time stamp was unknown because it was not associated with a file.
6109An entry (t . -1) is similar, except that it means the buffer's visited
6110file did not exist.
6111
6110An entry (nil PROPERTY VALUE BEG . END) indicates that a text property 6112An entry (nil PROPERTY VALUE BEG . END) indicates that a text property
6111was modified between BEG and END. PROPERTY is the property name, 6113was modified between BEG and END. PROPERTY is the property name,
6112and VALUE is the old value. 6114and VALUE is the old value.
diff --git a/src/bytecode.c b/src/bytecode.c
index d95c53bf055..c79027597f8 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -59,7 +59,8 @@ by Hallvard:
59 indirect threaded, using GCC's computed goto extension. This code, 59 indirect threaded, using GCC's computed goto extension. This code,
60 as currently implemented, is incompatible with BYTE_CODE_SAFE and 60 as currently implemented, is incompatible with BYTE_CODE_SAFE and
61 BYTE_CODE_METER. */ 61 BYTE_CODE_METER. */
62#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER) 62#if (defined __GNUC__ && !defined __STRICT_ANSI__ \
63 && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER)
63#define BYTE_CODE_THREADED 64#define BYTE_CODE_THREADED
64#endif 65#endif
65 66
@@ -285,8 +286,10 @@ enum byte_code_op
285 286
286#ifdef BYTE_CODE_SAFE 287#ifdef BYTE_CODE_SAFE
287 Bscan_buffer = 0153, /* No longer generated as of v18. */ 288 Bscan_buffer = 0153, /* No longer generated as of v18. */
288 Bset_mark = 0163 /* this loser is no longer generated as of v18 */ 289 Bset_mark = 0163, /* this loser is no longer generated as of v18 */
289#endif 290#endif
291
292 B__dummy__ = 0 /* Pacify C89. */
290}; 293};
291 294
292/* Whether to maintain a `top' and `bottom' field in the stack frame. */ 295/* Whether to maintain a `top' and `bottom' field in the stack frame. */
diff --git a/src/callproc.c b/src/callproc.c
index f0aa8222342..cdf92422b4d 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32#ifdef WINDOWSNT 32#ifdef WINDOWSNT
33#define NOMINMAX 33#define NOMINMAX
34#include <sys/socket.h> /* for fcntl */
34#include <windows.h> 35#include <windows.h>
35#include "w32.h" 36#include "w32.h"
36#define _P_NOWAIT 1 /* from process.h */ 37#define _P_NOWAIT 1 /* from process.h */
@@ -186,6 +187,12 @@ call_process_cleanup (Lisp_Object arg)
186 return Qnil; 187 return Qnil;
187} 188}
188 189
190#ifdef DOS_NT
191static mode_t const default_output_mode = S_IREAD | S_IWRITE;
192#else
193static mode_t const default_output_mode = 0666;
194#endif
195
189DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0, 196DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
190 doc: /* Call PROGRAM synchronously in separate process. 197 doc: /* Call PROGRAM synchronously in separate process.
191The remaining arguments are optional. 198The remaining arguments are optional.
@@ -407,18 +414,15 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
407 414
408 if (STRINGP (output_file)) 415 if (STRINGP (output_file))
409 { 416 {
410#ifdef DOS_NT
411 fd_output = emacs_open (SSDATA (output_file), 417 fd_output = emacs_open (SSDATA (output_file),
412 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, 418 O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
413 S_IREAD | S_IWRITE); 419 default_output_mode);
414#else /* not DOS_NT */
415 fd_output = creat (SSDATA (output_file), 0666);
416#endif /* not DOS_NT */
417 if (fd_output < 0) 420 if (fd_output < 0)
418 { 421 {
422 int open_errno = errno;
419 output_file = DECODE_FILE (output_file); 423 output_file = DECODE_FILE (output_file);
420 report_file_error ("Opening process output file", 424 report_file_errno ("Opening process output file",
421 Fcons (output_file, Qnil)); 425 Fcons (output_file, Qnil), open_errno);
422 } 426 }
423 if (STRINGP (error_file) || NILP (error_file)) 427 if (STRINGP (error_file) || NILP (error_file))
424 output_to_buffer = 0; 428 output_to_buffer = 0;
@@ -427,16 +431,19 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
427 /* Search for program; barf if not found. */ 431 /* Search for program; barf if not found. */
428 { 432 {
429 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 433 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
434 int ok;
430 435
431 GCPRO4 (infile, buffer, current_dir, error_file); 436 GCPRO4 (infile, buffer, current_dir, error_file);
432 openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK)); 437 ok = openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK));
433 UNGCPRO; 438 UNGCPRO;
439 if (ok < 0)
440 {
441 int openp_errno = errno;
442 emacs_close (filefd);
443 report_file_errno ("Searching for program",
444 Fcons (args[0], Qnil), openp_errno);
445 }
434 } 446 }
435 if (NILP (path))
436 {
437 emacs_close (filefd);
438 report_file_error ("Searching for program", Fcons (args[0], Qnil));
439 }
440 447
441 /* If program file name starts with /: for quoting a magic name, 448 /* If program file name starts with /: for quoting a magic name,
442 discard that. */ 449 discard that. */
@@ -492,12 +499,15 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
492 strcat (tempfile, "/"); 499 strcat (tempfile, "/");
493 strcat (tempfile, "detmp.XXX"); 500 strcat (tempfile, "detmp.XXX");
494 mktemp (tempfile); 501 mktemp (tempfile);
495 outfilefd = creat (tempfile, S_IREAD | S_IWRITE); 502 outfilefd = emacs_open (tempfile, O_WRONLY | O_CREAT | O_TRUNC,
496 if (outfilefd < 0) { 503 S_IREAD | S_IWRITE);
497 emacs_close (filefd); 504 if (outfilefd < 0)
498 report_file_error ("Opening process output file", 505 {
499 Fcons (build_string (tempfile), Qnil)); 506 int open_errno = errno;
500 } 507 emacs_close (filefd);
508 report_file_errno ("Opening process output file",
509 Fcons (build_string (tempfile), Qnil), open_errno);
510 }
501 } 511 }
502 else 512 else
503 outfilefd = fd_output; 513 outfilefd = fd_output;
@@ -514,12 +524,11 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
514 { 524 {
515#ifndef MSDOS 525#ifndef MSDOS
516 int fd[2]; 526 int fd[2];
517 if (pipe (fd) == -1) 527 if (pipe2 (fd, O_CLOEXEC) != 0)
518 { 528 {
519 int pipe_errno = errno; 529 int pipe_errno = errno;
520 emacs_close (filefd); 530 emacs_close (filefd);
521 errno = pipe_errno; 531 report_file_errno ("Creating process pipe", Qnil, pipe_errno);
522 report_file_error ("Creating process pipe", Qnil);
523 } 532 }
524 fd0 = fd[0]; 533 fd0 = fd[0];
525 fd1 = fd[1]; 534 fd1 = fd[1];
@@ -535,18 +544,13 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
535 if (NILP (error_file)) 544 if (NILP (error_file))
536 fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0); 545 fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0);
537 else if (STRINGP (error_file)) 546 else if (STRINGP (error_file))
538 { 547 fd_error = emacs_open (SSDATA (error_file),
539#ifdef DOS_NT 548 O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
540 fd_error = emacs_open (SSDATA (error_file), 549 default_output_mode);
541 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
542 S_IREAD | S_IWRITE);
543#else /* not DOS_NT */
544 fd_error = creat (SSDATA (error_file), 0666);
545#endif /* not DOS_NT */
546 }
547 550
548 if (fd_error < 0) 551 if (fd_error < 0)
549 { 552 {
553 int open_errno = errno;
550 emacs_close (filefd); 554 emacs_close (filefd);
551 if (fd0 != filefd) 555 if (fd0 != filefd)
552 emacs_close (fd0); 556 emacs_close (fd0);
@@ -559,7 +563,8 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
559 error_file = build_string (NULL_DEVICE); 563 error_file = build_string (NULL_DEVICE);
560 else if (STRINGP (error_file)) 564 else if (STRINGP (error_file))
561 error_file = DECODE_FILE (error_file); 565 error_file = DECODE_FILE (error_file);
562 report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil)); 566 report_file_errno ("Cannot redirect stderr",
567 Fcons (error_file, Qnil), open_errno);
563 } 568 }
564 569
565#ifdef MSDOS /* MW, July 1993 */ 570#ifdef MSDOS /* MW, July 1993 */
@@ -587,10 +592,12 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
587 fd0 = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); 592 fd0 = emacs_open (tempfile, O_RDONLY | O_BINARY, 0);
588 if (fd0 < 0) 593 if (fd0 < 0)
589 { 594 {
595 int open_errno = errno;
590 unlink (tempfile); 596 unlink (tempfile);
591 emacs_close (filefd); 597 emacs_close (filefd);
592 report_file_error ("Cannot re-open temporary file", 598 report_file_errno ("Cannot re-open temporary file",
593 Fcons (build_string (tempfile), Qnil)); 599 Fcons (build_string (tempfile), Qnil),
600 open_errno);
594 } 601 }
595 } 602 }
596 else 603 else
@@ -708,10 +715,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
708 } 715 }
709 716
710 if (pid < 0) 717 if (pid < 0)
711 { 718 report_file_errno ("Doing vfork", Qnil, child_errno);
712 errno = child_errno;
713 report_file_error ("Doing vfork", Qnil);
714 }
715 719
716 if (INTEGERP (buffer)) 720 if (INTEGERP (buffer))
717 return unbind_to (count, Qnil); 721 return unbind_to (count, Qnil);
@@ -1037,29 +1041,29 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
1037 memcpy (tempfile, SDATA (encoded_tem), SBYTES (encoded_tem) + 1); 1041 memcpy (tempfile, SDATA (encoded_tem), SBYTES (encoded_tem) + 1);
1038 coding_systems = Qt; 1042 coding_systems = Qt;
1039 1043
1040#ifdef HAVE_MKSTEMP 1044#if defined HAVE_MKOSTEMP || defined HAVE_MKSTEMP
1041 { 1045 {
1042 int fd; 1046 int fd, open_errno;
1043 1047
1044 block_input (); 1048 block_input ();
1049# ifdef HAVE_MKOSTEMP
1050 fd = mkostemp (tempfile, O_CLOEXEC);
1051# else
1045 fd = mkstemp (tempfile); 1052 fd = mkstemp (tempfile);
1053# endif
1054 open_errno = errno;
1046 unblock_input (); 1055 unblock_input ();
1047 if (fd == -1) 1056 if (fd < 0)
1048 report_file_error ("Failed to open temporary file", 1057 report_file_errno ("Failed to open temporary file",
1049 Fcons (build_string (tempfile), Qnil)); 1058 Fcons (build_string (tempfile), Qnil), open_errno);
1050 else 1059 emacs_close (fd);
1051 close (fd);
1052 } 1060 }
1053#else 1061#else
1054 errno = 0; 1062 errno = EEXIST;
1055 mktemp (tempfile); 1063 mktemp (tempfile);
1056 if (!*tempfile) 1064 if (!*tempfile)
1057 { 1065 report_file_error ("Failed to open temporary file using pattern",
1058 if (!errno) 1066 Fcons (pattern, Qnil));
1059 errno = EEXIST;
1060 report_file_error ("Failed to open temporary file using pattern",
1061 Fcons (pattern, Qnil));
1062 }
1063#endif 1067#endif
1064 1068
1065 filename_string = build_string (tempfile); 1069 filename_string = build_string (tempfile);
@@ -1185,15 +1189,6 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1185 1189
1186 pid_t pid = getpid (); 1190 pid_t pid = getpid ();
1187 1191
1188 /* Close Emacs's descriptors that this process should not have. */
1189 close_process_descs ();
1190
1191 /* DOS_NT isn't in a vfork, so if we are in the middle of load-file,
1192 we will lose if we call close_load_descs here. */
1193#ifndef DOS_NT
1194 close_load_descs ();
1195#endif
1196
1197 /* Note that use of alloca is always safe here. It's obvious for systems 1192 /* Note that use of alloca is always safe here. It's obvious for systems
1198 that do not have true vfork or that have true (stack) alloca. 1193 that do not have true vfork or that have true (stack) alloca.
1199 If using vfork and C_ALLOCA (when Emacs used to include 1194 If using vfork and C_ALLOCA (when Emacs used to include
@@ -1226,7 +1221,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1226 are changed between the check and this chdir, but we should 1221 are changed between the check and this chdir, but we should
1227 at least check. */ 1222 at least check. */
1228 if (chdir (temp) < 0) 1223 if (chdir (temp) < 0)
1229 _exit (errno); 1224 _exit (EXIT_CANCELED);
1230#else /* DOS_NT */ 1225#else /* DOS_NT */
1231 /* Get past the drive letter, so that d:/ is left alone. */ 1226 /* Get past the drive letter, so that d:/ is left alone. */
1232 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2])) 1227 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2]))
@@ -1351,28 +1346,24 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1351 } 1346 }
1352 1347
1353#ifndef MSDOS 1348#ifndef MSDOS
1354 emacs_close (0); 1349 /* Redirect file descriptors and clear the close-on-exec flag on the
1355 emacs_close (1); 1350 redirected ones. IN, OUT, and ERR are close-on-exec so they
1356 emacs_close (2); 1351 need not be closed explicitly. */
1357
1358 dup2 (in, 0); 1352 dup2 (in, 0);
1359 dup2 (out, 1); 1353 dup2 (out, 1);
1360 dup2 (err, 2); 1354 dup2 (err, 2);
1361 emacs_close (in);
1362 if (out != in)
1363 emacs_close (out);
1364 if (err != in && err != out)
1365 emacs_close (err);
1366 1355
1367 setpgid (0, 0); 1356 setpgid (0, 0);
1368 tcsetpgrp (0, pid); 1357 tcsetpgrp (0, pid);
1369 1358
1370 execve (new_argv[0], new_argv, env); 1359 execve (new_argv[0], new_argv, env);
1371 1360
1372 emacs_write (1, "Can't exec program: ", 20); 1361 /* Don't output the program name here, as it can be arbitrarily long,
1373 emacs_write (1, new_argv[0], strlen (new_argv[0])); 1362 and a long write from a vforked child to its parent can cause a
1374 emacs_write (1, "\n", 1); 1363 deadlock. */
1375 _exit (1); 1364 emacs_perror ("child process");
1365
1366 _exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
1376 1367
1377#else /* MSDOS */ 1368#else /* MSDOS */
1378 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); 1369 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env);
@@ -1387,7 +1378,8 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1387 1378
1388#ifndef WINDOWSNT 1379#ifndef WINDOWSNT
1389/* Move the file descriptor FD so that its number is not less than MINFD. 1380/* Move the file descriptor FD so that its number is not less than MINFD.
1390 If the file descriptor is moved at all, the original is freed. */ 1381 If the file descriptor is moved at all, the original is closed on MSDOS,
1382 but not elsewhere as the caller will close it anyway. */
1391static int 1383static int
1392relocate_fd (int fd, int minfd) 1384relocate_fd (int fd, int minfd)
1393{ 1385{
@@ -1395,18 +1387,15 @@ relocate_fd (int fd, int minfd)
1395 return fd; 1387 return fd;
1396 else 1388 else
1397 { 1389 {
1398 int new = fcntl (fd, F_DUPFD, minfd); 1390 int new = fcntl (fd, F_DUPFD_CLOEXEC, minfd);
1399 if (new == -1) 1391 if (new == -1)
1400 { 1392 {
1401 const char *message_1 = "Error while setting up child: "; 1393 emacs_perror ("while setting up child");
1402 const char *errmessage = strerror (errno); 1394 _exit (EXIT_CANCELED);
1403 const char *message_2 = "\n";
1404 emacs_write (2, message_1, strlen (message_1));
1405 emacs_write (2, errmessage, strlen (errmessage));
1406 emacs_write (2, message_2, strlen (message_2));
1407 _exit (1);
1408 } 1395 }
1396#ifdef MSDOS
1409 emacs_close (fd); 1397 emacs_close (fd);
1398#endif
1410 return new; 1399 return new;
1411 } 1400 }
1412} 1401}
diff --git a/src/coding.c b/src/coding.c
index 1ab59294b98..a1494ad38aa 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -11218,6 +11218,8 @@ character.");
11218 plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); 11218 plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding.");
11219 plist[15] = args[coding_arg_eol_type] = Qnil; 11219 plist[15] = args[coding_arg_eol_type] = Qnil;
11220 args[coding_arg_plist] = Flist (16, plist); 11220 args[coding_arg_plist] = Flist (16, plist);
11221 args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0);
11222 args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0);
11221 Fdefine_coding_system_internal (coding_arg_undecided_max, args); 11223 Fdefine_coding_system_internal (coding_arg_undecided_max, args);
11222 } 11224 }
11223 11225
diff --git a/src/cygw32.c b/src/cygw32.c
index a7dbdaed615..bbc3a49fd88 100644
--- a/src/cygw32.c
+++ b/src/cygw32.c
@@ -35,7 +35,7 @@ static void
35chdir_to_default_directory () 35chdir_to_default_directory ()
36{ 36{
37 Lisp_Object new_cwd; 37 Lisp_Object new_cwd;
38 int old_cwd_fd = open (".", O_RDONLY | O_DIRECTORY); 38 int old_cwd_fd = emacs_open (".", O_RDONLY | O_DIRECTORY, 0);
39 39
40 if (old_cwd_fd == -1) 40 if (old_cwd_fd == -1)
41 error ("could not open current directory: %s", strerror (errno)); 41 error ("could not open current directory: %s", strerror (errno));
diff --git a/src/data.c b/src/data.c
index 955c39727bb..dedbd51f36e 100644
--- a/src/data.c
+++ b/src/data.c
@@ -377,7 +377,8 @@ DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0,
377 377
378DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p, 378DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p,
379 1, 1, 0, 379 1, 1, 0,
380 doc: /* Return t if OBJECT is a multibyte string. */) 380 doc: /* Return t if OBJECT is a multibyte string.
381Return nil if OBJECT is either a unibyte string, or not a string. */)
381 (Lisp_Object object) 382 (Lisp_Object object)
382{ 383{
383 if (STRINGP (object) && STRING_MULTIBYTE (object)) 384 if (STRINGP (object) && STRING_MULTIBYTE (object))
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 3ec3c28431b..523544d56ca 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -142,7 +142,10 @@ static bool xd_in_read_queued_messages = 0;
142 } while (0) 142 } while (0)
143 143
144#else /* !DBUS_DEBUG */ 144#else /* !DBUS_DEBUG */
145#define XD_DEBUG_MESSAGE(...) \ 145# if __STDC_VERSION__ < 199901
146# define XD_DEBUG_MESSAGE (void) /* Pre-C99 compilers cannot debug. */
147# else
148# define XD_DEBUG_MESSAGE(...) \
146 do { \ 149 do { \
147 if (!NILP (Vdbus_debug)) \ 150 if (!NILP (Vdbus_debug)) \
148 { \ 151 { \
@@ -151,7 +154,8 @@ static bool xd_in_read_queued_messages = 0;
151 message ("%s: %s", __func__, s); \ 154 message ("%s: %s", __func__, s); \
152 } \ 155 } \
153 } while (0) 156 } while (0)
154#define XD_DEBUG_VALID_LISP_OBJECT_P(object) 157# endif
158# define XD_DEBUG_VALID_LISP_OBJECT_P(object)
155#endif 159#endif
156 160
157/* Check whether TYPE is a basic DBusType. */ 161/* Check whether TYPE is a basic DBusType. */
diff --git a/src/deps.mk b/src/deps.mk
index 83444474c59..39666dca515 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -190,7 +190,7 @@ sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
190 frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \ 190 frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \
191 globals.h $(config_h) composite.h sysselect.h gnutls.h \ 191 globals.h $(config_h) composite.h sysselect.h gnutls.h \
192 ../lib/allocator.h ../lib/careadlinkat.h \ 192 ../lib/allocator.h ../lib/careadlinkat.h \
193 ../lib/unistd.h ../lib/ignore-value.h 193 ../lib/unistd.h
194term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \ 194term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \
195 cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ 195 cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \
196 xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ 196 xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \
diff --git a/src/dired.c b/src/dired.c
index 7bbfee7e5b0..b3348b0aff0 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -95,7 +95,7 @@ open_directory (char const *name, int *fdp)
95 d = fdopendir (fd); 95 d = fdopendir (fd);
96 opendir_errno = errno; 96 opendir_errno = errno;
97 if (! d) 97 if (! d)
98 close (fd); 98 emacs_close (fd);
99 } 99 }
100#endif 100#endif
101 101
diff --git a/src/dispextern.h b/src/dispextern.h
index d1e62c8ea16..e5a43d820dc 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3144,6 +3144,7 @@ struct glyph_row *row_containing_pos (struct window *, ptrdiff_t,
3144 struct glyph_row *, 3144 struct glyph_row *,
3145 struct glyph_row *, int); 3145 struct glyph_row *, int);
3146int line_bottom_y (struct it *); 3146int line_bottom_y (struct it *);
3147int default_line_pixel_height (struct window *);
3147int display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); 3148int display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t);
3148void resize_echo_area_exactly (void); 3149void resize_echo_area_exactly (void);
3149int resize_mini_window (struct window *, int); 3150int resize_mini_window (struct window *, int);
@@ -3325,7 +3326,7 @@ int image_ascent (struct image *, struct face *, struct glyph_slice *);
3325void get_tty_size (int, int *, int *); 3326void get_tty_size (int, int *, int *);
3326void request_sigio (void); 3327void request_sigio (void);
3327void unrequest_sigio (void); 3328void unrequest_sigio (void);
3328int tabs_safe_p (int); 3329bool tabs_safe_p (int);
3329void init_baud_rate (int); 3330void init_baud_rate (int);
3330void init_sigio (int); 3331void init_sigio (int);
3331void ignore_sigio (void); 3332void ignore_sigio (void);
@@ -3497,11 +3498,12 @@ extern int string_cost (const char *);
3497extern int per_line_cost (const char *); 3498extern int per_line_cost (const char *);
3498extern void calculate_costs (struct frame *); 3499extern void calculate_costs (struct frame *);
3499extern void produce_glyphs (struct it *); 3500extern void produce_glyphs (struct it *);
3500extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, unsigned long); 3501extern bool tty_capable_p (struct tty_display_info *, unsigned,
3502 unsigned long, unsigned long);
3501extern void set_tty_color_mode (struct tty_display_info *, struct frame *); 3503extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
3502extern struct terminal *get_named_tty (const char *); 3504extern struct terminal *get_named_tty (const char *);
3503extern void create_tty_output (struct frame *); 3505extern void create_tty_output (struct frame *);
3504extern struct terminal *init_tty (const char *, const char *, int); 3506extern struct terminal *init_tty (const char *, const char *, bool);
3505extern void tty_append_glyph (struct it *); 3507extern void tty_append_glyph (struct it *);
3506 3508
3507 3509
diff --git a/src/dispnew.c b/src/dispnew.c
index ab73b6403ee..7db0a46d6da 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#define DISPEXTERN_INLINE EXTERN_INLINE 22#define DISPEXTERN_INLINE EXTERN_INLINE
23 23
24#include <stdio.h> 24#include "sysstdio.h"
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include "lisp.h" 27#include "lisp.h"
@@ -216,6 +216,7 @@ static void
216add_window_display_history (struct window *w, const char *msg, bool paused_p) 216add_window_display_history (struct window *w, const char *msg, bool paused_p)
217{ 217{
218 char *buf; 218 char *buf;
219 void *ptr = w;
219 220
220 if (history_idx >= REDISPLAY_HISTORY_SIZE) 221 if (history_idx >= REDISPLAY_HISTORY_SIZE)
221 history_idx = 0; 222 history_idx = 0;
@@ -225,7 +226,7 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
225 snprintf (buf, sizeof redisplay_history[0].trace, 226 snprintf (buf, sizeof redisplay_history[0].trace,
226 "%"pMu": window %p (`%s')%s\n%s", 227 "%"pMu": window %p (`%s')%s\n%s",
227 history_tick++, 228 history_tick++,
228 w, 229 ptr,
229 ((BUFFERP (w->contents) 230 ((BUFFERP (w->contents)
230 && STRINGP (BVAR (XBUFFER (w->contents), name))) 231 && STRINGP (BVAR (XBUFFER (w->contents), name)))
231 ? SSDATA (BVAR (XBUFFER (w->contents), name)) 232 ? SSDATA (BVAR (XBUFFER (w->contents), name))
@@ -242,6 +243,7 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
242static void add_frame_display_history (struct frame *f, int paused_p) 243static void add_frame_display_history (struct frame *f, int paused_p)
243{ 244{
244 char *buf; 245 char *buf;
246 void *ptr = f;
245 247
246 if (history_idx >= REDISPLAY_HISTORY_SIZE) 248 if (history_idx >= REDISPLAY_HISTORY_SIZE)
247 history_idx = 0; 249 history_idx = 0;
@@ -250,7 +252,7 @@ static void add_frame_display_history (struct frame *f, int paused_p)
250 252
251 sprintf (buf, "%"pMu": update frame %p%s", 253 sprintf (buf, "%"pMu": update frame %p%s",
252 history_tick++, 254 history_tick++,
253 f, paused_p ? " ***paused***" : ""); 255 ptr, paused_p ? " ***paused***" : "");
254} 256}
255 257
256 258
@@ -5616,17 +5618,17 @@ FILE = nil means just close any termscript file currently open. */)
5616 tty = CURTTY (); 5618 tty = CURTTY ();
5617 5619
5618 if (tty->termscript != 0) 5620 if (tty->termscript != 0)
5619 { 5621 {
5620 block_input (); 5622 block_input ();
5621 fclose (tty->termscript); 5623 fclose (tty->termscript);
5622 unblock_input (); 5624 tty->termscript = 0;
5623 } 5625 unblock_input ();
5624 tty->termscript = 0; 5626 }
5625 5627
5626 if (! NILP (file)) 5628 if (! NILP (file))
5627 { 5629 {
5628 file = Fexpand_file_name (file, Qnil); 5630 file = Fexpand_file_name (file, Qnil);
5629 tty->termscript = fopen (SSDATA (file), "w"); 5631 tty->termscript = emacs_fopen (SSDATA (file), "w");
5630 if (tty->termscript == 0) 5632 if (tty->termscript == 0)
5631 report_file_error ("Opening termscript", Fcons (file, Qnil)); 5633 report_file_error ("Opening termscript", Fcons (file, Qnil));
5632 } 5634 }
diff --git a/src/emacs.c b/src/emacs.c
index a1ad2d44b3b..08609ee6a08 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -28,12 +28,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include <unistd.h> 28#include <unistd.h>
29 29
30#include <close-stream.h> 30#include <close-stream.h>
31#include <ignore-value.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34 33
35#ifdef WINDOWSNT 34#ifdef WINDOWSNT
36#include <fcntl.h> 35#include <fcntl.h>
36#include <sys/socket.h>
37#include "w32.h" 37#include "w32.h"
38#include "w32heap.h" 38#include "w32heap.h"
39#endif 39#endif
@@ -204,10 +204,10 @@ int initial_argc;
204static void sort_args (int argc, char **argv); 204static void sort_args (int argc, char **argv);
205static void syms_of_emacs (void); 205static void syms_of_emacs (void);
206 206
207/* MSVC needs each string be shorter than 2048 bytes, so the usage 207/* C89 needs each string be at most 509 characters, so the usage
208 strings below are split to not overflow this limit. */ 208 strings below are split to not overflow this limit. */
209#define USAGE1 "\ 209static char const *const usage_message[] =
210Usage: %s [OPTION-OR-FILENAME]...\n\ 210 { "\
211\n\ 211\n\
212Run Emacs, the extensible, customizable, self-documenting real-time\n\ 212Run Emacs, the extensible, customizable, self-documenting real-time\n\
213display editor. The recommended way to start Emacs for normal editing\n\ 213display editor. The recommended way to start Emacs for normal editing\n\
@@ -218,11 +218,15 @@ read the main documentation for these command-line arguments.\n\
218\n\ 218\n\
219Initialization options:\n\ 219Initialization options:\n\
220\n\ 220\n\
221",
222 "\
221--batch do not do interactive display; implies -q\n\ 223--batch do not do interactive display; implies -q\n\
222--chdir DIR change to directory DIR\n\ 224--chdir DIR change to directory DIR\n\
223--daemon start a server in the background\n\ 225--daemon start a server in the background\n\
224--debug-init enable Emacs Lisp debugger for init file\n\ 226--debug-init enable Emacs Lisp debugger for init file\n\
225--display, -d DISPLAY use X server DISPLAY\n\ 227--display, -d DISPLAY use X server DISPLAY\n\
228",
229 "\
226--no-desktop do not load a saved desktop\n\ 230--no-desktop do not load a saved desktop\n\
227--no-init-file, -q load neither ~/.emacs nor default.el\n\ 231--no-init-file, -q load neither ~/.emacs nor default.el\n\
228--no-shared-memory, -nl do not use shared memory\n\ 232--no-shared-memory, -nl do not use shared memory\n\
@@ -230,14 +234,16 @@ Initialization options:\n\
230--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\ 234--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\
231--no-splash do not display a splash screen on startup\n\ 235--no-splash do not display a splash screen on startup\n\
232--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\ 236--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\
237",
238 "\
233--quick, -Q equivalent to:\n\ 239--quick, -Q equivalent to:\n\
234 -q --no-site-file --no-site-lisp --no-splash\n\ 240 -q --no-site-file --no-site-lisp --no-splash\n\
235--script FILE run FILE as an Emacs Lisp script\n\ 241--script FILE run FILE as an Emacs Lisp script\n\
236--terminal, -t DEVICE use DEVICE for terminal I/O\n\ 242--terminal, -t DEVICE use DEVICE for terminal I/O\n\
237--user, -u USER load ~USER/.emacs instead of your own\n\ 243--user, -u USER load ~USER/.emacs instead of your own\n\
238\n%s" 244\n\
239 245",
240#define USAGE2 "\ 246 "\
241Action options:\n\ 247Action options:\n\
242\n\ 248\n\
243FILE visit FILE using find-file\n\ 249FILE visit FILE using find-file\n\
@@ -246,6 +252,8 @@ FILE visit FILE using find-file\n\
246--directory, -L DIR add DIR to variable load-path\n\ 252--directory, -L DIR add DIR to variable load-path\n\
247--eval EXPR evaluate Emacs Lisp expression EXPR\n\ 253--eval EXPR evaluate Emacs Lisp expression EXPR\n\
248--execute EXPR evaluate Emacs Lisp expression EXPR\n\ 254--execute EXPR evaluate Emacs Lisp expression EXPR\n\
255",
256 "\
249--file FILE visit FILE using find-file\n\ 257--file FILE visit FILE using find-file\n\
250--find-file FILE visit FILE using find-file\n\ 258--find-file FILE visit FILE using find-file\n\
251--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\ 259--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
@@ -253,9 +261,9 @@ FILE visit FILE using find-file\n\
253--kill exit without asking for confirmation\n\ 261--kill exit without asking for confirmation\n\
254--load, -l FILE load Emacs Lisp FILE using the load function\n\ 262--load, -l FILE load Emacs Lisp FILE using the load function\n\
255--visit FILE visit FILE using find-file\n\ 263--visit FILE visit FILE using find-file\n\
256\n" 264\n\
257 265",
258#define USAGE3 "\ 266 "\
259Display options:\n\ 267Display options:\n\
260\n\ 268\n\
261--background-color, -bg COLOR window background color\n\ 269--background-color, -bg COLOR window background color\n\
@@ -263,6 +271,8 @@ Display options:\n\
263 used for debugging Emacs\n\ 271 used for debugging Emacs\n\
264--border-color, -bd COLOR main border color\n\ 272--border-color, -bd COLOR main border color\n\
265--border-width, -bw WIDTH width of main border\n\ 273--border-width, -bw WIDTH width of main border\n\
274",
275 "\
266--color, --color=MODE override color mode for character terminals;\n\ 276--color, --color=MODE override color mode for character terminals;\n\
267 MODE defaults to `auto', and\n\ 277 MODE defaults to `auto', and\n\
268 can also be `never', `always',\n\ 278 can also be `never', `always',\n\
@@ -270,17 +280,23 @@ Display options:\n\
270--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\ 280--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\
271--font, -fn FONT default font; must be fixed-width\n\ 281--font, -fn FONT default font; must be fixed-width\n\
272--foreground-color, -fg COLOR window foreground color\n\ 282--foreground-color, -fg COLOR window foreground color\n\
283",
284 "\
273--fullheight, -fh make the first frame high as the screen\n\ 285--fullheight, -fh make the first frame high as the screen\n\
274--fullscreen, -fs make the first frame fullscreen\n\ 286--fullscreen, -fs make the first frame fullscreen\n\
275--fullwidth, -fw make the first frame wide as the screen\n\ 287--fullwidth, -fw make the first frame wide as the screen\n\
276--maximized, -mm make the first frame maximized\n\ 288--maximized, -mm make the first frame maximized\n\
277--geometry, -g GEOMETRY window geometry\n\ 289--geometry, -g GEOMETRY window geometry\n\
290",
291 "\
278--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\ 292--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
279--iconic start Emacs in iconified state\n\ 293--iconic start Emacs in iconified state\n\
280--internal-border, -ib WIDTH width between text and main border\n\ 294--internal-border, -ib WIDTH width between text and main border\n\
281--line-spacing, -lsp PIXELS additional space to put between lines\n\ 295--line-spacing, -lsp PIXELS additional space to put between lines\n\
282--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\ 296--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\
283--name NAME title for initial Emacs frame\n\ 297--name NAME title for initial Emacs frame\n\
298",
299 "\
284--no-blinking-cursor, -nbc disable blinking cursor\n\ 300--no-blinking-cursor, -nbc disable blinking cursor\n\
285--reverse-video, -r, -rv switch foreground and background\n\ 301--reverse-video, -r, -rv switch foreground and background\n\
286--title, -T TITLE title for initial Emacs frame\n\ 302--title, -T TITLE title for initial Emacs frame\n\
@@ -289,9 +305,9 @@ Display options:\n\
289--parent-id XID set parent window\n\ 305--parent-id XID set parent window\n\
290--help display this help and exit\n\ 306--help display this help and exit\n\
291--version output version information and exit\n\ 307--version output version information and exit\n\
292\n" 308\n\
293 309",
294#define USAGE4 "\ 310 "\
295You can generally also specify long option names with a single -; for\n\ 311You can generally also specify long option names with a single -; for\n\
296example, -batch as well as --batch. You can use any unambiguous\n\ 312example, -batch as well as --batch. You can use any unambiguous\n\
297abbreviation for a --option.\n\ 313abbreviation for a --option.\n\
@@ -301,6 +317,7 @@ Emacs' operation. See the main documentation.\n\
301\n\ 317\n\
302Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\ 318Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\
303section of the Emacs manual or the file BUGS.\n" 319section of the Emacs manual or the file BUGS.\n"
320 };
304 321
305 322
306/* True if handling a fatal error already. */ 323/* True if handling a fatal error already. */
@@ -648,9 +665,7 @@ close_output_streams (void)
648{ 665{
649 if (close_stream (stdout) != 0) 666 if (close_stream (stdout) != 0)
650 { 667 {
651 fprintf (stderr, "Write error to standard output: %s\n", 668 emacs_perror ("Write error to standard output");
652 strerror (errno));
653 fflush (stderr);
654 _exit (EXIT_FAILURE); 669 _exit (EXIT_FAILURE);
655 } 670 }
656 671
@@ -791,7 +806,7 @@ main (int argc, char **argv)
791 execvp (argv[0], argv); 806 execvp (argv[0], argv);
792 807
793 /* If the exec fails, try to dump anyway. */ 808 /* If the exec fails, try to dump anyway. */
794 perror ("execvp"); 809 emacs_perror (argv[0]);
795 } 810 }
796#endif /* HAVE_PERSONALITY_LINUX32 */ 811#endif /* HAVE_PERSONALITY_LINUX32 */
797 812
@@ -892,7 +907,7 @@ main (int argc, char **argv)
892 emacs_close (0); 907 emacs_close (0);
893 emacs_close (1); 908 emacs_close (1);
894 result = emacs_open (term, O_RDWR, 0); 909 result = emacs_open (term, O_RDWR, 0);
895 if (result < 0 || dup (0) < 0) 910 if (result < 0 || fcntl (0, F_DUPFD_CLOEXEC, 1) < 0)
896 { 911 {
897 char *errstring = strerror (errno); 912 char *errstring = strerror (errno);
898 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring); 913 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);
@@ -939,9 +954,10 @@ main (int argc, char **argv)
939 /* Handle the --help option, which gives a usage message. */ 954 /* Handle the --help option, which gives a usage message. */
940 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args)) 955 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
941 { 956 {
942 printf (USAGE1, argv[0], USAGE2); 957 int i;
943 printf (USAGE3); 958 printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]);
944 printf (USAGE4); 959 for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
960 fputs (usage_message[i], stdout);
945 exit (0); 961 exit (0);
946 } 962 }
947 963
@@ -972,7 +988,7 @@ main (int argc, char **argv)
972 use a pipe for synchronization. The parent waits for the child 988 use a pipe for synchronization. The parent waits for the child
973 to close its end of the pipe (using `daemon-initialized') 989 to close its end of the pipe (using `daemon-initialized')
974 before exiting. */ 990 before exiting. */
975 if (pipe (daemon_pipe) == -1) 991 if (pipe2 (daemon_pipe, O_CLOEXEC) != 0)
976 { 992 {
977 fprintf (stderr, "Cannot pipe!\n"); 993 fprintf (stderr, "Cannot pipe!\n");
978 exit (1); 994 exit (1);
@@ -997,7 +1013,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
997 char buf[1]; 1013 char buf[1];
998 1014
999 /* Close unused writing end of the pipe. */ 1015 /* Close unused writing end of the pipe. */
1000 close (daemon_pipe[1]); 1016 emacs_close (daemon_pipe[1]);
1001 1017
1002 /* Just wait for the child to close its end of the pipe. */ 1018 /* Just wait for the child to close its end of the pipe. */
1003 do 1019 do
@@ -1017,13 +1033,13 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1017 exit (1); 1033 exit (1);
1018 } 1034 }
1019 1035
1020 close (daemon_pipe[0]); 1036 emacs_close (daemon_pipe[0]);
1021 exit (0); 1037 exit (0);
1022 } 1038 }
1023 if (f < 0) 1039 if (f < 0)
1024 { 1040 {
1025 fprintf (stderr, "Cannot fork!\n"); 1041 emacs_perror ("fork");
1026 exit (1); 1042 exit (EXIT_CANCELED);
1027 } 1043 }
1028 1044
1029#ifdef DAEMON_MUST_EXEC 1045#ifdef DAEMON_MUST_EXEC
@@ -1040,14 +1056,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1040 if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) 1056 if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr))
1041 { 1057 {
1042 fprintf (stderr, "daemon: child name too long\n"); 1058 fprintf (stderr, "daemon: child name too long\n");
1043 exit (1); 1059 exit (EXIT_CANNOT_INVOKE);
1044 } 1060 }
1045 1061
1046 argv[skip_args] = fdStr; 1062 argv[skip_args] = fdStr;
1047 1063
1048 execvp (argv[0], argv); 1064 execvp (argv[0], argv);
1049 fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); 1065 emacs_perror (argv[0]);
1050 exit (1); 1066 exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
1051 } 1067 }
1052 1068
1053 /* In exec'd: parse special dname into pipe and name info. */ 1069 /* In exec'd: parse special dname into pipe and name info. */
@@ -1055,7 +1071,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1055 || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) 1071 || strlen (dname_arg) < 1 || strlen (dname_arg) > 70)
1056 { 1072 {
1057 fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); 1073 fprintf (stderr, "emacs daemon: daemon name absent or too long\n");
1058 exit (1); 1074 exit (EXIT_CANNOT_INVOKE);
1059 } 1075 }
1060 dname_arg2[0] = '\0'; 1076 dname_arg2[0] = '\0';
1061 sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), 1077 sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
@@ -1067,10 +1083,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1067 if (dname_arg) 1083 if (dname_arg)
1068 daemon_name = xstrdup (dname_arg); 1084 daemon_name = xstrdup (dname_arg);
1069 /* Close unused reading end of the pipe. */ 1085 /* Close unused reading end of the pipe. */
1070 close (daemon_pipe[0]); 1086 emacs_close (daemon_pipe[0]);
1071 /* Make sure that the used end of the pipe is closed on exec, so
1072 that it is not accessible to programs started from .emacs. */
1073 fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC);
1074 1087
1075 setsid (); 1088 setsid ();
1076#else /* DOS_NT */ 1089#else /* DOS_NT */
@@ -1080,7 +1093,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1080 } 1093 }
1081 1094
1082#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC 1095#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
1083 malloc_enable_thread (); 1096# ifndef CANNOT_DUMP
1097 /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as
1098 that causes an infinite recursive loop with FreeBSD. But do make
1099 it thread-safe when creating emacs, otherwise bootstrap-emacs
1100 fails on Cygwin. See Bug#14569. */
1101 if (!noninteractive || initialized)
1102# endif
1103 malloc_enable_thread ();
1084#endif 1104#endif
1085 1105
1086 init_signals (dumping); 1106 init_signals (dumping);
@@ -1917,8 +1937,8 @@ shut_down_emacs (int sig, Lisp_Object stuff)
1917 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)]; 1937 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)];
1918 int buflen = sprintf (buf, format, sig); 1938 int buflen = sprintf (buf, format, sig);
1919 char const *sig_desc = safe_strsignal (sig); 1939 char const *sig_desc = safe_strsignal (sig);
1920 ignore_value (write (STDERR_FILENO, buf, buflen)); 1940 emacs_write (STDERR_FILENO, buf, buflen);
1921 ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc))); 1941 emacs_write (STDERR_FILENO, sig_desc, strlen (sig_desc));
1922 } 1942 }
1923 } 1943 }
1924 } 1944 }
@@ -2235,12 +2255,12 @@ from the parent process and its tty file descriptors. */)
2235 error ("This function can only be called after loading the init files"); 2255 error ("This function can only be called after loading the init files");
2236 2256
2237 /* Get rid of stdin, stdout and stderr. */ 2257 /* Get rid of stdin, stdout and stderr. */
2238 nfd = open ("/dev/null", O_RDWR); 2258 nfd = emacs_open ("/dev/null", O_RDWR, 0);
2239 err |= nfd < 0; 2259 err |= nfd < 0;
2240 err |= dup2 (nfd, 0) < 0; 2260 err |= dup2 (nfd, 0) < 0;
2241 err |= dup2 (nfd, 1) < 0; 2261 err |= dup2 (nfd, 1) < 0;
2242 err |= dup2 (nfd, 2) < 0; 2262 err |= dup2 (nfd, 2) < 0;
2243 err |= close (nfd) != 0; 2263 err |= emacs_close (nfd) != 0;
2244 2264
2245 /* Closing the pipe will notify the parent that it can exit. 2265 /* Closing the pipe will notify the parent that it can exit.
2246 FIXME: In case some other process inherited the pipe, closing it here 2266 FIXME: In case some other process inherited the pipe, closing it here
@@ -2250,7 +2270,7 @@ from the parent process and its tty file descriptors. */)
2250 call-process to make sure the pipe is never inherited by 2270 call-process to make sure the pipe is never inherited by
2251 subprocesses. */ 2271 subprocesses. */
2252 err |= write (daemon_pipe[1], "\n", 1) < 0; 2272 err |= write (daemon_pipe[1], "\n", 1) < 0;
2253 err |= close (daemon_pipe[1]) != 0; 2273 err |= emacs_close (daemon_pipe[1]) != 0;
2254 /* Set it to an invalid value so we know we've already run this function. */ 2274 /* Set it to an invalid value so we know we've already run this function. */
2255 daemon_pipe[1] = -1; 2275 daemon_pipe[1] = -1;
2256 2276
diff --git a/src/eval.c b/src/eval.c
index d3545add21d..0e231bdb285 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -114,6 +114,13 @@ Lisp_Object Vsignaling_function;
114 frame is half-initialized. */ 114 frame is half-initialized. */
115Lisp_Object inhibit_lisp_code; 115Lisp_Object inhibit_lisp_code;
116 116
117/* These would ordinarily be static, but they need to be visible to GDB. */
118bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
119Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE;
120Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE;
121union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE;
122union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE;
123
117static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); 124static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
118static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); 125static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
119 126
@@ -152,7 +159,7 @@ specpdl_func (union specbinding *pdl)
152 return pdl->unwind.func; 159 return pdl->unwind.func;
153} 160}
154 161
155static Lisp_Object 162Lisp_Object
156backtrace_function (union specbinding *pdl) 163backtrace_function (union specbinding *pdl)
157{ 164{
158 eassert (pdl->kind == SPECPDL_BACKTRACE); 165 eassert (pdl->kind == SPECPDL_BACKTRACE);
@@ -166,7 +173,7 @@ backtrace_nargs (union specbinding *pdl)
166 return pdl->bt.nargs; 173 return pdl->bt.nargs;
167} 174}
168 175
169static Lisp_Object * 176Lisp_Object *
170backtrace_args (union specbinding *pdl) 177backtrace_args (union specbinding *pdl)
171{ 178{
172 eassert (pdl->kind == SPECPDL_BACKTRACE); 179 eassert (pdl->kind == SPECPDL_BACKTRACE);
@@ -205,10 +212,6 @@ set_backtrace_debug_on_exit (union specbinding *pdl, bool doe)
205 212
206/* Helper functions to scan the backtrace. */ 213/* Helper functions to scan the backtrace. */
207 214
208bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
209union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE;
210union specbinding *backtrace_next (union specbinding *pdl) EXTERNALLY_VISIBLE;
211
212bool 215bool
213backtrace_p (union specbinding *pdl) 216backtrace_p (union specbinding *pdl)
214{ return pdl >= specpdl; } 217{ return pdl >= specpdl; }
@@ -1993,38 +1996,52 @@ If LEXICAL is t, evaluate using lexical scoping. */)
1993 return unbind_to (count, eval_sub (form)); 1996 return unbind_to (count, eval_sub (form));
1994} 1997}
1995 1998
1999/* Grow the specpdl stack by one entry.
2000 The caller should have already initialized the entry.
2001 Signal an error on stack overflow.
2002
2003 Make sure that there is always one unused entry past the top of the
2004 stack, so that the just-initialized entry is safely unwound if
2005 memory exhausted and an error is signaled here. Also, allocate a
2006 never-used entry just before the bottom of the stack; sometimes its
2007 address is taken. */
2008
1996static void 2009static void
1997grow_specpdl (void) 2010grow_specpdl (void)
1998{ 2011{
1999 ptrdiff_t count = SPECPDL_INDEX (); 2012 specpdl_ptr++;
2000 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); 2013
2001 union specbinding *pdlvec = specpdl - 1; 2014 if (specpdl_ptr == specpdl + specpdl_size)
2002 ptrdiff_t pdlvecsize = specpdl_size + 1;
2003 if (max_size <= specpdl_size)
2004 { 2015 {
2005 if (max_specpdl_size < 400) 2016 ptrdiff_t count = SPECPDL_INDEX ();
2006 max_size = max_specpdl_size = 400; 2017 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000);
2018 union specbinding *pdlvec = specpdl - 1;
2019 ptrdiff_t pdlvecsize = specpdl_size + 1;
2007 if (max_size <= specpdl_size) 2020 if (max_size <= specpdl_size)
2008 signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); 2021 {
2022 if (max_specpdl_size < 400)
2023 max_size = max_specpdl_size = 400;
2024 if (max_size <= specpdl_size)
2025 signal_error ("Variable binding depth exceeds max-specpdl-size",
2026 Qnil);
2027 }
2028 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl);
2029 specpdl = pdlvec + 1;
2030 specpdl_size = pdlvecsize - 1;
2031 specpdl_ptr = specpdl + count;
2009 } 2032 }
2010 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl);
2011 specpdl = pdlvec + 1;
2012 specpdl_size = pdlvecsize - 1;
2013 specpdl_ptr = specpdl + count;
2014} 2033}
2015 2034
2016void 2035void
2017record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) 2036record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
2018{ 2037{
2019 eassert (nargs >= UNEVALLED); 2038 eassert (nargs >= UNEVALLED);
2020 if (specpdl_ptr == specpdl + specpdl_size)
2021 grow_specpdl ();
2022 specpdl_ptr->bt.kind = SPECPDL_BACKTRACE; 2039 specpdl_ptr->bt.kind = SPECPDL_BACKTRACE;
2023 specpdl_ptr->bt.debug_on_exit = false; 2040 specpdl_ptr->bt.debug_on_exit = false;
2024 specpdl_ptr->bt.function = function; 2041 specpdl_ptr->bt.function = function;
2025 specpdl_ptr->bt.args = args; 2042 specpdl_ptr->bt.args = args;
2026 specpdl_ptr->bt.nargs = nargs; 2043 specpdl_ptr->bt.nargs = nargs;
2027 specpdl_ptr++; 2044 grow_specpdl ();
2028} 2045}
2029 2046
2030/* Eval a sub-expression of the current expression (i.e. in the same 2047/* Eval a sub-expression of the current expression (i.e. in the same
@@ -3110,8 +3127,6 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3110 3127
3111 CHECK_SYMBOL (symbol); 3128 CHECK_SYMBOL (symbol);
3112 sym = XSYMBOL (symbol); 3129 sym = XSYMBOL (symbol);
3113 if (specpdl_ptr == specpdl + specpdl_size)
3114 grow_specpdl ();
3115 3130
3116 start: 3131 start:
3117 switch (sym->redirect) 3132 switch (sym->redirect)
@@ -3124,7 +3139,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3124 specpdl_ptr->let.kind = SPECPDL_LET; 3139 specpdl_ptr->let.kind = SPECPDL_LET;
3125 specpdl_ptr->let.symbol = symbol; 3140 specpdl_ptr->let.symbol = symbol;
3126 specpdl_ptr->let.old_value = SYMBOL_VAL (sym); 3141 specpdl_ptr->let.old_value = SYMBOL_VAL (sym);
3127 ++specpdl_ptr; 3142 grow_specpdl ();
3128 if (!sym->constant) 3143 if (!sym->constant)
3129 SET_SYMBOL_VAL (sym, value); 3144 SET_SYMBOL_VAL (sym, value);
3130 else 3145 else
@@ -3159,7 +3174,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3159 if (NILP (Flocal_variable_p (symbol, Qnil))) 3174 if (NILP (Flocal_variable_p (symbol, Qnil)))
3160 { 3175 {
3161 specpdl_ptr->let.kind = SPECPDL_LET_DEFAULT; 3176 specpdl_ptr->let.kind = SPECPDL_LET_DEFAULT;
3162 ++specpdl_ptr; 3177 grow_specpdl ();
3163 Fset_default (symbol, value); 3178 Fset_default (symbol, value);
3164 return; 3179 return;
3165 } 3180 }
@@ -3167,7 +3182,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3167 else 3182 else
3168 specpdl_ptr->let.kind = SPECPDL_LET; 3183 specpdl_ptr->let.kind = SPECPDL_LET;
3169 3184
3170 specpdl_ptr++; 3185 grow_specpdl ();
3171 set_internal (symbol, value, Qnil, 1); 3186 set_internal (symbol, value, Qnil, 1);
3172 break; 3187 break;
3173 } 3188 }
@@ -3178,12 +3193,10 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3178void 3193void
3179record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) 3194record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg)
3180{ 3195{
3181 if (specpdl_ptr == specpdl + specpdl_size)
3182 grow_specpdl ();
3183 specpdl_ptr->unwind.kind = SPECPDL_UNWIND; 3196 specpdl_ptr->unwind.kind = SPECPDL_UNWIND;
3184 specpdl_ptr->unwind.func = function; 3197 specpdl_ptr->unwind.func = function;
3185 specpdl_ptr->unwind.arg = arg; 3198 specpdl_ptr->unwind.arg = arg;
3186 specpdl_ptr++; 3199 grow_specpdl ();
3187} 3200}
3188 3201
3189Lisp_Object 3202Lisp_Object
diff --git a/src/fileio.c b/src/fileio.c
index 4a14f5a5911..c3566390130 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#include <config.h> 20#include <config.h>
21#include <limits.h> 21#include <limits.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <stdio.h> 23#include "sysstdio.h"
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h> 25#include <sys/stat.h>
26#include <unistd.h> 26#include <unistd.h>
@@ -55,7 +55,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
55#ifdef WINDOWSNT 55#ifdef WINDOWSNT
56#define NOMINMAX 1 56#define NOMINMAX 1
57#include <windows.h> 57#include <windows.h>
58#include <fcntl.h>
59#include <sys/file.h> 58#include <sys/file.h>
60#include "w32.h" 59#include "w32.h"
61#endif /* not WINDOWSNT */ 60#endif /* not WINDOWSNT */
@@ -63,7 +62,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#ifdef MSDOS 62#ifdef MSDOS
64#include "msdos.h" 63#include "msdos.h"
65#include <sys/param.h> 64#include <sys/param.h>
66#include <fcntl.h>
67#endif 65#endif
68 66
69#ifdef DOS_NT 67#ifdef DOS_NT
@@ -148,7 +146,7 @@ static Lisp_Object Qdelete_directory;
148#ifdef WINDOWSNT 146#ifdef WINDOWSNT
149#endif 147#endif
150 148
151Lisp_Object Qfile_error; 149Lisp_Object Qfile_error, Qfile_notify_error;
152static Lisp_Object Qfile_already_exists, Qfile_date_error; 150static Lisp_Object Qfile_already_exists, Qfile_date_error;
153static Lisp_Object Qexcl; 151static Lisp_Object Qexcl;
154Lisp_Object Qfile_name_history; 152Lisp_Object Qfile_name_history;
@@ -161,11 +159,13 @@ static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
161 struct coding_system *); 159 struct coding_system *);
162 160
163 161
162/* Signal a file-access failure. STRING describes the failure,
163 DATA the file that was involved, and ERRORNO the errno value. */
164
164void 165void
165report_file_error (const char *string, Lisp_Object data) 166report_file_errno (char const *string, Lisp_Object data, int errorno)
166{ 167{
167 Lisp_Object errstring; 168 Lisp_Object errstring;
168 int errorno = errno;
169 char *str; 169 char *str;
170 170
171 synchronize_system_messages_locale (); 171 synchronize_system_messages_locale ();
@@ -198,6 +198,12 @@ report_file_error (const char *string, Lisp_Object data)
198 } 198 }
199} 199}
200 200
201void
202report_file_error (char const *string, Lisp_Object data)
203{
204 report_file_errno (string, data, errno);
205}
206
201Lisp_Object 207Lisp_Object
202close_file_unwind (Lisp_Object fd) 208close_file_unwind (Lisp_Object fd)
203{ 209{
@@ -2021,11 +2027,8 @@ entries (depending on how Emacs was built). */)
2021 { 2027 {
2022 /* CopyFile doesn't set errno when it fails. By far the most 2028 /* CopyFile doesn't set errno when it fails. By far the most
2023 "popular" reason is that the target is read-only. */ 2029 "popular" reason is that the target is read-only. */
2024 if (GetLastError () == 5) 2030 report_file_errno ("Copying file", Fcons (file, Fcons (newname, Qnil)),
2025 errno = EACCES; 2031 GetLastError () == 5 ? EACCES : EPERM);
2026 else
2027 errno = EPERM;
2028 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
2029 } 2032 }
2030 /* CopyFile retains the timestamp by default. */ 2033 /* CopyFile retains the timestamp by default. */
2031 else if (NILP (keep_time)) 2034 else if (NILP (keep_time))
@@ -2086,36 +2089,25 @@ entries (depending on how Emacs was built). */)
2086 2089
2087 if (out_st.st_mode != 0 2090 if (out_st.st_mode != 0
2088 && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino) 2091 && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino)
2089 { 2092 report_file_errno ("Input and output files are the same",
2090 errno = 0; 2093 Fcons (file, Fcons (newname, Qnil)), 0);
2091 report_file_error ("Input and output files are the same",
2092 Fcons (file, Fcons (newname, Qnil)));
2093 }
2094 2094
2095 /* We can copy only regular files. */ 2095 /* We can copy only regular files. */
2096 if (!S_ISREG (st.st_mode)) 2096 if (!S_ISREG (st.st_mode))
2097 { 2097 report_file_errno ("Non-regular file", Fcons (file, Qnil),
2098 /* Get a better looking error message. */ 2098 S_ISDIR (st.st_mode) ? EISDIR : EINVAL);
2099 errno = S_ISDIR (st.st_mode) ? EISDIR : EINVAL;
2100 report_file_error ("Non-regular file", Fcons (file, Qnil));
2101 }
2102 2099
2103#ifdef MSDOS
2104 /* System's default file type was set to binary by _fmode in emacs.c. */
2105 ofd = emacs_open (SDATA (encoded_newname),
2106 O_WRONLY | O_TRUNC | O_CREAT
2107 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
2108 S_IREAD | S_IWRITE);
2109#else /* not MSDOS */
2110 { 2100 {
2111 mode_t new_mask = !NILP (preserve_uid_gid) ? 0600 : 0666; 2101#ifndef MSDOS
2112 new_mask &= st.st_mode; 2102 int new_mask = st.st_mode & (!NILP (preserve_uid_gid) ? 0600 : 0666);
2103#else
2104 int new_mask = S_IREAD | S_IWRITE;
2105#endif
2113 ofd = emacs_open (SSDATA (encoded_newname), 2106 ofd = emacs_open (SSDATA (encoded_newname),
2114 (O_WRONLY | O_TRUNC | O_CREAT 2107 (O_WRONLY | O_TRUNC | O_CREAT
2115 | (NILP (ok_if_already_exists) ? O_EXCL : 0)), 2108 | (NILP (ok_if_already_exists) ? O_EXCL : 0)),
2116 new_mask); 2109 new_mask);
2117 } 2110 }
2118#endif /* not MSDOS */
2119 if (ofd < 0) 2111 if (ofd < 0)
2120 report_file_error ("Opening output file", Fcons (newname, Qnil)); 2112 report_file_error ("Opening output file", Fcons (newname, Qnil));
2121 2113
@@ -2124,7 +2116,7 @@ entries (depending on how Emacs was built). */)
2124 immediate_quit = 1; 2116 immediate_quit = 1;
2125 QUIT; 2117 QUIT;
2126 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) 2118 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0)
2127 if (emacs_write (ofd, buf, n) != n) 2119 if (emacs_write_sig (ofd, buf, n) != n)
2128 report_file_error ("I/O error", Fcons (newname, Qnil)); 2120 report_file_error ("I/O error", Fcons (newname, Qnil));
2129 immediate_quit = 0; 2121 immediate_quit = 0;
2130 2122
@@ -2611,7 +2603,11 @@ Use `file-symlink-p' to test for such links. */)
2611 call the corresponding file handler. */ 2603 call the corresponding file handler. */
2612 handler = Ffind_file_name_handler (absname, Qfile_exists_p); 2604 handler = Ffind_file_name_handler (absname, Qfile_exists_p);
2613 if (!NILP (handler)) 2605 if (!NILP (handler))
2614 return call2 (handler, Qfile_exists_p, absname); 2606 {
2607 Lisp_Object result = call2 (handler, Qfile_exists_p, absname);
2608 errno = 0;
2609 return result;
2610 }
2615 2611
2616 absname = ENCODE_FILE (absname); 2612 absname = ENCODE_FILE (absname);
2617 2613
@@ -2708,7 +2704,6 @@ If there is no error, returns nil. */)
2708 (Lisp_Object filename, Lisp_Object string) 2704 (Lisp_Object filename, Lisp_Object string)
2709{ 2705{
2710 Lisp_Object handler, encoded_filename, absname; 2706 Lisp_Object handler, encoded_filename, absname;
2711 int fd;
2712 2707
2713 CHECK_STRING (filename); 2708 CHECK_STRING (filename);
2714 absname = Fexpand_file_name (filename, Qnil); 2709 absname = Fexpand_file_name (filename, Qnil);
@@ -2723,10 +2718,8 @@ If there is no error, returns nil. */)
2723 2718
2724 encoded_filename = ENCODE_FILE (absname); 2719 encoded_filename = ENCODE_FILE (absname);
2725 2720
2726 fd = emacs_open (SSDATA (encoded_filename), O_RDONLY, 0); 2721 if (faccessat (AT_FDCWD, SSDATA (encoded_filename), R_OK, AT_EACCESS) != 0)
2727 if (fd < 0)
2728 report_file_error (SSDATA (string), Fcons (filename, Qnil)); 2722 report_file_error (SSDATA (string), Fcons (filename, Qnil));
2729 emacs_close (fd);
2730 2723
2731 return Qnil; 2724 return Qnil;
2732} 2725}
@@ -2835,7 +2828,11 @@ searchable directory. */)
2835 call the corresponding file handler. */ 2828 call the corresponding file handler. */
2836 handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p); 2829 handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p);
2837 if (!NILP (handler)) 2830 if (!NILP (handler))
2838 return call2 (handler, Qfile_accessible_directory_p, absname); 2831 {
2832 Lisp_Object r = call2 (handler, Qfile_accessible_directory_p, absname);
2833 errno = 0;
2834 return r;
2835 }
2839 2836
2840 absname = ENCODE_FILE (absname); 2837 absname = ENCODE_FILE (absname);
2841 return file_accessible_directory_p (SSDATA (absname)) ? Qt : Qnil; 2838 return file_accessible_directory_p (SSDATA (absname)) ? Qt : Qnil;
@@ -3347,7 +3344,7 @@ otherwise, if FILE2 does not exist, the answer is t. */)
3347 if (stat (SSDATA (absname2), &st2) < 0) 3344 if (stat (SSDATA (absname2), &st2) < 0)
3348 return Qt; 3345 return Qt;
3349 3346
3350 return (EMACS_TIME_GT (get_stat_mtime (&st1), get_stat_mtime (&st2)) 3347 return (EMACS_TIME_LT (get_stat_mtime (&st2), get_stat_mtime (&st1))
3351 ? Qt : Qnil); 3348 ? Qt : Qnil);
3352} 3349}
3353 3350
@@ -4577,8 +4574,8 @@ by calling `format-decode', which see. */)
4577 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) 4574 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS)
4578 { 4575 {
4579 /* If visiting nonexistent file, return nil. */ 4576 /* If visiting nonexistent file, return nil. */
4580 errno = save_errno; 4577 report_file_errno ("Opening input file", Fcons (orig_filename, Qnil),
4581 report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); 4578 save_errno);
4582 } 4579 }
4583 4580
4584 if (read_quit) 4581 if (read_quit)
@@ -4899,13 +4896,13 @@ This calls `write-region-annotate-functions' at the start, and
4899 4896
4900 if (desc < 0) 4897 if (desc < 0)
4901 { 4898 {
4899 int open_errno = errno;
4902#ifdef CLASH_DETECTION 4900#ifdef CLASH_DETECTION
4903 save_errno = errno;
4904 if (!auto_saving) unlock_file (lockname); 4901 if (!auto_saving) unlock_file (lockname);
4905 errno = save_errno;
4906#endif /* CLASH_DETECTION */ 4902#endif /* CLASH_DETECTION */
4907 UNGCPRO; 4903 UNGCPRO;
4908 report_file_error ("Opening output file", Fcons (filename, Qnil)); 4904 report_file_errno ("Opening output file", Fcons (filename, Qnil),
4905 open_errno);
4909 } 4906 }
4910 4907
4911 record_unwind_protect (close_file_unwind, make_number (desc)); 4908 record_unwind_protect (close_file_unwind, make_number (desc));
@@ -4915,13 +4912,13 @@ This calls `write-region-annotate-functions' at the start, and
4915 off_t ret = lseek (desc, offset, SEEK_SET); 4912 off_t ret = lseek (desc, offset, SEEK_SET);
4916 if (ret < 0) 4913 if (ret < 0)
4917 { 4914 {
4915 int lseek_errno = errno;
4918#ifdef CLASH_DETECTION 4916#ifdef CLASH_DETECTION
4919 save_errno = errno;
4920 if (!auto_saving) unlock_file (lockname); 4917 if (!auto_saving) unlock_file (lockname);
4921 errno = save_errno;
4922#endif /* CLASH_DETECTION */ 4918#endif /* CLASH_DETECTION */
4923 UNGCPRO; 4919 UNGCPRO;
4924 report_file_error ("Lseek error", Fcons (filename, Qnil)); 4920 report_file_errno ("Lseek error", Fcons (filename, Qnil),
4921 lseek_errno);
4925 } 4922 }
4926 } 4923 }
4927 4924
@@ -5319,12 +5316,10 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
5319 5316
5320 if (coding->produced > 0) 5317 if (coding->produced > 0)
5321 { 5318 {
5322 coding->produced 5319 char *buf = (STRINGP (coding->dst_object)
5323 -= emacs_write (desc, 5320 ? SSDATA (coding->dst_object)
5324 STRINGP (coding->dst_object) 5321 : (char *) BYTE_POS_ADDR (coding->dst_pos_byte));
5325 ? SSDATA (coding->dst_object) 5322 coding->produced -= emacs_write_sig (desc, buf, coding->produced);
5326 : (char *) BYTE_POS_ADDR (coding->dst_pos_byte),
5327 coding->produced);
5328 5323
5329 if (coding->produced) 5324 if (coding->produced)
5330 return 0; 5325 return 0;
@@ -5379,36 +5374,19 @@ See Info node `(elisp)Modification Time' for more details. */)
5379 return Qnil; 5374 return Qnil;
5380} 5375}
5381 5376
5382DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime,
5383 Sclear_visited_file_modtime, 0, 0, 0,
5384 doc: /* Clear out records of last mod time of visited file.
5385Next attempt to save will certainly not complain of a discrepancy. */)
5386 (void)
5387{
5388 current_buffer->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS);
5389 current_buffer->modtime_size = -1;
5390 return Qnil;
5391}
5392
5393DEFUN ("visited-file-modtime", Fvisited_file_modtime, 5377DEFUN ("visited-file-modtime", Fvisited_file_modtime,
5394 Svisited_file_modtime, 0, 0, 0, 5378 Svisited_file_modtime, 0, 0, 0,
5395 doc: /* Return the current buffer's recorded visited file modification time. 5379 doc: /* Return the current buffer's recorded visited file modification time.
5396The value is a list of the form (HIGH LOW USEC PSEC), like the time values that 5380The value is a list of the form (HIGH LOW USEC PSEC), like the time values that
5397`file-attributes' returns. If the current buffer has no recorded file 5381`file-attributes' returns. If the current buffer has no recorded file
5398modification time, this function returns 0. If the visited file 5382modification time, this function returns 0. If the visited file
5399doesn't exist, HIGH will be -1. 5383doesn't exist, return -1.
5400See Info node `(elisp)Modification Time' for more details. */) 5384See Info node `(elisp)Modification Time' for more details. */)
5401 (void) 5385 (void)
5402{ 5386{
5403 if (EMACS_NSECS (current_buffer->modtime) < 0) 5387 int ns = EMACS_NSECS (current_buffer->modtime);
5404 { 5388 if (ns < 0)
5405 if (EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) 5389 return make_number (UNKNOWN_MODTIME_NSECS - ns);
5406 {
5407 /* make_lisp_time won't work here if time_t is unsigned. */
5408 return list4i (-1, 65535, 0, 0);
5409 }
5410 return make_number (0);
5411 }
5412 return make_lisp_time (current_buffer->modtime); 5390 return make_lisp_time (current_buffer->modtime);
5413} 5391}
5414 5392
@@ -5419,12 +5397,22 @@ Useful if the buffer was not read from the file normally
5419or if the file itself has been changed for some known benign reason. 5397or if the file itself has been changed for some known benign reason.
5420An argument specifies the modification time value to use 5398An argument specifies the modification time value to use
5421\(instead of that of the visited file), in the form of a list 5399\(instead of that of the visited file), in the form of a list
5422\(HIGH LOW USEC PSEC) as returned by `current-time'. */) 5400\(HIGH LOW USEC PSEC) or an integer flag as returned by
5423 (Lisp_Object time_list) 5401`visited-file-modtime'. */)
5402 (Lisp_Object time_flag)
5424{ 5403{
5425 if (!NILP (time_list)) 5404 if (!NILP (time_flag))
5426 { 5405 {
5427 current_buffer->modtime = lisp_time_argument (time_list); 5406 EMACS_TIME mtime;
5407 if (INTEGERP (time_flag))
5408 {
5409 CHECK_RANGED_INTEGER (time_flag, -1, 0);
5410 mtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS - XINT (time_flag));
5411 }
5412 else
5413 mtime = lisp_time_argument (time_flag);
5414
5415 current_buffer->modtime = mtime;
5428 current_buffer->modtime_size = -1; 5416 current_buffer->modtime_size = -1;
5429 } 5417 }
5430 else 5418 else
@@ -5620,7 +5608,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5620 UNGCPRO; 5608 UNGCPRO;
5621 } 5609 }
5622 5610
5623 stream = fopen (SSDATA (listfile), "w"); 5611 stream = emacs_fopen (SSDATA (listfile), "w");
5624 } 5612 }
5625 5613
5626 record_unwind_protect (do_auto_save_unwind, 5614 record_unwind_protect (do_auto_save_unwind,
@@ -5887,6 +5875,7 @@ syms_of_fileio (void)
5887 DEFSYM (Qfile_error, "file-error"); 5875 DEFSYM (Qfile_error, "file-error");
5888 DEFSYM (Qfile_already_exists, "file-already-exists"); 5876 DEFSYM (Qfile_already_exists, "file-already-exists");
5889 DEFSYM (Qfile_date_error, "file-date-error"); 5877 DEFSYM (Qfile_date_error, "file-date-error");
5878 DEFSYM (Qfile_notify_error, "file-notify-error");
5890 DEFSYM (Qexcl, "excl"); 5879 DEFSYM (Qexcl, "excl");
5891 5880
5892 DEFVAR_LISP ("file-name-coding-system", Vfile_name_coding_system, 5881 DEFVAR_LISP ("file-name-coding-system", Vfile_name_coding_system,
@@ -5925,6 +5914,11 @@ of file names regardless of the current language environment. */);
5925 Fput (Qfile_date_error, Qerror_message, 5914 Fput (Qfile_date_error, Qerror_message,
5926 build_pure_c_string ("Cannot set file date")); 5915 build_pure_c_string ("Cannot set file date"));
5927 5916
5917 Fput (Qfile_notify_error, Qerror_conditions,
5918 Fpurecopy (list3 (Qfile_notify_error, Qfile_error, Qerror)));
5919 Fput (Qfile_notify_error, Qerror_message,
5920 build_pure_c_string ("File notification error"));
5921
5928 DEFVAR_LISP ("file-name-handler-alist", Vfile_name_handler_alist, 5922 DEFVAR_LISP ("file-name-handler-alist", Vfile_name_handler_alist,
5929 doc: /* Alist of elements (REGEXP . HANDLER) for file names handled specially. 5923 doc: /* Alist of elements (REGEXP . HANDLER) for file names handled specially.
5930If a file name matches REGEXP, all I/O on that file is done by calling 5924If a file name matches REGEXP, all I/O on that file is done by calling
@@ -6119,7 +6113,6 @@ This includes interactive calls to `delete-file' and
6119 defsubr (&Swrite_region); 6113 defsubr (&Swrite_region);
6120 defsubr (&Scar_less_than_car); 6114 defsubr (&Scar_less_than_car);
6121 defsubr (&Sverify_visited_file_modtime); 6115 defsubr (&Sverify_visited_file_modtime);
6122 defsubr (&Sclear_visited_file_modtime);
6123 defsubr (&Svisited_file_modtime); 6116 defsubr (&Svisited_file_modtime);
6124 defsubr (&Sset_visited_file_modtime); 6117 defsubr (&Sset_visited_file_modtime);
6125 defsubr (&Sdo_auto_save); 6118 defsubr (&Sdo_auto_save);
diff --git a/src/filelock.c b/src/filelock.c
index de6aba8385c..244663ad20a 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -47,6 +47,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#include "systime.h" 47#include "systime.h"
48#ifdef WINDOWSNT 48#ifdef WINDOWSNT
49#include <share.h> 49#include <share.h>
50#include <sys/socket.h> /* for fcntl */
50#include "w32.h" /* for dostounix_filename */ 51#include "w32.h" /* for dostounix_filename */
51#endif 52#endif
52 53
@@ -380,9 +381,9 @@ rename_lock_file (char const *old, char const *new, bool force)
380#endif 381#endif
381} 382}
382 383
383/* Create the lock file FILE with contents CONTENTS. Return 0 if 384/* Create the lock file LFNAME with contents LOCK_INFO_STR. Return 0 if
384 successful, an errno value on failure. If FORCE, remove any 385 successful, an errno value on failure. If FORCE, remove any
385 existing FILE if necessary. */ 386 existing LFNAME if necessary. */
386 387
387static int 388static int
388create_lock_file (char *lfname, char *lock_info_str, bool force) 389create_lock_file (char *lfname, char *lock_info_str, bool force)
@@ -416,8 +417,13 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
416 memcpy (nonce, lfname, lfdirlen); 417 memcpy (nonce, lfname, lfdirlen);
417 strcpy (nonce + lfdirlen, nonce_base); 418 strcpy (nonce + lfdirlen, nonce_base);
418 419
419#if HAVE_MKSTEMP 420#if HAVE_MKOSTEMP
420 /* Prefer mkstemp if available, as it avoids a race between 421 /* Prefer mkostemp to mkstemp, as it avoids a window where FD is
422 temporarily open without close-on-exec. */
423 fd = mkostemp (nonce, O_BINARY | O_CLOEXEC);
424 need_fchmod = 1;
425#elif HAVE_MKSTEMP
426 /* Prefer mkstemp to mktemp, as it avoids a race between
421 mktemp and emacs_open. */ 427 mktemp and emacs_open. */
422 fd = mkstemp (nonce); 428 fd = mkstemp (nonce);
423 need_fchmod = 1; 429 need_fchmod = 1;
@@ -432,7 +438,11 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
432 err = errno; 438 err = errno;
433 else 439 else
434 { 440 {
435 ptrdiff_t lock_info_len = strlen (lock_info_str); 441 ptrdiff_t lock_info_len;
442#if ! HAVE_MKOSTEMP
443 fcntl (fd, F_SETFD, FD_CLOEXEC);
444#endif
445 lock_info_len = strlen (lock_info_str);
436 err = 0; 446 err = 0;
437 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len 447 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
438 || (need_fchmod && fchmod (fd, world_readable) != 0)) 448 || (need_fchmod && fchmod (fd, world_readable) != 0))
diff --git a/src/fns.c b/src/fns.c
index 7a8ddc04540..49bd8470f7f 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5011,13 +5011,21 @@ this variable. */);
5011 defsubr (&Ssecure_hash); 5011 defsubr (&Ssecure_hash);
5012 defsubr (&Slocale_info); 5012 defsubr (&Slocale_info);
5013 5013
5014 { 5014 hashtest_eq.name = Qeq;
5015 struct hash_table_test 5015 hashtest_eq.user_hash_function = Qnil;
5016 eq = { Qeq, Qnil, Qnil, NULL, hashfn_eq }, 5016 hashtest_eq.user_cmp_function = Qnil;
5017 eql = { Qeql, Qnil, Qnil, cmpfn_eql, hashfn_eql }, 5017 hashtest_eq.cmpfn = 0;
5018 equal = { Qequal, Qnil, Qnil, cmpfn_equal, hashfn_equal }; 5018 hashtest_eq.hashfn = hashfn_eq;
5019 hashtest_eq = eq; 5019
5020 hashtest_eql = eql; 5020 hashtest_eql.name = Qeql;
5021 hashtest_equal = equal; 5021 hashtest_eql.user_hash_function = Qnil;
5022 } 5022 hashtest_eql.user_cmp_function = Qnil;
5023 hashtest_eql.cmpfn = cmpfn_eql;
5024 hashtest_eql.hashfn = hashfn_eql;
5025
5026 hashtest_equal.name = Qequal;
5027 hashtest_equal.user_hash_function = Qnil;
5028 hashtest_equal.user_cmp_function = Qnil;
5029 hashtest_equal.cmpfn = cmpfn_equal;
5030 hashtest_equal.hashfn = hashfn_equal;
5023} 5031}
diff --git a/src/frame.c b/src/frame.c
index ba9074ddebe..648687a7cb4 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1855,7 +1855,7 @@ See `redirect-frame-focus'. */)
1855/* Return the value of frame parameter PROP in frame FRAME. */ 1855/* Return the value of frame parameter PROP in frame FRAME. */
1856 1856
1857#ifdef HAVE_WINDOW_SYSTEM 1857#ifdef HAVE_WINDOW_SYSTEM
1858#if !HAVE_NS && !defined(WINDOWSNT) 1858#if !HAVE_NS && !defined (WINDOWSNT)
1859static 1859static
1860#endif 1860#endif
1861Lisp_Object 1861Lisp_Object
@@ -2964,6 +2964,15 @@ x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
2964 f->extra_line_spacing = 0; 2964 f->extra_line_spacing = 0;
2965 else if (RANGED_INTEGERP (0, new_value, INT_MAX)) 2965 else if (RANGED_INTEGERP (0, new_value, INT_MAX))
2966 f->extra_line_spacing = XFASTINT (new_value); 2966 f->extra_line_spacing = XFASTINT (new_value);
2967 else if (FLOATP (new_value))
2968 {
2969 int new_spacing = XFLOAT_DATA (new_value) * FRAME_LINE_HEIGHT (f) + 0.5;
2970
2971 if (new_spacing >= 0)
2972 f->extra_line_spacing = new_spacing;
2973 else
2974 signal_error ("Invalid line-spacing", new_value);
2975 }
2967 else 2976 else
2968 signal_error ("Invalid line-spacing", new_value); 2977 signal_error ("Invalid line-spacing", new_value);
2969 if (FRAME_VISIBLE_P (f)) 2978 if (FRAME_VISIBLE_P (f))
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index c8d12ce8fa0..4e684d1fb54 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -132,15 +132,14 @@ This arranges for filesystem events pertaining to FILE to be reported
132to Emacs. Use `gfile-rm-watch' to cancel the watch. 132to Emacs. Use `gfile-rm-watch' to cancel the watch.
133 133
134Value is a descriptor for the added watch. If the file cannot be 134Value is a descriptor for the added watch. If the file cannot be
135watched for some reason, this function signals a `file-error' error. 135watched for some reason, this function signals a `file-notify-error' error.
136 136
137FLAGS is a list of conditions to set what will be watched for. It can 137FLAGS is a list of conditions to set what will be watched for. It can
138include the following symbols: 138include the following symbols:
139 139
140 'watch-mounts' -- watch for mount events 140 'watch-mounts' -- watch for mount events
141 'send-moved' -- pair 'deleted' and 'created' events caused by file 141 'send-moved' -- pair 'deleted' and 'created' events caused by file
142 renames (moves) and send a single 'event-moved' 142 renames and send a single 'renamed' event instead
143 event instead
144 143
145When any event happens, Emacs will call the CALLBACK function passing 144When any event happens, Emacs will call the CALLBACK function passing
146it a single argument EVENT, which is of the form 145it a single argument EVENT, which is of the form
@@ -193,7 +192,7 @@ will be reported only in case of the 'moved' event. */)
193 /* Enable watch. */ 192 /* Enable watch. */
194 monitor = g_file_monitor (gfile, gflags, NULL, NULL); 193 monitor = g_file_monitor (gfile, gflags, NULL, NULL);
195 if (! monitor) 194 if (! monitor)
196 xsignal2 (Qfile_error, build_string ("Cannot watch file"), file); 195 xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
197 196
198 /* On all known glib platforms, converting MONITOR directly to a 197 /* On all known glib platforms, converting MONITOR directly to a
199 Lisp_Object value results is a Lisp integer, which is safe. This 198 Lisp_Object value results is a Lisp integer, which is safe. This
@@ -202,7 +201,8 @@ will be reported only in case of the 'moved' event. */)
202 if (! INTEGERP (watch_descriptor)) 201 if (! INTEGERP (watch_descriptor))
203 { 202 {
204 g_object_unref (monitor); 203 g_object_unref (monitor);
205 xsignal2 (Qfile_error, build_string ("Unsupported file watcher"), file); 204 xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
205 file);
206 } 206 }
207 207
208 g_signal_connect (monitor, "changed", 208 g_signal_connect (monitor, "changed",
@@ -226,14 +226,14 @@ WATCH-DESCRIPTOR should be an object returned by `gfile-add-watch'. */)
226 Lisp_Object watch_object = assq_no_quit (watch_descriptor, watch_list); 226 Lisp_Object watch_object = assq_no_quit (watch_descriptor, watch_list);
227 227
228 if (! CONSP (watch_object)) 228 if (! CONSP (watch_object))
229 xsignal2 (Qfile_error, build_string ("Not a watch descriptor"), 229 xsignal2 (Qfile_notify_error, build_string ("Not a watch descriptor"),
230 watch_descriptor); 230 watch_descriptor);
231 231
232 eassert (INTEGERP (watch_descriptor)); 232 eassert (INTEGERP (watch_descriptor));
233 int_monitor = XLI (watch_descriptor); 233 int_monitor = XLI (watch_descriptor);
234 monitor = (GFileMonitor *) int_monitor; 234 monitor = (GFileMonitor *) int_monitor;
235 if (!g_file_monitor_cancel (monitor)) 235 if (!g_file_monitor_cancel (monitor))
236 xsignal2 (Qfile_error, build_string ("Could not rm watch"), 236 xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
237 watch_descriptor); 237 watch_descriptor);
238 238
239 /* Remove watch descriptor from watch list. */ 239 /* Remove watch descriptor from watch list. */
diff --git a/src/gnutls.h b/src/gnutls.h
index f1a337e7b3e..86dcab77b62 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -42,7 +42,7 @@ typedef enum
42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET, 42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
43 GNUTLS_STAGE_HANDSHAKE_TRIED, 43 GNUTLS_STAGE_HANDSHAKE_TRIED,
44 44
45 GNUTLS_STAGE_READY, 45 GNUTLS_STAGE_READY
46} gnutls_initstage_t; 46} gnutls_initstage_t;
47 47
48#define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1 48#define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1
diff --git a/src/image.c b/src/image.c
index 2c288342028..c085e6e63eb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <stdio.h> 21#include "sysstdio.h"
22#include <unistd.h> 22#include <unistd.h>
23 23
24#ifdef HAVE_PNG 24#ifdef HAVE_PNG
@@ -316,7 +316,6 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
316 int xhot, yhot, result; 316 int xhot, yhot, result;
317 ptrdiff_t id; 317 ptrdiff_t id;
318 Lisp_Object found; 318 Lisp_Object found;
319 int fd;
320 char *filename; 319 char *filename;
321 320
322 /* Look for an existing bitmap with the same name. */ 321 /* Look for an existing bitmap with the same name. */
@@ -332,10 +331,8 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
332 } 331 }
333 332
334 /* Search bitmap-file-path for the file, if appropriate. */ 333 /* Search bitmap-file-path for the file, if appropriate. */
335 fd = openp (Vx_bitmap_file_path, file, Qnil, &found, Qnil); 334 if (openp (Vx_bitmap_file_path, file, Qnil, &found, make_number (R_OK)) < 0)
336 if (fd < 0)
337 return -1; 335 return -1;
338 emacs_close (fd);
339 336
340 filename = SSDATA (found); 337 filename = SSDATA (found);
341 338
@@ -2260,7 +2257,8 @@ x_find_image_file (Lisp_Object file)
2260 else 2257 else
2261 { 2258 {
2262 file_found = ENCODE_FILE (file_found); 2259 file_found = ENCODE_FILE (file_found);
2263 close (fd); 2260 if (fd != -2)
2261 emacs_close (fd);
2264 } 2262 }
2265 2263
2266 return file_found; 2264 return file_found;
@@ -2274,7 +2272,7 @@ x_find_image_file (Lisp_Object file)
2274static unsigned char * 2272static unsigned char *
2275slurp_file (char *file, ptrdiff_t *size) 2273slurp_file (char *file, ptrdiff_t *size)
2276{ 2274{
2277 FILE *fp = fopen (file, "rb"); 2275 FILE *fp = emacs_fopen (file, "rb");
2278 unsigned char *buf = NULL; 2276 unsigned char *buf = NULL;
2279 struct stat st; 2277 struct stat st;
2280 2278
@@ -4559,7 +4557,6 @@ x_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
4559 XColor *colors, *p; 4557 XColor *colors, *p;
4560 XImagePtr_or_DC ximg; 4558 XImagePtr_or_DC ximg;
4561#ifdef HAVE_NTGUI 4559#ifdef HAVE_NTGUI
4562 HDC hdc;
4563 HGDIOBJ prev; 4560 HGDIOBJ prev;
4564#endif /* HAVE_NTGUI */ 4561#endif /* HAVE_NTGUI */
4565 4562
@@ -4929,7 +4926,6 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
4929#ifndef HAVE_NTGUI 4926#ifndef HAVE_NTGUI
4930 XImagePtr mask_img; 4927 XImagePtr mask_img;
4931#else 4928#else
4932 HDC frame_dc;
4933 HGDIOBJ prev; 4929 HGDIOBJ prev;
4934 char *mask_img; 4930 char *mask_img;
4935 int row_width; 4931 int row_width;
@@ -5725,7 +5721,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5725 } 5721 }
5726 5722
5727 /* Open the image file. */ 5723 /* Open the image file. */
5728 fp = fopen (SSDATA (file), "rb"); 5724 fp = emacs_fopen (SSDATA (file), "rb");
5729 if (!fp) 5725 if (!fp)
5730 { 5726 {
5731 image_error ("Cannot open image file `%s'", file, Qnil); 5727 image_error ("Cannot open image file `%s'", file, Qnil);
@@ -6486,7 +6482,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6486 return 0; 6482 return 0;
6487 } 6483 }
6488 6484
6489 fp = fopen (SSDATA (file), "rb"); 6485 fp = emacs_fopen (SSDATA (file), "rb");
6490 if (fp == NULL) 6486 if (fp == NULL)
6491 { 6487 {
6492 image_error ("Cannot open `%s'", file, Qnil); 6488 image_error ("Cannot open `%s'", file, Qnil);
@@ -7627,6 +7623,31 @@ gif_load (struct frame *f, struct image *img)
7627#endif /* HAVE_GIF */ 7623#endif /* HAVE_GIF */
7628 7624
7629 7625
7626#ifdef HAVE_IMAGEMAGICK
7627
7628/***********************************************************************
7629 ImageMagick
7630***********************************************************************/
7631
7632/* Scale an image size by returning SIZE / DIVISOR * MULTIPLIER,
7633 safely rounded and clipped to int range. */
7634
7635static int
7636scale_image_size (int size, size_t divisor, size_t multiplier)
7637{
7638 if (divisor != 0)
7639 {
7640 double s = size;
7641 double scaled = s * multiplier / divisor + 0.5;
7642 if (scaled < INT_MAX)
7643 return scaled;
7644 }
7645 return INT_MAX;
7646}
7647
7648/* Compute the desired size of an image with native size WIDTH x HEIGHT.
7649 Use SPEC to deduce the size. Store the desired size into
7650 *D_WIDTH x *D_HEIGHT. Store -1 x -1 if the native size is OK. */
7630static void 7651static void
7631compute_image_size (size_t width, size_t height, 7652compute_image_size (size_t width, size_t height,
7632 Lisp_Object spec, 7653 Lisp_Object spec,
@@ -7640,39 +7661,36 @@ compute_image_size (size_t width, size_t height,
7640 unspecified should be calculated from the specified to preserve 7661 unspecified should be calculated from the specified to preserve
7641 aspect ratio. */ 7662 aspect ratio. */
7642 value = image_spec_value (spec, QCwidth, NULL); 7663 value = image_spec_value (spec, QCwidth, NULL);
7643 desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); 7664 desired_width = NATNUMP (value) ? min (XFASTINT (value), INT_MAX) : -1;
7644 value = image_spec_value (spec, QCheight, NULL); 7665 value = image_spec_value (spec, QCheight, NULL);
7645 desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); 7666 desired_height = NATNUMP (value) ? min (XFASTINT (value), INT_MAX) : -1;
7646 7667
7647 if (desired_width == -1) 7668 if (desired_width == -1)
7648 { 7669 {
7649 value = image_spec_value (spec, QCmax_width, NULL); 7670 value = image_spec_value (spec, QCmax_width, NULL);
7650 if (INTEGERP (value) && 7671 if (NATNUMP (value))
7651 width > XFASTINT (value))
7652 { 7672 {
7653 /* The image is wider than :max-width. */ 7673 int max_width = min (XFASTINT (value), INT_MAX);
7654 desired_width = XFASTINT (value); 7674 if (max_width < width)
7655 if (desired_height == -1)
7656 { 7675 {
7657 value = image_spec_value (spec, QCmax_height, NULL); 7676 /* The image is wider than :max-width. */
7658 if (INTEGERP (value)) 7677 desired_width = max_width;
7678 if (desired_height == -1)
7659 { 7679 {
7660 /* We have no specified height, but we have a 7680 desired_height = scale_image_size (desired_width,
7661 :max-height value, so check that we satisfy both 7681 width, height);
7662 conditions. */ 7682 value = image_spec_value (spec, QCmax_height, NULL);
7663 desired_height = (double) desired_width / width * height; 7683 if (NATNUMP (value))
7664 if (desired_height > XFASTINT (value))
7665 { 7684 {
7666 desired_height = XFASTINT (value); 7685 int max_height = min (XFASTINT (value), INT_MAX);
7667 desired_width = (double) desired_height / height * width; 7686 if (max_height < desired_height)
7687 {
7688 desired_height = max_height;
7689 desired_width = scale_image_size (desired_height,
7690 height, width);
7691 }
7668 } 7692 }
7669 } 7693 }
7670 else
7671 {
7672 /* We have no specified height and no specified
7673 max-height, so just compute the height. */
7674 desired_height = (double) desired_width / width * height;
7675 }
7676 } 7694 }
7677 } 7695 }
7678 } 7696 }
@@ -7680,28 +7698,26 @@ compute_image_size (size_t width, size_t height,
7680 if (desired_height == -1) 7698 if (desired_height == -1)
7681 { 7699 {
7682 value = image_spec_value (spec, QCmax_height, NULL); 7700 value = image_spec_value (spec, QCmax_height, NULL);
7683 if (INTEGERP (value) && 7701 if (NATNUMP (value))
7684 height > XFASTINT (value)) 7702 {
7685 desired_height = XFASTINT (value); 7703 int max_height = min (XFASTINT (value), INT_MAX);
7704 if (max_height < height)
7705 desired_height = max_height;
7706 }
7686 } 7707 }
7687 7708
7688 if (desired_width != -1 && desired_height == -1) 7709 if (desired_width != -1 && desired_height == -1)
7689 /* w known, calculate h. */ 7710 /* w known, calculate h. */
7690 desired_height = (double) desired_width / width * height; 7711 desired_height = scale_image_size (desired_width, width, height);
7691 7712
7692 if (desired_width == -1 && desired_height != -1) 7713 if (desired_width == -1 && desired_height != -1)
7693 /* h known, calculate w. */ 7714 /* h known, calculate w. */
7694 desired_width = (double) desired_height / height * width; 7715 desired_width = scale_image_size (desired_height, height, width);
7695 7716
7696 *d_width = desired_width; 7717 *d_width = desired_width;
7697 *d_height = desired_height; 7718 *d_height = desired_height;
7698} 7719}
7699 7720
7700/***********************************************************************
7701 ImageMagick
7702***********************************************************************/
7703#if defined (HAVE_IMAGEMAGICK)
7704
7705static Lisp_Object Qimagemagick; 7721static Lisp_Object Qimagemagick;
7706 7722
7707static bool imagemagick_image_p (Lisp_Object); 7723static bool imagemagick_image_p (Lisp_Object);
@@ -8036,7 +8052,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8036 8052
8037 init_color_table (); 8053 init_color_table ();
8038 8054
8039#ifdef HAVE_MAGICKEXPORTIMAGEPIXELS 8055#if defined (HAVE_MAGICKEXPORTIMAGEPIXELS) && ! defined (HAVE_NS)
8040 if (imagemagick_render_type != 0) 8056 if (imagemagick_render_type != 0)
8041 { 8057 {
8042 /* Magicexportimage is normally faster than pixelpushing. This 8058 /* Magicexportimage is normally faster than pixelpushing. This
diff --git a/src/inotify.c b/src/inotify.c
index 4efef9e55b7..f4f850bf180 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -71,9 +71,8 @@ static Lisp_Object Qunmount; /* IN_UNMOUNT */
71# define IN_ONLYDIR 0 71# define IN_ONLYDIR 0
72#endif 72#endif
73 73
74enum { uninitialized = -100 };
75/* File handle for inotify. */ 74/* File handle for inotify. */
76static int inotifyfd = uninitialized; 75static int inotifyfd = -1;
77 76
78/* Assoc list of files being watched. 77/* Assoc list of files being watched.
79 Format: 78 Format:
@@ -139,8 +138,8 @@ inotifyevent_to_event (Lisp_Object watch_object, struct inotify_event const *ev)
139 138
140 return list2 (list4 (make_watch_descriptor (ev->wd), 139 return list2 (list4 (make_watch_descriptor (ev->wd),
141 mask_to_aspects (ev->mask), 140 mask_to_aspects (ev->mask),
142 make_number (ev->cookie), 141 name,
143 name), 142 make_number (ev->cookie)),
144 XCDR (watch_object)); 143 XCDR (watch_object));
145} 144}
146 145
@@ -158,15 +157,17 @@ inotify_callback (int fd, void *_)
158 157
159 to_read = 0; 158 to_read = 0;
160 if (ioctl (fd, FIONREAD, &to_read) == -1) 159 if (ioctl (fd, FIONREAD, &to_read) == -1)
161 report_file_error ("Error while trying to retrieve file system events", 160 xsignal1
162 Qnil); 161 (Qfile_notify_error,
162 build_string ("Error while trying to retrieve file system events"));
163 buffer = xmalloc (to_read); 163 buffer = xmalloc (to_read);
164 n = read (fd, buffer, to_read); 164 n = read (fd, buffer, to_read);
165 if (n < 0) 165 if (n < 0)
166 { 166 {
167 xfree (buffer); 167 xfree (buffer);
168 report_file_error ("Error while trying to read file system events", 168 xsignal1
169 Qnil); 169 (Qfile_notify_error,
170 build_string ("Error while trying to read file system events"));
170 } 171 }
171 172
172 EVENT_INIT (event); 173 EVENT_INIT (event);
@@ -242,7 +243,7 @@ symbol_to_inotifymask (Lisp_Object symb)
242 else if (EQ (symb, Qt) || EQ (symb, Qall_events)) 243 else if (EQ (symb, Qt) || EQ (symb, Qall_events))
243 return IN_ALL_EVENTS; 244 return IN_ALL_EVENTS;
244 else 245 else
245 signal_error ("Unknown aspect", symb); 246 xsignal2 (Qfile_notify_error, build_string ("Unknown aspect"), symb);
246} 247}
247 248
248static uint32_t 249static uint32_t
@@ -266,8 +267,10 @@ aspect_to_inotifymask (Lisp_Object aspect)
266DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0, 267DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0,
267 doc: /* Add a watch for FILE-NAME to inotify. 268 doc: /* Add a watch for FILE-NAME to inotify.
268 269
269A WATCH-DESCRIPTOR is returned on success. ASPECT might be one of the following 270Return a watch descriptor. The watch will look for ASPECT events and
270symbols or a list of those symbols: 271invoke CALLBACK when an event occurs.
272
273ASPECT might be one of the following symbols or a list of those symbols:
271 274
272access 275access
273attrib 276attrib
@@ -286,7 +289,7 @@ all-events or t
286move 289move
287close 290close
288 291
289The following symbols can also be added to a list of aspects 292The following symbols can also be added to a list of aspects:
290 293
291dont-follow 294dont-follow
292excl-unlink 295excl-unlink
@@ -294,11 +297,10 @@ mask-add
294oneshot 297oneshot
295onlydir 298onlydir
296 299
297Watching a directory is not recursive. CALLBACK gets called in case of an 300Watching a directory is not recursive. CALLBACK is passed a single argument
298event. It gets passed a single argument EVENT which contains an event structure 301EVENT which contains an event structure of the format
299of the format
300 302
301(WATCH-DESCRIPTOR ASPECTS COOKIE NAME) 303(WATCH-DESCRIPTOR ASPECTS NAME COOKIE)
302 304
303WATCH-DESCRIPTOR is the same object that was returned by this function. It can 305WATCH-DESCRIPTOR is the same object that was returned by this function. It can
304be tested for equality using `equal'. ASPECTS describes the event. It is a 306be tested for equality using `equal'. ASPECTS describes the event. It is a
@@ -310,11 +312,11 @@ isdir
310q-overflow 312q-overflow
311unmount 313unmount
312 314
315If a directory is watched then NAME is the name of file that caused the event.
316
313COOKIE is an object that can be compared using `equal' to identify two matching 317COOKIE is an object that can be compared using `equal' to identify two matching
314renames (moved-from and moved-to). 318renames (moved-from and moved-to).
315 319
316If a directory is watched then NAME is the name of file that caused the event.
317
318See inotify(7) and inotify_add_watch(2) for further information. The inotify fd 320See inotify(7) and inotify_add_watch(2) for further information. The inotify fd
319is managed internally and there is no corresponding inotify_init. Use 321is managed internally and there is no corresponding inotify_init. Use
320`inotify-rm-watch' to remove a watch. 322`inotify-rm-watch' to remove a watch.
@@ -329,15 +331,13 @@ is managed internally and there is no corresponding inotify_init. Use
329 331
330 CHECK_STRING (file_name); 332 CHECK_STRING (file_name);
331 333
332 if (inotifyfd == uninitialized) 334 if (inotifyfd < 0)
333 { 335 {
334 inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC); 336 inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
335 if (inotifyfd == -1) 337 if (inotifyfd < 0)
336 { 338 xsignal1
337 inotifyfd = uninitialized; 339 (Qfile_notify_error,
338 report_file_error ("File watching feature (inotify) is not available", 340 build_string ("File watching feature (inotify) is not available"));
339 Qnil);
340 }
341 watch_list = Qnil; 341 watch_list = Qnil;
342 add_read_fd (inotifyfd, &inotify_callback, NULL); 342 add_read_fd (inotifyfd, &inotify_callback, NULL);
343 } 343 }
@@ -346,7 +346,8 @@ is managed internally and there is no corresponding inotify_init. Use
346 encoded_file_name = ENCODE_FILE (file_name); 346 encoded_file_name = ENCODE_FILE (file_name);
347 watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask); 347 watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
348 if (watchdesc == -1) 348 if (watchdesc == -1)
349 report_file_error ("Could not add watch for file", Fcons (file_name, Qnil)); 349 xsignal2 (Qfile_notify_error,
350 build_string ("Could not add watch for file"), file_name);
350 351
351 watch_descriptor = make_watch_descriptor (watchdesc); 352 watch_descriptor = make_watch_descriptor (watchdesc);
352 353
@@ -375,8 +376,8 @@ See inotify_rm_watch(2) for more information.
375 int wd = XINT (watch_descriptor); 376 int wd = XINT (watch_descriptor);
376 377
377 if (inotify_rm_watch (inotifyfd, wd) == -1) 378 if (inotify_rm_watch (inotifyfd, wd) == -1)
378 report_file_error ("Could not rm watch", Fcons (watch_descriptor, 379 xsignal2 (Qfile_notify_error,
379 Qnil)); 380 build_string ("Could not rm watch"), watch_descriptor);
380 381
381 /* Remove watch descriptor from watch list. */ 382 /* Remove watch descriptor from watch list. */
382 watch_object = Fassoc (watch_descriptor, watch_list); 383 watch_object = Fassoc (watch_descriptor, watch_list);
@@ -386,9 +387,9 @@ See inotify_rm_watch(2) for more information.
386 /* Cleanup if no more files are watched. */ 387 /* Cleanup if no more files are watched. */
387 if (NILP (watch_list)) 388 if (NILP (watch_list))
388 { 389 {
389 close (inotifyfd); 390 emacs_close (inotifyfd);
390 delete_read_fd (inotifyfd); 391 delete_read_fd (inotifyfd);
391 inotifyfd = uninitialized; 392 inotifyfd = -1;
392 } 393 }
393 394
394 return Qt; 395 return Qt;
diff --git a/src/keyboard.c b/src/keyboard.c
index 6129fdd26c8..a6f43d216ff 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -23,7 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#define BLOCKINPUT_INLINE EXTERN_INLINE 23#define BLOCKINPUT_INLINE EXTERN_INLINE
24#define KEYBOARD_INLINE EXTERN_INLINE 24#define KEYBOARD_INLINE EXTERN_INLINE
25 25
26#include <stdio.h> 26#include "sysstdio.h"
27 27
28#include "lisp.h" 28#include "lisp.h"
29#include "termchar.h" 29#include "termchar.h"
@@ -2289,7 +2289,6 @@ read_event_from_main_queue (EMACS_TIME *end_time,
2289 XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL)); 2289 XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL));
2290 } 2290 }
2291 2291
2292 /* FIXME: Decode tty keyboard input here. */
2293 return c; 2292 return c;
2294} 2293}
2295 2294
@@ -7035,7 +7034,7 @@ tty_read_avail_input (struct terminal *terminal,
7035 { 7034 {
7036 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); 7035 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read);
7037 /* POSIX infers that processes which are not in the session leader's 7036 /* POSIX infers that processes which are not in the session leader's
7038 process group won't get SIGHUP's at logout time. BSDI adheres to 7037 process group won't get SIGHUPs at logout time. BSDI adheres to
7039 this part standard and returns -1 from read (0) with errno==EIO 7038 this part standard and returns -1 from read (0) with errno==EIO
7040 when the control tty is taken away. 7039 when the control tty is taken away.
7041 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 7040 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
@@ -10156,7 +10155,7 @@ The file will be closed when Emacs exits. */)
10156 if (!NILP (file)) 10155 if (!NILP (file))
10157 { 10156 {
10158 file = Fexpand_file_name (file, Qnil); 10157 file = Fexpand_file_name (file, Qnil);
10159 dribble = fopen (SSDATA (file), "w"); 10158 dribble = emacs_fopen (SSDATA (file), "w");
10160 if (dribble == 0) 10159 if (dribble == 0)
10161 report_file_error ("Opening dribble", Fcons (file, Qnil)); 10160 report_file_error ("Opening dribble", Fcons (file, Qnil));
10162 } 10161 }
diff --git a/src/lisp.h b/src/lisp.h
index 6bea1ec67ed..e194a1ef765 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -363,9 +363,9 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
363#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1)) 363#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
364#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 364#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
365 365
366/* Idea stolen from GDB. MSVC doesn't support enums in bitfields, 366/* Idea stolen from GDB. Pedantic GCC complains about enum bitfields,
367 and xlc complains vociferously about them. */ 367 MSVC doesn't support them, and xlc complains vociferously about them. */
368#if defined _MSC_VER || defined __IBMC__ 368#if defined __STRICT_ANSI__ || defined _MSC_VER || defined __IBMC__
369#define ENUM_BF(TYPE) unsigned int 369#define ENUM_BF(TYPE) unsigned int
370#else 370#else
371#define ENUM_BF(TYPE) enum TYPE 371#define ENUM_BF(TYPE) enum TYPE
@@ -398,7 +398,7 @@ enum Lisp_Type
398 /* Cons. XCONS (object) points to a struct Lisp_Cons. */ 398 /* Cons. XCONS (object) points to a struct Lisp_Cons. */
399 Lisp_Cons = 6, 399 Lisp_Cons = 6,
400 400
401 Lisp_Float = 7, 401 Lisp_Float = 7
402 }; 402 };
403 403
404/* This is the set of data types that share a common structure. 404/* This is the set of data types that share a common structure.
@@ -428,7 +428,7 @@ enum Lisp_Fwd_Type
428 Lisp_Fwd_Bool, /* Fwd to a C boolean var. */ 428 Lisp_Fwd_Bool, /* Fwd to a C boolean var. */
429 Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */ 429 Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */
430 Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */ 430 Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */
431 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 431 Lisp_Fwd_Kboard_Obj /* Fwd to a Lisp_Object field of kboards. */
432 }; 432 };
433 433
434/* If you want to define a new Lisp data type, here are some 434/* If you want to define a new Lisp data type, here are some
@@ -2545,11 +2545,16 @@ CHECK_NUMBER_CDR (Lisp_Object x)
2545 minargs, maxargs, lname, intspec, 0}; \ 2545 minargs, maxargs, lname, intspec, 0}; \
2546 Lisp_Object fnname 2546 Lisp_Object fnname
2547#else /* not _MSC_VER */ 2547#else /* not _MSC_VER */
2548# if __STDC_VERSION__ < 199901
2549# define DEFUN_FUNCTION_INIT(fnname, maxargs) (Lisp_Object (*) (void)) fnname
2550# else
2551# define DEFUN_FUNCTION_INIT(fnname, maxargs) .a ## maxargs = fnname
2552# endif
2548#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 2553#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
2549 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 2554 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
2550 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ 2555 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
2551 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ 2556 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
2552 { .a ## maxargs = fnname }, \ 2557 { DEFUN_FUNCTION_INIT (fnname, maxargs) }, \
2553 minargs, maxargs, lname, intspec, 0}; \ 2558 minargs, maxargs, lname, intspec, 0}; \
2554 Lisp_Object fnname 2559 Lisp_Object fnname
2555#endif 2560#endif
@@ -3673,7 +3678,6 @@ extern Lisp_Object string_to_number (char const *, int, bool);
3673extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), 3678extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
3674 Lisp_Object); 3679 Lisp_Object);
3675extern void dir_warning (const char *, Lisp_Object); 3680extern void dir_warning (const char *, Lisp_Object);
3676extern void close_load_descs (void);
3677extern void init_obarray (void); 3681extern void init_obarray (void);
3678extern void init_lread (void); 3682extern void init_lread (void);
3679extern void syms_of_lread (void); 3683extern void syms_of_lread (void);
@@ -3814,6 +3818,7 @@ extern void syms_of_marker (void);
3814/* Defined in fileio.c. */ 3818/* Defined in fileio.c. */
3815 3819
3816extern Lisp_Object Qfile_error; 3820extern Lisp_Object Qfile_error;
3821extern Lisp_Object Qfile_notify_error;
3817extern Lisp_Object Qfile_exists_p; 3822extern Lisp_Object Qfile_exists_p;
3818extern Lisp_Object Qfile_directory_p; 3823extern Lisp_Object Qfile_directory_p;
3819extern Lisp_Object Qinsert_file_contents; 3824extern Lisp_Object Qinsert_file_contents;
@@ -3822,6 +3827,7 @@ extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
3822EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ 3827EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
3823extern Lisp_Object close_file_unwind (Lisp_Object); 3828extern Lisp_Object close_file_unwind (Lisp_Object);
3824extern Lisp_Object restore_point_unwind (Lisp_Object); 3829extern Lisp_Object restore_point_unwind (Lisp_Object);
3830extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
3825extern _Noreturn void report_file_error (const char *, Lisp_Object); 3831extern _Noreturn void report_file_error (const char *, Lisp_Object);
3826extern bool internal_delete_file (Lisp_Object); 3832extern bool internal_delete_file (Lisp_Object);
3827extern Lisp_Object emacs_readlinkat (int, const char *); 3833extern Lisp_Object emacs_readlinkat (int, const char *);
@@ -3927,7 +3933,7 @@ extern Lisp_Object Qvisible;
3927extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); 3933extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
3928extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); 3934extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
3929extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); 3935extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
3930#if HAVE_NS || defined(WINDOWSNT) 3936#if HAVE_NS || defined WINDOWSNT
3931extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); 3937extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
3932#endif 3938#endif
3933extern void frames_discard_buffer (Lisp_Object); 3939extern void frames_discard_buffer (Lisp_Object);
@@ -3999,11 +4005,11 @@ extern void delete_keyboard_wait_descriptor (int);
3999extern void add_gpm_wait_descriptor (int); 4005extern void add_gpm_wait_descriptor (int);
4000extern void delete_gpm_wait_descriptor (int); 4006extern void delete_gpm_wait_descriptor (int);
4001#endif 4007#endif
4002extern void close_process_descs (void);
4003extern void init_process_emacs (void); 4008extern void init_process_emacs (void);
4004extern void syms_of_process (void); 4009extern void syms_of_process (void);
4005extern void setup_process_coding_systems (Lisp_Object); 4010extern void setup_process_coding_systems (Lisp_Object);
4006 4011
4012/* Defined in callproc.c. */
4007#ifndef DOS_NT 4013#ifndef DOS_NT
4008 _Noreturn 4014 _Noreturn
4009#endif 4015#endif
@@ -4096,6 +4102,8 @@ extern int emacs_open (const char *, int, int);
4096extern int emacs_close (int); 4102extern int emacs_close (int);
4097extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 4103extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
4098extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); 4104extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t);
4105extern ptrdiff_t emacs_write_sig (int, char const *, ptrdiff_t);
4106extern void emacs_perror (char const *);
4099 4107
4100extern void unlock_all_files (void); 4108extern void unlock_all_files (void);
4101extern void lock_file (Lisp_Object); 4109extern void lock_file (Lisp_Object);
diff --git a/src/lread.c b/src/lread.c
index b57665e365c..f0423f166dd 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include "sysstdio.h"
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h> 25#include <sys/stat.h>
26#include <sys/file.h> 26#include <sys/file.h>
@@ -38,7 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include "keyboard.h" 38#include "keyboard.h"
39#include "frame.h" 39#include "frame.h"
40#include "termhooks.h" 40#include "termhooks.h"
41#include "coding.h"
42#include "blockinput.h" 41#include "blockinput.h"
43 42
44#ifdef MSDOS 43#ifdef MSDOS
@@ -96,9 +95,6 @@ static Lisp_Object Qload_in_progress;
96 It must be set to nil before all top-level calls to read0. */ 95 It must be set to nil before all top-level calls to read0. */
97static Lisp_Object read_objects; 96static Lisp_Object read_objects;
98 97
99/* List of descriptors now open for Fload. */
100static Lisp_Object load_descriptor_list;
101
102/* File for get_file_char to read from. Use by load. */ 98/* File for get_file_char to read from. Use by load. */
103static FILE *instream; 99static FILE *instream;
104 100
@@ -150,7 +146,6 @@ static void readevalloop (Lisp_Object, FILE *, Lisp_Object, bool,
150 Lisp_Object, Lisp_Object, 146 Lisp_Object, Lisp_Object,
151 Lisp_Object, Lisp_Object); 147 Lisp_Object, Lisp_Object);
152static Lisp_Object load_unwind (Lisp_Object); 148static Lisp_Object load_unwind (Lisp_Object);
153static Lisp_Object load_descriptor_unwind (Lisp_Object);
154 149
155/* Functions that read one byte from the current source READCHARFUN 150/* Functions that read one byte from the current source READCHARFUN
156 or unreads one byte. If the integer argument C is -1, it returns 151 or unreads one byte. If the integer argument C is -1, it returns
@@ -828,7 +823,7 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
828 { 823 {
829 bool rv = 0; 824 bool rv = 0;
830 enum { 825 enum {
831 NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX, 826 NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX
832 } beg_end_state = NOMINAL; 827 } beg_end_state = NOMINAL;
833 bool in_file_vars = 0; 828 bool in_file_vars = 0;
834 829
@@ -1298,7 +1293,7 @@ Return t if the file exists and loads successfully. */)
1298 if (fd >= 0) 1293 if (fd >= 0)
1299 { 1294 {
1300 emacs_close (fd); 1295 emacs_close (fd);
1301 stream = fopen (SSDATA (efound), fmode); 1296 stream = emacs_fopen (SSDATA (efound), fmode);
1302 } 1297 }
1303 else 1298 else
1304 stream = NULL; 1299 stream = NULL;
@@ -1329,11 +1324,8 @@ Return t if the file exists and loads successfully. */)
1329 } 1324 }
1330 1325
1331 record_unwind_protect (load_unwind, make_save_pointer (stream)); 1326 record_unwind_protect (load_unwind, make_save_pointer (stream));
1332 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
1333 specbind (Qload_file_name, found); 1327 specbind (Qload_file_name, found);
1334 specbind (Qinhibit_file_name_operation, Qnil); 1328 specbind (Qinhibit_file_name_operation, Qnil);
1335 load_descriptor_list
1336 = Fcons (make_number (fileno (stream)), load_descriptor_list);
1337 specbind (Qload_in_progress, Qt); 1329 specbind (Qload_in_progress, Qt);
1338 1330
1339 instream = stream; 1331 instream = stream;
@@ -1396,26 +1388,6 @@ load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */
1396 } 1388 }
1397 return Qnil; 1389 return Qnil;
1398} 1390}
1399
1400static Lisp_Object
1401load_descriptor_unwind (Lisp_Object oldlist)
1402{
1403 load_descriptor_list = oldlist;
1404 return Qnil;
1405}
1406
1407/* Close all descriptors in use for Floads.
1408 This is used when starting a subprocess. */
1409
1410void
1411close_load_descs (void)
1412{
1413#ifndef WINDOWSNT
1414 Lisp_Object tail;
1415 for (tail = load_descriptor_list; CONSP (tail); tail = XCDR (tail))
1416 emacs_close (XFASTINT (XCAR (tail)));
1417#endif
1418}
1419 1391
1420static bool 1392static bool
1421complete_filename_p (Lisp_Object pathname) 1393complete_filename_p (Lisp_Object pathname)
@@ -1440,8 +1412,8 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */)
1440{ 1412{
1441 Lisp_Object file; 1413 Lisp_Object file;
1442 int fd = openp (path, filename, suffixes, &file, predicate); 1414 int fd = openp (path, filename, suffixes, &file, predicate);
1443 if (NILP (predicate) && fd > 0) 1415 if (NILP (predicate) && fd >= 0)
1444 close (fd); 1416 emacs_close (fd);
1445 return file; 1417 return file;
1446} 1418}
1447 1419
@@ -1449,14 +1421,15 @@ static Lisp_Object Qdir_ok;
1449 1421
1450/* Search for a file whose name is STR, looking in directories 1422/* Search for a file whose name is STR, looking in directories
1451 in the Lisp list PATH, and trying suffixes from SUFFIX. 1423 in the Lisp list PATH, and trying suffixes from SUFFIX.
1452 On success, returns a file descriptor. On failure, returns -1. 1424 On success, return a file descriptor (or 1 or -2 as described below).
1425 On failure, return -1 and set errno.
1453 1426
1454 SUFFIXES is a list of strings containing possible suffixes. 1427 SUFFIXES is a list of strings containing possible suffixes.
1455 The empty suffix is automatically added if the list is empty. 1428 The empty suffix is automatically added if the list is empty.
1456 1429
1457 PREDICATE non-nil means don't open the files, 1430 PREDICATE non-nil means don't open the files,
1458 just look for one that satisfies the predicate. In this case, 1431 just look for one that satisfies the predicate. In this case,
1459 returns 1 on success. The predicate can be a lisp function or 1432 return 1 on success. The predicate can be a lisp function or
1460 an integer to pass to `access' (in which case file-name-handlers 1433 an integer to pass to `access' (in which case file-name-handlers
1461 are ignored). 1434 are ignored).
1462 1435
@@ -1468,7 +1441,8 @@ static Lisp_Object Qdir_ok;
1468 but store the found remote file name in *STOREPTR. */ 1441 but store the found remote file name in *STOREPTR. */
1469 1442
1470int 1443int
1471openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) 1444openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1445 Lisp_Object *storeptr, Lisp_Object predicate)
1472{ 1446{
1473 ptrdiff_t fn_size = 100; 1447 ptrdiff_t fn_size = 100;
1474 char buf[100]; 1448 char buf[100];
@@ -1479,6 +1453,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1479 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 1453 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
1480 Lisp_Object string, tail, encoded_fn; 1454 Lisp_Object string, tail, encoded_fn;
1481 ptrdiff_t max_suffix_len = 0; 1455 ptrdiff_t max_suffix_len = 0;
1456 int last_errno = ENOENT;
1482 1457
1483 CHECK_STRING (str); 1458 CHECK_STRING (str);
1484 1459
@@ -1548,14 +1523,22 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1548 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) 1523 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate))
1549 { 1524 {
1550 bool exists; 1525 bool exists;
1526 last_errno = ENOENT;
1551 if (NILP (predicate)) 1527 if (NILP (predicate))
1552 exists = !NILP (Ffile_readable_p (string)); 1528 exists = !NILP (Ffile_readable_p (string));
1553 else 1529 else
1554 { 1530 {
1555 Lisp_Object tmp = call1 (predicate, string); 1531 Lisp_Object tmp = call1 (predicate, string);
1556 exists = !NILP (tmp) 1532 if (NILP (tmp))
1557 && (EQ (tmp, Qdir_ok) 1533 exists = 0;
1558 || NILP (Ffile_directory_p (string))); 1534 else if (EQ (tmp, Qdir_ok)
1535 || NILP (Ffile_directory_p (string)))
1536 exists = 1;
1537 else
1538 {
1539 exists = 0;
1540 last_errno = EISDIR;
1541 }
1559 } 1542 }
1560 1543
1561 if (exists) 1544 if (exists)
@@ -1577,21 +1560,36 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1577 1560
1578 /* Check that we can access or open it. */ 1561 /* Check that we can access or open it. */
1579 if (NATNUMP (predicate)) 1562 if (NATNUMP (predicate))
1580 fd = (((XFASTINT (predicate) & ~INT_MAX) == 0 1563 {
1581 && (faccessat (AT_FDCWD, pfn, XFASTINT (predicate), 1564 fd = -1;
1565 if (INT_MAX < XFASTINT (predicate))
1566 last_errno = EINVAL;
1567 else if (faccessat (AT_FDCWD, pfn, XFASTINT (predicate),
1582 AT_EACCESS) 1568 AT_EACCESS)
1583 == 0) 1569 == 0)
1584 && ! file_directory_p (pfn)) 1570 {
1585 ? 1 : -1); 1571 if (file_directory_p (pfn))
1572 last_errno = EISDIR;
1573 else
1574 fd = 1;
1575 }
1576 }
1586 else 1577 else
1587 { 1578 {
1588 struct stat st;
1589 fd = emacs_open (pfn, O_RDONLY, 0); 1579 fd = emacs_open (pfn, O_RDONLY, 0);
1590 if (fd >= 0 1580 if (fd < 0)
1591 && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode))) 1581 last_errno = errno;
1582 else
1592 { 1583 {
1593 emacs_close (fd); 1584 struct stat st;
1594 fd = -1; 1585 int err = (fstat (fd, &st) != 0 ? errno
1586 : S_ISDIR (st.st_mode) ? EISDIR : 0);
1587 if (err)
1588 {
1589 last_errno = err;
1590 emacs_close (fd);
1591 fd = -1;
1592 }
1595 } 1593 }
1596 } 1594 }
1597 1595
@@ -1610,6 +1608,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1610 } 1608 }
1611 1609
1612 UNGCPRO; 1610 UNGCPRO;
1611 errno = last_errno;
1613 return -1; 1612 return -1;
1614} 1613}
1615 1614
@@ -4350,9 +4349,6 @@ init_lread (void)
4350 4349
4351 load_in_progress = 0; 4350 load_in_progress = 0;
4352 Vload_file_name = Qnil; 4351 Vload_file_name = Qnil;
4353
4354 load_descriptor_list = Qnil;
4355
4356 Vstandard_input = Qt; 4352 Vstandard_input = Qt;
4357 Vloads_in_progress = Qnil; 4353 Vloads_in_progress = Qnil;
4358} 4354}
@@ -4625,9 +4621,6 @@ variables, this must be set in the first line of a file. */);
4625 4621
4626 /* Vsource_directory was initialized in init_lread. */ 4622 /* Vsource_directory was initialized in init_lread. */
4627 4623
4628 load_descriptor_list = Qnil;
4629 staticpro (&load_descriptor_list);
4630
4631 DEFSYM (Qcurrent_load_list, "current-load-list"); 4624 DEFSYM (Qcurrent_load_list, "current-load-list");
4632 DEFSYM (Qstandard_input, "standard-input"); 4625 DEFSYM (Qstandard_input, "standard-input");
4633 DEFSYM (Qread_char, "read-char"); 4626 DEFSYM (Qread_char, "read-char");
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 272b053ed12..f4885580e1c 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -813,7 +813,6 @@ $(BLD)/emacs.$(O) : \
813 $(NT_INC)/sys/file.h \ 813 $(NT_INC)/sys/file.h \
814 $(NT_INC)/unistd.h \ 814 $(NT_INC)/unistd.h \
815 $(GNU_LIB)/close-stream.h \ 815 $(GNU_LIB)/close-stream.h \
816 $(GNU_LIB)/ignore-value.h \
817 $(ATIMER_H) \ 816 $(ATIMER_H) \
818 $(BUFFER_H) \ 817 $(BUFFER_H) \
819 $(CHARACTER_H) \ 818 $(CHARACTER_H) \
@@ -1407,7 +1406,6 @@ $(BLD)/sysdep.$(O) : \
1407 $(NT_INC)/sys/stat.h \ 1406 $(NT_INC)/sys/stat.h \
1408 $(NT_INC)/unistd.h \ 1407 $(NT_INC)/unistd.h \
1409 $(GNU_LIB)/execinfo.h \ 1408 $(GNU_LIB)/execinfo.h \
1410 $(GNU_LIB)/ignore-value.h \
1411 $(GNU_LIB)/utimens.h \ 1409 $(GNU_LIB)/utimens.h \
1412 $(CONFIG_H) \ 1410 $(CONFIG_H) \
1413 $(C_CTYPE_H) \ 1411 $(C_CTYPE_H) \
diff --git a/src/nsfns.m b/src/nsfns.m
index 1e075995c11..6eebb4d2567 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -89,9 +89,6 @@ extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
89Lisp_Object Qbuffered; 89Lisp_Object Qbuffered;
90Lisp_Object Qfontsize; 90Lisp_Object Qfontsize;
91 91
92/* hack for OS X file panels */
93char panelOK = 0;
94
95EmacsTooltip *ns_tooltip = nil; 92EmacsTooltip *ns_tooltip = nil;
96 93
97/* Need forward declaration here to preserve organizational integrity of file */ 94/* Need forward declaration here to preserve organizational integrity of file */
@@ -888,7 +885,7 @@ ns_appkit_version_str (void)
888 885
889#ifdef NS_IMPL_GNUSTEP 886#ifdef NS_IMPL_GNUSTEP
890 sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION)); 887 sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION));
891#elif defined(NS_IMPL_COCOA) 888#elif defined (NS_IMPL_COCOA)
892 sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber); 889 sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber);
893#else 890#else
894 tmp = "ns-unknown"; 891 tmp = "ns-unknown";
@@ -905,7 +902,7 @@ ns_appkit_version_int (void)
905{ 902{
906#ifdef NS_IMPL_GNUSTEP 903#ifdef NS_IMPL_GNUSTEP
907 return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION; 904 return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
908#elif defined(NS_IMPL_COCOA) 905#elif defined (NS_IMPL_COCOA)
909 return (int)NSAppKitVersionNumber; 906 return (int)NSAppKitVersionNumber;
910#endif 907#endif
911 return 0; 908 return 0;
@@ -1396,6 +1393,41 @@ DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
1396 return Qnil; 1393 return Qnil;
1397} 1394}
1398 1395
1396static struct
1397{
1398 id panel;
1399 BOOL ret;
1400#if ! defined (NS_IMPL_COCOA) || \
1401 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
1402 NSString *dirS, *initS;
1403 BOOL no_types;
1404#endif
1405} ns_fd_data;
1406
1407void
1408ns_run_file_dialog (void)
1409{
1410 if (ns_fd_data.panel == nil) return;
1411#if defined (NS_IMPL_COCOA) && \
1412 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1413 ns_fd_data.ret = [ns_fd_data.panel runModal];
1414#else
1415 if (ns_fd_data.no_types)
1416 {
1417 ns_fd_data.ret = [ns_fd_data.panel
1418 runModalForDirectory: ns_fd_data.dirS
1419 file: ns_fd_data.initS];
1420 }
1421 else
1422 {
1423 ns_fd_data.ret = [ns_fd_data.panel
1424 runModalForDirectory: ns_fd_data.dirS
1425 file: ns_fd_data.initS
1426 types: nil];
1427 }
1428#endif
1429 ns_fd_data.panel = nil;
1430}
1399 1431
1400DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0, 1432DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0,
1401 doc: /* Use a graphical panel to read a file name, using prompt PROMPT. 1433 doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
@@ -1420,6 +1452,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1420 [NSString stringWithUTF8String: SSDATA (dir)]; 1452 [NSString stringWithUTF8String: SSDATA (dir)];
1421 NSString *initS = NILP (init) || !STRINGP (init) ? nil : 1453 NSString *initS = NILP (init) || !STRINGP (init) ? nil :
1422 [NSString stringWithUTF8String: SSDATA (init)]; 1454 [NSString stringWithUTF8String: SSDATA (init)];
1455 NSEvent *nxev;
1423 1456
1424 check_window_system (NULL); 1457 check_window_system (NULL);
1425 1458
@@ -1440,7 +1473,6 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1440 [panel setTreatsFilePackagesAsDirectories: YES]; 1473 [panel setTreatsFilePackagesAsDirectories: YES];
1441 [panel setDelegate: fileDelegate]; 1474 [panel setDelegate: fileDelegate];
1442 1475
1443 panelOK = 0;
1444 if (! NILP (dir_only_p)) 1476 if (! NILP (dir_only_p))
1445 { 1477 {
1446 [panel setCanChooseDirectories: YES]; 1478 [panel setCanChooseDirectories: YES];
@@ -1454,7 +1486,9 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1454 [panel setCanChooseFiles: YES]; 1486 [panel setCanChooseFiles: YES];
1455 } 1487 }
1456 1488
1457 block_input (); 1489 block_input ();
1490 ns_fd_data.panel = panel;
1491 ns_fd_data.ret = NO;
1458#if defined (NS_IMPL_COCOA) && \ 1492#if defined (NS_IMPL_COCOA) && \
1459 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 1493 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1460 if (! NILP (mustmatch) || ! NILP (dir_only_p)) 1494 if (! NILP (mustmatch) || ! NILP (dir_only_p))
@@ -1465,19 +1499,32 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1465 else 1499 else
1466 [panel setNameFieldStringValue: @""]; 1500 [panel setNameFieldStringValue: @""];
1467 1501
1468 ret = [panel runModal];
1469#else 1502#else
1470 if (NILP (mustmatch) && NILP (dir_only_p)) 1503 ns_fd_data.no_types = NILP (mustmatch) && NILP (dir_only_p);
1471 { 1504 ns_fd_data.dirS = dirS;
1472 ret = [panel runModalForDirectory: dirS file: initS]; 1505 ns_fd_data.initS = initS;
1473 }
1474 else
1475 {
1476 ret = [panel runModalForDirectory: dirS file: initS types: nil];
1477 }
1478#endif 1506#endif
1479 1507
1480 ret = (ret == NSOKButton) || panelOK; 1508 /* runModalForDirectory/runModal restarts the main event loop when done,
1509 so we must start an event loop and then pop up the file dialog.
1510 The file dialog may pop up a confirm dialog after Ok has been pressed,
1511 so we can not simply pop down on the Ok/Cancel press.
1512 */
1513 nxev = [NSEvent otherEventWithType: NSApplicationDefined
1514 location: NSMakePoint (0, 0)
1515 modifierFlags: 0
1516 timestamp: 0
1517 windowNumber: [[NSApp mainWindow] windowNumber]
1518 context: [NSApp context]
1519 subtype: 0
1520 data1: 0
1521 data2: NSAPP_DATA2_RUNFILEDIALOG];
1522
1523 [NSApp postEvent: nxev atStart: NO];
1524 while (ns_fd_data.panel != nil)
1525 [NSApp run];
1526
1527 ret = (ns_fd_data.ret == NSOKButton);
1481 1528
1482 if (ret) 1529 if (ret)
1483 { 1530 {
@@ -2446,7 +2493,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
2446 vy = (short) (primary_display_height - 2493 vy = (short) (primary_display_height -
2447 vfr.size.height - vfr.origin.y); 2494 vfr.size.height - vfr.origin.y);
2448 } 2495 }
2449 2496
2450 m->geom.x = (short) fr.origin.x; 2497 m->geom.x = (short) fr.origin.x;
2451 m->geom.y = y; 2498 m->geom.y = y;
2452 m->geom.width = (unsigned short) fr.size.width; 2499 m->geom.width = (unsigned short) fr.size.width;
@@ -2755,25 +2802,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
2755} 2802}
2756 2803
2757@implementation EmacsSavePanel 2804@implementation EmacsSavePanel
2758#ifdef NS_IMPL_COCOA
2759/* --------------------------------------------------------------------------
2760 These are overridden to intercept on OS X: ending panel restarts NSApp
2761 event loop if it is stopped. Not sure if this is correct behavior,
2762 perhaps should check if running and if so send an appdefined.
2763 -------------------------------------------------------------------------- */
2764- (void) ok: (id)sender
2765{
2766 [super ok: sender];
2767 panelOK = 1;
2768 [NSApp stop: self];
2769}
2770- (void) cancel: (id)sender
2771{
2772 [super cancel: sender];
2773 [NSApp stop: self];
2774}
2775#endif
2776
2777- (BOOL)performKeyEquivalent:(NSEvent *)theEvent 2805- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
2778{ 2806{
2779 BOOL ret = handlePanelKeys (self, theEvent); 2807 BOOL ret = handlePanelKeys (self, theEvent);
@@ -2785,31 +2813,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
2785 2813
2786 2814
2787@implementation EmacsOpenPanel 2815@implementation EmacsOpenPanel
2788#ifdef NS_IMPL_COCOA
2789/* --------------------------------------------------------------------------
2790 These are overridden to intercept on OS X: ending panel restarts NSApp
2791 event loop if it is stopped. Not sure if this is correct behavior,
2792 perhaps should check if running and if so send an appdefined.
2793 -------------------------------------------------------------------------- */
2794- (void) ok: (id)sender
2795{
2796 [super ok: sender];
2797
2798 // If not choosing directories, and Open is pressed on a directory, return.
2799 if (! [self canChooseDirectories] && ns_directory_from_panel (self) &&
2800 ! ns_filename_from_panel (self))
2801 return;
2802
2803 panelOK = 1;
2804 [NSApp stop: self];
2805}
2806- (void) cancel: (id)sender
2807{
2808 [super cancel: sender];
2809 [NSApp stop: self];
2810}
2811
2812#endif
2813- (BOOL)performKeyEquivalent:(NSEvent *)theEvent 2816- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
2814{ 2817{
2815 // NSOpenPanel inherits NSSavePanel, so passing self is OK. 2818 // NSOpenPanel inherits NSSavePanel, so passing self is OK.
diff --git a/src/nsfont.m b/src/nsfont.m
index 49ede8f483c..a657d01dbe4 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -33,7 +33,6 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu)
33#include "window.h" 33#include "window.h"
34#include "fontset.h" 34#include "fontset.h"
35#include "nsterm.h" 35#include "nsterm.h"
36#include "frame.h"
37#include "character.h" 36#include "character.h"
38#include "font.h" 37#include "font.h"
39#include "termchar.h" 38#include "termchar.h"
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 1d3d111e9a1..22635dca0a2 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -612,8 +612,8 @@ extern NSString *NSMenuDidBeginTrackingNotification;
612 if (trackingMenu == 0) 612 if (trackingMenu == 0)
613 return; 613 return;
614/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ 614/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
615#if ! defined(NS_IMPL_COCOA) || \ 615#if (! defined (NS_IMPL_COCOA) \
616 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 616 || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
617 /* Don't know how to do this for anything other than OSX >= 10.5 617 /* Don't know how to do this for anything other than OSX >= 10.5
618 This is wrong, as it might run Lisp code in the event loop. */ 618 This is wrong, as it might run Lisp code in the event loop. */
619 ns_update_menubar (frame, true, self); 619 ns_update_menubar (frame, true, self);
@@ -1240,7 +1240,7 @@ update_frame_tool_bar (FRAME_PTR f)
1240#ifdef NS_IMPL_GNUSTEP 1240#ifdef NS_IMPL_GNUSTEP
1241 [self insertItemWithItemIdentifier: identifier atIndex: idx]; 1241 [self insertItemWithItemIdentifier: identifier atIndex: idx];
1242#endif 1242#endif
1243 1243
1244 [item setTag: tag]; 1244 [item setTag: tag];
1245 [item setEnabled: enabled]; 1245 [item setEnabled: enabled];
1246 1246
diff --git a/src/nsterm.h b/src/nsterm.h
index fd8c9baa3e4..745b8a4145b 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -286,8 +286,7 @@ typedef float EmacsCGFloat;
286/* ========================================================================== 286/* ==========================================================================
287 287
288 File open/save panels 288 File open/save panels
289 This and next override methods to work around OS X behavior of 289 This and next override methods to handle keyboard input in panels.
290 restarting application loop when user dismisses panel.
291 290
292 ========================================================================== */ 291 ========================================================================== */
293 292
@@ -838,6 +837,9 @@ extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
838#define NSAPP_DATA2_RUNASSCRIPT 10 837#define NSAPP_DATA2_RUNASSCRIPT 10
839extern void ns_run_ascript (void); 838extern void ns_run_ascript (void);
840 839
840#define NSAPP_DATA2_RUNFILEDIALOG 11
841extern void ns_run_file_dialog (void);
842
841extern const char *ns_etc_directory (void); 843extern const char *ns_etc_directory (void);
842extern const char *ns_exec_path (void); 844extern const char *ns_exec_path (void);
843extern const char *ns_load_path (void); 845extern const char *ns_load_path (void);
diff --git a/src/nsterm.m b/src/nsterm.m
index 93f693fe55e..d7cea5c189a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3603,7 +3603,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3603 3603
3604 /* Inform fd_handler that select should be called */ 3604 /* Inform fd_handler that select should be called */
3605 c = 'g'; 3605 c = 'g';
3606 emacs_write (selfds[1], &c, 1); 3606 emacs_write_sig (selfds[1], &c, 1);
3607 } 3607 }
3608 else if (nr == 0 && timeout) 3608 else if (nr == 0 && timeout)
3609 { 3609 {
@@ -3636,7 +3636,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3636 if (nr > 0 && readfds) 3636 if (nr > 0 && readfds)
3637 { 3637 {
3638 c = 's'; 3638 c = 's';
3639 emacs_write (selfds[1], &c, 1); 3639 emacs_write_sig (selfds[1], &c, 1);
3640 } 3640 }
3641 unblock_input (); 3641 unblock_input ();
3642 3642
@@ -4142,7 +4142,7 @@ ns_term_init (Lisp_Object display_name)
4142 4142
4143 if (selfds[0] == -1) 4143 if (selfds[0] == -1)
4144 { 4144 {
4145 if (pipe (selfds) == -1) 4145 if (pipe2 (selfds, O_CLOEXEC) != 0)
4146 { 4146 {
4147 fprintf (stderr, "Failed to create pipe: %s\n", 4147 fprintf (stderr, "Failed to create pipe: %s\n",
4148 emacs_strerror (errno)); 4148 emacs_strerror (errno));
@@ -4419,16 +4419,33 @@ ns_term_shutdown (int sig)
4419/* NSTRACE (sendEvent); */ 4419/* NSTRACE (sendEvent); */
4420/*fprintf (stderr, "received event of type %d\t%d\n", type);*/ 4420/*fprintf (stderr, "received event of type %d\t%d\n", type);*/
4421 4421
4422#ifdef NS_IMPL_COCOA 4422#ifdef NS_IMPL_GNUSTEP
4423 if (type == NSApplicationDefined 4423 // Keyboard events aren't propagated to file dialogs for some reason.
4424 && [theEvent data2] == NSAPP_DATA2_RUNASSCRIPT) 4424 if ([NSApp modalWindow] != nil &&
4425 (type == NSKeyDown || type == NSKeyUp || type == NSFlagsChanged))
4425 { 4426 {
4426 ns_run_ascript (); 4427 [[NSApp modalWindow] sendEvent: theEvent];
4427 [self stop: self];
4428 return; 4428 return;
4429 } 4429 }
4430#endif 4430#endif
4431 4431
4432 if (type == NSApplicationDefined)
4433 {
4434 switch ([theEvent data2])
4435 {
4436#ifdef NS_IMPL_COCOA
4437 case NSAPP_DATA2_RUNASSCRIPT:
4438 ns_run_ascript ();
4439 [self stop: self];
4440 return;
4441#endif
4442 case NSAPP_DATA2_RUNFILEDIALOG:
4443 ns_run_file_dialog ();
4444 [self stop: self];
4445 return;
4446 }
4447 }
4448
4432 if (type == NSCursorUpdate && window == nil) 4449 if (type == NSCursorUpdate && window == nil)
4433 { 4450 {
4434 fprintf (stderr, "Dropping external cursor update event.\n"); 4451 fprintf (stderr, "Dropping external cursor update event.\n");
diff --git a/src/print.c b/src/print.c
index f5ee47dc114..1257b46dda4 100644
--- a/src/print.c
+++ b/src/print.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include "sysstdio.h"
24 24
25#include "lisp.h" 25#include "lisp.h"
26#include "character.h" 26#include "character.h"
@@ -767,7 +767,7 @@ append to existing target file. */)
767 { 767 {
768 file = Fexpand_file_name (file, Qnil); 768 file = Fexpand_file_name (file, Qnil);
769 initial_stderr_stream = stderr; 769 initial_stderr_stream = stderr;
770 stderr = fopen (SSDATA (file), NILP (append) ? "w" : "a"); 770 stderr = emacs_fopen (SSDATA (file), NILP (append) ? "w" : "a");
771 if (stderr == NULL) 771 if (stderr == NULL)
772 { 772 {
773 stderr = initial_stderr_stream; 773 stderr = initial_stderr_stream;
@@ -1774,9 +1774,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1774#endif 1774#endif
1775 else if (WINDOWP (obj)) 1775 else if (WINDOWP (obj))
1776 { 1776 {
1777 int len; 1777 void *ptr = XWINDOW (obj);
1778 strout ("#<window ", -1, -1, printcharfun); 1778 int len = sprintf (buf, "#<window %p", ptr);
1779 len = sprintf (buf, "%p", XWINDOW (obj));
1780 strout (buf, len, len, printcharfun); 1779 strout (buf, len, len, printcharfun);
1781 if (BUFFERP (XWINDOW (obj)->contents)) 1780 if (BUFFERP (XWINDOW (obj)->contents))
1782 { 1781 {
@@ -1807,6 +1806,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1807 ptrdiff_t real_size, size; 1806 ptrdiff_t real_size, size;
1808 int len; 1807 int len;
1809#if 0 1808#if 0
1809 void *ptr = h;
1810 strout ("#<hash-table", -1, -1, printcharfun); 1810 strout ("#<hash-table", -1, -1, printcharfun);
1811 if (SYMBOLP (h->test)) 1811 if (SYMBOLP (h->test))
1812 { 1812 {
@@ -1819,9 +1819,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1819 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next)); 1819 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next));
1820 strout (buf, len, len, printcharfun); 1820 strout (buf, len, len, printcharfun);
1821 } 1821 }
1822 len = sprintf (buf, " %p", h); 1822 len = sprintf (buf, " %p>", ptr);
1823 strout (buf, len, len, printcharfun); 1823 strout (buf, len, len, printcharfun);
1824 PRINTCHAR ('>');
1825#endif 1824#endif
1826 /* Implement a readable output, e.g.: 1825 /* Implement a readable output, e.g.:
1827 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ 1826 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
@@ -1901,6 +1900,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1901 else if (FRAMEP (obj)) 1900 else if (FRAMEP (obj))
1902 { 1901 {
1903 int len; 1902 int len;
1903 void *ptr = XFRAME (obj);
1904 Lisp_Object frame_name = XFRAME (obj)->name; 1904 Lisp_Object frame_name = XFRAME (obj)->name;
1905 1905
1906 strout ((FRAME_LIVE_P (XFRAME (obj)) 1906 strout ((FRAME_LIVE_P (XFRAME (obj))
@@ -1916,9 +1916,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1916 frame_name = build_string ("*INVALID*FRAME*NAME*"); 1916 frame_name = build_string ("*INVALID*FRAME*NAME*");
1917 } 1917 }
1918 print_string (frame_name, printcharfun); 1918 print_string (frame_name, printcharfun);
1919 len = sprintf (buf, " %p", XFRAME (obj)); 1919 len = sprintf (buf, " %p>", ptr);
1920 strout (buf, len, len, printcharfun); 1920 strout (buf, len, len, printcharfun);
1921 PRINTCHAR ('>');
1922 } 1921 }
1923 else if (FONTP (obj)) 1922 else if (FONTP (obj))
1924 { 1923 {
diff --git a/src/process.c b/src/process.c
index 9961697e671..8589acaa8b5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -78,7 +78,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
78#endif 78#endif
79 79
80#ifdef HAVE_RES_INIT 80#ifdef HAVE_RES_INIT
81#include <netinet/in.h>
82#include <arpa/nameser.h> 81#include <arpa/nameser.h>
83#include <resolv.h> 82#include <resolv.h>
84#endif 83#endif
@@ -136,6 +135,37 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
136 EMACS_TIME *, void *); 135 EMACS_TIME *, void *);
137#endif 136#endif
138 137
138#ifndef SOCK_CLOEXEC
139# define SOCK_CLOEXEC 0
140#endif
141
142#ifndef HAVE_ACCEPT4
143
144/* Emulate GNU/Linux accept4 and socket well enough for this module. */
145
146static int
147close_on_exec (int fd)
148{
149 if (0 <= fd)
150 fcntl (fd, F_SETFD, FD_CLOEXEC);
151 return fd;
152}
153
154static int
155accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
156{
157 return close_on_exec (accept (sockfd, addr, addrlen));
158}
159
160static int
161process_socket (int domain, int type, int protocol)
162{
163 return close_on_exec (socket (domain, type, protocol));
164}
165# undef socket
166# define socket(domain, type, protocol) process_socket (domain, type, protocol)
167#endif
168
139/* Work around GCC 4.7.0 bug with strict overflow checking; see 169/* Work around GCC 4.7.0 bug with strict overflow checking; see
140 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 170 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
141 These lines can be removed once the GCC bug is fixed. */ 171 These lines can be removed once the GCC bug is fixed. */
@@ -1586,6 +1616,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1586{ 1616{
1587 int inchannel, outchannel; 1617 int inchannel, outchannel;
1588 pid_t pid; 1618 pid_t pid;
1619 int vfork_errno;
1589 int sv[2]; 1620 int sv[2];
1590#ifndef WINDOWSNT 1621#ifndef WINDOWSNT
1591 int wait_child_setup[2]; 1622 int wait_child_setup[2];
@@ -1620,47 +1651,30 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1620 else 1651 else
1621#endif /* HAVE_PTYS */ 1652#endif /* HAVE_PTYS */
1622 { 1653 {
1623 int tem; 1654 if (pipe2 (sv, O_CLOEXEC) != 0)
1624 tem = pipe (sv);
1625 if (tem < 0)
1626 report_file_error ("Creating pipe", Qnil); 1655 report_file_error ("Creating pipe", Qnil);
1627 inchannel = sv[0]; 1656 inchannel = sv[0];
1628 forkout = sv[1]; 1657 forkout = sv[1];
1629 tem = pipe (sv); 1658 if (pipe2 (sv, O_CLOEXEC) != 0)
1630 if (tem < 0)
1631 { 1659 {
1660 int pipe_errno = errno;
1632 emacs_close (inchannel); 1661 emacs_close (inchannel);
1633 emacs_close (forkout); 1662 emacs_close (forkout);
1634 report_file_error ("Creating pipe", Qnil); 1663 report_file_errno ("Creating pipe", Qnil, pipe_errno);
1635 } 1664 }
1636 outchannel = sv[1]; 1665 outchannel = sv[1];
1637 forkin = sv[0]; 1666 forkin = sv[0];
1638 } 1667 }
1639 1668
1640#ifndef WINDOWSNT 1669#ifndef WINDOWSNT
1641 { 1670 if (pipe2 (wait_child_setup, O_CLOEXEC) != 0)
1642 int tem; 1671 report_file_error ("Creating pipe", Qnil);
1643
1644 tem = pipe (wait_child_setup);
1645 if (tem < 0)
1646 report_file_error ("Creating pipe", Qnil);
1647 tem = fcntl (wait_child_setup[1], F_GETFD, 0);
1648 if (tem >= 0)
1649 tem = fcntl (wait_child_setup[1], F_SETFD, tem | FD_CLOEXEC);
1650 if (tem < 0)
1651 {
1652 emacs_close (wait_child_setup[0]);
1653 emacs_close (wait_child_setup[1]);
1654 report_file_error ("Setting file descriptor flags", Qnil);
1655 }
1656 }
1657#endif 1672#endif
1658 1673
1659 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1674 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1660 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1675 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1661 1676
1662 /* Record this as an active process, with its channels. 1677 /* Record this as an active process, with its channels. */
1663 As a result, child_setup will close Emacs's side of the pipes. */
1664 chan_process[inchannel] = process; 1678 chan_process[inchannel] = process;
1665 XPROCESS (process)->infd = inchannel; 1679 XPROCESS (process)->infd = inchannel;
1666 XPROCESS (process)->outfd = outchannel; 1680 XPROCESS (process)->outfd = outchannel;
@@ -1740,7 +1754,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1740 tcgetattr (xforkin, &t); 1754 tcgetattr (xforkin, &t);
1741 t.c_lflag = LDISC1; 1755 t.c_lflag = LDISC1;
1742 if (tcsetattr (xforkin, TCSANOW, &t) < 0) 1756 if (tcsetattr (xforkin, TCSANOW, &t) < 0)
1743 emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39); 1757 emacs_perror ("create_process/tcsetattr LDISC1");
1744 } 1758 }
1745#else 1759#else
1746#if defined (NTTYDISC) && defined (TIOCSETD) 1760#if defined (NTTYDISC) && defined (TIOCSETD)
@@ -1787,10 +1801,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1787 1801
1788 if (xforkin < 0) 1802 if (xforkin < 0)
1789 { 1803 {
1790 emacs_write (1, "Couldn't open the pty terminal ", 31); 1804 emacs_perror (pty_name);
1791 emacs_write (1, pty_name, strlen (pty_name)); 1805 _exit (EXIT_CANCELED);
1792 emacs_write (1, "\n", 1);
1793 _exit (1);
1794 } 1806 }
1795 1807
1796 } 1808 }
@@ -1802,12 +1814,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1802 SETUP_SLAVE_PTY; 1814 SETUP_SLAVE_PTY;
1803 } 1815 }
1804#endif /* SETUP_SLAVE_PTY */ 1816#endif /* SETUP_SLAVE_PTY */
1805#ifdef AIX
1806 /* On AIX, we've disabled SIGHUP above once we start a child on a pty.
1807 Now reenable it in the child, so it will die when we want it to. */
1808 if (pty_flag)
1809 signal (SIGHUP, SIG_DFL);
1810#endif
1811#endif /* HAVE_PTYS */ 1817#endif /* HAVE_PTYS */
1812 1818
1813 signal (SIGINT, SIG_DFL); 1819 signal (SIGINT, SIG_DFL);
@@ -1825,7 +1831,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1825 pid = child_setup (xforkin, xforkout, xforkout, 1831 pid = child_setup (xforkin, xforkout, xforkout,
1826 new_argv, 1, encoded_current_dir); 1832 new_argv, 1, encoded_current_dir);
1827#else /* not WINDOWSNT */ 1833#else /* not WINDOWSNT */
1828 emacs_close (wait_child_setup[0]);
1829 child_setup (xforkin, xforkout, xforkout, 1834 child_setup (xforkin, xforkout, xforkout,
1830 new_argv, 1, encoded_current_dir); 1835 new_argv, 1, encoded_current_dir);
1831#endif /* not WINDOWSNT */ 1836#endif /* not WINDOWSNT */
@@ -1833,6 +1838,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1833 1838
1834 /* Back in the parent process. */ 1839 /* Back in the parent process. */
1835 1840
1841 vfork_errno = errno;
1836 XPROCESS (process)->pid = pid; 1842 XPROCESS (process)->pid = pid;
1837 if (pid >= 0) 1843 if (pid >= 0)
1838 XPROCESS (process)->alive = 1; 1844 XPROCESS (process)->alive = 1;
@@ -1847,6 +1853,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1847 emacs_close (forkin); 1853 emacs_close (forkin);
1848 if (forkin != forkout && forkout >= 0) 1854 if (forkin != forkout && forkout >= 0)
1849 emacs_close (forkout); 1855 emacs_close (forkout);
1856 report_file_errno ("Doing vfork", Qnil, vfork_errno);
1850 } 1857 }
1851 else 1858 else
1852 { 1859 {
@@ -1892,10 +1899,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1892 } 1899 }
1893#endif 1900#endif
1894 } 1901 }
1895
1896 /* Now generate the error if vfork failed. */
1897 if (pid < 0)
1898 report_file_error ("Doing vfork", Qnil);
1899} 1902}
1900 1903
1901void 1904void
@@ -3136,7 +3139,8 @@ usage: (make-network-process &rest ARGS) */)
3136 retry_connect: 3139 retry_connect:
3137#endif 3140#endif
3138 3141
3139 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); 3142 s = socket (lres->ai_family, lres->ai_socktype | SOCK_CLOEXEC,
3143 lres->ai_protocol);
3140 if (s < 0) 3144 if (s < 0)
3141 { 3145 {
3142 xerrno = errno; 3146 xerrno = errno;
@@ -3260,12 +3264,11 @@ usage: (make-network-process &rest ARGS) */)
3260 3264
3261 len = sizeof xerrno; 3265 len = sizeof xerrno;
3262 eassert (FD_ISSET (s, &fdset)); 3266 eassert (FD_ISSET (s, &fdset));
3263 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) 3267 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0)
3264 report_file_error ("getsockopt failed", Qnil); 3268 report_file_error ("getsockopt failed", Qnil);
3265 if (xerrno) 3269 if (xerrno)
3266 errno = xerrno, report_file_error ("error during connect", Qnil); 3270 report_file_errno ("error during connect", Qnil, xerrno);
3267 else 3271 break;
3268 break;
3269 } 3272 }
3270#endif /* !WINDOWSNT */ 3273#endif /* !WINDOWSNT */
3271 3274
@@ -3349,11 +3352,10 @@ usage: (make-network-process &rest ARGS) */)
3349 if (is_non_blocking_client) 3352 if (is_non_blocking_client)
3350 return Qnil; 3353 return Qnil;
3351 3354
3352 errno = xerrno; 3355 report_file_errno ((is_server
3353 if (is_server) 3356 ? "make server process failed"
3354 report_file_error ("make server process failed", contact); 3357 : "make client process failed"),
3355 else 3358 contact, xerrno);
3356 report_file_error ("make client process failed", contact);
3357 } 3359 }
3358 3360
3359 inch = s; 3361 inch = s;
@@ -3533,7 +3535,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3533 int s; 3535 int s;
3534 Lisp_Object res; 3536 Lisp_Object res;
3535 3537
3536 s = socket (AF_INET, SOCK_STREAM, 0); 3538 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
3537 if (s < 0) 3539 if (s < 0)
3538 return Qnil; 3540 return Qnil;
3539 3541
@@ -3544,14 +3546,14 @@ format; see the description of ADDRESS in `make-network-process'. */)
3544 ifconf.ifc_len = buf_size; 3546 ifconf.ifc_len = buf_size;
3545 if (ioctl (s, SIOCGIFCONF, &ifconf)) 3547 if (ioctl (s, SIOCGIFCONF, &ifconf))
3546 { 3548 {
3547 close (s); 3549 emacs_close (s);
3548 xfree (buf); 3550 xfree (buf);
3549 return Qnil; 3551 return Qnil;
3550 } 3552 }
3551 } 3553 }
3552 while (ifconf.ifc_len == buf_size); 3554 while (ifconf.ifc_len == buf_size);
3553 3555
3554 close (s); 3556 emacs_close (s);
3555 3557
3556 res = Qnil; 3558 res = Qnil;
3557 ifreq = ifconf.ifc_req; 3559 ifreq = ifconf.ifc_req;
@@ -3689,7 +3691,7 @@ FLAGS is the current flags of the interface. */)
3689 error ("interface name too long"); 3691 error ("interface name too long");
3690 strcpy (rq.ifr_name, SSDATA (ifname)); 3692 strcpy (rq.ifr_name, SSDATA (ifname));
3691 3693
3692 s = socket (AF_INET, SOCK_STREAM, 0); 3694 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
3693 if (s < 0) 3695 if (s < 0)
3694 return Qnil; 3696 return Qnil;
3695 3697
@@ -3808,7 +3810,7 @@ FLAGS is the current flags of the interface. */)
3808#endif 3810#endif
3809 res = Fcons (elt, res); 3811 res = Fcons (elt, res);
3810 3812
3811 close (s); 3813 emacs_close (s);
3812 3814
3813 return any ? res : Qnil; 3815 return any ? res : Qnil;
3814} 3816}
@@ -3985,7 +3987,7 @@ server_accept_connection (Lisp_Object server, int channel)
3985 } saddr; 3987 } saddr;
3986 socklen_t len = sizeof saddr; 3988 socklen_t len = sizeof saddr;
3987 3989
3988 s = accept (channel, &saddr.sa, &len); 3990 s = accept4 (channel, &saddr.sa, &len, SOCK_CLOEXEC);
3989 3991
3990 if (s < 0) 3992 if (s < 0)
3991 { 3993 {
@@ -4621,20 +4623,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4621 if (xerrno == EINTR) 4623 if (xerrno == EINTR)
4622 no_avail = 1; 4624 no_avail = 1;
4623 else if (xerrno == EBADF) 4625 else if (xerrno == EBADF)
4624 { 4626 emacs_abort ();
4625#ifdef AIX
4626 /* AIX doesn't handle PTY closure the same way BSD does. On AIX,
4627 the child's closure of the pts gives the parent a SIGHUP, and
4628 the ptc file descriptor is automatically closed,
4629 yielding EBADF here or at select() call above.
4630 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
4631 in m/ibmrt-aix.h), and here we just ignore the select error.
4632 Cleanup occurs c/o status_notify after SIGCHLD. */
4633 no_avail = 1; /* Cannot depend on values returned */
4634#else
4635 emacs_abort ();
4636#endif
4637 }
4638 else 4627 else
4639 error ("select error: %s", emacs_strerror (xerrno)); 4628 error ("select error: %s", emacs_strerror (xerrno));
4640 } 4629 }
@@ -5490,7 +5479,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5490 written = emacs_gnutls_write (p, cur_buf, cur_len); 5479 written = emacs_gnutls_write (p, cur_buf, cur_len);
5491 else 5480 else
5492#endif 5481#endif
5493 written = emacs_write (outfd, cur_buf, cur_len); 5482 written = emacs_write_sig (outfd, cur_buf, cur_len);
5494 rv = (written ? 0 : -1); 5483 rv = (written ? 0 : -1);
5495#ifdef ADAPTIVE_READ_BUFFERING 5484#ifdef ADAPTIVE_READ_BUFFERING
5496 if (p->read_output_delay > 0 5485 if (p->read_output_delay > 0
@@ -6859,32 +6848,6 @@ setup_process_coding_systems (Lisp_Object process)
6859#endif 6848#endif
6860} 6849}
6861 6850
6862/* Close all descriptors currently in use for communication
6863 with subprocess. This is used in a newly-forked subprocess
6864 to get rid of irrelevant descriptors. */
6865
6866void
6867close_process_descs (void)
6868{
6869#ifndef DOS_NT
6870 int i;
6871 for (i = 0; i < MAXDESC; i++)
6872 {
6873 Lisp_Object process;
6874 process = chan_process[i];
6875 if (!NILP (process))
6876 {
6877 int in = XPROCESS (process)->infd;
6878 int out = XPROCESS (process)->outfd;
6879 if (in >= 0)
6880 emacs_close (in);
6881 if (out >= 0 && in != out)
6882 emacs_close (out);
6883 }
6884 }
6885#endif
6886}
6887
6888DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, 6851DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
6889 doc: /* Return the (or a) process associated with BUFFER. 6852 doc: /* Return the (or a) process associated with BUFFER.
6890BUFFER may be a buffer or the name of one. */) 6853BUFFER may be a buffer or the name of one. */)
diff --git a/src/process.h b/src/process.h
index e7ee5f9adde..8ae33aebf39 100644
--- a/src/process.h
+++ b/src/process.h
@@ -198,6 +198,14 @@ extern Lisp_Object QCspeed;
198extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; 198extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
199extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; 199extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
200 200
201/* Exit statuses for GNU programs that exec other programs. */
202enum
203{
204 EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */
205 EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */
206 EXIT_ENOENT = 127 /* Could not find program to exec. */
207};
208
201/* Defined in callproc.c. */ 209/* Defined in callproc.c. */
202 210
203extern void block_child_signal (void); 211extern void block_child_signal (void);
diff --git a/src/profiler.c b/src/profiler.c
index aba81344c68..c86fb47d21d 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -568,12 +568,12 @@ to make room for new entries. */);
568 profiler_log_size = 10000; 568 profiler_log_size = 10000;
569 569
570 DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal"); 570 DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal");
571 { 571
572 struct hash_table_test test 572 hashtest_profiler.name = Qprofiler_backtrace_equal;
573 = { Qprofiler_backtrace_equal, Qnil, Qnil, 573 hashtest_profiler.user_hash_function = Qnil;
574 cmpfn_profiler, hashfn_profiler }; 574 hashtest_profiler.user_cmp_function = Qnil;
575 hashtest_profiler = test; 575 hashtest_profiler.cmpfn = cmpfn_profiler;
576 } 576 hashtest_profiler.hashfn = hashfn_profiler;
577 577
578 defsubr (&Sfunction_equal); 578 defsubr (&Sfunction_equal);
579 579
diff --git a/src/ralloc.c b/src/ralloc.c
index 13fd65cbb0c..5f25ef2c320 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -43,8 +43,6 @@ extern size_t __malloc_extra_blocks;
43#else /* not emacs */ 43#else /* not emacs */
44 44
45#include <stddef.h> 45#include <stddef.h>
46
47#include <unistd.h>
48#include <malloc.h> 46#include <malloc.h>
49 47
50#endif /* not emacs */ 48#endif /* not emacs */
diff --git a/src/regex.c b/src/regex.c
index 79fb28ba12a..39adb080efd 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -531,8 +531,10 @@ init_syntax_once (void)
531/* Type of source-pattern and string chars. */ 531/* Type of source-pattern and string chars. */
532#ifdef _MSC_VER 532#ifdef _MSC_VER
533typedef unsigned char re_char; 533typedef unsigned char re_char;
534typedef const re_char const_re_char;
534#else 535#else
535typedef const unsigned char re_char; 536typedef const unsigned char re_char;
537typedef re_char const_re_char;
536#endif 538#endif
537 539
538typedef char boolean; 540typedef char boolean;
@@ -2015,7 +2017,7 @@ struct range_table_work_area
2015 2017
2016/* Map a string to the char class it names (if any). */ 2018/* Map a string to the char class it names (if any). */
2017re_wctype_t 2019re_wctype_t
2018re_wctype (const re_char *str) 2020re_wctype (const_re_char *str)
2019{ 2021{
2020 const char *string = (const char *) str; 2022 const char *string = (const char *) str;
2021 if (STREQ (string, "alnum")) return RECC_ALNUM; 2023 if (STREQ (string, "alnum")) return RECC_ALNUM;
@@ -2409,7 +2411,8 @@ do { \
2409 } while (0) 2411 } while (0)
2410 2412
2411static reg_errcode_t 2413static reg_errcode_t
2412regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) 2414regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax,
2415 struct re_pattern_buffer *bufp)
2413{ 2416{
2414 /* We fetch characters from PATTERN here. */ 2417 /* We fetch characters from PATTERN here. */
2415 register re_wchar_t c, c1; 2418 register re_wchar_t c, c1;
@@ -3765,7 +3768,7 @@ insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned cha
3765 least one character before the ^. */ 3768 least one character before the ^. */
3766 3769
3767static boolean 3770static boolean
3768at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) 3771at_begline_loc_p (const_re_char *pattern, const_re_char *p, reg_syntax_t syntax)
3769{ 3772{
3770 re_char *prev = p - 2; 3773 re_char *prev = p - 2;
3771 boolean odd_backslashes; 3774 boolean odd_backslashes;
@@ -3806,7 +3809,7 @@ at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
3806 at least one character after the $, i.e., `P < PEND'. */ 3809 at least one character after the $, i.e., `P < PEND'. */
3807 3810
3808static boolean 3811static boolean
3809at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) 3812at_endline_loc_p (const_re_char *p, const_re_char *pend, reg_syntax_t syntax)
3810{ 3813{
3811 re_char *next = p; 3814 re_char *next = p;
3812 boolean next_backslash = *next == '\\'; 3815 boolean next_backslash = *next == '\\';
@@ -3850,7 +3853,8 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
3850 Return -1 if fastmap was not updated accurately. */ 3853 Return -1 if fastmap was not updated accurately. */
3851 3854
3852static int 3855static int
3853analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) 3856analyse_first (const_re_char *p, const_re_char *pend, char *fastmap,
3857 const int multibyte)
3854{ 3858{
3855 int j, k; 3859 int j, k;
3856 boolean not; 3860 boolean not;
@@ -4594,7 +4598,7 @@ static int bcmp_translate (re_char *s1, re_char *s2,
4594/* If the operation is a match against one or more chars, 4598/* If the operation is a match against one or more chars,
4595 return a pointer to the next operation, else return NULL. */ 4599 return a pointer to the next operation, else return NULL. */
4596static re_char * 4600static re_char *
4597skip_one_char (const re_char *p) 4601skip_one_char (const_re_char *p)
4598{ 4602{
4599 switch (*p++) 4603 switch (*p++)
4600 { 4604 {
@@ -4636,7 +4640,7 @@ skip_one_char (const re_char *p)
4636 4640
4637/* Jump over non-matching operations. */ 4641/* Jump over non-matching operations. */
4638static re_char * 4642static re_char *
4639skip_noops (const re_char *p, const re_char *pend) 4643skip_noops (const_re_char *p, const_re_char *pend)
4640{ 4644{
4641 int mcnt; 4645 int mcnt;
4642 while (p < pend) 4646 while (p < pend)
@@ -4663,7 +4667,8 @@ skip_noops (const re_char *p, const re_char *pend)
4663 4667
4664/* Non-zero if "p1 matches something" implies "p2 fails". */ 4668/* Non-zero if "p1 matches something" implies "p2 fails". */
4665static int 4669static int
4666mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) 4670mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1,
4671 const_re_char *p2)
4667{ 4672{
4668 re_opcode_t op2; 4673 re_opcode_t op2;
4669 const boolean multibyte = RE_MULTIBYTE_P (bufp); 4674 const boolean multibyte = RE_MULTIBYTE_P (bufp);
@@ -4922,8 +4927,8 @@ WEAK_ALIAS (__re_match_2, re_match_2)
4922/* This is a separate function so that we can force an alloca cleanup 4927/* This is a separate function so that we can force an alloca cleanup
4923 afterwards. */ 4928 afterwards. */
4924static regoff_t 4929static regoff_t
4925re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, 4930re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
4926 size_t size1, const re_char *string2, size_t size2, 4931 size_t size1, const_re_char *string2, size_t size2,
4927 ssize_t pos, struct re_registers *regs, ssize_t stop) 4932 ssize_t pos, struct re_registers *regs, ssize_t stop)
4928{ 4933{
4929 /* General temporaries. */ 4934 /* General temporaries. */
@@ -6265,7 +6270,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
6265 bytes; nonzero otherwise. */ 6270 bytes; nonzero otherwise. */
6266 6271
6267static int 6272static int
6268bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len, 6273bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len,
6269 RE_TRANSLATE_TYPE translate, const int target_multibyte) 6274 RE_TRANSLATE_TYPE translate, const int target_multibyte)
6270{ 6275{
6271 register re_char *p1 = s1, *p2 = s2; 6276 register re_char *p1 = s1, *p2 = s2;
@@ -6434,7 +6439,7 @@ re_exec (const char *s)
6434 the return codes and their meanings.) */ 6439 the return codes and their meanings.) */
6435 6440
6436reg_errcode_t 6441reg_errcode_t
6437regcomp (regex_t *__restrict preg, const char *__restrict pattern, 6442regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern,
6438 int cflags) 6443 int cflags)
6439{ 6444{
6440 reg_errcode_t ret; 6445 reg_errcode_t ret;
@@ -6515,8 +6520,8 @@ WEAK_ALIAS (__regcomp, regcomp)
6515 We return 0 if we find a match and REG_NOMATCH if not. */ 6520 We return 0 if we find a match and REG_NOMATCH if not. */
6516 6521
6517reg_errcode_t 6522reg_errcode_t
6518regexec (const regex_t *__restrict preg, const char *__restrict string, 6523regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
6519 size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) 6524 size_t nmatch, regmatch_t pmatch[_Restrict_arr_], int eflags)
6520{ 6525{
6521 regoff_t ret; 6526 regoff_t ret;
6522 struct re_registers regs; 6527 struct re_registers regs;
diff --git a/src/regex.h b/src/regex.h
index 8fe7ba16adc..bb737df5239 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -528,31 +528,41 @@ extern int re_exec (const char *);
528#endif 528#endif
529 529
530/* GCC 2.95 and later have "__restrict"; C99 compilers have 530/* GCC 2.95 and later have "__restrict"; C99 compilers have
531 "restrict", and "configure" may have defined "restrict". */ 531 "restrict", and "configure" may have defined "restrict".
532#ifndef __restrict 532 Other compilers use __restrict, __restrict__, and _Restrict, and
533# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) 533 'configure' might #define 'restrict' to those words, so pick a
534# if defined restrict || 199901L <= __STDC_VERSION__ 534 different name. */
535# define __restrict restrict 535#ifndef _Restrict_
536# else 536# if 199901L <= __STDC_VERSION__
537# define __restrict 537# define _Restrict_ restrict
538# endif 538# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
539# define _Restrict_ __restrict
540# else
541# define _Restrict_
539# endif 542# endif
540#endif 543#endif
541/* For now conditionally define __restrict_arr to expand to nothing. 544/* gcc 3.1 and up support the [restrict] syntax. Don't trust
542 Ideally we would have a test for the compiler which allows defining 545 sys/cdefs.h's definition of __restrict_arr, though, as it
543 it to restrict. */ 546 mishandles gcc -ansi -pedantic. */
544#ifndef __restrict_arr 547#ifndef _Restrict_arr_
545# define __restrict_arr 548# if ((199901L <= __STDC_VERSION__ \
549 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
550 && !defined __STRICT_ANSI__)) \
551 && !defined __GNUG__)
552# define _Restrict_arr_ _Restrict_
553# else
554# define _Restrict_arr_
555# endif
546#endif 556#endif
547 557
548/* POSIX compatibility. */ 558/* POSIX compatibility. */
549extern reg_errcode_t regcomp (regex_t *__restrict __preg, 559extern reg_errcode_t regcomp (regex_t *_Restrict_ __preg,
550 const char *__restrict __pattern, 560 const char *_Restrict_ __pattern,
551 int __cflags); 561 int __cflags);
552 562
553extern reg_errcode_t regexec (const regex_t *__restrict __preg, 563extern reg_errcode_t regexec (const regex_t *_Restrict_ __preg,
554 const char *__restrict __string, size_t __nmatch, 564 const char *_Restrict_ __string, size_t __nmatch,
555 regmatch_t __pmatch[__restrict_arr], 565 regmatch_t __pmatch[_Restrict_arr_],
556 int __eflags); 566 int __eflags);
557 567
558extern size_t regerror (int __errcode, const regex_t * __preg, 568extern size_t regerror (int __errcode, const regex_t * __preg,
diff --git a/src/search.c b/src/search.c
index 8b4d39c7811..19cc08f84c4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -22,10 +22,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <config.h> 22#include <config.h>
23 23
24#include "lisp.h" 24#include "lisp.h"
25#include "syntax.h"
26#include "category.h" 25#include "category.h"
27#include "character.h" 26#include "character.h"
28#include "buffer.h" 27#include "buffer.h"
28#include "syntax.h"
29#include "charset.h" 29#include "charset.h"
30#include "region-cache.h" 30#include "region-cache.h"
31#include "commands.h" 31#include "commands.h"
diff --git a/src/sheap.c b/src/sheap.c
index f8eec753268..54eef60c27d 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -25,7 +25,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <unistd.h> 26#include <unistd.h>
27 27
28#ifdef __x86_64__
29#define STATIC_HEAP_SIZE (18 * 1024 * 1024)
30#else
28#define STATIC_HEAP_SIZE (13 * 1024 * 1024) 31#define STATIC_HEAP_SIZE (13 * 1024 * 1024)
32#endif
29 33
30int debug_sheap = 0; 34int debug_sheap = 0;
31 35
diff --git a/src/sound.c b/src/sound.c
index 7f0ede5b398..5ce185ea60e 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -879,7 +879,7 @@ vox_init (struct sound_device *sd)
879static void 879static void
880vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes) 880vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes)
881{ 881{
882 if (emacs_write (sd->fd, buffer, nbytes) != nbytes) 882 if (emacs_write_sig (sd->fd, buffer, nbytes) != nbytes)
883 sound_perror ("Error writing to sound device"); 883 sound_perror ("Error writing to sound device");
884} 884}
885 885
diff --git a/src/syntax.c b/src/syntax.c
index ea15cf68c43..6d52d115889 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -20,6 +20,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#define SYNTAX_INLINE EXTERN_INLINE
24
23#include <sys/types.h> 25#include <sys/types.h>
24 26
25#include "lisp.h" 27#include "lisp.h"
@@ -58,54 +60,86 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58 For style c (like the nested flag), the flag can be placed on any of 60 For style c (like the nested flag), the flag can be placed on any of
59 the chars. */ 61 the chars. */
60 62
61/* These macros extract specific flags from an integer 63/* These functions extract specific flags from an integer
62 that holds the syntax code and the flags. */ 64 that holds the syntax code and the flags. */
63 65
64#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) 66static bool
65 67SYNTAX_FLAGS_COMSTART_FIRST (int flags)
66#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) 68{
67 69 return (flags >> 16) & 1;
68#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) 70}
69 71static bool
70#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) 72SYNTAX_FLAGS_COMSTART_SECOND (int flags)
71 73{
72#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) 74 return (flags >> 17) & 1;
75}
76static bool
77SYNTAX_FLAGS_COMEND_FIRST (int flags)
78{
79 return (flags >> 18) & 1;
80}
81static bool
82SYNTAX_FLAGS_COMEND_SECOND (int flags)
83{
84 return (flags >> 19) & 1;
85}
86static bool
87SYNTAX_FLAGS_PREFIX (int flags)
88{
89 return (flags >> 20) & 1;
90}
91static bool
92SYNTAX_FLAGS_COMMENT_STYLEB (int flags)
93{
94 return (flags >> 21) & 1;
95}
96static bool
97SYNTAX_FLAGS_COMMENT_STYLEC (int flags)
98{
99 return (flags >> 23) & 1;
100}
101static int
102SYNTAX_FLAGS_COMMENT_STYLEC2 (int flags)
103{
104 return (flags >> 22) & 2; /* SYNTAX_FLAGS_COMMENT_STYLEC (flags) * 2 */
105}
106static bool
107SYNTAX_FLAGS_COMMENT_NESTED (int flags)
108{
109 return (flags >> 22) & 1;
110}
73 111
74#define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1)
75#define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 23) & 1)
76#define SYNTAX_FLAGS_COMMENT_STYLEC2(flags) (((flags) >> 22) & 2) /* C * 2 */
77/* FLAGS should be the flags of the main char of the comment marker, e.g. 112/* FLAGS should be the flags of the main char of the comment marker, e.g.
78 the second for comstart and the first for comend. */ 113 the second for comstart and the first for comend. */
79#define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ 114static int
80 (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ 115SYNTAX_FLAGS_COMMENT_STYLE (int flags, int other_flags)
81 | SYNTAX_FLAGS_COMMENT_STYLEC2 (flags) \ 116{
82 | SYNTAX_FLAGS_COMMENT_STYLEC2 (other_flags)) 117 return (SYNTAX_FLAGS_COMMENT_STYLEB (flags)
83 118 | SYNTAX_FLAGS_COMMENT_STYLEC2 (flags)
84#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) 119 | SYNTAX_FLAGS_COMMENT_STYLEC2 (other_flags));
120}
85 121
86/* These macros extract a particular flag for a given character. */ 122/* Extract a particular flag for a given character. */
87 123
88#define SYNTAX_COMEND_FIRST(c) \ 124static bool
89 (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) 125SYNTAX_COMEND_FIRST (int c)
90#define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) 126{
127 return SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c));
128}
91 129
92/* We use these constants in place for comment-style and 130/* We use these constants in place for comment-style and
93 string-ender-char to distinguish comments/strings started by 131 string-ender-char to distinguish comments/strings started by
94 comment_fence and string_fence codes. */ 132 comment_fence and string_fence codes. */
95 133
96#define ST_COMMENT_STYLE (256 + 1) 134enum
97#define ST_STRING_STYLE (256 + 2) 135 {
136 ST_COMMENT_STYLE = 256 + 1,
137 ST_STRING_STYLE = 256 + 2
138 };
98 139
99static Lisp_Object Qsyntax_table_p; 140static Lisp_Object Qsyntax_table_p;
100static Lisp_Object Qsyntax_table, Qscan_error; 141static Lisp_Object Qsyntax_table, Qscan_error;
101 142
102#ifndef __GNUC__
103/* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
104 if not compiled with GCC. No need to mark it, since it is used
105 only very temporarily. */
106Lisp_Object syntax_temp;
107#endif
108
109/* This is the internal form of the parse state used in parse-partial-sexp. */ 143/* This is the internal form of the parse state used in parse-partial-sexp. */
110 144
111struct lisp_parse_state 145struct lisp_parse_state
@@ -162,14 +196,107 @@ bset_syntax_table (struct buffer *b, Lisp_Object val)
162bool 196bool
163syntax_prefix_flag_p (int c) 197syntax_prefix_flag_p (int c)
164{ 198{
165 return SYNTAX_PREFIX (c); 199 return SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c));
166} 200}
167 201
168struct gl_state_s gl_state; /* Global state of syntax parser. */ 202struct gl_state_s gl_state; /* Global state of syntax parser. */
169 203
170#define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals 204enum { INTERVALS_AT_ONCE = 10 }; /* 1 + max-number of intervals
171 to scan to property-change. */ 205 to scan to property-change. */
172 206
207/* Set the syntax entry VAL for char C in table TABLE. */
208
209static void
210SET_RAW_SYNTAX_ENTRY (Lisp_Object table, int c, Lisp_Object val)
211{
212 CHAR_TABLE_SET (table, c, val);
213}
214
215/* Set the syntax entry VAL for char-range RANGE in table TABLE.
216 RANGE is a cons (FROM . TO) specifying the range of characters. */
217
218static void
219SET_RAW_SYNTAX_ENTRY_RANGE (Lisp_Object table, Lisp_Object range,
220 Lisp_Object val)
221{
222 Fset_char_table_range (table, range, val);
223}
224
225/* Extract the information from the entry for character C
226 in the current syntax table. */
227
228static Lisp_Object
229SYNTAX_MATCH (int c)
230{
231 Lisp_Object ent = SYNTAX_ENTRY (c);
232 return CONSP (ent) ? XCDR (ent) : Qnil;
233}
234
235/* This should be called with FROM at the start of forward
236 search, or after the last position of the backward search. It
237 makes sure that the first char is picked up with correct table, so
238 one does not need to call UPDATE_SYNTAX_TABLE immediately after the
239 call.
240 Sign of COUNT gives the direction of the search.
241 */
242
243static void
244SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
245{
246 SETUP_BUFFER_SYNTAX_TABLE ();
247 gl_state.b_property = BEGV;
248 gl_state.e_property = ZV + 1;
249 gl_state.object = Qnil;
250 gl_state.offset = 0;
251 if (parse_sexp_lookup_properties)
252 if (count > 0 || from > BEGV)
253 update_syntax_table (count > 0 ? from : from - 1, count, 1, Qnil);
254}
255
256/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
257 If it is t (which is only used in fast_c_string_match_ignore_case),
258 ignore properties altogether.
259
260 This is meant for regex.c to use. For buffers, regex.c passes arguments
261 to the UPDATE_SYNTAX_TABLE functions which are relative to BEGV.
262 So if it is a buffer, we set the offset field to BEGV. */
263
264void
265SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
266 ptrdiff_t from, ptrdiff_t count)
267{
268 SETUP_BUFFER_SYNTAX_TABLE ();
269 gl_state.object = object;
270 if (BUFFERP (gl_state.object))
271 {
272 struct buffer *buf = XBUFFER (gl_state.object);
273 gl_state.b_property = 1;
274 gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1;
275 gl_state.offset = BUF_BEGV (buf) - 1;
276 }
277 else if (NILP (gl_state.object))
278 {
279 gl_state.b_property = 1;
280 gl_state.e_property = ZV - BEGV + 1;
281 gl_state.offset = BEGV - 1;
282 }
283 else if (EQ (gl_state.object, Qt))
284 {
285 gl_state.b_property = 0;
286 gl_state.e_property = PTRDIFF_MAX;
287 gl_state.offset = 0;
288 }
289 else
290 {
291 gl_state.b_property = 0;
292 gl_state.e_property = 1 + SCHARS (gl_state.object);
293 gl_state.offset = 0;
294 }
295 if (parse_sexp_lookup_properties)
296 update_syntax_table (from + gl_state.offset - (count <= 0),
297 count, 1, gl_state.object);
298}
299
173/* Update gl_state to an appropriate interval which contains CHARPOS. The 300/* Update gl_state to an appropriate interval which contains CHARPOS. The
174 sign of COUNT give the relative position of CHARPOS wrt the previously 301 sign of COUNT give the relative position of CHARPOS wrt the previously
175 valid interval. If INIT, only [be]_property fields of gl_state are 302 valid interval. If INIT, only [be]_property fields of gl_state are
@@ -1751,7 +1878,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1751 } 1878 }
1752 1879
1753 immediate_quit = 1; 1880 immediate_quit = 1;
1754 /* This code may look up syntax tables using macros that rely on the 1881 /* This code may look up syntax tables using functions that rely on the
1755 gl_state object. To make sure this object is not out of date, 1882 gl_state object. To make sure this object is not out of date,
1756 let's initialize it manually. 1883 let's initialize it manually.
1757 We ignore syntax-table text-properties for now, since that's 1884 We ignore syntax-table text-properties for now, since that's
@@ -2426,11 +2553,13 @@ between them, return t; otherwise return nil. */)
2426} 2553}
2427 2554
2428/* Return syntax code of character C if C is an ASCII character 2555/* Return syntax code of character C if C is an ASCII character
2429 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */ 2556 or if MULTIBYTE_SYMBOL_P is false. Otherwise, return Ssymbol. */
2430 2557
2431#define SYNTAX_WITH_MULTIBYTE_CHECK(c) \ 2558static enum syntaxcode
2432 ((ASCII_CHAR_P (c) || !multibyte_symbol_p) \ 2559syntax_multibyte (int c, bool multibyte_symbol_p)
2433 ? SYNTAX (c) : Ssymbol) 2560{
2561 return ASCII_CHAR_P (c) || !multibyte_symbol_p ? SYNTAX (c) : Ssymbol;
2562}
2434 2563
2435static Lisp_Object 2564static Lisp_Object
2436scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) 2565scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
@@ -2441,7 +2570,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2441 int stringterm; 2570 int stringterm;
2442 bool quoted; 2571 bool quoted;
2443 bool mathexit = 0; 2572 bool mathexit = 0;
2444 enum syntaxcode code, temp_code, c_code; 2573 enum syntaxcode code;
2445 EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */ 2574 EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */
2446 int comstyle = 0; /* style of comment encountered */ 2575 int comstyle = 0; /* style of comment encountered */
2447 bool comnested = 0; /* whether the comment is nestable or not */ 2576 bool comnested = 0; /* whether the comment is nestable or not */
@@ -2473,7 +2602,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2473 UPDATE_SYNTAX_TABLE_FORWARD (from); 2602 UPDATE_SYNTAX_TABLE_FORWARD (from);
2474 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2603 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2475 syntax = SYNTAX_WITH_FLAGS (c); 2604 syntax = SYNTAX_WITH_FLAGS (c);
2476 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2605 code = syntax_multibyte (c, multibyte_symbol_p);
2477 comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); 2606 comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax);
2478 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); 2607 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax);
2479 comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); 2608 comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0);
@@ -2519,10 +2648,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2519 { 2648 {
2520 UPDATE_SYNTAX_TABLE_FORWARD (from); 2649 UPDATE_SYNTAX_TABLE_FORWARD (from);
2521 2650
2522 /* Some compilers can't handle this inside the switch. */
2523 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2651 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2524 c_code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2652 switch (syntax_multibyte (c, multibyte_symbol_p))
2525 switch (c_code)
2526 { 2653 {
2527 case Scharquote: 2654 case Scharquote:
2528 case Sescape: 2655 case Sescape:
@@ -2594,18 +2721,17 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2594 stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2721 stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2595 while (1) 2722 while (1)
2596 { 2723 {
2724 enum syntaxcode c_code;
2597 if (from >= stop) 2725 if (from >= stop)
2598 goto lose; 2726 goto lose;
2599 UPDATE_SYNTAX_TABLE_FORWARD (from); 2727 UPDATE_SYNTAX_TABLE_FORWARD (from);
2600 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2728 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2729 c_code = syntax_multibyte (c, multibyte_symbol_p);
2601 if (code == Sstring 2730 if (code == Sstring
2602 ? (c == stringterm 2731 ? c == stringterm && c_code == Sstring
2603 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2732 : c_code == Sstring_fence)
2604 : SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring_fence)
2605 break; 2733 break;
2606 2734
2607 /* Some compilers can't handle this inside the switch. */
2608 c_code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2609 switch (c_code) 2735 switch (c_code)
2610 { 2736 {
2611 case Scharquote: 2737 case Scharquote:
@@ -2644,7 +2770,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2644 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2770 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2645 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2771 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2646 syntax= SYNTAX_WITH_FLAGS (c); 2772 syntax= SYNTAX_WITH_FLAGS (c);
2647 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2773 code = syntax_multibyte (c, multibyte_symbol_p);
2648 if (depth == min_depth) 2774 if (depth == min_depth)
2649 last_good = from; 2775 last_good = from;
2650 comstyle = 0; 2776 comstyle = 0;
@@ -2697,9 +2823,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2697 temp_pos--; 2823 temp_pos--;
2698 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2824 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2699 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2825 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2700 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2701 /* Don't allow comment-end to be quoted. */ 2826 /* Don't allow comment-end to be quoted. */
2702 if (temp_code == Sendcomment) 2827 if (syntax_multibyte (c1, multibyte_symbol_p) == Sendcomment)
2703 goto done2; 2828 goto done2;
2704 quoted = char_quoted (from - 1, temp_pos); 2829 quoted = char_quoted (from - 1, temp_pos);
2705 if (quoted) 2830 if (quoted)
@@ -2709,11 +2834,12 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2709 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2834 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2710 } 2835 }
2711 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2836 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2712 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); 2837 if (! quoted)
2713 if (! (quoted || temp_code == Sword 2838 switch (syntax_multibyte (c1, multibyte_symbol_p))
2714 || temp_code == Ssymbol 2839 {
2715 || temp_code == Squote)) 2840 case Sword: case Ssymbol: case Squote: break;
2716 goto done2; 2841 default: goto done2;
2842 }
2717 DEC_BOTH (from, from_byte); 2843 DEC_BOTH (from, from_byte);
2718 } 2844 }
2719 goto done2; 2845 goto done2;
@@ -2768,10 +2894,12 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2768 goto lose; 2894 goto lose;
2769 DEC_BOTH (from, from_byte); 2895 DEC_BOTH (from, from_byte);
2770 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2896 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2771 if (!char_quoted (from, from_byte) 2897 if (!char_quoted (from, from_byte))
2772 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), 2898 {
2773 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code)) 2899 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2774 break; 2900 if (syntax_multibyte (c, multibyte_symbol_p) == code)
2901 break;
2902 }
2775 } 2903 }
2776 if (code == Sstring_fence && !depth && sexpflag) goto done2; 2904 if (code == Sstring_fence && !depth && sexpflag) goto done2;
2777 break; 2905 break;
@@ -2784,11 +2912,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2784 goto lose; 2912 goto lose;
2785 DEC_BOTH (from, from_byte); 2913 DEC_BOTH (from, from_byte);
2786 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2914 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2787 if (!char_quoted (from, from_byte) 2915 if (!char_quoted (from, from_byte))
2788 && (stringterm 2916 {
2789 == (c = FETCH_CHAR_AS_MULTIBYTE (from_byte))) 2917 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2790 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2918 if (c == stringterm
2791 break; 2919 && (syntax_multibyte (c, multibyte_symbol_p)
2920 == Sstring))
2921 break;
2922 }
2792 } 2923 }
2793 if (!depth && sexpflag) goto done2; 2924 if (!depth && sexpflag) goto done2;
2794 break; 2925 break;
@@ -2894,7 +3025,7 @@ This includes chars with "quote" or "prefix" syntax (' or p). */)
2894 while (!char_quoted (pos, pos_byte) 3025 while (!char_quoted (pos, pos_byte)
2895 /* Previous statement updates syntax table. */ 3026 /* Previous statement updates syntax table. */
2896 && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote) 3027 && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote)
2897 || SYNTAX_PREFIX (c))) 3028 || syntax_prefix_flag_p (c)))
2898 { 3029 {
2899 opoint = pos; 3030 opoint = pos;
2900 opoint_byte = pos_byte; 3031 opoint_byte = pos_byte;
@@ -3117,10 +3248,8 @@ do { prev_from = from; \
3117 symstarted: 3248 symstarted:
3118 while (from < end) 3249 while (from < end)
3119 { 3250 {
3120 /* Some compilers can't handle this inside the switch. */
3121 int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); 3251 int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3122 enum syntaxcode symcharcode = SYNTAX (symchar); 3252 switch (SYNTAX (symchar))
3123 switch (symcharcode)
3124 { 3253 {
3125 case Scharquote: 3254 case Scharquote:
3126 case Sescape: 3255 case Sescape:
@@ -3206,7 +3335,6 @@ do { prev_from = from; \
3206 3335
3207 if (from >= end) goto done; 3336 if (from >= end) goto done;
3208 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 3337 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3209 /* Some compilers can't handle this inside the switch. */
3210 c_code = SYNTAX (c); 3338 c_code = SYNTAX (c);
3211 3339
3212 /* Check C_CODE here so that if the char has 3340 /* Check C_CODE here so that if the char has
diff --git a/src/syntax.h b/src/syntax.h
index 58d39b9059c..1b96284af42 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -18,6 +18,10 @@ GNU General Public License for more details.
18You should have received a copy of the GNU General Public License 18You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21INLINE_HEADER_BEGIN
22#ifndef SYNTAX_INLINE
23# define SYNTAX_INLINE INLINE
24#endif
21 25
22extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object); 26extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object);
23 27
@@ -54,79 +58,64 @@ enum syntaxcode
54 Smax /* Upper bound on codes that are meaningful */ 58 Smax /* Upper bound on codes that are meaningful */
55 }; 59 };
56 60
57/* Set the syntax entry VAL for char C in table TABLE. */
58
59#define SET_RAW_SYNTAX_ENTRY(table, c, val) \
60 CHAR_TABLE_SET ((table), c, (val))
61 61
62/* Set the syntax entry VAL for char-range RANGE in table TABLE. 62struct gl_state_s
63 RANGE is a cons (FROM . TO) specifying the range of characters. */ 63{
64 Lisp_Object object; /* The object we are scanning. */
65 ptrdiff_t start; /* Where to stop. */
66 ptrdiff_t stop; /* Where to stop. */
67 bool use_global; /* Whether to use global_code
68 or c_s_t. */
69 Lisp_Object global_code; /* Syntax code of current char. */
70 Lisp_Object current_syntax_table; /* Syntax table for current pos. */
71 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
72 ptrdiff_t b_property; /* First index where c_s_t is valid. */
73 ptrdiff_t e_property; /* First index where c_s_t is
74 not valid. */
75 INTERVAL forward_i; /* Where to start lookup on forward */
76 INTERVAL backward_i; /* or backward movement. The
77 data in c_s_t is valid
78 between these intervals,
79 and possibly at the
80 intervals too, depending
81 on: */
82 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
83 ptrdiff_t offset;
84};
64 85
65#define SET_RAW_SYNTAX_ENTRY_RANGE(table, range, val) \ 86extern struct gl_state_s gl_state;
66 Fset_char_table_range ((table), (range), (val))
67 87
68/* SYNTAX_ENTRY fetches the information from the entry for character C 88/* Fetch the information from the entry for character C
69 in syntax table TABLE, or from globally kept data (gl_state). 89 in syntax table TABLE, or from globally kept data (gl_state).
70 Does inheritance. */ 90 Does inheritance. */
71/* CURRENT_SYNTAX_TABLE gives the syntax table valid for current
72 position, it is either the buffer's syntax table, or syntax table
73 found in text properties. */
74 91
92SYNTAX_INLINE Lisp_Object
93SYNTAX_ENTRY (int c)
94{
75#ifdef SYNTAX_ENTRY_VIA_PROPERTY 95#ifdef SYNTAX_ENTRY_VIA_PROPERTY
76# define SYNTAX_ENTRY(c) \ 96 return (gl_state.use_global
77 (gl_state.use_global ? gl_state.global_code : SYNTAX_ENTRY_INT (c)) 97 ? gl_state.global_code
78# define CURRENT_SYNTAX_TABLE gl_state.current_syntax_table 98 : CHAR_TABLE_REF (gl_state.current_syntax_table, c));
79#else 99#else
80# define SYNTAX_ENTRY SYNTAX_ENTRY_INT 100 return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c);
81# define CURRENT_SYNTAX_TABLE BVAR (current_buffer, syntax_table)
82#endif 101#endif
83 102}
84#define SYNTAX_ENTRY_INT(c) CHAR_TABLE_REF (CURRENT_SYNTAX_TABLE, (c))
85 103
86/* Extract the information from the entry for character C 104/* Extract the information from the entry for character C
87 in the current syntax table. */ 105 in the current syntax table. */
88 106
89#ifdef __GNUC__ 107SYNTAX_INLINE int
90#define SYNTAX(c) \ 108SYNTAX_WITH_FLAGS (int c)
91 ({ Lisp_Object _syntax_temp; \ 109{
92 _syntax_temp = SYNTAX_ENTRY (c); \ 110 Lisp_Object ent = SYNTAX_ENTRY (c);
93 (CONSP (_syntax_temp) \ 111 return CONSP (ent) ? XINT (XCAR (ent)) : Swhitespace;
94 ? (enum syntaxcode) (XINT (XCAR (_syntax_temp)) & 0xff) \ 112}
95 : Swhitespace); }) 113
96 114SYNTAX_INLINE enum syntaxcode
97#define SYNTAX_WITH_FLAGS(c) \ 115SYNTAX (int c)
98 ({ Lisp_Object _syntax_temp; \ 116{
99 _syntax_temp = SYNTAX_ENTRY (c); \ 117 return SYNTAX_WITH_FLAGS (c) & 0xff;
100 (CONSP (_syntax_temp) \ 118}
101 ? XINT (XCAR (_syntax_temp)) \
102 : Swhitespace); })
103
104#define SYNTAX_MATCH(c) \
105 ({ Lisp_Object _syntax_temp; \
106 _syntax_temp = SYNTAX_ENTRY (c); \
107 (CONSP (_syntax_temp) \
108 ? XCDR (_syntax_temp) \
109 : Qnil); })
110#else
111extern Lisp_Object syntax_temp;
112#define SYNTAX(c) \
113 (syntax_temp = SYNTAX_ENTRY ((c)), \
114 (CONSP (syntax_temp) \
115 ? (enum syntaxcode) (XINT (XCAR (syntax_temp)) & 0xff) \
116 : Swhitespace))
117
118#define SYNTAX_WITH_FLAGS(c) \
119 (syntax_temp = SYNTAX_ENTRY ((c)), \
120 (CONSP (syntax_temp) \
121 ? XINT (XCAR (syntax_temp)) \
122 : Swhitespace))
123
124#define SYNTAX_MATCH(c) \
125 (syntax_temp = SYNTAX_ENTRY ((c)), \
126 (CONSP (syntax_temp) \
127 ? XCDR (syntax_temp) \
128 : Qnil))
129#endif
130 119
131 120
132/* Whether the syntax of the character C has the prefix flag set. */ 121/* Whether the syntax of the character C has the prefix flag set. */
@@ -145,158 +134,65 @@ extern char const syntax_code_spec[16];
145/* Convert the byte offset BYTEPOS into a character position, 134/* Convert the byte offset BYTEPOS into a character position,
146 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. 135 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT.
147 136
148 The value is meant for use in the UPDATE_SYNTAX_TABLE... macros. 137 The value is meant for use in code that does nothing when
149 These macros do nothing when parse_sexp_lookup_properties is 0, 138 parse_sexp_lookup_properties is 0, so return 0 in that case, for speed. */
150 so we return 0 in that case, for speed. */ 139
151 140SYNTAX_INLINE ptrdiff_t
152#define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \ 141SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos)
153 (! parse_sexp_lookup_properties \ 142{
154 ? 0 \ 143 return (! parse_sexp_lookup_properties
155 : STRINGP (gl_state.object) \ 144 ? 0
156 ? string_byte_to_char (gl_state.object, (bytepos)) \ 145 : STRINGP (gl_state.object)
157 : BUFFERP (gl_state.object) \ 146 ? string_byte_to_char (gl_state.object, bytepos)
158 ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), \ 147 : BUFFERP (gl_state.object)
159 (bytepos) + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1) - BUF_BEGV (XBUFFER (gl_state.object)) + 1 \ 148 ? ((buf_bytepos_to_charpos
160 : NILP (gl_state.object) \ 149 (XBUFFER (gl_state.object),
161 ? BYTE_TO_CHAR ((bytepos) + BEGV_BYTE - 1) - BEGV + 1 \ 150 (bytepos + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1)))
162 : (bytepos)) 151 - BUF_BEGV (XBUFFER (gl_state.object)) + 1)
152 : NILP (gl_state.object)
153 ? BYTE_TO_CHAR (bytepos + BEGV_BYTE - 1) - BEGV + 1
154 : bytepos);
155}
163 156
164/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 157/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
165 currently good for a position before CHARPOS. */ 158 currently good for a position before CHARPOS. */
166 159
167#define UPDATE_SYNTAX_TABLE_FORWARD(charpos) \ 160SYNTAX_INLINE void
168 (parse_sexp_lookup_properties \ 161UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
169 && (charpos) >= gl_state.e_property \ 162{
170 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0, \ 163 if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
171 gl_state.object), \ 164 update_syntax_table (charpos + gl_state.offset, 1, 0, gl_state.object);
172 1) \ 165}
173 : 0)
174 166
175/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 167/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
176 currently good for a position after CHARPOS. */ 168 currently good for a position after CHARPOS. */
177 169
178#define UPDATE_SYNTAX_TABLE_BACKWARD(charpos) \ 170SYNTAX_INLINE void
179 (parse_sexp_lookup_properties \ 171UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos)
180 && (charpos) < gl_state.b_property \ 172{
181 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ 173 if (parse_sexp_lookup_properties && charpos < gl_state.b_property)
182 gl_state.object), \ 174 update_syntax_table (charpos + gl_state.offset, -1, 0, gl_state.object);
183 1) \ 175}
184 : 0)
185 176
186/* Make syntax table good for CHARPOS. */ 177/* Make syntax table good for CHARPOS. */
187 178
188#define UPDATE_SYNTAX_TABLE(charpos) \ 179SYNTAX_INLINE void
189 (parse_sexp_lookup_properties \ 180UPDATE_SYNTAX_TABLE (ptrdiff_t charpos)
190 && (charpos) < gl_state.b_property \ 181{
191 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ 182 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
192 gl_state.object), \ 183 UPDATE_SYNTAX_TABLE_FORWARD (charpos);
193 1) \ 184}
194 : (parse_sexp_lookup_properties \ 185
195 && (charpos) >= gl_state.e_property \ 186/* Set up the buffer-global syntax table. */
196 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0,\
197 gl_state.object), \
198 1) \
199 : 0))
200
201/* This macro sets up the buffer-global syntax table. */
202#define SETUP_BUFFER_SYNTAX_TABLE() \
203do \
204 { \
205 gl_state.use_global = 0; \
206 gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);\
207 } while (0)
208
209/* This macro should be called with FROM at the start of forward
210 search, or after the last position of the backward search. It
211 makes sure that the first char is picked up with correct table, so
212 one does not need to call UPDATE_SYNTAX_TABLE immediately after the
213 call.
214 Sign of COUNT gives the direction of the search.
215 */
216
217#define SETUP_SYNTAX_TABLE(FROM, COUNT) \
218do \
219 { \
220 SETUP_BUFFER_SYNTAX_TABLE (); \
221 gl_state.b_property = BEGV; \
222 gl_state.e_property = ZV + 1; \
223 gl_state.object = Qnil; \
224 gl_state.offset = 0; \
225 if (parse_sexp_lookup_properties) \
226 if ((COUNT) > 0 || (FROM) > BEGV) \
227 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
228 1, Qnil); \
229 } \
230while (0)
231
232/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
233 If it is t (which is only used in fast_c_string_match_ignore_case),
234 ignore properties altogether.
235
236 This is meant for regex.c to use. For buffers, regex.c passes arguments
237 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV.
238 So if it is a buffer, we set the offset field to BEGV. */
239
240#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \
241do \
242 { \
243 SETUP_BUFFER_SYNTAX_TABLE (); \
244 gl_state.object = (OBJECT); \
245 if (BUFFERP (gl_state.object)) \
246 { \
247 struct buffer *buf = XBUFFER (gl_state.object); \
248 gl_state.b_property = 1; \
249 gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1; \
250 gl_state.offset = BUF_BEGV (buf) - 1; \
251 } \
252 else if (NILP (gl_state.object)) \
253 { \
254 gl_state.b_property = 1; \
255 gl_state.e_property = ZV - BEGV + 1; \
256 gl_state.offset = BEGV - 1; \
257 } \
258 else if (EQ (gl_state.object, Qt)) \
259 { \
260 gl_state.b_property = 0; \
261 gl_state.e_property = PTRDIFF_MAX; \
262 gl_state.offset = 0; \
263 } \
264 else \
265 { \
266 gl_state.b_property = 0; \
267 gl_state.e_property = 1 + SCHARS (gl_state.object); \
268 gl_state.offset = 0; \
269 } \
270 if (parse_sexp_lookup_properties) \
271 update_syntax_table (((FROM) + gl_state.offset \
272 + (COUNT > 0 ? 0 : -1)), \
273 COUNT, 1, gl_state.object); \
274 } \
275while (0)
276 187
277struct gl_state_s 188SYNTAX_INLINE void
189SETUP_BUFFER_SYNTAX_TABLE (void)
278{ 190{
279 Lisp_Object object; /* The object we are scanning. */ 191 gl_state.use_global = 0;
280 ptrdiff_t start; /* Where to stop. */ 192 gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
281 ptrdiff_t stop; /* Where to stop. */ 193}
282 int use_global; /* Whether to use global_code
283 or c_s_t. */
284 Lisp_Object global_code; /* Syntax code of current char. */
285 Lisp_Object current_syntax_table; /* Syntax table for current pos. */
286 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
287 ptrdiff_t b_property; /* First index where c_s_t is valid. */
288 ptrdiff_t e_property; /* First index where c_s_t is
289 not valid. */
290 INTERVAL forward_i; /* Where to start lookup on forward */
291 INTERVAL backward_i; /* or backward movement. The
292 data in c_s_t is valid
293 between these intervals,
294 and possibly at the
295 intervals too, depending
296 on: */
297 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
298 ptrdiff_t offset;
299};
300 194
301extern struct gl_state_s gl_state;
302extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT); 195extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
196extern void SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t, ptrdiff_t);
197
198INLINE_HEADER_END
diff --git a/src/sysdep.c b/src/sysdep.c
index 212ceef64b9..f614d8bc557 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -22,7 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#define SYSTIME_INLINE EXTERN_INLINE 22#define SYSTIME_INLINE EXTERN_INLINE
23 23
24#include <execinfo.h> 24#include <execinfo.h>
25#include <stdio.h> 25#include "sysstdio.h"
26#ifdef HAVE_PWD_H 26#ifdef HAVE_PWD_H
27#include <pwd.h> 27#include <pwd.h>
28#include <grp.h> 28#include <grp.h>
@@ -31,7 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <unistd.h> 31#include <unistd.h>
32 32
33#include <c-ctype.h> 33#include <c-ctype.h>
34#include <ignore-value.h>
35#include <utimens.h> 34#include <utimens.h>
36 35
37#include "lisp.h" 36#include "lisp.h"
@@ -103,8 +102,8 @@ int _cdecl _getpid (void);
103#include "syssignal.h" 102#include "syssignal.h"
104#include "systime.h" 103#include "systime.h"
105 104
106static int emacs_get_tty (int, struct emacs_tty *); 105static void emacs_get_tty (int, struct emacs_tty *);
107static int emacs_set_tty (int, struct emacs_tty *, int); 106static int emacs_set_tty (int, struct emacs_tty *, bool);
108 107
109/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ 108/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
110#ifndef ULLONG_MAX 109#ifndef ULLONG_MAX
@@ -538,13 +537,11 @@ sys_subshell (void)
538 if (str && chdir ((char *) str) != 0) 537 if (str && chdir ((char *) str) != 0)
539 { 538 {
540#ifndef DOS_NT 539#ifndef DOS_NT
541 ignore_value (write (1, "Can't chdir\n", 12)); 540 emacs_perror ((char *) str);
542 _exit (1); 541 _exit (EXIT_CANCELED);
543#endif 542#endif
544 } 543 }
545 544
546 close_process_descs (); /* Close Emacs's pipes/ptys */
547
548#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 545#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */
549 { 546 {
550 char *epwd = getenv ("PWD"); 547 char *epwd = getenv ("PWD");
@@ -572,8 +569,8 @@ sys_subshell (void)
572 write (1, "Can't execute subshell", 22); 569 write (1, "Can't execute subshell", 22);
573#else /* not WINDOWSNT */ 570#else /* not WINDOWSNT */
574 execlp (sh, sh, (char *) 0); 571 execlp (sh, sh, (char *) 0);
575 ignore_value (write (1, "Can't execute subshell", 22)); 572 emacs_perror (sh);
576 _exit (1); 573 _exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
577#endif /* not WINDOWSNT */ 574#endif /* not WINDOWSNT */
578#endif /* not MSDOS */ 575#endif /* not MSDOS */
579 } 576 }
@@ -772,31 +769,26 @@ widen_foreground_group (int fd)
772 769
773/* Getting and setting emacs_tty structures. */ 770/* Getting and setting emacs_tty structures. */
774 771
775/* Set *TC to the parameters associated with the terminal FD. 772/* Set *TC to the parameters associated with the terminal FD,
776 Return zero if all's well, or -1 if we ran into an error we 773 or clear it if the parameters are not available. */
777 couldn't deal with. */ 774static void
778int
779emacs_get_tty (int fd, struct emacs_tty *settings) 775emacs_get_tty (int fd, struct emacs_tty *settings)
780{ 776{
781 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ 777 /* Retrieve the primary parameters - baud rate, character size, etcetera. */
782#ifndef DOS_NT 778#ifndef DOS_NT
783 /* We have those nifty POSIX tcmumbleattr functions. */ 779 /* We have those nifty POSIX tcmumbleattr functions. */
784 memset (&settings->main, 0, sizeof (settings->main)); 780 memset (&settings->main, 0, sizeof (settings->main));
785 if (tcgetattr (fd, &settings->main) < 0) 781 tcgetattr (fd, &settings->main);
786 return -1;
787#endif 782#endif
788
789 /* We have survived the tempest. */
790 return 0;
791} 783}
792 784
793 785
794/* Set the parameters of the tty on FD according to the contents of 786/* Set the parameters of the tty on FD according to the contents of
795 *SETTINGS. If FLUSHP is non-zero, we discard input. 787 *SETTINGS. If FLUSHP, discard input.
796 Return 0 if all went well, and -1 if anything failed. */ 788 Return 0 if all went well, and -1 (setting errno) if anything failed. */
797 789
798int 790static int
799emacs_set_tty (int fd, struct emacs_tty *settings, int flushp) 791emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
800{ 792{
801 /* Set the primary parameters - baud rate, character size, etcetera. */ 793 /* Set the primary parameters - baud rate, character size, etcetera. */
802#ifndef DOS_NT 794#ifndef DOS_NT
@@ -1121,10 +1113,10 @@ init_sys_modes (struct tty_display_info *tty_out)
1121 tty_out->term_initted = 1; 1113 tty_out->term_initted = 1;
1122} 1114}
1123 1115
1124/* Return nonzero if safe to use tabs in output. 1116/* Return true if safe to use tabs in output.
1125 At the time this is called, init_sys_modes has not been done yet. */ 1117 At the time this is called, init_sys_modes has not been done yet. */
1126 1118
1127int 1119bool
1128tabs_safe_p (int fd) 1120tabs_safe_p (int fd)
1129{ 1121{
1130 struct emacs_tty etty; 1122 struct emacs_tty etty;
@@ -1378,8 +1370,10 @@ init_system_name (void)
1378 uname (&uts); 1370 uname (&uts);
1379 Vsystem_name = build_string (uts.nodename); 1371 Vsystem_name = build_string (uts.nodename);
1380#else /* HAVE_GETHOSTNAME */ 1372#else /* HAVE_GETHOSTNAME */
1381 unsigned int hostname_size = 256; 1373 char *hostname_alloc = NULL;
1382 char *hostname = alloca (hostname_size); 1374 char hostname_buf[256];
1375 ptrdiff_t hostname_size = sizeof hostname_buf;
1376 char *hostname = hostname_buf;
1383 1377
1384 /* Try to get the host name; if the buffer is too short, try 1378 /* Try to get the host name; if the buffer is too short, try
1385 again. Apparently, the only indication gethostname gives of 1379 again. Apparently, the only indication gethostname gives of
@@ -1394,8 +1388,8 @@ init_system_name (void)
1394 if (strlen (hostname) < hostname_size - 1) 1388 if (strlen (hostname) < hostname_size - 1)
1395 break; 1389 break;
1396 1390
1397 hostname_size <<= 1; 1391 hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1,
1398 hostname = alloca (hostname_size); 1392 min (PTRDIFF_MAX, SIZE_MAX), 1);
1399 } 1393 }
1400#ifdef HAVE_SOCKETS 1394#ifdef HAVE_SOCKETS
1401 /* Turn the hostname into the official, fully-qualified hostname. 1395 /* Turn the hostname into the official, fully-qualified hostname.
@@ -1440,7 +1434,13 @@ init_system_name (void)
1440 } 1434 }
1441 if (it) 1435 if (it)
1442 { 1436 {
1443 hostname = alloca (strlen (it->ai_canonname) + 1); 1437 ptrdiff_t len = strlen (it->ai_canonname);
1438 if (hostname_size <= len)
1439 {
1440 hostname_size = len + 1;
1441 hostname = hostname_alloc = xrealloc (hostname_alloc,
1442 hostname_size);
1443 }
1444 strcpy (hostname, it->ai_canonname); 1444 strcpy (hostname, it->ai_canonname);
1445 } 1445 }
1446 freeaddrinfo (res); 1446 freeaddrinfo (res);
@@ -1487,10 +1487,11 @@ init_system_name (void)
1487 } 1487 }
1488#endif /* HAVE_SOCKETS */ 1488#endif /* HAVE_SOCKETS */
1489 Vsystem_name = build_string (hostname); 1489 Vsystem_name = build_string (hostname);
1490 xfree (hostname_alloc);
1490#endif /* HAVE_GETHOSTNAME */ 1491#endif /* HAVE_GETHOSTNAME */
1491 { 1492 {
1492 unsigned char *p; 1493 char *p;
1493 for (p = SDATA (Vsystem_name); *p; p++) 1494 for (p = SSDATA (Vsystem_name); *p; p++)
1494 if (*p == ' ' || *p == '\t') 1495 if (*p == ' ' || *p == '\t')
1495 *p = '-'; 1496 *p = '-';
1496 } 1497 }
@@ -1630,7 +1631,7 @@ deliver_thread_signal (int sig, signal_handler_t handler)
1630# undef sys_siglist 1631# undef sys_siglist
1631# ifdef _sys_siglist 1632# ifdef _sys_siglist
1632# define sys_siglist _sys_siglist 1633# define sys_siglist _sys_siglist
1633# elif defined HAVE_DECL___SYS_SIGLIST 1634# elif HAVE_DECL___SYS_SIGLIST
1634# define sys_siglist __sys_siglist 1635# define sys_siglist __sys_siglist
1635# else 1636# else
1636# define sys_siglist my_sys_siglist 1637# define sys_siglist my_sys_siglist
@@ -2136,10 +2137,10 @@ emacs_backtrace (int backtrace_limit)
2136 2137
2137 if (npointers) 2138 if (npointers)
2138 { 2139 {
2139 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12)); 2140 emacs_write (STDERR_FILENO, "\nBacktrace:\n", 12);
2140 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); 2141 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
2141 if (bounded_limit < npointers) 2142 if (bounded_limit < npointers)
2142 ignore_value (write (STDERR_FILENO, "...\n", 4)); 2143 emacs_write (STDERR_FILENO, "...\n", 4);
2143 } 2144 }
2144} 2145}
2145 2146
@@ -2151,34 +2152,108 @@ emacs_abort (void)
2151} 2152}
2152#endif 2153#endif
2153 2154
2155/* Open FILE for Emacs use, using open flags OFLAG and mode MODE.
2156 Arrange for subprograms to not inherit the file descriptor.
2157 Prefer a method that is multithread-safe, if available.
2158 Do not fail merely because the open was interrupted by a signal.
2159 Allow the user to quit. */
2160
2154int 2161int
2155emacs_open (const char *path, int oflag, int mode) 2162emacs_open (const char *file, int oflags, int mode)
2156{ 2163{
2157 register int rtnval; 2164 int fd;
2158 2165 oflags |= O_CLOEXEC;
2159 while ((rtnval = open (path, oflag, mode)) == -1 2166 while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR)
2160 && (errno == EINTR))
2161 QUIT; 2167 QUIT;
2162 return (rtnval); 2168 if (! O_CLOEXEC && 0 <= fd)
2169 fcntl (fd, F_SETFD, FD_CLOEXEC);
2170 return fd;
2163} 2171}
2164 2172
2165int 2173/* Open FILE as a stream for Emacs use, with mode MODE.
2166emacs_close (int fd) 2174 Act like emacs_open with respect to threads, signals, and quits. */
2175
2176FILE *
2177emacs_fopen (char const *file, char const *mode)
2167{ 2178{
2168 int did_retry = 0; 2179 int fd, omode, oflags;
2169 register int rtnval; 2180 int bflag = 0;
2181 char const *m = mode;
2170 2182
2171 while ((rtnval = close (fd)) == -1 2183 switch (*m++)
2172 && (errno == EINTR)) 2184 {
2173 did_retry = 1; 2185 case 'r': omode = O_RDONLY; oflags = 0; break;
2186 case 'w': omode = O_WRONLY; oflags = O_CREAT | O_TRUNC; break;
2187 case 'a': omode = O_WRONLY; oflags = O_CREAT | O_APPEND; break;
2188 default: emacs_abort ();
2189 }
2174 2190
2175 /* If close is interrupted SunOS 4.1 may or may not have closed the 2191 while (*m)
2176 file descriptor. If it did the second close will fail with 2192 switch (*m++)
2177 errno = EBADF. That means we have succeeded. */ 2193 {
2178 if (rtnval == -1 && did_retry && errno == EBADF) 2194 case '+': omode = O_RDWR; break;
2179 return 0; 2195 case 'b': bflag = O_BINARY; break;
2196 case 't': bflag = O_TEXT; break;
2197 default: /* Ignore. */ break;
2198 }
2199
2200 fd = emacs_open (file, omode | oflags | bflag, 0666);
2201 return fd < 0 ? 0 : fdopen (fd, mode);
2202}
2203
2204/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
2205 For the background behind this mess, please see Austin Group defect 529
2206 <http://austingroupbugs.net/view.php?id=529>. */
2207
2208#ifndef POSIX_CLOSE_RESTART
2209# define POSIX_CLOSE_RESTART 1
2210static int
2211posix_close (int fd, int flag)
2212{
2213 /* Only the POSIX_CLOSE_RESTART case is emulated. */
2214 eassert (flag == POSIX_CLOSE_RESTART);
2180 2215
2181 return rtnval; 2216 /* Things are tricky if close (fd) returns -1 with errno == EINTR
2217 on a system that does not define POSIX_CLOSE_RESTART.
2218
2219 In this case, in some systems (e.g., GNU/Linux, AIX) FD is
2220 closed, and retrying the close could inadvertently close a file
2221 descriptor allocated by some other thread. In other systems
2222 (e.g., HP/UX) FD is not closed. And in still other systems
2223 (e.g., OS X, Solaris), maybe FD is closed, maybe not, and in a
2224 multithreaded program there can be no way to tell.
2225
2226 So, in this case, pretend that the close succeeded. This works
2227 well on systems like GNU/Linux that close FD. Although it may
2228 leak a file descriptor on other systems, the leak is unlikely and
2229 it's better to leak than to close a random victim. */
2230 return close (fd) == 0 || errno == EINTR ? 0 : -1;
2231}
2232#endif
2233
2234/* Close FD, retrying if interrupted. If successful, return 0;
2235 otherwise, return -1 and set errno to a non-EINTR value. Consider
2236 an EINPROGRESS error to be successful, as that's merely a signal
2237 arriving. FD is always closed when this function returns, even
2238 when it returns -1.
2239
2240 Do not call this function if FD is nonnegative and might already be closed,
2241 as that might close an innocent victim opened by some other thread. */
2242
2243int
2244emacs_close (int fd)
2245{
2246 while (1)
2247 {
2248 int r = posix_close (fd, POSIX_CLOSE_RESTART);
2249 if (r == 0)
2250 return r;
2251 if (!POSIX_CLOSE_RESTART || errno != EINTR)
2252 {
2253 eassert (errno != EBADF || fd < 0);
2254 return errno == EINPROGRESS ? 0 : r;
2255 }
2256 }
2182} 2257}
2183 2258
2184/* Maximum number of bytes to read or write in a single system call. 2259/* Maximum number of bytes to read or write in a single system call.
@@ -2210,27 +2285,26 @@ emacs_read (int fildes, char *buf, ptrdiff_t nbyte)
2210} 2285}
2211 2286
2212/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted 2287/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted
2213 or if a partial write occurs. Return the number of bytes written, setting 2288 or if a partial write occurs. If interrupted, process pending
2289 signals if PROCESS SIGNALS. Return the number of bytes written, setting
2214 errno if this is less than NBYTE. */ 2290 errno if this is less than NBYTE. */
2215ptrdiff_t 2291static ptrdiff_t
2216emacs_write (int fildes, const char *buf, ptrdiff_t nbyte) 2292emacs_full_write (int fildes, char const *buf, ptrdiff_t nbyte,
2293 bool process_signals)
2217{ 2294{
2218 ssize_t rtnval; 2295 ptrdiff_t bytes_written = 0;
2219 ptrdiff_t bytes_written;
2220
2221 bytes_written = 0;
2222 2296
2223 while (nbyte > 0) 2297 while (nbyte > 0)
2224 { 2298 {
2225 rtnval = write (fildes, buf, min (nbyte, MAX_RW_COUNT)); 2299 ssize_t n = write (fildes, buf, min (nbyte, MAX_RW_COUNT));
2226 2300
2227 if (rtnval < 0) 2301 if (n < 0)
2228 { 2302 {
2229 if (errno == EINTR) 2303 if (errno == EINTR)
2230 { 2304 {
2231 /* I originally used `QUIT' but that might causes files to 2305 /* I originally used `QUIT' but that might causes files to
2232 be truncated if you hit C-g in the middle of it. --Stef */ 2306 be truncated if you hit C-g in the middle of it. --Stef */
2233 if (pending_signals) 2307 if (process_signals && pending_signals)
2234 process_pending_signals (); 2308 process_pending_signals ();
2235 continue; 2309 continue;
2236 } 2310 }
@@ -2238,12 +2312,57 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte)
2238 break; 2312 break;
2239 } 2313 }
2240 2314
2241 buf += rtnval; 2315 buf += n;
2242 nbyte -= rtnval; 2316 nbyte -= n;
2243 bytes_written += rtnval; 2317 bytes_written += n;
2244 } 2318 }
2245 2319
2246 return (bytes_written); 2320 return bytes_written;
2321}
2322
2323/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if
2324 interrupted or if a partial write occurs. Return the number of
2325 bytes written, setting errno if this is less than NBYTE. */
2326ptrdiff_t
2327emacs_write (int fildes, char const *buf, ptrdiff_t nbyte)
2328{
2329 return emacs_full_write (fildes, buf, nbyte, 0);
2330}
2331
2332/* Like emacs_write, but also process pending signals if interrupted. */
2333ptrdiff_t
2334emacs_write_sig (int fildes, char const *buf, ptrdiff_t nbyte)
2335{
2336 return emacs_full_write (fildes, buf, nbyte, 1);
2337}
2338
2339/* Write a diagnostic to standard error that contains MESSAGE and a
2340 string derived from errno. Preserve errno. Do not buffer stderr.
2341 Do not process pending signals if interrupted. */
2342void
2343emacs_perror (char const *message)
2344{
2345 int err = errno;
2346 char const *error_string = strerror (err);
2347 char const *command = (initial_argv && initial_argv[0]
2348 ? initial_argv[0] : "emacs");
2349 /* Write it out all at once, if it's short; this is less likely to
2350 be interleaved with other output. */
2351 char buf[BUFSIZ];
2352 int nbytes = snprintf (buf, sizeof buf, "%s: %s: %s\n",
2353 command, message, error_string);
2354 if (0 <= nbytes && nbytes < BUFSIZ)
2355 emacs_write (STDERR_FILENO, buf, nbytes);
2356 else
2357 {
2358 emacs_write (STDERR_FILENO, command, strlen (command));
2359 emacs_write (STDERR_FILENO, ": ", 2);
2360 emacs_write (STDERR_FILENO, message, strlen (message));
2361 emacs_write (STDERR_FILENO, ": ", 2);
2362 emacs_write (STDERR_FILENO, error_string, strlen (error_string));
2363 emacs_write (STDERR_FILENO, "\n", 1);
2364 }
2365 errno = err;
2247} 2366}
2248 2367
2249/* Return a struct timeval that is roughly equivalent to T. 2368/* Return a struct timeval that is roughly equivalent to T.
@@ -2597,7 +2716,7 @@ list_system_processes (void)
2597 2716
2598#endif /* !defined (WINDOWSNT) */ 2717#endif /* !defined (WINDOWSNT) */
2599 2718
2600#ifdef GNU_LINUX 2719#if defined GNU_LINUX && defined HAVE_LONG_LONG_INT
2601static EMACS_TIME 2720static EMACS_TIME
2602time_from_jiffies (unsigned long long tval, long hz) 2721time_from_jiffies (unsigned long long tval, long hz)
2603{ 2722{
@@ -2637,7 +2756,7 @@ get_up_time (void)
2637 EMACS_TIME up = make_emacs_time (0, 0); 2756 EMACS_TIME up = make_emacs_time (0, 0);
2638 2757
2639 block_input (); 2758 block_input ();
2640 fup = fopen ("/proc/uptime", "r"); 2759 fup = emacs_fopen ("/proc/uptime", "r");
2641 2760
2642 if (fup) 2761 if (fup)
2643 { 2762 {
@@ -2682,7 +2801,7 @@ procfs_ttyname (int rdev)
2682 char name[PATH_MAX]; 2801 char name[PATH_MAX];
2683 2802
2684 block_input (); 2803 block_input ();
2685 fdev = fopen ("/proc/tty/drivers", "r"); 2804 fdev = emacs_fopen ("/proc/tty/drivers", "r");
2686 2805
2687 if (fdev) 2806 if (fdev)
2688 { 2807 {
@@ -2724,7 +2843,7 @@ procfs_get_total_memory (void)
2724 unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */ 2843 unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */
2725 2844
2726 block_input (); 2845 block_input ();
2727 fmem = fopen ("/proc/meminfo", "r"); 2846 fmem = emacs_fopen ("/proc/meminfo", "r");
2728 2847
2729 if (fmem) 2848 if (fmem)
2730 { 2849 {
diff --git a/src/sysstdio.h b/src/sysstdio.h
new file mode 100644
index 00000000000..e9dfb696059
--- /dev/null
+++ b/src/sysstdio.h
@@ -0,0 +1,2 @@
1#include <stdio.h>
2extern FILE *emacs_fopen (char const *, char const *);
diff --git a/src/systime.h b/src/systime.h
index c3bc00c1479..df733b290c3 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -67,7 +67,9 @@ SYSTIME_INLINE time_t *emacs_secs_addr (EMACS_TIME *t) { return &t->tv_sec; }
67SYSTIME_INLINE EMACS_TIME 67SYSTIME_INLINE EMACS_TIME
68make_emacs_time (time_t s, int ns) 68make_emacs_time (time_t s, int ns)
69{ 69{
70 EMACS_TIME r = { s, ns }; 70 EMACS_TIME r;
71 r.tv_sec = s;
72 r.tv_nsec = ns;
71 return r; 73 return r;
72} 74}
73 75
@@ -75,7 +77,9 @@ make_emacs_time (time_t s, int ns)
75SYSTIME_INLINE EMACS_TIME 77SYSTIME_INLINE EMACS_TIME
76invalid_emacs_time (void) 78invalid_emacs_time (void)
77{ 79{
78 EMACS_TIME r = { 0, -1 }; 80 EMACS_TIME r;
81 r.tv_sec = 0;
82 r.tv_nsec = -1;
79 return r; 83 return r;
80} 84}
81 85
@@ -166,21 +170,6 @@ EMACS_TIME_EQ (EMACS_TIME t1, EMACS_TIME t2)
166 return timespec_cmp (t1, t2) == 0; 170 return timespec_cmp (t1, t2) == 0;
167} 171}
168SYSTIME_INLINE int 172SYSTIME_INLINE int
169EMACS_TIME_NE (EMACS_TIME t1, EMACS_TIME t2)
170{
171 return timespec_cmp (t1, t2) != 0;
172}
173SYSTIME_INLINE int
174EMACS_TIME_GT (EMACS_TIME t1, EMACS_TIME t2)
175{
176 return timespec_cmp (t1, t2) > 0;
177}
178SYSTIME_INLINE int
179EMACS_TIME_GE (EMACS_TIME t1, EMACS_TIME t2)
180{
181 return timespec_cmp (t1, t2) >= 0;
182}
183SYSTIME_INLINE int
184EMACS_TIME_LT (EMACS_TIME t1, EMACS_TIME t2) 173EMACS_TIME_LT (EMACS_TIME t1, EMACS_TIME t2)
185{ 174{
186 return timespec_cmp (t1, t2) < 0; 175 return timespec_cmp (t1, t2) < 0;
diff --git a/src/term.c b/src/term.c
index 0bcef55947a..b6878a0abd1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -71,13 +71,13 @@ static void tty_turn_off_highlight (struct tty_display_info *);
71static void tty_show_cursor (struct tty_display_info *); 71static void tty_show_cursor (struct tty_display_info *);
72static void tty_hide_cursor (struct tty_display_info *); 72static void tty_hide_cursor (struct tty_display_info *);
73static void tty_background_highlight (struct tty_display_info *tty); 73static void tty_background_highlight (struct tty_display_info *tty);
74static struct terminal *get_tty_terminal (Lisp_Object, int); 74static struct terminal *get_tty_terminal (Lisp_Object, bool);
75static void clear_tty_hooks (struct terminal *terminal); 75static void clear_tty_hooks (struct terminal *terminal);
76static void set_tty_hooks (struct terminal *terminal); 76static void set_tty_hooks (struct terminal *terminal);
77static void dissociate_if_controlling_tty (int fd); 77static void dissociate_if_controlling_tty (int fd);
78static void delete_tty (struct terminal *); 78static void delete_tty (struct terminal *);
79static _Noreturn void maybe_fatal (int must_succeed, struct terminal *terminal, 79static _Noreturn void maybe_fatal (bool, struct terminal *,
80 const char *str1, const char *str2, ...) 80 const char *, const char *, ...)
81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); 81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
82static _Noreturn void vfatal (const char *str, va_list ap) 82static _Noreturn void vfatal (const char *str, va_list ap)
83 ATTRIBUTE_FORMAT_PRINTF (1, 0); 83 ATTRIBUTE_FORMAT_PRINTF (1, 0);
@@ -85,8 +85,7 @@ static _Noreturn void vfatal (const char *str, va_list ap)
85 85
86#define OUTPUT(tty, a) \ 86#define OUTPUT(tty, a) \
87 emacs_tputs ((tty), a, \ 87 emacs_tputs ((tty), a, \
88 (int) (FRAME_LINES (XFRAME (selected_frame)) \ 88 FRAME_LINES (XFRAME (selected_frame)) - curY (tty), \
89 - curY (tty)), \
90 cmputc) 89 cmputc)
91 90
92#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) 91#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
@@ -695,7 +694,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
695{ 694{
696 unsigned char *conversion_buffer; 695 unsigned char *conversion_buffer;
697 struct coding_system *coding; 696 struct coding_system *coding;
698 size_t n, stringlen; 697 int n, stringlen;
699 698
700 struct tty_display_info *tty = FRAME_TTY (f); 699 struct tty_display_info *tty = FRAME_TTY (f);
701 700
@@ -1431,7 +1430,7 @@ static void append_glyph (struct it *);
1431static void append_composite_glyph (struct it *); 1430static void append_composite_glyph (struct it *);
1432static void produce_composite_glyph (struct it *); 1431static void produce_composite_glyph (struct it *);
1433static void append_glyphless_glyph (struct it *, int, const char *); 1432static void append_glyphless_glyph (struct it *, int, const char *);
1434static void produce_glyphless_glyph (struct it *, int, Lisp_Object); 1433static void produce_glyphless_glyph (struct it *, Lisp_Object);
1435 1434
1436/* Append glyphs to IT's glyph_row. Called from produce_glyphs for 1435/* Append glyphs to IT's glyph_row. Called from produce_glyphs for
1437 terminal frames if IT->glyph_row != NULL. IT->char_to_display is 1436 terminal frames if IT->glyph_row != NULL. IT->char_to_display is
@@ -1551,7 +1550,7 @@ produce_glyphs (struct it *it)
1551 1550
1552 if (it->what == IT_GLYPHLESS) 1551 if (it->what == IT_GLYPHLESS)
1553 { 1552 {
1554 produce_glyphless_glyph (it, 0, Qnil); 1553 produce_glyphless_glyph (it, Qnil);
1555 goto done; 1554 goto done;
1556 } 1555 }
1557 1556
@@ -1620,7 +1619,7 @@ produce_glyphs (struct it *it)
1620 Lisp_Object acronym = lookup_glyphless_char_display (-1, it); 1619 Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
1621 1620
1622 eassert (it->what == IT_GLYPHLESS); 1621 eassert (it->what == IT_GLYPHLESS);
1623 produce_glyphless_glyph (it, 1, acronym); 1622 produce_glyphless_glyph (it, acronym);
1624 } 1623 }
1625 } 1624 }
1626 1625
@@ -1794,14 +1793,12 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1794 the character. See the description of enum 1793 the character. See the description of enum
1795 glyphless_display_method in dispextern.h for the details. 1794 glyphless_display_method in dispextern.h for the details.
1796 1795
1797 FOR_NO_FONT is nonzero if and only if this is for a character that 1796 ACRONYM, if non-nil, is an acronym string for the character.
1798 is not supported by the coding system of the terminal. ACRONYM, if
1799 non-nil, is an acronym string for the character.
1800 1797
1801 The glyphs actually produced are of type CHAR_GLYPH. */ 1798 The glyphs actually produced are of type CHAR_GLYPH. */
1802 1799
1803static void 1800static void
1804produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) 1801produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
1805{ 1802{
1806 int face_id; 1803 int face_id;
1807 int len; 1804 int len;
@@ -1968,7 +1965,7 @@ turn_on_face (struct frame *f, int face_id)
1968 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; 1965 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
1969 if (fg >= 0 && ts) 1966 if (fg >= 0 && ts)
1970 { 1967 {
1971 p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); 1968 p = tparam (ts, NULL, 0, fg, 0, 0, 0);
1972 OUTPUT (tty, p); 1969 OUTPUT (tty, p);
1973 xfree (p); 1970 xfree (p);
1974 } 1971 }
@@ -1976,7 +1973,7 @@ turn_on_face (struct frame *f, int face_id)
1976 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; 1973 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
1977 if (bg >= 0 && ts) 1974 if (bg >= 0 && ts)
1978 { 1975 {
1979 p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); 1976 p = tparam (ts, NULL, 0, bg, 0, 0, 0);
1980 OUTPUT (tty, p); 1977 OUTPUT (tty, p);
1981 xfree (p); 1978 xfree (p);
1982 } 1979 }
@@ -2027,11 +2024,11 @@ turn_off_face (struct frame *f, int face_id)
2027} 2024}
2028 2025
2029 2026
2030/* Return non-zero if the terminal on frame F supports all of the 2027/* Return true if the terminal on frame F supports all of the
2031 capabilities in CAPS simultaneously, with foreground and background 2028 capabilities in CAPS simultaneously, with foreground and background
2032 colors FG and BG. */ 2029 colors FG and BG. */
2033 2030
2034int 2031bool
2035tty_capable_p (struct tty_display_info *tty, unsigned int caps, 2032tty_capable_p (struct tty_display_info *tty, unsigned int caps,
2036 unsigned long fg, unsigned long bg) 2033 unsigned long fg, unsigned long bg)
2037{ 2034{
@@ -2099,7 +2096,7 @@ static char *default_set_background;
2099/* Save or restore the default color-related capabilities of this 2096/* Save or restore the default color-related capabilities of this
2100 terminal. */ 2097 terminal. */
2101static void 2098static void
2102tty_default_color_capabilities (struct tty_display_info *tty, int save) 2099tty_default_color_capabilities (struct tty_display_info *tty, bool save)
2103{ 2100{
2104 2101
2105 if (save) 2102 if (save)
@@ -2209,7 +2206,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
2209/* Return the tty display object specified by TERMINAL. */ 2206/* Return the tty display object specified by TERMINAL. */
2210 2207
2211static struct terminal * 2208static struct terminal *
2212get_tty_terminal (Lisp_Object terminal, int throw) 2209get_tty_terminal (Lisp_Object terminal, bool throw)
2213{ 2210{
2214 struct terminal *t = get_terminal (terminal, throw); 2211 struct terminal *t = get_terminal (terminal, throw);
2215 2212
@@ -2479,9 +2476,9 @@ term_mouse_moveto (int x, int y)
2479 const char *name; 2476 const char *name;
2480 int fd; 2477 int fd;
2481 name = (const char *) ttyname (0); 2478 name = (const char *) ttyname (0);
2482 fd = open (name, O_WRONLY); 2479 fd = emacs_open (name, O_WRONLY, 0);
2483 SOME_FUNCTION (x, y, fd); 2480 SOME_FUNCTION (x, y, fd);
2484 close (fd); 2481 emacs_close (fd);
2485 last_mouse_x = x; 2482 last_mouse_x = x;
2486 last_mouse_y = y; */ 2483 last_mouse_y = y; */
2487} 2484}
@@ -2519,7 +2516,7 @@ tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
2519 cursor_to (f, save_y, save_x); 2516 cursor_to (f, save_y, save_x);
2520} 2517}
2521 2518
2522static int 2519static bool
2523term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) 2520term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2524{ 2521{
2525 /* Has the mouse moved off the glyph it was on at the last sighting? */ 2522 /* Has the mouse moved off the glyph it was on at the last sighting? */
@@ -2649,7 +2646,7 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2649{ 2646{
2650 struct frame *f = XFRAME (tty->top_frame); 2647 struct frame *f = XFRAME (tty->top_frame);
2651 struct input_event ie; 2648 struct input_event ie;
2652 int do_help = 0; 2649 bool do_help = 0;
2653 int count = 0; 2650 int count = 0;
2654 2651
2655 EVENT_INIT (ie); 2652 EVENT_INIT (ie);
@@ -2934,7 +2931,7 @@ dissociate_if_controlling_tty (int fd)
2934 If MUST_SUCCEED is true, then all errors are fatal. */ 2931 If MUST_SUCCEED is true, then all errors are fatal. */
2935 2932
2936struct terminal * 2933struct terminal *
2937init_tty (const char *name, const char *terminal_type, int must_succeed) 2934init_tty (const char *name, const char *terminal_type, bool must_succeed)
2938{ 2935{
2939 char *area = NULL; 2936 char *area = NULL;
2940 char **address = &area; 2937 char **address = &area;
@@ -2942,7 +2939,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
2942 int status; 2939 int status;
2943 struct tty_display_info *tty = NULL; 2940 struct tty_display_info *tty = NULL;
2944 struct terminal *terminal = NULL; 2941 struct terminal *terminal = NULL;
2945 int ctty = 0; /* 1 if asked to open controlling tty. */ 2942 bool ctty = 0; /* True if asked to open controlling tty. */
2946 2943
2947 if (!terminal_type) 2944 if (!terminal_type)
2948 maybe_fatal (must_succeed, 0, 2945 maybe_fatal (must_succeed, 0,
@@ -3015,7 +3012,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3015 name); 3012 name);
3016 if (!isatty (fd)) 3013 if (!isatty (fd))
3017 { 3014 {
3018 close (fd); 3015 emacs_close (fd);
3019 maybe_fatal (must_succeed, terminal, 3016 maybe_fatal (must_succeed, terminal,
3020 "Not a tty device: %s", 3017 "Not a tty device: %s",
3021 "Not a tty device: %s", 3018 "Not a tty device: %s",
@@ -3412,10 +3409,10 @@ vfatal (const char *str, va_list ap)
3412 3409
3413/* Auxiliary error-handling function for init_tty. 3410/* Auxiliary error-handling function for init_tty.
3414 Delete TERMINAL, then call error or fatal with str1 or str2, 3411 Delete TERMINAL, then call error or fatal with str1 or str2,
3415 respectively, according to whether MUST_SUCCEED is zero or not. */ 3412 respectively, according to whether MUST_SUCCEED is true. */
3416 3413
3417static void 3414static void
3418maybe_fatal (int must_succeed, struct terminal *terminal, 3415maybe_fatal (bool must_succeed, struct terminal *terminal,
3419 const char *str1, const char *str2, ...) 3416 const char *str1, const char *str2, ...)
3420{ 3417{
3421 va_list ap; 3418 va_list ap;
diff --git a/src/termcap.c b/src/termcap.c
index 99bbfce27f5..be05828eea6 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -213,8 +213,8 @@ tgetst1 (char *ptr, char **area)
213 abbreviation expansion makes that effort a little more hairy than 213 abbreviation expansion makes that effort a little more hairy than
214 its worth; this is cleaner. */ 214 its worth; this is cleaner. */
215 { 215 {
216 register int last_p_param = 0; 216 int last_p_param = 0;
217 int remove_p_params = 1; 217 bool remove_p_params = 1;
218 struct { char *beg; int len; } cut[11]; 218 struct { char *beg; int len; } cut[11];
219 219
220 for (cut[0].beg = p = ret; p < r - 3; p++) 220 for (cut[0].beg = p = ret; p < r - 3; p++)
@@ -318,26 +318,26 @@ struct termcap_buffer
318 char *beg; 318 char *beg;
319 ptrdiff_t size; 319 ptrdiff_t size;
320 char *ptr; 320 char *ptr;
321 int ateof; 321 bool ateof;
322 ptrdiff_t full; 322 ptrdiff_t full;
323 }; 323 };
324 324
325/* Forward declarations of static functions. */ 325/* Forward declarations of static functions. */
326 326
327static int scan_file (char *str, int fd, register struct termcap_buffer *bufp); 327static bool scan_file (char *, int, struct termcap_buffer *);
328static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end); 328static char *gobble_line (int, struct termcap_buffer *, char *);
329static int compare_contin (register char *str1, register char *str2); 329static bool compare_contin (char *, char *);
330static int name_match (char *line, char *name); 330static bool name_match (char *, char *);
331 331
332#ifdef MSDOS /* MW, May 1993 */ 332static bool
333static int
334valid_filename_p (char *fn) 333valid_filename_p (char *fn)
335{ 334{
335#ifdef MSDOS
336 return *fn == '/' || fn[1] == ':'; 336 return *fn == '/' || fn[1] == ':';
337}
338#else 337#else
339#define valid_filename_p(fn) (*(fn) == '/') 338 return *fn == '/';
340#endif 339#endif
340}
341 341
342/* Find the termcap entry data for terminal type NAME 342/* Find the termcap entry data for terminal type NAME
343 and store it in the block that BP points to. 343 and store it in the block that BP points to.
@@ -360,10 +360,10 @@ tgetent (char *bp, const char *name)
360 char *tc_search_point; 360 char *tc_search_point;
361 char *term; 361 char *term;
362 ptrdiff_t malloc_size = 0; 362 ptrdiff_t malloc_size = 0;
363 register int c; 363 int c;
364 char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */ 364 char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */
365 char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ 365 char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */
366 int filep; 366 bool filep;
367 367
368#ifdef INTERNAL_TERMINAL 368#ifdef INTERNAL_TERMINAL
369 /* For the internal terminal we don't want to read any termcap file, 369 /* For the internal terminal we don't want to read any termcap file,
@@ -427,11 +427,7 @@ tgetent (char *bp, const char *name)
427 427
428 /* Here we know we must search a file and termcap_name has its name. */ 428 /* Here we know we must search a file and termcap_name has its name. */
429 429
430#ifdef MSDOS 430 fd = emacs_open (termcap_name, O_RDONLY | O_TEXT, 0);
431 fd = open (termcap_name, O_RDONLY|O_TEXT, 0);
432#else
433 fd = open (termcap_name, O_RDONLY, 0);
434#endif
435 if (fd < 0) 431 if (fd < 0)
436 return -1; 432 return -1;
437 433
@@ -459,7 +455,7 @@ tgetent (char *bp, const char *name)
459 /* Scan the file, reading it via buf, till find start of main entry. */ 455 /* Scan the file, reading it via buf, till find start of main entry. */
460 if (scan_file (term, fd, &buf) == 0) 456 if (scan_file (term, fd, &buf) == 0)
461 { 457 {
462 close (fd); 458 emacs_close (fd);
463 xfree (buf.beg); 459 xfree (buf.beg);
464 if (malloc_size) 460 if (malloc_size)
465 xfree (bp); 461 xfree (bp);
@@ -497,7 +493,7 @@ tgetent (char *bp, const char *name)
497 term = tgetst1 (tc_search_point, (char **) 0); 493 term = tgetst1 (tc_search_point, (char **) 0);
498 } 494 }
499 495
500 close (fd); 496 emacs_close (fd);
501 xfree (buf.beg); 497 xfree (buf.beg);
502 498
503 if (malloc_size) 499 if (malloc_size)
@@ -514,10 +510,10 @@ tgetent (char *bp, const char *name)
514 Return 1 if successful, with that line in BUFP, 510 Return 1 if successful, with that line in BUFP,
515 or 0 if no entry is found in the file. */ 511 or 0 if no entry is found in the file. */
516 512
517static int 513static bool
518scan_file (char *str, int fd, register struct termcap_buffer *bufp) 514scan_file (char *str, int fd, struct termcap_buffer *bufp)
519{ 515{
520 register char *end; 516 char *end;
521 517
522 bufp->ptr = bufp->beg; 518 bufp->ptr = bufp->beg;
523 bufp->full = 0; 519 bufp->full = 0;
@@ -548,13 +544,13 @@ scan_file (char *str, int fd, register struct termcap_buffer *bufp)
548 return 0; 544 return 0;
549} 545}
550 546
551/* Return nonzero if NAME is one of the names specified 547/* Return true if NAME is one of the names specified
552 by termcap entry LINE. */ 548 by termcap entry LINE. */
553 549
554static int 550static bool
555name_match (char *line, char *name) 551name_match (char *line, char *name)
556{ 552{
557 register char *tem; 553 char *tem;
558 554
559 if (!compare_contin (line, name)) 555 if (!compare_contin (line, name))
560 return 1; 556 return 1;
@@ -566,18 +562,18 @@ name_match (char *line, char *name)
566 return 0; 562 return 0;
567} 563}
568 564
569static int 565static bool
570compare_contin (register char *str1, register char *str2) 566compare_contin (char *str1, char *str2)
571{ 567{
572 register int c1, c2;
573 while (1) 568 while (1)
574 { 569 {
575 c1 = *str1++; 570 int c1 = *str1++;
576 c2 = *str2++; 571 int c2 = *str2++;
577 while (c1 == '\\' && *str1 == '\n') 572 while (c1 == '\\' && *str1 == '\n')
578 { 573 {
579 str1++; 574 str1++;
580 while ((c1 = *str1++) == ' ' || c1 == '\t'); 575 while ((c1 = *str1++) == ' ' || c1 == '\t')
576 continue;
581 } 577 }
582 if (c2 == '\0') 578 if (c2 == '\0')
583 { 579 {
@@ -651,57 +647,3 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
651 } 647 }
652 return end + 1; 648 return end + 1;
653} 649}
654
655#ifdef TEST
656
657#include <stdio.h>
658
659static void
660tprint (char *cap)
661{
662 char *x = tgetstr (cap, 0);
663 register char *y;
664
665 printf ("%s: ", cap);
666 if (x)
667 {
668 for (y = x; *y; y++)
669 if (*y <= ' ' || *y == 0177)
670 printf ("\\%0o", *y);
671 else
672 putchar (*y);
673 free (x);
674 }
675 else
676 printf ("none");
677 putchar ('\n');
678}
679
680int
681main (int argc, char **argv)
682{
683 char *term;
684 char *buf;
685
686 term = argv[1];
687 printf ("TERM: %s\n", term);
688
689 buf = (char *) tgetent (0, term);
690 if ((int) buf <= 0)
691 {
692 printf ("No entry.\n");
693 return 0;
694 }
695
696 printf ("Entry: %s\n", buf);
697
698 tprint ("cm");
699 tprint ("AL");
700
701 printf ("co: %d\n", tgetnum ("co"));
702 printf ("am: %d\n", tgetflag ("am"));
703
704 return 0;
705}
706
707#endif /* TEST */
diff --git a/src/termhooks.h b/src/termhooks.h
index fdbeda076b7..f11f5ae9ffc 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -646,7 +646,7 @@ extern struct terminal *terminal_list;
646 (((d)->type != output_termcap && (d)->type != output_msdos_raw) \ 646 (((d)->type != output_termcap && (d)->type != output_msdos_raw) \
647 || (d)->display_info.tty->input) 647 || (d)->display_info.tty->input)
648 648
649extern struct terminal *get_terminal (Lisp_Object terminal, int); 649extern struct terminal *get_terminal (Lisp_Object terminal, bool);
650extern struct terminal *create_terminal (void); 650extern struct terminal *create_terminal (void);
651extern void delete_terminal (struct terminal *); 651extern void delete_terminal (struct terminal *);
652 652
diff --git a/src/terminal.c b/src/terminal.c
index c99c39c64ae..c55fd4eb077 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -199,11 +199,11 @@ ins_del_lines (struct frame *f, int vpos, int n)
199 199
200/* Return the terminal object specified by TERMINAL. TERMINAL may be 200/* Return the terminal object specified by TERMINAL. TERMINAL may be
201 a terminal object, a frame, or nil for the terminal device of the 201 a terminal object, a frame, or nil for the terminal device of the
202 current frame. If THROW is zero, return NULL for failure, 202 current frame. If THROW is false, return NULL for failure,
203 otherwise throw an error. */ 203 otherwise throw an error. */
204 204
205struct terminal * 205struct terminal *
206get_terminal (Lisp_Object terminal, int throw) 206get_terminal (Lisp_Object terminal, bool throw)
207{ 207{
208 struct terminal *result = NULL; 208 struct terminal *result = NULL;
209 209
diff --git a/src/undo.c b/src/undo.c
index d8711882fbf..234b8510f0a 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -229,10 +229,9 @@ record_first_change (void)
229 if (base_buffer->base_buffer) 229 if (base_buffer->base_buffer)
230 base_buffer = base_buffer->base_buffer; 230 base_buffer = base_buffer->base_buffer;
231 231
232 bset_undo_list 232 bset_undo_list (current_buffer,
233 (current_buffer, 233 Fcons (Fcons (Qt, Fvisited_file_modtime ()),
234 Fcons (Fcons (Qt, make_lisp_time (base_buffer->modtime)), 234 BVAR (current_buffer, undo_list)));
235 BVAR (current_buffer, undo_list)));
236} 235}
237 236
238/* Record a change in property PROP (whose old value was VAL) 237/* Record a change in property PROP (whose old value was VAL)
diff --git a/src/unexaix.c b/src/unexaix.c
index 44a824b8c12..757ba6f51b3 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -42,6 +42,7 @@ what you give them. Help stamp out software-hoarding! */
42 42
43#include <config.h> 43#include <config.h>
44#include "unexec.h" 44#include "unexec.h"
45#include "lisp.h"
45 46
46#define PERROR(file) report_error (file, new) 47#define PERROR(file) report_error (file, new)
47#include <a.out.h> 48#include <a.out.h>
@@ -93,13 +94,10 @@ static int pagemask;
93static _Noreturn void 94static _Noreturn void
94report_error (const char *file, int fd) 95report_error (const char *file, int fd)
95{ 96{
97 int err = errno;
96 if (fd) 98 if (fd)
97 { 99 emacs_close (fd);
98 int failed_errno = errno; 100 report_file_errno ("Cannot unexec", Fcons (build_string (file), Qnil), err);
99 close (fd);
100 errno = failed_errno;
101 }
102 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
103} 101}
104 102
105#define ERROR0(msg) report_error_1 (new, msg) 103#define ERROR0(msg) report_error_1 (new, msg)
@@ -110,7 +108,7 @@ static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3)
110report_error_1 (int fd, const char *msg, ...) 108report_error_1 (int fd, const char *msg, ...)
111{ 109{
112 va_list ap; 110 va_list ap;
113 close (fd); 111 emacs_close (fd);
114 va_start (ap, msg); 112 va_start (ap, msg);
115 verror (msg, ap); 113 verror (msg, ap);
116 va_end (ap); 114 va_end (ap);
@@ -132,11 +130,11 @@ unexec (const char *new_name, const char *a_name)
132{ 130{
133 int new = -1, a_out = -1; 131 int new = -1, a_out = -1;
134 132
135 if (a_name && (a_out = open (a_name, O_RDONLY)) < 0) 133 if (a_name && (a_out = emacs_open (a_name, O_RDONLY, 0)) < 0)
136 { 134 {
137 PERROR (a_name); 135 PERROR (a_name);
138 } 136 }
139 if ((new = creat (new_name, 0666)) < 0) 137 if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
140 { 138 {
141 PERROR (new_name); 139 PERROR (new_name);
142 } 140 }
@@ -147,13 +145,13 @@ unexec (const char *new_name, const char *a_name)
147 || adjust_lnnoptrs (new, a_out, new_name) < 0 145 || adjust_lnnoptrs (new, a_out, new_name) < 0
148 || unrelocate_symbols (new, a_out, a_name, new_name) < 0) 146 || unrelocate_symbols (new, a_out, a_name, new_name) < 0)
149 { 147 {
150 close (new); 148 emacs_close (new);
151 return; 149 return;
152 } 150 }
153 151
154 close (new); 152 emacs_close (new);
155 if (a_out >= 0) 153 if (a_out >= 0)
156 close (a_out); 154 emacs_close (a_out);
157 mark_x (new_name); 155 mark_x (new_name);
158} 156}
159 157
@@ -503,7 +501,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
503 if (!lnnoptr || !f_hdr.f_symptr) 501 if (!lnnoptr || !f_hdr.f_symptr)
504 return 0; 502 return 0;
505 503
506 if ((new = open (new_name, O_RDWR)) < 0) 504 if ((new = emacs_open (new_name, O_RDWR, 0)) < 0)
507 { 505 {
508 PERROR (new_name); 506 PERROR (new_name);
509 return -1; 507 return -1;
@@ -533,7 +531,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
533 } 531 }
534 } 532 }
535 } 533 }
536 close (new); 534 emacs_close (new);
537 535
538 return 0; 536 return 0;
539} 537}
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 2e662a34145..c467e59a665 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -52,6 +52,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
52 52
53#include <config.h> 53#include <config.h>
54#include "unexec.h" 54#include "unexec.h"
55#include "lisp.h"
55 56
56#define PERROR(file) report_error (file, new) 57#define PERROR(file) report_error (file, new)
57 58
@@ -126,9 +127,10 @@ static int pagemask;
126static void 127static void
127report_error (const char *file, int fd) 128report_error (const char *file, int fd)
128{ 129{
130 int err = errno;
129 if (fd) 131 if (fd)
130 close (fd); 132 emacs_close (fd);
131 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); 133 report_file_errno ("Cannot unexec", Fcons (build_string (file), Qnil), err);
132} 134}
133 135
134#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 136#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
@@ -138,7 +140,7 @@ report_error (const char *file, int fd)
138static void 140static void
139report_error_1 (int fd, const char *msg, int a1, int a2) 141report_error_1 (int fd, const char *msg, int a1, int a2)
140{ 142{
141 close (fd); 143 emacs_close (fd);
142 error (msg, a1, a2); 144 error (msg, a1, a2);
143} 145}
144 146
@@ -486,7 +488,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
486#ifdef MSDOS 488#ifdef MSDOS
487 if ((new = writedesc) < 0) 489 if ((new = writedesc) < 0)
488#else 490#else
489 if ((new = open (new_name, O_RDWR)) < 0) 491 if ((new = emacs_open (new_name, O_RDWR, 0)) < 0)
490#endif 492#endif
491 { 493 {
492 PERROR (new_name); 494 PERROR (new_name);
@@ -510,7 +512,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
510 } 512 }
511 } 513 }
512#ifndef MSDOS 514#ifndef MSDOS
513 close (new); 515 emacs_close (new);
514#endif 516#endif
515 return 0; 517 return 0;
516} 518}
@@ -525,11 +527,11 @@ unexec (const char *new_name, const char *a_name)
525{ 527{
526 int new = -1, a_out = -1; 528 int new = -1, a_out = -1;
527 529
528 if (a_name && (a_out = open (a_name, O_RDONLY)) < 0) 530 if (a_name && (a_out = emacs_open (a_name, O_RDONLY, 0)) < 0)
529 { 531 {
530 PERROR (a_name); 532 PERROR (a_name);
531 } 533 }
532 if ((new = creat (new_name, 0666)) < 0) 534 if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
533 { 535 {
534 PERROR (new_name); 536 PERROR (new_name);
535 } 537 }
@@ -540,13 +542,13 @@ unexec (const char *new_name, const char *a_name)
540 || adjust_lnnoptrs (new, a_out, new_name) < 0 542 || adjust_lnnoptrs (new, a_out, new_name) < 0
541 ) 543 )
542 { 544 {
543 close (new); 545 emacs_close (new);
544 return; 546 return;
545 } 547 }
546 548
547 close (new); 549 emacs_close (new);
548 if (a_out >= 0) 550 if (a_out >= 0)
549 close (a_out); 551 emacs_close (a_out);
550 mark_x (new_name); 552 mark_x (new_name);
551} 553}
552 554
diff --git a/src/unexcw.c b/src/unexcw.c
index 1290c28d245..12435a85051 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -20,8 +20,8 @@ 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 "lisp.h"
23 24
24#include <lisp.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <fcntl.h> 26#include <fcntl.h>
27#include <a.out.h> 27#include <a.out.h>
@@ -298,9 +298,9 @@ unexec (const char *outfile, const char *infile)
298 infile = add_exe_suffix_if_necessary (infile, infile_buffer); 298 infile = add_exe_suffix_if_necessary (infile, infile_buffer);
299 outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer); 299 outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
300 300
301 fd_in = open (infile, O_RDONLY | O_BINARY); 301 fd_in = emacs_open (infile, O_RDONLY | O_BINARY, 0);
302 assert (fd_in >= 0); 302 assert (fd_in >= 0);
303 fd_out = open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755); 303 fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
304 assert (fd_out >= 0); 304 assert (fd_out >= 0);
305 for (;;) 305 for (;;)
306 { 306 {
@@ -316,13 +316,13 @@ unexec (const char *outfile, const char *infile)
316 ret2 = write (fd_out, buffer, ret); 316 ret2 = write (fd_out, buffer, ret);
317 assert (ret2 == ret); 317 assert (ret2 == ret);
318 } 318 }
319 ret = close (fd_in); 319 ret = emacs_close (fd_in);
320 assert (ret == 0); 320 assert (ret == 0);
321 321
322 bss_sbrk_did_unexec = 1; 322 bss_sbrk_did_unexec = 1;
323 fixup_executable (fd_out); 323 fixup_executable (fd_out);
324 bss_sbrk_did_unexec = 0; 324 bss_sbrk_did_unexec = 0;
325 325
326 ret = close (fd_out); 326 ret = emacs_close (fd_out);
327 assert (ret == 0); 327 assert (ret == 0);
328} 328}
diff --git a/src/unexelf.c b/src/unexelf.c
index 4e50bb86367..e2412393286 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -386,9 +386,8 @@ temacs:
386 Instead we read the whole file, modify it, and write it out. */ 386 Instead we read the whole file, modify it, and write it out. */
387 387
388#include <config.h> 388#include <config.h>
389#include <unexec.h> 389#include "unexec.h"
390 390#include "lisp.h"
391extern _Noreturn void fatal (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
392 391
393#include <errno.h> 392#include <errno.h>
394#include <fcntl.h> 393#include <fcntl.h>
@@ -672,7 +671,7 @@ unexec (const char *new_name, const char *old_name)
672 /* Open the old file, allocate a buffer of the right size, and read 671 /* Open the old file, allocate a buffer of the right size, and read
673 in the file contents. */ 672 in the file contents. */
674 673
675 old_file = open (old_name, O_RDONLY); 674 old_file = emacs_open (old_name, O_RDONLY, 0);
676 675
677 if (old_file < 0) 676 if (old_file < 0)
678 fatal ("Can't open %s for reading: %s", old_name, strerror (errno)); 677 fatal ("Can't open %s for reading: %s", old_name, strerror (errno));
@@ -681,7 +680,7 @@ unexec (const char *new_name, const char *old_name)
681 fatal ("Can't fstat (%s): %s", old_name, strerror (errno)); 680 fatal ("Can't fstat (%s): %s", old_name, strerror (errno));
682 681
683#if MAP_ANON == 0 682#if MAP_ANON == 0
684 mmap_fd = open ("/dev/zero", O_RDONLY); 683 mmap_fd = emacs_open ("/dev/zero", O_RDONLY, 0);
685 if (mmap_fd < 0) 684 if (mmap_fd < 0)
686 fatal ("Can't open /dev/zero for reading: %s", strerror (errno)); 685 fatal ("Can't open /dev/zero for reading: %s", strerror (errno));
687#endif 686#endif
@@ -801,7 +800,7 @@ unexec (const char *new_name, const char *old_name)
801 the image of the new file. Set pointers to various interesting 800 the image of the new file. Set pointers to various interesting
802 objects. */ 801 objects. */
803 802
804 new_file = open (new_name, O_RDWR | O_CREAT, 0666); 803 new_file = emacs_open (new_name, O_RDWR | O_CREAT, 0666);
805 if (new_file < 0) 804 if (new_file < 0)
806 fatal ("Can't creat (%s): %s", new_name, strerror (errno)); 805 fatal ("Can't creat (%s): %s", new_name, strerror (errno));
807 806
@@ -1313,13 +1312,13 @@ temacs:
1313 /* Close the files and make the new file executable. */ 1312 /* Close the files and make the new file executable. */
1314 1313
1315#if MAP_ANON == 0 1314#if MAP_ANON == 0
1316 close (mmap_fd); 1315 emacs_close (mmap_fd);
1317#endif 1316#endif
1318 1317
1319 if (close (old_file) != 0) 1318 if (emacs_close (old_file) != 0)
1320 fatal ("Can't close (%s): %s", old_name, strerror (errno)); 1319 fatal ("Can't close (%s): %s", old_name, strerror (errno));
1321 1320
1322 if (close (new_file) != 0) 1321 if (emacs_close (new_file) != 0)
1323 fatal ("Can't close (%s): %s", new_name, strerror (errno)); 1322 fatal ("Can't close (%s): %s", new_name, strerror (errno));
1324 1323
1325 if (stat (new_name, &stat_buf) != 0) 1324 if (stat (new_name, &stat_buf) != 0)
diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c
index ce65faffd4e..bee2517307a 100644
--- a/src/unexhp9k800.c
+++ b/src/unexhp9k800.c
@@ -51,6 +51,7 @@
51 51
52#include <config.h> 52#include <config.h>
53#include "unexec.h" 53#include "unexec.h"
54#include "lisp.h"
54 55
55#include <stdio.h> 56#include <stdio.h>
56#include <fcntl.h> 57#include <fcntl.h>
@@ -268,10 +269,10 @@ unexec (const char *new_name, /* name of the new a.out file to be created *
268 intact. NOT implemented. */ 269 intact. NOT implemented. */
269 270
270 /* Open the input and output a.out files */ 271 /* Open the input and output a.out files */
271 old = open (old_name, O_RDONLY); 272 old = emacs_open (old_name, O_RDONLY, 0);
272 if (old < 0) 273 if (old < 0)
273 { perror (old_name); exit (1); } 274 { perror (old_name); exit (1); }
274 new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777); 275 new = emacs_open (new_name, O_CREAT | O_RDWR | O_TRUNC, 0777);
275 if (new < 0) 276 if (new < 0)
276 { perror (new_name); exit (1); } 277 { perror (new_name); exit (1); }
277 278
@@ -305,6 +306,6 @@ unexec (const char *new_name, /* name of the new a.out file to be created *
305 write_header (new, &hdr, &auxhdr); 306 write_header (new, &hdr, &auxhdr);
306 307
307 /* Close the binary file */ 308 /* Close the binary file */
308 close (old); 309 emacs_close (old);
309 close (new); 310 emacs_close (new);
310} 311}
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 8d4e636fa5c..87848b012ba 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -97,6 +97,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
97#undef free 97#undef free
98 98
99#include "unexec.h" 99#include "unexec.h"
100#include "lisp.h"
100 101
101#include <stdio.h> 102#include <stdio.h>
102#include <fcntl.h> 103#include <fcntl.h>
@@ -1322,16 +1323,16 @@ unexec (const char *outfile, const char *infile)
1322 unexec_error ("Unexec from a dumped executable is not supported."); 1323 unexec_error ("Unexec from a dumped executable is not supported.");
1323 1324
1324 pagesize = getpagesize (); 1325 pagesize = getpagesize ();
1325 infd = open (infile, O_RDONLY, 0); 1326 infd = emacs_open (infile, O_RDONLY, 0);
1326 if (infd < 0) 1327 if (infd < 0)
1327 { 1328 {
1328 unexec_error ("cannot open input file `%s'", infile); 1329 unexec_error ("cannot open input file `%s'", infile);
1329 } 1330 }
1330 1331
1331 outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755); 1332 outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
1332 if (outfd < 0) 1333 if (outfd < 0)
1333 { 1334 {
1334 close (infd); 1335 emacs_close (infd);
1335 unexec_error ("cannot open output file `%s'", outfile); 1336 unexec_error ("cannot open output file `%s'", outfile);
1336 } 1337 }
1337 1338
@@ -1345,7 +1346,7 @@ unexec (const char *outfile, const char *infile)
1345 1346
1346 dump_it (); 1347 dump_it ();
1347 1348
1348 close (outfd); 1349 emacs_close (outfd);
1349} 1350}
1350 1351
1351 1352
diff --git a/src/w32.c b/src/w32.c
index 230479cd61a..1a3d81bbffc 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -234,6 +234,8 @@ extern int sys_access (const char *, int);
234extern void *e_malloc (size_t); 234extern void *e_malloc (size_t);
235extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 235extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
236 EMACS_TIME *, void *); 236 EMACS_TIME *, void *);
237extern int sys_dup (int);
238
237 239
238 240
239 241
@@ -6719,10 +6721,16 @@ sys_sendto (int s, const char * buf, int len, int flags,
6719} 6721}
6720 6722
6721/* Windows does not have an fcntl function. Provide an implementation 6723/* Windows does not have an fcntl function. Provide an implementation
6722 solely for making sockets non-blocking. */ 6724 good enough for Emacs. */
6723int 6725int
6724fcntl (int s, int cmd, int options) 6726fcntl (int s, int cmd, int options)
6725{ 6727{
6728 /* In the w32 Emacs port, fcntl (fd, F_DUPFD_CLOEXEC, fd1) is always
6729 invoked in a context where fd1 is closed and all descriptors less
6730 than fd1 are open, so sys_dup is an adequate implementation. */
6731 if (cmd == F_DUPFD_CLOEXEC)
6732 return sys_dup (s);
6733
6726 if (winsock_lib == NULL) 6734 if (winsock_lib == NULL)
6727 { 6735 {
6728 errno = ENETDOWN; 6736 errno = ENETDOWN;
@@ -6864,13 +6872,14 @@ sys_dup2 (int src, int dst)
6864 return rc; 6872 return rc;
6865} 6873}
6866 6874
6867/* Unix pipe() has only one arg */
6868int 6875int
6869sys_pipe (int * phandles) 6876pipe2 (int * phandles, int pipe2_flags)
6870{ 6877{
6871 int rc; 6878 int rc;
6872 unsigned flags; 6879 unsigned flags;
6873 6880
6881 eassert (pipe2_flags == O_CLOEXEC);
6882
6874 /* make pipe handles non-inheritable; when we spawn a child, we 6883 /* make pipe handles non-inheritable; when we spawn a child, we
6875 replace the relevant handle with an inheritable one. Also put 6884 replace the relevant handle with an inheritable one. Also put
6876 pipes into binary mode; we will do text mode translation ourselves 6885 pipes into binary mode; we will do text mode translation ourselves
diff --git a/src/w32.h b/src/w32.h
index 17da0778db1..9c1f1efa699 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -188,7 +188,7 @@ extern int random (void);
188 188
189extern int fchmod (int, mode_t); 189extern int fchmod (int, mode_t);
190extern int sys_rename_replace (char const *, char const *, BOOL); 190extern int sys_rename_replace (char const *, char const *, BOOL);
191extern int sys_pipe (int *); 191extern int pipe2 (int *, int);
192 192
193extern void set_process_dir (char *); 193extern void set_process_dir (char *);
194extern int sys_spawnve (int, char *, char **, char **); 194extern int sys_spawnve (int, char *, char **, char **);
diff --git a/src/w32fns.c b/src/w32fns.c
index 46fb02d96a1..3fa23c166e2 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -106,6 +106,7 @@ Lisp_Object Qalt;
106Lisp_Object Qctrl; 106Lisp_Object Qctrl;
107Lisp_Object Qcontrol; 107Lisp_Object Qcontrol;
108Lisp_Object Qshift; 108Lisp_Object Qshift;
109static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes;
109 110
110 111
111/* Prefix for system colors. */ 112/* Prefix for system colors. */
@@ -131,6 +132,15 @@ static HWND track_mouse_window;
131#ifndef MONITOR_DEFAULT_TO_NEAREST 132#ifndef MONITOR_DEFAULT_TO_NEAREST
132#define MONITOR_DEFAULT_TO_NEAREST 2 133#define MONITOR_DEFAULT_TO_NEAREST 2
133#endif 134#endif
135#ifndef MONITORINFOF_PRIMARY
136#define MONITORINFOF_PRIMARY 1
137#endif
138#ifndef SM_XVIRTUALSCREEN
139#define SM_XVIRTUALSCREEN 76
140#endif
141#ifndef SM_YVIRTUALSCREEN
142#define SM_YVIRTUALSCREEN 77
143#endif
134/* MinGW headers define MONITORINFO unconditionally, but MSVC ones don't. 144/* MinGW headers define MONITORINFO unconditionally, but MSVC ones don't.
135 To avoid a compile error on one or the other, redefine with a new name. */ 145 To avoid a compile error on one or the other, redefine with a new name. */
136struct MONITOR_INFO 146struct MONITOR_INFO
@@ -141,6 +151,18 @@ struct MONITOR_INFO
141 DWORD dwFlags; 151 DWORD dwFlags;
142}; 152};
143 153
154#ifndef CCHDEVICENAME
155#define CCHDEVICENAME 32
156#endif
157struct MONITOR_INFO_EX
158{
159 DWORD cbSize;
160 RECT rcMonitor;
161 RECT rcWork;
162 DWORD dwFlags;
163 char szDevice[CCHDEVICENAME];
164};
165
144/* Reportedly, MSVC does not have this in its headers. */ 166/* Reportedly, MSVC does not have this in its headers. */
145#if defined (_MSC_VER) && _WIN32_WINNT < 0x0500 167#if defined (_MSC_VER) && _WIN32_WINNT < 0x0500
146DECLARE_HANDLE(HMONITOR); 168DECLARE_HANDLE(HMONITOR);
@@ -159,6 +181,10 @@ typedef BOOL (WINAPI * GetMonitorInfo_Proc)
159 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); 181 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
160typedef HMONITOR (WINAPI * MonitorFromWindow_Proc) 182typedef HMONITOR (WINAPI * MonitorFromWindow_Proc)
161 (IN HWND hwnd, IN DWORD dwFlags); 183 (IN HWND hwnd, IN DWORD dwFlags);
184typedef BOOL CALLBACK (* MonitorEnum_Proc)
185 (IN HMONITOR monitor, IN HDC hdc, IN RECT *rcMonitor, IN LPARAM dwData);
186typedef BOOL (WINAPI * EnumDisplayMonitors_Proc)
187 (IN HDC hdc, IN RECT *rcClip, IN MonitorEnum_Proc fnEnum, IN LPARAM dwData);
162 188
163TrackMouseEvent_Proc track_mouse_event_fn = NULL; 189TrackMouseEvent_Proc track_mouse_event_fn = NULL;
164ImmGetCompositionString_Proc get_composition_string_fn = NULL; 190ImmGetCompositionString_Proc get_composition_string_fn = NULL;
@@ -168,6 +194,7 @@ ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
168MonitorFromPoint_Proc monitor_from_point_fn = NULL; 194MonitorFromPoint_Proc monitor_from_point_fn = NULL;
169GetMonitorInfo_Proc get_monitor_info_fn = NULL; 195GetMonitorInfo_Proc get_monitor_info_fn = NULL;
170MonitorFromWindow_Proc monitor_from_window_fn = NULL; 196MonitorFromWindow_Proc monitor_from_window_fn = NULL;
197EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL;
171 198
172#ifdef NTGUI_UNICODE 199#ifdef NTGUI_UNICODE
173#define unicode_append_menu AppendMenuW 200#define unicode_append_menu AppendMenuW
@@ -4674,7 +4701,11 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width,
4674 doc: /* Return the width in pixels of DISPLAY. 4701 doc: /* Return the width in pixels of DISPLAY.
4675The optional argument DISPLAY specifies which display to ask about. 4702The optional argument DISPLAY specifies which display to ask about.
4676DISPLAY should be either a frame or a display name (a string). 4703DISPLAY should be either a frame or a display name (a string).
4677If omitted or nil, that stands for the selected frame's display. */) 4704If omitted or nil, that stands for the selected frame's display.
4705
4706On \"multi-monitor\" setups this refers to the pixel width for all
4707physical monitors associated with DISPLAY. To get information for
4708each physical monitor, use `display-monitor-attributes-list'. */)
4678 (Lisp_Object display) 4709 (Lisp_Object display)
4679{ 4710{
4680 struct w32_display_info *dpyinfo = check_x_display_info (display); 4711 struct w32_display_info *dpyinfo = check_x_display_info (display);
@@ -4687,7 +4718,11 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
4687 doc: /* Return the height in pixels of DISPLAY. 4718 doc: /* Return the height in pixels of DISPLAY.
4688The optional argument DISPLAY specifies which display to ask about. 4719The optional argument DISPLAY specifies which display to ask about.
4689DISPLAY should be either a frame or a display name (a string). 4720DISPLAY should be either a frame or a display name (a string).
4690If omitted or nil, that stands for the selected frame's display. */) 4721If omitted or nil, that stands for the selected frame's display.
4722
4723On \"multi-monitor\" setups this refers to the pixel height for all
4724physical monitors associated with DISPLAY. To get information for
4725each physical monitor, use `display-monitor-attributes-list'. */)
4691 (Lisp_Object display) 4726 (Lisp_Object display)
4692{ 4727{
4693 struct w32_display_info *dpyinfo = check_x_display_info (display); 4728 struct w32_display_info *dpyinfo = check_x_display_info (display);
@@ -4779,41 +4814,46 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height,
4779 doc: /* Return the height in millimeters of DISPLAY. 4814 doc: /* Return the height in millimeters of DISPLAY.
4780The optional argument DISPLAY specifies which display to ask about. 4815The optional argument DISPLAY specifies which display to ask about.
4781DISPLAY should be either a frame or a display name (a string). 4816DISPLAY should be either a frame or a display name (a string).
4782If omitted or nil, that stands for the selected frame's display. */) 4817If omitted or nil, that stands for the selected frame's display.
4818
4819On \"multi-monitor\" setups this refers to the height in millimeters for
4820all physical monitors associated with DISPLAY. To get information
4821for each physical monitor, use `display-monitor-attributes-list'. */)
4783 (Lisp_Object display) 4822 (Lisp_Object display)
4784{ 4823{
4785 struct w32_display_info *dpyinfo = check_x_display_info (display); 4824 struct w32_display_info *dpyinfo = check_x_display_info (display);
4786 HDC hdc; 4825 HDC hdc;
4787 int cap; 4826 double mm_per_pixel;
4788
4789 hdc = GetDC (dpyinfo->root_window);
4790 4827
4791 cap = GetDeviceCaps (hdc, VERTSIZE); 4828 hdc = GetDC (NULL);
4829 mm_per_pixel = ((double) GetDeviceCaps (hdc, VERTSIZE)
4830 / GetDeviceCaps (hdc, VERTRES));
4831 ReleaseDC (NULL, hdc);
4792 4832
4793 ReleaseDC (dpyinfo->root_window, hdc); 4833 return make_number (x_display_pixel_height (dpyinfo) * mm_per_pixel + 0.5);
4794
4795 return make_number (cap);
4796} 4834}
4797 4835
4798DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 4836DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
4799 doc: /* Return the width in millimeters of DISPLAY. 4837 doc: /* Return the width in millimeters of DISPLAY.
4800The optional argument DISPLAY specifies which display to ask about. 4838The optional argument DISPLAY specifies which display to ask about.
4801DISPLAY should be either a frame or a display name (a string). 4839DISPLAY should be either a frame or a display name (a string).
4802If omitted or nil, that stands for the selected frame's display. */) 4840If omitted or nil, that stands for the selected frame's display.
4841
4842On \"multi-monitor\" setups this refers to the width in millimeters for
4843all physical monitors associated with TERMINAL. To get information
4844for each physical monitor, use `display-monitor-attributes-list'. */)
4803 (Lisp_Object display) 4845 (Lisp_Object display)
4804{ 4846{
4805 struct w32_display_info *dpyinfo = check_x_display_info (display); 4847 struct w32_display_info *dpyinfo = check_x_display_info (display);
4806
4807 HDC hdc; 4848 HDC hdc;
4808 int cap; 4849 double mm_per_pixel;
4809 4850
4810 hdc = GetDC (dpyinfo->root_window); 4851 hdc = GetDC (NULL);
4852 mm_per_pixel = ((double) GetDeviceCaps (hdc, HORZSIZE)
4853 / GetDeviceCaps (hdc, HORZRES));
4854 ReleaseDC (NULL, hdc);
4811 4855
4812 cap = GetDeviceCaps (hdc, HORZSIZE); 4856 return make_number (x_display_pixel_width (dpyinfo) * mm_per_pixel + 0.5);
4813
4814 ReleaseDC (dpyinfo->root_window, hdc);
4815
4816 return make_number (cap);
4817} 4857}
4818 4858
4819DEFUN ("x-display-backing-store", Fx_display_backing_store, 4859DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -4865,6 +4905,202 @@ If omitted or nil, that stands for the selected frame's display. */)
4865 return Qnil; 4905 return Qnil;
4866} 4906}
4867 4907
4908static BOOL CALLBACK
4909w32_monitor_enum (HMONITOR monitor, HDC hdc, RECT *rcMonitor, LPARAM dwData)
4910{
4911 Lisp_Object *monitor_list = (Lisp_Object *) dwData;
4912
4913 *monitor_list = Fcons (make_save_pointer (monitor), *monitor_list);
4914
4915 return TRUE;
4916}
4917
4918static Lisp_Object
4919w32_display_monitor_attributes_list (void)
4920{
4921 Lisp_Object attributes_list = Qnil, primary_monitor_attributes = Qnil;
4922 Lisp_Object monitor_list = Qnil, monitor_frames, rest, frame;
4923 int i, n_monitors;
4924 HMONITOR *monitors;
4925 struct gcpro gcpro1, gcpro2, gcpro3;
4926
4927 if (!(enum_display_monitors_fn && get_monitor_info_fn
4928 && monitor_from_window_fn))
4929 return Qnil;
4930
4931 if (!enum_display_monitors_fn (NULL, NULL, w32_monitor_enum,
4932 (LPARAM) &monitor_list)
4933 || NILP (monitor_list))
4934 return Qnil;
4935
4936 n_monitors = 0;
4937 for (rest = monitor_list; CONSP (rest); rest = XCDR (rest))
4938 n_monitors++;
4939
4940 monitors = xmalloc (n_monitors * sizeof (*monitors));
4941 for (i = 0; i < n_monitors; i++)
4942 {
4943 monitors[i] = XSAVE_POINTER (XCAR (monitor_list), 0);
4944 monitor_list = XCDR (monitor_list);
4945 }
4946
4947 monitor_frames = Fmake_vector (make_number (n_monitors), Qnil);
4948 FOR_EACH_FRAME (rest, frame)
4949 {
4950 struct frame *f = XFRAME (frame);
4951
4952 if (FRAME_W32_P (f) && !EQ (frame, tip_frame))
4953 {
4954 HMONITOR monitor =
4955 monitor_from_window_fn (FRAME_W32_WINDOW (f),
4956 MONITOR_DEFAULT_TO_NEAREST);
4957
4958 for (i = 0; i < n_monitors; i++)
4959 if (monitors[i] == monitor)
4960 break;
4961
4962 if (i < n_monitors)
4963 ASET (monitor_frames, i, Fcons (frame, AREF (monitor_frames, i)));
4964 }
4965 }
4966
4967 GCPRO3 (attributes_list, primary_monitor_attributes, monitor_frames);
4968
4969 for (i = 0; i < n_monitors; i++)
4970 {
4971 Lisp_Object geometry, workarea, name, attributes = Qnil;
4972 HDC hdc;
4973 int width_mm, height_mm;
4974 struct MONITOR_INFO_EX mi;
4975
4976 mi.cbSize = sizeof (mi);
4977 if (!get_monitor_info_fn (monitors[i], (struct MONITOR_INFO *) &mi))
4978 continue;
4979
4980 hdc = CreateDCA ("DISPLAY", mi.szDevice, NULL, NULL);
4981 if (hdc == NULL)
4982 continue;
4983 width_mm = GetDeviceCaps (hdc, HORZSIZE);
4984 height_mm = GetDeviceCaps (hdc, VERTSIZE);
4985 DeleteDC (hdc);
4986
4987 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
4988 attributes);
4989
4990 name = DECODE_SYSTEM (make_unibyte_string (mi.szDevice,
4991 strlen (mi.szDevice)));
4992 attributes = Fcons (Fcons (Qname, name), attributes);
4993
4994 attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)),
4995 attributes);
4996
4997 workarea = list4i (mi.rcWork.left, mi.rcWork.top,
4998 mi.rcWork.right - mi.rcWork.left,
4999 mi.rcWork.bottom - mi.rcWork.top);
5000 attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
5001
5002 geometry = list4i (mi.rcMonitor.left, mi.rcMonitor.top,
5003 mi.rcMonitor.right - mi.rcMonitor.left,
5004 mi.rcMonitor.bottom - mi.rcMonitor.top);
5005 attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
5006
5007 if (mi.dwFlags & MONITORINFOF_PRIMARY)
5008 primary_monitor_attributes = attributes;
5009 else
5010 attributes_list = Fcons (attributes, attributes_list);
5011 }
5012
5013 if (!NILP (primary_monitor_attributes))
5014 attributes_list = Fcons (primary_monitor_attributes, attributes_list);
5015
5016 UNGCPRO;
5017
5018 xfree (monitors);
5019
5020 return attributes_list;
5021}
5022
5023static Lisp_Object
5024w32_display_monitor_attributes_list_fallback (struct w32_display_info *dpyinfo)
5025{
5026 Lisp_Object geometry, workarea, frames, rest, frame, attributes = Qnil;
5027 HDC hdc;
5028 double mm_per_pixel;
5029 int pixel_width, pixel_height, width_mm, height_mm;
5030 RECT workarea_rect;
5031
5032 /* Fallback: treat (possibly) multiple physical monitors as if they
5033 formed a single monitor as a whole. This should provide a
5034 consistent result at least on single monitor environments. */
5035 attributes = Fcons (Fcons (Qname, build_string ("combined screen")),
5036 attributes);
5037
5038 frames = Qnil;
5039 FOR_EACH_FRAME (rest, frame)
5040 {
5041 struct frame *f = XFRAME (frame);
5042
5043 if (FRAME_W32_P (f) && !EQ (frame, tip_frame))
5044 frames = Fcons (frame, frames);
5045 }
5046 attributes = Fcons (Fcons (Qframes, frames), attributes);
5047
5048 pixel_width = x_display_pixel_width (dpyinfo);
5049 pixel_height = x_display_pixel_height (dpyinfo);
5050
5051 hdc = GetDC (NULL);
5052 mm_per_pixel = ((double) GetDeviceCaps (hdc, HORZSIZE)
5053 / GetDeviceCaps (hdc, HORZRES));
5054 width_mm = pixel_width * mm_per_pixel + 0.5;
5055 mm_per_pixel = ((double) GetDeviceCaps (hdc, VERTSIZE)
5056 / GetDeviceCaps (hdc, VERTRES));
5057 height_mm = pixel_height * mm_per_pixel + 0.5;
5058 ReleaseDC (NULL, hdc);
5059 attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)),
5060 attributes);
5061
5062 /* GetSystemMetrics below may return 0 for Windows 95 or NT 4.0, but
5063 we don't care. */
5064 geometry = list4i (GetSystemMetrics (SM_XVIRTUALSCREEN),
5065 GetSystemMetrics (SM_YVIRTUALSCREEN),
5066 pixel_width, pixel_height);
5067 if (SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0))
5068 workarea = list4i (workarea_rect.left, workarea_rect.top,
5069 workarea_rect.right - workarea_rect.left,
5070 workarea_rect.bottom - workarea_rect.top);
5071 else
5072 workarea = geometry;
5073 attributes = Fcons (Fcons (Qworkarea, workarea), attributes);
5074
5075 attributes = Fcons (Fcons (Qgeometry, geometry), attributes);
5076
5077 return list1 (attributes);
5078}
5079
5080DEFUN ("w32-display-monitor-attributes-list", Fw32_display_monitor_attributes_list,
5081 Sw32_display_monitor_attributes_list,
5082 0, 1, 0,
5083 doc: /* Return a list of physical monitor attributes on the W32 display DISPLAY.
5084
5085The optional argument DISPLAY specifies which display to ask about.
5086DISPLAY should be either a frame or a display name (a string).
5087If omitted or nil, that stands for the selected frame's display.
5088
5089Internal use only, use `display-monitor-attributes-list' instead. */)
5090 (Lisp_Object display)
5091{
5092 struct w32_display_info *dpyinfo = check_x_display_info (display);
5093 Lisp_Object attributes_list;
5094
5095 block_input ();
5096 attributes_list = w32_display_monitor_attributes_list ();
5097 if (NILP (attributes_list))
5098 attributes_list = w32_display_monitor_attributes_list_fallback (dpyinfo);
5099 unblock_input ();
5100
5101 return attributes_list;
5102}
5103
4868DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0, 5104DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
4869 doc: /* Set the sound generated when the bell is rung. 5105 doc: /* Set the sound generated when the bell is rung.
4870SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent 5106SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
@@ -7357,6 +7593,10 @@ syms_of_w32fns (void)
7357 DEFSYM (Qcontrol, "control"); 7593 DEFSYM (Qcontrol, "control");
7358 DEFSYM (Qshift, "shift"); 7594 DEFSYM (Qshift, "shift");
7359 DEFSYM (Qfont_param, "font-parameter"); 7595 DEFSYM (Qfont_param, "font-parameter");
7596 DEFSYM (Qgeometry, "geometry");
7597 DEFSYM (Qworkarea, "workarea");
7598 DEFSYM (Qmm_size, "mm-size");
7599 DEFSYM (Qframes, "frames");
7360 /* This is the end of symbol initialization. */ 7600 /* This is the end of symbol initialization. */
7361 7601
7362 7602
@@ -7646,6 +7886,7 @@ only be necessary if the default setting causes problems. */);
7646 7886
7647 defsubr (&Sw32_define_rgb_color); 7887 defsubr (&Sw32_define_rgb_color);
7648 defsubr (&Sw32_default_color_map); 7888 defsubr (&Sw32_default_color_map);
7889 defsubr (&Sw32_display_monitor_attributes_list);
7649 defsubr (&Sw32_send_sys_command); 7890 defsubr (&Sw32_send_sys_command);
7650 defsubr (&Sw32_shell_execute); 7891 defsubr (&Sw32_shell_execute);
7651 defsubr (&Sw32_register_hot_key); 7892 defsubr (&Sw32_register_hot_key);
@@ -7707,6 +7948,8 @@ globals_of_w32fns (void)
7707 GetProcAddress (user32_lib, "GetMonitorInfoA"); 7948 GetProcAddress (user32_lib, "GetMonitorInfoA");
7708 monitor_from_window_fn = (MonitorFromWindow_Proc) 7949 monitor_from_window_fn = (MonitorFromWindow_Proc)
7709 GetProcAddress (user32_lib, "MonitorFromWindow"); 7950 GetProcAddress (user32_lib, "MonitorFromWindow");
7951 enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
7952 GetProcAddress (user32_lib, "EnumDisplayMonitors");
7710 7953
7711 { 7954 {
7712 HMODULE imm32_lib = GetModuleHandle ("imm32.dll"); 7955 HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
diff --git a/src/w32term.c b/src/w32term.c
index d3174c65bf0..732a4f4bfef 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -143,6 +143,15 @@ BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
143#define WS_EX_LAYERED 0x80000 143#define WS_EX_LAYERED 0x80000
144#endif 144#endif
145 145
146/* SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN are not defined on 95 and
147 NT4. */
148#ifndef SM_CXVIRTUALSCREEN
149#define SM_CXVIRTUALSCREEN 78
150#endif
151#ifndef SM_CYVIRTUALSCREEN
152#define SM_CYVIRTUALSCREEN 79
153#endif
154
146/* This is a frame waiting to be autoraised, within w32_read_socket. */ 155/* This is a frame waiting to be autoraised, within w32_read_socket. */
147struct frame *pending_autoraise_frame; 156struct frame *pending_autoraise_frame;
148 157
@@ -519,18 +528,24 @@ x_set_frame_alpha (struct frame *f)
519int 528int
520x_display_pixel_height (struct w32_display_info *dpyinfo) 529x_display_pixel_height (struct w32_display_info *dpyinfo)
521{ 530{
522 HDC dc = GetDC (NULL); 531 int pixels = GetSystemMetrics (SM_CYVIRTUALSCREEN);
523 int pixels = GetDeviceCaps (dc, VERTRES); 532
524 ReleaseDC (NULL, dc); 533 if (pixels == 0)
534 /* Fallback for Windows 95 or NT 4.0. */
535 pixels = GetSystemMetrics (SM_CYSCREEN);
536
525 return pixels; 537 return pixels;
526} 538}
527 539
528int 540int
529x_display_pixel_width (struct w32_display_info *dpyinfo) 541x_display_pixel_width (struct w32_display_info *dpyinfo)
530{ 542{
531 HDC dc = GetDC (NULL); 543 int pixels = GetSystemMetrics (SM_CXVIRTUALSCREEN);
532 int pixels = GetDeviceCaps (dc, HORZRES); 544
533 ReleaseDC (NULL, dc); 545 if (pixels == 0)
546 /* Fallback for Windows 95 or NT 4.0. */
547 pixels = GetSystemMetrics (SM_CXSCREEN);
548
534 return pixels; 549 return pixels;
535} 550}
536 551
@@ -5159,7 +5174,10 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
5159 the current matrix is invalid or such, give up. */ 5174 the current matrix is invalid or such, give up. */
5160 cursor_glyph = get_phys_cursor_glyph (w); 5175 cursor_glyph = get_phys_cursor_glyph (w);
5161 if (cursor_glyph == NULL) 5176 if (cursor_glyph == NULL)
5162 return; 5177 {
5178 DeleteObject (hb);
5179 return;
5180 }
5163 5181
5164 /* Compute frame-relative coordinates for phys cursor. */ 5182 /* Compute frame-relative coordinates for phys cursor. */
5165 get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h); 5183 get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h);
@@ -6606,7 +6624,7 @@ w32_initialize (void)
6606 } 6624 }
6607 6625
6608#ifdef CYGWIN 6626#ifdef CYGWIN
6609 if ((w32_message_fd = open ("/dev/windows", O_RDWR | O_CLOEXEC)) == -1) 6627 if ((w32_message_fd = emacs_open ("/dev/windows", O_RDWR, 0)) == -1)
6610 fatal ("opening /dev/windows: %s", strerror (errno)); 6628 fatal ("opening /dev/windows: %s", strerror (errno));
6611#endif /* CYGWIN */ 6629#endif /* CYGWIN */
6612 6630
diff --git a/src/window.c b/src/window.c
index f02aa1d89a0..5c5d2b8e138 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4374,6 +4374,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4374 int vscrolled = 0; 4374 int vscrolled = 0;
4375 int x, y, rtop, rbot, rowh, vpos; 4375 int x, y, rtop, rbot, rowh, vpos;
4376 void *itdata = NULL; 4376 void *itdata = NULL;
4377 int window_total_lines;
4378 int frame_line_height = default_line_pixel_height (w);
4377 4379
4378 SET_TEXT_POS_FROM_MARKER (start, w->start); 4380 SET_TEXT_POS_FROM_MARKER (start, w->start);
4379 /* Scrolling a minibuffer window via scroll bar when the echo area 4381 /* Scrolling a minibuffer window via scroll bar when the echo area
@@ -4417,7 +4419,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4417 if (rtop || rbot) /* partially visible */ 4419 if (rtop || rbot) /* partially visible */
4418 { 4420 {
4419 int px; 4421 int px;
4420 int dy = WINDOW_FRAME_LINE_HEIGHT (w); 4422 int dy = frame_line_height;
4421 if (whole) 4423 if (whole)
4422 dy = max ((window_box_height (w) 4424 dy = max ((window_box_height (w)
4423 - next_screen_context_lines * dy), 4425 - next_screen_context_lines * dy),
@@ -4503,7 +4505,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4503 if (whole) 4505 if (whole)
4504 { 4506 {
4505 ptrdiff_t start_pos = IT_CHARPOS (it); 4507 ptrdiff_t start_pos = IT_CHARPOS (it);
4506 int dy = WINDOW_FRAME_LINE_HEIGHT (w); 4508 int dy = frame_line_height;
4507 dy = max ((window_box_height (w) 4509 dy = max ((window_box_height (w)
4508 - next_screen_context_lines * dy), 4510 - next_screen_context_lines * dy),
4509 dy) * n; 4511 dy) * n;
@@ -4620,10 +4622,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4620 /* Move PT out of scroll margins. 4622 /* Move PT out of scroll margins.
4621 This code wants current_y to be zero at the window start position 4623 This code wants current_y to be zero at the window start position
4622 even if there is a header line. */ 4624 even if there is a header line. */
4625 window_total_lines
4626 = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height;
4623 this_scroll_margin = max (0, scroll_margin); 4627 this_scroll_margin = max (0, scroll_margin);
4624 this_scroll_margin 4628 this_scroll_margin
4625 = min (this_scroll_margin, w->total_lines / 4); 4629 = min (this_scroll_margin, window_total_lines / 4);
4626 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); 4630 this_scroll_margin *= frame_line_height;
4627 4631
4628 if (n > 0) 4632 if (n > 0)
4629 { 4633 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 88a806fa268..9aae37d48c1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1239,6 +1239,52 @@ Value is the height in pixels of the line at point. */)
1239 return make_number (line_bottom_y (&it)); 1239 return make_number (line_bottom_y (&it));
1240} 1240}
1241 1241
1242/* Return the default pixel height of text lines in window W. The
1243 value is the canonical height of the W frame's default font, plus
1244 any extra space required by the line-spacing variable or frame
1245 parameter.
1246
1247 Implementation note: this ignores any line-spacing text properties
1248 put on the newline characters. This is because those properties
1249 only affect the _screen_ line ending in the newline (i.e., in a
1250 continued line, only the last screen line will be affected), which
1251 means only a small number of lines in a buffer can ever use this
1252 feature. Since this function is used to compute the default pixel
1253 equivalent of text lines in a window, we can safely ignore those
1254 few lines. For the same reasons, we ignore the line-height
1255 properties. */
1256int
1257default_line_pixel_height (struct window *w)
1258{
1259 struct frame *f = WINDOW_XFRAME (w);
1260 int height = FRAME_LINE_HEIGHT (f);
1261
1262 if (!FRAME_INITIAL_P (f) && BUFFERP (w->contents))
1263 {
1264 struct buffer *b = XBUFFER (w->contents);
1265 Lisp_Object val = BVAR (b, extra_line_spacing);
1266
1267 if (NILP (val))
1268 val = BVAR (&buffer_defaults, extra_line_spacing);
1269 if (!NILP (val))
1270 {
1271 if (RANGED_INTEGERP (0, val, INT_MAX))
1272 height += XFASTINT (val);
1273 else if (FLOATP (val))
1274 {
1275 int addon = XFLOAT_DATA (val) * height + 0.5;
1276
1277 if (addon >= 0)
1278 height += addon;
1279 }
1280 }
1281 else
1282 height += f->extra_line_spacing;
1283 }
1284
1285 return height;
1286}
1287
1242/* Subroutine of pos_visible_p below. Extracts a display string, if 1288/* Subroutine of pos_visible_p below. Extracts a display string, if
1243 any, from the display spec given as its argument. */ 1289 any, from the display spec given as its argument. */
1244static Lisp_Object 1290static Lisp_Object
@@ -1373,8 +1419,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1373 struct it save_it = it; 1419 struct it save_it = it;
1374 /* Why 10? because we don't know how many canonical lines 1420 /* Why 10? because we don't know how many canonical lines
1375 will the height of the next line(s) be. So we guess. */ 1421 will the height of the next line(s) be. So we guess. */
1376 int ten_more_lines = 1422 int ten_more_lines = 10 * default_line_pixel_height (w);
1377 10 * FRAME_LINE_HEIGHT (XFRAME (WINDOW_FRAME (w)));
1378 1423
1379 move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1, 1424 move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1,
1380 MOVE_TO_POS | MOVE_TO_Y); 1425 MOVE_TO_POS | MOVE_TO_Y);
@@ -9112,7 +9157,7 @@ move_it_vertically_backward (struct it *it, int dy)
9112 start_pos = IT_CHARPOS (*it); 9157 start_pos = IT_CHARPOS (*it);
9113 9158
9114 /* Estimate how many newlines we must move back. */ 9159 /* Estimate how many newlines we must move back. */
9115 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); 9160 nlines = max (1, dy / default_line_pixel_height (it->w));
9116 if (it->line_wrap == TRUNCATE) 9161 if (it->line_wrap == TRUNCATE)
9117 pos_limit = BEGV; 9162 pos_limit = BEGV;
9118 else 9163 else
@@ -12600,6 +12645,7 @@ static void debug_method_add (struct window *, char const *, ...)
12600static void 12645static void
12601debug_method_add (struct window *w, char const *fmt, ...) 12646debug_method_add (struct window *w, char const *fmt, ...)
12602{ 12647{
12648 void *ptr = w;
12603 char *method = w->desired_matrix->method; 12649 char *method = w->desired_matrix->method;
12604 int len = strlen (method); 12650 int len = strlen (method);
12605 int size = sizeof w->desired_matrix->method; 12651 int size = sizeof w->desired_matrix->method;
@@ -12618,7 +12664,7 @@ debug_method_add (struct window *w, char const *fmt, ...)
12618 12664
12619 if (trace_redisplay_p) 12665 if (trace_redisplay_p)
12620 fprintf (stderr, "%p (%s): %s\n", 12666 fprintf (stderr, "%p (%s): %s\n",
12621 w, 12667 ptr,
12622 ((BUFFERP (w->contents) 12668 ((BUFFERP (w->contents)
12623 && STRINGP (BVAR (XBUFFER (w->contents), name))) 12669 && STRINGP (BVAR (XBUFFER (w->contents), name)))
12624 ? SSDATA (BVAR (XBUFFER (w->contents), name)) 12670 ? SSDATA (BVAR (XBUFFER (w->contents), name))
@@ -14599,6 +14645,9 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14599 Lisp_Object aggressive; 14645 Lisp_Object aggressive;
14600 /* We will never try scrolling more than this number of lines. */ 14646 /* We will never try scrolling more than this number of lines. */
14601 int scroll_limit = SCROLL_LIMIT; 14647 int scroll_limit = SCROLL_LIMIT;
14648 int frame_line_height = default_line_pixel_height (w);
14649 int window_total_lines
14650 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
14602 14651
14603#ifdef GLYPH_DEBUG 14652#ifdef GLYPH_DEBUG
14604 debug_method_add (w, "try_scrolling"); 14653 debug_method_add (w, "try_scrolling");
@@ -14609,8 +14658,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14609 /* Compute scroll margin height in pixels. We scroll when point is 14658 /* Compute scroll margin height in pixels. We scroll when point is
14610 within this distance from the top or bottom of the window. */ 14659 within this distance from the top or bottom of the window. */
14611 if (scroll_margin > 0) 14660 if (scroll_margin > 0)
14612 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 14661 this_scroll_margin = min (scroll_margin, window_total_lines / 4)
14613 * FRAME_LINE_HEIGHT (f); 14662 * frame_line_height;
14614 else 14663 else
14615 this_scroll_margin = 0; 14664 this_scroll_margin = 0;
14616 14665
@@ -14621,19 +14670,19 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14621 if (arg_scroll_conservatively > scroll_limit) 14670 if (arg_scroll_conservatively > scroll_limit)
14622 { 14671 {
14623 arg_scroll_conservatively = scroll_limit + 1; 14672 arg_scroll_conservatively = scroll_limit + 1;
14624 scroll_max = scroll_limit * FRAME_LINE_HEIGHT (f); 14673 scroll_max = scroll_limit * frame_line_height;
14625 } 14674 }
14626 else if (scroll_step || arg_scroll_conservatively || temp_scroll_step) 14675 else if (scroll_step || arg_scroll_conservatively || temp_scroll_step)
14627 /* Compute how much we should try to scroll maximally to bring 14676 /* Compute how much we should try to scroll maximally to bring
14628 point into view. */ 14677 point into view. */
14629 scroll_max = (max (scroll_step, 14678 scroll_max = (max (scroll_step,
14630 max (arg_scroll_conservatively, temp_scroll_step)) 14679 max (arg_scroll_conservatively, temp_scroll_step))
14631 * FRAME_LINE_HEIGHT (f)); 14680 * frame_line_height);
14632 else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively)) 14681 else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively))
14633 || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))) 14682 || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)))
14634 /* We're trying to scroll because of aggressive scrolling but no 14683 /* We're trying to scroll because of aggressive scrolling but no
14635 scroll_step is set. Choose an arbitrary one. */ 14684 scroll_step is set. Choose an arbitrary one. */
14636 scroll_max = 10 * FRAME_LINE_HEIGHT (f); 14685 scroll_max = 10 * frame_line_height;
14637 else 14686 else
14638 scroll_max = 0; 14687 scroll_max = 0;
14639 14688
@@ -14648,7 +14697,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14648 either that ypos or PT, whichever comes first. */ 14697 either that ypos or PT, whichever comes first. */
14649 start_display (&it, w, startp); 14698 start_display (&it, w, startp);
14650 scroll_margin_y = it.last_visible_y - this_scroll_margin 14699 scroll_margin_y = it.last_visible_y - this_scroll_margin
14651 - FRAME_LINE_HEIGHT (f) * extra_scroll_margin_lines; 14700 - frame_line_height * extra_scroll_margin_lines;
14652 move_it_to (&it, PT, -1, scroll_margin_y - 1, -1, 14701 move_it_to (&it, PT, -1, scroll_margin_y - 1, -1,
14653 (MOVE_TO_POS | MOVE_TO_Y)); 14702 (MOVE_TO_POS | MOVE_TO_Y));
14654 14703
@@ -14660,7 +14709,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14660 the user limited scrolling by a small number of lines, but 14709 the user limited scrolling by a small number of lines, but
14661 always finds PT if scroll_conservatively is set to a large 14710 always finds PT if scroll_conservatively is set to a large
14662 number, such as most-positive-fixnum. */ 14711 number, such as most-positive-fixnum. */
14663 int slack = max (scroll_max, 10 * FRAME_LINE_HEIGHT (f)); 14712 int slack = max (scroll_max, 10 * frame_line_height);
14664 int y_to_move = it.last_visible_y + slack; 14713 int y_to_move = it.last_visible_y + slack;
14665 14714
14666 /* Compute the distance from the scroll margin to PT or to 14715 /* Compute the distance from the scroll margin to PT or to
@@ -14687,8 +14736,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14687 move it down by scroll_step. */ 14736 move it down by scroll_step. */
14688 if (arg_scroll_conservatively) 14737 if (arg_scroll_conservatively)
14689 amount_to_scroll 14738 amount_to_scroll
14690 = min (max (dy, FRAME_LINE_HEIGHT (f)), 14739 = min (max (dy, frame_line_height),
14691 FRAME_LINE_HEIGHT (f) * arg_scroll_conservatively); 14740 frame_line_height * arg_scroll_conservatively);
14692 else if (scroll_step || temp_scroll_step) 14741 else if (scroll_step || temp_scroll_step)
14693 amount_to_scroll = scroll_max; 14742 amount_to_scroll = scroll_max;
14694 else 14743 else
@@ -14785,7 +14834,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14785 start_display (&it, w, pos); 14834 start_display (&it, w, pos);
14786 y0 = it.current_y; 14835 y0 = it.current_y;
14787 y_to_move = max (it.last_visible_y, 14836 y_to_move = max (it.last_visible_y,
14788 max (scroll_max, 10 * FRAME_LINE_HEIGHT (f))); 14837 max (scroll_max, 10 * frame_line_height));
14789 move_it_to (&it, CHARPOS (scroll_margin_pos), 0, 14838 move_it_to (&it, CHARPOS (scroll_margin_pos), 0,
14790 y_to_move, -1, 14839 y_to_move, -1,
14791 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 14840 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
@@ -14801,7 +14850,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14801 start_display (&it, w, startp); 14850 start_display (&it, w, startp);
14802 14851
14803 if (arg_scroll_conservatively) 14852 if (arg_scroll_conservatively)
14804 amount_to_scroll = max (dy, FRAME_LINE_HEIGHT (f) * 14853 amount_to_scroll = max (dy, frame_line_height *
14805 max (scroll_step, temp_scroll_step)); 14854 max (scroll_step, temp_scroll_step));
14806 else if (scroll_step || temp_scroll_step) 14855 else if (scroll_step || temp_scroll_step)
14807 amount_to_scroll = scroll_max; 14856 amount_to_scroll = scroll_max;
@@ -15021,6 +15070,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15021 { 15070 {
15022 int this_scroll_margin, top_scroll_margin; 15071 int this_scroll_margin, top_scroll_margin;
15023 struct glyph_row *row = NULL; 15072 struct glyph_row *row = NULL;
15073 int frame_line_height = default_line_pixel_height (w);
15074 int window_total_lines
15075 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
15024 15076
15025#ifdef GLYPH_DEBUG 15077#ifdef GLYPH_DEBUG
15026 debug_method_add (w, "cursor movement"); 15078 debug_method_add (w, "cursor movement");
@@ -15030,8 +15082,8 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15030 of the window. This is a pixel value. */ 15082 of the window. This is a pixel value. */
15031 if (scroll_margin > 0) 15083 if (scroll_margin > 0)
15032 { 15084 {
15033 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 15085 this_scroll_margin = min (scroll_margin, window_total_lines / 4);
15034 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 15086 this_scroll_margin *= frame_line_height;
15035 } 15087 }
15036 else 15088 else
15037 this_scroll_margin = 0; 15089 this_scroll_margin = 0;
@@ -15373,6 +15425,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15373 int centering_position = -1; 15425 int centering_position = -1;
15374 int last_line_misfit = 0; 15426 int last_line_misfit = 0;
15375 ptrdiff_t beg_unchanged, end_unchanged; 15427 ptrdiff_t beg_unchanged, end_unchanged;
15428 int frame_line_height;
15376 15429
15377 SET_TEXT_POS (lpoint, PT, PT_BYTE); 15430 SET_TEXT_POS (lpoint, PT, PT_BYTE);
15378 opoint = lpoint; 15431 opoint = lpoint;
@@ -15387,6 +15440,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15387 15440
15388 restart: 15441 restart:
15389 reconsider_clip_changes (w, buffer); 15442 reconsider_clip_changes (w, buffer);
15443 frame_line_height = default_line_pixel_height (w);
15390 15444
15391 /* Has the mode line to be updated? */ 15445 /* Has the mode line to be updated? */
15392 update_mode_line = (w->update_mode_line 15446 update_mode_line = (w->update_mode_line
@@ -15622,8 +15676,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15622 /* Some people insist on not letting point enter the scroll 15676 /* Some people insist on not letting point enter the scroll
15623 margin, even though this part handles windows that didn't 15677 margin, even though this part handles windows that didn't
15624 scroll at all. */ 15678 scroll at all. */
15625 int margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 15679 int window_total_lines
15626 int pixel_margin = margin * FRAME_LINE_HEIGHT (f); 15680 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
15681 int margin = min (scroll_margin, window_total_lines / 4);
15682 int pixel_margin = margin * frame_line_height;
15627 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w); 15683 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w);
15628 15684
15629 /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop 15685 /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop
@@ -15634,7 +15690,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15634 new_vpos 15690 new_vpos
15635 = pixel_margin + (header_line 15691 = pixel_margin + (header_line
15636 ? CURRENT_HEADER_LINE_HEIGHT (w) 15692 ? CURRENT_HEADER_LINE_HEIGHT (w)
15637 : 0) + FRAME_LINE_HEIGHT (f); 15693 : 0) + frame_line_height;
15638 else 15694 else
15639 { 15695 {
15640 int window_height = window_box_height (w); 15696 int window_height = window_box_height (w);
@@ -15883,9 +15939,11 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15883 it.current_y = it.last_visible_y; 15939 it.current_y = it.last_visible_y;
15884 if (centering_position < 0) 15940 if (centering_position < 0)
15885 { 15941 {
15942 int window_total_lines
15943 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
15886 int margin = 15944 int margin =
15887 scroll_margin > 0 15945 scroll_margin > 0
15888 ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 15946 ? min (scroll_margin, window_total_lines / 4)
15889 : 0; 15947 : 0;
15890 ptrdiff_t margin_pos = CHARPOS (startp); 15948 ptrdiff_t margin_pos = CHARPOS (startp);
15891 Lisp_Object aggressive; 15949 Lisp_Object aggressive;
@@ -15907,7 +15965,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15907 15965
15908 SAVE_IT (it1, it, it1data); 15966 SAVE_IT (it1, it, it1data);
15909 start_display (&it1, w, startp); 15967 start_display (&it1, w, startp);
15910 move_it_vertically (&it1, margin * FRAME_LINE_HEIGHT (f)); 15968 move_it_vertically (&it1, margin * frame_line_height);
15911 margin_pos = IT_CHARPOS (it1); 15969 margin_pos = IT_CHARPOS (it1);
15912 RESTORE_IT (&it, &it, it1data); 15970 RESTORE_IT (&it, &it, it1data);
15913 } 15971 }
@@ -15943,15 +16001,15 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15943 if (pt_offset) 16001 if (pt_offset)
15944 centering_position -= pt_offset; 16002 centering_position -= pt_offset;
15945 centering_position -= 16003 centering_position -=
15946 FRAME_LINE_HEIGHT (f) * (1 + margin + (last_line_misfit != 0)) 16004 frame_line_height * (1 + margin + (last_line_misfit != 0))
15947 + WINDOW_HEADER_LINE_HEIGHT (w); 16005 + WINDOW_HEADER_LINE_HEIGHT (w);
15948 /* Don't let point enter the scroll margin near top of 16006 /* Don't let point enter the scroll margin near top of
15949 the window. */ 16007 the window. */
15950 if (centering_position < margin * FRAME_LINE_HEIGHT (f)) 16008 if (centering_position < margin * frame_line_height)
15951 centering_position = margin * FRAME_LINE_HEIGHT (f); 16009 centering_position = margin * frame_line_height;
15952 } 16010 }
15953 else 16011 else
15954 centering_position = margin * FRAME_LINE_HEIGHT (f) + pt_offset; 16012 centering_position = margin * frame_line_height + pt_offset;
15955 } 16013 }
15956 else 16014 else
15957 /* Set the window start half the height of the window backward 16015 /* Set the window start half the height of the window backward
@@ -16056,11 +16114,13 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16056 make that row fully visible and out of the margin. */ 16114 make that row fully visible and out of the margin. */
16057 if (scroll_conservatively > SCROLL_LIMIT) 16115 if (scroll_conservatively > SCROLL_LIMIT)
16058 { 16116 {
16117 int window_total_lines
16118 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) * frame_line_height;
16059 int margin = 16119 int margin =
16060 scroll_margin > 0 16120 scroll_margin > 0
16061 ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 16121 ? min (scroll_margin, window_total_lines / 4)
16062 : 0; 16122 : 0;
16063 int move_down = w->cursor.vpos >= WINDOW_TOTAL_LINES (w) / 2; 16123 int move_down = w->cursor.vpos >= window_total_lines / 2;
16064 16124
16065 move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1)); 16125 move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1));
16066 clear_glyph_matrix (w->desired_matrix); 16126 clear_glyph_matrix (w->desired_matrix);
@@ -16247,6 +16307,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16247 struct it it; 16307 struct it it;
16248 struct glyph_row *last_text_row = NULL; 16308 struct glyph_row *last_text_row = NULL;
16249 struct frame *f = XFRAME (w->frame); 16309 struct frame *f = XFRAME (w->frame);
16310 int frame_line_height = default_line_pixel_height (w);
16250 16311
16251 /* Make POS the new window start. */ 16312 /* Make POS the new window start. */
16252 set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); 16313 set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos));
@@ -16279,11 +16340,13 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16279 && !MINI_WINDOW_P (w)) 16340 && !MINI_WINDOW_P (w))
16280 { 16341 {
16281 int this_scroll_margin; 16342 int this_scroll_margin;
16343 int window_total_lines
16344 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
16282 16345
16283 if (scroll_margin > 0) 16346 if (scroll_margin > 0)
16284 { 16347 {
16285 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 16348 this_scroll_margin = min (scroll_margin, window_total_lines / 4);
16286 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 16349 this_scroll_margin *= frame_line_height;
16287 } 16350 }
16288 else 16351 else
16289 this_scroll_margin = 0; 16352 this_scroll_margin = 0;
@@ -17598,10 +17661,13 @@ try_window_id (struct window *w)
17598 /* Don't let the cursor end in the scroll margins. */ 17661 /* Don't let the cursor end in the scroll margins. */
17599 { 17662 {
17600 int this_scroll_margin, cursor_height; 17663 int this_scroll_margin, cursor_height;
17664 int frame_line_height = default_line_pixel_height (w);
17665 int window_total_lines
17666 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (it.f) / frame_line_height;
17601 17667
17602 this_scroll_margin = 17668 this_scroll_margin =
17603 max (0, min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4)); 17669 max (0, min (scroll_margin, window_total_lines / 4));
17604 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); 17670 this_scroll_margin *= frame_line_height;
17605 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; 17671 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
17606 17672
17607 if ((w->cursor.y < this_scroll_margin 17673 if ((w->cursor.y < this_scroll_margin
diff --git a/src/xfaces.c b/src/xfaces.c
index b2ace1be14e..4b42cb7dc40 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -200,10 +200,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
200 used to fill in unspecified attributes of the default face. */ 200 used to fill in unspecified attributes of the default face. */
201 201
202#include <config.h> 202#include <config.h>
203#include <stdio.h> 203#include "sysstdio.h"
204#include <sys/types.h> 204#include <sys/types.h>
205#include <sys/stat.h> 205#include <sys/stat.h>
206#include <stdio.h> /* This needs to be before termchar.h */
207 206
208#include "lisp.h" 207#include "lisp.h"
209#include "character.h" 208#include "character.h"
@@ -6291,7 +6290,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6291 CHECK_STRING (filename); 6290 CHECK_STRING (filename);
6292 abspath = Fexpand_file_name (filename, Qnil); 6291 abspath = Fexpand_file_name (filename, Qnil);
6293 6292
6294 fp = fopen (SSDATA (abspath), "rt"); 6293 fp = emacs_fopen (SSDATA (abspath), "rt");
6295 if (fp) 6294 if (fp)
6296 { 6295 {
6297 char buf[512]; 6296 char buf[512];
diff --git a/src/xrdb.c b/src/xrdb.c
index c25c25d6f33..7c9cd53fa8c 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -634,10 +634,7 @@ member (char *elt, List list)
634static void 634static void
635fatal (char *msg, char *prog) 635fatal (char *msg, char *prog)
636{ 636{
637 if (errno) 637 fprintf (stderr, msg, prog);
638 perror (prog);
639
640 (void) fprintf (stderr, msg, prog);
641 exit (1); 638 exit (1);
642} 639}
643 640
diff --git a/src/xsettings.c b/src/xsettings.c
index f48c49dbafe..45f8435d9f4 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -170,7 +170,7 @@ enum {
170 SEEN_HINTSTYLE = 0x10, 170 SEEN_HINTSTYLE = 0x10,
171 SEEN_DPI = 0x20, 171 SEEN_DPI = 0x20,
172 SEEN_FONT = 0x40, 172 SEEN_FONT = 0x40,
173 SEEN_TB_STYLE = 0x80, 173 SEEN_TB_STYLE = 0x80
174}; 174};
175struct xsettings 175struct xsettings
176{ 176{
@@ -687,7 +687,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
687 { 687 {
688 static char const format[] = 688 static char const format[] =
689 "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, " 689 "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, "
690 "Hintstyle: %d, DPI: %lf"; 690 "Hintstyle: %d, DPI: %f";
691 enum 691 enum
692 { 692 {
693 d_formats = 5, 693 d_formats = 5,
@@ -696,7 +696,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
696 max_f_integer_digits = DBL_MAX_10_EXP + 1, 696 max_f_integer_digits = DBL_MAX_10_EXP + 1,
697 f_precision = 6, 697 f_precision = 6,
698 lf_growth = (sizeof "-." + max_f_integer_digits + f_precision 698 lf_growth = (sizeof "-." + max_f_integer_digits + f_precision
699 - sizeof "%lf") 699 - sizeof "%f")
700 }; 700 };
701 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; 701 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
702 702
diff --git a/src/xterm.c b/src/xterm.c
index 3755b478dbc..547bdbe8333 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -72,7 +72,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
72#include "atimer.h" 72#include "atimer.h"
73#include "keymap.h" 73#include "keymap.h"
74#include "font.h" 74#include "font.h"
75#include "fontset.h"
76#include "xsettings.h" 75#include "xsettings.h"
77#include "xgselect.h" 76#include "xgselect.h"
78#include "sysselect.h" 77#include "sysselect.h"
@@ -2651,7 +2650,10 @@ x_draw_underwave (struct glyph_string *s)
2651 2650
2652 /* Find and set clipping rectangle */ 2651 /* Find and set clipping rectangle */
2653 2652
2654 wave_clip = (XRectangle){ x0, y0, width, wave_height }; 2653 wave_clip.x = x0;
2654 wave_clip.y = y0;
2655 wave_clip.width = width;
2656 wave_clip.height = wave_height;
2655 get_glyph_string_clip_rect (s, &string_clip); 2657 get_glyph_string_clip_rect (s, &string_clip);
2656 2658
2657 if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) 2659 if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
@@ -10210,71 +10212,73 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10210 } 10212 }
10211 10213
10212 { 10214 {
10213 const struct 10215 static const struct
10214 { 10216 {
10215 const char *name; 10217 const char *name;
10216 Atom *atom; 10218 int offset;
10217 } atom_refs[] = { 10219 } atom_refs[] = {
10218 { "WM_PROTOCOLS", &dpyinfo->Xatom_wm_protocols }, 10220#define ATOM_REFS_INIT(string, member) \
10219 { "WM_TAKE_FOCUS", &dpyinfo->Xatom_wm_take_focus }, 10221 { string, offsetof (struct x_display_info, member) },
10220 { "WM_SAVE_YOURSELF", &dpyinfo->Xatom_wm_save_yourself }, 10222 ATOM_REFS_INIT ("WM_PROTOCOLS", Xatom_wm_protocols)
10221 { "WM_DELETE_WINDOW", &dpyinfo->Xatom_wm_delete_window }, 10223 ATOM_REFS_INIT ("WM_TAKE_FOCUS", Xatom_wm_take_focus)
10222 { "WM_CHANGE_STATE", &dpyinfo->Xatom_wm_change_state }, 10224 ATOM_REFS_INIT ("WM_SAVE_YOURSELF", Xatom_wm_save_yourself)
10223 { "WM_CONFIGURE_DENIED", &dpyinfo->Xatom_wm_configure_denied }, 10225 ATOM_REFS_INIT ("WM_DELETE_WINDOW", Xatom_wm_delete_window)
10224 { "WM_MOVED", &dpyinfo->Xatom_wm_window_moved }, 10226 ATOM_REFS_INIT ("WM_CHANGE_STATE", Xatom_wm_change_state)
10225 { "WM_CLIENT_LEADER", &dpyinfo->Xatom_wm_client_leader }, 10227 ATOM_REFS_INIT ("WM_CONFIGURE_DENIED", Xatom_wm_configure_denied)
10226 { "Editres", &dpyinfo->Xatom_editres }, 10228 ATOM_REFS_INIT ("WM_MOVED", Xatom_wm_window_moved)
10227 { "CLIPBOARD", &dpyinfo->Xatom_CLIPBOARD }, 10229 ATOM_REFS_INIT ("WM_CLIENT_LEADER", Xatom_wm_client_leader)
10228 { "TIMESTAMP", &dpyinfo->Xatom_TIMESTAMP }, 10230 ATOM_REFS_INIT ("Editres", Xatom_editres)
10229 { "TEXT", &dpyinfo->Xatom_TEXT }, 10231 ATOM_REFS_INIT ("CLIPBOARD", Xatom_CLIPBOARD)
10230 { "COMPOUND_TEXT", &dpyinfo->Xatom_COMPOUND_TEXT }, 10232 ATOM_REFS_INIT ("TIMESTAMP", Xatom_TIMESTAMP)
10231 { "UTF8_STRING", &dpyinfo->Xatom_UTF8_STRING }, 10233 ATOM_REFS_INIT ("TEXT", Xatom_TEXT)
10232 { "DELETE", &dpyinfo->Xatom_DELETE }, 10234 ATOM_REFS_INIT ("COMPOUND_TEXT", Xatom_COMPOUND_TEXT)
10233 { "MULTIPLE", &dpyinfo->Xatom_MULTIPLE }, 10235 ATOM_REFS_INIT ("UTF8_STRING", Xatom_UTF8_STRING)
10234 { "INCR", &dpyinfo->Xatom_INCR }, 10236 ATOM_REFS_INIT ("DELETE", Xatom_DELETE)
10235 { "_EMACS_TMP_", &dpyinfo->Xatom_EMACS_TMP }, 10237 ATOM_REFS_INIT ("MULTIPLE", Xatom_MULTIPLE)
10236 { "TARGETS", &dpyinfo->Xatom_TARGETS }, 10238 ATOM_REFS_INIT ("INCR", Xatom_INCR)
10237 { "NULL", &dpyinfo->Xatom_NULL }, 10239 ATOM_REFS_INIT ("_EMACS_TMP_", Xatom_EMACS_TMP)
10238 { "ATOM", &dpyinfo->Xatom_ATOM }, 10240 ATOM_REFS_INIT ("TARGETS", Xatom_TARGETS)
10239 { "ATOM_PAIR", &dpyinfo->Xatom_ATOM_PAIR }, 10241 ATOM_REFS_INIT ("NULL", Xatom_NULL)
10240 { "CLIPBOARD_MANAGER", &dpyinfo->Xatom_CLIPBOARD_MANAGER }, 10242 ATOM_REFS_INIT ("ATOM", Xatom_ATOM)
10241 { "_XEMBED_INFO", &dpyinfo->Xatom_XEMBED_INFO }, 10243 ATOM_REFS_INIT ("ATOM_PAIR", Xatom_ATOM_PAIR)
10244 ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER)
10245 ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO)
10242 /* For properties of font. */ 10246 /* For properties of font. */
10243 { "PIXEL_SIZE", &dpyinfo->Xatom_PIXEL_SIZE }, 10247 ATOM_REFS_INIT ("PIXEL_SIZE", Xatom_PIXEL_SIZE)
10244 { "AVERAGE_WIDTH", &dpyinfo->Xatom_AVERAGE_WIDTH }, 10248 ATOM_REFS_INIT ("AVERAGE_WIDTH", Xatom_AVERAGE_WIDTH)
10245 { "_MULE_BASELINE_OFFSET", &dpyinfo->Xatom_MULE_BASELINE_OFFSET }, 10249 ATOM_REFS_INIT ("_MULE_BASELINE_OFFSET", Xatom_MULE_BASELINE_OFFSET)
10246 { "_MULE_RELATIVE_COMPOSE", &dpyinfo->Xatom_MULE_RELATIVE_COMPOSE }, 10250 ATOM_REFS_INIT ("_MULE_RELATIVE_COMPOSE", Xatom_MULE_RELATIVE_COMPOSE)
10247 { "_MULE_DEFAULT_ASCENT", &dpyinfo->Xatom_MULE_DEFAULT_ASCENT }, 10251 ATOM_REFS_INIT ("_MULE_DEFAULT_ASCENT", Xatom_MULE_DEFAULT_ASCENT)
10248 /* Ghostscript support. */ 10252 /* Ghostscript support. */
10249 { "DONE", &dpyinfo->Xatom_DONE }, 10253 ATOM_REFS_INIT ("DONE", Xatom_DONE)
10250 { "PAGE", &dpyinfo->Xatom_PAGE }, 10254 ATOM_REFS_INIT ("PAGE", Xatom_PAGE)
10251 { "SCROLLBAR", &dpyinfo->Xatom_Scrollbar }, 10255 ATOM_REFS_INIT ("SCROLLBAR", Xatom_Scrollbar)
10252 { "_XEMBED", &dpyinfo->Xatom_XEMBED }, 10256 ATOM_REFS_INIT ("_XEMBED", Xatom_XEMBED)
10253 /* EWMH */ 10257 /* EWMH */
10254 { "_NET_WM_STATE", &dpyinfo->Xatom_net_wm_state }, 10258 ATOM_REFS_INIT ("_NET_WM_STATE", Xatom_net_wm_state)
10255 { "_NET_WM_STATE_FULLSCREEN", &dpyinfo->Xatom_net_wm_state_fullscreen }, 10259 ATOM_REFS_INIT ("_NET_WM_STATE_FULLSCREEN", Xatom_net_wm_state_fullscreen)
10256 { "_NET_WM_STATE_MAXIMIZED_HORZ", 10260 ATOM_REFS_INIT ("_NET_WM_STATE_MAXIMIZED_HORZ",
10257 &dpyinfo->Xatom_net_wm_state_maximized_horz }, 10261 Xatom_net_wm_state_maximized_horz)
10258 { "_NET_WM_STATE_MAXIMIZED_VERT", 10262 ATOM_REFS_INIT ("_NET_WM_STATE_MAXIMIZED_VERT",
10259 &dpyinfo->Xatom_net_wm_state_maximized_vert }, 10263 Xatom_net_wm_state_maximized_vert)
10260 { "_NET_WM_STATE_STICKY", &dpyinfo->Xatom_net_wm_state_sticky }, 10264 ATOM_REFS_INIT ("_NET_WM_STATE_STICKY", Xatom_net_wm_state_sticky)
10261 { "_NET_WM_STATE_HIDDEN", &dpyinfo->Xatom_net_wm_state_hidden }, 10265 ATOM_REFS_INIT ("_NET_WM_STATE_HIDDEN", Xatom_net_wm_state_hidden)
10262 { "_NET_WM_WINDOW_TYPE", &dpyinfo->Xatom_net_window_type }, 10266 ATOM_REFS_INIT ("_NET_WM_WINDOW_TYPE", Xatom_net_window_type)
10263 { "_NET_WM_WINDOW_TYPE_TOOLTIP", 10267 ATOM_REFS_INIT ("_NET_WM_WINDOW_TYPE_TOOLTIP",
10264 &dpyinfo->Xatom_net_window_type_tooltip }, 10268 Xatom_net_window_type_tooltip)
10265 { "_NET_WM_ICON_NAME", &dpyinfo->Xatom_net_wm_icon_name }, 10269 ATOM_REFS_INIT ("_NET_WM_ICON_NAME", Xatom_net_wm_icon_name)
10266 { "_NET_WM_NAME", &dpyinfo->Xatom_net_wm_name }, 10270 ATOM_REFS_INIT ("_NET_WM_NAME", Xatom_net_wm_name)
10267 { "_NET_SUPPORTED", &dpyinfo->Xatom_net_supported }, 10271 ATOM_REFS_INIT ("_NET_SUPPORTED", Xatom_net_supported)
10268 { "_NET_SUPPORTING_WM_CHECK", &dpyinfo->Xatom_net_supporting_wm_check }, 10272 ATOM_REFS_INIT ("_NET_SUPPORTING_WM_CHECK", Xatom_net_supporting_wm_check)
10269 { "_NET_WM_WINDOW_OPACITY", &dpyinfo->Xatom_net_wm_window_opacity }, 10273 ATOM_REFS_INIT ("_NET_WM_WINDOW_OPACITY", Xatom_net_wm_window_opacity)
10270 { "_NET_ACTIVE_WINDOW", &dpyinfo->Xatom_net_active_window }, 10274 ATOM_REFS_INIT ("_NET_ACTIVE_WINDOW", Xatom_net_active_window)
10271 { "_NET_FRAME_EXTENTS", &dpyinfo->Xatom_net_frame_extents }, 10275 ATOM_REFS_INIT ("_NET_FRAME_EXTENTS", Xatom_net_frame_extents)
10272 { "_NET_CURRENT_DESKTOP", &dpyinfo->Xatom_net_current_desktop }, 10276 ATOM_REFS_INIT ("_NET_CURRENT_DESKTOP", Xatom_net_current_desktop)
10273 { "_NET_WORKAREA", &dpyinfo->Xatom_net_workarea }, 10277 ATOM_REFS_INIT ("_NET_WORKAREA", Xatom_net_workarea)
10274 /* Session management */ 10278 /* Session management */
10275 { "SM_CLIENT_ID", &dpyinfo->Xatom_SM_CLIENT_ID }, 10279 ATOM_REFS_INIT ("SM_CLIENT_ID", Xatom_SM_CLIENT_ID)
10276 { "_XSETTINGS_SETTINGS", &dpyinfo->Xatom_xsettings_prop }, 10280 ATOM_REFS_INIT ("_XSETTINGS_SETTINGS", Xatom_xsettings_prop)
10277 { "MANAGER", &dpyinfo->Xatom_xsettings_mgr }, 10281 ATOM_REFS_INIT ("MANAGER", Xatom_xsettings_mgr)
10278 }; 10282 };
10279 10283
10280 int i; 10284 int i;
@@ -10299,7 +10303,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10299 False, atoms_return); 10303 False, atoms_return);
10300 10304
10301 for (i = 0; i < atom_count; i++) 10305 for (i = 0; i < atom_count; i++)
10302 *atom_refs[i].atom = atoms_return[i]; 10306 *(Atom *) ((char *) dpyinfo + atom_refs[i].offset) = atoms_return[i];
10303 10307
10304 /* Manual copy of last atom */ 10308 /* Manual copy of last atom */
10305 dpyinfo->Xatom_xsettings_sel = atoms_return[i]; 10309 dpyinfo->Xatom_xsettings_sel = atoms_return[i];
diff --git a/src/xterm.h b/src/xterm.h
index 4a5ebc66370..5415a77cf58 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -38,8 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include <X11/CoreP.h> /* foul, but we need this to use our own 38#include <X11/CoreP.h> /* foul, but we need this to use our own
39 window inside a widget instead of one 39 window inside a widget instead of one
40 that Xt creates... */ 40 that Xt creates... */
41#include <X11/StringDefs.h>
42
43typedef Widget xt_or_gtk_widget; 41typedef Widget xt_or_gtk_widget;
44#endif 42#endif
45 43
diff --git a/test/ChangeLog b/test/ChangeLog
index 9ccb1f4bc89..d69155a27ff 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,101 @@
12013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 * automated/python-tests.el (python-imenu-create-index-2)
4 (python-imenu-create-index-3): New tests.
5
62013-07-11 Glenn Morris <rgm@gnu.org>
7
8 * automated/ert-tests.el: Require cl-lib at runtime too.
9 (ert-test-special-operator-p): Use cl-gensym rather than ert-- version.
10 (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*)
11 (ert-test-set-functions, ert-test-gensym)
12 (ert-test-coerce-to-vector, ert-test-string-position)
13 (ert-test-mismatch): Remove tests.
14 * automated/cl-lib.el: New, split from ert-tests.el.
15
16 * automated/ruby-mode-tests.el (ruby-deftest-move-to-block):
17 Goto point-min.
18 (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two)
19 (ruby-move-to-block-skips-percent-literal)
20 (ruby-move-to-block-skips-heredoc)
21 (ruby-move-to-block-moves-from-else-to-if)
22 (ruby-beginning-of-defun-does-not-fold-case)
23 (ruby-end-of-defun-skips-to-next-line-after-the-method):
24 Replace goto-line with forward-line/goto-char.
25 (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer.
26
27 * automated/package-test.el (makeinfo-buffer): Autoload.
28 (compilation-in-progress, tar-parse-info, tar-header-name): Declare.
29 (package-test-install-texinfo): Don't require makeinfo.
30
31 * automated/files.el: Stop "local variables" confusion.
32
33 * automated/flymake-tests.el (flymake-tests): Remove unused group.
34
35 * automated/icalendar-tests.el (icalendar-tests--do-test-cycle):
36 Use with-current-buffer.
37
38 * automated/undo-tests.el (undo-test-buffer-modified)
39 (undo-test-file-modified): New tests.
40
412013-07-09 Michael Albinus <michael.albinus@gmx.de>
42
43 * automated/file-notify-tests.el (file-notify-test00-availability):
44 Set :expected-result.
45 (file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
46 (file-notify-test02-events, file-notify-test02-events-remote)
47 (file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
48 Skip when `file-notify-support' is nil. (Bug#14823)
49
502013-07-09 Glenn Morris <rgm@gnu.org>
51
52 * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch):
53 Declare.
54 (inotify-file-watch-simple): Silence compiler.
55
56 * automated/python-tests.el (python-indent-block-enders):
57 Make it actually test something.
58
59 * automated/package-x-test.el: Require package-test when compiling.
60
61 * automated/add-log-tests.el, automated/advice-tests.el:
62 * automated/imenu-test.el, automated/package-x-test.el:
63 * automated/python-tests.el, automated/ruby-mode-tests.el:
64 * automated/xml-parse-tests.el: Explictly require ert.
65
662013-07-08 Kenichi Handa <handa@gnu.org>
67
68 * automated/decoder-tests.el (decoder-tests-prefer-utf-8-read):
69 Use with-ccoding-priority to avoid side-effect (Bug#14781).
70
712013-07-05 Michael Albinus <michael.albinus@gmx.de>
72
73 * automated/file-notify-tests.el
74 (file-notify-test-remote-temporary-file-directory): Use
75 `null-device' on w32.
76 (file-notify--test-tmpfile, file-notify--test-tmpfile1)
77 (file-notify--test-results, file-notify--test-event)
78 (file-notify--deftest-remote, file-notify--event-test)
79 (file-notify--test-event-handler)
80 (file-notify--test-make-temp-name): Renamed, in order to mark them
81 internal.
82 (tramp-message-show-message, tramp-read-passwd): Tweak them for
83 better fitting in noninteractive tests.
84 (file-notify-test00-availability): Renamed from `file-notify-test0'.
85 (file-notify-test01-add-watch): Renamed from `file-notify-test1'.
86 Use `temporary-file-directory '.
87 (file-notify-test01-add-watch-remote): New test.
88 (file-notify-test02-events): Renamed from `file-notify-test2'.
89 (file-notify-test02-events-remote): Renamed from `file-notify-test3'.
90 (file-notify-test03-autorevert): Renamed from
91 `file-notify-test4'. Use timeouts.
92 (file-notify-test03-autorevert-remote): Renamed from
93 `file-notify-test5'.
94
952013-07-04 Michael Albinus <michael.albinus@gmx.de>
96
97 * automated/file-notify-tests.el: New package.
98
12013-06-28 Kenichi Handa <handa@gnu.org> 992013-06-28 Kenichi Handa <handa@gnu.org>
2 100
3 * automated/decoder-tests.el (decoder-tests-gen-file): New arg FILE. 101 * automated/decoder-tests.el (decoder-tests-gen-file): New arg FILE.
@@ -43,7 +141,7 @@
43 Use it to create separate tests for each element, so we run them 141 Use it to create separate tests for each element, so we run them
44 all rather than stopping at the first error. 142 all rather than stopping at the first error.
45 143
462013-06-24 Glenn Morris <rgm@fencepost.gnu.org> 1442013-06-24 Glenn Morris <rgm@gnu.org>
47 145
48 * automated/occur-tests.el (occur-tests): 146 * automated/occur-tests.el (occur-tests):
49 Update for 2013-05-29 change to occur header line. 147 Update for 2013-05-29 change to occur header line.
diff --git a/test/automated/add-log-tests.el b/test/automated/add-log-tests.el
index f6e803cd317..bd073016505 100644
--- a/test/automated/add-log-tests.el
+++ b/test/automated/add-log-tests.el
@@ -22,6 +22,7 @@
22 22
23;;; Code: 23;;; Code:
24 24
25(require 'ert)
25(require 'add-log) 26(require 'add-log)
26 27
27(defmacro add-log-current-defun-deftest (name doc major-mode 28(defmacro add-log-current-defun-deftest (name doc major-mode
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index 8beaea64cd9..69c15e34ed0 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -21,6 +21,8 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
25
24(ert-deftest advice-tests-nadvice () 26(ert-deftest advice-tests-nadvice ()
25 "Test nadvice code." 27 "Test nadvice code."
26 (defun sm-test1 (x) (+ x 4)) 28 (defun sm-test1 (x) (+ x 4))
diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el
new file mode 100644
index 00000000000..3a339e01734
--- /dev/null
+++ b/test/automated/cl-lib.el
@@ -0,0 +1,198 @@
1;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; This program is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `http://www.gnu.org/licenses/'.
19
20;;; Commentary:
21
22;; Extracted from ert-tests.el, back when ert used to reimplement some
23;; cl functions.
24
25;;; Code:
26
27(require 'cl-lib)
28(require 'ert)
29
30(ert-deftest cl-lib-test-remprop ()
31 (let ((x (cl-gensym)))
32 (should (equal (symbol-plist x) '()))
33 ;; Remove nonexistent property on empty plist.
34 (cl-remprop x 'b)
35 (should (equal (symbol-plist x) '()))
36 (put x 'a 1)
37 (should (equal (symbol-plist x) '(a 1)))
38 ;; Remove nonexistent property on nonempty plist.
39 (cl-remprop x 'b)
40 (should (equal (symbol-plist x) '(a 1)))
41 (put x 'b 2)
42 (put x 'c 3)
43 (put x 'd 4)
44 (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4)))
45 ;; Remove property that is neither first nor last.
46 (cl-remprop x 'c)
47 (should (equal (symbol-plist x) '(a 1 b 2 d 4)))
48 ;; Remove last property from a plist of length >1.
49 (cl-remprop x 'd)
50 (should (equal (symbol-plist x) '(a 1 b 2)))
51 ;; Remove first property from a plist of length >1.
52 (cl-remprop x 'a)
53 (should (equal (symbol-plist x) '(b 2)))
54 ;; Remove property when there is only one.
55 (cl-remprop x 'b)
56 (should (equal (symbol-plist x) '()))))
57
58(ert-deftest cl-lib-test-remove-if-not ()
59 (let ((list (list 'a 'b 'c 'd))
60 (i 0))
61 (let ((result (cl-remove-if-not (lambda (x)
62 (should (eql x (nth i list)))
63 (cl-incf i)
64 (member i '(2 3)))
65 list)))
66 (should (equal i 4))
67 (should (equal result '(b c)))
68 (should (equal list '(a b c d)))))
69 (should (equal '()
70 (cl-remove-if-not (lambda (_x) (should nil)) '()))))
71
72(ert-deftest cl-lib-test-remove ()
73 (let ((list (list 'a 'b 'c 'd))
74 (key-index 0)
75 (test-index 0))
76 (let ((result
77 (cl-remove 'foo list
78 :key (lambda (x)
79 (should (eql x (nth key-index list)))
80 (prog1
81 (list key-index x)
82 (cl-incf key-index)))
83 :test
84 (lambda (a b)
85 (should (eql a 'foo))
86 (should (equal b (list test-index
87 (nth test-index list))))
88 (cl-incf test-index)
89 (member test-index '(2 3))))))
90 (should (equal key-index 4))
91 (should (equal test-index 4))
92 (should (equal result '(a d)))
93 (should (equal list '(a b c d)))))
94 (let ((x (cons nil nil))
95 (y (cons nil nil)))
96 (should (equal (cl-remove x (list x y))
97 ;; or (list x), since we use `equal' -- the
98 ;; important thing is that only one element got
99 ;; removed, this proves that the default test is
100 ;; `eql', not `equal'
101 (list y)))))
102
103
104(ert-deftest cl-lib-test-set-functions ()
105 (let ((c1 (cons nil nil))
106 (c2 (cons nil nil))
107 (sym (make-symbol "a")))
108 (let ((e '())
109 (a (list 'a 'b sym nil "" "x" c1 c2))
110 (b (list c1 'y 'b sym 'x)))
111 (should (equal (cl-set-difference e e) e))
112 (should (equal (cl-set-difference a e) a))
113 (should (equal (cl-set-difference e a) e))
114 (should (equal (cl-set-difference a a) e))
115 (should (equal (cl-set-difference b e) b))
116 (should (equal (cl-set-difference e b) e))
117 (should (equal (cl-set-difference b b) e))
118 ;; Note: this test (and others) is sensitive to the order of the
119 ;; result, which is not documented.
120 (should (equal (cl-set-difference a b) (list c2 "x" "" nil 'a)))
121 (should (equal (cl-set-difference b a) (list 'x 'y)))
122
123 ;; We aren't testing whether this is really using `eq' rather than `eql'.
124 (should (equal (cl-set-difference e e :test 'eq) e))
125 (should (equal (cl-set-difference a e :test 'eq) a))
126 (should (equal (cl-set-difference e a :test 'eq) e))
127 (should (equal (cl-set-difference a a :test 'eq) e))
128 (should (equal (cl-set-difference b e :test 'eq) b))
129 (should (equal (cl-set-difference e b :test 'eq) e))
130 (should (equal (cl-set-difference b b :test 'eq) e))
131 (should (equal (cl-set-difference a b :test 'eq) (list c2 "x" "" nil 'a)))
132 (should (equal (cl-set-difference b a :test 'eq) (list 'x 'y)))
133
134 (should (equal (cl-union e e) e))
135 (should (equal (cl-union a e) a))
136 (should (equal (cl-union e a) a))
137 (should (equal (cl-union a a) a))
138 (should (equal (cl-union b e) b))
139 (should (equal (cl-union e b) b))
140 (should (equal (cl-union b b) b))
141 (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2)))
142
143 (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2)))
144
145 (should (equal (cl-intersection e e) e))
146 (should (equal (cl-intersection a e) e))
147 (should (equal (cl-intersection e a) e))
148 (should (equal (cl-intersection a a) a))
149 (should (equal (cl-intersection b e) e))
150 (should (equal (cl-intersection e b) e))
151 (should (equal (cl-intersection b b) b))
152 (should (equal (cl-intersection a b) (list sym 'b c1)))
153 (should (equal (cl-intersection b a) (list sym 'b c1))))))
154
155(ert-deftest cl-lib-test-gensym ()
156 ;; Since the expansion of `should' calls `cl-gensym' and thus has a
157 ;; side-effect on `cl--gensym-counter', we have to make sure all
158 ;; macros in our test body are expanded before we rebind
159 ;; `cl--gensym-counter' and run the body. Otherwise, the test would
160 ;; fail if run interpreted.
161 (let ((body (byte-compile
162 '(lambda ()
163 (should (equal (symbol-name (cl-gensym)) "G0"))
164 (should (equal (symbol-name (cl-gensym)) "G1"))
165 (should (equal (symbol-name (cl-gensym)) "G2"))
166 (should (equal (symbol-name (cl-gensym "foo")) "foo3"))
167 (should (equal (symbol-name (cl-gensym "bar")) "bar4"))
168 (should (equal cl--gensym-counter 5))))))
169 (let ((cl--gensym-counter 0))
170 (funcall body))))
171
172(ert-deftest cl-lib-test-coerce-to-vector ()
173 (let* ((a (vector))
174 (b (vector 1 a 3))
175 (c (list))
176 (d (list b a)))
177 (should (eql (cl-coerce a 'vector) a))
178 (should (eql (cl-coerce b 'vector) b))
179 (should (equal (cl-coerce c 'vector) (vector)))
180 (should (equal (cl-coerce d 'vector) (vector b a)))))
181
182(ert-deftest cl-lib-test-string-position ()
183 (should (eql (cl-position ?x "") nil))
184 (should (eql (cl-position ?a "abc") 0))
185 (should (eql (cl-position ?b "abc") 1))
186 (should (eql (cl-position ?c "abc") 2))
187 (should (eql (cl-position ?d "abc") nil))
188 (should (eql (cl-position ?A "abc") nil)))
189
190(ert-deftest cl-lib-test-mismatch ()
191 (should (eql (cl-mismatch "" "") nil))
192 (should (eql (cl-mismatch "" "a") 0))
193 (should (eql (cl-mismatch "a" "a") nil))
194 (should (eql (cl-mismatch "ab" "a") 1))
195 (should (eql (cl-mismatch "Aa" "aA") 0))
196 (should (eql (cl-mismatch '(a b c) '(a b d)) 2)))
197
198;;; cl-lib.el ends here
diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el
index e1b05faf3c0..2e99fd7f115 100644
--- a/test/automated/decoder-tests.el
+++ b/test/automated/decoder-tests.el
@@ -213,10 +213,9 @@
213;; PREFER is non-nil, prefer that coding system before reading. 213;; PREFER is non-nil, prefer that coding system before reading.
214 214
215(defun decoder-tests-prefer-utf-8-read (file detect prefer) 215(defun decoder-tests-prefer-utf-8-read (file detect prefer)
216 (if prefer
217 (prefer-coding-system prefer))
218 (with-temp-buffer 216 (with-temp-buffer
219 (insert-file-contents file) 217 (with-coding-priority (if prefer (list prefer))
218 (insert-file-contents file))
220 (if (eq buffer-file-coding-system detect) 219 (if (eq buffer-file-coding-system detect)
221 nil 220 nil
222 (format "Invalid detection: %s" buffer-file-coding-system)))) 221 (format "Invalid detection: %s" buffer-file-coding-system))))
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el
index 0c3c3692c1d..36864377ec9 100644
--- a/test/automated/ert-tests.el
+++ b/test/automated/ert-tests.el
@@ -26,11 +26,9 @@
26 26
27;;; Code: 27;;; Code:
28 28
29(eval-when-compile 29(require 'cl-lib)
30 (require 'cl-lib))
31(require 'ert) 30(require 'ert)
32 31
33
34;;; Self-test that doesn't rely on ERT, for bootstrapping. 32;;; Self-test that doesn't rely on ERT, for bootstrapping.
35 33
36;; This is used to test that bodies actually run. 34;; This is used to test that bodies actually run.
@@ -578,7 +576,7 @@ This macro is used to test if macroexpansion in `should' works."
578 (should (ert--special-operator-p 'if)) 576 (should (ert--special-operator-p 'if))
579 (should-not (ert--special-operator-p 'car)) 577 (should-not (ert--special-operator-p 'car))
580 (should-not (ert--special-operator-p 'ert--special-operator-p)) 578 (should-not (ert--special-operator-p 'ert--special-operator-p))
581 (let ((b (ert--gensym))) 579 (let ((b (cl-gensym)))
582 (should-not (ert--special-operator-p b)) 580 (should-not (ert--special-operator-p b))
583 (fset b 'if) 581 (fset b 'if)
584 (should (ert--special-operator-p b)))) 582 (should (ert--special-operator-p b))))
@@ -626,171 +624,6 @@ This macro is used to test if macroexpansion in `should' works."
626 :explanation nil) 624 :explanation nil)
627 )))))) 625 ))))))
628 626
629(ert-deftest ert-test-remprop ()
630 (let ((x (ert--gensym)))
631 (should (equal (symbol-plist x) '()))
632 ;; Remove nonexistent property on empty plist.
633 (ert--remprop x 'b)
634 (should (equal (symbol-plist x) '()))
635 (put x 'a 1)
636 (should (equal (symbol-plist x) '(a 1)))
637 ;; Remove nonexistent property on nonempty plist.
638 (ert--remprop x 'b)
639 (should (equal (symbol-plist x) '(a 1)))
640 (put x 'b 2)
641 (put x 'c 3)
642 (put x 'd 4)
643 (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4)))
644 ;; Remove property that is neither first nor last.
645 (ert--remprop x 'c)
646 (should (equal (symbol-plist x) '(a 1 b 2 d 4)))
647 ;; Remove last property from a plist of length >1.
648 (ert--remprop x 'd)
649 (should (equal (symbol-plist x) '(a 1 b 2)))
650 ;; Remove first property from a plist of length >1.
651 (ert--remprop x 'a)
652 (should (equal (symbol-plist x) '(b 2)))
653 ;; Remove property when there is only one.
654 (ert--remprop x 'b)
655 (should (equal (symbol-plist x) '()))))
656
657(ert-deftest ert-test-remove-if-not ()
658 (let ((list (list 'a 'b 'c 'd))
659 (i 0))
660 (let ((result (ert--remove-if-not (lambda (x)
661 (should (eql x (nth i list)))
662 (cl-incf i)
663 (member i '(2 3)))
664 list)))
665 (should (equal i 4))
666 (should (equal result '(b c)))
667 (should (equal list '(a b c d)))))
668 (should (equal '()
669 (ert--remove-if-not (lambda (_x) (should nil)) '()))))
670
671(ert-deftest ert-test-remove* ()
672 (let ((list (list 'a 'b 'c 'd))
673 (key-index 0)
674 (test-index 0))
675 (let ((result
676 (ert--remove* 'foo list
677 :key (lambda (x)
678 (should (eql x (nth key-index list)))
679 (prog1
680 (list key-index x)
681 (cl-incf key-index)))
682 :test
683 (lambda (a b)
684 (should (eql a 'foo))
685 (should (equal b (list test-index
686 (nth test-index list))))
687 (cl-incf test-index)
688 (member test-index '(2 3))))))
689 (should (equal key-index 4))
690 (should (equal test-index 4))
691 (should (equal result '(a d)))
692 (should (equal list '(a b c d)))))
693 (let ((x (cons nil nil))
694 (y (cons nil nil)))
695 (should (equal (ert--remove* x (list x y))
696 ;; or (list x), since we use `equal' -- the
697 ;; important thing is that only one element got
698 ;; removed, this proves that the default test is
699 ;; `eql', not `equal'
700 (list y)))))
701
702
703(ert-deftest ert-test-set-functions ()
704 (let ((c1 (cons nil nil))
705 (c2 (cons nil nil))
706 (sym (make-symbol "a")))
707 (let ((e '())
708 (a (list 'a 'b sym nil "" "x" c1 c2))
709 (b (list c1 'y 'b sym 'x)))
710 (should (equal (ert--set-difference e e) e))
711 (should (equal (ert--set-difference a e) a))
712 (should (equal (ert--set-difference e a) e))
713 (should (equal (ert--set-difference a a) e))
714 (should (equal (ert--set-difference b e) b))
715 (should (equal (ert--set-difference e b) e))
716 (should (equal (ert--set-difference b b) e))
717 (should (equal (ert--set-difference a b) (list 'a nil "" "x" c2)))
718 (should (equal (ert--set-difference b a) (list 'y 'x)))
719
720 ;; We aren't testing whether this is really using `eq' rather than `eql'.
721 (should (equal (ert--set-difference-eq e e) e))
722 (should (equal (ert--set-difference-eq a e) a))
723 (should (equal (ert--set-difference-eq e a) e))
724 (should (equal (ert--set-difference-eq a a) e))
725 (should (equal (ert--set-difference-eq b e) b))
726 (should (equal (ert--set-difference-eq e b) e))
727 (should (equal (ert--set-difference-eq b b) e))
728 (should (equal (ert--set-difference-eq a b) (list 'a nil "" "x" c2)))
729 (should (equal (ert--set-difference-eq b a) (list 'y 'x)))
730
731 (should (equal (ert--union e e) e))
732 (should (equal (ert--union a e) a))
733 (should (equal (ert--union e a) a))
734 (should (equal (ert--union a a) a))
735 (should (equal (ert--union b e) b))
736 (should (equal (ert--union e b) b))
737 (should (equal (ert--union b b) b))
738 (should (equal (ert--union a b) (list 'a 'b sym nil "" "x" c1 c2 'y 'x)))
739 (should (equal (ert--union b a) (list c1 'y 'b sym 'x 'a nil "" "x" c2)))
740
741 (should (equal (ert--intersection e e) e))
742 (should (equal (ert--intersection a e) e))
743 (should (equal (ert--intersection e a) e))
744 (should (equal (ert--intersection a a) a))
745 (should (equal (ert--intersection b e) e))
746 (should (equal (ert--intersection e b) e))
747 (should (equal (ert--intersection b b) b))
748 (should (equal (ert--intersection a b) (list 'b sym c1)))
749 (should (equal (ert--intersection b a) (list c1 'b sym))))))
750
751(ert-deftest ert-test-gensym ()
752 ;; Since the expansion of `should' calls `ert--gensym' and thus has a
753 ;; side-effect on `ert--gensym-counter', we have to make sure all
754 ;; macros in our test body are expanded before we rebind
755 ;; `ert--gensym-counter' and run the body. Otherwise, the test would
756 ;; fail if run interpreted.
757 (let ((body (byte-compile
758 '(lambda ()
759 (should (equal (symbol-name (ert--gensym)) "G0"))
760 (should (equal (symbol-name (ert--gensym)) "G1"))
761 (should (equal (symbol-name (ert--gensym)) "G2"))
762 (should (equal (symbol-name (ert--gensym "foo")) "foo3"))
763 (should (equal (symbol-name (ert--gensym "bar")) "bar4"))
764 (should (equal ert--gensym-counter 5))))))
765 (let ((ert--gensym-counter 0))
766 (funcall body))))
767
768(ert-deftest ert-test-coerce-to-vector ()
769 (let* ((a (vector))
770 (b (vector 1 a 3))
771 (c (list))
772 (d (list b a)))
773 (should (eql (ert--coerce-to-vector a) a))
774 (should (eql (ert--coerce-to-vector b) b))
775 (should (equal (ert--coerce-to-vector c) (vector)))
776 (should (equal (ert--coerce-to-vector d) (vector b a)))))
777
778(ert-deftest ert-test-string-position ()
779 (should (eql (ert--string-position ?x "") nil))
780 (should (eql (ert--string-position ?a "abc") 0))
781 (should (eql (ert--string-position ?b "abc") 1))
782 (should (eql (ert--string-position ?c "abc") 2))
783 (should (eql (ert--string-position ?d "abc") nil))
784 (should (eql (ert--string-position ?A "abc") nil)))
785
786(ert-deftest ert-test-mismatch ()
787 (should (eql (ert--mismatch "" "") nil))
788 (should (eql (ert--mismatch "" "a") 0))
789 (should (eql (ert--mismatch "a" "a") nil))
790 (should (eql (ert--mismatch "ab" "a") 1))
791 (should (eql (ert--mismatch "Aa" "aA") 0))
792 (should (eql (ert--mismatch '(a b c) '(a b d)) 2)))
793
794(ert-deftest ert-test-string-first-line () 627(ert-deftest ert-test-string-first-line ()
795 (should (equal (ert--string-first-line "") "")) 628 (should (equal (ert--string-first-line "") ""))
796 (should (equal (ert--string-first-line "abc") "abc")) 629 (should (equal (ert--string-first-line "abc") "abc"))
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
new file mode 100644
index 00000000000..0e9be33f157
--- /dev/null
+++ b/test/automated/file-notify-tests.el
@@ -0,0 +1,263 @@
1;;; file-notify-tests.el --- Tests of file notifications
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx.de>
6
7;; This program is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `http://www.gnu.org/licenses/'.
19
20;;; Commentary:
21
22;; Some of the tests are intended to run over remote files. Set
23;; `file-notify-test-remote-temporary-file-directory' to a suitable
24;; value. It must NOT require an interactive password prompt, when
25;; running the tests in batch mode.
26
27;; If you want to skip tests for remote files, set this variable to
28;; `null-device'.
29
30;;; Code:
31
32(require 'ert)
33(require 'filenotify)
34
35;; There is no default value on w32 systems, which could work out of the box.
36(defconst file-notify-test-remote-temporary-file-directory
37 (if (eq system-type 'windows-nt) null-device "/ssh::/tmp")
38 "Temporary directory for Tramp tests.")
39
40(defvar file-notify--test-tmpfile nil)
41(defvar file-notify--test-tmpfile1 nil)
42(defvar file-notify--test-results nil)
43(defvar file-notify--test-event nil)
44
45(require 'tramp)
46(setq tramp-verbose 0
47 tramp-message-show-message nil)
48(when noninteractive (defalias 'tramp-read-passwd 'ignore))
49
50(defmacro file-notify--deftest-remote (test docstring)
51 "Define ert `TEST-remote' for remote files."
52 `(when (ignore-errors
53 (and
54 (file-remote-p file-notify-test-remote-temporary-file-directory)
55 (file-directory-p file-notify-test-remote-temporary-file-directory)
56 (file-writable-p file-notify-test-remote-temporary-file-directory)))
57 ;; Define the test.
58 (ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
59 ,docstring
60 (let* ((temporary-file-directory
61 file-notify-test-remote-temporary-file-directory)
62 (ert-test (ert-get-test ',test))
63 (most-recent-result (ert-test-most-recent-result ert-test))
64 result)
65 (unwind-protect
66 (progn
67 (setq result
68 (condition-case err
69 (ert-run-test ert-test)
70 ((error quit)
71 (ert-fail err))))
72 (when (ert-test-failed-p result)
73 (ert-fail
74 (cadr (ert-test-result-with-condition-condition result)))))
75 ;; Reset status of TEST.
76 (setf (ert-test-most-recent-result ert-test) most-recent-result))))))
77
78(ert-deftest file-notify-test00-availability ()
79 "Test availability of `file-notify'."
80 :expected-result (if file-notify-support :passed :failed)
81 (should (memq file-notify-support '(gfilenotify inotify w32notify))))
82
83(when file-notify-support
84
85 (ert-deftest file-notify-test01-add-watch ()
86 "Check `file-notify-add-watch'."
87 (let (desc)
88 ;; Check, that different valid parameters are accepted.
89 (should (setq desc (file-notify-add-watch
90 temporary-file-directory '(change) 'ignore)))
91 (file-notify-rm-watch desc)
92 (should (setq desc (file-notify-add-watch
93 temporary-file-directory
94 '(attribute-change) 'ignore)))
95 (file-notify-rm-watch desc)
96 (should (setq desc (file-notify-add-watch
97 temporary-file-directory
98 '(change attribute-change) 'ignore)))
99 (file-notify-rm-watch desc)
100
101 ;; Check error handling.
102 (should
103 (equal (car (should-error (file-notify-add-watch 1 2 3 4)))
104 'wrong-number-of-arguments))
105 (should
106 (equal (should-error (file-notify-add-watch 1 2 3))
107 '(wrong-type-argument 1)))
108 (should
109 (equal (should-error (file-notify-add-watch
110 temporary-file-directory 2 3))
111 '(wrong-type-argument 2)))
112 (should
113 (equal (should-error (file-notify-add-watch
114 temporary-file-directory '(change) 3))
115 '(wrong-type-argument 3)))))
116
117 (file-notify--deftest-remote file-notify-test01-add-watch
118 "Check `file-notify-add-watch' for remote files.")
119 ) ;; file-notify-support
120
121(defun file-notify--test-event-test ()
122 "Ert test function to be called by `file-notify--test-event-handler'.
123We cannot pass arguments, so we assume that `file-notify--test-event'
124is bound somewhere."
125 ;(message "Event %S" file-notify--test-event)
126 ;; Check the file name.
127 (should
128 (string-equal (file-notify--event-file-name file-notify--test-event)
129 file-notify--test-tmpfile))
130 ;; Check the second file name if exists.
131 (when (eq (nth 1 file-notify--test-event) 'renamed)
132 (should
133 (string-equal
134 (file-notify--event-file1-name file-notify--test-event)
135 file-notify--test-tmpfile1))))
136
137(defun file-notify--test-event-handler (file-notify--test-event)
138 "Run a test over FILE-NOTIFY--TEST-EVENT.
139Save the result in `file-notify--test-results', for later analysis."
140 (let ((result
141 (ert-run-test (make-ert-test :body 'file-notify--test-event-test))))
142 (setq file-notify--test-results
143 (append file-notify--test-results `(,result)))))
144
145(defun file-notify--test-make-temp-name ()
146 "Create a temporary file name for test."
147 (expand-file-name
148 (make-temp-name "file-notify-test") temporary-file-directory))
149
150(when file-notify-support
151
152 (ert-deftest file-notify-test02-events ()
153 "Check file creation/removal notifications."
154 (let (desc)
155 (unwind-protect
156 (progn
157 (setq file-notify--test-results nil
158 file-notify--test-tmpfile (file-notify--test-make-temp-name)
159 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
160 desc
161 (file-notify-add-watch
162 file-notify--test-tmpfile
163 '(change) 'file-notify--test-event-handler))
164
165 ;; Check creation and removal.
166 (write-region "any text" nil file-notify--test-tmpfile)
167 (delete-file file-notify--test-tmpfile)
168
169 ;; Check copy and rename.
170 (write-region "any text" nil file-notify--test-tmpfile)
171 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
172 (delete-file file-notify--test-tmpfile)
173 (delete-file file-notify--test-tmpfile1)
174
175 (write-region "any text" nil file-notify--test-tmpfile)
176 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
177 (delete-file file-notify--test-tmpfile1))
178
179 ;; Wait for events, and exit.
180 (sit-for 5 'nodisplay)
181 (file-notify-rm-watch desc)
182 (ignore-errors (delete-file file-notify--test-tmpfile))
183 (ignore-errors (delete-file file-notify--test-tmpfile1))))
184
185 (dolist (result file-notify--test-results)
186 ;(message "%s" (ert-test-result-messages result))
187 (when (ert-test-failed-p result)
188 (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
189
190 (file-notify--deftest-remote file-notify-test02-events
191 "Check file creation/removal notifications for remote files.")
192 ) ;; file-notify-support
193
194;; autorevert runs only in interactive mode.
195(defvar auto-revert-remote-files)
196(setq auto-revert-remote-files t)
197(require 'autorevert)
198(when (and file-notify-support (null noninteractive))
199
200 (ert-deftest file-notify-test03-autorevert ()
201 "Check autorevert via file notification.
202This test is skipped in batch mode."
203 ;; `auto-revert-buffers' runs every 5". And we must wait, until
204 ;; the file has been reverted.
205 (let ((timeout 10)
206 buf)
207 (unwind-protect
208 (progn
209 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
210
211 (write-region "any text" nil file-notify--test-tmpfile)
212 (setq buf (find-file-noselect file-notify--test-tmpfile))
213 (with-current-buffer buf
214 (should (string-equal (buffer-string) "any text"))
215 (auto-revert-mode 1)
216
217 ;; `auto-revert-buffers' runs every 5".
218 (with-timeout (timeout (ignore))
219 (while (null auto-revert-notify-watch-descriptor)
220 (sit-for 0.1 'nodisplay)))
221
222 ;; Check, that file notification has been used.
223 (should auto-revert-mode)
224 (should auto-revert-use-notify)
225 (should auto-revert-notify-watch-descriptor)
226
227 ;; Modify file. We wait for a second, in order to
228 ;; have another timestamp.
229 (sit-for 1)
230 (shell-command
231 (format "echo -n 'another text' >%s"
232 (or (file-remote-p file-notify--test-tmpfile 'localname)
233 file-notify--test-tmpfile)))
234
235 ;; Check, that the buffer has been reverted.
236 (with-current-buffer (get-buffer-create "*Messages*")
237 (with-timeout (timeout (ignore))
238 (while
239 (null (string-match
240 (format "Reverting buffer `%s'." (buffer-name buf))
241 (buffer-string)))
242 (sit-for 0.1 'nodisplay))))
243 (should (string-equal (buffer-string) "another text"))))
244
245 ;; Exit.
246 (ignore-errors (kill-buffer buf))
247 (ignore-errors (delete-file file-notify--test-tmpfile)))))
248
249 (file-notify--deftest-remote file-notify-test03-autorevert
250 "Check autorevert via file notification for remote files.
251This test is skipped in batch mode.")
252 ) ;; (and file-notify-support (null noninteractive))
253
254(defun file-notify-test-all (&optional interactive)
255 "Run all tests for \\[file-notify]."
256 (interactive "p")
257 (when file-notify-support
258 (if interactive
259 (ert-run-tests-interactively "^file-notify-")
260 (ert-run-tests-batch "^file-notify-"))))
261
262(provide 'file-notify-tests)
263;;; file-notify-tests.el ends here
diff --git a/test/automated/files.el b/test/automated/files.el
index f2d2192a420..8ce2ed7230c 100644
--- a/test/automated/files.el
+++ b/test/automated/files.el
@@ -146,4 +146,7 @@ form.")
146 (should (file-test--do-local-variables-test str subtest)))))) 146 (should (file-test--do-local-variables-test str subtest))))))
147 (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) 147 (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test)))
148 148
149;; Stop the above "Local Var..." confusing Emacs.
150
151
149;;; files.el ends here 152;;; files.el ends here
diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el
index 9cc87b608ad..03a8fb08bc5 100644
--- a/test/automated/flymake-tests.el
+++ b/test/automated/flymake-tests.el
@@ -25,9 +25,6 @@
25(require 'ert) 25(require 'ert)
26(require 'flymake) 26(require 'flymake)
27 27
28(defgroup flymake-tests nil
29 "Test suite for flymake.")
30
31 28
32;; Warning predicate 29;; Warning predicate
33(defun flymake-tests--current-face (file predicate) 30(defun flymake-tests--current-face (file predicate)
diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el
index bca462da4d9..28fa47630a8 100644
--- a/test/automated/icalendar-tests.el
+++ b/test/automated/icalendar-tests.el
@@ -1194,8 +1194,7 @@ Argument INPUT icalendar event string."
1194 (should (string= org-input cycled))))) 1194 (should (string= org-input cycled)))))
1195 ;; clean up 1195 ;; clean up
1196 (kill-buffer (find-buffer-visiting temp-diary)) 1196 (kill-buffer (find-buffer-visiting temp-diary))
1197 (save-excursion 1197 (with-current-buffer (find-buffer-visiting temp-ics)
1198 (set-buffer (find-buffer-visiting temp-ics))
1199 (set-buffer-modified-p nil) 1198 (set-buffer-modified-p nil)
1200 (kill-buffer (current-buffer))) 1199 (kill-buffer (current-buffer)))
1201 (delete-file temp-diary) 1200 (delete-file temp-diary)
diff --git a/test/automated/imenu-test.el b/test/automated/imenu-test.el
index 83e19ebd914..b2b0c6b5c31 100644
--- a/test/automated/imenu-test.el
+++ b/test/automated/imenu-test.el
@@ -22,6 +22,7 @@
22 22
23;;; Code: 23;;; Code:
24 24
25(require 'ert)
25(require 'imenu) 26(require 'imenu)
26 27
27;; (imenu-simple-scan-deftest-gather-strings-from-list 28;; (imenu-simple-scan-deftest-gather-strings-from-list
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el
index 175f262b282..b4d20cf4fb1 100644
--- a/test/automated/inotify-test.el
+++ b/test/automated/inotify-test.el
@@ -25,6 +25,9 @@
25 25
26(require 'ert) 26(require 'ert)
27 27
28(declare-function inotify-add-watch "inotify.c" (file-name aspect callback))
29(declare-function inotify-rm-watch "inotify.c" (watch-descriptor))
30
28(when (featurep 'inotify) 31(when (featurep 'inotify)
29 32
30 ;; (ert-deftest filewatch-file-watch-aspects-check () 33 ;; (ert-deftest filewatch-file-watch-aspects-check ()
@@ -45,7 +48,7 @@
45 (let ((temp-file (make-temp-file "inotify-simple")) 48 (let ((temp-file (make-temp-file "inotify-simple"))
46 (events 0)) 49 (events 0))
47 (let ((wd 50 (let ((wd
48 (inotify-add-watch temp-file t (lambda (ev) 51 (inotify-add-watch temp-file t (lambda (_ev)
49 (setq events (1+ events)))))) 52 (setq events (1+ events))))))
50 (unwind-protect 53 (unwind-protect
51 (progn 54 (progn
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 706ba953d98..a5f0ebb1f94 100755
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -142,6 +142,9 @@
142 (let ((help-xref-following t)) 142 (let ((help-xref-following t))
143 ,@body))) 143 ,@body)))
144 144
145(autoload 'makeinfo-buffer "makeinfo")
146(defvar compilation-in-progress)
147
145(defun package-test-install-texinfo (file) 148(defun package-test-install-texinfo (file)
146 "Install from texinfo FILE. 149 "Install from texinfo FILE.
147 150
@@ -156,7 +159,6 @@ FILE should be a .texinfo file relative to the current
156 (with-current-buffer (find-file-literally full-file) 159 (with-current-buffer (find-file-literally full-file)
157 (unwind-protect 160 (unwind-protect
158 (progn 161 (progn
159 (require 'makeinfo)
160 (makeinfo-buffer) 162 (makeinfo-buffer)
161 ;; Give `makeinfo-buffer' a chance to finish 163 ;; Give `makeinfo-buffer' a chance to finish
162 (while compilation-in-progress 164 (while compilation-in-progress
@@ -184,6 +186,9 @@ DIR is the base name of the package directory, without the trailing slash"
184 (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) 186 (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes))
185 (delete-file file)))) 187 (delete-file file))))
186 188
189(defvar tar-parse-info)
190(declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct
191
187(defun package-test-search-tar-file (filename) 192(defun package-test-search-tar-file (filename)
188 "Search the current buffer's `tar-parse-info' variable for FILENAME. 193 "Search the current buffer's `tar-parse-info' variable for FILENAME.
189 194
diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el
index b8f2a23f6d5..beb18358085 100755
--- a/test/automated/package-x-test.el
+++ b/test/automated/package-x-test.el
@@ -35,6 +35,7 @@
35(require 'package-x) 35(require 'package-x)
36(require 'ert) 36(require 'ert)
37(require 'cl-lib) 37(require 'cl-lib)
38(eval-when-compile (require 'package-test))
38 39
39;; package-test is not normally in `load-path', so temporarily set 40;; package-test is not normally in `load-path', so temporarily set
40;; `load-path' to contain the current directory. 41;; `load-path' to contain the current directory.
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 40505cc7953..fdae235ad38 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -21,6 +21,7 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
24(require 'python) 25(require 'python)
25 26
26(defmacro python-tests-with-temp-buffer (contents &rest body) 27(defmacro python-tests-with-temp-buffer (contents &rest body)
@@ -463,10 +464,10 @@ Class foo(object):
463" 464"
464 (python-tests-look-at "3)") 465 (python-tests-look-at "3)")
465 (forward-line 1) 466 (forward-line 1)
466 (= (python-indent-calculate-indentation) 12) 467 (should (= (python-indent-calculate-indentation) 8))
467 (python-tests-look-at "pass") 468 (python-tests-look-at "pass")
468 (forward-line 1) 469 (forward-line 1)
469 (= (python-indent-calculate-indentation) 8))) 470 (should (= (python-indent-calculate-indentation) 8))))
470 471
471 472
472;;; Navigation 473;;; Navigation
@@ -1744,6 +1745,53 @@ class Baz(object):
1744 (cons "c (def)" (copy-marker 626))))) 1745 (cons "c (def)" (copy-marker 626)))))
1745 (python-imenu-create-index))))) 1746 (python-imenu-create-index)))))
1746 1747
1748(ert-deftest python-imenu-create-index-2 ()
1749 (python-tests-with-temp-buffer
1750 "
1751class Foo(object):
1752 def foo(self):
1753 def foo1():
1754 pass
1755
1756 def foobar(self):
1757 pass
1758"
1759 (goto-char (point-max))
1760 (should (equal
1761 (list
1762 (list
1763 "Foo (class)"
1764 (cons "*class definition*" (copy-marker 2))
1765 (list
1766 "foo (def)"
1767 (cons "*function definition*" (copy-marker 21))
1768 (cons "foo1 (def)" (copy-marker 40)))
1769 (cons "foobar (def)" (copy-marker 78))))
1770 (python-imenu-create-index)))))
1771
1772(ert-deftest python-imenu-create-index-3 ()
1773 (python-tests-with-temp-buffer
1774 "
1775class Foo(object):
1776 def foo(self):
1777 def foo1():
1778 pass
1779 def foo2():
1780 pass
1781"
1782 (goto-char (point-max))
1783 (should (equal
1784 (list
1785 (list
1786 "Foo (class)"
1787 (cons "*class definition*" (copy-marker 2))
1788 (list
1789 "foo (def)"
1790 (cons "*function definition*" (copy-marker 21))
1791 (cons "foo1 (def)" (copy-marker 40))
1792 (cons "foo2 (def)" (copy-marker 77)))))
1793 (python-imenu-create-index)))))
1794
1747(ert-deftest python-imenu-create-flat-index-1 () 1795(ert-deftest python-imenu-create-flat-index-1 ()
1748 (python-tests-with-temp-buffer 1796 (python-tests-with-temp-buffer
1749 " 1797 "
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index a18899df02f..ad805f16777 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -21,6 +21,7 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
24(require 'ruby-mode) 25(require 'ruby-mode)
25 26
26(defun ruby-should-indent (content column) 27(defun ruby-should-indent (content column)
@@ -474,29 +475,30 @@ VALUES-PLIST is a list with alternating index and value elements."
474 (with-temp-buffer 475 (with-temp-buffer
475 (insert ruby-block-test-example) 476 (insert ruby-block-test-example)
476 (ruby-mode) 477 (ruby-mode)
478 (goto-char (point-min))
477 ,@body))) 479 ,@body)))
478 480
479(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) 481(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun)
480 482
481(ruby-deftest-move-to-block works-on-do 483(ruby-deftest-move-to-block works-on-do
482 (goto-line 11) 484 (forward-line 10)
483 (ruby-end-of-block) 485 (ruby-end-of-block)
484 (should (= 13 (line-number-at-pos))) 486 (should (= 13 (line-number-at-pos)))
485 (ruby-beginning-of-block) 487 (ruby-beginning-of-block)
486 (should (= 11 (line-number-at-pos)))) 488 (should (= 11 (line-number-at-pos))))
487 489
488(ruby-deftest-move-to-block zero-is-noop 490(ruby-deftest-move-to-block zero-is-noop
489 (goto-line 5) 491 (forward-line 4)
490 (ruby-move-to-block 0) 492 (ruby-move-to-block 0)
491 (should (= 5 (line-number-at-pos)))) 493 (should (= 5 (line-number-at-pos))))
492 494
493(ruby-deftest-move-to-block ok-with-three 495(ruby-deftest-move-to-block ok-with-three
494 (goto-line 2) 496 (forward-line 1)
495 (ruby-move-to-block 3) 497 (ruby-move-to-block 3)
496 (should (= 14 (line-number-at-pos)))) 498 (should (= 14 (line-number-at-pos))))
497 499
498(ruby-deftest-move-to-block ok-with-minus-two 500(ruby-deftest-move-to-block ok-with-minus-two
499 (goto-line 10) 501 (forward-line 9)
500 (ruby-move-to-block -2) 502 (ruby-move-to-block -2)
501 (should (= 2 (line-number-at-pos)))) 503 (should (= 2 (line-number-at-pos))))
502 504
@@ -514,7 +516,7 @@ VALUES-PLIST is a list with alternating index and value elements."
514 | | 516 | |
515 |end"))) 517 |end")))
516 (ruby-with-temp-buffer s 518 (ruby-with-temp-buffer s
517 (goto-line 1) 519 (goto-char (point-min))
518 (ruby-end-of-block) 520 (ruby-end-of-block)
519 (should (= 5 (line-number-at-pos))) 521 (should (= 5 (line-number-at-pos)))
520 (ruby-beginning-of-block) 522 (ruby-beginning-of-block)
@@ -529,7 +531,7 @@ VALUES-PLIST is a list with alternating index and value elements."
529 | end 531 | end
530 | eowarn 532 | eowarn
531 |end") 533 |end")
532 (goto-line 1) 534 (goto-char (point-min))
533 (ruby-end-of-block) 535 (ruby-end-of-block)
534 (should (= 6 (line-number-at-pos))) 536 (should (= 6 (line-number-at-pos)))
535 (ruby-beginning-of-block) 537 (ruby-beginning-of-block)
@@ -541,11 +543,22 @@ VALUES-PLIST is a list with alternating index and value elements."
541 "foo do 543 "foo do
542 | Module.to_s 544 | Module.to_s
543 |end") 545 |end")
544 (end-of-buffer)
545 (let ((case-fold-search t)) 546 (let ((case-fold-search t))
546 (ruby-beginning-of-block)) 547 (ruby-beginning-of-block))
547 (should (= 1 (line-number-at-pos))))) 548 (should (= 1 (line-number-at-pos)))))
548 549
550(ert-deftest ruby-move-to-block-moves-from-else-to-if ()
551 (ruby-with-temp-buffer (ruby-test-string
552 "if true
553 | nested_block do
554 | end
555 |else
556 |end")
557 (goto-char (point-min))
558 (forward-line 3)
559 (ruby-beginning-of-block)
560 (should (= 1 (line-number-at-pos)))))
561
549(ert-deftest ruby-beginning-of-defun-does-not-fold-case () 562(ert-deftest ruby-beginning-of-defun-does-not-fold-case ()
550 (ruby-with-temp-buffer 563 (ruby-with-temp-buffer
551 (ruby-test-string 564 (ruby-test-string
@@ -554,7 +567,8 @@ VALUES-PLIST is a list with alternating index and value elements."
554 | Class.to_s 567 | Class.to_s
555 | end 568 | end
556 |end") 569 |end")
557 (goto-line 4) 570 (goto-char (point-min))
571 (forward-line 3)
558 (let ((case-fold-search t)) 572 (let ((case-fold-search t))
559 (beginning-of-defun)) 573 (beginning-of-defun))
560 (should (= 2 (line-number-at-pos))))) 574 (should (= 2 (line-number-at-pos)))))
@@ -567,7 +581,8 @@ VALUES-PLIST is a list with alternating index and value elements."
567 | 'ho hum' 581 | 'ho hum'
568 | end 582 | end
569 |end") 583 |end")
570 (goto-line 2) 584 (goto-char (point-min))
585 (forward-line 1)
571 (end-of-defun) 586 (end-of-defun)
572 (should (= 5 (line-number-at-pos))))) 587 (should (= 5 (line-number-at-pos)))))
573 588
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el
index 98b0c52728b..87c55c5d374 100644
--- a/test/automated/undo-tests.el
+++ b/test/automated/undo-tests.el
@@ -200,6 +200,32 @@
200 '(error "Unrecognized entry in undo list \"bogus\"")))) 200 '(error "Unrecognized entry in undo list \"bogus\""))))
201 (buffer-string)))))) 201 (buffer-string))))))
202 202
203;; http://debbugs.gnu.org/14824
204(ert-deftest undo-test-buffer-modified ()
205 "Test undoing marks buffer unmodified."
206 (with-temp-buffer
207 (buffer-enable-undo)
208 (insert "1")
209 (undo-boundary)
210 (set-buffer-modified-p nil)
211 (insert "2")
212 (undo)
213 (should-not (buffer-modified-p))))
214
215(ert-deftest undo-test-file-modified ()
216 "Test undoing marks buffer visiting file unmodified."
217 (let ((tempfile (make-temp-file "undo-test")))
218 (unwind-protect
219 (progn
220 (with-current-buffer (find-file-noselect tempfile)
221 (insert "1")
222 (undo-boundary)
223 (set-buffer-modified-p nil)
224 (insert "2")
225 (undo)
226 (should-not (buffer-modified-p))))
227 (delete-file tempfile))))
228
203(defun undo-test-all (&optional interactive) 229(defun undo-test-all (&optional interactive)
204 "Run all tests for \\[undo]." 230 "Run all tests for \\[undo]."
205 (interactive "p") 231 (interactive "p")
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el
index 874ae01affb..9157a0d3002 100644
--- a/test/automated/xml-parse-tests.el
+++ b/test/automated/xml-parse-tests.el
@@ -27,6 +27,7 @@
27 27
28;;; Code: 28;;; Code:
29 29
30(require 'ert)
30(require 'xml) 31(require 'xml)
31 32
32(defvar xml-parse-tests--data 33(defvar xml-parse-tests--data