all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Change the default binding of C-x C-e ?
@ 2008-01-06 11:41 Mike Mattie
  2008-01-06 14:59 ` Leo
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Mike Mattie @ 2008-01-06 11:41 UTC (permalink / raw)
  To: emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 690 bytes --]

Hello,

I think it is a good idea to change the default key-binding of C-x C-e to eval-defun. From a reading of the Elisp
Intro I became used to using the usual binding which is eval-last-sexp. Things worked fine until I progressed
in elisp to where I wanted to use defvar. As the informed have probably surmised I was baffled by the results
because repeated evaluation did not affect the default value.

While reading through the manuals I stumbled across eval-defun and realized what was going on. AFAICT they
are effectively the same in use, however eval-defun does not have suprising corner cases like defvar default
values.

FWIW it may help others to change this binding.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

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

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 11:41 Change the default binding of C-x C-e ? Mike Mattie
@ 2008-01-06 14:59 ` Leo
  2008-01-06 15:14   ` Mike Mattie
  2008-01-06 15:17 ` Alan Mackenzie
  2008-01-07  4:18 ` Richard Stallman
  2 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2008-01-06 14:59 UTC (permalink / raw)
  To: emacs-devel

On 2008-01-06 11:41 +0000, Mike Mattie wrote:
> Hello,
>
> I think it is a good idea to change the default key-binding of C-x C-e to eval-defun. From a reading of the Elisp
> Intro I became used to using the usual binding which is eval-last-sexp. Things worked fine until I progressed
> in elisp to where I wanted to use defvar. As the informed have probably surmised I was baffled by the results
> because repeated evaluation did not affect the default value.
>
> While reading through the manuals I stumbled across eval-defun and realized what was going on. AFAICT they
> are effectively the same in use, however eval-defun does not have suprising corner cases like defvar default
> values.
>
> FWIW it may help others to change this binding.

Do you know about "C-M-x"?

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .:  [ GPG Key: 9283AA3F ]  :.

          Use the best OS -- http://www.fedoraproject.org/

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 14:59 ` Leo
@ 2008-01-06 15:14   ` Mike Mattie
  0 siblings, 0 replies; 10+ messages in thread
From: Mike Mattie @ 2008-01-06 15:14 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --]

On Sun, 06 Jan 2008 14:59:11 +0000
Leo <sdl.web@gmail.com> wrote:

> On 2008-01-06 11:41 +0000, Mike Mattie wrote:
> > Hello,
> >
> > I think it is a good idea to change the default key-binding of C-x
> > C-e to eval-defun. From a reading of the Elisp Intro I became used
> > to using the usual binding which is eval-last-sexp. Things worked
> > fine until I progressed in elisp to where I wanted to use defvar.
> > As the informed have probably surmised I was baffled by the results
> > because repeated evaluation did not affect the default value.
> >
> > While reading through the manuals I stumbled across eval-defun and
> > realized what was going on. AFAICT they are effectively the same in
> > use, however eval-defun does not have suprising corner cases like
> > defvar default values.
> >
> > FWIW it may help others to change this binding.
> 
> Do you know about "C-M-x"?
> 

I do now. I have eval-defun bound to a key-sequence that works for me. I addressed
the mailing list because I thought others might stumble as I did on this particular
issue while learning elisp.

A note in the Emacs Lisp Intro would likely only confuse the learning process at
the earliest stage which is precocious. I thought that using eval-defun from
the beginning would side-step trouble down the road with defvar altogether.

So the issue is resolved for me, my concern was for others travelling the
elisp path.

Cheers,
Mike Mattie

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

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

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 11:41 Change the default binding of C-x C-e ? Mike Mattie
  2008-01-06 14:59 ` Leo
@ 2008-01-06 15:17 ` Alan Mackenzie
  2008-01-06 20:35   ` Stefan Monnier
  2008-01-07  4:18 ` Richard Stallman
  2 siblings, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2008-01-06 15:17 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs developers

Hi, Mike!

On Sun, Jan 06, 2008 at 03:41:04AM -0800, Mike Mattie wrote:
> Hello,

> I think it is a good idea to change the default key-binding of C-x C-e
> to eval-defun. From a reading of the Elisp Intro I became used to using
> the usual binding which is eval-last-sexp. Things worked fine until I
> progressed in elisp to where I wanted to use defvar. As the informed
> have probably surmised I was baffled by the results because repeated
> evaluation did not affect the default value.

> While reading through the manuals I stumbled across eval-defun and
> realized what was going on. AFAICT they are effectively the same in
> use, however eval-defun does not have suprising corner cases like
> defvar default values.

eval-last-sexp and eval-defun do different things - e-d determines the
top level construct surrounding point, e-l-s finds the previous
expression.  I think you've just found that out.

It is sometimes useful whilst hacking lisp to evaluate an expression in
the middle of a defun.  You'd be surprised how often that happens.
That's what C-x C-e is for, and I'd bet my entire life savings on the
rest of the Emacs team agreeing here.

> FWIW it may help others to change this binding.

Maybe, maybe not.  I would suggest a compromise binding: C-u C-x C-e for
eval-defun.  You could implement that for yourself using "advice".

-- 
Alan Mackenzie (Nuremberg).

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

* Re: Change the default binding of C-x C-e ?
@ 2008-01-06 17:21 Robert J. Chassell
  2008-01-06 19:45 ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Robert J. Chassell @ 2008-01-06 17:21 UTC (permalink / raw)
  To: emacs-devel

    Things worked fine until I progressed in elisp to where I wanted
    to use defvar.

(info "(eintr)defvar")
says

       The `defvar' special form ... only sets the value of the
    variable if the variable does not already have a value.

