unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42052: 28.0.50; tab-bar-mode should be frame-local
@ 2020-06-25 20:07 James N. V. Cash
  2020-06-27 23:40 ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: James N. V. Cash @ 2020-06-25 20:07 UTC (permalink / raw)
  To: 42052


When setting tab-bar-show to `1`, I expect the tab bar to only show if
there is more than one tab in the frame.

This behaves as expected when there is only one frame, but if I have
multiple frames open, then if any one of them has more than one tab, it
turns on tab-bar-mode, which then makes any other frame show the tab
bar, even if they only have one tab in them.

Would it be possible to have tab-bar-mode showing be frame-local?

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10)
 of 2020-06-20 built on gonk
Repository revision: 3af631dcf28a5964d9e56c9be8ee7f2125d90d8a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.4 LTS

Configured using:
 'configure --with-xwidgets --with-cairo'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD JSON PDUMPER LCMS2 GMP





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-25 20:07 bug#42052: 28.0.50; tab-bar-mode should be frame-local James N. V. Cash
@ 2020-06-27 23:40 ` Juri Linkov
  2020-06-28 12:15   ` James N. V. Cash
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-06-27 23:40 UTC (permalink / raw)
  To: James N. V. Cash; +Cc: 42052

> When setting tab-bar-show to `1`, I expect the tab bar to only show if
> there is more than one tab in the frame.
>
> This behaves as expected when there is only one frame, but if I have
> multiple frames open, then if any one of them has more than one tab, it
> turns on tab-bar-mode, which then makes any other frame show the tab
> bar, even if they only have one tab in them.
>
> Would it be possible to have tab-bar-mode showing be frame-local?

Thanks for the request, I see this means a request for a new feature of
enabling the tab-bar separately on each frame independently from
other frames.

When some time ago I asked on emacs-devel about the need for a such feature,
proposing to add a new function global-tab-bar-mode, no one wanted it.
But nevertheless it could be created now anyway.

If someone will point out an example of frame-local modes,
this could help in implementing the same for tab-bar-mode.

I can find only toggle-tool-bar-mode-from-frame, but actually
it's still not frame-local.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-27 23:40 ` Juri Linkov
@ 2020-06-28 12:15   ` James N. V. Cash
  2020-06-28 19:45     ` James N. V. Cash
  0 siblings, 1 reply; 17+ messages in thread
From: James N. V. Cash @ 2020-06-28 12:15 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 42052

Juri Linkov <juri@linkov.net> writes:

>> When setting tab-bar-show to `1`, I expect the tab bar to only show if
>> there is more than one tab in the frame.
>>
> If someone will point out an example of frame-local modes,
> this could help in implementing the same for tab-bar-mode.

Looking at how the tab-bar-mode currently works, the thing that seems
simplest to me would be to change the various functions that
conditionally turn tab-bar-mode on/off (e.g. in tab-bar-new-tab-to)
to have an additional check if (natnump tab-bar-show), in which case
instead of calling (tab-bar-mode 1) or -1, setting the frame parameter
tab-bar-lines for that particular frame to be 1 or 0, as appropriate.

The wrinkle would be, I suppose, having to remove all the frame-local
settings if tab-bar-show changes, but presumably that wouldn't be
happening too often.

A frame-local toggling of the tab bar could work the same way.

If that makes sense (i.e. having the setting be frame local only when
tab-bar-show is 1), I can try submitting a patch later today.

James Cash





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-28 12:15   ` James N. V. Cash
@ 2020-06-28 19:45     ` James N. V. Cash
  2020-06-28 23:18       ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: James N. V. Cash @ 2020-06-28 19:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 42052

James N. V. Cash <james.nvc@gmail.com> writes:

> Juri Linkov <juri@linkov.net> writes:
>
>>> When setting tab-bar-show to `1`, I expect the tab bar to only show if
>>> there is more than one tab in the frame.
>>>
>> If someone will point out an example of frame-local modes,
>> this could help in implementing the same for tab-bar-mode.
>
> Looking at how the tab-bar-mode currently works, the thing that seems
> simplest to me would be to change the various functions that
> conditionally turn tab-bar-mode on/off (e.g. in tab-bar-new-tab-to)
> to have an additional check if (natnump tab-bar-show), in which case
> instead of calling (tab-bar-mode 1) or -1, setting the frame parameter
> tab-bar-lines for that particular frame to be 1 or 0, as appropriate.
>
> The wrinkle would be, I suppose, having to remove all the frame-local
> settings if tab-bar-show changes, but presumably that wouldn't be
> happening too often.
>
> A frame-local toggling of the tab bar could work the same way.
>
> If that makes sense (i.e. having the setting be frame local only when
> tab-bar-show is 1), I can try submitting a patch later today.

