commit d52749202f690a50f832c25ddd80929d175e67b4 (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Sun May 22 13:13:01 2022 +0800 Fix use-after-free in x_destroy_window * src/xterm.c (x_destroy_window): Fix use after free of the dpyinfo. diff --git a/src/xterm.c b/src/xterm.c index 5c2deb62e0..0487259bf0 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -23397,7 +23397,6 @@ x_destroy_window (struct frame *f) x_free_frame_resources (f); xfree (f->output_data.x->saved_menu_event); - xfree (f->output_data.x); #ifdef HAVE_X_I18N if (f->output_data.x->preedit_chars) @@ -23409,6 +23408,7 @@ x_destroy_window (struct frame *f) XFree (f->output_data.x->xi_masks); #endif + xfree (f->output_data.x); f->output_data.x = NULL; dpyinfo->reference_count--; commit 67685de75c2223443db892695cbc0af283839db6 Author: Po Lu Date: Sun May 22 05:03:12 2022 +0000 Fix focus redirection to/from surrogate minibuffer frames on Haiku * src/haikuterm.c (haiku_get_focus_frame): New function. (haiku_create_terminal): Register new hook. diff --git a/src/haikuterm.c b/src/haikuterm.c index 6401ea1233..47cffded48 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -3960,6 +3960,21 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) return message_count; } +static Lisp_Object +haiku_get_focus_frame (struct frame *f) +{ + Lisp_Object lisp_focus; + struct frame *focus; + + focus = FRAME_DISPLAY_INFO (f)->focused_frame; + + if (!focus) + return Qnil; + + XSETFRAME (lisp_focus, focus); + return lisp_focus; +} + static void haiku_frame_rehighlight (struct frame *frame) { @@ -4185,6 +4200,7 @@ haiku_create_terminal (struct haiku_display_info *dpyinfo) terminal->fullscreen_hook = haiku_fullscreen; terminal->toolkit_position_hook = haiku_toolkit_position; terminal->activate_menubar_hook = haiku_activate_menubar; + terminal->get_focus_frame = haiku_get_focus_frame; return terminal; } commit 714970f5967f2153bb95e35823dbd917e0e5b60b Author: Po Lu Date: Sun May 22 11:18:32 2022 +0800 Fix GNUstep build * src/nsfns.m (ns_implicitly_set_icon_type): Don't use UTType if GNUstep. diff --git a/src/nsfns.m b/src/nsfns.m index a2f9c26b55..818ba6f40f 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -847,6 +847,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. if (image == nil) { +#ifndef NS_IMPL_GNUSTEP #if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 if ([workspace respondsToSelector: @selector (iconForContentType:)]) @@ -857,6 +858,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. else #endif #endif +#endif #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 image = [[workspace iconForFileType: @"text"] retain]; #endif commit e5e474baaec391fe2a84fab1ebae978d9355dc2f Author: Po Lu Date: Sun May 22 11:02:24 2022 +0800 Fix compiler warnings on Mac OS X 10.12 * configure.ac: Check for Mac OS X 12 and link with UniformTypeIdentifiers.framework. * src/nsfns.m (IOMasterPort): Define to `IOMainPort' on Mac OS X 12. (ns_implicitly_set_icon_type, Fns_read_file_name): * src/nsxwidget.m: ([XwWebView initWithFrame:configuration:xwidget:]): Fix uses of obsolete things. diff --git a/configure.ac b/configure.ac index 3d5eb7f9c4..1d2d1f190b 100644 --- a/configure.ac +++ b/configure.ac @@ -2081,6 +2081,16 @@ Either fix this, or re-configure with the option '--without-ns'.])]) fi fi + AC_CACHE_CHECK([for Mac OS X 12.0 or later], + [emacs_cv_macosx_12_0], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 +Mac OS X 12.x or later. +#endif + ]])], [emacs_cv_macosx_12_0=no], + [emacs_cv_macosx_12_0=yes])) + if test "${with_native_image_api}" = yes; then AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.]) NATIVE_IMAGE_API="yes (ns)" @@ -6216,6 +6226,9 @@ case "$opsys" in if test "$NS_IMPL_COCOA" = "yes"; then libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon \ -framework IOSurface -framework QuartzCore" + if test "$emacs_cv_macosx_12_0" = "yes"; then + libs_nsgui="$libs_nsgui -framework UniformTypeIdentifiers" + fi fi else libs_nsgui= diff --git a/src/nsfns.m b/src/nsfns.m index f82665a300..a2f9c26b55 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -47,6 +47,13 @@ Updated by Christian Limpach (chris@nice.ch) #ifdef NS_IMPL_COCOA #include #include "macfont.h" + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 +#include +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 120000 +#define IOMasterPort IOMainPort +#endif +#endif #endif #ifdef HAVE_NS @@ -789,11 +796,13 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. Lisp_Object chain, elt; NSAutoreleasePool *pool; BOOL setMini = YES; + NSWorkspace *workspace; NSTRACE ("ns_implicitly_set_icon_type"); block_input (); pool = [[NSAutoreleasePool alloc] init]; + workspace = [NSWorkspace sharedWorkspace]; if (f->output_data.ns->miniimage && [[NSString stringWithLispString:f->name] isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]]) @@ -838,7 +847,19 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. if (image == nil) { - image = [[[NSWorkspace sharedWorkspace] iconForFileType: @"text"] retain]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + if ([workspace respondsToSelector: @selector (iconForContentType:)]) +#endif + image = [[workspace iconForContentType: + [UTType typeWithIdentifier: @"text"]] retain]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + else +#endif +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + image = [[workspace iconForFileType: @"text"] retain]; +#endif setMini = NO; } @@ -1757,7 +1778,20 @@ Frames are listed from topmost (first) to bottommost (last). */) ns_fd_data.ret = NO; #ifdef NS_IMPL_COCOA if (! NILP (mustmatch) || ! NILP (dir_only_p)) - [panel setAllowedFileTypes: nil]; + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + if ([panel respondsToSelector: @selector (setAllowedContentTypes:)]) +#endif + [panel setAllowedContentTypes: [NSArray array]]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + else +#endif +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 + [panel setAllowedFileTypes: nil]; +#endif + } if (dirS) [panel setDirectoryURL: [NSURL fileURLWithPath: dirS]]; if (initS && NILP (Ffile_directory_p (init))) [panel setNameFieldStringValue: [initS lastPathComponent]]; diff --git a/src/nsxwidget.m b/src/nsxwidget.m index f79873235c..be0eba0bcb 100644 --- a/src/nsxwidget.m +++ b/src/nsxwidget.m @@ -69,10 +69,13 @@ - (id)initWithFrame:(CGRect)frame [configuration.preferences setValue:@YES forKey:@"developerExtrasEnabled"]; +#if 0 /* Plugins are not supported by Mac OS X anymore. */ Lisp_Object enablePlugins = Fintern (build_string ("xwidget-webkit-enable-plugins"), Qnil); + if (!EQ (Fsymbol_value (enablePlugins), Qnil)) configuration.preferences.plugInsEnabled = YES; +#endif self = [super initWithFrame:frame configuration:configuration]; if (self) commit 672af0a5da6d13edc221f32c36a0b89bea9e799e Author: Po Lu Date: Sun May 22 09:38:21 2022 +0800 Set display size upon RRScreenChangeNotify * src/xterm.c (handle_one_xevent): Handle RRScreenChangeNotify correctly. diff --git a/src/xterm.c b/src/xterm.c index 05ede2e580..5c2deb62e0 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -20120,6 +20120,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, union buffered_input_event *ev; Time timestamp; Lisp_Object current_monitors; + XRRScreenChangeNotifyEvent *notify; if (event->type == (dpyinfo->xrandr_event_base + RRScreenChangeNotify)) @@ -20127,7 +20128,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (event->type == (dpyinfo->xrandr_event_base + RRScreenChangeNotify)) - timestamp = ((XRRScreenChangeNotifyEvent *) event)->timestamp; + { + notify = ((XRRScreenChangeNotifyEvent *) event); + timestamp = notify->timestamp; + + dpyinfo->screen_width = notify->width; + dpyinfo->screen_height = notify->height; + } else timestamp = 0; commit e465ea816d6a64a21822549982928c48961fec99 Author: Po Lu Date: Sun May 22 09:27:46 2022 +0800 Don't unnecessarily call monitor change functions * src/xterm.c (handle_one_xevent): If monitor attributes didn't change, don't send monitor change event. (x_term_init, mark_xterm): Mark and init new field. * src/xterm.h (struct x_display_info): New field `last_monitor_attributes_list'. diff --git a/src/xterm.c b/src/xterm.c index add0c848db..05ede2e580 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -20119,6 +20119,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, { union buffered_input_event *ev; Time timestamp; + Lisp_Object current_monitors; if (event->type == (dpyinfo->xrandr_event_base + RRScreenChangeNotify)) @@ -20144,6 +20145,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, inev.ie.kind = MONITORS_CHANGED_EVENT; inev.ie.timestamp = timestamp; XSETTERMINAL (inev.ie.arg, dpyinfo->terminal); + + /* Also don't do anything if the monitor configuration + didn't really change. */ + + current_monitors + = Fx_display_monitor_attributes_list (inev.ie.arg); + + if (Fequal (current_monitors, + dpyinfo->last_monitor_attributes_list)) + inev.ie.kind = NO_EVENT; + + dpyinfo->last_monitor_attributes_list = current_monitors; } #endif OTHER: @@ -24447,9 +24460,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) #endif #ifdef HAVE_XRANDR + Lisp_Object term; + + dpyinfo->last_monitor_attributes_list = Qnil; dpyinfo->xrandr_supported_p = XRRQueryExtension (dpy, &dpyinfo->xrandr_event_base, &dpyinfo->xrandr_error_base); + + XSETTERMINAL (term, terminal); + if (dpyinfo->xrandr_supported_p) { XRRQueryVersion (dpy, &dpyinfo->xrandr_major_version, @@ -24457,15 +24476,20 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) if (dpyinfo->xrandr_major_version == 1 && dpyinfo->xrandr_minor_version >= 2) - XRRSelectInput (dpyinfo->display, - dpyinfo->root_window, - (RRScreenChangeNotifyMask - | RRCrtcChangeNotifyMask - | RROutputChangeNotifyMask - /* Emacs doesn't actually need this, but GTK - selects for it when the display is - initialized. */ - | RROutputPropertyNotifyMask)); + { + dpyinfo->last_monitor_attributes_list + = Fx_display_monitor_attributes_list (term); + + XRRSelectInput (dpyinfo->display, + dpyinfo->root_window, + (RRScreenChangeNotifyMask + | RRCrtcChangeNotifyMask + | RROutputChangeNotifyMask + /* Emacs doesn't actually need this, but GTK + selects for it when the display is + initialized. */ + | RROutputPropertyNotifyMask)); + } } #endif @@ -25274,7 +25298,7 @@ mark_xterm (void) mark_object (val); } -#if defined HAVE_XINPUT2 || defined USE_TOOLKIT_SCROLL_BARS +#if defined HAVE_XINPUT2 || defined USE_TOOLKIT_SCROLL_BARS || defined HAVE_XRANDR for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) { #ifdef HAVE_XINPUT2 @@ -25284,6 +25308,9 @@ mark_xterm (void) #ifdef USE_TOOLKIT_SCROLL_BARS for (i = 0; i < dpyinfo->n_protected_windows; ++i) mark_object (dpyinfo->protected_windows[i]); +#endif +#ifdef HAVE_XRANDR + mark_object (dpyinfo->last_monitor_attributes_list); #endif } #endif diff --git a/src/xterm.h b/src/xterm.h index 8571bd9d39..c59992fdaa 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -607,6 +607,10 @@ struct x_display_info int xrandr_error_base; int xrandr_major_version; int xrandr_minor_version; + + /* This is used to determine if the monitor configuration really + changed upon receiving a monitor change event. */ + Lisp_Object last_monitor_attributes_list; #endif #if defined USE_CAIRO || defined HAVE_XRENDER commit 900700a03fd9839b70ffb6796e441e5ba57136a7 Author: Sean Whitton Date: Sat May 21 16:15:01 2022 -0700 ; * doc/emacs/dired.texi (Entering Dired): Fix typo. diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 92106ae1ed..ed4ff5213f 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -122,7 +122,7 @@ listing. As an exception, if you type @kbd{C-x C-j} in a Dired buffer, Emacs displays the directory listing of the parent directory and places point on the line that corresponds to the directory where you invoked @code{dired-jump}. Typing @kbd{C-x 4 C-j} -(@code{dired-jump-other-window} has the same effect, but displays the +(@code{dired-jump-other-window}) has the same effect, but displays the Dired buffer in a new window. The variable @code{dired-listing-switches} specifies the options to commit 208102fa470e3417320062cdb48a9967d80bf092 Author: Eli Zaretskii Date: Sat May 21 16:55:15 2022 +0300 ; Rename enable-theme and disable-theme hooks * lisp/custom.el (enable-theme-functions) (disable-theme-functions): Rename from enable-theme-hook and disable-theme-hook. All users changed. (Bug#37802) diff --git a/etc/NEWS b/etc/NEWS index 223f87ebfb..190620619f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1859,7 +1859,7 @@ functions. ** Themes --- -*** New hooks 'enable-theme-hook' and 'disable-theme-hook'. +*** New hooks 'enable-theme-functions' and 'disable-theme-functions'. These are run after enabling and disabling a theme, respectively. --- diff --git a/lisp/custom.el b/lisp/custom.el index 181711967d..a084304ff8 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1422,16 +1422,16 @@ are not directories are omitted from the expansion." ;;; Enabling and disabling loaded themes. -(defcustom enable-theme-hook nil - "Atypical hook run after a theme has been enabled. +(defcustom enable-theme-functions nil + "Abnormal hook that is run after a theme has been enabled. The functions in the hook are called with one parameter -- the name of the theme that's been enabled (as a symbol)." :type 'hook :group 'customize :version "29.1") -(defcustom disable-theme-hook nil - "Atypical hook run after a theme has been disabled. +(defcustom disable-theme-functions nil + "Abnormal hook that is run after a theme has been disabled. The functions in the hook are called with one parameter -- the name of the theme that's been disabled (as a symbol)." :type 'hook @@ -1448,7 +1448,7 @@ precedence (after `user') among enabled themes. Note that any already-enabled themes remain enabled after this function runs. To disable other themes, use `disable-theme'. -After THEME has been enabled, `enable-theme-hook' is run." +After THEME has been enabled, runs `enable-theme-functions'." (interactive (list (intern (completing-read "Enable custom theme: " @@ -1498,7 +1498,7 @@ After THEME has been enabled, `enable-theme-hook' is run." ;; Give the `user' theme the highest priority. (enable-theme 'user)) ;; Allow callers to react to the enabling. - (run-hook-with-args 'enable-theme-hook theme)) + (run-hook-with-args 'enable-theme-functions theme)) (defcustom custom-enabled-themes nil "List of enabled Custom Themes, highest precedence first. @@ -1545,7 +1545,7 @@ Setting this variable through Customize calls `enable-theme' or "Disable all variable and face settings defined by THEME. See `custom-enabled-themes' for a list of enabled themes. -After THEME has been disabled, `disable-theme-hook' is run." +After THEME has been disabled, runs `disable-theme-functions'." (interactive (list (intern (completing-read "Disable custom theme: " @@ -1591,7 +1591,7 @@ After THEME has been disabled, `disable-theme-hook' is run." (setq custom-enabled-themes (delq theme custom-enabled-themes)) ;; Allow callers to react to the disabling. - (run-hook-with-args 'disable-theme-hook theme))) + (run-hook-with-args 'disable-theme-functions theme))) ;; Only used if window-system not null. (declare-function x-get-resource "frame.c" commit 42af5bcbedc9cf60cf5b8d475287851098e35f8c Author: Michael Albinus Date: Sat May 21 15:44:22 2022 +0200 Some cleanups in tramp-tests.el * test/lisp/net/tramp-tests.el (tramp-fuse-remove-hidden-files): Declare. (tramp-test16-directory-files) (tramp-test16-file-expand-wildcards) (tramp-test26-file-name-completion, tramp--test-check-files): Use it. (tramp--test-check-files): Delete directory recursively. (tramp-test43-file-system-info): Make test more robust. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d9c5df1790..1532cbe049 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -68,6 +68,7 @@ (defvar tramp-connection-properties) (defvar tramp-copy-size-limit) (defvar tramp-display-escape-sequence-regexp) +(defvar tramp-fuse-remove-hidden-files) (defvar tramp-fuse-unmount-on-cleanup) (defvar tramp-inline-compress-start-size) (defvar tramp-persistency-file-name) @@ -3068,7 +3069,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (skip-unless (tramp--test-enabled)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) + (let* ((tramp-fuse-remove-hidden-files t) + (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (expand-file-name "bla" tmp-name1)) (tmp-name3 (expand-file-name "foo" tmp-name1))) (unwind-protect @@ -3112,7 +3114,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (skip-unless (tramp--test-enabled)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) + (let* ((tramp-fuse-remove-hidden-files t) + (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (expand-file-name "foo" tmp-name1)) (tmp-name3 (expand-file-name "bar" tmp-name1)) (tmp-name4 (expand-file-name "baz" tmp-name1)) @@ -4352,7 +4355,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ;; Method and host name in completion mode. This kind of completion ;; does not work on MS Windows. (unless (memq system-type '(cygwin windows-nt)) - (let ((method (file-remote-p tramp-test-temporary-file-directory 'method)) + (let ((tramp-fuse-remove-hidden-files t) + (method (file-remote-p tramp-test-temporary-file-directory 'method)) (host (file-remote-p tramp-test-temporary-file-directory 'host)) (orig-syntax tramp-syntax)) (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) @@ -4404,7 +4408,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (dolist (non-essential '(nil t)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let ((tmp-name (tramp--test-make-temp-name nil quoted))) + (let ((tramp-fuse-remove-hidden-files t) + (tmp-name (tramp--test-make-temp-name nil quoted))) (unwind-protect (progn @@ -6642,6 +6647,7 @@ This requires restrictions of file name syntax." ;; would let the test fail. (let* ((tramp-test-temporary-file-directory (file-truename tramp-test-temporary-file-directory)) + (tramp-fuse-remove-hidden-files t) (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (tramp--test-make-temp-name 'local quoted)) (files @@ -6815,7 +6821,7 @@ This requires restrictions of file name syntax." (delete-file file2) (should-not (file-exists-p file2)) - (delete-directory file1) + (delete-directory file1 'recursive) (should-not (file-exists-p file1)))) ;; Check, that environment variables are set correctly. @@ -7121,14 +7127,12 @@ Use the \"ls\" command." ;; `file-system-info' exists since Emacs 27.1. We don't want to see ;; compiler warnings for older Emacsen. - (let ((fsi (with-no-warnings - (file-system-info tramp-test-temporary-file-directory)))) - (skip-unless fsi) - (should (and (consp fsi) - (= (length fsi) 3) - (numberp (nth 0 fsi)) - (numberp (nth 1 fsi)) - (numberp (nth 2 fsi)))))) + (when-let ((fsi (with-no-warnings + (file-system-info tramp-test-temporary-file-directory)))) + (should (consp fsi)) + (should (= (length fsi) 3)) + (dotimes (i (length fsi)) + (should (natnump (or (nth i fsi) 0)))))) ;; `tramp-test44-asynchronous-requests' could be blocked. So we set a ;; timeout of 300 seconds, and we send a SIGUSR1 signal after 300 commit c32b92f2bd6e53542ccd7d753fee684fba5d869f Merge: 61367a971b a8acb9516e Author: Michael Albinus Date: Sat May 21 15:43:34 2022 +0200 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs commit a8acb9516e75b9b13ee988b6cbc2e6bbe1aa531c Author: kobarity Date: Sat May 21 15:23:21 2022 +0200 Fix recently introduced Python font lock breakage of chained assignments * lisp/progmodes/python.el (python-font-lock-assignment-matcher): Fix fontification of chained assignments (bug#54992). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ca744b1cfd..0761aaebdc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -606,12 +606,15 @@ builtins.") Search for next occurrence if REGEXP matched within a `paren' context (to avoid, e.g., default values for arguments or passing arguments by name being treated as assignments) or is followed by -an '=' sign (to avoid '==' being treated as an assignment." +an '=' sign (to avoid '==' being treated as an assignment. Set +point to the position one character before the end of the +occurrence found so that subsequent searches can detect the '=' +sign in chained assignment." (lambda (limit) (cl-loop while (re-search-forward regexp limit t) unless (or (python-syntax-context 'paren) (equal (char-after) ?=)) - return t))) + return (progn (backward-char) t)))) (defvar python-font-lock-keywords-maximum-decoration `((python--font-lock-f-strings) @@ -706,7 +709,7 @@ an '=' sign (to avoid '==' being treated as an assignment." ;; [a] = 5 ;; [*a] = 5, 6 (,(python-font-lock-assignment-matcher - (python-rx (or line-start ?\;) (* space) + (python-rx (or line-start ?\; ?=) (* space) (or "[" "(") (* space) grouped-assignment-target (* space) (or ")" "]") (* space) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 98b55a5f8b..ee7b66610a 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -342,6 +342,13 @@ aliqua." (16 . font-lock-variable-name-face) (17)))) (ert-deftest python-font-lock-assignment-statement-17 () + (python-tests-assert-faces + "(a) = (b) = 1" + `((1) + (2 . font-lock-variable-name-face) (3) + (8 . font-lock-variable-name-face) (9)))) + +(ert-deftest python-font-lock-assignment-statement-18 () (python-tests-assert-faces "CustomInt = int commit 61367a971bdf791cfd5b008143b2b4280965c2fc Merge: 56e81ca25b fa6a0962c5 Author: Michael Albinus Date: Sat May 21 15:20:10 2022 +0200 ; Merge from origin/emacs-28 The following commit was skipped: fa6a0962c5 Fix Tramp sshfs tests (don't merge) commit 56e81ca25b0b88df7d8659c60dc8abdd559a03c9 Merge: 22ae842b34 f836ed098f Author: Michael Albinus Date: Sat May 21 15:20:10 2022 +0200 Merge from origin/emacs-28 f836ed098f Some minor Tramp fixes commit 22ae842b346621095223213621f2244a5a59d3b8 Author: Lars Ingebrigtsen Date: Sat May 21 14:56:13 2022 +0200 Add new hooks when enabling and disabling themes * lisp/custom.el (enable-theme-hook, disable-theme-hook): New hooks (bug#37802). (enable-theme, disable-theme): Call them. diff --git a/etc/NEWS b/etc/NEWS index 564f7c4458..223f87ebfb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1856,6 +1856,17 @@ functions. * Lisp Changes in Emacs 29.1 +** Themes + +--- +*** New hooks 'enable-theme-hook' and 'disable-theme-hook'. +These are run after enabling and disabling a theme, respectively. + +--- +*** Themes can now be made obsolete. +Using 'make-obsolete' on a theme is now supported. This will make +'load-theme' issue a warning when loading the theme. + +++ ** New hook 'display-monitors-changed-functions'. It is called whenever the configuration of different monitors on a @@ -2366,11 +2377,6 @@ local variables. ** Third 'mapconcat' argument SEPARATOR is now optional. An explicit nil always meant the empty string, now it can be left out. ---- -** Themes can now be made obsolete. -Using 'make-obsolete' on a theme is now supported. This will make -'load-theme' issue a warning when loading the theme. - +++ ** New function 'define-keymap'. This function allows defining a number of keystrokes with one form. diff --git a/lisp/custom.el b/lisp/custom.el index 76c14831ca..181711967d 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1422,6 +1422,22 @@ are not directories are omitted from the expansion." ;;; Enabling and disabling loaded themes. +(defcustom enable-theme-hook nil + "Atypical hook run after a theme has been enabled. +The functions in the hook are called with one parameter -- the + name of the theme that's been enabled (as a symbol)." + :type 'hook + :group 'customize + :version "29.1") + +(defcustom disable-theme-hook nil + "Atypical hook run after a theme has been disabled. +The functions in the hook are called with one parameter -- the + name of the theme that's been disabled (as a symbol)." + :type 'hook + :group 'customize + :version "29.1") + (defun enable-theme (theme) "Reenable all variable and face settings defined by THEME. THEME should be either `user', or a theme loaded via `load-theme'. @@ -1430,7 +1446,9 @@ After this function completes, THEME will have the highest precedence (after `user') among enabled themes. Note that any already-enabled themes remain enabled after this -function runs. To disable other themes, use `disable-theme'." +function runs. To disable other themes, use `disable-theme'. + +After THEME has been enabled, `enable-theme-hook' is run." (interactive (list (intern (completing-read "Enable custom theme: " @@ -1478,7 +1496,9 @@ function runs. To disable other themes, use `disable-theme'." (setq custom-enabled-themes (cons theme (remq theme custom-enabled-themes))) ;; Give the `user' theme the highest priority. - (enable-theme 'user))) + (enable-theme 'user)) + ;; Allow callers to react to the enabling. + (run-hook-with-args 'enable-theme-hook theme)) (defcustom custom-enabled-themes nil "List of enabled Custom Themes, highest precedence first. @@ -1523,7 +1543,9 @@ Setting this variable through Customize calls `enable-theme' or (defun disable-theme (theme) "Disable all variable and face settings defined by THEME. -See `custom-enabled-themes' for a list of enabled themes." +See `custom-enabled-themes' for a list of enabled themes. + +After THEME has been disabled, `disable-theme-hook' is run." (interactive (list (intern (completing-read "Disable custom theme: " @@ -1567,7 +1589,9 @@ See `custom-enabled-themes' for a list of enabled themes." "unspecified-fg" "black")) (face-set-after-frame-default frame)) (setq custom-enabled-themes - (delq theme custom-enabled-themes)))) + (delq theme custom-enabled-themes)) + ;; Allow callers to react to the disabling. + (run-hook-with-args 'disable-theme-hook theme))) ;; Only used if window-system not null. (declare-function x-get-resource "frame.c" commit 050fa501a204e8db1688e89e2aaccb87f0286b27 Author: Eli Zaretskii Date: Sat May 21 12:55:12 2022 +0300 ; * etc/NEWS: Fix wording of 'zap-to-char's entry. diff --git a/etc/NEWS b/etc/NEWS index d238fd74fe..564f7c4458 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -701,7 +701,7 @@ option 'cycle-spacing-actions'. --- ** 'zap-to-char' and 'zap-up-to-char' are case-sensitive for upper-case chars. These commands now behave as case-sensitive for interactive calls when -are invoked with an uppercase argument, regardless of the +they are invoked with an uppercase character, regardless of the `case-fold-search' value. --- commit 212aea97f9c9fdabdf7e8a47e64c8243953a7690 Author: Tino Calancha Date: Sat May 21 11:23:17 2022 +0200 zap-to-char: case sensitive for upper-case characters In interactive calls, behave case-sensitively if the given char is an upper-case character. Same for zap-up-to-char (Bug#54804). This is analog to what the user-level incremental search feature does. * lisp/misc.el (zap-up-to-char): Add an optional arg INTERACTIVE. Perform a case-sensitive search when INTERACTIVE is non-nil and CHAR is an upper-case character. * lisp/simple.el (zap-to-char): Same. * etc/NEWS (Editing Changes in Emacs 29.1): Announce this change. * test/lisp/misc-tests.el (misc-test-zap-up-to-char): Add test cases. * test/lisp/simple-tests.el (with-zap-to-char-test): Add helper macro. (simple-tests-zap-to-char): Add a test. diff --git a/etc/NEWS b/etc/NEWS index 5eab8e23bb..d238fd74fe 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -698,6 +698,12 @@ Formerly it invoked 'just-one-space'. The actions performed by 'cycle-spacing' and their order can now be customized via the user option 'cycle-spacing-actions'. +--- +** 'zap-to-char' and 'zap-up-to-char' are case-sensitive for upper-case chars. +These commands now behave as case-sensitive for interactive calls when +are invoked with an uppercase argument, regardless of the +`case-fold-search' value. + --- ** 'scroll-other-window' and 'scroll-other-window-down' now respect remapping. These commands (bound to 'C-M-v' and 'C-M-V') used to scroll the other diff --git a/lisp/misc.el b/lisp/misc.el index d85f889ffd..0bb8ee6c7b 100644 --- a/lisp/misc.el +++ b/lisp/misc.el @@ -64,15 +64,22 @@ The characters copied are inserted in the buffer before point." ;; Variation of `zap-to-char'. ;;;###autoload -(defun zap-up-to-char (arg char) +(defun zap-up-to-char (arg char &optional interactive) "Kill up to, but not including ARGth occurrence of CHAR. +When run interactively, the argument INTERACTIVE is non-nil. Case is ignored if `case-fold-search' is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found. -Ignores CHAR at point." +Ignores CHAR at point. +If called interactively, do a case sensitive search if CHAR +is an upper-case character." (interactive (list (prefix-numeric-value current-prefix-arg) (read-char-from-minibuffer "Zap up to char: " - nil 'read-char-history))) - (let ((direction (if (>= arg 0) 1 -1))) + nil 'read-char-history) + t)) + (let ((direction (if (>= arg 0) 1 -1)) + (case-fold-search (if (and interactive (char-uppercase-p char)) + nil + case-fold-search))) (kill-region (point) (progn (forward-char direction) diff --git a/lisp/simple.el b/lisp/simple.el index 6aa079464a..6906675f68 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6342,21 +6342,26 @@ then gives correct answers only for ASCII characters." (characterp (get-char-code-property char 'lowercase))) ((and (>= char ?A) (<= char ?Z))))) -(defun zap-to-char (arg char) +(defun zap-to-char (arg char &optional interactive) "Kill up to and including ARGth occurrence of CHAR. +When run interactively, the argument INTERACTIVE is non-nil. Case is ignored if `case-fold-search' is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found. -See also `zap-up-to-char'." +See also `zap-up-to-char'. +If called interactively, do a case sensitive search if CHAR +is an upper-case character." (interactive (list (prefix-numeric-value current-prefix-arg) (read-char-from-minibuffer "Zap to char: " - nil 'read-char-history))) + nil 'read-char-history)) + t) ;; Avoid "obsolete" warnings for translation-table-for-input. (with-no-warnings (if (char-table-p translation-table-for-input) (setq char (or (aref translation-table-for-input char) char)))) - (kill-region (point) (progn - (search-forward (char-to-string char) nil nil arg) - (point)))) + (let ((case-fold-search (if (and interactive (char-uppercase-p char)) + nil + case-fold-search))) + (kill-region (point) (search-forward (char-to-string char) nil nil arg)))) ;; kill-line and its subroutines. diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el index 36a8726b88..236223ef49 100644 --- a/test/lisp/misc-tests.el +++ b/test/lisp/misc-tests.el @@ -44,7 +44,14 @@ (zap-up-to-char 1 ?c)) (with-misc-test "abcde abc123" "c123" (goto-char (point-min)) - (zap-up-to-char 2 ?c))) + (zap-up-to-char 2 ?c)) + (let ((case-fold-search t)) + (with-misc-test "abcdeCXYZ" "cdeCXYZ" + (goto-char (point-min)) + (zap-up-to-char 1 ?C)) + (with-misc-test "abcdeCXYZ" "CXYZ" + (goto-char (point-min)) + (zap-up-to-char 1 ?C 'interactive)))) (ert-deftest misc-test-upcase-char () (with-misc-test "abcde" "aBCDe" diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 437c62f61d..b4576889dc 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -1004,6 +1004,27 @@ See Bug#21722." (yank-in-context) (buffer-string)) "echo 'f'\\''bar'\\''oo'"))) + +;;; Tests for `zap-to-char' + +(defmacro with-zap-to-char-test (original result &rest body) + (declare (indent 2) (debug (stringp stringp body))) + `(with-temp-buffer + (insert ,original) + (goto-char (point-min)) + ,@body + (should (equal (buffer-string) ,result)))) + +(ert-deftest simple-tests-zap-to-char () + (with-zap-to-char-test "abcde" "de" + (zap-to-char 1 ?c)) + (with-zap-to-char-test "abcde abc123" "123" + (zap-to-char 2 ?c)) + (let ((case-fold-search t)) + (with-zap-to-char-test "abcdeCXYZ" "deCXYZ" + (zap-to-char 1 ?C)) + (with-zap-to-char-test "abcdeCXYZ" "XYZ" + (zap-to-char 1 ?C 'interactive)))) (provide 'simple-test) ;;; simple-tests.el ends here commit 92fa0df30be7a4e3947cdeca89280947794ac7d6 Author: Po Lu Date: Sat May 21 16:41:34 2022 +0800 Improve doc for `display-monitors-changed-functions' * doc/lispref/frames.texi (Multiple Terminals): Describe how to retrieve the new monitor configuration inside `display-monitor-attributes-list'. diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 7d600b5a0c..e8765cf958 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -465,7 +465,9 @@ changes, which can happen if a monitor is rotated, moved, added or removed from a multiple-monitor setup, if the primary monitor changes, or if the resolution of a monitor changes. It is called with a single argument consisting of the terminal on which the monitor configuration -changed. +changed. Programs should call @code{display-monitor-attributes-list} +with the terminal as the argument to retrieve the new monitor +configuration on that terminal. @end defvar @node Frame Geometry commit 69792e34a4d7c883a354c68e517b7019cefac2d4 Author: Eli Zaretskii Date: Sat May 21 11:04:58 2022 +0300 ; * etc/HELLO: Improve wording of preamble text. (Bug#55439) diff --git a/etc/HELLO b/etc/HELLO index bcaedd80b2..dc5ac9a28e 100644 --- a/etc/HELLO +++ b/etc/HELLO @@ -1,9 +1,11 @@ Content-Type: text/enriched Text-Width: 70 -This is a list of ways to say hello in various languages. -It is not intended to be comprehensive, but to demonstrate -some of the character sets that Emacs supports. +This is a list of ways to write a orange red"hello" greeting using +various scripts. It is not intended to be comprehensive, +but to demonstrate some of the character sets and writing +systems that Emacs supports. Look for the script used to +write your language, to see if it is supported. Non-ASCII examples: commit cf21e3854316bc23163014ee7f044dad2da74291 Author: Po Lu Date: Sat May 21 14:46:57 2022 +0800 Fix compiler warnings in printer code on 32-bit systems * print.c (enum print_entry_type, struct print_stack_entry): Clean up coding style. (struct print_stack): Make print_stack_entry.list.idx intmax_t, like it was before the nonrecursive printing was installed. Also clarify what "Brent cycle detection" means in the comments. diff --git a/src/print.c b/src/print.c index da4869e8fb..d3808fd0e4 100644 --- a/src/print.c +++ b/src/print.c @@ -2016,36 +2016,48 @@ named_escape (int i) return 0; } -enum print_entry_type { - PE_list, /* print rest of list */ - PE_rbrac, /* print ")" */ - PE_vector, /* print rest of vector */ - PE_hash, /* print rest of hash data */ -}; +enum print_entry_type + { + PE_list, /* print rest of list */ + PE_rbrac, /* print ")" */ + PE_vector, /* print rest of vector */ + PE_hash, /* print rest of hash data */ + }; -struct print_stack_entry { +struct print_stack_entry +{ enum print_entry_type type; - union { - struct { + + union + { + struct + { Lisp_Object last; /* cons whose car was just printed */ - ptrdiff_t idx; /* index of next element */ + intmax_t idx; /* index of next element */ intmax_t maxlen; /* max length (from Vprint_length) */ - /* state for Brent cycle detection */ + /* State for Brent cycle detection. See FOR_EACH_TAIL_INTERNAL + in lisp.h for more details. */ Lisp_Object tortoise; /* slow pointer */ ptrdiff_t n; /* tortoise step countdown */ ptrdiff_t m; /* tortoise step period */ } list; - struct { + + struct + { Lisp_Object obj; /* object to print after " . " */ } dotted_cdr; - struct { + + struct + { Lisp_Object obj; /* vector object */ ptrdiff_t size; /* length of vector */ ptrdiff_t idx; /* index of next element */ const char *end; /* string to print at end */ bool truncated; /* whether to print "..." before end */ } vector; - struct { + + struct + { Lisp_Object obj; /* hash-table object */ ptrdiff_t nobjs; /* number of keys and values to print */ ptrdiff_t idx; /* index of key-value pair */ @@ -2055,7 +2067,8 @@ struct print_stack_entry { } u; }; -struct print_stack { +struct print_stack +{ struct print_stack_entry *stack; /* base of stack */ ptrdiff_t size; /* allocated size in entries */ ptrdiff_t sp; /* current number of entries */ commit 3e3fe06307de183a4a4f9c7ead6a0d5c5adedfa9 Author: Po Lu Date: Sat May 21 06:28:06 2022 +0000 Compute frame workareas on Haiku * lisp/frame.el (display-monitor-attributes-list): Implement specially on Haiku as well. * src/haiku_support.cc (get_zoom_rect): New function. Extract CalculateZoomRect here. (class EmacsWindow, SetFullscreen): Use that instead of CalculateZoomRect. (be_get_explicit_workarea): New function. * src/haiku_support.h: Update prototypes. * src/haikufns.c (Fhaiku_display_monitor_attributes_list): New function. (syms_of_haikufns): Register new subr. diff --git a/lisp/frame.el b/lisp/frame.el index 094d67688c..27f99fb7d2 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2376,6 +2376,8 @@ If DISPLAY is omitted or nil, it defaults to the selected frame's display." (&optional terminal)) (declare-function pgtk-display-monitor-attributes-list "pgtkfns.c" (&optional terminal)) +(declare-function haiku-display-monitor-attributes-list "haikufns.c" + (&optional terminal)) (defun display-monitor-attributes-list (&optional display) "Return a list of physical monitor attributes on DISPLAY. @@ -2427,6 +2429,8 @@ monitors." (ns-display-monitor-attributes-list display)) ((eq frame-type 'pgtk) (pgtk-display-monitor-attributes-list display)) + ((eq frame-type 'haiku) + (haiku-display-monitor-attributes-list display)) (t (let ((geometry (list 0 0 (display-pixel-width display) (display-pixel-height display)))) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 33c68cbd46..0c8e87154b 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -449,6 +449,80 @@ map_normal (uint32_t kc, uint32_t *ch) key_map_lock.Unlock (); } +static BRect +get_zoom_rect (BWindow *window) +{ + BScreen screen; + BDeskbar deskbar; + BRect screen_frame; + BRect frame; + BRect deskbar_frame; + BRect window_frame; + BRect decorator_frame; + + if (!screen.IsValid ()) + gui_abort ("Failed to calculate screen rect"); + + screen_frame = frame = screen.Frame (); + deskbar_frame = deskbar.Frame (); + + if (!(modifiers () & B_SHIFT_KEY) && !deskbar.IsAutoHide ()) + { + switch (deskbar.Location ()) + { + case B_DESKBAR_TOP: + frame.top = deskbar_frame.bottom + 2; + break; + + case B_DESKBAR_BOTTOM: + case B_DESKBAR_LEFT_BOTTOM: + case B_DESKBAR_RIGHT_BOTTOM: + frame.bottom = deskbar_frame.top - 2; + break; + + case B_DESKBAR_LEFT_TOP: + if (!deskbar.IsExpanded ()) + frame.top = deskbar_frame.bottom + 2; + else if (!deskbar.IsAlwaysOnTop () + && !deskbar.IsAutoRaise ()) + frame.left = deskbar_frame.right + 2; + break; + + default: + if (deskbar.IsExpanded () + && !deskbar.IsAlwaysOnTop () + && !deskbar.IsAutoRaise ()) + frame.right = deskbar_frame.left - 2; + } + } + + if (window) + { + window_frame = window->Frame (); + decorator_frame = window->DecoratorFrame (); + + frame.top += (window_frame.top + - decorator_frame.top); + frame.bottom -= (decorator_frame.bottom + - window_frame.bottom); + frame.left += (window_frame.left + - decorator_frame.left); + frame.right -= (decorator_frame.right + - window_frame.right); + + if (frame.top > deskbar_frame.bottom + || frame.bottom < deskbar_frame.top) + { + frame.left = screen_frame.left + (window_frame.left + - decorator_frame.left); + frame.right = screen_frame.right - (decorator_frame.right + - window_frame.right); + } + } + + return frame; +} + class Emacs : public BApplication { public: @@ -593,77 +667,6 @@ class EmacsWindow : public BWindow SetFeel (B_NORMAL_WINDOW_FEEL); } - BRect - CalculateZoomRect (void) - { - BScreen screen (this); - BDeskbar deskbar; - BRect screen_frame; - BRect frame; - BRect deskbar_frame; - BRect window_frame; - BRect decorator_frame; - - if (!screen.IsValid ()) - gui_abort ("Failed to calculate screen rect"); - - screen_frame = frame = screen.Frame (); - deskbar_frame = deskbar.Frame (); - - if (!(modifiers () & B_SHIFT_KEY) && !deskbar.IsAutoHide ()) - { - switch (deskbar.Location ()) - { - case B_DESKBAR_TOP: - frame.top = deskbar_frame.bottom + 2; - break; - - case B_DESKBAR_BOTTOM: - case B_DESKBAR_LEFT_BOTTOM: - case B_DESKBAR_RIGHT_BOTTOM: - frame.bottom = deskbar_frame.top - 2; - break; - - case B_DESKBAR_LEFT_TOP: - if (!deskbar.IsExpanded ()) - frame.top = deskbar_frame.bottom + 2; - else if (!deskbar.IsAlwaysOnTop () - && !deskbar.IsAutoRaise ()) - frame.left = deskbar_frame.right + 2; - break; - - default: - if (deskbar.IsExpanded () - && !deskbar.IsAlwaysOnTop () - && !deskbar.IsAutoRaise ()) - frame.right = deskbar_frame.left - 2; - } - } - - window_frame = Frame (); - decorator_frame = DecoratorFrame (); - - frame.top += (window_frame.top - - decorator_frame.top); - frame.bottom -= (decorator_frame.bottom - - window_frame.bottom); - frame.left += (window_frame.left - - decorator_frame.left); - frame.right -= (decorator_frame.right - - window_frame.right); - - if (frame.top > deskbar_frame.bottom - || frame.bottom < deskbar_frame.top) - { - frame.left = screen_frame.left + (window_frame.left - - decorator_frame.left); - frame.right = screen_frame.right - (decorator_frame.right - - window_frame.right); - } - - return frame; - } - void UpwardsSubset (EmacsWindow *w) { @@ -1248,7 +1251,7 @@ class EmacsWindow : public BWindow { case FULLSCREEN_MODE_MAXIMIZED: pre_zoom_rect = frame; - zoom_rect = CalculateZoomRect (); + zoom_rect = get_zoom_rect (this); BWindow::Zoom (zoom_rect.LeftTop (), BE_RECT_WIDTH (zoom_rect) - 1, BE_RECT_HEIGHT (zoom_rect) - 1); @@ -5210,3 +5213,26 @@ be_set_window_fullscreen_mode (void *window, enum haiku_fullscreen_mode mode) w->SetFullscreen (mode); w->UnlockLooper (); } + +bool +be_get_explicit_workarea (int *x, int *y, int *width, int *height) +{ + BDeskbar deskbar; + BRect zoom; + deskbar_location location; + + location = deskbar.Location (); + + if (location != B_DESKBAR_TOP + && location != B_DESKBAR_BOTTOM) + return false; + + zoom = get_zoom_rect (NULL); + + *x = zoom.left; + *y = zoom.top; + *width = BE_RECT_WIDTH (zoom); + *height = BE_RECT_HEIGHT (zoom); + + return true; +} diff --git a/src/haiku_support.h b/src/haiku_support.h index 163685572f..dbb12c24aa 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -702,6 +702,7 @@ extern void be_set_window_fullscreen_mode (void *, enum haiku_fullscreen_mode); extern void be_lock_window (void *); extern void be_unlock_window (void *); +extern bool be_get_explicit_workarea (int *, int *, int *, int *); #ifdef __cplusplus } diff --git a/src/haikufns.c b/src/haikufns.c index 427ca7762d..7b1abb5cdc 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -3021,6 +3021,57 @@ call this function yourself. */) return Qnil; } +DEFUN ("haiku-display-monitor-attributes-list", + Fhaiku_display_monitor_attributes_list, + Shaiku_display_monitor_attributes_list, + 0, 1, 0, + doc: /* Return a list of physical monitor attributes on the display TERMINAL. + +The optional argument TERMINAL specifies which display to ask about. +TERMINAL should be a terminal object, a frame or a display name (a string). +If omitted or nil, that stands for the selected frame's display. + +Internal use only, use `display-monitor-attributes-list' instead. */) + (Lisp_Object terminal) +{ + struct MonitorInfo monitor; + struct haiku_display_info *dpyinfo; + Lisp_Object frames, tail, tem; + + dpyinfo = check_haiku_display_info (terminal); + frames = Qnil; + + FOR_EACH_FRAME (tail, tem) + { + maybe_quit (); + + if (FRAME_HAIKU_P (XFRAME (tem)) + && !FRAME_TOOLTIP_P (XFRAME (tem))) + frames = Fcons (tem, frames); + } + + monitor.geom.x = 0; + monitor.geom.y = 0; + be_get_screen_dimensions ((int *) &monitor.geom.width, + (int *) &monitor.geom.height); + + monitor.mm_width = (monitor.geom.width + / (dpyinfo->resx / 25.4)); + monitor.mm_height = (monitor.geom.height + / (dpyinfo->resy / 25.4)); + monitor.name = (char *) "BeOS monitor"; + + if (!be_get_explicit_workarea ((int *) &monitor.work.x, + (int *) &monitor.work.y, + (int *) &monitor.work.width, + (int *) &monitor.work.height)) + monitor.work = monitor.geom; + + return make_monitor_attribute_list (&monitor, 1, 0, + make_vector (1, frames), + "fallback"); +} + frame_parm_handler haiku_frame_parm_handlers[] = { gui_set_autoraise, @@ -3126,6 +3177,7 @@ syms_of_haikufns (void) defsubr (&Sx_display_save_under); defsubr (&Shaiku_frame_restack); defsubr (&Shaiku_save_session_reply); + defsubr (&Shaiku_display_monitor_attributes_list); tip_timer = Qnil; staticpro (&tip_timer); commit b7b14e920336646428c357b370cbfaac544ce295 Author: Po Lu Date: Sat May 21 11:50:08 2022 +0800 Implement monitor change hooks on NS This hasn't been tested with anything more complicated than removing an emulated monitor. * nsterm.m (ns_displays_reconfigured): New function. (ns_term_init): Register display reconfiguration callbacks. diff --git a/src/nsterm.m b/src/nsterm.m index 7fbfcf8c6d..67b02c7a54 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5213,6 +5213,31 @@ static Lisp_Object ns_string_to_lispmod (const char *s) ns_default_font_parameter }; +#ifdef NS_IMPL_COCOA +static void +ns_displays_reconfigured (CGDirectDisplayID display, + CGDisplayChangeSummaryFlags flags, + void *user_info) +{ + struct input_event ie; + union buffered_input_event *ev; + + EVENT_INIT (ie); + + ev = (kbd_store_ptr == kbd_buffer + ? kbd_buffer + KBD_BUFFER_SIZE - 1 + : kbd_store_ptr - 1); + + if (kbd_store_ptr != kbd_fetch_ptr + && ev->ie.kind == MONITORS_CHANGED_EVENT) + return; + + ie.kind = MONITORS_CHANGED_EVENT; + XSETTERMINAL (ie.arg, x_display_list->terminal); + + kbd_buffer_store_event (&ie); +} +#endif static void ns_delete_display (struct ns_display_info *dpyinfo) @@ -5568,6 +5593,15 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes. catch_child_signal (); #endif +#ifdef NS_IMPL_COCOA + /* Begin listening for display reconfiguration, so we can run the + appropriate hooks. FIXME: is this called when the resolution of + a monitor changes? */ + + CGDisplayRegisterReconfigurationCallback (ns_displays_reconfigured, + NULL); +#endif + NSTRACE_MSG ("ns_term_init done"); unblock_input (); commit 5a290eb7d3e9104edf0fe1ff1d4b078a39dec3d2 Author: Po Lu Date: Sat May 21 11:34:51 2022 +0800 Call XRRUpdateConfiguration when the root window geometry changes * src/xterm.c (handle_one_xevent): Call XRRUpdateConfiguration on RRScreenChangeNotify and upon ConfigureNotify events for the root window. diff --git a/src/xterm.c b/src/xterm.c index b321f43da1..add0c848db 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -16613,6 +16613,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (configureEvent.xconfigure.window == dpyinfo->root_window) { +#ifdef HAVE_XRANDR + /* This function is OK to call even if the X server doesn't + support RandR. */ + XRRUpdateConfiguration (&configureEvent); +#endif + dpyinfo->screen_width = configureEvent.xconfigure.width; dpyinfo->screen_height = configureEvent.xconfigure.height; } @@ -20114,6 +20120,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, union buffered_input_event *ev; Time timestamp; + if (event->type == (dpyinfo->xrandr_event_base + + RRScreenChangeNotify)) + XRRUpdateConfiguration (event); + if (event->type == (dpyinfo->xrandr_event_base + RRScreenChangeNotify)) timestamp = ((XRRScreenChangeNotifyEvent *) event)->timestamp; commit 98163f48a081442616bf680be06cf51ab74b4681 Author: Po Lu Date: Sat May 21 11:29:22 2022 +0800 Implement `display-monitors-changed-hook' on PGTK * src/pgtkterm.c (pgtk_draw_glyphless_glyph_string_foreground): Pacify GCC 12. (pgtk_monitors_changed_cb): New function. (pgtk_term_init): Attach new signal handler. diff --git a/src/pgtkterm.c b/src/pgtkterm.c index b9d0b7b512..71b5f23283 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -1587,6 +1587,10 @@ pgtk_draw_glyphless_glyph_string_foreground (struct glyph_string *s) false); x += glyph->pixel_width; } + + /* Pacify GCC 12 even though s->char2b is not used after this + function returns. */ + s->char2b = NULL; } /* Brightness beyond which a color won't have its highlight brightness @@ -6163,6 +6167,20 @@ drag_data_received (GtkWidget *widget, GdkDragContext *context, gtk_drag_finish (context, TRUE, FALSE, time); } +static void +pgtk_monitors_changed_cb (GdkScreen *screen, gpointer user_data) +{ + struct terminal *terminal; + union buffered_input_event inev; + + EVENT_INIT (inev.ie); + terminal = user_data; + inev.ie.kind = MONITORS_CHANGED_EVENT; + XSETTERMINAL (inev.ie.arg, terminal); + + evq_enqueue (&inev); +} + void pgtk_set_event_handler (struct frame *f) { @@ -6458,6 +6476,10 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) dpyinfo->resx = dpi; dpyinfo->resy = dpi; + g_signal_connect (G_OBJECT (gscr), "monitors-changed", + G_CALLBACK (pgtk_monitors_changed_cb), + terminal); + /* Set up scrolling increments. */ dpyinfo->scroll.x_per_char = 1; dpyinfo->scroll.y_per_line = 1; commit edf9700c3ca65d92bdfca59306845ffc0717d690 Author: Po Lu Date: Sat May 21 11:17:34 2022 +0800 Add a hook run upon monitor configuration changes * doc/lispref/frames.texi (Multiple Terminals): Document new hook `display-monitors-changed-functions'. * etc/NEWS: Announce new abnormal hook. * src/keyboard.c (kbd_buffer_get_event): Handle MONITORS_CHANGED_EVENT. (syms_of_keyboard): New hook and defsyms. * src/termhooks.h (enum event_kind): Add new event `MONITORS_CHANGED_EVENT'. * src/xterm.c (handle_one_xevent): Handle RRNotify and RRScreenChangeNotify events. (x_term_init): Select for RRScreenChange, RRCrtcChange and RROutputChange. * src/xterm.h (struct x_display_info): Improve RandR version detection. diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 5ea060871f..7d600b5a0c 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -458,6 +458,16 @@ monitor, the same string as returned by the function @var{display} should be the name of an X display (a string). @end deffn +@cindex monitor change functions +@defvar display-monitors-changed-functions +This variable is an abnormal hook run when the monitor configuration +changes, which can happen if a monitor is rotated, moved, added or +removed from a multiple-monitor setup, if the primary monitor changes, +or if the resolution of a monitor changes. It is called with a single +argument consisting of the terminal on which the monitor configuration +changed. +@end defvar + @node Frame Geometry @section Frame Geometry @cindex frame geometry diff --git a/etc/NEWS b/etc/NEWS index 70f2c0e6da..5eab8e23bb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1850,6 +1850,11 @@ functions. * Lisp Changes in Emacs 29.1 ++++ +** New hook 'display-monitors-changed-functions'. +It is called whenever the configuration of different monitors on a +display changes. + +++ ** 'prin1' and 'prin1-to-string' now take an optional OVERRIDES parameter. This parameter can be used to override values of print-related settings. diff --git a/src/keyboard.c b/src/keyboard.c index 481633f92f..a2322f1b49 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -4058,6 +4058,18 @@ kbd_buffer_get_event (KBOARD **kbp, } #endif + case MONITORS_CHANGED_EVENT: + { + kbd_fetch_ptr = next_kbd_event (event); + input_pending = readable_events (0); + + CALLN (Frun_hook_with_args, + Qdisplay_monitors_changed_functions, + event->ie.arg); + + break; + } + #ifdef HAVE_EXT_MENU_BAR case MENU_BAR_ACTIVATE_EVENT: { @@ -12609,6 +12621,8 @@ See also `pre-command-hook'. */); DEFSYM (Qtouchscreen_end, "touchscreen-end"); DEFSYM (Qtouchscreen_update, "touchscreen-update"); DEFSYM (Qpinch, "pinch"); + DEFSYM (Qdisplay_monitors_changed_functions, + "display-monitors-changed-functions"); DEFSYM (Qcoding, "coding"); @@ -12953,6 +12967,15 @@ Otherwise, a wheel event will be sent every time the mouse wheel is moved. */); mwheel_coalesce_scroll_events = true; + DEFVAR_LISP ("display-monitors-changed-functions", Vdisplay_monitors_changed_functions, + doc: /* Abnormal hook run when the monitor configuration changes. +This can happen if a monitor is rotated, moved, plugged in or removed +from a multi-monitor setup, if the primary monitor changes, or if the +resolution of a monitor changes. The hook should accept a single +argument, which is the terminal on which the monitor configuration +changed. */); + Vdisplay_monitors_changed_functions = Qnil; + pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); } diff --git a/src/termhooks.h b/src/termhooks.h index 08bde0aec0..d7190e7736 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -31,7 +31,8 @@ struct glyph; INLINE_HEADER_BEGIN -enum scroll_bar_part { +enum scroll_bar_part +{ scroll_bar_nowhere, scroll_bar_above_handle, scroll_bar_handle, @@ -301,8 +302,9 @@ enum event_kind #endif #ifdef HAVE_XWIDGETS - /* events generated by xwidgets*/ + /* An event generated by an xwidget to tell us something. */ , XWIDGET_EVENT + /* Event generated when WebKit asks us to display another widget. */ , XWIDGET_DISPLAY_EVENT #endif @@ -349,6 +351,11 @@ enum event_kind positive delta represents a change clockwise, and a negative delta represents a change counter-clockwise. */ , PINCH_EVENT + + /* In a MONITORS_CHANGED_EVENT, .arg gives the terminal on which the + monitor configuration changed. .timestamp gives the time on + which the monitors changed. */ + , MONITORS_CHANGED_EVENT }; /* Bit width of an enum event_kind tag at the start of structs and unions. */ diff --git a/src/xterm.c b/src/xterm.c index cbe6426447..b321f43da1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -20103,6 +20103,38 @@ handle_one_xevent (struct x_display_info *dpyinfo, } } } +#endif +#ifdef HAVE_XRANDR + if (dpyinfo->xrandr_supported_p + && (event->type == (dpyinfo->xrandr_event_base + + RRScreenChangeNotify) + || event->type == (dpyinfo->xrandr_event_base + + RRNotify))) + { + union buffered_input_event *ev; + Time timestamp; + + if (event->type == (dpyinfo->xrandr_event_base + + RRScreenChangeNotify)) + timestamp = ((XRRScreenChangeNotifyEvent *) event)->timestamp; + else + timestamp = 0; + + ev = (kbd_store_ptr == kbd_buffer + ? kbd_buffer + KBD_BUFFER_SIZE - 1 + : kbd_store_ptr - 1); + + if (kbd_store_ptr != kbd_fetch_ptr + && ev->ie.kind == MONITORS_CHANGED_EVENT + && XTERMINAL (ev->ie.arg) == dpyinfo->terminal) + /* Don't store a MONITORS_CHANGED_EVENT if there is + already an undelivered event on the queue. */ + goto OTHER; + + inev.ie.kind = MONITORS_CHANGED_EVENT; + inev.ie.timestamp = timestamp; + XSETTERMINAL (inev.ie.arg, dpyinfo->terminal); + } #endif OTHER: #ifdef USE_X_TOOLKIT @@ -24405,13 +24437,25 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) #endif #ifdef HAVE_XRANDR - int xrr_event_base, xrr_error_base; - bool xrr_ok = false; - xrr_ok = XRRQueryExtension (dpy, &xrr_event_base, &xrr_error_base); - if (xrr_ok) + dpyinfo->xrandr_supported_p + = XRRQueryExtension (dpy, &dpyinfo->xrandr_event_base, + &dpyinfo->xrandr_error_base); + if (dpyinfo->xrandr_supported_p) { XRRQueryVersion (dpy, &dpyinfo->xrandr_major_version, &dpyinfo->xrandr_minor_version); + + if (dpyinfo->xrandr_major_version == 1 + && dpyinfo->xrandr_minor_version >= 2) + XRRSelectInput (dpyinfo->display, + dpyinfo->root_window, + (RRScreenChangeNotifyMask + | RRCrtcChangeNotifyMask + | RROutputChangeNotifyMask + /* Emacs doesn't actually need this, but GTK + selects for it when the display is + initialized. */ + | RROutputPropertyNotifyMask)); } #endif diff --git a/src/xterm.h b/src/xterm.h index a05bc404f6..8571bd9d39 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -602,6 +602,9 @@ struct x_display_info XModifierKeymap *modmap; #ifdef HAVE_XRANDR + bool xrandr_supported_p; + int xrandr_event_base; + int xrandr_error_base; int xrandr_major_version; int xrandr_minor_version; #endif commit 1cbabe973be88bed5a21d77defc3220034f7c91f Author: Stefan Kangas Date: Fri May 20 20:56:54 2022 +0200 Remove compat code; assume imenu.el exists * lisp/progmodes/antlr-mode.el (antlr-mode): * lisp/progmodes/cperl-mode.el (cperl-menu): * lisp/progmodes/f90.el (f90-mode-map): * lisp/progmodes/fortran.el (fortran-menu): * lisp/speedbar.el (speedbar-use-imenu-flag): Remove compat code; assume imenu.el exists. diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el index 4bc6de0c75..d6e2ab8a87 100644 --- a/lisp/progmodes/antlr-mode.el +++ b/lisp/progmodes/antlr-mode.el @@ -2437,7 +2437,6 @@ the default language." #'antlr-imenu-create-index-function) (set (make-local-variable 'imenu-generic-expression) t) ; fool stupid test (and antlr-imenu-name ; there should be a global variable... - (fboundp 'imenu-add-to-menubar) (imenu-add-to-menubar (if (stringp antlr-imenu-name) antlr-imenu-name "Index"))) (antlr-set-tabs)) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index b79dc65693..e571cee83c 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1091,7 +1091,7 @@ Unless KEEP, removes the old indentation." ["Debugger" cperl-db t] "----" ("Tools" - ["Imenu" imenu (fboundp 'imenu)] + ["Imenu" imenu] ["Imenu on Perl Info" cperl-imenu-on-info (featurep 'imenu)] "----" ["Ispell PODs" cperl-pod-spell diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index ce8824b85c..342fcb27b3 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -825,9 +825,7 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") :style toggle :help "Expand abbreviations while typing in this buffer"] ["Add Imenu Menu" f90-add-imenu-menu :active (not (lookup-key (current-local-map) [menu-bar index])) - :included (fboundp 'imenu-add-to-menubar) - :help "Add an index menu to the menu-bar" - ])) + :help "Add an index menu to the menu-bar"])) map) "Keymap used in F90 mode.") diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index 86f0be7320..786c5ae804 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -2213,7 +2213,6 @@ arg DO-SPACE prevents stripping the whitespace." :style toggle :help "Expand abbreviations while typing in this buffer"] ["Add Imenu Menu" imenu-add-menubar-index :active (not (lookup-key (current-local-map) [menu-bar index])) - :included (fboundp 'imenu-add-to-menubar) :help "Add an index menu to the menu-bar"])) (provide 'fortran) diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 3ceccfb20c..b12cf3d9c2 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -306,10 +306,9 @@ attached to and added to this list before the new frame is initialized." (symbol :tag "Parameter") (sexp :tag "Value")))) -(defcustom speedbar-use-imenu-flag (fboundp 'imenu) +(defcustom speedbar-use-imenu-flag t "Non-nil means use imenu for file parsing, nil to use etags. -XEmacs prior to 20.4 doesn't support imenu, therefore the default is to -use etags instead. Etags support is not as robust as imenu support." +Etags support is not as robust as imenu support." ; See Bug#51102 :tag "Use Imenu for tags" :group 'speedbar :type 'boolean) commit dd6a24ebedc9953b1632eeafbd2f3b776afe04db Author: Po Lu Date: Fri May 20 20:08:06 2022 +0800 ; * src/xterm.c (struct x_client_list_window): Improve comment. diff --git a/src/xterm.c b/src/xterm.c index 46f55cb994..cbe6426447 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1034,8 +1034,9 @@ struct x_client_list_window /* Whether or not the window is mapped. */ bool mapped_p; - /* The event mask for the window before Emacs selected for events on - it. */ + /* A bitmask describing events Emacs was listening for from the + window before some extra events were added in + `x_dnd_compute_toplevels'. */ long previous_event_mask; /* The window manager state of the window. */ commit 8db0acb0f06ca35c366d896341147f616c048c25 Author: Po Lu Date: Fri May 20 20:03:05 2022 +0800 Check for allocation errors when setting XdndActionDescription * src/xterm.c (x_dnd_begin_drag_and_drop): Check for BadAlloc when setting action descriptions. diff --git a/src/xterm.c b/src/xterm.c index a3b7c4ac25..46f55cb994 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10101,7 +10101,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, struct frame *any; char *atom_name, *ask_actions; Lisp_Object action, ltimestamp; - specpdl_ref ref; + specpdl_ref ref, count; ptrdiff_t i, end, fill; XTextProperty prop; xm_drop_start_message dmsg; @@ -10228,6 +10228,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, { ask_actions = NULL; end = 0; + count = SPECPDL_INDEX (); for (i = 0; i < n_ask_actions; ++i) { @@ -10249,16 +10250,25 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, prop.format = 8; prop.nitems = end; + record_unwind_protect_ptr (xfree, ask_actions); + + /* This can potentially store a lot of data in window + properties, so check for allocation errors. */ block_input (); + x_catch_errors (FRAME_X_DISPLAY (f)); XSetTextProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &prop, FRAME_DISPLAY_INFO (f)->Xatom_XdndActionDescription); - xfree (ask_actions); XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_DISPLAY_INFO (f)->Xatom_XdndActionList, XA_ATOM, 32, PropModeReplace, (unsigned char *) ask_action_list, n_ask_actions); + x_check_errors (FRAME_X_DISPLAY (f), + "Can't set action descriptions: %s"); + x_uncatch_errors_after_check (); unblock_input (); + + unbind_to (count, Qnil); } else { commit e04cc584a8e0da7f80415397efc1c9a11efae4ff Author: Eli Zaretskii Date: Fri May 20 15:06:44 2022 +0300 ; * doc/lispref/text.texi (Yanking): Fix wording. diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 8fd8a5fb97..4439bc4865 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -1113,7 +1113,7 @@ or specifying key bindings. It takes effect after @defopt yank-transform-functions This variable is a list of functions. Each function is called (in -order) with the string to be yanked as the parameter, and should +order) with the string to be yanked as the argument, and should return a (possibly transformed) string. This variable can be set globally, but can also be used to create new commands that are variations on @code{yank}. For instance, to create a command that commit 6265e0c540e989021f2cbe3876be140188bef92f Author: Eli Zaretskii Date: Fri May 20 15:03:06 2022 +0300 Document 'enriched-toggle-markup' * etc/enriched.txt: Document the new 'enriched-toggle-markup' command. (Bug#33855) diff --git a/etc/NEWS b/etc/NEWS index 9321b4c079..70f2c0e6da 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -822,7 +822,7 @@ so automatically. ** Enriched Mode ---- ++++ *** New command 'enriched-toggle-markup'. This allows you to see the markup in 'enriched-mode' buffers (e.g., the HELLO file). diff --git a/etc/enriched.txt b/etc/enriched.txt index 5c74c610ae..2d970d197b 100644 --- a/etc/enriched.txt +++ b/etc/enriched.txt @@ -137,7 +137,7 @@ Unfortunately this does not look as nice with a fixed-width font as it does in a proportionally-spaced printed document; the extra spaces that are needed on the screen can make it hard to read. -
+
Center @@ -149,7 +149,6 @@ spaces that are needed on the screen can make it hard to read. justification. -
Note that justification can only change at hard newlines, because that is the unit over which filling gets done. @@ -189,7 +188,14 @@ as possible. The text/enriched standard is defined in Internet RFC 1896 -(<). +(<). + + +To make format annotations visible and possibly edit them, tell +Emacs to display the markup: + + +M-x enriched-toggle-markup RET bluewhiteCUSTOMIZATION commit 349284a40cad8ea79a7101de970c4ff2712984ad Author: Eli Zaretskii Date: Fri May 20 14:51:07 2022 +0300 ; * lisp/simple.el (yank-transform-functions): Doc fix. diff --git a/lisp/simple.el b/lisp/simple.el index c80af7c37b..6aa079464a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5952,9 +5952,8 @@ Each function in this list will be called (in order) with the string to be yanked as the sole argument, and should return the (possibly) transformed string. -The functions will be called from the buffer the string will be -inserted, and with point at the place where the string is to be -inserted." +The functions will be called with the destination buffer as the current +buffer, and with point at the place where the string is to be inserted." :type '(repeat function) :version "29.1" :group 'killing) commit eb71446de5352f6735e8a778ab4f71a04d90f76e Author: Eli Zaretskii Date: Fri May 20 14:35:03 2022 +0300 ; Improve documentation of 'display-buffer-avoid-small-windows' * lisp/window.el (display-buffer-avoid-small-windows) (get-lru-window): * etc/NEWS: * doc/lispref/windows.texi (Choosing Window Options): Improve documentation of 'display-buffer-avoid-small-windows'. (Bug#10186) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index bc3857b136..03d0f28867 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -3307,7 +3307,9 @@ that means not to split this way. @defopt display-buffer-avoid-small-windows If non-@code{nil}, this should be a number. Windows that have fewer -lines than this will be avoided when choosing an existing window. +lines than that will be avoided when choosing an existing window. The +value is interpreted in units of the frame's canonical line height, +like @code{window-total-height} does (@pxref{Window Sizes}). @end defopt @defopt even-window-sizes diff --git a/etc/NEWS b/etc/NEWS index 85413b0d38..9321b4c079 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -606,8 +606,8 @@ specifiers can now use ':type webp'. ** Windows *** New user option 'display-buffer-avoid-small-windows'. -If non-nil, this should be a window height. If windows smaller than -this will be avoided by 'display-buffer', if possible. +If non-nil, this should be a window height, a number. Windows smaller +than this will be avoided by 'display-buffer', if possible. +++ *** New display action 'display-buffer-full-frame'. diff --git a/lisp/window.el b/lisp/window.el index a0c51600dc..3fe48e2522 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2490,7 +2490,8 @@ and no others." (defcustom display-buffer-avoid-small-windows nil "If non-nil, windows that have fewer lines than this are avoided. -This is used by `get-lru-window'." +This is used by `get-lru-window'. The value is interpreted in units +of the frame's canonical line height, like `window-total-height' does." :type '(choice nil number) :version "29.1" :group 'windows) @@ -2522,9 +2523,9 @@ have special meanings: Any other value of ALL-FRAMES means consider all windows on the selected frame and no others. -`display-buffer-avoid-small-windows' is also taken into -consideration. Windows smaller than this size will be avoided if -there are larger windows available." +`display-buffer-avoid-small-windows', if non-nil, is also taken into +consideration. Windows whose height is smaller that the value of that +variable will be avoided if larger windows are available." (let ((windows (window-list-1 nil 'nomini all-frames)) best-window best-time second-best-window second-best-time time) (dolist (window windows) commit 3c82e96954450e766c63b507ed4e927d18e4cd9c Author: Lars Ingebrigtsen Date: Fri May 20 12:05:34 2022 +0200 Add new user option display-buffer-avoid-small-windows * doc/lispref/windows.texi (Choosing Window Options): Document it. * lisp/window.el (display-buffer-avoid-small-windows): New user option (bug#10186). (get-lru-window): Use it. diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 90551e6697..bc3857b136 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -3305,6 +3305,11 @@ window has at least that many columns. If the value is @code{nil}, that means not to split this way. @end defopt +@defopt display-buffer-avoid-small-windows +If non-@code{nil}, this should be a number. Windows that have fewer +lines than this will be avoided when choosing an existing window. +@end defopt + @defopt even-window-sizes This variable, if non-@code{nil}, causes @code{display-buffer} to even window sizes whenever it reuses an existing window, and that window is diff --git a/etc/NEWS b/etc/NEWS index 2314e55164..85413b0d38 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -605,6 +605,10 @@ specifiers can now use ':type webp'. ** Windows +*** New user option 'display-buffer-avoid-small-windows'. +If non-nil, this should be a window height. If windows smaller than +this will be avoided by 'display-buffer', if possible. + +++ *** New display action 'display-buffer-full-frame'. This action removes other windows on the frame when displaying a diff --git a/lisp/window.el b/lisp/window.el index 4ad2defdf9..a0c51600dc 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2488,8 +2488,15 @@ and no others." (defalias 'some-window 'get-window-with-predicate) +(defcustom display-buffer-avoid-small-windows nil + "If non-nil, windows that have fewer lines than this are avoided. +This is used by `get-lru-window'." + :type '(choice nil number) + :version "29.1" + :group 'windows) + (defun get-lru-window (&optional all-frames dedicated not-selected no-other) - "Return the least recently used window on frames specified by ALL-FRAMES. + "Return the least recently used window on frames specified by ALL-FRAMES. Return a full-width window if possible. A minibuffer window is never a candidate. A dedicated window is never a candidate unless DEDICATED is non-nil, so if all windows are dedicated, the @@ -2513,15 +2520,23 @@ have special meanings: - A frame means consider all windows on that frame only. Any other value of ALL-FRAMES means consider all windows on the -selected frame and no others." - (let (best-window best-time second-best-window second-best-time time) - (dolist (window (window-list-1 nil 'nomini all-frames)) +selected frame and no others. + +`display-buffer-avoid-small-windows' is also taken into +consideration. Windows smaller than this size will be avoided if +there are larger windows available." + (let ((windows (window-list-1 nil 'nomini all-frames)) + best-window best-time second-best-window second-best-time time) + (dolist (window windows) (when (and (or dedicated (not (window-dedicated-p window))) (or (not not-selected) (not (eq window (selected-window)))) (or (not no-other) (not (window-parameter window 'no-other-window)))) (setq time (window-use-time window)) (if (or (eq window (selected-window)) + (and display-buffer-avoid-small-windows + (< (window-height window) + display-buffer-avoid-small-windows)) (not (window-full-width-p window))) (when (or (not second-best-time) (< time second-best-time)) (setq second-best-time time) commit 69f42faa509aa25ffda036c8d1b0f1ee62eb17c5 Author: Lars Ingebrigtsen Date: Fri May 20 11:06:49 2022 +0200 Clarify select-active-regions doc string * src/keyboard.c (syms_of_keyboard): Clarify doc string (bug#29889). diff --git a/src/keyboard.c b/src/keyboard.c index 6c114986b7..481633f92f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12863,11 +12863,12 @@ and tool-bar buttons. */); DEFVAR_LISP ("select-active-regions", Vselect_active_regions, - doc: /* If non-nil, an active region automatically sets the primary selection. -If the value is `only', only temporarily active regions (usually made -by mouse-dragging or shift-selection) set the window selection. + doc: /* If non-nil, any active region automatically sets the primary selection. +This variable only has an effect when Transient Mark mode is enabled. -This takes effect only when Transient Mark mode is enabled. */); +If the value is `only', only temporarily active regions (usually made +by mouse-dragging or shift-selection) set the window system's primary +selection. */); Vselect_active_regions = Qt; DEFVAR_LISP ("saved-region-selection", commit c1fbbc57a9c850e2e8d756d0e6d7e967c652e870 Author: Po Lu Date: Fri May 20 09:28:19 2022 +0000 Fix race conditions processing zoom events on Haiku * src/haiku_support.cc (Zoom): * src/haiku_support.h (struct haiku_zoom_event): Include the current fullscreen mode in the event. * src/haikuterm.c (haiku_read_socket): Use that instead of the current frame's fullscreen mode. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 3961d33e4d..33c68cbd46 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1281,6 +1281,7 @@ class EmacsWindow : public BWindow struct haiku_zoom_event rq; rq.window = this; + rq.fullscreen_mode = fullscreen_mode; haiku_write (ZOOM_EVENT, &rq); } diff --git a/src/haiku_support.h b/src/haiku_support.h index b66486b1dc..163685572f 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -249,6 +249,7 @@ struct haiku_menu_bar_help_event struct haiku_zoom_event { void *window; + int fullscreen_mode; }; enum haiku_font_specification diff --git a/src/haikuterm.c b/src/haikuterm.c index 731afd9d39..6401ea1233 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -3867,14 +3867,11 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) { struct haiku_zoom_event *b = buf; struct frame *f = haiku_window_to_frame (b->window); - struct haiku_output *output; if (!f) continue; - output = FRAME_OUTPUT_DATA (f); - - if (output->fullscreen_mode == FULLSCREEN_MAXIMIZED) + if (b->fullscreen_mode == FULLSCREEN_MODE_MAXIMIZED) f->want_fullscreen = FULLSCREEN_NONE; else f->want_fullscreen = FULLSCREEN_MAXIMIZED; commit bbe6c68d79ae422498048f06fd8f1641abb38eab Author: Lars Ingebrigtsen Date: Fri May 20 10:37:15 2022 +0200 Re-fix previous `&' dired change * lisp/dired-aux.el (dired-shell-stuff-it): Re-fix the previous change -- the &wait was in the wrong place (bug#36331). diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index a98425d129..d87d617ed7 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -998,13 +998,14 @@ Also see the `dired-confirm-shell-command' variable." file-list dired-mark-separator))) (when (cdr file-list) (setq files (concat dired-mark-prefix files dired-mark-postfix))) - (funcall stuff-it files)))) - (or (and in-background - (if (not w32-shell) - ;; Work the same as the `on-each' case -- don't - ;; accept user input in the output buffer. - "&wait" - "&")) + (concat + (funcall stuff-it files) + ;; Be consistent in how we treat inputs to commands -- do + ;; the same here as in the `on-each' case. + (if (and in-background (not w32-shell)) + "&wait" + ""))))) + (or (and in-background "&") "")))) ;; This is an extra function so that it can be redefined by ange-ftp. commit 63eb0157226ad02eb6aeb9a6ec285502fddc4ddf Author: Philip Kaludercic Date: Sun May 15 02:09:46 2022 +0200 Add option to kill a shell buffer when the process ends * shell.el (shell-kill-buffer-on-quit): Add new option (bug#55426). (shell): Respect 'shell-kill-buffer-on-quit'. * NEWS: Mention 'shell-kill-buffer-on-quit'. diff --git a/etc/NEWS b/etc/NEWS index 26b9b19952..2314e55164 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1616,6 +1616,13 @@ values passed as a single token, such as '-oVALUE' or 'eshell-eval-using-options' macro. See "Defining new built-in commands" in the "(eshell) Built-ins" node of the Eshell manual. +** Shell + +--- +*** New user option 'shell-kill-buffer-on-exit'. +Enabling this will automatically kill a *shell* buffer as soon as the +shell session terminates. + ** Calc +++ diff --git a/lisp/shell.el b/lisp/shell.el index 47887433d9..4e65fccf9e 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -331,6 +331,12 @@ Useful for shells like zsh that has this feature." :group 'shell-directories :version "28.1") +(defcustom shell-kill-buffer-on-exit nil + "Kill a shell buffer after the shell process terminates." + :type 'boolean + :group 'shell + :version "29.1") + (defvar shell-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-f" 'shell-forward-command) @@ -818,6 +824,17 @@ Make the shell buffer the current buffer, and return it. (with-temp-buffer (insert-file-contents startfile) (buffer-string))))))) + (when shell-kill-buffer-on-exit + (let* ((buffer (current-buffer)) + (process (get-buffer-process buffer)) + (sentinel (process-sentinel process))) + (set-process-sentinel + process + (lambda (proc event) + (when sentinel + (funcall sentinel proc event)) + (unless (buffer-live-p proc) + (kill-buffer buffer)))))) buffer) ;;; Directory tracking commit fa6a0962c5315cceb3632fa6a701eac986940810 Author: Michael Albinus Date: Tue May 17 09:14:36 2022 +0200 Fix Tramp sshfs tests (don't merge) * test/lisp/net/tramp-tests.el (tramp-fuse-remove-hidden-files): Declare. (tramp-test16-directory-files) (tramp-test16-file-expand-wildcards) (tramp-test26-file-name-completion, tramp--test-check-files): Use it. (tramp--test-check-files): Delete directory recursively. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 7a377e7fbf..dbf62dbc1c 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -68,6 +68,7 @@ (defvar tramp-connection-properties) (defvar tramp-copy-size-limit) (defvar tramp-display-escape-sequence-regexp) +(defvar tramp-fuse-remove-hidden-files) (defvar tramp-fuse-unmount-on-cleanup) (defvar tramp-inline-compress-start-size) (defvar tramp-persistency-file-name) @@ -2997,7 +2998,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (skip-unless (tramp--test-enabled)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) + (let* ((tramp-fuse-remove-hidden-files t) + (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (expand-file-name "bla" tmp-name1)) (tmp-name3 (expand-file-name "foo" tmp-name1))) (unwind-protect @@ -3041,7 +3043,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (skip-unless (tramp--test-enabled)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) + (let* ((tramp-fuse-remove-hidden-files t) + (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (expand-file-name "foo" tmp-name1)) (tmp-name3 (expand-file-name "bar" tmp-name1)) (tmp-name4 (expand-file-name "baz" tmp-name1)) @@ -4303,7 +4306,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ;; Method and host name in completion mode. This kind of completion ;; does not work on MS Windows. (when (not (memq system-type '(cygwin windows-nt))) - (let ((method (file-remote-p tramp-test-temporary-file-directory 'method)) + (let ((tramp-fuse-remove-hidden-files t) + (method (file-remote-p tramp-test-temporary-file-directory 'method)) (host (file-remote-p tramp-test-temporary-file-directory 'host)) (orig-syntax tramp-syntax)) (when (and (stringp host) (string-match tramp-host-with-port-regexp host)) @@ -4355,7 +4359,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (dolist (non-essential '(nil t)) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) - (let ((tmp-name (tramp--test-make-temp-name nil quoted))) + (let ((tramp-fuse-remove-hidden-files t) + (tmp-name (tramp--test-make-temp-name nil quoted))) (unwind-protect (progn @@ -6463,6 +6468,7 @@ This requires restrictions of file name syntax." ;; would let the test fail. (let* ((tramp-test-temporary-file-directory (file-truename tramp-test-temporary-file-directory)) + (tramp-fuse-remove-hidden-files t) (tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (tramp--test-make-temp-name 'local quoted)) (files @@ -6636,7 +6642,7 @@ This requires restrictions of file name syntax." (delete-file file2) (should-not (file-exists-p file2)) - (delete-directory file1) + (delete-directory file1 'recursive) (should-not (file-exists-p file1)))) ;; Check, that environment variables are set correctly. commit f836ed098fe8c649e3c30cf55696b3a750f1bbf0 Author: Michael Albinus Date: Tue May 17 09:13:34 2022 +0200 Some minor Tramp fixes * lisp/net/tramp-cmds.el (tramp-list-tramp-buffers) (tramp-list-remote-buffers): Add ;;;###tramp-autoload cookie. * lisp/net/tramp-fuse.el (tramp-fuse-remove-hidden-files): New defvar. (tramp-fuse-remove-hidden-files): Use it. * lisp/net/tramp-gvfs.el (tramp-gvfs-handler-askquestion): Keep regression tests running. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 43aed62555..8e359c382b 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -51,6 +51,7 @@ SYNTAX can be one of the symbols `default' (default), (when syntax (customize-set-variable 'tramp-syntax syntax))) +;;;###tramp-autoload (defun tramp-list-tramp-buffers () "Return a list of all Tramp connection buffers." (append @@ -61,6 +62,7 @@ SYNTAX can be one of the symbols `default' (default), (all-completions "*trace tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list)))))) +;;;###tramp-autoload (defun tramp-list-remote-buffers () "Return a list of all buffers with remote `default-directory'." (delq diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el index 54e7999e7a..7344c3c730 100644 --- a/lisp/net/tramp-fuse.el +++ b/lisp/net/tramp-fuse.el @@ -44,11 +44,16 @@ (delete-file (tramp-fuse-local-file-name filename) trash) (tramp-flush-file-properties v localname))) +(defvar tramp-fuse-remove-hidden-files nil + "Remove hidden files from directory listings.") + (defsubst tramp-fuse-remove-hidden-files (files) "Remove hidden files from FILES." - (cl-remove-if - (lambda (x) (and (stringp x) (string-match-p "\\.fuse_hidden" x))) - files)) + (if tramp-fuse-remove-hidden-files + (cl-remove-if + (lambda (x) (and (stringp x) (string-match-p "\\.fuse_hidden" x))) + files) + files)) (defun tramp-fuse-handle-directory-files (directory &optional full match nosort count) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index c09c016e64..3a5041c491 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1774,22 +1774,26 @@ a downcased host name only." (list t ;; handled. nil ;; no abort of D-Bus. - (with-tramp-connection-property (tramp-get-process v) message - ;; In theory, there can be several choices. - ;; Until now, there is only the question whether - ;; to accept an unknown host signature or certificate. - (with-temp-buffer - ;; Preserve message for `progress-reporter'. - (with-temp-message "" - (insert message) - (goto-char (point-max)) - (if noninteractive - (message "%s" message) - (pop-to-buffer (current-buffer))) - (if (yes-or-no-p - (buffer-substring - (line-beginning-position) (point))) - 0 1))))) + ;; Preserve message for `progress-reporter'. + (with-temp-message "" + (if noninteractive + ;; Keep regression tests running. + (progn + (message "%s" message) + 0) + (with-tramp-connection-property (tramp-get-process v) message + ;; In theory, there can be several choices. + ;; Until now, there is only the question + ;; whether to accept an unknown host + ;; signature or certificate. + (with-temp-buffer + (insert message) + (goto-char (point-max)) + (pop-to-buffer (current-buffer)) + (if (yes-or-no-p + (buffer-substring + (line-beginning-position) (point))) + 0 1)))))) ;; When QUIT is raised, we shall return this ;; information to D-Bus.