commit 6acff25280dbb97b5e9ddfd872b33ceb36b0470a (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Mon Sep 5 19:57:22 2016 +0300 Avoid assertion violations when scrolling narrowed buffer * src/window.c (window_scroll_pixel_based): * src/xdisp.c (pos_visible_p): Don't allow simulated redisplay to start outside the accessible portion of the buffer. This avoids assertion violations when some Lisp narrows the buffer to less than the current window, and then attempts to scroll the buffer. diff --git a/src/window.c b/src/window.c index 374ef0f..753ebc1 100644 --- a/src/window.c +++ b/src/window.c @@ -4813,8 +4813,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) SET_TEXT_POS_FROM_MARKER (start, w->start); /* Scrolling a minibuffer window via scroll bar when the echo area shows long text sometimes resets the minibuffer contents behind - our backs. */ - if (CHARPOS (start) > ZV) + our backs. Also, someone might narrow-to-region and immediately + call a scroll function. */ + if (CHARPOS (start) > ZV || CHARPOS (start) < BEGV) SET_TEXT_POS (start, BEGV, BEGV_BYTE); /* If PT is not visible in WINDOW, move back one half of diff --git a/src/xdisp.c b/src/xdisp.c index dc68cd4..d1e8848 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1317,8 +1317,9 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, SET_TEXT_POS_FROM_MARKER (top, w->start); /* Scrolling a minibuffer window via scroll bar when the echo area shows long text sometimes resets the minibuffer contents behind - our backs. */ - if (CHARPOS (top) > ZV) + our backs. Also, someone might narrow-to-region and immediately + call a scroll function. */ + if (CHARPOS (top) > ZV || CHARPOS (top) < BEGV) SET_TEXT_POS (top, BEGV, BEGV_BYTE); /* If the top of the window is after CHARPOS, the latter is surely commit cfaf18a27c262694750400005e882f1cfc7ff2b0 Author: Eli Zaretskii Date: Mon Sep 5 19:50:59 2016 +0300 Treat SIGINT correctly in GUI sessions on MS-Windows * src/w32proc.c (sys_signal): Don't reject SIGINT, as it is supported by MS runtime. * src/term.c (DEV_TTY): Move from here ... * src/conf_post.h (DEV_TTY): ... to here. Separate definitions for WINDOWSNT and for the rest. * src/keyboard.c (handle_interrupt_signal): Use DEV_TTY instead of a literal "/dev/tty". * etc/NEWS: Mention the behavior change. diff --git a/etc/NEWS b/etc/NEWS index 3092e9f..79a476c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -607,6 +607,13 @@ still apply.) Previously, on MS-Windows this function converted slash characters in file names into backslashes. It no longer does that. +** GUI sessions now treat SIGINT like Posix platforms do. +The effect of delivering a Ctrl-C (SIGINT) signal to a GUI Emacs on +MS-Windows is now the same as on Posix platforms -- Emacs saves the +session and exits. In particular, this will happen if you start +emacs.exe from the Windows shell, then type Ctrl-C into that shell's +window. + * Installation Changes in Emacs 25.1 diff --git a/src/conf_post.h b/src/conf_post.h index 865d018..bc8b096 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -140,6 +140,10 @@ typedef bool bool_bf; #undef HAVE_RINT #endif /* HPUX */ +#ifdef WINDOWSNT +# define DEV_TTY "CONOUT$" +#endif + #ifdef MSDOS #ifndef __DJGPP__ You lose; /* Emacs for DOS must be compiled with DJGPP */ @@ -242,6 +246,11 @@ extern int emacs_setenv_TZ (char const *); #include #include +#ifndef DEV_TTY +# define DEV_TTY "/dev/tty" +#endif + + #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ #define NO_INLINE __attribute__((noinline)) #else diff --git a/src/keyboard.c b/src/keyboard.c index e441552..3ef797c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10241,7 +10241,7 @@ static void handle_interrupt_signal (int sig) { /* See if we have an active terminal on our controlling tty. */ - struct terminal *terminal = get_named_terminal ("/dev/tty"); + struct terminal *terminal = get_named_terminal (DEV_TTY); if (!terminal) { /* If there are no frames there, let's pretend that we are a diff --git a/src/term.c b/src/term.c index d54ff11..cb684b3 100644 --- a/src/term.c +++ b/src/term.c @@ -58,10 +58,7 @@ static int been_here = -1; /* The name of the default console device. */ #ifdef WINDOWSNT -#define DEV_TTY "CONOUT$" #include "w32term.h" -#else -#define DEV_TTY "/dev/tty" #endif static void tty_set_scroll_region (struct frame *f, int start, int stop); diff --git a/src/w32proc.c b/src/w32proc.c index 11a121f..217d005 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -86,9 +86,9 @@ sys_signal (int sig, signal_handler handler) /* SIGCHLD is needed for supporting subprocesses, see sys_kill below. SIGALRM and SIGPROF are used by setitimer. All the others are the only ones supported by the MS runtime. */ - if (!(sig == SIGCHLD || sig == SIGSEGV || sig == SIGILL + if (!(sig == SIGINT || sig == SIGSEGV || sig == SIGILL || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM - || sig == SIGALRM || sig == SIGPROF)) + || sig == SIGCHLD || sig == SIGALRM || sig == SIGPROF)) { errno = EINVAL; return SIG_ERR;