Here's a simple patch I made that seems to act more like I expect

--- /home/james/src/emacs/lisp/tab-bar.el 2020-06-20 10:16:57.177037735 -0400
+++ tab-bar.el  2020-06-28 15:40:38.711147160 -0400
@@ -799,11 +799,16 @@
       (run-hook-with-args 'tab-bar-tab-post-open-functions
                           (nth to-index tabs)))

-    (when (and (not tab-bar-mode)
-               (or (eq tab-bar-show t)
-                   (and (natnump tab-bar-show)
-                        (> (length tabs) tab-bar-show))))
+    (cond
+     (tab-bar-mode)
+     ((eq tab-bar-show t)
       (tab-bar-mode 1))
+     ((and (natnump tab-bar-show)
+           (> (length tabs) tab-bar-show)
+           (zerop (frame-parameter nil 'tab-bar-lines)))
+      (progn
+        (message "show")
+        (set-frame-parameter nil 'tab-bar-lines 1))))

     (force-mode-line-update)
     (unless tab-bar-mode
@@ -936,10 +941,10 @@
                 tab-bar-closed-tabs)
           (set-frame-parameter nil 'tabs (delq close-tab tabs)))

-        (when (and tab-bar-mode
+        (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
                    (and (natnump tab-bar-show)
                         (<= (length tabs) tab-bar-show)))
-          (tab-bar-mode -1))
+          (set-frame-parameter nil 'tab-bar-lines 0))

         (force-mode-line-update)
         (unless tab-bar-mode
@@ -975,10 +980,12 @@
           (run-hook-with-args 'tab-bar-tab-pre-close-functions (nth index tabs) nil)))
       (set-frame-parameter nil 'tabs (list (nth current-index tabs)))

-      (when (and tab-bar-mode
-                 (and (natnump tab-bar-show)
-                      (<= 1 tab-bar-show)))
-        (tab-bar-mode -1))
+      (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
+                   (and (natnump tab-bar-show)
+                        (<= (length tabs) tab-bar-show)))
+          (modify-frame-parameters
+           nil
+           (assq-delete-all 'tab-bar-lines (frame-parameters nil))))

       (force-mode-line-update)
       (unless tab-bar-mode





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-28 19:45     ` James N. V. Cash
@ 2020-06-28 23:18       ` Juri Linkov
  2020-06-29  0:26         ` James N. V. Cash
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-06-28 23:18 UTC (permalink / raw)
  To: James N. V. Cash; +Cc: 42052

>> Looking at how the tab-bar-mode currently works, the thing that seems
>> simplest to me would be to change the various functions that
>> conditionally turn tab-bar-mode on/off (e.g. in tab-bar-new-tab-to)
>> to have an additional check if (natnump tab-bar-show), in which case
>> instead of calling (tab-bar-mode 1) or -1, setting the frame parameter
>> tab-bar-lines for that particular frame to be 1 or 0, as appropriate.
>>
>> The wrinkle would be, I suppose, having to remove all the frame-local
>> settings if tab-bar-show changes, but presumably that wouldn't be
>> happening too often.
>>
>> A frame-local toggling of the tab bar could work the same way.
>>
>> If that makes sense (i.e. having the setting be frame local only when
>> tab-bar-show is 1), I can try submitting a patch later today.
>
> Here's a simple patch I made that seems to act more like I expect

Thanks for the patch.  One problem is that directly changing the
frame parameter tab-bar-lines avoids performing some other
settings in tab-bar-mode such as loading button images and changing
some keybindings.  OTOH, these keybindings can't be frame-local anyway,
so maybe this is not important for the case when tab-bar-show is 1.

> +     ((and (natnump tab-bar-show)
> +           (> (length tabs) tab-bar-show)
> +           (zerop (frame-parameter nil 'tab-bar-lines)))
> +      (progn
> +        (message "show")
> +        (set-frame-parameter nil 'tab-bar-lines 1))))

Please don't forget to remove this debugging message in the final patch.

> @@ -975,10 +980,12 @@
>            (run-hook-with-args 'tab-bar-tab-pre-close-functions (nth index tabs) nil)))
>        (set-frame-parameter nil 'tabs (list (nth current-index tabs)))
>
> -      (when (and tab-bar-mode
> -                 (and (natnump tab-bar-show)
> -                      (<= 1 tab-bar-show)))
> -        (tab-bar-mode -1))
> +      (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
> +                   (and (natnump tab-bar-show)
> +                        (<= (length tabs) tab-bar-show)))
> +          (modify-frame-parameters
> +           nil
> +           (assq-delete-all 'tab-bar-lines (frame-parameters nil))))

Unlike other places that simply use (set-frame-parameter nil 'tab-bar-lines 0)
this code is more complex.  But it seems it should work with just
(set-frame-parameter nil 'tab-bar-lines 0) as well.

BTW, I see a problem in the old code: the variable 'tabs' is not always updated
and sometimes contains obsolete data.  It should help to replace

  (<= (length tabs) tab-bar-show)

with

  (<= (length (funcall tab-bar-tabs-function)) tab-bar-show)

that gets fresh data.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-28 23:18       ` Juri Linkov
@ 2020-06-29  0:26         ` James N. V. Cash
  2020-06-29  0:35           ` James N. V. Cash
  2020-06-29 23:45           ` Juri Linkov
  0 siblings, 2 replies; 17+ messages in thread
From: James N. V. Cash @ 2020-06-29  0:26 UTC (permalink / raw)
  To: 42052

Juri Linkov <juri@linkov.net> writes:

> Please don't forget to remove this debugging message in the final patch.

Oh oops, sorry about that.

> Unlike other places that simply use (set-frame-parameter nil 'tab-bar-lines 0)
> this code is more complex.  But it seems it should work with just
> (set-frame-parameter nil 'tab-bar-lines 0) as well.

Ah, right. I was thinking that

> BTW, I see a problem in the old code: the variable 'tabs' is not always updated
> and sometimes contains obsolete data.  It should help to replace
>
>   (<= (length tabs) tab-bar-show)
>
> with
>
>   (<= (length (funcall tab-bar-tabs-function)) tab-bar-show)
>
> that gets fresh data.

That makes sense.

Here's another patch that addresses this issues, although as you say, it
still doesn't address the issue of loading the button images or changing
keybindings.

--- /home/james/src/emacs/lisp/tab-bar.el 2020-06-20 10:16:57.177037735 -0400
+++ /home/james/tmp/tab-bar.el  2020-06-28 20:15:46.073203151 -0400
@@ -799,11 +799,14 @@
       (run-hook-with-args 'tab-bar-tab-post-open-functions
                           (nth to-index tabs)))

-    (when (and (not tab-bar-mode)
-               (or (eq tab-bar-show t)
-                   (and (natnump tab-bar-show)
-                        (> (length tabs) tab-bar-show))))
+    (cond
+     (tab-bar-mode)
+     ((eq tab-bar-show t)
       (tab-bar-mode 1))
+     ((and (natnump tab-bar-show)
+           (> (length (funcall tab-bar-tabs-function)) tab-bar-show)
+           (zerop (frame-parameter nil 'tab-bar-lines)))
+      (set-frame-parameter nil 'tab-bar-lines 1)))

     (force-mode-line-update)
     (unless tab-bar-mode
@@ -936,10 +939,11 @@
                 tab-bar-closed-tabs)
           (set-frame-parameter nil 'tabs (delq close-tab tabs)))

-        (when (and tab-bar-mode
-                   (and (natnump tab-bar-show)
-                        (<= (length tabs) tab-bar-show)))
-          (tab-bar-mode -1))
+        (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
+                   (natnump tab-bar-show)
+                   (<= (length (funcall tab-bar-tabs-function))
+                       tab-bar-show))
+          (set-frame-parameter nil 'tab-bar-lines 0))

         (force-mode-line-update)
         (unless tab-bar-mode
@@ -975,10 +979,11 @@
           (run-hook-with-args 'tab-bar-tab-pre-close-functions (nth index tabs) nil)))
       (set-frame-parameter nil 'tabs (list (nth current-index tabs)))

-      (when (and tab-bar-mode
-                 (and (natnump tab-bar-show)
-                      (<= 1 tab-bar-show)))
-        (tab-bar-mode -1))
+      (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
+                 (natnump tab-bar-show)
+                 (<= (length (funcall tab-bar-tabs-function))
+                     tab-bar-show))
+        (set-frame-parameter nil 'tab-bar-lines 0))

       (force-mode-line-update)
       (unless tab-bar-mode





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-29  0:26         ` James N. V. Cash
@ 2020-06-29  0:35           ` James N. V. Cash
  2020-06-29 23:45           ` Juri Linkov
  1 sibling, 0 replies; 17+ messages in thread
From: James N. V. Cash @ 2020-06-29  0:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 42052

James N. V. Cash <james.nvc@gmail.com> writes:

>> Unlike other places that simply use (set-frame-parameter nil 'tab-bar-lines 0)
>> this code is more complex.  But it seems it should work with just
>> (set-frame-parameter nil 'tab-bar-lines 0) as well.
>
> Ah, right. I was thinking that

Oof, sorry, my brain is just melting today.

Meant to write: "I was thinking that removing the tab-bar-lines would
allow switching tab-bar-mode on or off global work properly, but then
looking at the implementation, I see that it sets the frame parameter
explicitly when toggling on/off in any case."





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-29  0:26         ` James N. V. Cash
  2020-06-29  0:35           ` James N. V. Cash
@ 2020-06-29 23:45           ` Juri Linkov
  2020-07-09 17:06             ` James N. V. Cash
  1 sibling, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-06-29 23:45 UTC (permalink / raw)
  To: James N. V. Cash; +Cc: 42052

> Here's another patch that addresses this issues, although as you say, it
> still doesn't address the issue of loading the button images or changing
> keybindings.

Thanks, pushed to master.  If you have more ideas for further development,
this report could be left open to address these issues too.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-06-29 23:45           ` Juri Linkov
@ 2020-07-09 17:06             ` James N. V. Cash
  2020-07-09 23:49               ` Juri Linkov
  0 siblings, 1 reply; 17+ messages in thread
From: James N. V. Cash @ 2020-07-09 17:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 42052

Juri Linkov <juri@linkov.net> writes:

> Thanks, pushed to master.  If you have more ideas for further development,
> this report could be left open to address these issues too.

I've attached another patch that makes the key bindings & xpm icons get
loaded when tab-bar-show is 1 as well. It doesn't un-load the
keybindings in the way that globalling toggling tab-bar-mode off, but I
don't really see a sensible way of doing that frame-locally.

--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -95,23 +95,27 @@ tab-bar-select-tab-modifiers
   :version "27.1")
 
 \f
-(define-minor-mode tab-bar-mode
-  "Toggle the tab bar in all graphical frames (Tab Bar mode)."
-  :global t
-  ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
-  :variable tab-bar-mode
-  (let ((val (if tab-bar-mode 1 0)))
-    (dolist (frame (frame-list))
-      (set-frame-parameter frame 'tab-bar-lines val))
-    ;; If the user has given `default-frame-alist' a `tab-bar-lines'
-    ;; parameter, replace it.
-    (if (assq 'tab-bar-lines default-frame-alist)
-        (setq default-frame-alist
-              (cons (cons 'tab-bar-lines val)
-                    (assq-delete-all 'tab-bar-lines
-                                     default-frame-alist)))))
-
-  (when (and tab-bar-mode tab-bar-new-button
+(defun tab-bar--define-keys ()
+  "Install key bindings for switching between tabs if the user has
+configured them."
+  (when tab-bar-select-tab-modifiers
+    (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0)))
+                    'tab-bar-switch-to-recent-tab)
+    (dotimes (i 9)
+      (global-set-key (vector (append tab-bar-select-tab-modifiers
+                                      (list (+ i 1 ?0))))
+                      'tab-bar-select-tab)))
+  ;; Don't override user customized key bindings
+  (unless (global-key-binding [(control tab)])
+    (global-set-key [(control tab)] 'tab-next))
+  (unless (global-key-binding [(control shift tab)])
+    (global-set-key [(control shift tab)] 'tab-previous))
+  (unless (global-key-binding [(control shift iso-lefttab)])
+    (global-set-key [(control shift iso-lefttab)] 'tab-previous)))
+
+(defun tab-bar--load-buttons ()
+  "Load the icons for the tab buttons."
+  (when (and tab-bar-new-button
              (not (get-text-property 0 'display tab-bar-new-button)))
     ;; This file is pre-loaded so only here we can use the right data-directory:
     (add-text-properties 0 (length tab-bar-new-button)
@@ -121,7 +125,7 @@ tab-bar-mode
                                           :ascent center))
                          tab-bar-new-button))
 
-  (when (and tab-bar-mode tab-bar-close-button
+  (when (and tab-bar-close-button
              (not (get-text-property 0 'display tab-bar-close-button)))
     ;; This file is pre-loaded so only here we can use the right data-directory:
     (add-text-properties 0 (length tab-bar-close-button)
@@ -129,24 +133,27 @@ tab-bar-mode
                                           :file "tabs/close.xpm"
                                           :margin (2 . 0)
                                           :ascent center))
-                         tab-bar-close-button))
+                         tab-bar-close-button)))
 
+(define-minor-mode tab-bar-mode
+  "Toggle the tab bar in all graphical frames (Tab Bar mode)."
+  :global t
+  ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
+  :variable tab-bar-mode
+  (let ((val (if tab-bar-mode 1 0)))
+    (dolist (frame (frame-list))
+      (set-frame-parameter frame 'tab-bar-lines val))
+    ;; If the user has given `default-frame-alist' a `tab-bar-lines'
+    ;; parameter, replace it.
+    (if (assq 'tab-bar-lines default-frame-alist)
+        (setq default-frame-alist
+              (cons (cons 'tab-bar-lines val)
+                    (assq-delete-all 'tab-bar-lines
+                                     default-frame-alist)))))
+  (when tab-bar-mode
+    (tab-bar--load-buttons))
   (if tab-bar-mode
-      (progn
-        (when tab-bar-select-tab-modifiers
-          (global-set-key (vector (append tab-bar-select-tab-modifiers (list ?0)))
-                          'tab-bar-switch-to-recent-tab)
-          (dotimes (i 9)
-            (global-set-key (vector (append tab-bar-select-tab-modifiers
-                                            (list (+ i 1 ?0))))
-                            'tab-bar-select-tab)))
-        ;; Don't override user customized key bindings
-        (unless (global-key-binding [(control tab)])
-          (global-set-key [(control tab)] 'tab-next))
-        (unless (global-key-binding [(control shift tab)])
-          (global-set-key [(control shift tab)] 'tab-previous))
-        (unless (global-key-binding [(control shift iso-lefttab)])
-          (global-set-key [(control shift iso-lefttab)] 'tab-previous)))
+      (tab-bar--define-keys)
     ;; Unset only keys bound by tab-bar
     (when (eq (global-key-binding [(control tab)]) 'tab-next)
       (global-unset-key [(control tab)]))
@@ -806,7 +813,10 @@ tab-bar-new-tab-to
      ((and (natnump tab-bar-show)
            (> (length (funcall tab-bar-tabs-function)) tab-bar-show)
            (zerop (frame-parameter nil 'tab-bar-lines)))
-      (set-frame-parameter nil 'tab-bar-lines 1)))
+      (progn
+        (tab-bar--load-buttons)
+        (tab-bar--define-keys)
+        (set-frame-parameter nil 'tab-bar-lines 1))))
 
     (force-mode-line-update)
     (unless tab-bar-mode





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-09 17:06             ` James N. V. Cash
@ 2020-07-09 23:49               ` Juri Linkov
  2020-07-11 14:45                 ` James N. V. Cash
                                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Juri Linkov @ 2020-07-09 23:49 UTC (permalink / raw)
  To: James N. V. Cash; +Cc: 42052, Stefan Monnier

> I've attached another patch that makes the key bindings & xpm icons get
> loaded when tab-bar-show is 1 as well. It doesn't un-load the
> keybindings in the way that globalling toggling tab-bar-mode off, but I
> don't really see a sensible way of doing that frame-locally.

I don't know if such thing as frame-local keybindings is currently possible.

The manual at (info "(elisp) Searching Keymaps") shows the decision tree:

     (or (if overriding-terminal-local-map
             (FIND-IN overriding-terminal-local-map))
         (if overriding-local-map
             (FIND-IN overriding-local-map)
           (or (FIND-IN (get-char-property (point) 'keymap))
               (FIND-IN-ANY emulation-mode-map-alists)
               (FIND-IN-ANY minor-mode-overriding-map-alist)
               (FIND-IN-ANY minor-mode-map-alist)
               (if (get-text-property (point) 'local-map)
                   (FIND-IN (get-char-property (point) 'local-map))
                 (FIND-IN (current-local-map)))))
         (FIND-IN (current-global-map)))

If the variable `overriding-terminal-local-map` can't be made frame-local,
then maybe a new rule could be added.  Then like `(get-char-property (point) 'keymap)`
gets a keymap at point, a new rule could get a keymap from the frame alist.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-09 23:49               ` Juri Linkov
@ 2020-07-11 14:45                 ` James N. V. Cash
  2020-07-12  0:01                   ` Juri Linkov
  2020-07-11 15:17                 ` Stefan Monnier
  2020-10-13  3:07                 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 17+ messages in thread
From: James N. V. Cash @ 2020-07-11 14:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 42052, Stefan Monnier

Juri Linkov <juri@linkov.net> writes:

>> I've attached another patch that makes the key bindings & xpm icons get
>> loaded when tab-bar-show is 1 as well. It doesn't un-load the
>> keybindings in the way that globalling toggling tab-bar-mode off, but I
>> don't really see a sensible way of doing that frame-locally.
>
> ...
>
> If the variable `overriding-terminal-local-map` can't be made frame-local,
> then maybe a new rule could be added.  Then like `(get-char-property (point) 'keymap)`
> gets a keymap at point, a new rule could get a keymap from the frame alist.

I can look into that as a generally useful addition.

For this particular case though, I don't know if it's completely
necessary: The functions that are bound to keys here silently do nothing
if there's only one tab and the bindings don't get added if there are
other bindings for those keys, so as far as I can tell, it shouldn't
really make a difference whether or not the bindings are active when the
tab bar isn't visible.

It is entirely possible I'm missing something though and it certainly
does seem "cleaner" to remove the key bindings when they don't need to
be there.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-09 23:49               ` Juri Linkov
  2020-07-11 14:45                 ` James N. V. Cash
@ 2020-07-11 15:17                 ` Stefan Monnier
  2020-07-12  0:04                   ` Juri Linkov
  2020-10-13  3:07                 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2020-07-11 15:17 UTC (permalink / raw)
  To: Juri Linkov; +Cc: James N. V. Cash, 42052

> I don't know if such thing as frame-local keybindings is currently possible.
>
> The manual at (info "(elisp) Searching Keymaps") shows the decision tree:

FWIW, I think it would be nice to eliminate the last few remaining
places where we collect the active keymaps by hand rather than by
calling Fcurrent_active_maps.

Then we could allow Elisp code to modify the behavior of
`current-active-maps`.


        Stefan






^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-11 14:45                 ` James N. V. Cash
@ 2020-07-12  0:01                   ` Juri Linkov
  0 siblings, 0 replies; 17+ messages in thread
From: Juri Linkov @ 2020-07-12  0:01 UTC (permalink / raw)
  To: James N. V. Cash; +Cc: 42052, Stefan Monnier

> For this particular case though, I don't know if it's completely
> necessary: The functions that are bound to keys here silently do nothing
> if there's only one tab and the bindings don't get added if there are
> other bindings for those keys, so as far as I can tell, it shouldn't
> really make a difference whether or not the bindings are active when the
> tab bar isn't visible.

The answer depends on another question: why bother unsetting tab-bar keys
while disabling tab-bar-mode globally?  I mean the lines in tab-bar-mode
after ";; Unset only keys bound by tab-bar".  Maybe it's useful to make the
keybindings space cleaner?

PS: please see the bug report sent yesterday to emacs-devel at
https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00251.html

It seems the variable tab-bar-mode should be frame-local.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-11 15:17                 ` Stefan Monnier
@ 2020-07-12  0:04                   ` Juri Linkov
  2020-07-12 16:38                     ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2020-07-12  0:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: James N. V. Cash, 42052

>> I don't know if such thing as frame-local keybindings is currently possible.
>>
>> The manual at (info "(elisp) Searching Keymaps") shows the decision tree:
>
> FWIW, I think it would be nice to eliminate the last few remaining
> places where we collect the active keymaps by hand rather than by
> calling Fcurrent_active_maps.
>
> Then we could allow Elisp code to modify the behavior of
> `current-active-maps`.

I can't find these places where the active keymaps are collected by hand.
But maybe adding an advice on `current-active-maps` to use frame-local
keybindings might help to find these places where frame-local keybindings
will fail.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-12  0:04                   ` Juri Linkov
@ 2020-07-12 16:38                     ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2020-07-12 16:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: James N. V. Cash, 42052

Juri Linkov [2020-07-12 03:04:31] wrote:

>>> I don't know if such thing as frame-local keybindings is currently possible.
>>>
>>> The manual at (info "(elisp) Searching Keymaps") shows the decision tree:
>>
>> FWIW, I think it would be nice to eliminate the last few remaining
>> places where we collect the active keymaps by hand rather than by
>> calling Fcurrent_active_maps.
>>
>> Then we could allow Elisp code to modify the behavior of
>> `current-active-maps`.
>
> I can't find these places where the active keymaps are collected by hand.

Grep for `current_minor_maps`: it should ideally only be called from
Fcurrent_minor_mode_maps and Fcurrent_active_maps.

IIRC it's done in the code to build the menus and the tool bar.


        Stefan






^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-07-09 23:49               ` Juri Linkov
  2020-07-11 14:45                 ` James N. V. Cash
  2020-07-11 15:17                 ` Stefan Monnier
@ 2020-10-13  3:07                 ` Lars Ingebrigtsen
  2021-01-05 18:36                   ` Juri Linkov
  2 siblings, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-13  3:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: James N. V. Cash, 42052, Stefan Monnier

Juri Linkov <juri@linkov.net> writes:

>> I've attached another patch that makes the key bindings & xpm icons get
>> loaded when tab-bar-show is 1 as well. It doesn't un-load the
>> keybindings in the way that globalling toggling tab-bar-mode off, but I
>> don't really see a sensible way of doing that frame-locally.
>
> I don't know if such thing as frame-local keybindings is currently possible.

And then the discussion seemed to be concerned with that point, but
skimming this thread, it doesn't look like the proposed patch was
discussed.

Juri, could you take a look at the patch and see whether it looks
reasonable?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#42052: 28.0.50; tab-bar-mode should be frame-local
  2020-10-13  3:07                 ` Lars Ingebrigtsen
@ 2021-01-05 18:36                   ` Juri Linkov
  0 siblings, 0 replies; 17+ messages in thread
From: Juri Linkov @ 2021-01-05 18:36 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: James N. V. Cash, 42052, Stefan Monnier

tags 42052 fixed
close 42052 28.0.50
thanks

>>> I've attached another patch that makes the key bindings & xpm icons get
>>> loaded when tab-bar-show is 1 as well. It doesn't un-load the
>>> keybindings in the way that globalling toggling tab-bar-mode off, but I
>>> don't really see a sensible way of doing that frame-locally.
>>
>> I don't know if such thing as frame-local keybindings is currently possible.
>
> And then the discussion seemed to be concerned with that point, but
> skimming this thread, it doesn't look like the proposed patch was
> discussed.
>
> Juri, could you take a look at the patch and see whether it looks
> reasonable?

Sorry for the delay.  Now the patch is pushed to master, and report is closed.

Frame-local keybindings could be implemented in a separate feature request.





^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-01-05 18:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 20:07 bug#42052: 28.0.50; tab-bar-mode should be frame-local James N. V. Cash
2020-06-27 23:40 ` Juri Linkov
2020-06-28 12:15   ` James N. V. Cash
2020-06-28 19:45     ` James N. V. Cash
2020-06-28 23:18       ` Juri Linkov
2020-06-29  0:26         ` James N. V. Cash
2020-06-29  0:35           ` James N. V. Cash
2020-06-29 23:45           ` Juri Linkov
2020-07-09 17:06             ` James N. V. Cash
2020-07-09 23:49               ` Juri Linkov
2020-07-11 14:45                 ` James N. V. Cash
2020-07-12  0:01                   ` Juri Linkov
2020-07-11 15:17                 ` Stefan Monnier
2020-07-12  0:04                   ` Juri Linkov
2020-07-12 16:38                     ` Stefan Monnier
2020-10-13  3:07                 ` Lars Ingebrigtsen
2021-01-05 18:36                   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).