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

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

[debbugs-tracker] bug#7730: closed (24.0.50; `image-mode-fit-frame': add


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#7730: closed (24.0.50; `image-mode-fit-frame': add optional FRAME arg)
Date: Sat, 19 Jan 2013 10:38:01 +0000

Your message dated Sat, 19 Jan 2013 18:36:07 +0800
with message-id <address@hidden>
and subject line Re: bug#7730: 24.0.50; `image-mode-fit-frame': add optional 
FRAME arg
has caused the debbugs.gnu.org bug report #7730,
regarding 24.0.50; `image-mode-fit-frame': add optional FRAME arg
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
7730: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7730
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- 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'
 




--- End Message ---
--- Begin Message --- Subject: Re: bug#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg Date: Sat, 19 Jan 2013 18:36:07 +0800 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (gnu/linux)
"Drew Adams" <address@hidden> 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.


--- End Message ---

reply via email to

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