From 3711339f92be0c50633aefae991d8fa4a135fe33 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Fri, 1 Jan 2021 10:36:39 +0000 Subject: Fix crash in ns_mouse_position (bug#45541) * src/nsterm.m (ns_mouse_position): Explicitly initialize f to NULL. ; Do not merge to master --- src/nsterm.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nsterm.m b/src/nsterm.m index b75c6c7ef56..b8658a05daf 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2480,7 +2480,7 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, id view; NSPoint view_position; Lisp_Object frame, tail; - struct frame *f; + struct frame *f = NULL; struct ns_display_info *dpyinfo; NSTRACE ("ns_mouse_position"); -- cgit v1.3 From ad2567fb1efced752352096f345c69f88e1ff405 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 3 Jan 2021 16:15:18 +0000 Subject: Fix child frame restacking on NS (bug#41422) * src/nsfns.m (Fns_frame_restack): Use new restackWindow method. * src/nsterm.m ([EmacsWindow orderFront:]): ([EmacsWindow makeKeyAndOrderFront:]): (nswindow_orderedIndex_sort): ([EmacsWindow orderBack:]): ([EmacsWindow restackWindow:above:]): Override superclass methods to handle child windows the way we want. --- src/nsfns.m | 14 ++++---- src/nsterm.h | 1 + src/nsterm.m | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nsfns.m b/src/nsfns.m index ee2daea0723..ae114f83e4d 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1485,14 +1485,14 @@ Some window managers may refuse to restack windows. */) if (FRAME_NS_VIEW (f1) && FRAME_NS_VIEW (f2)) { - NSWindow *window = [FRAME_NS_VIEW (f1) window]; - NSInteger window2 = [[FRAME_NS_VIEW (f2) window] windowNumber]; - NSWindowOrderingMode flag = NILP (above) ? NSWindowBelow : NSWindowAbove; + EmacsWindow *window = (EmacsWindow *)[FRAME_NS_VIEW (f1) window]; + NSWindow *window2 = [FRAME_NS_VIEW (f2) window]; + BOOL flag = !NILP (above); - [window orderWindow: flag - relativeTo: window2]; - - return Qt; + if ([window restackWindow:window2 above:!NILP (above)]) + return Qt; + else + return Qnil; } else { diff --git a/src/nsterm.h b/src/nsterm.h index 3fb64494f76..2c9d8e85ba9 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -498,6 +498,7 @@ typedef id instancetype; NSPoint grabOffset; } +- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above; - (void)setAppearance; @end diff --git a/src/nsterm.m b/src/nsterm.m index 27310639508..2defb9e2eec 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -8693,6 +8693,112 @@ not_in_argv (NSString *arg) @implementation EmacsWindow +/* It seems the only way to reorder child frames is by removing them + from the parent and then reattaching them in the correct order. */ + +- (void)orderFront:(id)sender +{ + NSTRACE ("[EmacsWindow orderFront:]"); + + NSWindow *parent = [self parentWindow]; + if (parent) + { + [parent removeChildWindow:self]; + [parent addChildWindow:self ordered:NSWindowAbove]; + } + else + [super orderFront:sender]; +} + +- (void)makeKeyAndOrderFront:(id)sender +{ + NSTRACE ("[EmacsWindow makeKeyAndOrderFront:]"); + + if ([self parentWindow]) + { + [self orderFront:sender]; + [self makeKeyWindow]; + } + else + [super makeKeyAndOrderFront:sender]; +} + + +/* The array returned by [NSWindow parentWindow] may already be + sorted, but the documentation doesn't tell us whether or not it is, + so to be safe we'll sort it. */ +NSInteger nswindow_orderedIndex_sort (id w1, id w2, void *c) +{ + NSInteger i1 = [w1 orderedIndex]; + NSInteger i2 = [w2 orderedIndex]; + + if (i1 > i2) + return NSOrderedAscending; + if (i1 < i2) + return NSOrderedDescending; + + return NSOrderedSame; +} + +- (void)orderBack:(id)sender +{ + NSTRACE ("[EmacsWindow orderBack:]"); + + NSWindow *parent = [self parentWindow]; + if (parent) + { + NSArray *children = [[parent childWindows] + sortedArrayUsingFunction:nswindow_orderedIndex_sort + context:nil]; + [parent removeChildWindow:self]; + [parent addChildWindow:self ordered:NSWindowAbove]; + + for (NSWindow *win in children) + { + if (win != self) + { + [parent removeChildWindow:win]; + [parent addChildWindow:win ordered:NSWindowAbove]; + } + } + } + else + [super orderBack:sender]; +} + +- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above +{ + NSTRACE ("[EmacsWindow restackWindow:above:]"); + + /* If parent windows don't match we can't restack these frames + without changing the parents. */ + if ([self parentWindow] != [win parentWindow]) + return NO; + else if (![self parentWindow]) + [self orderWindow:(above ? NSWindowAbove : NSWindowBelow) + relativeTo:[win windowNumber]]; + else + { + NSInteger index; + NSWindow *parent = [self parentWindow]; + NSMutableArray *children = [[[parent childWindows] + sortedArrayUsingFunction:nswindow_orderedIndex_sort + context:nil] + mutableCopy]; + [children removeObject:self]; + index = [children indexOfObject:win]; + [children insertObject:self atIndex:(above ? index+1 : index)]; + + for (NSWindow *w in children) + { + [parent removeChildWindow:w]; + [parent addChildWindow:w ordered:NSWindowAbove]; + } + } + + return YES; +} + #ifdef NS_IMPL_COCOA - (id)accessibilityAttributeValue:(NSString *)attribute { -- cgit v1.3 From 585997d05adde5a3510ce1221f9e8dd60407ce30 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 3 Jan 2021 11:19:48 -0800 Subject: Fix broken build on AIX 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, the build on AIX 7.2 with xlc fails in the ‘CCLD temacs’ step with the diagnostic ‘ld: 0711-317 ERROR: Undefined symbol: BC’. This is because -lcurses does not define BC etc. * configure.ac: When building terminfo.o, define TERMINFO_DEFINES_BC if the library defines BC etc. * src/terminfo.c (UP, BC, PC): Define depending on TERMINFO_DEFINES_BC, not on TERMINFO. --- configure.ac | 12 ++++++++++++ src/terminfo.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/configure.ac b/configure.ac index 48e96529ff2..89b0785d031 100644 --- a/configure.ac +++ b/configure.ac @@ -4366,6 +4366,18 @@ TERMCAP_OBJ=tparam.o if test $TERMINFO = yes; then AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.]) TERMCAP_OBJ=terminfo.o + AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC], + [emacs_cv_terminfo_defines_BC], + [OLD_LIBS=$LIBS + LIBS="$LIBS $LIBS_TERMCAP" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])], + [emacs_cv_terminfo_defines_BC=yes], + [emacs_cv_terminfo_defines_BC=no]) + LIBS=$OLD_LIBS]) + if test "$emacs_cv_terminfo_defines_BC" = yes; then + AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the + terminfo library defines the variables BC, PC, and UP.]) + fi fi if test "X$LIBS_TERMCAP" = "X-lncurses"; then AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.]) diff --git a/src/terminfo.c b/src/terminfo.c index 15aff317f15..a9c9572bbb2 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -23,10 +23,10 @@ along with GNU Emacs. If not, see . */ /* Define these variables that serve as global parameters to termcap, so that we do not need to conditionalize the places in Emacs - that set them. But don't do that for terminfo, as that could - cause link errors when using -fno-common. */ + that set them. But don't do that if terminfo defines them, as that + could cause link errors when using -fno-common. */ -#if !TERMINFO +#ifndef TERMINFO_DEFINES_BC char *UP, *BC, PC; #endif -- cgit v1.3 From 2e09efdb6877a2c189385be45d4cdceb617b6c5d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 3 Jan 2021 11:58:34 -0800 Subject: Revert previous patch which was installed into wrong branch. --- configure.ac | 12 ------------ src/terminfo.c | 6 +++--- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/configure.ac b/configure.ac index 89b0785d031..48e96529ff2 100644 --- a/configure.ac +++ b/configure.ac @@ -4366,18 +4366,6 @@ TERMCAP_OBJ=tparam.o if test $TERMINFO = yes; then AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.]) TERMCAP_OBJ=terminfo.o - AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC], - [emacs_cv_terminfo_defines_BC], - [OLD_LIBS=$LIBS - LIBS="$LIBS $LIBS_TERMCAP" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])], - [emacs_cv_terminfo_defines_BC=yes], - [emacs_cv_terminfo_defines_BC=no]) - LIBS=$OLD_LIBS]) - if test "$emacs_cv_terminfo_defines_BC" = yes; then - AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the - terminfo library defines the variables BC, PC, and UP.]) - fi fi if test "X$LIBS_TERMCAP" = "X-lncurses"; then AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.]) diff --git a/src/terminfo.c b/src/terminfo.c index a9c9572bbb2..15aff317f15 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -23,10 +23,10 @@ along with GNU Emacs. If not, see . */ /* Define these variables that serve as global parameters to termcap, so that we do not need to conditionalize the places in Emacs - that set them. But don't do that if terminfo defines them, as that - could cause link errors when using -fno-common. */ + that set them. But don't do that for terminfo, as that could + cause link errors when using -fno-common. */ -#ifndef TERMINFO_DEFINES_BC +#if !TERMINFO char *UP, *BC, PC; #endif -- cgit v1.3 From 632917461a7c1893a83979a3873b51d4da3b8a42 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 3 Jan 2021 11:19:48 -0800 Subject: Fix broken build on AIX 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, the build on AIX 7.2 with xlc fails in the ‘CCLD temacs’ step with the diagnostic ‘ld: 0711-317 ERROR: Undefined symbol: BC’. This is because -lcurses does not define BC etc. * configure.ac: When building terminfo.o, define TERMINFO_DEFINES_BC if the library defines BC etc. * src/terminfo.c (UP, BC, PC): Define depending on TERMINFO_DEFINES_BC, not on TERMINFO. --- configure.ac | 12 ++++++++++++ src/terminfo.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/configure.ac b/configure.ac index bcc0be7de03..66c660696b7 100644 --- a/configure.ac +++ b/configure.ac @@ -4393,6 +4393,18 @@ TERMCAP_OBJ=tparam.o if test $TERMINFO = yes; then AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.]) TERMCAP_OBJ=terminfo.o + AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC], + [emacs_cv_terminfo_defines_BC], + [OLD_LIBS=$LIBS + LIBS="$LIBS $LIBS_TERMCAP" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])], + [emacs_cv_terminfo_defines_BC=yes], + [emacs_cv_terminfo_defines_BC=no]) + LIBS=$OLD_LIBS]) + if test "$emacs_cv_terminfo_defines_BC" = yes; then + AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the + terminfo library defines the variables BC, PC, and UP.]) + fi fi if test "X$LIBS_TERMCAP" = "X-lncurses"; then AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.]) diff --git a/src/terminfo.c b/src/terminfo.c index 15aff317f15..a9c9572bbb2 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -23,10 +23,10 @@ along with GNU Emacs. If not, see . */ /* Define these variables that serve as global parameters to termcap, so that we do not need to conditionalize the places in Emacs - that set them. But don't do that for terminfo, as that could - cause link errors when using -fno-common. */ + that set them. But don't do that if terminfo defines them, as that + could cause link errors when using -fno-common. */ -#if !TERMINFO +#ifndef TERMINFO_DEFINES_BC char *UP, *BC, PC; #endif -- cgit v1.3 From c2e0f1982f886a9c269fed50a3fc904ca2e1655a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 3 Jan 2021 16:07:16 -0500 Subject: * src/buffer.c (Fset_buffer_multibyte): Remove dead code --- src/buffer.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/buffer.c b/src/buffer.c index 81f7d922fdb..0a7ff6e6752 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2602,8 +2602,6 @@ current buffer is cleared. */) p += bytes, pos += bytes; } } - if (narrowed) - Fnarrow_to_region (make_fixnum (begv), make_fixnum (zv)); } else { @@ -2682,9 +2680,6 @@ current buffer is cleared. */) if (pt != PT) TEMP_SET_PT (pt); - if (narrowed) - Fnarrow_to_region (make_fixnum (begv), make_fixnum (zv)); - /* Do this first, so that chars_in_text asks the right question. set_intervals_multibyte needs it too. */ bset_enable_multibyte_characters (current_buffer, Qt); -- cgit v1.3 From b2f8c9f96fbda53387b9f910d3b97aefefab6cab Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 4 Jan 2021 00:59:56 -0500 Subject: * src/xdisp.c (syms_of_xdisp): New var redisplay-skip-fontification-on-input (handle_fontified_prop): Use it. * src/keyboard.h (input_was_pending): Declare. * src/keyboard.c (input_was_pending): Make non-static. --- etc/NEWS | 6 ++++++ src/keyboard.c | 2 +- src/keyboard.h | 2 +- src/xdisp.c | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/etc/NEWS b/etc/NEWS index 8003175a83a..d8f25ab362e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -212,6 +212,12 @@ This makes debugging Emacs Lisp scripts run in batch mode easier. To get back the old behavior, set the new variable 'backtrace-on-error-noninteractive' to a nil value. +** 'redisplay-skip-fontification-on-input' helps Emacs keep up with fast input. +This is another attempt to solve the problem of handling high key repeat rate +and other "slow scrolling" situations. It is hoped it behaves better +than 'fast-but-imprecise-scrolling' and 'jit-lock-defer-time'. +It is not enabled by default. + * Editing Changes in Emacs 28.1 diff --git a/src/keyboard.c b/src/keyboard.c index d2f0cb405f0..cf15cd73572 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -285,7 +285,7 @@ bool input_pending; with the input rate, but if it can keep up just enough that there's no input_pending when we begin the command, then redisplay is not skipped which results in better feedback to the user. */ -static bool input_was_pending; +bool input_was_pending; /* Circular buffer for pre-read keyboard input. */ diff --git a/src/keyboard.h b/src/keyboard.h index 91c6f4604f9..8bdffaa2bff 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -432,7 +432,7 @@ extern int parse_solitary_modifier (Lisp_Object symbol); extern Lisp_Object real_this_command; extern int quit_char; - +extern bool input_was_pending; extern unsigned int timers_run; extern bool menu_separator_name_p (const char *); diff --git a/src/xdisp.c b/src/xdisp.c index 749893baad6..43447e2bf7e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4262,6 +4262,7 @@ handle_fontified_prop (struct it *it) if (!STRINGP (it->string) && it->s == NULL && !NILP (Vfontification_functions) + && !(input_was_pending && redisplay_skip_fontification_on_input) && !NILP (Vrun_hooks) && (pos = make_fixnum (IT_CHARPOS (*it)), prop = Fget_char_property (pos, Qfontified, Qnil), @@ -35598,6 +35599,19 @@ best except in special circumstances such as running redisplay tests in batch mode. */); redisplay_skip_initial_frame = true; + DEFVAR_BOOL ("redisplay-skip-fontification-on-input", + redisplay_skip_fontification_on_input, + doc: /* Skip `fontification_functions` when there is input pending. +If non-nil and there was input pending at the beginning of the command, +the `fontification_functions` hook is not run. This usually does not +affect the display because redisplay is completely skipped anyway if input +was pending, but it can make scrolling smoother by avoiding +unnecessary fontification. +It is similar to `fast-but-imprecise-scrolling' with similar tradeoffs, +but with the advantage that it should only affect the behavior when Emacs +has trouble keeping up with the incoming input rate. */); + redisplay_skip_fontification_on_input = false; + DEFVAR_BOOL ("redisplay-adhoc-scroll-in-resize-mini-windows", redisplay_adhoc_scroll_in_resize_mini_windows, doc: /* If nil always use normal scrolling in minibuffer windows. -- cgit v1.3 From 90951f847c04d288121d5cb3b2e03639f060125c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 4 Jan 2021 01:00:33 -0500 Subject: * src/print.c (print_vectorlike): Use `HASH_TABLE_SIZE` --- src/lisp.h | 4 ++-- src/print.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lisp.h b/src/lisp.h index 0ad788cff84..5cc735be86c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1478,8 +1478,8 @@ struct Lisp_String { struct { - ptrdiff_t size; - ptrdiff_t size_byte; + ptrdiff_t size; /* MSB is used as the markbit. */ + ptrdiff_t size_byte; /* Set to -1 for unibyte strings. */ INTERVAL intervals; /* Text properties in this string. */ unsigned char *data; } s; diff --git a/src/print.c b/src/print.c index 94a8bcbf882..14af9195475 100644 --- a/src/print.c +++ b/src/print.c @@ -1557,7 +1557,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, /* Implement a readable output, e.g.: #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ /* Always print the size. */ - int len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); + int len = sprintf (buf, "#s(hash-table size %"pD"d", + HASH_TABLE_SIZE (h)); strout (buf, len, len, printcharfun); if (!NILP (h->test.name)) -- cgit v1.3 From 65f21729e60f831026ce134b87561c5119b6a926 Mon Sep 17 00:00:00 2001 From: Amin Bandali Date: Mon, 4 Jan 2021 10:48:08 +0100 Subject: Fix off-by-one error in mode-line-compact code * src/xdisp.c (display_mode_line): Fix off-by-one error that would chop off the final non-space character when compacting (bug#45646). --- src/xdisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xdisp.c b/src/xdisp.c index 43447e2bf7e..6a4304d194b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -25504,7 +25504,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) if (start < i) display_string (NULL, Fsubstring (mode_string, make_fixnum (start), - make_fixnum (i - 1)), + make_fixnum (i)), Qnil, 0, 0, &it, 0, 0, 0, STRING_MULTIBYTE (mode_string)); } -- cgit v1.3 From 56556b5f4d73d9c3683fa7573e6bd89f2ef37902 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Mon, 4 Jan 2021 13:09:40 +0000 Subject: Fix build for --enable-checking=structs The last change to lisp.h only added comments in Lisp_String, so the portable dumper need not be changed. * src/pdumper.c (dump_string): Update hash for Lisp_String. --- src/pdumper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdumper.c b/src/pdumper.c index 6956ee36829..116cc28dbba 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2058,7 +2058,7 @@ dump_interval_tree (struct dump_context *ctx, static dump_off dump_string (struct dump_context *ctx, const struct Lisp_String *string) { -#if CHECK_STRUCTS && !defined (HASH_Lisp_String_86FEA6EC7C) +#if CHECK_STRUCTS && !defined (HASH_Lisp_String_348C2B2FDB) # error "Lisp_String changed. See CHECK_STRUCTS comment in config.h." #endif /* If we have text properties, write them _after_ the string so that -- cgit v1.3 From fa574e68dec8255e211fbca95e187083ec6eabb4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 3 Jan 2021 11:19:48 -0800 Subject: Fix broken build on AIX 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, the build on AIX 7.2 with xlc fails in the ‘CCLD temacs’ step with the diagnostic ‘ld: 0711-317 ERROR: Undefined symbol: BC’. This is because -lcurses does not define BC etc. * configure.ac: When building terminfo.o, define TERMINFO_DEFINES_BC if the library defines BC etc. * src/terminfo.c (UP, BC, PC): Define depending on TERMINFO_DEFINES_BC, not on TERMINFO. (cherry picked from commit 632917461a7c1893a83979a3873b51d4da3b8a42) --- configure.ac | 12 ++++++++++++ src/terminfo.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/configure.ac b/configure.ac index bcc0be7de03..66c660696b7 100644 --- a/configure.ac +++ b/configure.ac @@ -4393,6 +4393,18 @@ TERMCAP_OBJ=tparam.o if test $TERMINFO = yes; then AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.]) TERMCAP_OBJ=terminfo.o + AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC], + [emacs_cv_terminfo_defines_BC], + [OLD_LIBS=$LIBS + LIBS="$LIBS $LIBS_TERMCAP" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])], + [emacs_cv_terminfo_defines_BC=yes], + [emacs_cv_terminfo_defines_BC=no]) + LIBS=$OLD_LIBS]) + if test "$emacs_cv_terminfo_defines_BC" = yes; then + AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the + terminfo library defines the variables BC, PC, and UP.]) + fi fi if test "X$LIBS_TERMCAP" = "X-lncurses"; then AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.]) diff --git a/src/terminfo.c b/src/terminfo.c index 15aff317f15..a9c9572bbb2 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -23,10 +23,10 @@ along with GNU Emacs. If not, see . */ /* Define these variables that serve as global parameters to termcap, so that we do not need to conditionalize the places in Emacs - that set them. But don't do that for terminfo, as that could - cause link errors when using -fno-common. */ + that set them. But don't do that if terminfo defines them, as that + could cause link errors when using -fno-common. */ -#if !TERMINFO +#ifndef TERMINFO_DEFINES_BC char *UP, *BC, PC; #endif -- cgit v1.3 From 97226aacfde717ec48fa8931c870497e089da17b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Jan 2021 10:33:43 -0800 Subject: Do not assume Xrender merely because Cairo Problem reported by Andrea Corallo in: https://lists.gnu.org/r/emacs-devel/2021-01/msg00225.html * src/xterm.c (x_term_init) [USE_CAIRO && !HAVE_XRENDER]: Do not call XRenderQueryExtension. --- src/xterm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/xterm.c b/src/xterm.c index 0a86738cc20..b8374fed8b1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -13035,13 +13035,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) or larger than other for other applications, even if it is the same font name (monospace-10 for example). */ +# ifdef HAVE_XRENDER int event_base, error_base; - char *v; - double d; - XRenderQueryExtension (dpyinfo->display, &event_base, &error_base); +# endif - v = XGetDefault (dpyinfo->display, "Xft", "dpi"); + char *v = XGetDefault (dpyinfo->display, "Xft", "dpi"); + double d; if (v != NULL && sscanf (v, "%lf", &d) == 1) dpyinfo->resy = dpyinfo->resx = d; } -- cgit v1.3 From d6f30e5632b1c9cf43ebfbdbf164d5c54be33475 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 4 Jan 2021 22:57:21 -0500 Subject: * lisp/subr.el (global-map): Initialize inside declaration. * src/commands.h (global_map): * src/keymap.c (global_map): Delete variable. (syms_of_keymap): Don't initialize global_map here. (keys_of_keymap): Delete function. * src/lisp.h (keys_of_cmds): * src/cmds.c (keys_of_cmds): Delete function. * src/emacs.c (main): Don't call them. * src/window.c (keys_of_window): Don't initialize global_map here. * src/keyboard.c (keys_of_keyboard): Don't initialize global_map here. --- lisp/subr.el | 36 +++++++++++++++++++++++++++++++----- src/cmds.c | 21 --------------------- src/commands.h | 1 - src/emacs.c | 2 -- src/keyboard.c | 2 -- src/keymap.c | 15 +-------------- src/keymap.h | 1 - src/lisp.h | 1 - src/window.c | 1 - 9 files changed, 32 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/lisp/subr.el b/lisp/subr.el index 1acc3c3250b..6187f7ad3c4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1242,11 +1242,6 @@ in a cleaner way with command remapping, like this: ;; global-map, esc-map, and ctl-x-map have their values set up in ;; keymap.c; we just give them docstrings here. -(defvar global-map nil - "Default global keymap mapping Emacs keyboard input into commands. -The value is a keymap that is usually (but not necessarily) Emacs's -global map.") - (defvar esc-map nil "Default keymap for ESC (meta) commands. The normal global definition of the character ESC indirects to this keymap.") @@ -1269,6 +1264,37 @@ The normal global definition of the character C-x indirects to this keymap.") "Keymap for tab-bar related commands.") (define-key ctl-x-map "t" tab-prefix-map) +(defvar global-map + (let ((map (make-keymap))) + (define-key map "\C-[" 'ESC-prefix) + (define-key map "\C-x" 'Control-X-prefix) + + (define-key map "\C-i" #'self-insert-command) + (let* ((vec1 (make-vector 1 nil)) + (f (lambda (from to) + (while (< from to) + (aset vec1 0 from) + (define-key map vec1 #'self-insert-command) + (setq from (1+ from)))))) + (funcall f #o040 #o0177) + (when (eq system-type 'ms-dos) ;FIXME: Why? + (funcall f #o0200 #o0240)) + (funcall f #o0240 #o0400)) + + (define-key map "\C-a" #'beginning-of-line) + (define-key map "\C-b" #'backward-char) + (define-key map "\C-e" #'end-of-line) + (define-key map "\C-f" #'forward-char) + (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later! + + (define-key map "\C-v" #'scroll-up-command) + (define-key map "\C-]" #'abort-recursive-edit) + map) + "Default global keymap mapping Emacs keyboard input into commands. +The value is a keymap that is usually (but not necessarily) Emacs's +global map.") +(use-global-map global-map) + ;;;; Event manipulation functions. diff --git a/src/cmds.c b/src/cmds.c index 798fd68a920..1547db80e88 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -529,24 +529,3 @@ This is run after inserting the character. */); defsubr (&Sdelete_char); defsubr (&Sself_insert_command); } - -void -keys_of_cmds (void) -{ - int n; - - initial_define_key (global_map, Ctl ('I'), "self-insert-command"); - for (n = 040; n < 0177; n++) - initial_define_key (global_map, n, "self-insert-command"); -#ifdef MSDOS - for (n = 0200; n < 0240; n++) - initial_define_key (global_map, n, "self-insert-command"); -#endif - for (n = 0240; n < 0400; n++) - initial_define_key (global_map, n, "self-insert-command"); - - initial_define_key (global_map, Ctl ('A'), "beginning-of-line"); - initial_define_key (global_map, Ctl ('B'), "backward-char"); - initial_define_key (global_map, Ctl ('E'), "end-of-line"); - initial_define_key (global_map, Ctl ('F'), "forward-char"); -} diff --git a/src/commands.h b/src/commands.h index a09858d050d..be6f5823bcc 100644 --- a/src/commands.h +++ b/src/commands.h @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see . */ calls to initial_define_key. These should *not* be used after initialization; use-global-map doesn't affect these; it sets current_global_map instead. */ -extern Lisp_Object global_map; extern Lisp_Object meta_map; extern Lisp_Object control_x_map; diff --git a/src/emacs.c b/src/emacs.c index fe8dcb1c476..3c293d85edd 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1957,10 +1957,8 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif keys_of_casefiddle (); - keys_of_cmds (); keys_of_buffer (); keys_of_keyboard (); - keys_of_keymap (); keys_of_window (); } else diff --git a/src/keyboard.c b/src/keyboard.c index cf15cd73572..52d913c537d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12388,10 +12388,8 @@ syms_of_keyboard_for_pdumper (void) void keys_of_keyboard (void) { - initial_define_key (global_map, Ctl ('Z'), "suspend-emacs"); initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs"); initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit"); - initial_define_key (global_map, Ctl (']'), "abort-recursive-edit"); initial_define_key (meta_map, 'x', "execute-extended-command"); initial_define_lispy_key (Vspecial_event_map, "delete-frame", diff --git a/src/keymap.c b/src/keymap.c index 1eeea81f627..772ced42ccd 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -59,8 +59,6 @@ along with GNU Emacs. If not, see . */ Lisp_Object current_global_map; /* Current global keymap. */ -Lisp_Object global_map; /* Default global key bindings. */ - Lisp_Object meta_map; /* The keymap used for globally bound ESC-prefixed default commands. */ @@ -3195,11 +3193,7 @@ syms_of_keymap (void) Each one is the value of a Lisp variable, and is also pointed to by a C variable */ - global_map = Fmake_keymap (Qnil); - Fset (intern_c_string ("global-map"), global_map); - - current_global_map = global_map; - staticpro (&global_map); + current_global_map = Qnil; staticpro (¤t_global_map); meta_map = Fmake_keymap (Qnil); @@ -3328,10 +3322,3 @@ be preferred. */); defsubr (&Swhere_is_internal); defsubr (&Sdescribe_buffer_bindings); } - -void -keys_of_keymap (void) -{ - initial_define_key (global_map, 033, "ESC-prefix"); - initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); -} diff --git a/src/keymap.h b/src/keymap.h index 072c09348e2..1967025dcb4 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -40,7 +40,6 @@ extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **); extern void initial_define_key (Lisp_Object, int, const char *); extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); extern void syms_of_keymap (void); -extern void keys_of_keymap (void); typedef void (*map_keymap_function_t) (Lisp_Object key, Lisp_Object val, Lisp_Object args, void *data); diff --git a/src/lisp.h b/src/lisp.h index 5cc735be86c..d259e950dab 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3561,7 +3561,6 @@ extern void swap_in_global_binding (struct Lisp_Symbol *); /* Defined in cmds.c */ extern void syms_of_cmds (void); -extern void keys_of_cmds (void); /* Defined in coding.c. */ extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, diff --git a/src/window.c b/src/window.c index ba8682eed7c..f2862a287d6 100644 --- a/src/window.c +++ b/src/window.c @@ -8590,7 +8590,6 @@ keys_of_window (void) initial_define_key (control_x_map, '<', "scroll-left"); initial_define_key (control_x_map, '>', "scroll-right"); - initial_define_key (global_map, Ctl ('V'), "scroll-up-command"); initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); initial_define_key (meta_map, 'v', "scroll-down-command"); } -- cgit v1.3 From 5bddc097385c1d9088748ed92abc2370857b2202 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 4 Jan 2021 23:11:07 -0500 Subject: * lisp/subr.el (ctl-x-map): Initialize inside the declaration. * src/command.h (control_x_map): * src/keymap.c (control_x_map): Delete variable. (syms_of_keymap): * src/keyboard.c (keys_of_keyboard): * src/casefiddle.c (keys_of_casefiddle): * src/window.c (keys_of_window): Move initialization of ctl-x-map to subr.el. * src/lisp.h (syms_of_buffer): * src/buffer.c (keys_of_buffer): Delete function. * src/emacs.c (main): Don't call it. --- lisp/subr.el | 29 ++++++++++++++++++++--------- src/buffer.c | 7 ------- src/casefiddle.c | 5 ----- src/commands.h | 1 - src/emacs.c | 1 - src/keyboard.c | 1 - src/keymap.c | 7 ------- src/lisp.h | 1 - src/window.c | 3 --- 9 files changed, 20 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/lisp/subr.el b/lisp/subr.el index 6187f7ad3c4..206e71ac03b 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1246,23 +1246,34 @@ in a cleaner way with command remapping, like this: "Default keymap for ESC (meta) commands. The normal global definition of the character ESC indirects to this keymap.") -(defvar ctl-x-map nil - "Default keymap for C-x commands. -The normal global definition of the character C-x indirects to this keymap.") - (defvar ctl-x-4-map (make-sparse-keymap) "Keymap for subcommands of C-x 4.") (defalias 'ctl-x-4-prefix ctl-x-4-map) -(define-key ctl-x-map "4" 'ctl-x-4-prefix) (defvar ctl-x-5-map (make-sparse-keymap) "Keymap for frame commands.") (defalias 'ctl-x-5-prefix ctl-x-5-map) -(define-key ctl-x-map "5" 'ctl-x-5-prefix) (defvar tab-prefix-map (make-sparse-keymap) "Keymap for tab-bar related commands.") -(define-key ctl-x-map "t" tab-prefix-map) + +(defvar ctl-x-map + (let ((map (make-keymap))) + (define-key map "4" 'ctl-x-4-prefix) + (define-key map "5" 'ctl-x-5-prefix) + (define-key map "t" tab-prefix-map) + + (define-key map "b" #'switch-to-buffer) + (define-key map "l" #'kill-buffer) + (define-key map "\C-u" #'upcase-region) (put 'upcase-region 'disabled t) + (define-key map "\C-l" #'downcase-region) (put 'downcase-region 'disabled t) + (define-key map "<" #'scroll-left) + (define-key map ">" #'scroll-right) + map) + "Default keymap for C-x commands. +The normal global definition of the character C-x indirects to this keymap.") +(fset 'Control-X-prefix ctl-x-map) +(make-obsolete 'Control-X-prefix 'ctl-x-map "28.1") (defvar global-map (let ((map (make-keymap))) @@ -1285,8 +1296,8 @@ The normal global definition of the character C-x indirects to this keymap.") (define-key map "\C-b" #'backward-char) (define-key map "\C-e" #'end-of-line) (define-key map "\C-f" #'forward-char) - (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later! - + (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later! + (define-key map "\C-x\C-z" #'suspend-emacs) ;FIXME: Re-bound later! (define-key map "\C-v" #'scroll-up-command) (define-key map "\C-]" #'abort-recursive-edit) map) diff --git a/src/buffer.c b/src/buffer.c index 0a7ff6e6752..71ad5edd527 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -6380,10 +6380,3 @@ nil NORECORD argument since it may lead to infinite recursion. */); Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt); } - -void -keys_of_buffer (void) -{ - initial_define_key (control_x_map, 'b', "switch-to-buffer"); - initial_define_key (control_x_map, 'k', "kill-buffer"); -} diff --git a/src/casefiddle.c b/src/casefiddle.c index a948bb3bc88..42de9722ecd 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -686,11 +686,6 @@ Called with one argument METHOD which can be: void keys_of_casefiddle (void) { - initial_define_key (control_x_map, Ctl ('U'), "upcase-region"); - Fput (intern ("upcase-region"), Qdisabled, Qt); - initial_define_key (control_x_map, Ctl ('L'), "downcase-region"); - Fput (intern ("downcase-region"), Qdisabled, Qt); - initial_define_key (meta_map, 'u', "upcase-word"); initial_define_key (meta_map, 'l', "downcase-word"); initial_define_key (meta_map, 'c', "capitalize-word"); diff --git a/src/commands.h b/src/commands.h index be6f5823bcc..8f9c76b1e2d 100644 --- a/src/commands.h +++ b/src/commands.h @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see . */ initialization; use-global-map doesn't affect these; it sets current_global_map instead. */ extern Lisp_Object meta_map; -extern Lisp_Object control_x_map; /* If not Qnil, this is a switch-frame event which we decided to put off until the end of a key sequence. This should be read as the diff --git a/src/emacs.c b/src/emacs.c index 3c293d85edd..18b54dd07ef 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1957,7 +1957,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif keys_of_casefiddle (); - keys_of_buffer (); keys_of_keyboard (); keys_of_window (); } diff --git a/src/keyboard.c b/src/keyboard.c index 52d913c537d..bb4d981fe59 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12388,7 +12388,6 @@ syms_of_keyboard_for_pdumper (void) void keys_of_keyboard (void) { - initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs"); initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit"); initial_define_key (meta_map, 'x', "execute-extended-command"); diff --git a/src/keymap.c b/src/keymap.c index 772ced42ccd..171f9460412 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -62,9 +62,6 @@ Lisp_Object current_global_map; /* Current global keymap. */ Lisp_Object meta_map; /* The keymap used for globally bound ESC-prefixed default commands. */ -Lisp_Object control_x_map; /* The keymap used for globally bound - C-x-prefixed default commands. */ - /* The keymap used by the minibuf for local bindings when spaces are allowed in the minibuf. */ @@ -3200,10 +3197,6 @@ syms_of_keymap (void) Fset (intern_c_string ("esc-map"), meta_map); Ffset (intern_c_string ("ESC-prefix"), meta_map); - control_x_map = Fmake_keymap (Qnil); - Fset (intern_c_string ("ctl-x-map"), control_x_map); - Ffset (intern_c_string ("Control-X-prefix"), control_x_map); - exclude_keys = pure_list (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), diff --git a/src/lisp.h b/src/lisp.h index d259e950dab..915ad64f6e1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4261,7 +4261,6 @@ extern Lisp_Object get_truename_buffer (Lisp_Object); extern void init_buffer_once (void); extern void init_buffer (void); extern void syms_of_buffer (void); -extern void keys_of_buffer (void); /* Defined in marker.c. */ diff --git a/src/window.c b/src/window.c index f2862a287d6..29d499ccd45 100644 --- a/src/window.c +++ b/src/window.c @@ -8587,9 +8587,6 @@ displayed after a scrolling operation to be somewhat inaccurate. */); void keys_of_window (void) { - initial_define_key (control_x_map, '<', "scroll-left"); - initial_define_key (control_x_map, '>', "scroll-right"); - initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); initial_define_key (meta_map, 'v', "scroll-down-command"); } -- cgit v1.3 From 8ef4314c44a046e92bcd7dddde26203a9d641f09 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 4 Jan 2021 23:20:44 -0500 Subject: * lisp/subr.el (esc-map): Initialize inside declaration * src/commands.h (meta_map): * src/keymap.c (meta_map): Delete variable. (syms_of_keymap): Don't initialize esc-map here. (initial_define_key): * src/keymap.h (initial_define_key): Delete function. * src/keyboard.c (keys_of_keyboard): Don't initialize esc-map here. * src/window.h (keys_of_window): * src/window.c (keys_of_window): Delete function. * src/lisp.h (keys_of_casefiddle): * src/casefiddle.c (keys_of_casefiddle): Delete function. * src/emacs.c (main): Don't call them. --- lisp/subr.el | 22 ++++++++++++++++++---- src/casefiddle.c | 8 -------- src/commands.h | 6 ------ src/emacs.c | 2 -- src/keyboard.c | 3 --- src/keymap.c | 28 ---------------------------- src/keymap.h | 1 - src/lisp.h | 1 - src/window.c | 7 ------- src/window.h | 1 - 10 files changed, 18 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/lisp/subr.el b/lisp/subr.el index 206e71ac03b..60a77859c43 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1242,9 +1242,17 @@ in a cleaner way with command remapping, like this: ;; global-map, esc-map, and ctl-x-map have their values set up in ;; keymap.c; we just give them docstrings here. -(defvar esc-map nil +(defvar esc-map + (let ((map (make-keymap))) + (define-key map "u" #'upcase-word) + (define-key map "l" #'downcase-word) + (define-key map "c" #'capitalize-word) + (define-key map "x" #'execute-extended-command) + map) "Default keymap for ESC (meta) commands. The normal global definition of the character ESC indirects to this keymap.") +(fset 'ESC-prefix esc-map) +(make-obsolete 'ESC-prefix 'esc-map "28.1") (defvar ctl-x-4-map (make-sparse-keymap) "Keymap for subcommands of C-x 4.") @@ -1273,7 +1281,7 @@ The normal global definition of the character ESC indirects to this keymap.") "Default keymap for C-x commands. The normal global definition of the character C-x indirects to this keymap.") (fset 'Control-X-prefix ctl-x-map) -(make-obsolete 'Control-X-prefix 'ctl-x-map "28.1") +(make-obsolete 'Control-X-prefix 'ctl-x-map "28.1") (defvar global-map (let ((map (make-keymap))) @@ -1296,10 +1304,16 @@ The normal global definition of the character C-x indirects to this keymap.") (define-key map "\C-b" #'backward-char) (define-key map "\C-e" #'end-of-line) (define-key map "\C-f" #'forward-char) + (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later! (define-key map "\C-x\C-z" #'suspend-emacs) ;FIXME: Re-bound later! - (define-key map "\C-v" #'scroll-up-command) - (define-key map "\C-]" #'abort-recursive-edit) + + (define-key map "\C-v" #'scroll-up-command) + (define-key map "\M-v" #'scroll-down-command) + (define-key map "\M-\C-v" #'scroll-other-window) + + (define-key map "\M-\C-c" #'exit-recursive-edit) + (define-key map "\C-]" #'abort-recursive-edit) map) "Default global keymap mapping Emacs keyboard input into commands. The value is a keymap that is usually (but not necessarily) Emacs's diff --git a/src/casefiddle.c b/src/casefiddle.c index 42de9722ecd..a7a25414909 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -682,11 +682,3 @@ Called with one argument METHOD which can be: defsubr (&Sdowncase_word); defsubr (&Scapitalize_word); } - -void -keys_of_casefiddle (void) -{ - initial_define_key (meta_map, 'u', "upcase-word"); - initial_define_key (meta_map, 'l', "downcase-word"); - initial_define_key (meta_map, 'c', "capitalize-word"); -} diff --git a/src/commands.h b/src/commands.h index 8f9c76b1e2d..2205ebf7d39 100644 --- a/src/commands.h +++ b/src/commands.h @@ -23,12 +23,6 @@ along with GNU Emacs. If not, see . */ #define Ctl(c) ((c)&037) -/* Define the names of keymaps, just so people can refer to them in - calls to initial_define_key. These should *not* be used after - initialization; use-global-map doesn't affect these; it sets - current_global_map instead. */ -extern Lisp_Object meta_map; - /* If not Qnil, this is a switch-frame event which we decided to put off until the end of a key sequence. This should be read as the next command input, after any Vunread_command_events. diff --git a/src/emacs.c b/src/emacs.c index 18b54dd07ef..69d10821fae 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1956,9 +1956,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem syms_of_json (); #endif - keys_of_casefiddle (); keys_of_keyboard (); - keys_of_window (); } else { diff --git a/src/keyboard.c b/src/keyboard.c index bb4d981fe59..9ee4c4f6d68 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12388,9 +12388,6 @@ syms_of_keyboard_for_pdumper (void) void keys_of_keyboard (void) { - initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit"); - initial_define_key (meta_map, 'x', "execute-extended-command"); - initial_define_lispy_key (Vspecial_event_map, "delete-frame", "handle-delete-frame"); #ifdef HAVE_NTGUI diff --git a/src/keymap.c b/src/keymap.c index 171f9460412..37270f5782b 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -59,17 +59,6 @@ along with GNU Emacs. If not, see . */ Lisp_Object current_global_map; /* Current global keymap. */ -Lisp_Object meta_map; /* The keymap used for globally bound - ESC-prefixed default commands. */ - - /* The keymap used by the minibuf for local - bindings when spaces are allowed in the - minibuf. */ - - /* The keymap used by the minibuf for local - bindings when spaces are not encouraged - in the minibuf. */ - /* Alist of elements like (DEL . "\d"). */ static Lisp_Object exclude_keys; @@ -135,19 +124,6 @@ in case you use it as a menu with `x-popup-menu'. */) return list1 (Qkeymap); } -/* This function is used for installing the standard key bindings - at initialization time. - - For example: - - initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */ - -void -initial_define_key (Lisp_Object keymap, int key, const char *defname) -{ - store_in_keymap (keymap, make_fixnum (key), intern_c_string (defname)); -} - void initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname) { @@ -3193,10 +3169,6 @@ syms_of_keymap (void) current_global_map = Qnil; staticpro (¤t_global_map); - meta_map = Fmake_keymap (Qnil); - Fset (intern_c_string ("esc-map"), meta_map); - Ffset (intern_c_string ("ESC-prefix"), meta_map); - exclude_keys = pure_list (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), diff --git a/src/keymap.h b/src/keymap.h index 1967025dcb4..f417301c8f2 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -37,7 +37,6 @@ extern char *push_key_description (EMACS_INT, char *); extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, bool, bool, bool); extern Lisp_Object get_keymap (Lisp_Object, bool, bool); extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **); -extern void initial_define_key (Lisp_Object, int, const char *); extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); extern void syms_of_keymap (void); diff --git a/src/lisp.h b/src/lisp.h index 915ad64f6e1..ca0eb51c061 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4357,7 +4357,6 @@ extern void syms_of_callint (void); /* Defined in casefiddle.c. */ extern void syms_of_casefiddle (void); -extern void keys_of_casefiddle (void); /* Defined in casetab.c. */ diff --git a/src/window.c b/src/window.c index 29d499ccd45..58204c13e44 100644 --- a/src/window.c +++ b/src/window.c @@ -8583,10 +8583,3 @@ displayed after a scrolling operation to be somewhat inaccurate. */); defsubr (&Swindow_parameter); defsubr (&Sset_window_parameter); } - -void -keys_of_window (void) -{ - initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); - initial_define_key (meta_map, 'v', "scroll-down-command"); -} diff --git a/src/window.h b/src/window.h index 1f94fc0252f..332cb3091fd 100644 --- a/src/window.h +++ b/src/window.h @@ -1202,7 +1202,6 @@ extern bool window_outdated (struct window *); extern void init_window_once (void); extern void init_window (void); extern void syms_of_window (void); -extern void keys_of_window (void); /* Move cursor to row/column position VPOS/HPOS, pixel coordinates Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y are window-relative pixel positions. This is always done during -- cgit v1.3 From 7f16f177270e8e69cb8b78fb502caae3653a32cf Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Tue, 29 Dec 2020 16:55:06 +0100 Subject: Pretty-print keys without <> around modifiers (bug#45536) Be consistent when pretty-printing keys: put modifiers outside <>, thus the more logical C-M- instead of . * src/keymap.c (Fsingle_key_description): Skip modifier prefix before adding <>. * doc/lispref/help.texi (Describing Characters): Update example. * doc/lispref/debugging.texi (Backtraces): * doc/lispref/minibuf.texi (Text from Minibuffer): Use @kbd instead of @key. * etc/NEWS: Announce the change. * test/src/keymap-tests.el (keymap--key-description): * test/lisp/subr-tests.el (subr--kbd): New tests. --- doc/lispref/debugging.texi | 2 +- doc/lispref/help.texi | 2 +- doc/lispref/minibuf.texi | 2 +- etc/NEWS | 7 +++++++ src/keymap.c | 20 +++++++++++++++----- test/lisp/subr-tests.el | 8 ++++++++ test/src/keymap-tests.el | 12 ++++++++++++ 7 files changed, 45 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 1e779ac7054..8e4b0ebfe96 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi @@ -424,7 +424,7 @@ move to it and type @key{RET}, to visit the source code. You can also type @key{RET} while point is on any name of a function or variable which is not underlined, to see help information for that symbol in a help buffer, if any exists. The @code{xref-find-definitions} command, -bound to @key{M-.}, can also be used on any identifier in a backtrace +bound to @kbd{M-.}, can also be used on any identifier in a backtrace (@pxref{Looking Up Identifiers,,,emacs, The GNU Emacs Manual}). In backtraces, the tails of long lists and the ends of long strings, diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi index 2fd05b73917..298bec5230c 100644 --- a/doc/lispref/help.texi +++ b/doc/lispref/help.texi @@ -545,7 +545,7 @@ brackets. @end group @group (single-key-description 'C-mouse-1) - @result{} "" + @result{} "C-" @end group @group (single-key-description 'C-mouse-1 t) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 81139b9e746..f0036f0ccfc 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -348,7 +348,7 @@ default, it makes the following bindings: @item @key{RET} @code{exit-minibuffer} -@item @key{M-<} +@item @kbd{M-<} @code{minibuffer-beginning-of-buffer} @item @kbd{C-g} diff --git a/etc/NEWS b/etc/NEWS index ef1c4b39a6f..d1cc422e9f7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -218,6 +218,13 @@ and other "slow scrolling" situations. It is hoped it behaves better than 'fast-but-imprecise-scrolling' and 'jit-lock-defer-time'. It is not enabled by default. ++++ +** Modifiers now go outside angle brackets in pretty-printed key bindings. +For example, with Control and Meta modifiers is now shown as +C-M- instead of . Either variant can be used as +input; functions such as 'kbd' and 'read-kbd-macro' accept both styles +as equivalent (they have done so for a long time). + * Editing Changes in Emacs 28.1 diff --git a/src/keymap.c b/src/keymap.c index 37270f5782b..3d1993869bc 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2188,11 +2188,21 @@ See `text-char-description' for describing character codes. */) { if (NILP (no_angles)) { - Lisp_Object result; - char *buffer = SAFE_ALLOCA (sizeof "<>" - + SBYTES (SYMBOL_NAME (key))); - esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); - result = build_string (buffer); + Lisp_Object namestr = SYMBOL_NAME (key); + const char *sym = SSDATA (namestr); + ptrdiff_t len = SBYTES (namestr); + /* Find the extent of the modifier prefix, like "C-M-". */ + int i = 0; + while (i < len - 3 && sym[i + 1] == '-' && strchr ("CMSsHA", sym[i])) + i += 2; + /* First I bytes of SYM are modifiers; put <> around the rest. */ + char *buffer = SAFE_ALLOCA (len + 3); + memcpy (buffer, sym, i); + buffer[i] = '<'; + memcpy (buffer + i + 1, sym + i, len - i); + buffer [len + 1] = '>'; + buffer [len + 2] = '\0'; + Lisp_Object result = build_string (buffer); SAFE_FREE (); return result; } diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 2f5b38d05d9..8d19a268773 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -630,5 +630,13 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350." (should (>= (length (apropos-internal "^help" #'commandp)) 15)) (should-not (apropos-internal "^next-line$" #'keymapp))) +(ert-deftest subr--kbd () + ;; Check that kbd handles both new and old style key descriptions + ;; (bug#45536). + (should (equal (kbd "s-") [s-return])) + (should (equal (kbd "") [s-return])) + (should (equal (kbd "C-M-") [C-M-return])) + (should (equal (kbd "") [C-M-return]))) + (provide 'subr-tests) ;;; subr-tests.el ends here diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el index 74fb3c892db..d4f5fc3f190 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el @@ -248,6 +248,18 @@ g .. h foo 0 .. 3 foo "))))) +(ert-deftest keymap--key-description () + (should (equal (key-description [right] [?\C-x]) + "C-x ")) + (should (equal (key-description [M-H-right] [?\C-x]) + "C-x M-H-")) + (should (equal (single-key-description 'home) + "")) + (should (equal (single-key-description 'home t) + "home")) + (should (equal (single-key-description 'C-s-home) + "C-s-"))) + (provide 'keymap-tests) ;;; keymap-tests.el ends here -- cgit v1.3 From 048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Tue, 5 Jan 2021 21:43:12 +0000 Subject: Prevent stack overflow in GNUstep menu code * src/nsmenu.m (ns_update_menubar): Always do a deep update for GNUstep. ([EmacsMenu menuNeedsUpdate:]): Don't update the menu as it should always have had a deep update. --- src/nsmenu.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nsmenu.m b/src/nsmenu.m index 9b56958100a..8086f56854e 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -145,6 +145,10 @@ ns_update_menubar (struct frame *f, bool deep_p) t = -(1000*tb.time+tb.millitm); #endif +#ifdef NS_IMPL_GNUSTEP + deep_p = 1; /* See comment in menuNeedsUpdate. */ +#endif + if (deep_p) { /* Make a widget-value tree representing the entire menu trees. */ @@ -433,21 +437,22 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) } -/* Delegate method called when a submenu is being opened: run a 'deep' call - to set_frame_menubar. */ - -/* TODO: GNUstep calls this method when the menu is still being built - which throws it into an infinite loop. One possible solution is to - use menuWillOpen instead, but the Apple docs explicitly warn - against changing the contents of the menu in it. I don't know what - the right thing to do for GNUstep is. */ +/* Delegate method called when a submenu is being opened: run a 'deep' + call to ns_update_menubar. */ - (void)menuNeedsUpdate: (NSMenu *)menu { if (!FRAME_LIVE_P (SELECTED_FRAME ())) return; +#ifdef NS_IMPL_COCOA +/* TODO: GNUstep calls this method when the menu is still being built + which results in a recursive stack overflow. One possible solution + is to use menuWillOpen instead, but the Apple docs explicitly warn + against changing the contents of the menu in it. I don't know what + the right thing to do for GNUstep is. */ if (needsUpdate) ns_update_menubar (SELECTED_FRAME (), true); +#endif } -- cgit v1.3 From 40a0f8a3a2ac790bb398c321e7eb6928da330511 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 7 Jan 2021 16:35:48 +0100 Subject: Add a display-buffer window selection function that's more like XEmacs * doc/lispref/windows.texi (Buffer Display Action Functions): Document it. * lisp/window.el (display-buffer--action-function-custom-type): Add. (display-buffer): Mention it. (display-buffer-use-least-recent-window): New function (bug#45688). * src/window.c (Fwindow_bump_use_time): New function. --- doc/lispref/windows.texi | 6 ++++++ etc/NEWS | 9 +++++++++ lisp/window.el | 13 +++++++++++++ src/window.c | 13 +++++++++++++ 4 files changed, 41 insertions(+) (limited to 'src') diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index b0906acbad5..f305d1a8ee8 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -2634,6 +2634,12 @@ window and displaying the buffer in that window. It can fail if all windows are dedicated to other buffers (@pxref{Dedicated Windows}). @end defun +@defun display-buffer-use-least-recent-window buffer alist +This function is like @code{display-buffer-use-some-window}, but will +not reuse the current window, and will use the least recently +switched-to window. +@end defun + @defun display-buffer-in-direction buffer alist This function tries to display @var{buffer} at a location specified by @var{alist}. For this purpose, @var{alist} should contain a diff --git a/etc/NEWS b/etc/NEWS index 48fb4b88e15..14d6b45c929 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -373,6 +373,15 @@ disabled entirely. ** Windows ++++ +*** New 'display-buffer' function 'display-buffer-use-least-recent-window' +This is like 'display-buffer-use-some-window', but won't reuse the +current window, and when called repeatedly will try not to reuse a +previously selected window. + +*** New function 'window-bump-use-time'. +This updates the use time of a window. + *** The key prefix 'C-x 4 1' displays next command buffer in the same window. It's bound to the command 'same-window-prefix' that requests the buffer of the next command to be displayed in the same window. diff --git a/lisp/window.el b/lisp/window.el index c54a0db211e..37e1800ad11 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7243,6 +7243,7 @@ The actual non-nil value of this variable will be copied to the (const display-buffer-below-selected) (const display-buffer-at-bottom) (const display-buffer-in-previous-window) + (const display-buffer-use-least-recent-window) (const display-buffer-use-some-window) (const display-buffer-use-some-frame) (function :tag "Other function")) @@ -7387,6 +7388,8 @@ to a list containing one of these \"action\" functions: `display-buffer-in-previous-window' -- Use a window that did show the buffer before. `display-buffer-use-some-window' -- Use some existing window. + `display-buffer-use-least-recent-window' -- Try to avoid re-using + windows that have recently been switched to. `display-buffer-pop-up-window' -- Pop up a new window. `display-buffer-below-selected' -- Use or pop up a window below the selected one. @@ -8256,6 +8259,16 @@ indirectly called by the latter." (when (setq window (or best-window second-best-window)) (window--display-buffer buffer window 'reuse alist)))) +(defun display-buffer-use-least-recent-window (buffer alist) + "Display BUFFER in an existing window, but that hasn't been used lately. +This `display-buffer' action function is like +`display-buffer-use-some-window', but will cycle through windows +when displaying buffers repeatedly, and if there's only a single +window, it will split the window." + (when-let ((window (display-buffer-use-some-window + buffer (cons (cons 'inhibit-same-window t) alist)))) + (window-bump-use-time window))) + (defun display-buffer-use-some-window (buffer alist) "Display BUFFER in an existing window. Search for a usable window, set that window to the buffer, and diff --git a/src/window.c b/src/window.c index 58204c13e44..5e78aa400b5 100644 --- a/src/window.c +++ b/src/window.c @@ -8100,6 +8100,18 @@ and scrolling positions. */) return Qt; return Qnil; } + +DEFUN ("window-bump-use-time", Fwindow_bump_use_time, + Swindow_bump_use_time, 1, 1, 0, + doc: /* Mark WINDOW as having been recently used. */) + (Lisp_Object window) +{ + struct window *w = decode_valid_window (window); + + w->use_time = ++window_select_count; + return Qnil; +} + static void init_window_once_for_pdumper (void); @@ -8573,6 +8585,7 @@ displayed after a scrolling operation to be somewhat inaccurate. */); defsubr (&Swindow_vscroll); defsubr (&Sset_window_vscroll); defsubr (&Scompare_window_configurations); + defsubr (&Swindow_bump_use_time); defsubr (&Swindow_list); defsubr (&Swindow_list_1); defsubr (&Swindow_prev_buffers); -- cgit v1.3 From 705292c200a6e35127c26a0ff676f41a072fefa4 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 7 Jan 2021 19:01:55 +0100 Subject: Remove unused DEFSYM * src/minibuf.c (syms_of_minibuf) : Remove unused DEFSYM. --- src/minibuf.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/minibuf.c b/src/minibuf.c index 8b235690199..5ee440f6622 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -2013,9 +2013,6 @@ syms_of_minibuf (void) DEFSYM (Qminibuffer_setup_hook, "minibuffer-setup-hook"); DEFSYM (Qminibuffer_exit_hook, "minibuffer-exit-hook"); - /* The maximum length of a minibuffer history. */ - DEFSYM (Qhistory_length, "history-length"); - DEFSYM (Qcurrent_input_method, "current-input-method"); DEFSYM (Qactivate_input_method, "activate-input-method"); DEFSYM (Qcase_fold_search, "case-fold-search"); -- cgit v1.3 From 5ac7b480757d8731fe2bda0452e48f0cd0356aa4 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 8 Jan 2021 15:16:02 +0100 Subject: Lift define-prefix-command to Lisp * lisp/subr.el (define-prefix-command): New defun. * src/keymap.c (Fdefine_prefix_command): Remove DEFUN. (syms_of_keymap): Remove defsubr for Fdefine_prefix_command. * test/lisp/subr-tests.el (subr-test-define-prefix-command): New test. --- lisp/subr.el | 16 ++++++++++++++++ src/keymap.c | 23 ----------------------- test/lisp/subr-tests.el | 11 +++++++++++ 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/lisp/subr.el b/lisp/subr.el index 11aabfe504d..b92744cdcbe 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -995,6 +995,22 @@ a menu, so this function is not useful for non-menu keymaps." (setq inserted t))) (setq tail (cdr tail))))) +(defun define-prefix-command (command &optional mapvar name) + "Define COMMAND as a prefix command. COMMAND should be a symbol. +A new sparse keymap is stored as COMMAND's function definition and its +value. +This prepares COMMAND for use as a prefix key's binding. +If a second optional argument MAPVAR is given, it should be a symbol. +The map is then stored as MAPVAR's value instead of as COMMAND's +value; but COMMAND is still defined as a function. +The third optional argument NAME, if given, supplies a menu name +string for the map. This is required to use the keymap as a menu. +This function returns COMMAND." + (let ((map (make-sparse-keymap name))) + (fset command map) + (set (or mapvar command) map) + command)) + (defun map-keymap-sorted (function keymap) "Implement `map-keymap' with sorting. Don't call this function; it is for internal use only." diff --git a/src/keymap.c b/src/keymap.c index 3d1993869bc..1197f6fd4a5 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1712,28 +1712,6 @@ bindings; see the description of `lookup-key' for more details about this. */) return Flist (j, maps); } -DEFUN ("define-prefix-command", Fdefine_prefix_command, Sdefine_prefix_command, 1, 3, 0, - doc: /* Define COMMAND as a prefix command. COMMAND should be a symbol. -A new sparse keymap is stored as COMMAND's function definition and its -value. -This prepares COMMAND for use as a prefix key's binding. -If a second optional argument MAPVAR is given, it should be a symbol. -The map is then stored as MAPVAR's value instead of as COMMAND's -value; but COMMAND is still defined as a function. -The third optional argument NAME, if given, supplies a menu name -string for the map. This is required to use the keymap as a menu. -This function returns COMMAND. */) - (Lisp_Object command, Lisp_Object mapvar, Lisp_Object name) -{ - Lisp_Object map = Fmake_sparse_keymap (name); - Ffset (command, map); - if (!NILP (mapvar)) - Fset (mapvar, map); - else - Fset (command, map); - return command; -} - DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, doc: /* Select KEYMAP as the global keymap. */) (Lisp_Object keymap) @@ -3280,7 +3258,6 @@ be preferred. */); defsubr (&Sminor_mode_key_binding); defsubr (&Sdefine_key); defsubr (&Slookup_key); - defsubr (&Sdefine_prefix_command); defsubr (&Suse_global_map); defsubr (&Suse_local_map); defsubr (&Scurrent_local_map); diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 54f6eb4b2a1..83031c44fcd 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -70,6 +70,17 @@ (should (equal (kbd "RET") "\C-m")) (should (equal (kbd "C-x a") "\C-xa"))) +(ert-deftest subr-test-define-prefix-command () + (define-prefix-command 'foo-prefix-map) + (should (keymapp foo-prefix-map)) + (should (fboundp #'foo-prefix-map)) + ;; With optional argument. + (define-prefix-command 'bar-prefix 'bar-prefix-map) + (should (keymapp bar-prefix-map)) + (should (fboundp #'bar-prefix)) + ;; Returns the symbol. + (should (eq (define-prefix-command 'foo-bar) 'foo-bar))) + ;;;; Mode hooks. -- cgit v1.3 From 4cebd2ded01f733957919cea9d10a67101cb7a67 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 9 Jan 2021 21:17:42 +0100 Subject: Don't unblock SIGCHLD too early. We first need to register the received process ID so that 'handle_child_signal' checks it. Otherwise we might never call 'waitpid' for these processes, risking deadlock. * src/callproc.c (call_process): * src/process.c (create_process): Don't unblock SIGCHLD before registering the process ID to wait for. * src/callproc.c (emacs_spawn): Accept a signal set from the caller. --- src/callproc.c | 31 ++++++++++++++++++++----------- src/lisp.h | 4 ++-- src/process.c | 10 +++++++++- 3 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/callproc.c b/src/callproc.c index 8d2a5619eb8..1da315bef18 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -314,6 +314,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ char *tempfile = NULL; #else + sigset_t oldset; pid_t pid = -1; #endif int child_errno; @@ -601,9 +602,12 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, #ifndef MSDOS + block_input (); + block_child_signal (&oldset); + child_errno = emacs_spawn (&pid, filefd, fd_output, fd_error, new_argv, env, - SSDATA (current_dir), NULL); + SSDATA (current_dir), NULL, &oldset); eassert ((child_errno == 0) == (0 < pid)); if (pid > 0) @@ -624,6 +628,9 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, } } + unblock_child_signal (&oldset); + unblock_input (); + if (pid < 0) report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, child_errno); @@ -1227,17 +1234,21 @@ child_setup (int in, int out, int err, char **new_argv, char **env, process image file ARGV[0]. Use ENVP for the environment block for the new process. Use CWD as working directory for the new process. If PTY is not NULL, it must be a pseudoterminal device. If PTY is - NULL, don't perform any terminal setup. */ + NULL, don't perform any terminal setup. OLDSET must be a pointer + to a signal set initialized by `block_child_signal'. Before + calling this function, call `block_input' and `block_child_signal'; + afterwards, call `unblock_input' and `unblock_child_signal'. Be + sure to call `unblock_child_signal' only after registering NEWPID + in a list where `handle_child_signal' can find it! */ int emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, - char **argv, char **envp, const char *cwd, const char *pty) + char **argv, char **envp, const char *cwd, + const char *pty, const sigset_t *oldset) { - sigset_t oldset; int pid; - block_input (); - block_child_signal (&oldset); + eassert (input_blocked_p ()); #ifndef WINDOWSNT /* vfork, and prevent local vars from being clobbered by the vfork. */ @@ -1249,6 +1260,7 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, int volatile stdout_volatile = std_out; int volatile stderr_volatile = std_err; char **volatile envp_volatile = envp; + const sigset_t *volatile oldset_volatile = oldset; #ifdef DARWIN_OS /* Darwin doesn't let us run setsid after a vfork, so use fork when @@ -1270,6 +1282,7 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, std_out = stdout_volatile; std_err = stderr_volatile; envp = envp_volatile; + oldset = oldset_volatile; if (pid == 0) #endif /* not WINDOWSNT */ @@ -1364,7 +1377,7 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, #endif /* Stop blocking SIGCHLD in the child. */ - unblock_child_signal (&oldset); + unblock_child_signal (oldset); if (pty_flag) child_setup_tty (std_out); @@ -1382,10 +1395,6 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, int vfork_error = pid < 0 ? errno : 0; - /* Stop blocking in the parent. */ - unblock_child_signal (&oldset); - unblock_input (); - if (pid < 0) { eassert (0 < vfork_error); diff --git a/src/lisp.h b/src/lisp.h index ca0eb51c061..d139df93424 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4495,8 +4495,8 @@ extern void setup_process_coding_systems (Lisp_Object); # define CHILD_SETUP_ERROR_DESC "Doing vfork" #endif -extern int emacs_spawn (pid_t *, int, int, int, char **, char **, const char *, - const char *); +extern int emacs_spawn (pid_t *, int, int, int, char **, char **, + const char *, const char *, const sigset_t *); extern char **make_environment_block (Lisp_Object); extern void init_callproc_1 (void); extern void init_callproc (void); diff --git a/src/process.c b/src/process.c index 06d750d3368..67e930e18f1 100644 --- a/src/process.c +++ b/src/process.c @@ -2059,6 +2059,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) bool pty_flag = 0; char pty_name[PTY_NAME_SIZE]; Lisp_Object lisp_pty_name = Qnil; + sigset_t oldset; inchannel = outchannel = -1; @@ -2139,13 +2140,16 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) setup_process_coding_systems (process); char **env = make_environment_block (current_dir); + block_input (); + block_child_signal (&oldset); + pty_flag = p->pty_flag; eassert (pty_flag == ! NILP (lisp_pty_name)); vfork_errno = emacs_spawn (&pid, forkin, forkout, forkerr, new_argv, env, SSDATA (current_dir), - pty_flag ? SSDATA (lisp_pty_name) : NULL); + pty_flag ? SSDATA (lisp_pty_name) : NULL, &oldset); eassert ((vfork_errno == 0) == (0 < pid)); @@ -2153,6 +2157,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) if (pid >= 0) p->alive = 1; + /* Stop blocking in the parent. */ + unblock_child_signal (&oldset); + unblock_input (); + /* Environment block no longer needed. */ unbind_to (count, Qnil); -- cgit v1.3 From 302e6d4623d6f87789c055717490799c1f2ec015 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sun, 10 Jan 2021 09:50:15 +0100 Subject: Remove a pointless check for WCOREDUMPED. WCOREDUMPED can only be used if the process was killed. * src/process.c (status_convert): Don't check WCOREDUMPED if WIFEXITED. --- src/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/process.c b/src/process.c index 67e930e18f1..dac7d0440fa 100644 --- a/src/process.c +++ b/src/process.c @@ -692,8 +692,7 @@ status_convert (int w) if (WIFSTOPPED (w)) return Fcons (Qstop, Fcons (make_fixnum (WSTOPSIG (w)), Qnil)); else if (WIFEXITED (w)) - return Fcons (Qexit, Fcons (make_fixnum (WEXITSTATUS (w)), - WCOREDUMP (w) ? Qt : Qnil)); + return Fcons (Qexit, Fcons (make_fixnum (WEXITSTATUS (w)), Qnil)); else if (WIFSIGNALED (w)) return Fcons (Qsignal, Fcons (make_fixnum (WTERMSIG (w)), WCOREDUMP (w) ? Qt : Qnil)); -- cgit v1.3