all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Two binding features
@ 2008-05-07 17:35 Richard M Stallman
  2008-05-07 17:43 ` David Kastrup
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Richard M Stallman @ 2008-05-07 17:35 UTC (permalink / raw)
  To: emacs-devel

Two primitive features that would be useful for mumamo
(and perhaps othere programs) are:

* A primitive that would let-bind variables from an alist.
I think Common Lisp has such a construct; is that correct?
I do not recall its name, though.

* A way to temporarily turn off all buffer-local bindings.  This could
take the form of a variable which you would bind with `let', and when
it is non-nil, the buffer-local bindings are not visible.
`with-current-buffer' should bind it to nil so that the buffer-local
bindings of the newly current buffer always do take effect.

It would be ok if certain variables whose values are stored directly
in the buffer object, such as `buffer-file-name', fail to be affected
by this feature.

I think any feature to temporarily switch modes, or pretend to do so,
would find these features useful.  Could someone implement them?




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

* Re: Two binding features
  2008-05-07 17:35 Two binding features Richard M Stallman
@ 2008-05-07 17:43 ` David Kastrup
  2008-05-08 22:28   ` Richard M Stallman
  2008-05-07 18:47 ` Johan Bockgård
  2008-05-09  1:30 ` Stefan Monnier
  2 siblings, 1 reply; 8+ messages in thread
From: David Kastrup @ 2008-05-07 17:43 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard M Stallman <rms@gnu.org> writes:

> Two primitive features that would be useful for mumamo
> (and perhaps othere programs) are:
>
> * A primitive that would let-bind variables from an alist.
> I think Common Lisp has such a construct; is that correct?
> I do not recall its name, though.
>
> * A way to temporarily turn off all buffer-local bindings.  This could
> take the form of a variable which you would bind with `let', and when
> it is non-nil, the buffer-local bindings are not visible.

How about making (with-current-buffer nil ...)  have that effect (in
case this is not already the case or an error)?  Or is that
inconvenient?

> I think any feature to temporarily switch modes, or pretend to do so,
> would find these features useful.

How so?

-- 
David Kastrup




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

* Re: Two binding features
  2008-05-07 17:35 Two binding features Richard M Stallman
  2008-05-07 17:43 ` David Kastrup
@ 2008-05-07 18:47 ` Johan Bockgård
  2008-05-07 22:15   ` Paul R
  2008-05-08 22:28   ` Richard M Stallman
  2008-05-09  1:30 ` Stefan Monnier
  2 siblings, 2 replies; 8+ messages in thread
From: Johan Bockgård @ 2008-05-07 18:47 UTC (permalink / raw)
  To: emacs-devel

Richard M Stallman <rms@gnu.org> writes:

> * A primitive that would let-bind variables from an alist.
> I think Common Lisp has such a construct; is that correct?
> I do not recall its name, though.

  progv is a Lisp macro in `cl-macs.el'.

  (progv SYMBOLS VALUES &rest BODY)

  Bind SYMBOLS to VALUES dynamically in BODY.
  The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
  Each symbol in the first list is bound to the corresponding value in the
  second list (or made unbound if VALUES is shorter than SYMBOLS); then
  the
  BODY forms are executed and their result is returned.  This is much like
  a `let' form, except that the list of symbols can be computed at
  run-time.

-- 
Johan Bockgård





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

* Re: Two binding features
  2008-05-07 18:47 ` Johan Bockgård
@ 2008-05-07 22:15   ` Paul R
  2008-05-08 22:28   ` Richard M Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Paul R @ 2008-05-07 22:15 UTC (permalink / raw)
  To: emacs-devel

bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> Richard M Stallman <rms@gnu.org> writes:
>
>> * A primitive that would let-bind variables from an alist.
>> I think Common Lisp has such a construct; is that correct?
>> I do not recall its name, though.
>
>   progv is a Lisp macro in `cl-macs.el'.
>
>   (progv SYMBOLS VALUES &rest BODY)
>
>   Bind SYMBOLS to VALUES dynamically in BODY.
>   The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
>   Each symbol in the first list is bound to the corresponding value in the
>   second list (or made unbound if VALUES is shorter than SYMBOLS); then
>   the
>   BODY forms are executed and their result is returned.  This is much like
>   a `let' form, except that the list of symbols can be computed at
>   run-time.

destructuring-bind is also a lisp macro in cl-macs.el. No docstring in
my install. It works pretty much the same, but generalized to any
structure for symbols and values.
Also, I feel org-mode implemented exactly what Richard said, I'll dig
it a bit more and report later.

-- 
      Paul




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

* Re: Two binding features
  2008-05-07 17:43 ` David Kastrup
