From: Michael Sperber <sperber@deinprogramm.de>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: "'Berndl, Klaus'" <klaus.berndl@capgemini-sdm.com>,
'Lennart Borgman' <lennart.borgman@gmail.com>,
mike@xemacs.org, emacs-devel@gnu.org,
'Juri Linkov' <juri@jurta.org>,
"'Stephen J. Turnbull'" <stephen@xemacs.org>
Subject: Re: read syntax for window configs
Date: Thu, 18 Mar 2010 17:07:00 +0100 [thread overview]
Message-ID: <y9l4okdvckb.fsf@deinprogramm.de> (raw)
In-Reply-To: <86716EEF25B64190B631AD85710E965D@us.oracle.com> (Drew Adams's message of "Fri, 5 Mar 2010 09:07:38 -0800")
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
"Drew Adams" <drew.adams@oracle.com> writes:
>> > > Since XEmacs have lots of other object types, maybe
>> > > XEmacs already has a read syntax for window configurations
>>
>> Window configurations in XEmacs don't have read syntax, but they're
>> pretty close, and thus it wouldn't be hard to do.
>
> Read syntax for window (and frame) configs would be very welcome.
I've attached code that works for XEmacs. Is this along the line of
what you'd like?
--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
[-- Attachment #2: Type: text/plain, Size: 5118 bytes --]
(defun window-configuration->sexp (config)
"Convert a window configuration to a readable S-expression."
`(window-configuration
(frame . ,(position (window-configuration-frame config) (frame-list))) ; lame, but the best we can do
(frame-top . ,(window-configuration-frame-top config))
(frame-left . ,(window-configuration-frame-left config))
(frame-pixel-width . ,(window-configuration-frame-pixel-width config))
(frame-pixel-height . ,(window-configuration-frame-pixel-height config))
(current-buffer . ,(buffer-name (window-configuration-current-buffer config)))
(minibuffer-pixel-height . ,(window-configuration-minibuffer-pixel-height config))
(min-width . ,(window-configuration-min-width config))
(min-height . ,(window-configuration-min-height config))
(saved-root-window . ,(saved-window->sexp (window-configuration-saved-root-window config)))))
(defun saved-window->sexp (saved)
"Convert a saved-window structure to a readable S-expression."
`(saved-window
(currentp . ,(saved-window-currentp saved))
(minibufferp . ,(saved-window-minibuffer-scrollp saved))
(minibuffer-scrollp . ,(saved-window-minibuffer-scrollp saved))
(buffer . ,(buffer-name (saved-window-buffer saved)))
(mark-marker . ,(maybe-marker-position (saved-window-mark-marker saved)))
(start-marker . ,(maybe-marker-position (saved-window-start-marker saved)))
(point-marker . ,(maybe-marker-position (saved-window-point-marker saved)))
(pixel-left . ,(saved-window-pixel-left saved))
(pixel-top . ,(saved-window-pixel-top saved))
(pixel-right . ,(saved-window-pixel-right saved))
(pixel-bottom . ,(saved-window-pixel-bottom saved))
(hscroll . ,(saved-window-hscroll saved))
(modeline-hscroll . ,(saved-window-modeline-hscroll saved))
(dedicatedp . ,(saved-window-dedicatedp saved))
(first-hchild . ,(maybe-saved-window->sexp (saved-window-first-hchild saved)))
(first-vchild . ,(maybe-saved-window->sexp (saved-window-first-vchild saved)))
(next-child . ,(maybe-saved-window->sexp (saved-window-next-child saved)))))
(defun maybe-saved-window->sexp (saved)
"Like `saved-window->sexp', but also accepts nil."
(and saved (saved-window->sexp saved)))
(defun maybe-marker-position (marker)
"Extract position from marker, or return nil for nil marker."
(and marker (marker-position marker)))
(defun sexp->window-configuration (sexp)
"Convert return value of `window-configuration->sexp' back into window config."
(make-window-configuration
:frame (let ((pos (sexp-tag->value sexp 'frame))
(frames (frame-list)))
(if (< pos (length frames))
(nth pos frames)
(car frames)))
:frame-top (sexp-tag->value sexp 'frame-top)
:frame-left (sexp-tag->value sexp 'frame-left)
:frame-pixel-width (sexp-tag->value sexp 'frame-pixel-width)
:frame-pixel-height (sexp-tag->value sexp 'frame-pixel-height)
:current-buffer (get-buffer-create (sexp-tag->value sexp 'current-buffer))
:min-width (sexp-tag->value sexp 'min-width)
:min-height (sexp-tag->value sexp 'min-height)
:minibuffer-pixel-height (sexp-tag->value sexp 'minibuffer-pixel-height)
:saved-root-window (sexp->saved-window (sexp-tag->value sexp 'saved-root-window))))
(defun sexp->saved-window (sexp)
"Convert return value of `saved-window->sexp' back into saved window."
(let ((buf (get-buffer-create (sexp-tag->value sexp 'buffer))))
(make-saved-window
:window nil ; sorry
:currentp (sexp-tag->value sexp 'currentp)
:minibufferp (sexp-tag->value sexp 'minibufferp)
:minibuffer-scrollp (sexp-tag->value sexp 'minibuffer-scrollp)
:buffer buf
:mark-marker (maybe-marker-position->marker buf (sexp-tag->value sexp 'mark-marker))
:start-marker (maybe-marker-position->marker buf (sexp-tag->value sexp 'start-marker))
:point-marker (maybe-marker-position->marker buf (sexp-tag->value sexp 'point-marker))
:pixel-left (sexp-tag->value sexp 'pixel-left)
:pixel-top (sexp-tag->value sexp 'pixel-top)
:pixel-right (sexp-tag->value sexp 'pixel-right)
:pixel-bottom (sexp-tag->value sexp 'pixel-bottom)
:hscroll (sexp-tag->value sexp 'hscroll)
:modeline-hscroll (sexp-tag->value sexp 'modeline-hscroll)
:dedicatedp (sexp-tag->value sexp 'dedicatedp)
:first-hchild (maybe-sexp->saved-window (sexp-tag->value sexp 'first-hchild))
:first-vchild (maybe-sexp->saved-window (sexp-tag->value sexp 'first-vchild))
:next-child (maybe-sexp->saved-window (sexp-tag->value sexp 'next-child)))))
(defun maybe-sexp->saved-window (sexp)
"Like `sexp->saved-window', but accepts nil."
(and sexp (sexp->saved-window sexp)))
(defun sexp-tag->value (sexp tag)
"Extract value for tag in S-expression sexp.
This works for the values returned by `window-configuration->sexp' and
`saved-window->sexp'. Returns nil if the tag is not there."
(cdr (assq tag (cdr sexp))))
(defun maybe-marker-position->marker (buffer pos)
"Turn nil or a marker position into a marker."
(let ((marker (make-marker)))
(set-marker marker pos buffer)
marker))
next prev parent reply other threads:[~2010-03-18 16:07 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-01 18:53 Fwd: CEDET sync Lluís
2010-03-01 18:59 ` Chong Yidong
2010-03-01 19:36 ` Lennart Borgman
2010-03-01 21:27 ` Stefan Monnier
2010-03-01 22:07 ` Fabian Ezequiel Gallina
2010-03-01 22:42 ` Eric M. Ludlam
2010-03-02 7:58 ` AW: " Berndl, Klaus
2010-03-02 8:51 ` Stephen J. Turnbull
2010-03-02 9:35 ` David Kastrup
2010-03-02 9:43 ` Lennart Borgman
2010-03-02 10:36 ` AW: " Berndl, Klaus
2010-03-02 10:43 ` Lennart Borgman
2010-03-02 11:08 ` AW: " Berndl, Klaus
2010-03-02 21:03 ` Juri Linkov
2010-03-03 3:20 ` Stephen J. Turnbull
2010-03-05 13:45 ` Michael Sperber
2010-03-05 17:07 ` read syntax for window configs (was: CEDET sync) Drew Adams
2010-03-05 17:48 ` Lennart Borgman
2010-03-06 17:44 ` read syntax for window configs Juri Linkov
2010-03-06 17:48 ` Juri Linkov
2010-03-06 19:32 ` Drew Adams
2010-03-18 16:07 ` Michael Sperber [this message]
2010-03-18 16:41 ` Drew Adams
2010-03-19 10:48 ` martin rudalics
2010-03-19 11:09 ` Michael Sperber
2010-03-19 13:07 ` martin rudalics
2010-03-19 15:31 ` Michael Sperber
2010-03-02 11:13 ` AW: Fwd: CEDET sync Richard Riley
2010-03-02 11:42 ` David Kastrup
2010-03-02 15:23 ` Stephen J. Turnbull
2010-03-02 16:06 ` David Kastrup
2010-03-02 17:20 ` Stephen J. Turnbull
2010-03-02 17:58 ` David Kastrup
2010-03-03 3:51 ` Stephen J. Turnbull
2010-03-02 18:40 ` OT: threats to Free Software (was: AW: Fwd: CEDET sync) Stefan Monnier
2010-03-02 19:33 ` Lennart Borgman
2010-03-02 22:07 ` David Reitter
2010-03-03 22:48 ` Richard Stallman
2010-03-03 4:00 ` Stephen J. Turnbull
2010-03-03 22:48 ` Richard Stallman
2010-03-03 10:37 ` Richard Stallman
2010-03-03 10:37 ` AW: Fwd: CEDET sync Richard Stallman
2010-03-03 18:37 ` Stephen J. Turnbull
2010-03-03 19:00 ` Chong Yidong
2010-03-05 20:05 ` Richard Stallman
2010-03-06 4:29 ` Stephen J. Turnbull
2010-03-06 7:45 ` David Kastrup
2010-03-03 7:07 ` joakim
2010-03-02 15:25 ` Stefan Monnier
2010-03-02 15:59 ` AW: " Berndl, Klaus
2010-03-02 16:08 ` Chong Yidong
2010-03-02 16:44 ` Stephen J. Turnbull
2010-03-02 20:28 ` Chong Yidong
2010-03-03 4:06 ` Stephen J. Turnbull
2010-03-03 4:47 ` Miles Bader
2010-03-03 7:21 ` Stephen J. Turnbull
2010-03-03 15:45 ` Chong Yidong
2010-03-03 7:41 ` David Kastrup
2010-03-03 8:51 ` Stephen J. Turnbull
2010-03-03 9:10 ` tomas
2010-03-03 10:02 ` David Kastrup
2010-03-03 16:51 ` Stephen J. Turnbull
2010-03-02 18:45 ` Stefan Monnier
2010-03-03 10:38 ` Richard Stallman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=y9l4okdvckb.fsf@deinprogramm.de \
--to=sperber@deinprogramm.de \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=juri@jurta.org \
--cc=klaus.berndl@capgemini-sdm.com \
--cc=lennart.borgman@gmail.com \
--cc=mike@xemacs.org \
--cc=stephen@xemacs.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).