all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Trying to write an emacs lisp function
@ 2006-08-28  3:17 jkarres
  2006-08-28  5:27 ` Ye Wenbin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jkarres @ 2006-08-28  3:17 UTC (permalink / raw)


I'm trying to write a function such that when you use it, all the
windows on the current frame will be deleted, and for each deleted
window, a new frame will be created, displaying the same buffer that
the just-deleted window had been displaying.  When it is finished
running, the original frame/window should still be on top (/in
focus/active/however you say it).

This is what I have so far:

(defun windows-into-frames ()
  "If the current frame has more than one window,
make each window display in its own
seperate frame."
  (interactive)
  (setq original-frame (selected-frame))
  (while (not (one-window-p t))
    (other-window 1)
    (make-frame)
    (delete-window)
    (select-frame original-frame)))

Apparently "select-frame" doesn't work quite like I thought.  Can
anybody help me out?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Trying to write an emacs lisp function
  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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ye Wenbin @ 2006-08-28  5:27 UTC (permalink / raw)


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)))

On Mon, 28 Aug 2006 11:17:44 +0800, <jkarres@gmail.com> wrote:

>
> (defun windows-into-frames ()
>   "If the current frame has more than one window,
> make each window display in its own
> seperate frame."
>   (interactive)
>   (setq original-frame (selected-frame))
>   (while (not (one-window-p t))
>     (other-window 1)
>     (make-frame)
>     (delete-window)
>     (select-frame original-frame)))



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Trying to write an emacs lisp function
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: B. T. Raven @ 2006-08-28  5:40 UTC (permalink / raw)



<jkarres@gmail.com> wrote in message
news:1156735064.663675.84930@m73g2000cwd.googlegroups.com...
> I'm trying to write a function such that when you use it, all the
> windows on the current frame will be deleted, and for each deleted
> window, a new frame will be created, displaying the same buffer that
> the just-deleted window had been displaying.  When it is finished
> running, the original frame/window should still be on top (/in
> focus/active/however you say it).
>
> This is what I have so far:
>
> (defun windows-into-frames ()
>   "If the current frame has more than one window,
> make each window display in its own
> seperate frame."  ;;;;;;;;separate
>   (interactive)
>   (setq original-frame (selected-frame))
 ;;; where does the value of 'selected-frame come from???
;;; maybe try (last (frames-on-display-list)) or maybe car??
>   (while (not (one-window-p t))
>     (other-window 1)
>     (make-frame)
>     (delete-window)  ;;; it looks like you want to close the "while"
here; doesn't kill buffer
>     (select-frame original-frame)))
>
> Apparently "select-frame" doesn't work quite like I thought.  Can
> anybody help me out?
>
> Thanks.
>

More important than the above comments is whether your main purpose can
even be achieved by creating frames and deleting windows. The buffers
still exist until they are killed and all of them will be viewable through
the new frames you create. It might be a good idea to try and accomplish
what you want (semi-) manually before you try it programmatically. I don't
know enough to state categorically that you can't do it, but I doubt it. I
tried to look for functions that might help you but I kept running into
dead ends. For example the promising frame-live-p in frames.el couldn't be
traced further. I must be a c language primitive. By evaluating
(frame-live-p) in *scratch* I found that it needs 1 or more arguments. A
number, string, and symbol all returned nil instead of a backtrace.
In version 22 there is a frame-selected-window function that on first
invocation returned

#<window 8 on *scratch*>

and after killing some buffers:

#<window 3 on *scratch*>

>From all of this I suspect that if what you want to do is possible at all,
it probably requires advanced knowledge elisp or maybe even c.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Trying to write an emacs lisp function
  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>
       [not found] ` <mailman.5775.1156759119.9609.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 6+ messages in thread
From: Ehud Karni @ 2006-08-28  9:58 UTC (permalink / raw)
  Cc: help-gnu-emacs

On 27 Aug 2006 20:17:44 -0700, jkarres@gmail.com wrote:
>
> I'm trying to write a function such that when you use it, all the
> windows on the current frame will be deleted, and for each deleted
> window, a new frame will be created, displaying the same buffer that
> the just-deleted window had been displaying.  When it is finished
> running, the original frame/window should still be on top (/in
> focus/active/however you say it).
>
> This is what I have so far:
>
> (defun windows-into-frames ()
>   "If the current frame has more than one window,
> make each window display in its own
> seperate frame."
>   (interactive)
>   (setq original-frame (selected-frame))
>   (while (not (one-window-p t))
>     (other-window 1)
>     (make-frame)
>     (delete-window)
>     (select-frame original-frame)))
>
> Apparently "select-frame" doesn't work quite like I thought.  Can
> anybody help me out?

Look at `raise-frame', I think that is the function your looking for.

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Trying to write an emacs lisp function
       [not found] ` <mailman.5767.1156742845.9609.help-gnu-emacs@gnu.org>
@ 2006-08-28 10:38   ` Pascal Bourguignon
  0 siblings, 0 replies; 6+ messages in thread
From: Pascal Bourguignon @ 2006-08-28 10:38 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Trying to write an emacs lisp function
       [not found] ` <mailman.5775.1156759119.9609.help-gnu-emacs@gnu.org>
@ 2006-08-28 16:00   ` jkarres
  0 siblings, 0 replies; 6+ messages in thread
From: jkarres @ 2006-08-28 16:00 UTC (permalink / raw)



Ehud Karni wrote:
> On 27 Aug 2006 20:17:44 -0700, jkarres@gmail.com wrote:
> >
> > I'm trying to write a function such that when you use it, all the
> > windows on the current frame will be deleted, and for each deleted
> > window, a new frame will be created, displaying the same buffer that
> > the just-deleted window had been displaying.  When it is finished
> > running, the original frame/window should still be on top (/in
> > focus/active/however you say it).
> >
> > This is what I have so far:
> >
> > (defun windows-into-frames ()
> >   "If the current frame has more than one window,
> > make each window display in its own
> > seperate frame."
> >   (interactive)
> >   (setq original-frame (selected-frame))
> >   (while (not (one-window-p t))
> >     (other-window 1)
> >     (make-frame)
> >     (delete-window)
> >     (select-frame original-frame)))
> >
> > Apparently "select-frame" doesn't work quite like I thought.  Can
> > anybody help me out?
>
> Look at `raise-frame', I think that is the function your looking for.
>
> Ehud.
>
>
> --
>  Ehud Karni           Tel: +972-3-7966-561  /"\
>  Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
>  Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
>  http://www.mvs.co.il  FAX:  1-815-5509341  / \
>  GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

Yes, that solved it! Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-08-28 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [not found] ` <mailman.5775.1156759119.9609.help-gnu-emacs@gnu.org>
2006-08-28 16:00   ` jkarres

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.