diff --git a/etc/NEWS b/etc/NEWS index 1e6756e431e..f3c12ffaf34 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -511,9 +511,9 @@ terminal. --- *** After deleting, 'delete-frame' now selects the most recently used frame. Previously, after deleting a specified frame, 'delete-frame' would -select the next eligible frame in the order of the frame list. This is -often unrelated to frames' recent use and can appear somewhat random to -users. +select the oldest visible frame on the same terminal. To revert to the +old behavior, set the new user option +'after-delete-frame-select-mru-frame' to nil. +++ *** New value 'force' for user option 'frame-inhibit-implied-resize'. diff --git a/src/frame.c b/src/frame.c index 6b5d8942db4..8844e869b18 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2749,7 +2749,9 @@ delete_frame (Lisp_Object frame, Lisp_Object force) else { frame1 = Qnil; - if (!EQ (force, Qnoelisp)) + + if (after_delete_frame_select_mru_frame + && !EQ (force, Qnoelisp)) { /* Find the most recently used visible frame among all frames on the same terminal as FRAME, excluding FRAME @@ -7778,6 +7780,13 @@ The default is \\+`inhibit' in NS builds and nil everywhere else. */); alter_fullscreen_frames = Qnil; #endif + DEFVAR_BOOL ("after-delete-frame-select-mru-frame", + after_delete_frame_select_mru_frame, + doc: /* Non-nil means `delete-frame' selects most recently used frame. +If this is nil, `delete-frame' will select the oldest visible frame on +the same terminal. */); + after_delete_frame_select_mru_frame = true; + defsubr (&Sframe_id); defsubr (&Sframep); defsubr (&Sframe_live_p);