From feb7e20179471458b702ada2521272e913598314 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 8 Sep 2014 21:20:01 -0400 Subject: [PATCH 01/14] NEWS fix display-buffer-in-previous-window existed before 24.4, but was not in display-buffer-fallback-action --- etc/NEWS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 654160c4a7a..70dfc504a0b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -240,9 +240,6 @@ of the buffer is visible). *** New display actions functions for `display-buffer': -**** `display-buffer-in-previous-window' displays a buffer in a window -previously showing that buffer. - **** `display-buffer-at-bottom' chooses or creates a window at the bottom of the selected frame. @@ -252,6 +249,9 @@ bottom of the selected frame. caller of `display-buffer' is ready to handle the case of not displaying the buffer in a window. +*** `display-buffer-in-previous-window' is now a member of +`display-buffer-fallback-action'. + ** Lisp evaluation *** `eval-defun' on an already defined defcustom calls the :set function, From da604136b92764f159442496a9b18cb48204787e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 9 Sep 2014 18:00:51 +0300 Subject: [PATCH 02/14] Fix mouse-dragging mode lines on text-mode terminals. lisp/mouse.el (mouse-drag-line): On text-mode frames, count the mode line and header line as 1 pixel. This fixes the 1-"pixel" (row) discrepancy between window-pixel-edges and mouse events, and avoids moving mode line up when the mouse click is on the modeline and no drag is attempted. --- lisp/ChangeLog | 8 ++++++++ lisp/mouse.el | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2bd234e12e0..9f31741a1c5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2014-09-09 Eli Zaretskii + + * mouse.el (mouse-drag-line): On text-mode frames, count the mode + line and header line as 1 pixel. This fixes the 1-"pixel" (row) + discrepancy between window-pixel-edges and mouse events, and + avoids moving mode line up when the mouse click is on the modeline + and no drag is attempted. + 2014-09-08 Glenn Morris * calendar/calendar.el (calendar-basic-setup): diff --git a/lisp/mouse.el b/lisp/mouse.el index 99407d9f9cf..d84c6c119ed 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -395,7 +395,16 @@ must be one of the symbols `header', `mode', or `vertical'." ;; Check whether header-line can be dragged at all. (if (window-at-side-p window 'top) (setq draggable nil) - (setq height (/ (window-header-line-height window) 2)) + ;; window-pixel-edges includes the header and mode lines, so + ;; we need to account for that when calculating window growth. + ;; On GUI frames, assume the mouse is approximately in the + ;; middle of the header/mode line, so we need only half the + ;; height in pixels. + (setq height + (cond + ((display-graphic-p frame) + (/ (window-header-line-height window) 2)) + (t (window-header-line-height window)))) (setq window (window-in-direction 'above window t)))) ((eq line 'mode) ;; Check whether mode-line can be dragged at all. @@ -410,7 +419,11 @@ must be one of the symbols `header', `mode', or `vertical'." (eq minibuffer-window (active-minibuffer-window)))))) (setq draggable nil) - (setq height (/ (window-mode-line-height window) 2)))) + (setq height + (cond + ((display-graphic-p frame) + (/ (window-mode-line-height window) 2)) + (t (window-mode-line-height window)))))) ((eq line 'vertical) ;; Get the window to adjust for the vertical case. If the scroll ;; bar is on the window's right or we drag a vertical divider, From 1acb1beff16b4df3512f0fe59850ed4541d038c3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 9 Sep 2014 18:04:35 +0300 Subject: [PATCH 03/14] Fix the row number mistakenly reported by pos_visible_p in rare cases. src/xdisp.c (pos_visible_p): Properly save and restore the iterator state around the call to line_bottom, since it can move the iterator to another screen line. This fixes off-by-one errors in the reported row in some rare cases. --- src/ChangeLog | 7 +++++++ src/xdisp.c | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e834a2cc161..274817d8262 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-09-09 Eli Zaretskii + + * xdisp.c (pos_visible_p): Properly save and restore the iterator + state around the call to line_bottom, since it can move the + iterator to another screen line. This fixes off-by-one errors in + the reported row in some rare cases. + 2014-09-07 Eli Zaretskii * dispnew.c (prepare_desired_row): When MODE_LINE_P is zero, diff --git a/src/xdisp.c b/src/xdisp.c index d435bf148a0..6991e44b931 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1452,11 +1452,15 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, glyph. */ int top_x = it.current_x; int top_y = it.current_y; - /* Calling line_bottom_y may change it.method, it.position, etc. */ - enum it_method it_method = it.method; - int bottom_y = (last_height = 0, line_bottom_y (&it)); int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w); + int bottom_y; + struct it save_it; + void *save_it_data = NULL; + /* Calling line_bottom_y may change it.method, it.position, etc. */ + SAVE_IT (save_it, it, save_it_data); + last_height = 0; + bottom_y = line_bottom_y (&it); if (top_y < window_top_y) visible_p = bottom_y > window_top_y; else if (top_y < it.last_visible_y) @@ -1473,7 +1477,6 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, move_it_to again with a slightly larger vertical limit, and see if it actually moved vertically; if it did, we didn't really reach CHARPOS, which is beyond window end. */ - struct it save_it = it; /* Why 10? because we don't know how many canonical lines will the height of the next line(s) be. So we guess. */ int ten_more_lines = 10 * default_line_pixel_height (w); @@ -1483,11 +1486,11 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, if (it.current_y > top_y) visible_p = 0; - it = save_it; } + RESTORE_IT (&it, &save_it, save_it_data); if (visible_p) { - if (it_method == GET_FROM_DISPLAY_VECTOR) + if (it.method == GET_FROM_DISPLAY_VECTOR) { /* We stopped on the last glyph of a display vector. Try and recompute. Hack alert! */ From b0fb34364bede539a904fb89c8adc8830ee8c652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Tue, 9 Sep 2014 19:46:28 +0200 Subject: [PATCH 04/14] * nsterm.m (updateFrameSize:, initFrameFromEmacs:) (toggleFullScreen:): Take frame_resize_pixelwise into account when setting resize increments. Fixes: debbugs:18435 --- src/ChangeLog | 6 ++++++ src/nsterm.m | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 274817d8262..fc1f1af853b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-09-09 Jan Djärv + + * nsterm.m (updateFrameSize:, initFrameFromEmacs:) + (toggleFullScreen:): Take frame_resize_pixelwise into account when + setting resize increments (Bug#18435). + 2014-09-09 Eli Zaretskii * xdisp.c (pos_visible_p): Properly save and restore the iterator diff --git a/src/nsterm.m b/src/nsterm.m index 4b1ebb2b516..833b8e389a9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5821,10 +5821,13 @@ not_in_argv (NSString *arg) // Did resize increments change because of a font change? if (sz.width != FRAME_COLUMN_WIDTH (emacsframe) || - sz.height != FRAME_LINE_HEIGHT (emacsframe)) + sz.height != FRAME_LINE_HEIGHT (emacsframe) || + (frame_resize_pixelwise && sz.width != 1)) { - sz.width = FRAME_COLUMN_WIDTH (emacsframe); - sz.height = FRAME_LINE_HEIGHT (emacsframe); + sz.width = frame_resize_pixelwise + ? 1 : FRAME_COLUMN_WIDTH (emacsframe); + sz.height = frame_resize_pixelwise + ? 1 : FRAME_LINE_HEIGHT (emacsframe); [win setResizeIncrements: sz]; NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); @@ -6086,8 +6089,8 @@ if (cols > 0 && rows > 0) [win setDelegate: self]; [win useOptimizedDrawing: YES]; - sz.width = FRAME_COLUMN_WIDTH (f); - sz.height = FRAME_LINE_HEIGHT (f); + sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); + sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); [win setResizeIncrements: sz]; [[win contentView] addSubview: self]; @@ -6434,8 +6437,8 @@ if (cols > 0 && rows > 0) (FRAME_DEFAULT_FACE (f)), f); - sz.width = FRAME_COLUMN_WIDTH (f); - sz.height = FRAME_LINE_HEIGHT (f); + sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); + sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); if (fs_state != FULLSCREEN_BOTH) { From d7a3bb022cdd7d63b6af679a08d4570304d8f28e Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 9 Sep 2014 14:09:54 -0400 Subject: [PATCH 05/14] * calendar/diary-lib.el (diary-list-entries): Restore 24.3 display behavior. Fixes: debbugs:18381 --- lisp/ChangeLog | 5 +++++ lisp/calendar/diary-lib.el | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9f31741a1c5..7018d3c8abb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-09-09 Glenn Morris + + * calendar/diary-lib.el (diary-list-entries): + Restore 24.3 display behavior. (Bug#18381) + 2014-09-09 Eli Zaretskii * mouse.el (mouse-drag-line): On text-mode frames, count the mode diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index c609cee7d6f..7b07f4f6814 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -1,7 +1,6 @@ ;;; diary-lib.el --- diary functions -;; Copyright (C) 1989-1990, 1992-1995, 2001-2014 Free Software -;; Foundation, Inc. +;; Copyright (C) 1989-1990, 1992-1995, 2001-2014 Free Software Foundation, Inc. ;; Author: Edward M. Reingold ;; Maintainer: Glenn Morris @@ -901,12 +900,20 @@ LIST-ONLY is non-nil, in which case it just returns the list." ;;; (diary-include-other-diary-files) ; recurse ;;; (run-hooks 'diary-list-entries-hook)) (unless list-only - (if (and diary-display-function - (listp diary-display-function)) - ;; Backwards compatibility. - (run-hooks 'diary-display-function) - (funcall (or diary-display-function - 'diary-simple-display)))) + ;; Avoid M-x diary; M-x calendar; M-x diary + ;; clobbering the calendar window. + ;; FIXME this is not the right solution. + (let ((display-buffer-fallback-action + (list (delq + 'display-buffer-in-previous-window + (copy-sequence + (car display-buffer-fallback-action)))))) + (if (and diary-display-function + (listp diary-display-function)) + ;; Backwards compatibility. + (run-hooks 'diary-display-function) + (funcall (or diary-display-function + 'diary-simple-display))))) (run-hooks 'diary-hook))))) (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff))) (or d-incp (message "Preparing diary...done")) From 7c2aaeb4f6ee5c209283ab0c6bdf3f0918f3de98 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 9 Sep 2014 21:23:26 +0300 Subject: [PATCH 06/14] src/xdisp.c (pos_visible_p): Don't assign a boolean value to an int var. --- src/xdisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xdisp.c b/src/xdisp.c index 6991e44b931..6b327c84290 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1464,7 +1464,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, if (top_y < window_top_y) visible_p = bottom_y > window_top_y; else if (top_y < it.last_visible_y) - visible_p = true; + visible_p = 1; if (bottom_y >= it.last_visible_y && it.bidi_p && it.bidi_it.scan_dir == -1 && IT_CHARPOS (it) < charpos) From 2776a6502b211c45e6b4e65549436d2d8527b6f3 Mon Sep 17 00:00:00 2001 From: Ivan Shmakov Date: Tue, 9 Sep 2014 20:47:20 -0400 Subject: [PATCH 07/14] * lisp/desktop.el (desktop-create-buffer): Check that buffers are still live before burying them. Fixes: debbugs:18373 --- lisp/ChangeLog | 5 +++++ lisp/desktop.el | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7018d3c8abb..46cb4ba0d68 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-09-10 Ivan Shmakov (tiny change) + + * desktop.el (desktop-create-buffer): Check that buffers are still live + before burying them (bug#18373). + 2014-09-09 Glenn Morris * calendar/diary-lib.el (diary-list-entries): diff --git a/lisp/desktop.el b/lisp/desktop.el index 40e6b364e45..360ff48339b 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -1375,7 +1375,9 @@ after that many seconds of idle time." ;; Restore buffer list order with new buffer at end. Don't change ;; the order for old desktop files (old desktop module behavior). (unless (< desktop-file-version 206) - (mapc 'bury-buffer buffer-list) + (dolist (buf buffer-list) + (and (buffer-live-p buf) + (bury-buffer buf))) (when result (bury-buffer result))) (when result (unless (or desktop-first-buffer (< desktop-file-version 206)) From 6e49a66ad282cd8416d6d8ed2646fb9dd7f41bd4 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 11 Sep 2014 10:47:34 +0200 Subject: [PATCH 08/14] In Fresize_mini_window_internal set w->total_lines from w->pixel_height (Bug#18422). * window.c (Fresize_mini_window_internal): Set w->total_lines from w->pixel_height (Bug#18422). --- src/ChangeLog | 5 +++++ src/window.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fc1f1af853b..0117b83feb1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-09-11 Martin Rudalics + + * window.c (Fresize_mini_window_internal): Set w->total_lines + from w->pixel_height (Bug#18422). + 2014-09-09 Jan Djärv * nsterm.m (updateFrameSize:, initFrameFromEmacs:) diff --git a/src/window.c b/src/window.c index 3fefd9ce682..7e50282a39b 100644 --- a/src/window.c +++ b/src/window.c @@ -4804,10 +4804,10 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini block_input (); window_resize_apply (r, 0); - w->total_lines = XFASTINT (w->new_total); - w->top_line = r->top_line + r->total_lines; w->pixel_height = XFASTINT (w->new_pixel); + w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f); w->pixel_top = r->pixel_top + r->pixel_height; + w->top_line = r->top_line + r->total_lines; fset_redisplay (f); FRAME_WINDOW_SIZES_CHANGED (f) = 1; From ab10393e755d0e263760672e0af60287fe472bb7 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 11 Sep 2014 13:35:44 -0400 Subject: [PATCH 09/14] * etc/NEWS: Mention timer error reporting. Ref: http://debbugs.gnu.org/18444#8 --- etc/NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 70dfc504a0b..e8bcdb50b9d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1124,6 +1124,11 @@ and can be accessed by calling the `coding-system-type' function.) *** `with-demoted-errors' takes an additional argument `format'. +*** Errors from timer functions are no longer silently discarded, +but are reported as messages. So you may see "Error running timer" +messages from code that was failing silently till now. Set +`debug-on-error' non-nil to get a real error and a backtrace. + ** Faces *** Face specs set via Custom themes now replace the `defface' spec From c4ea7c96121ec50db8dbfcb4bfe961f23760e3f9 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Fri, 12 Sep 2014 08:26:46 +0200 Subject: [PATCH 10/14] Fix fit-window-to-buffer doc-string. --- lisp/ChangeLog | 4 ++++ lisp/window.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 46cb4ba0d68..822abf9c0fe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-09-12 Kan-Ru Chen + + * window.el (fit-window-to-buffer): Doc fix. + 2014-09-10 Ivan Shmakov (tiny change) * desktop.el (desktop-create-buffer): Check that buffers are still live diff --git a/lisp/window.el b/lisp/window.el index c73f019870b..4dc30ff968c 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7173,7 +7173,7 @@ and header line and a bottom divider, if any. If WINDOW is part of a horizontal combination and the value of the option `fit-window-to-buffer-horizontally' is non-nil, adjust -WINDOW's height. The new width of WINDOW is calculated from the +WINDOW's width. The new width of WINDOW is calculated from the maximum length of its buffer's lines that follow the current start position of WINDOW. The optional argument MAX-WIDTH specifies a maximum width and defaults to the width of WINDOW's From e868e853a85fb4466ab045962a269db31760f354 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 13 Sep 2014 10:10:40 +0300 Subject: [PATCH 11/14] Resurrect sound support on MS-Windows that was lost in transition. configure.ac (HAVE_SOUND): Check for mmsystem.h header that defines the sound stuff on MS-Windows. (Bug#18463) --- ChangeLog | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e0090a45ced..b1951aa6c71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-13 Eli Zaretskii + + * configure.ac (HAVE_SOUND): Check for mmsystem.h header that + defines the sound stuff on MS-Windows. (Bug#18463) + 2014-08-22 Ken Brown * configure.ac (HAVE_XPM): Explain the use of CPPFLAGS in the diff --git a/configure.ac b/configure.ac index d4e1d65ff56..f05c14a319c 100644 --- a/configure.ac +++ b/configure.ac @@ -1398,7 +1398,7 @@ AC_DEFUN([PKG_CHECK_MODULES], [ HAVE_SOUND=no if test "${with_sound}" != "no"; then # Sound support for GNU/Linux, the free BSDs, and MinGW. - AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h], + AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h], have_sound_header=yes, [], [ #ifdef __MINGW32__ #define WIN32_LEAN_AND_MEAN From a6cc335aef90cb4a2dc3fde77cbea9886240301e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 13 Sep 2014 11:26:44 +0300 Subject: [PATCH 12/14] Fix expansion and encoding of sound file names on MS-Windows. src/sound.c (Fplay_sound_internal): Encode the sound file name in the ANSI codepage. Expand it against data-directory, as per docs, not against the current directory. No need to make a local copy of the file name; pass the encoded file name directly to do_play_sound. (Bug#18463) src/w32.c (ansi_encode_filename): If w32_get_short_filename returns NULL, and the file name is not encodable in ANSI codepage, return the string with "?" replacement characters, which will fail the caller. This avoids returning a random value in that case. --- src/ChangeLog | 13 +++++++++++++ src/sound.c | 18 ++++++++++-------- src/w32.c | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0117b83feb1..4f851edb0fd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2014-09-13 Eli Zaretskii + + * sound.c (Fplay_sound_internal): Encode the sound file name in + the ANSI codepage. Expand it against data-directory, as per docs, + not against the current directory. No need to make a local copy + of the file name; pass the encoded file name directly to + do_play_sound. (Bug#18463) + + * w32.c (ansi_encode_filename): If w32_get_short_filename returns + NULL, and the file name is not encodable in ANSI codepage, return + the string with "?" replacement characters, which will fail the + caller. This avoids returning a random value in that case. + 2014-09-11 Martin Rudalics * window.c (Fresize_mini_window_internal): Set w->total_lines diff --git a/src/sound.c b/src/sound.c index a95678812e1..552f75b68e8 100644 --- a/src/sound.c +++ b/src/sound.c @@ -88,6 +88,9 @@ along with GNU Emacs. If not, see . */ #include #include #include + +#include "coding.h" +#include "w32.h" /* END: Windows Specific Includes */ #endif /* WINDOWSNT */ @@ -1309,9 +1312,7 @@ Internal use only, use `play-sound' instead. */) struct gcpro gcpro1, gcpro2; Lisp_Object args[2]; #else /* WINDOWSNT */ - int len = 0; - Lisp_Object lo_file = {0}; - char * psz_file = NULL; + Lisp_Object lo_file; unsigned long ui_volume_tmp = UINT_MAX; unsigned long ui_volume = UINT_MAX; #endif /* WINDOWSNT */ @@ -1383,10 +1384,11 @@ Internal use only, use `play-sound' instead. */) #else /* WINDOWSNT */ - lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil); - len = XSTRING (lo_file)->size; - psz_file = alloca (len + 1); - strcpy (psz_file, XSTRING (lo_file)->data); + lo_file = Fexpand_file_name (attrs[SOUND_FILE], Vdata_directory); + lo_file = ENCODE_FILE (lo_file); + /* Since UNICOWS.DLL includes only a stub for mciSendStringW, we + need to encode the file in the ANSI codepage. */ + lo_file = ansi_encode_filename (lo_file); if (INTEGERP (attrs[SOUND_VOLUME])) { ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]); @@ -1408,7 +1410,7 @@ Internal use only, use `play-sound' instead. */) { ui_volume = ui_volume_tmp * (UINT_MAX / 100); } - do_play_sound (psz_file, ui_volume); + do_play_sound (SDATA (lo_file), ui_volume); #endif /* WINDOWSNT */ diff --git a/src/w32.c b/src/w32.c index 15e53600d95..fee1be22739 100644 --- a/src/w32.c +++ b/src/w32.c @@ -2387,6 +2387,8 @@ ansi_encode_filename (Lisp_Object filename) dostounix_filename (shortname); encoded_filename = build_string (shortname); } + else + encoded_filename = build_unibyte_string (fname); } else encoded_filename = build_unibyte_string (fname); From 9ed670023f6d7534f0e812417fe13ab3cfadaa7a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 14 Sep 2014 18:18:39 +0300 Subject: [PATCH 13/14] Fix bug #18420 with deadlocks communicating with subprocess on MS-Windows. src/w32.c (fcntl): Support O_NONBLOCK fcntl on the write side of pipes. (sys_write): When a write to a non-blocking pipe returns ENOSPC, set errno to EAGAIN instead, to allow the caller to retry the write after some waiting. Fixes deadlocks when Emacs exchanges a lot of data through the pipe. --- src/ChangeLog | 9 +++++++++ src/w32.c | 54 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 4f851edb0fd..c32b4c44988 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2014-09-14 Eli Zaretskii + + * w32.c (fcntl): Support O_NONBLOCK fcntl on the write side of + pipes. + (sys_write): When a write to a non-blocking pipe returns ENOSPC, + set errno to EAGAIN instead, to allow the caller to retry the + write after some waiting. Fixes deadlocks when Emacs exchanges a + lot of data through the pipe. (Bug#18420) + 2014-09-13 Eli Zaretskii * sound.c (Fplay_sound_internal): Encode the sound file name in diff --git a/src/w32.c b/src/w32.c index fee1be22739..aba0b5a81f9 100644 --- a/src/w32.c +++ b/src/w32.c @@ -7690,15 +7690,15 @@ fcntl (int s, int cmd, int options) if (cmd == F_DUPFD_CLOEXEC) return sys_dup (s); - if (winsock_lib == NULL) - { - errno = ENETDOWN; - return -1; - } - check_errno (); if (fd_info[s].flags & FILE_SOCKET) { + if (winsock_lib == NULL) + { + errno = ENETDOWN; + return -1; + } + if (cmd == F_SETFL && options == O_NONBLOCK) { unsigned long nblock = 1; @@ -7715,13 +7715,36 @@ fcntl (int s, int cmd, int options) return SOCKET_ERROR; } } + else if ((fd_info[s].flags & (FILE_PIPE | FILE_WRITE)) + == (FILE_PIPE | FILE_WRITE)) + { + /* Force our writes to pipes be non-blocking. */ + if (cmd == F_SETFL && options == O_NONBLOCK) + { + HANDLE h = (HANDLE)_get_osfhandle (s); + DWORD pipe_mode = PIPE_NOWAIT; + + if (!SetNamedPipeHandleState (h, &pipe_mode, NULL, NULL)) + { + DebPrint (("SetNamedPipeHandleState: %lu\n", GetLastError ())); + return SOCKET_ERROR; + } + fd_info[s].flags |= FILE_NDELAY; + return 0; + } + else + { + errno = EINVAL; + return SOCKET_ERROR; + } + } errno = ENOTSOCK; return SOCKET_ERROR; } /* Shadow main io functions: we need to handle pipes and sockets more - intelligently, and implement non-blocking mode as well. */ + intelligently. */ int sys_close (int fd) @@ -8206,7 +8229,6 @@ sys_read (int fd, char * buffer, unsigned int count) /* From w32xfns.c */ extern HANDLE interrupt_handle; -/* For now, don't bother with a non-blocking mode */ int sys_write (int fd, const void * buffer, unsigned int count) { @@ -8341,6 +8363,22 @@ sys_write (int fd, const void * buffer, unsigned int count) nchars += n; if (n < 0) { + /* When there's no buffer space in a pipe that is in the + non-blocking mode, _write returns ENOSPC. We return + EAGAIN instead, which should trigger the logic in + send_process that enters waiting loop and calls + wait_reading_process_output to allow process input to + be accepted during the wait. Those calls to + wait_reading_process_output allow sys_select to + notice when process input becomes available, thus + avoiding deadlock whereby each side of the pipe is + blocked on write, waiting for the other party to read + its end of the pipe. */ + if (errno == ENOSPC + && fd < MAXDESC + && ((fd_info[fd].flags & (FILE_PIPE | FILE_NDELAY)) + == (FILE_PIPE | FILE_NDELAY))) + errno = EAGAIN; nchars = n; break; } From d4dc0e1691a15efd1ea0a8793cf889e683a37933 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 14 Sep 2014 16:59:57 -0700 Subject: [PATCH 14/14] * lisp/image.el (image-multi-frame-p): Fix thinko do not force a delay if none was specified. Fixes: debbugs:18334 --- lisp/ChangeLog | 5 +++++ lisp/image.el | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 822abf9c0fe..b696eb61ab9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-09-14 Glenn Morris + + * image.el (image-multi-frame-p): Fix thinko - do not force + a delay if none was specified. (Bug#18334) + 2014-09-12 Kan-Ru Chen * window.el (fit-window-to-buffer): Doc fix. diff --git a/lisp/image.el b/lisp/image.el index ef39fa7909f..8430d36a627 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -637,8 +637,8 @@ in which case you might want to use `image-default-frame-delay'." (images (plist-get metadata 'count)) (delay (plist-get metadata 'delay))) (when (and images (> images 1)) - (if (or (not (numberp delay)) (< delay 0)) - (setq delay image-default-frame-delay)) + (and delay (or (not (numberp delay)) (< delay 0)) + (setq delay image-default-frame-delay)) (cons images delay))))) (defun image-animated-p (image)