I just checked this:  I can use C-x C-e (eval-last-sexp) to set the
value of a variable with `defvar' for the first time.  As described in
the Introduction, I cannot change the value a second time with
`defvar' and `eval-last-sexp'; for that, I must use `setq'.

Today's GNU Emacs CVS snapshot, Sun, 2008 Jan  6  11:10 UTC
GNU Emacs 23.0.50.21 (i686-pc-linux-gnu, GTK+ Version 2.12.1)

--
    Robert J. Chassell                          GnuPG Key ID: 004B4AC8
    bob@rattlesnake.com                         bob@gnu.org
    http://www.rattlesnake.com                  http://www.teak.cc

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 17:21 Robert J. Chassell
@ 2008-01-06 19:45 ` Tom Tromey
  2008-01-07  0:15   ` Stephen J. Turnbull
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2008-01-06 19:45 UTC (permalink / raw)
  To: bob; +Cc: emacs-devel

Robert> I just checked this:  I can use C-x C-e (eval-last-sexp) to set the
Robert> value of a variable with `defvar' for the first time.  As described in
Robert> the Introduction, I cannot change the value a second time with
Robert> `defvar' and `eval-last-sexp'; for that, I must use `setq'.

For interactive elisp hacking I redefine eval-last-sexp to treat a
defvar more like a defconst.  This is pretty handy since it means I
don't have to modify the source or copy/paste/modify sexps in order to
do what I (usually) want.

Tom

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 15:17 ` Alan Mackenzie
@ 2008-01-06 20:35   ` Stefan Monnier
  2008-01-07  6:53     ` Andreas Röhler
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2008-01-06 20:35 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Mike Mattie, emacs developers

> It is sometimes useful whilst hacking lisp to evaluate an expression in
> the middle of a defun.  You'd be surprised how often that happens.
> That's what C-x C-e is for, and I'd bet my entire life savings on the
> rest of the Emacs team agreeing here.

I'd agree, but I also think that maybe the OP has a point: C-x C-e when
used after an expression such as (defvar foo 1) should, just like C-M-x
force `foo' to be reset to 1.


        Stefan

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 19:45 ` Tom Tromey
@ 2008-01-07  0:15   ` Stephen J. Turnbull
  0 siblings, 0 replies; 10+ messages in thread
From: Stephen J. Turnbull @ 2008-01-07  0:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: bob, emacs-devel

Tom Tromey writes:

 > For interactive elisp hacking I redefine eval-last-sexp to treat a
 > defvar more like a defconst.  This is pretty handy since it means I
 > don't have to modify the source or copy/paste/modify sexps in order to
 > do what I (usually) want.

XEmacs's eval-last-sexp also does this (by default) and issues a
warning that the defvar has been treated as a defconst.

As a possibly useful data point, I do not recall seeing a complaint
about this (I've been following the XEmacs developer's list
religiouusly and the newsgroup intermittently since 1997).

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 11:41 Change the default binding of C-x C-e ? Mike Mattie
  2008-01-06 14:59 ` Leo
  2008-01-06 15:17 ` Alan Mackenzie
@ 2008-01-07  4:18 ` Richard Stallman
  2 siblings, 0 replies; 10+ messages in thread
From: Richard Stallman @ 2008-01-07  4:18 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

    I think it is a good idea to change the default key-binding of C-x C-e to e=
    val-defun.

Since eval-defun is already on C-M-x, I don't see a point putting it
on C-x C-e as well.

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

* Re: Change the default binding of C-x C-e ?
  2008-01-06 20:35   ` Stefan Monnier
@ 2008-01-07  6:53     ` Andreas Röhler
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Röhler @ 2008-01-07  6:53 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Mike Mattie, Tom Tromey, Robert Chassell,
	Stefan Monnier, Alan Mackenzie, Leo, 

Am Sonntag, 6. Januar 2008 21:35 schrieb Stefan Monnier:
> > It is sometimes useful whilst hacking lisp to evaluate an expression in
> > the middle of a defun.  You'd be surprised how often that happens.
> > That's what C-x C-e is for, and I'd bet my entire life savings on the
> > rest of the Emacs team agreeing here.
>
> I'd agree, but I also think that maybe the OP has a point: C-x C-e when
> used after an expression such as (defvar foo 1) should, just like C-M-x
> force `foo' to be reset to 1.
>
>
>         Stefan
>

Would welcome that.

Presently, while playing around with new code, `devfar'
is not comfortable, as it defends it's value once set.

If values are still experimental, I use `setq'
instead. From what follows a need to correct that
afterwards. With this changing we would get rid of that
need and avoid possible errors.

Right?

Andreas Röhler

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

end of thread, other threads:[~2008-01-07  6:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-06 11:41 Change the default binding of C-x C-e ? Mike Mattie
2008-01-06 14:59 ` Leo
2008-01-06 15:14   ` Mike Mattie
2008-01-06 15:17 ` Alan Mackenzie
2008-01-06 20:35   ` Stefan Monnier
2008-01-07  6:53     ` Andreas Röhler
2008-01-07  4:18 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2008-01-06 17:21 Robert J. Chassell
2008-01-06 19:45 ` Tom Tromey
2008-01-07  0:15   ` Stephen J. Turnbull

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.