bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16028: 24.3.50; Latest build completely breaks my thumnail frames co


From: Drew Adams
Subject: bug#16028: 24.3.50; Latest build completely breaks my thumnail frames code
Date: Fri, 13 Dec 2013 10:05:12 -0800 (PST)

>  > What solution was that?  Can you state it again, in the context of
>  > the thumb-frm.el code?  I believe I've tried everything I saw suggested
>  > here, but I'm open to a fix for my code, of course.  I've been asking
>  > for it.  The last suggestion I recall was to change the order, and I
>  > reported the problems that caused.
> 
> To thumbify
> (1) Save the current frame pixel size, font and scrollbar width.
> (2) Set the new font size.
> (3) Set the new scrollbar width.
> (4) Set the new pixel size to some calculated from the one saved in
>     (1) and the scale factor used in (2).
> 
> To dethumbify
> (5) Set the new font size to the one saved in (1).
> (6) Set the new scrollbar width to the one saved in (1).
> (7) Set the new frame pixel size to the one saved in (1).

a. I don't know how to get the frame pixel size.  Do you mean only
`frame-pixel-width'?

b. I need to allow users to specify settings for thumbified frames
(option `thumfr-frame-parameters').

c. I need to be able to record the current frame parameters and use
them to restore - for both thumbified and non-thumbified frames.
I store this info in frame parameters `thumfr-thumbnail-frame' and
`thumfr-non-thumbnail-frame'.

Perhaps you can make a concrete suggestion, since you seem to understand
what you have in mind by (1)-(7).  I do not.

But when I asked for concrete suggestions for "trying to get my code to
work properly with your new code" you replied "I'm afraid there's not
much you can do here."

The code for `thumfr-thumbify-frame' and `thumfr-dethumbify-frame' is
only 50 lines long, and (i) some of that is for stacking offsets, which
is irrelevant here, and (ii) some of it is `font-too-small' error handling,
to retry with a slightly larger font.

Here is the essential code (30 lines):

(defun thumfr-thumbify-frame (&optional frame)
  (interactive)
  (setq frame  (or frame (selected-frame)))
  (let* ((tf-params      (frame-parameter frame 'thumfr-non-thumbnail-frame))
         (non-tf-params  (cl-remove-if #'thumfr-thumfr-parameter-p
                                       (frame-parameters frame))))
    (unless (frame-parameter frame 'thumfr-thumbnail-frame)
      (set-frame-parameter frame 'thumfr-thumbnail-frame non-tf-params)
      (set-frame-parameter frame 'thumfr-non-thumbnail-frame nil)
      (condition-case thumfr-thumbify-frame
          (progn (enlarge-font (- thumfr-font-difference) frame)
                 (when tf-params (modify-frame-parameters frame tf-params))
                 (modify-frame-parameters frame thumfr-frame-parameters))
        (error (set-frame-parameter frame 'thumfr-non-thumbnail-frame tf-params)
               (set-frame-parameter frame 'thumfr-thumbnail-frame nil)
               (error (error-message-string thumfr-thumbify-frame)))))))

(defun thumfr-dethumbify-frame (&optional frame)
  (interactive)
  (setq frame  (or frame (selected-frame)))
  (let* ((non-tf-params  (frame-parameter frame 'thumfr-thumbnail-frame))
         (tf-params      (cl-remove-if #'thumfr-thumfr-parameter-p
                                       (frame-parameters frame))))
    (when non-tf-params
      (set-frame-parameter frame 'thumfr-non-thumbnail-frame tf-params)
      (set-frame-parameter frame 'thumfr-thumbnail-frame nil)
      (condition-case thumfr-dethumbify-frame
          (progn (enlarge-font thumfr-font-difference frame)
                 (modify-frame-parameters frame non-tf-params))
        (error (set-frame-parameter frame 'thumfr-thumbnail-frame non-tf-params)
               (set-frame-parameter frame 'thumfr-non-thumbnail-frame nil)
               (error (error-message-string thumfr-dethumbify-frame)))))))

Helper code:

(defun thumfr-thumfr-parameter-p (parameter+value)
  (memq (car parameter+value)
        '(thumfr-thumbnail-frame thumfr-non-thumbnail-frame)))

(defcustom thumfr-frame-parameters
  '((menu-bar-lines . 0) (tool-bar-lines . 0) (scroll-bar-width . 6))
  :type '(repeat (cons symbol sexp)) :group 'Thumbnail-Frames
  :set (lambda (sym defs)
         (custom-set-default sym defs)
         (dolist (frm  (frame-list))
           (when (and (frame-live-p frm)
                      (frame-parameter frm 'thumfr-thumbnail-frame))
             (modify-frame-parameters frm thumfr-frame-parameters)))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]