all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: Trying to write an emacs lisp function
Date: Mon, 28 Aug 2006 12:38:20 +0200	[thread overview]
Message-ID: <874pvxrvqb.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.5767.1156742845.9609.help-gnu-emacs@gnu.org

"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!"

  parent reply	other threads:[~2006-08-28 10:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-28  3:17 Trying to write an emacs lisp function jkarres
2006-08-28  5:27 ` Ye Wenbin
2006-08-28  5:40 ` B. T. Raven
2006-08-28  9:58 ` Ehud Karni
     [not found] ` <mailman.5767.1156742845.9609.help-gnu-emacs@gnu.org>
2006-08-28 10:38   ` Pascal Bourguignon [this message]
     [not found] ` <mailman.5775.1156759119.9609.help-gnu-emacs@gnu.org>
2006-08-28 16:00   ` jkarres

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874pvxrvqb.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.