From: Eli Zaretskii <eliz@gnu.org>
To: Matthew Leach <matthew@mattleach.net>
Cc: 23259@debbugs.gnu.org
Subject: bug#23259: 25.1.50; Xerror: "BadLength" on extreme zoom causing emacs to segfault
Date: Sun, 10 Apr 2016 19:24:00 +0300 [thread overview]
Message-ID: <83lh4lh1pb.fsf@gnu.org> (raw)
In-Reply-To: <87twj9mqbm.fsf@mattleach.net> (message from Matthew Leach on Sun, 10 Apr 2016 16:33:17 +0100)
> From: Matthew Leach <matthew@mattleach.net>
> Cc: 23259@debbugs.gnu.org
> Date: Sun, 10 Apr 2016 16:33:17 +0100
>
> Maybe limit the zoom before X would crash? Presumably X has an upper
> bound on how large it can render things since it can yield a BadLength
> error. However, I've never studied X before.
I think we can use the display dimensions instead: it makes little
sense to make the font larger than that.
> > . what is the maximum value of the scale factor you see on the mode
> > line before Emacs crashes
>
> I can get to about +34 before it crashes.
>
> > . what is the value returned by display-pixel-width
>
> (display-pixel-width) => 1366
>
> > . what is the values returned by frame-char-width and
> > frame-char-height
>
> (frame-char-width) => 9
> (frame-char-height) => 18
Thanks. Please try the patch below. It should also avoid similar
crashes when you repeatedly press C-- to decrease the font.
--- lisp/face-remap.el~0 2016-01-03 06:46:29.000000000 +0200
+++ lisp/face-remap.el 2016-04-10 16:03:57.601223100 +0300
@@ -256,6 +256,14 @@
text-scale-mode-amount))))
(force-window-update (current-buffer)))
+(defun text-scale-min-amount ()
+ "Return the minimum amount of text-scaling we allow."
+ (log (/ 1.0 (frame-char-height)) text-scale-mode-step))
+
+(defun text-scale-max-amount ()
+ "Return the maximum amount of text-scaling we allow."
+ (log (/ (min (display-pixel-width) #xffff) (frame-char-width)) text-scale-mode-step))
+
;;;###autoload
(defun text-scale-set (level)
"Set the scale factor of the default face in the current buffer to LEVEL.
@@ -266,7 +274,8 @@
`text-scale-mode-step' (a negative number decreases the height by
the same amount)."
(interactive "p")
- (setq text-scale-mode-amount level)
+ (setq text-scale-mode-amount
+ (max (min level (text-scale-max-amount)) (text-scale-min-amount)))
(text-scale-mode (if (zerop text-scale-mode-amount) -1 1)))
;;;###autoload
@@ -279,8 +288,13 @@
height by the same amount). As a special case, an argument of 0
will remove any scaling currently active."
(interactive "p")
- (setq text-scale-mode-amount
- (if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
+ (let* ((current-value (if text-scale-mode text-scale-mode-amount 0))
+ (new-value (if (= inc 0) 0 (+ current-value inc))))
+ (if (or (> new-value (text-scale-max-amount))
+ (< new-value (text-scale-min-amount)))
+ (user-error "Cannot %s the default face height more than it already is"
+ (if (> inc 0) "increase" "decrease")))
+ (setq text-scale-mode-amount new-value))
(text-scale-mode (if (zerop text-scale-mode-amount) -1 1)))
;;;###autoload
next prev parent reply other threads:[~2016-04-10 16:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-10 10:49 bug#23259: 25.1.50; Xerror: "BadLength" on extreme zoom causing emacs to segfault Matthew Leach
2016-04-10 15:01 ` Eli Zaretskii
2016-04-10 15:33 ` Matthew Leach
2016-04-10 16:24 ` Eli Zaretskii [this message]
2016-04-10 16:36 ` Matthew Leach
2016-04-10 16:52 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83lh4lh1pb.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=23259@debbugs.gnu.org \
--cc=matthew@mattleach.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.