diff options
| author | Stefan Monnier | 2008-04-03 02:19:23 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-04-03 02:19:23 +0000 |
| commit | bd1d6a63fcf01daeec366af4628d4de049e0e36b (patch) | |
| tree | a133e7e36fba2ff6d07e98f493e51a07a3479806 | |
| parent | d34c311ab4d865e0bbfd0d9c81719580f8bdacf4 (diff) | |
| download | emacs-bd1d6a63fcf01daeec366af4628d4de049e0e36b.tar.gz emacs-bd1d6a63fcf01daeec366af4628d4de049e0e36b.zip | |
(image-mode-fit-frame): New command.
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/image-mode.el | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2ad26207d6d..4bb89f6bc21 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2008-04-03 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-04-03 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * image-mode.el (image-mode-fit-frame): New command. | ||
| 4 | |||
| 3 | * simple.el (beginning-of-buffer, end-of-buffer, goto-line, undo) | 5 | * simple.el (beginning-of-buffer, end-of-buffer, goto-line, undo) |
| 4 | (copy-region-as-kill, kill-ring-save, use-region-p, mark-word) | 6 | (copy-region-as-kill, kill-ring-save, use-region-p, mark-word) |
| 5 | (keyboard-escape-quit): Check region-active-p i.s.o transient-mark-mode. | 7 | (keyboard-escape-quit): Check region-active-p i.s.o transient-mark-mode. |
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index fc38f045ff9..2fe1cdc88e6 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -244,6 +244,31 @@ stopping if the top or bottom edge of the image is reached." | |||
| 244 | (image-set-window-hscroll (max 0 (- img-width win-width))) | 244 | (image-set-window-hscroll (max 0 (- img-width win-width))) |
| 245 | (image-set-window-vscroll (max 0 (- img-height win-height))))) | 245 | (image-set-window-vscroll (max 0 (- img-height win-height))))) |
| 246 | 246 | ||
| 247 | ;; Adjust frame and image size. | ||
| 248 | |||
| 249 | (defun image-mode-fit-frame () | ||
| 250 | "Fit the frame to the current image. | ||
| 251 | This function assumes the current frame has only one window." | ||
| 252 | ;; FIXME: This does not take into account decorations like mode-line, | ||
| 253 | ;; minibuffer, header-line, ... | ||
| 254 | (interactive) | ||
| 255 | (let* ((saved (frame-parameter nil 'image-mode-saved-size)) | ||
| 256 | (display (image-get-display-property)) | ||
| 257 | (size (image-size display))) | ||
| 258 | (if (and saved | ||
| 259 | (eq (caar saved) (frame-width)) | ||
| 260 | (eq (cdar saved) (frame-height))) | ||
| 261 | (progn ;; Toggle back to previous non-fitted size. | ||
| 262 | (set-frame-parameter nil 'image-mode-saved-size nil) | ||
| 263 | (setq size (cdr saved))) | ||
| 264 | ;; Round up size, and save current size so we can toggle back to it. | ||
| 265 | (setcar size (ceiling (car size))) | ||
| 266 | (setcdr size (ceiling (cdr size))) | ||
| 267 | (set-frame-parameter nil 'image-mode-saved-size | ||
| 268 | (cons size (cons (frame-width) (frame-height))))) | ||
| 269 | (set-frame-width (selected-frame) (car size)) | ||
| 270 | (set-frame-height (selected-frame) (cdr size)))) | ||
| 271 | |||
| 247 | ;;; Image Mode setup | 272 | ;;; Image Mode setup |
| 248 | 273 | ||
| 249 | (defvar image-type nil | 274 | (defvar image-type nil |