unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* EWMH package, please review.
@ 2003-10-12 16:53 Jan D.
  2003-10-12 22:17 ` Kim F. Storm
  0 siblings, 1 reply; 12+ messages in thread
From: Jan D. @ 2003-10-12 16:53 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Hello.

I've made a small package to manipulate extended window manager hints.  Since 
Elisp is not my biggest strength, I'd like some comments.  I don't know if this 
is useful enough to be included in Emacs, so I'd like your views on that also.

Thanks,

	Jan D.

[-- Attachment #2: x-ewmh.el --]
[-- Type: text/plain, Size: 5850 bytes --]

;;; x-ewmh.el --- support extended window manager hints under X. -*-coding: iso-2022-7bit;-*-

;; Copyright (C) 2003 Free Software Foundation

;; Author: Jan Dj^[,Ad^[(Brv <jan.d.h@swipnet.se>
;; Keywords: window manager, hints

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Manipulate extended window manager hints (EWMH) under X.
;; The EWMH specification can be found at http://www.freedesktop.org/.

;; Extended window manager hints lets you manipulate the state
;; of Emacs frames, like fullscreen, shaded, maximized vertical
;; and/or horizontal.  If the window manager supports multiple desktops,
;; EWMH can set if a window is sticky (present in all desktops) or not.

;; NOTE:  EWMH only works on window managers that support EWMH.  If
;; there is no support, this package does nothing.  Also, not all
;; window managers implement all hints, and not with the same effect.

;;; Todo:

;; Retreive current EWMH state?.


;;; Code:

(defun x-ewmh-send (arg hint frame &optional hint2)
  "Send a client message to change an extended window manager hint.

FRAME may be nil to use the selected frame.
If ARG is poitive, add HINT.
If ARG is negative, remove HINT.
Otherwise toggle HINT."

  (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg)))
	 (action (cond ((= eff-arg 0) 2)	;; Toggle
		       ((> eff-arg 0) 1)	;; Add
		       (t 0))))			;; Remove
    (x-send-client-message nil 0 frame "_NET_WM_STATE" 32
			   (list action
				 hint 
				 (if hint2 hint2 0)
				 0))))


(defun x-ewmh-fullscreen (&optional arg frame)
  "Toggle FRAME fullscreen hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is poitive, add fullscreen hint.
If ARG is negative, remove fullscreen hint.
Otherwise toggle fullscreen hint.

If fullscreen doesn't work with your window manager, try
`x-ewmh-horz-and-vert'.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_FULLSCREEN" frame))


