From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Trying to write an emacs lisp function Date: Mon, 28 Aug 2006 12:38:20 +0200 Organization: Informatimago Message-ID: <874pvxrvqb.fsf@thalassa.informatimago.com> References: <1156735064.663675.84930@m73g2000cwd.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1156761671 16495 80.91.229.2 (28 Aug 2006 10:41:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2006 10:41:11 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 28 12:41:06 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GHeY3-0003Qs-2P for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Aug 2006 12:40:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHeY2-0004iy-Jf for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Aug 2006 06:40:54 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 67 Original-X-Trace: individual.net Uff2LJaFoTryi5SAAJ0mhA+rghJrFBlePu+tjPmt9Ys+3V8D43 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:46dXtRa0Xl9h2jqR2oooXOQ2yJc= Original-Xref: shelby.stanford.edu gnu.emacs.help:141365 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:36985 Archived-At: "Ye Wenbin" 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!"