Re: Learning to program sawfish
- From: Rodrigo Amestica <ramestica nrao edu>
- To: General discussion about sawfish wm <sawfish-list gnome org>
- Subject: Re: Learning to program sawfish
- Date: Thu, 04 Sep 2008 14:04:09 -0400
Hi,
perhaps here I'm risking to skew off the main purpose of the originator of this
topic. But it helps me chime in with a similar 'programming' problem I have.
Hopefully it will help anyhow, not to better understand the language but the way
sawfish works.
I'm trying to move windows with the keyboard in a way that probably makes sense
only to me and, therefore, it is probably not helpful to provide all the
details. Take this as an example, I use focus mode 'enter-only, now consider the
following piece of code:
(setq focus-mode 'click)
(move-window-to w (car tpos1) (cdr tpos1))
(setq focus-mode 'enter-only)
My thinking was like this: if the mouse is at the edge of the window and the
next motion will move the window away from it and it also happens that there is
an other window right below there then my moved window will lose focus. I do not
want that to happen. Then very cleverly, I thought, let's change the focus mode,
move the window and then revert to the original focus mode. Well, this does not
work. It seems that move-window-to has not really completed moving the window
after it has returned.
For a moment I thought that the *-grabbed functions would help me, but they did
not and I do not really understand what exactly they are doing.
Then I thought I should use hooks. Install a hook, move the window, let the hook
detect things and uninstall the hook from the hook itself. But this sounds to
convoluted. Not sure something like this is the right approach.
There is something about the 'mechanics' of sawfish that I cannot grasp and
which I have not being able to find somehow described in the documentation and
older postings.
thanks,
Rodrigo
Timo Korvola wrote:
Rafal Kolanski <rafalk cse unsw edu au> writes:
Unfortunately, I know very little lisp. If I were to look at a lisp
tutorial, which lisp is rep closest to?
These days, I'd say Scheme. Scheme is a good dialect to start with
anyway, being simple and elegant. Rep started out as somewhat similar
to Elisp but has been moving towards Scheme. Elisp is closer to
Common Lisp.
The classic Scheme book is Structure and Interpretation of Computer
Programs by Abelson, Sussman and Sussman, but it is really a book
about programming in general that just uses Scheme for presentation
<URL:http://mitpress.mit.edu/sicp/>. A good reference work is the
Revised^5 Report on the Algorithmic Language Scheme, a comprehensive
description of the entire language in only 50 pages
<URL:http://www.schemers.org/Documents/Standards/R5RS/>. There is
also the more recent R6RS but it is much longer and you probably do
not care about its new features at this point.
As I'm also learning a little bit of emacs hacking ... what are the
main differences between rep and elisp?
Emacs Lisp uses (defun name (args) body) for function definitions,
similar to Common Lisp. Rep also started out with defun but support
for the Scheme syntax (define (name args) body) was added later.
Newer code generally uses define but support for defun has been
retained for compatibility. define can be nested like in Scheme (with
similar restrictions).
In Elisp symbols have separate function and variable bindings, like in
Common Lisp. In Rep and Scheme they do not. You may come across
the terms Lisp-2 and Lisp-1 that refer to this distinction: Elisp is a
Lisp-2 and Rep a Lisp-1.
Elisp uses dynamic scoping exclusively. Rep normally uses lexical
scoping but defvar can be used to declare special variables that are
dynamically scoped. Consider the following:
(setq foo 'outer)
(defun bar () foo)
(let ((foo 'inner)) (bar))
In Elisp the let returns inner whereas in Rep it returns outer. If
you change the setq to defvar, both dialects return inner.
In Elisp and Common Lisp the symbol nil is the empty list and
evaluates to itself. The reader converts () to nil. In Rep the empty
list is a special object denoted by () and nil is just an ordinary
symbol bound to the empty list. Thus (eq nil 'nil) is true in Elisp
and false in Rep, ditto for (eq '() 'nil). (eq '() nil) is true in
both dialects. Note that in Rep the empty list evaluates to itself
but in Scheme it is an error to evaluate it. The symbol nil is
undefined in Scheme.
In Rep, Elisp and Common Lisp the empty list is the only value
considered false in a Boolean context. Anything else is considred
true. Predicates (functions returning Boolean values) generally
return the symbol t for true. Scheme on the other hand has special
Boolean values denoted by #t and #f. Only #f is considered false in
Boolean context: all other values including the empty list are
considered true.
Rep does not follow the Scheme convention of suffixing predicates with
"?" and destructive modifications with "!". Predicates are sometimes
suffixed with "p" and sometimes not, like in Elisp and Common Lisp.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]