(defun x-ewmh-shaded (&optional arg frame)
  "Toggle FRAME shaded hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add shaded hint.
If ARG is negative, remove shaded hint.
Otherwise toggle shaded hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_SHADED" frame))


(defun x-ewmh-sticky (&optional arg frame)
  "Toggle FRAME sticky hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add sticky hint.
If ARG is negative, remove sticky hint.
Otherwise toggle sticky hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_STICKY" frame))


(defun x-ewmh-maximized_vert (&optional arg frame)
  "Toggle FRAME maximized_vert hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add maximized_vert hint.
If ARG is negative, remove maximized_vert hint.
Otherwise toggle maximized_vert hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_VERT" frame))


(defun x-ewmh-maximized_horz (&optional arg frame)
  "Toggle FRAME maximized_horz hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add maximized_horz hint.
If ARG is negative, remove maximized_horz hint.
Otherwise toggle maximized_horz hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_HORZ" frame))


(defun x-ewmh-horz-and-vert (&optional arg frame)
  "Toggle FRAME maximized_horz/vert hints at the same time.

If FRAME is not given, the selected frame is used.
If ARG is positive, add both hints.
If ARG is negative, remove both hints.
Otherwise toggle both hints.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_HORZ" frame
	       "_NET_WM_STATE_MAXIMIZED_VERT"))


(defun x-ewmh-above (&optional arg frame)
  "Toggle FRAME above hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add above hint.
If ARG is negative, remove above hint.
Otherwise toggle above hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_ABOVE" frame))


(defun x-ewmh-below (&optional arg frame)
  "Toggle FRAME below hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add below hint.
If ARG is negative, remove below hint.
Otherwise toggle below hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_BELOW" frame))


(provide 'x-ewmh)

;;; arch-tag: ???
;;; x-ewmh.el ends here

[-- Attachment #3: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

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

* Re: EWMH package, please review.
  2003-10-12 16:53 EWMH package, please review Jan D.
@ 2003-10-12 22:17 ` Kim F. Storm
  2003-10-12 22:54   ` Miles Bader
                     ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Kim F. Storm @ 2003-10-12 22:17 UTC (permalink / raw)
  Cc: emacs-devel

"Jan D." <jan.h.d@swipnet.se> writes:

> Hello.
> 
> I've made a small package to manipulate extended window manager hints.
> Since Elisp is not my biggest strength, I'd like some comments.  

Ok, you asked for it :-)

>                                                                  I
> don't know if this is useful enough to be included in Emacs, so I'd
> like your views on that also.

I don't know.  Are (all of) those hints something an ordinary user
would typically toggle interactively?


> ;;; Code:
> 
> (defun x-ewmh-send (arg hint frame &optional hint2)
>   "Send a client message to change an extended window manager hint.
> 
> FRAME may be nil to use the selected frame.
> If ARG is poitive, add HINT.
> If ARG is negative, remove HINT.
> Otherwise toggle HINT."
> 
>   (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg)))

This is simpler:

  (setq arg (if (null arg) 0 (prefix-numeric-value arg)))
  (let ((action ...use ARG instead of EFF-ARG...))

IMO, it is somewhat unusual to let a generic, non-interactive function
assume that it is always invoked by an interactive function.  I would
normally let the callers do that (possibly using an auxiliary
function), but in your case I would just change the DOC string to say
that ARG is supposed to be a raw prefix argument.


> 	 (action (cond ((= eff-arg 0) 2)	;; Toggle
> 		       ((> eff-arg 0) 1)	;; Add
> 		       (t 0))))			;; Remove
>     (x-send-client-message nil 0 frame "_NET_WM_STATE" 32
> 			   (list action
> 				 hint 
> 				 (if hint2 hint2 0)

simpler:  (or hint2 0)

> 				 0))))
> 
> 
> (defun x-ewmh-fullscreen (&optional arg frame)
>   "Toggle FRAME fullscreen hint using extended window manager hints (EWMH).

Since this is an interactive function, you should describe the normal
interactive function in the "one-liner", which in your case would mean
not referring to the FRAME argument.

> 
> If FRAME is not given, the selected frame is used.
> If ARG is poitive, add fullscreen hint.
> If ARG is negative, remove fullscreen hint.

Since this is an interactive function, you would normally say that
using a positive command prefix would add the hint and a negative
prefix would remove the hint, while no prefix toggles the hint.

But it might be clearer if you say that a C-u prefix (write
\\[universal-argument] in the doc string) adds the hint, while
a M-- prefix (write \\[negative-argument] removes the hint.

> Otherwise toggle fullscreen hint.

I suggest you write something like this in the doc string:

  "Toggle EWMH fullscreen hint of selected frame.

With \\[universal-argument] prefix arg, add fullscreen hint, and
with \\[negative-argument] prefix arg, remove fullscreen hint.

When called from a Lisp program, optional second arg FRAME specifies the
frame on which to apply the fullscreen hint."

> 
> If fullscreen doesn't work with your window manager, try
> `x-ewmh-horz-and-vert'.
> 
> NOTE:  If the window manager does not support EWMH, this does nothing."
>   (interactive "P")
>   (x-ewmh-send arg "_NET_WM_STATE_FULLSCREEN" frame))
> 


> 
> (defun x-ewmh-maximized_vert (&optional arg frame)

x-ewmh-maximized-vertical  (don't use underscore and write name in full)

> 
> (defun x-ewmh-maximized_horz (&optional arg frame)

x-ewmh-maximized-horizontal  (ditto)

> 
> (defun x-ewmh-horz-and-vert (&optional arg frame)

x-ewmh-horizontal-and-vertical  (ditto)


Maybe in general, the functions should be named

        x-ewmh-toggle-...

to emphasize that their default operation is to toggle the hint.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: EWMH package, please review.
  2003-10-12 22:17 ` Kim F. Storm
@ 2003-10-12 22:54   ` Miles Bader
  2003-10-13  4:34     ` Jan D.
  2003-10-13  4:30   ` Jan D.
  2003-10-13 18:21   ` Richard Stallman
  2 siblings, 1 reply; 12+ messages in thread
From: Miles Bader @ 2003-10-12 22:54 UTC (permalink / raw)
  Cc: Jan D., emacs-devel

On Mon, Oct 13, 2003 at 12:17:35AM +0200, Kim F. Storm wrote:
> Maybe in general, the functions should be named
> 
>         x-ewmh-toggle-...
> 
> to emphasize that their default operation is to toggle the hint.

If they _only_ toggle, they could be called `...toggle...', but it seems
wrong to call them that if they just usually toggle.

In general the set and naming of functions seems kind of clumsy; how about
having just a single `x-ewmh-maximize' that can do both horizontal and
vertical maximization based on an optional argument?  Interactively, I'd
like something like:

   just    `M-x x-ewmh-maximize' toggles (full screen) maximization
   C-u     `M-x x-ewmh-maximize' toggles vertical maximization
   C-u C-u `M-x x-ewmh-maximize' toggles horizontal maximization
   C-u -1  `M-x x-ewmh-maximize' un-maximizes
   C-u 1   `M-x x-ewmh-maximize' (full screen) maximizes

[Of course normally you'd bind it to a key.  I chose vertical maximization
for the single-C-u because I find myself doing that _far_ more often than
horizontal maximization.]

Implementation-wise, this would probably be something like:

(defun x-emwh-maximize (arg &optional axis frame)
   "... ARG nil, toggle, ARG < 0, un-maximize, ARG > 0, maximize ...
   If AXIS is `horizontal', maximiaze horizontally, if `vertical',
   maximiaze vertically, otherwise, both. ..."
   (interactive
    (cond ((equal current-prefix-arg '(4)) '(nil vertical))
    	  ((equal current-prefix-arg '(16)) '(nil horizontal))
	  (t (list (prefix-numeric-value current-prefix-arg)))))
   ...)

That seems simpler and more convenient for both users and for programs.

-miles
-- 
Freedom's just another word, for nothing left to lose   --Janis Joplin

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

* Re: EWMH package, please review.
  2003-10-12 22:17 ` Kim F. Storm
  2003-10-12 22:54   ` Miles Bader
@ 2003-10-13  4:30   ` Jan D.
  2003-10-13  7:54     ` David Kastrup
  2003-10-13  8:43     ` Thien-Thi Nguyen
  2003-10-13 18:21   ` Richard Stallman
  2 siblings, 2 replies; 12+ messages in thread
From: Jan D. @ 2003-10-13  4:30 UTC (permalink / raw)
  Cc: emacs-devel

>> don't know if this is useful enough to be included in Emacs, so I'd
>> like your views on that also.
>
> I don't know.  Are (all of) those hints something an ordinary user
> would typically toggle interactively?

Shaded, fullscreen and maximize horizontal and vertical are.  Above and
below are probably a bit obscure.

>
>
>> ;;; Code:
>>
>> (defun x-ewmh-send (arg hint frame &optional hint2)
>>   "Send a client message to change an extended window manager hint.
>>
>> FRAME may be nil to use the selected frame.
>> If ARG is poitive, add HINT.
>> If ARG is negative, remove HINT.
>> Otherwise toggle HINT."
>>
>>   (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg)))
>
> This is simpler:
>
>   (setq arg (if (null arg) 0 (prefix-numeric-value arg)))
>   (let ((action ...use ARG instead of EFF-ARG...))

I was told to avoid setq when I learned lisp :-).

>
> IMO, it is somewhat unusual to let a generic, non-interactive function
> assume that it is always invoked by an interactive function.  I would
> normally let the callers do that (possibly using an auxiliary
> function), but in your case I would just change the DOC string to say
> that ARG is supposed to be a raw prefix argument.

I'd just wanted to minimize the duplication.  I understand the problem
though, I'll change the doc.

>
>
>> 	 (action (cond ((= eff-arg 0) 2)	;; Toggle
>> 		       ((> eff-arg 0) 1)	;; Add
>> 		       (t 0))))			;; Remove
>>     (x-send-client-message nil 0 frame "_NET_WM_STATE" 32
>> 			   (list action
>> 				 hint
>> 				 (if hint2 hint2 0)
>
> simpler:  (or hint2 0)

Right.

>
>> 				 0))))
>>
>>
>> (defun x-ewmh-fullscreen (&optional arg frame)
>>   "Toggle FRAME fullscreen hint using extended window manager hints 
>> (EWMH).
>
> Since this is an interactive function, you should describe the normal
> interactive function in the "one-liner", which in your case would mean
> not referring to the FRAME argument.
>
>>
>> If FRAME is not given, the selected frame is used.
>> If ARG is poitive, add fullscreen hint.
>> If ARG is negative, remove fullscreen hint.
>
> Since this is an interactive function, you would normally say that
> using a positive command prefix would add the hint and a negative
> prefix would remove the hint, while no prefix toggles the hint.
>
> But it might be clearer if you say that a C-u prefix (write
> \\[universal-argument] in the doc string) adds the hint, while
> a M-- prefix (write \\[negative-argument] removes the hint.

I'll change, thanks.  I'd probably should say more what the functions
do in the one liner.  I.e "Make a frame fullscreen" or some such.

>
>> Otherwise toggle fullscreen hint.
>
> I suggest you write something like this in the doc string:
>
>   "Toggle EWMH fullscreen hint of selected frame.
>
> With \\[universal-argument] prefix arg, add fullscreen hint, and
> with \\[negative-argument] prefix arg, remove fullscreen hint.
>
> When called from a Lisp program, optional second arg FRAME specifies 
> the
> frame on which to apply the fullscreen hint."

Good suggestion.

>
>>
>> If fullscreen doesn't work with your window manager, try
>> `x-ewmh-horz-and-vert'.
>>
>> NOTE:  If the window manager does not support EWMH, this does 
>> nothing."
>>   (interactive "P")
>>   (x-ewmh-send arg "_NET_WM_STATE_FULLSCREEN" frame))
>>
>
>
>>
>> (defun x-ewmh-maximized_vert (&optional arg frame)
>
> x-ewmh-maximized-vertical  (don't use underscore and write name in 
> full)
>
>>
>> (defun x-ewmh-maximized_horz (&optional arg frame)
>
> x-ewmh-maximized-horizontal  (ditto)
>
>>
>> (defun x-ewmh-horz-and-vert (&optional arg frame)
>
> x-ewmh-horizontal-and-vertical  (ditto)
>
>
> Maybe in general, the functions should be named
>
>         x-ewmh-toggle-...
>
> to emphasize that their default operation is to toggle the hint.

That is better.

Thanks for the comments.

	Jan D.

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

* Re: EWMH package, please review.
  2003-10-12 22:54   ` Miles Bader
@ 2003-10-13  4:34     ` Jan D.
  0 siblings, 0 replies; 12+ messages in thread
From: Jan D. @ 2003-10-13  4:34 UTC (permalink / raw)
  Cc: emacs-devel, Kim F. Storm

> On Mon, Oct 13, 2003 at 12:17:35AM +0200, Kim F. Storm wrote:
>> Maybe in general, the functions should be named
>>
>>         x-ewmh-toggle-...
>>
>> to emphasize that their default operation is to toggle the hint.
>
> If they _only_ toggle, they could be called `...toggle...', but it 
> seems
> wrong to call them that if they just usually toggle.
>
> In general the set and naming of functions seems kind of clumsy; how 
> about
> having just a single `x-ewmh-maximize' that can do both horizontal and
> vertical maximization based on an optional argument?  Interactively, 
> I'd
> like something like:
>
>    just    `M-x x-ewmh-maximize' toggles (full screen) maximization
>    C-u     `M-x x-ewmh-maximize' toggles vertical maximization
>    C-u C-u `M-x x-ewmh-maximize' toggles horizontal maximization
>    C-u -1  `M-x x-ewmh-maximize' un-maximizes
>    C-u 1   `M-x x-ewmh-maximize' (full screen) maximizes
>
> [Of course normally you'd bind it to a key.  I chose vertical 
> maximization
> for the single-C-u because I find myself doing that _far_ more often 
> than
> horizontal maximization.]
>
> Implementation-wise, this would probably be something like:
>
> (defun x-emwh-maximize (arg &optional axis frame)
>    "... ARG nil, toggle, ARG < 0, un-maximize, ARG > 0, maximize ...
>    If AXIS is `horizontal', maximiaze horizontally, if `vertical',
>    maximiaze vertically, otherwise, both. ..."
>    (interactive
>     (cond ((equal current-prefix-arg '(4)) '(nil vertical))
>     	  ((equal current-prefix-arg '(16)) '(nil horizontal))
> 	  (t (list (prefix-numeric-value current-prefix-arg)))))
>    ...)
>
> That seems simpler and more convenient for both users and for programs.

The problem is that fullscreen, vertical and horizontal are three
different hints.  So the un-maximiez must know which of the three
that has been done.  It is possible to do horizontal and vertical
and fullscreen all at once.  So which should be removed?  I guess
you could remove them all unconditionally, but then you can not
go from max horizontal and vertical to just max vertical.

Or am I missing something?

Thanks for the comment.

	Jan D.

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

* Re: EWMH package, please review.
  2003-10-13  4:30   ` Jan D.
@ 2003-10-13  7:54     ` David Kastrup
  2003-10-13  8:43     ` Thien-Thi Nguyen
  1 sibling, 0 replies; 12+ messages in thread
From: David Kastrup @ 2003-10-13  7:54 UTC (permalink / raw)
  Cc: emacs-devel, Kim F. Storm

"Jan D." <jan.h.d@swipnet.se> writes:

> >> ;;; Code:
> >>
> >> (defun x-ewmh-send (arg hint frame &optional hint2)
> >>   "Send a client message to change an extended window manager hint.
> >>
> >>   (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg)))
> >
> > This is simpler:
> >
> >   (setq arg (if (null arg) 0 (prefix-numeric-value arg)))
> >   (let ((action ...use ARG instead of EFF-ARG...))
> 
> I was told to avoid setq when I learned lisp :-).

And using setq on variables not supposed to be global and not having
a local binding either is quite a bad practice.  In this case,
however, arg already _has_ a local binding from the defun.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: EWMH package, please review.
  2003-10-13  4:30   ` Jan D.
  2003-10-13  7:54     ` David Kastrup
@ 2003-10-13  8:43     ` Thien-Thi Nguyen
  2003-10-18 17:47       ` Jan D.
  1 sibling, 1 reply; 12+ messages in thread
From: Thien-Thi Nguyen @ 2003-10-13  8:43 UTC (permalink / raw)
  Cc: emacs-devel, storm

   From: "Jan D." <jan.h.d@swipnet.se>
   Date: Mon, 13 Oct 2003 06:30:54 +0200

   I was told to avoid setq when I learned lisp :-).

but whoever told you that was doing a setq on your brain,
so why would you trust that advice w/o question?

thi

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

* Re: EWMH package, please review.
  2003-10-12 22:17 ` Kim F. Storm
  2003-10-12 22:54   ` Miles Bader
  2003-10-13  4:30   ` Jan D.
@ 2003-10-13 18:21   ` Richard Stallman
  2 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2003-10-13 18:21 UTC (permalink / raw)
  Cc: jan.h.d, emacs-devel

    > (defun x-ewmh-fullscreen (&optional arg frame)
    >   "Toggle FRAME fullscreen hint using extended window manager hints (EWMH).

Since this toggles something, it would be good to follow the
conventions for minor modes in regard to its arguments.

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

* Re: EWMH package, please review.
  2003-10-13  8:43     ` Thien-Thi Nguyen
@ 2003-10-18 17:47       ` Jan D.
  2003-10-18 18:05         ` David Kastrup
  0 siblings, 1 reply; 12+ messages in thread
From: Jan D. @ 2003-10-18 17:47 UTC (permalink / raw)
  Cc: storm, emacs-devel

Thien-Thi Nguyen wrote:
>    From: "Jan D." <jan.h.d@swipnet.se>
>    Date: Mon, 13 Oct 2003 06:30:54 +0200
> 
>    I was told to avoid setq when I learned lisp :-).
> 
> but whoever told you that was doing a setq on your brain,
> so why would you trust that advice w/o question?

It was functional programming that we used Lisp for (never reassign variables, 
among other things), so it kind of stuck.  And there was questions asked at the 
time :-).

	Jan D.

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

* Re: EWMH package, please review.
  2003-10-18 17:47       ` Jan D.
@ 2003-10-18 18:05         ` David Kastrup
  2003-10-18 18:15           ` David Kastrup
  2003-10-27  5:56           ` Jan D.
  0 siblings, 2 replies; 12+ messages in thread
From: David Kastrup @ 2003-10-18 18:05 UTC (permalink / raw)
  Cc: ttn, emacs-devel, storm

"Jan D." <jan.h.d@swipnet.se> writes:

> Thien-Thi Nguyen wrote:
> >    From: "Jan D." <jan.h.d@swipnet.se>
> >    Date: Mon, 13 Oct 2003 06:30:54 +0200
> >    I was told to avoid setq when I learned lisp :-).
> > but whoever told you that was doing a setq on your brain,
> > so why would you trust that advice w/o question?
> 
> It was functional programming that we used Lisp for (never reassign
> variables, among other things), so it kind of stuck.  And there was
> questions asked at the time :-).

You mean things like doing recursion without having a lexical
possibility to let a lambda function refer to itself?

Emacs-Lisp:

((lambda (f g n) (funcall g (funcall f f g) n))
 (lambda (f g) `(lambda (n) (,g (funcall ,f ,f ,g) n)))
 (lambda (f n) (if (zerop n) 1 (* n (funcall f (1- n)))))
 5)

Common Lisp: delete the ` and ,

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: EWMH package, please review.
  2003-10-18 18:05         ` David Kastrup
@ 2003-10-18 18:15           ` David Kastrup
  2003-10-27  5:56           ` Jan D.
  1 sibling, 0 replies; 12+ messages in thread
From: David Kastrup @ 2003-10-18 18:15 UTC (permalink / raw)
  Cc: ttn, storm, emacs-devel

David Kastrup <dak@gnu.org> writes:

> "Jan D." <jan.h.d@swipnet.se> writes:
> 
> > It was functional programming that we used Lisp for (never
> > reassign variables, among other things), so it kind of stuck.  And
> > there was questions asked at the time :-).
> 
> You mean things like doing recursion without having a lexical
> possibility to let a lambda function refer to itself?
> 
> Emacs-Lisp:
> 
> ((lambda (f g n) (funcall g (funcall f f g) n))
>  (lambda (f g) `(lambda (n) (,g (funcall ,f ,f ,g) n)))
>  (lambda (f n) (if (zerop n) 1 (* n (funcall f (1- n)))))
>  5)
> 
> Common Lisp: delete the ` and ,

Uh, actually you have to add a funcall in the second line, too, in
order to get this through Common Lisp:

((lambda (f g n) (funcall g (funcall f f g) n))
 (lambda (f g) (lambda (n) (funcall g (funcall f f g) n)))
 (lambda (f n) (if (zerop n) 1 (* n (funcall f (1- n)))))
 5)

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: EWMH package, please review.
  2003-10-18 18:05         ` David Kastrup
  2003-10-18 18:15           ` David Kastrup
@ 2003-10-27  5:56           ` Jan D.
  1 sibling, 0 replies; 12+ messages in thread
From: Jan D. @ 2003-10-27  5:56 UTC (permalink / raw)
  Cc: ttn, storm, emacs-devel

> You mean things like doing recursion without having a lexical
> possibility to let a lambda function refer to itself?
>
> Emacs-Lisp:
>
> ((lambda (f g n) (funcall g (funcall f f g) n))
>  (lambda (f g) `(lambda (n) (,g (funcall ,f ,f ,g) n)))
>  (lambda (f n) (if (zerop n) 1 (* n (funcall f (1- n)))))
>  5)
>
> Common Lisp: delete the ` and ,

In principle yes, but not that advanced/obscure :-)

	Jan D.

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

end of thread, other threads:[~2003-10-27  5:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-12 16:53 EWMH package, please review Jan D.
2003-10-12 22:17 ` Kim F. Storm
2003-10-12 22:54   ` Miles Bader
2003-10-13  4:34     ` Jan D.
2003-10-13  4:30   ` Jan D.
2003-10-13  7:54     ` David Kastrup
2003-10-13  8:43     ` Thien-Thi Nguyen
2003-10-18 17:47       ` Jan D.
2003-10-18 18:05         ` David Kastrup
2003-10-18 18:15           ` David Kastrup
2003-10-27  5:56           ` Jan D.
2003-10-13 18:21   ` Richard Stallman

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