From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: thomas.hisch@ims.co.at, 41852@debbugs.gnu.org
Subject: bug#41852: 27.0.50; text-scale commands don't scale header of tabulated-list-mode
Date: Thu, 12 Nov 2020 17:25:17 -0500 [thread overview]
Message-ID: <CADwFkm=TY_H419-jeiXRxZPbVXv5uqSELAWg9S+6bK1kj3GZOw@mail.gmail.com> (raw)
In-Reply-To: <837dr6gu05.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1938 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> > (progn
>> > (setq-local text-scale-remap-header-line-face t)
>> > (setq-local header-line-format (concat
>> > (propertize "foo" 'face 'fixed-pitch) " "
>> > (propertize "bar" 'face 'variable-pitch))))
>> >
>> > They also scale.
>>
>> They don't scale obn my system, which is what I'd expect. Maybe these
>> faces don't specify the font on some systems, but the principle is
>> nevertheless valid.
>
> No, that's because your patch is not yet in, so setting
> text-scale-remap-header-line-face has no effect. Sorry, I didn't
> realize you haven't yet committed those changes.
>
> In any case, the general point is valid: it is incorrect to assume
> that every face used anywhere will scale with the buffer text.
What do you think of the attached patch? It is along the lines of
what I suggested in a separate email, where I wrote:
> So looking at this, I'm not sure we should even say: "This will also
> affect any face that inherits from it." It risks confusing more than
> helping, IMHO.
>
> Nor am I so sure we should talk about the 'header-line' face.
>
> I think we should say something closer to what Martin suggested, say:
>
> *** text-scale-mode can now scale the header line.
> When the new buffer local variable 'text-scale-remap-header-line-face'
> is non-nil, 'text-scale-adjust' will also scale the text in the header
> line when displaying that buffer.
>
> This is useful for major modes that arrange their display in a tabular
> form below the header-line. It is therefore enabled by default in
> 'tabulated-list-mode' and its derived modes.
>
> Note that text scaling never affects text using a face where the
> :height attribute is set to an absolute value.
>
> And then adjust the docstring accordingly.
Do you think this is horribly wrong, or does it make sense?
Thanks in advance.
[-- Attachment #2: 0001-Make-text-scale-mode-optionally-adjust-the-header-li.patch --]
[-- Type: text/x-diff, Size: 5130 bytes --]
From ec6286f10b1357e719fca90ffa87d254193fb60f Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Thu, 12 Nov 2020 23:12:06 +0100
Subject: [PATCH] Make text-scale-mode optionally adjust the header line
* lisp/face-remap.el
(text-scale-remap-header-line-face): New buffer local variable.
(text-scale-mode): Adjust header line if above variable is non-nil.
(face-remap--clear-remappings, face-remap--remap-face): New defuns.
* lisp/face-remap.el: Arrange to watch text-scale-mode-remapping.
(text-scale--refresh): New function.
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-mode): Use
text-scale-remap-header-line.
---
etc/NEWS | 12 ++++++++
lisp/emacs-lisp/tabulated-list.el | 1 +
lisp/face-remap.el | 51 +++++++++++++++++++++++++------
3 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index f21c4cb02c..a21d8f9dce 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1459,6 +1459,18 @@ mouse now pops up a TTY menu by default instead of running the command
'tmm-menubar'. To restore the old behavior, set the user option
'tty-menu-open-use-tmm' to non-nil.
+** text-scale-mode
+
+---
+*** text-scale-mode can now adjust font size of the header line.
+When the new buffer local variable 'text-scale-remap-header-line'
+is non-nil, 'text-scale-adjust' will also scale the text in the header
+line when displaying that buffer.
+
+This is useful for major modes that arrange their display in a tabular
+form below the header line. It is enabled by default in
+'tabulated-list-mode' and its derived modes.
+
** xwidget-webkit mode
*** New xwidget commands.
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 30577679f2..ae3ed055c5 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -767,6 +767,7 @@ tabulated-list-mode
(setq-local revert-buffer-function #'tabulated-list-revert)
(setq-local glyphless-char-display
(tabulated-list-make-glyphless-char-display-table))
+ (setq-local text-scale-remap-header-line t)
;; Avoid messing up the entries' display just because the first
;; column of the first entry happens to begin with a R2L letter.
(setq bidi-paragraph-direction 'left-to-right)
diff --git a/lisp/face-remap.el b/lisp/face-remap.el
index 028269a4b0..20c7607408 100644
--- a/lisp/face-remap.el
+++ b/lisp/face-remap.el
@@ -229,6 +229,39 @@ text-scale-mode-lighter
(defvar text-scale-mode-amount 0)
(make-variable-buffer-local 'text-scale-mode-amount)
+(defvar text-scale-remap-header-line nil
+ "If non-nil, also change font size of the header line.")
+(make-variable-buffer-local 'text-scale-header-line)
+
+(defun text-scale--refresh (symbol newval operation where)
+ "Watcher for `text-scale-remap-header-line'.
+See `add-variable-watcher'."
+ (when (and (eq symbol 'text-scale-remap-header-line)
+ (eq operation 'set)
+ text-scale-mode)
+ (with-current-buffer where
+ (let ((text-scale-remap-header-line newval))
+ (text-scale-mode 1)))))
+(add-variable-watcher 'text-scale-remap-header-line #'text-scale--refresh)
+
+(defun face-remap--clear-remappings ()
+ (dolist (remapping
+ ;; This is a bit messy to stay backwards compatible.
+ ;; In the future, this can be simplified to just use
+ ;; `text-scale-mode-remapping'.
+ (if (consp (car-safe text-scale-mode-remapping))
+ text-scale-mode-remapping
+ (list text-scale-mode-remapping)))
+ (face-remap-remove-relative remapping))
+ (setq text-scale-mode-remapping nil))
+
+(defun face-remap--remap-face (sym)
+ (push (face-remap-add-relative sym
+ :height
+ (expt text-scale-mode-step
+ text-scale-mode-amount))
+ text-scale-mode-remapping))
+
(define-minor-mode text-scale-mode
"Minor mode for displaying buffer text in a larger/smaller font.
@@ -240,19 +273,19 @@ text-scale-mode
The `text-scale-increase', `text-scale-decrease', and
`text-scale-set' functions may be used to interactively modify
the variable `text-scale-mode-amount' (they also enable or
-disable `text-scale-mode' as necessary)."
+disable `text-scale-mode' as necessary).
+
+If `text-scale-remap-header-line' is non-nil, also change
+the font size of the header line."
:lighter (" " text-scale-mode-lighter)
- (when text-scale-mode-remapping
- (face-remap-remove-relative text-scale-mode-remapping))
+ (face-remap--clear-remappings)
(setq text-scale-mode-lighter
(format (if (>= text-scale-mode-amount 0) "+%d" "%d")
text-scale-mode-amount))
- (setq text-scale-mode-remapping
- (and text-scale-mode
- (face-remap-add-relative 'default
- :height
- (expt text-scale-mode-step
- text-scale-mode-amount))))
+ (when text-scale-mode
+ (face-remap--remap-face 'default)
+ (when text-scale-remap-header-line
+ (face-remap--remap-face 'header-line)))
(force-window-update (current-buffer)))
(defun text-scale-min-amount ()
--
2.28.0
next prev parent reply other threads:[~2020-11-12 22:25 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 13:36 bug#41852: 27.0.50; text-scale commands don't scale header of tabulated-list-mode Thomas Hisch
2020-06-14 14:42 ` Eli Zaretskii
2020-06-14 16:25 ` Thomas Hisch
2020-10-18 23:34 ` Stefan Kangas
2020-10-19 14:19 ` Eli Zaretskii
2020-10-19 18:21 ` Stefan Kangas
2020-10-19 19:02 ` Eli Zaretskii
2020-10-19 22:41 ` Stefan Kangas
2020-10-20 14:15 ` Eli Zaretskii
2020-10-20 14:40 ` Stefan Kangas
2020-10-20 14:45 ` Eli Zaretskii
2020-10-20 19:10 ` Thomas Hisch
2020-10-29 17:43 ` Stefan Kangas
2020-10-29 19:37 ` Thomas Hisch
2020-10-29 21:45 ` Stefan Kangas
2020-10-30 8:01 ` Eli Zaretskii
2020-10-29 17:33 ` Stefan Kangas
2020-10-29 18:02 ` Drew Adams
2020-10-29 18:15 ` Stefan Kangas
2020-10-29 18:32 ` Drew Adams
2020-10-29 18:47 ` Stefan Kangas
2020-10-30 8:54 ` martin rudalics
2020-10-30 16:04 ` Stefan Kangas
2020-10-30 17:37 ` martin rudalics
2020-10-30 19:01 ` Eli Zaretskii
2020-10-31 0:31 ` Stefan Kangas
2020-10-31 8:00 ` martin rudalics
2020-10-30 18:54 ` Eli Zaretskii
2020-10-30 20:22 ` Stefan Kangas
2020-10-30 20:53 ` Eli Zaretskii
2020-10-31 16:15 ` Stefan Kangas
2020-10-31 16:48 ` Eli Zaretskii
2020-10-31 16:57 ` Eli Zaretskii
2020-10-31 17:55 ` Eli Zaretskii
2020-11-12 22:25 ` Stefan Kangas [this message]
2020-11-13 7:51 ` Eli Zaretskii
2020-11-25 2:08 ` Stefan Kangas
2020-11-13 8:49 ` martin rudalics
2020-11-25 2:08 ` Stefan Kangas
2020-11-13 13:00 ` Jean Louis
2020-11-13 14:32 ` Stefan Kangas
2020-11-13 15:33 ` Jean Louis
2020-11-13 16:07 ` github.com
2020-11-13 16:49 ` Stefan Kangas
2020-10-31 16:50 ` Stefan Kangas
2020-10-31 8:29 ` Eli Zaretskii
2020-10-31 16:25 ` Stefan Kangas
[not found] <<955fe4fe-a64d-b7c6-fe31-7efd810f97a5@ims.co.at>
[not found] ` <<83mu553e0x.fsf@gnu.org>
2020-06-14 16:28 ` Drew Adams
2020-06-14 17:23 ` Thomas Hisch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADwFkm=TY_H419-jeiXRxZPbVXv5uqSELAWg9S+6bK1kj3GZOw@mail.gmail.com' \
--to=stefan@marxist.se \
--cc=41852@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=thomas.hisch@ims.co.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).