GNU bug report logs - #7730
24.0.50; `image-mode-fit-frame': add optional FRAME arg

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Fri, 24 Dec 2010 23:40:02 UTC

Severity: wishlist

Found in version 24.0.50

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: "Drew Adams" <drew.adams <at> oracle.com>
Subject: bug#7730: closed (Re: bug#7730: 24.0.50; `image-mode-fit-frame':
 add optional FRAME arg)
Date: Sat, 19 Jan 2013 10:38:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 7730 <at> debbugs.gnu.org.

-- 
7730: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7730
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Chong Yidong <cyd <at> gnu.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 7730-done <at> debbugs.gnu.org
Subject: Re: bug#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg
Date: Sat, 19 Jan 2013 18:36:07 +0800
"Drew Adams" <drew.adams <at> oracle.com> writes:

> Here's a possible enhancement to `image-mode-fit-frame'.
>  
> 1. Added an optional FRAME arg.
>  
> 2. The command only toggles if called interactively (actually, if the
> first arg is non-nil).

Thanks.  I've committed something similar.

[Message part 3 (message/rfc822, inline)]
From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.0.50; `image-mode-fit-frame': add optional FRAME arg
Date: Fri, 24 Dec 2010 15:45:05 -0800
Here's a possible enhancement to `image-mode-fit-frame'.
These are the differences:
 
1. Added an optional FRAME arg.
 
2. The command only toggles if called interactively (actually, if the
first arg is non-nil).
 
#1 means you can use it for another frame.  #2 means that only
 interactive calls save the previous frame size and alternate between
 fitting and restoring the old size.
 
Also, at the end of the function I changed the separate calls to
`set-frame-width' and `set-frame-height' to a single call to
`set-frame-size'.  I did that because I was seeing that the frame was
not getting resized to fit in some cases.  Dunno if there is a bug
associated with that.

FWIW, in my own use of this, my general command `fit-frame' calls it
for Emacs 23+ if the FRAME is in `image-mode' or `image-minor-mode':

(if (and (fboundp 'image-mode-fit-frame) ; Emacs 23+
         (if (or (null frame) (eq frame (selected-frame)))
             (or (eq major-mode 'image-mode) image-minor-mode)
           (save-window-excursion
             (select-frame frame)
             (or (eq major-mode 'image-mode) image-minor-mode))))
      (fit-frame-to-image (interactive-p) frame)
  ...)

(I also use a different name for the command.)
 
(defun fit-frame-to-image (interactivep &optional frame)
  "Fit FRAME to the current image.
If FRAME is not the selected frame, fit it to its first image.
Interactively, if frame has already been fit to the image, then
 restore the size from before it was fit.
This function assumes that FRAME has only one window."
  ;; FIXME: This does not take into account decorations
  ;; like mode-line, minibuffer, header-line, ...
  (interactive "p")
  (let* ((saved    (frame-parameter frame 'image-mode-saved-size))
         (display  (if (or (null frame) (equal frame (selected-frame)))
                       (image-get-display-property)
                     (save-selected-window (select-frame frame)
                                           (image-get-display-property))))
         (size     (image-display-size display nil frame)))
    (setq frame  (or frame (selected-frame)))
    (if (and interactivep saved
             (eq (caar saved) (frame-width frame))
             (eq (cdar saved) (frame-height frame)))
        (progn ; Restore previous size, before it was fit.
          (set-frame-parameter frame 'image-mode-saved-size nil)
          (setq size (cdr saved)))
      ;; Round up size, and save current size so we can toggle back to it.
      (setcar size (ceiling (car size)))
      (setcdr size (ceiling (cdr size)))
      (set-frame-parameter
       frame 'image-mode-saved-size
       (cons size (cons (frame-width frame) (frame-height frame)))))
    (set-frame-size frame (car size) (cdr size))))
 

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-12-20 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags
-Ic:/imagesupport/include'
 




This bug report was last modified 12 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.