@ 2008-05-08 22:28   ` Richard M Stallman
  0 siblings, 0 replies; 8+ messages in thread
From: Richard M Stallman @ 2008-05-08 22:28 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

    > * A way to temporarily turn off all buffer-local bindings.  This could
    > take the form of a variable which you would bind with `let', and when
    > it is non-nil, the buffer-local bindings are not visible.

    How about making (with-current-buffer nil ...)  have that effect (in
    case this is not already the case or an error)?  Or is that
    inconvenient?

This would seem to mean that no buffer is current
and you can't edit any buffer.  That is not what we want.




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

* Re: Two binding features
  2008-05-07 18:47 ` Johan Bockgård
  2008-05-07 22:15   ` Paul R
@ 2008-05-08 22:28   ` Richard M Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Richard M Stallman @ 2008-05-08 22:28 UTC (permalink / raw)
  To: Johan Bockgård; +Cc: emacs-devel

progv in CL is implemented using unwind-protect.
That does the job, but maybe it would be better
to implement it as a primitive, making real bindings.

The current implementation has one advantage: it uses
just one specpdl slot for any number of variables.
But I suspect that the unwind-protect implementation
will give wrong results in some cases, for instance
when buffer-local bindings are in use for the same
variables.




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

* Re: Two binding features
  2008-05-07 17:35 Two binding features Richard M Stallman
  2008-05-07 17:43 ` David Kastrup
  2008-05-07 18:47 ` Johan Bockgård
@ 2008-05-09  1:30 ` Stefan Monnier
  2008-05-10  8:55   ` Richard M Stallman
  2 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-05-09  1:30 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

> Two primitive features that would be useful for mumamo
> (and perhaps othere programs) are:

> * A primitive that would let-bind variables from an alist.
> I think Common Lisp has such a construct; is that correct?
> I do not recall its name, though.

> * A way to temporarily turn off all buffer-local bindings.  This could
> take the form of a variable which you would bind with `let', and when
> it is non-nil, the buffer-local bindings are not visible.
> `with-current-buffer' should bind it to nil so that the buffer-local
> bindings of the newly current buffer always do take effect.

> It would be ok if certain variables whose values are stored directly
> in the buffer object, such as `buffer-file-name', fail to be affected
> by this feature.

> I think any feature to temporarily switch modes, or pretend to do so,
> would find these features useful.  Could someone implement them?

The above features can be simulated fairly well and easily with Elisp
code, so I think it'd be better to first try an Elisp implementation and
when it turns out that it is indeed useful and that the performance
and/or semantics of the Elisp code is problematic, we can consider
adding the feature in C.


        Stefan




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

* Re: Two binding features
  2008-05-09  1:30 ` Stefan Monnier
@ 2008-05-10  8:55   ` Richard M Stallman
  0 siblings, 0 replies; 8+ messages in thread
From: Richard M Stallman @ 2008-05-10  8:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Mumamo already has Lisp code to do these jobs.
Of course, it is rather ugly.  What we need now is
primitives to do it cleanly.




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

end of thread, other threads:[~2008-05-10  8:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-07 17:35 Two binding features Richard M Stallman
2008-05-07 17:43 ` David Kastrup
2008-05-08 22:28   ` Richard M Stallman
2008-05-07 18:47 ` Johan Bockgård
2008-05-07 22:15   ` Paul R
2008-05-08 22:28   ` Richard M Stallman
2008-05-09  1:30 ` Stefan Monnier
2008-05-10  8:55   ` Richard M Stallman

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.