From 0522049864951fcb1231e80725a3c8d7d88605c6 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 7 Jul 2023 09:33:56 +0300 Subject: [PATCH 1/3] * lisp/tab-bar.el: Improve tab-bar-minibuffer-restore-tab (bug#64373). (tab-bar-select-tab): Set tab-bar-minibuffer-restore-tab and minibuffer-exit-hook minibuffer-locally to handle recursive minibuffers for non-nil read-minibuffer-restore-windows. (tab-bar-minibuffer-restore-tab): No need to reset minibuffer-local values. --- lisp/tab-bar.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 234e7e5d14d..f47c4a7bb6c 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1261,10 +1261,8 @@ inherits the current tab's `explicit-name' parameter." This is necessary to prepare the same window configuration where original windows were saved and will be restored. This function is used only when `read-minibuffer-restore-windows' is non-nil." - (when (and read-minibuffer-restore-windows - tab-bar-minibuffer-restore-tab) - (tab-bar-select-tab tab-bar-minibuffer-restore-tab) - (setq tab-bar-minibuffer-restore-tab nil))) + (when tab-bar-minibuffer-restore-tab + (tab-bar-select-tab tab-bar-minibuffer-restore-tab))) (defun tab-bar-select-tab (&optional tab-number) "Switch to the tab by its absolute position TAB-NUMBER in the tab bar. @@ -1293,8 +1291,8 @@ Negative TAB-NUMBER counts tabs from the end of the tab bar." (when (and read-minibuffer-restore-windows minibuffer-was-active (not tab-bar-minibuffer-restore-tab)) - (setq tab-bar-minibuffer-restore-tab (1+ from-index)) - (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab)) + (setq-local tab-bar-minibuffer-restore-tab (1+ from-index)) + (add-hook 'minibuffer-exit-hook 'tab-bar-minibuffer-restore-tab nil t)) (unless (eq from-index to-index) (let* ((from-tab (tab-bar--tab)) From 51807e12dacbc1abc238ebafb4ba20e27f4bcc81 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 7 Jul 2023 10:18:43 +0300 Subject: [PATCH 2/3] * lisp/tab-bar.el: Fix tab-bar-tab-name-current for active minibuffer. (tab-bar-tab-name-current): Use get-mru-window in the active minibuffer when minibuffer-selected-window is nil after switching to another tab. (tab-bar-tab-name-current-with-count) (tab-bar-tab-name-truncated): Use tab-bar-tab-name-current. --- lisp/tab-bar.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index f47c4a7bb6c..14b340f6183 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -618,13 +618,18 @@ from all windows in the window configuration." (defun tab-bar-tab-name-current () "Generate tab name from the buffer of the selected window." - (buffer-name (window-buffer (minibuffer-selected-window)))) + ;; `minibuffer-selected-window' loses its original window + ;; after switching to another tab while the minibuffer was active, + ;; so get the most recently used non-minibuffer window. + (buffer-name (window-buffer (or (minibuffer-selected-window) + (and (window-minibuffer-p) + (get-mru-window)))))) (defun tab-bar-tab-name-current-with-count () "Generate tab name from the buffer of the selected window. Also add the number of windows in the window configuration." (let ((count (length (window-list-1 nil 'nomini))) - (name (window-buffer (minibuffer-selected-window)))) + (name (tab-bar-tab-name-current))) (if (> count 1) (format "%s (%d)" name count) (format "%s" name)))) @@ -651,7 +656,7 @@ to `tab-bar-tab-name-truncated'." "Generate tab name from the buffer of the selected window. Truncate it to the length specified by `tab-bar-tab-name-truncated-max'. Append ellipsis `tab-bar-tab-name-ellipsis' in this case." - (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window))))) + (let ((tab-name (tab-bar-tab-name-current))) (if (< (length tab-name) tab-bar-tab-name-truncated-max) tab-name (propertize (truncate-string-to-width From 37101780243d083e8773c255242aa26614f22a14 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 7 Jul 2023 12:09:50 -0400 Subject: [PATCH 3/3] * lisp/emacs-lisp/bytecomp.el (byte-compile-eval): Fix bug#64232 --- lisp/emacs-lisp/bytecomp.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 262c658e258..489a9724fc4 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1128,7 +1128,8 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." ;; we arguably should add it to b-c-noruntime-functions, ;; but it's not clear it's worth the trouble ;; trying to recognize that case. - (unless (get f 'function-history) + (unless (or (get f 'function-history) + (assq f byte-compile-function-environment)) (push f byte-compile-noruntime-functions))))))))))))) (defun byte-compile-eval-before-compile (form)