[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to write an emacs lisp function
From: |
Pascal Bourguignon |
Subject: |
Re: Trying to write an emacs lisp function |
Date: |
Mon, 28 Aug 2006 12:38:20 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"Ye Wenbin" <wenbinye@163.com> writes:
> Maybe you function encounter some error, because original-frame always
> have many windows,
> and should use selected-frame-set-input-focus finally.
>
> (defun windows-into-frames ()
> "If the current frame has more than one window,
> make each window display in its own
> seperate frame."
> (interactive)
> (let ((original-frame (selected-frame))
> (original-window (selected-window)))
> (dolist (win (window-list))
> (when (not (eq win original-window))
> (select-window win)
> (make-frame)
> (select-frame original-frame)))
> (select-frame-set-input-focus original-frame)
> (select-window original-window)))
Not exactly what was asked, but I find this funnier:
(defun char-to-pixel-width (w &optional frame)
(* w (frame-char-width (or frame (current-frame)))))
(defun char-to-pixel-height (h &optional frame)
(* h (frame-char-height (or frame (current-frame)))))
(defun frame-top (&optional frame)
(cdr (assoc 'top (frame-parameters (or frame (current-frame))))))
(defun frame-left (&optional frame)
(cdr (assoc 'left (frame-parameters (or frame (current-frame))))))
(defun windows-into-frames ()
"If the current frame has more than one window,
make each window display in its own
seperate frame."
(interactive)
(let ((original-frame (selected-frame))
(original-window (selected-window))
(new-selected-frame nil))
(dolist (win (window-list))
(select-window win)
(let (new-frame)
(destructuring-bind (left top right bottom) (window-edges win)
(setf new-frame
(make-frame `((width . ,(- right left))
(height . ,(- bottom top))
(left . ,(+ (frame-left original-frame)
(char-to-pixel-width left)))
(top . ,(+ (frame-top original-frame)
(char-to-pixel-height top)))))))
(when (eql win original-window)
(setf new-selected-frame new-frame))))
(select-frame-set-input-focus new-selected-frame)
(delete-frame original-frame)))
--
__Pascal Bourguignon__ http://www.informatimago.com/
"Our users will know fear and cower before our software! Ship it!
Ship it and let them flee like the dogs they are!"