all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* toggle-viper-mode strangeness
@ 2006-01-19  1:13 Giorgos Keramidas
  2006-01-19 21:43 ` Kevin Rodgers
  2006-01-20  1:14 ` Richard M. Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Giorgos Keramidas @ 2006-01-19  1:13 UTC (permalink / raw)


It's been several days since I updated cvs-emacs here, so forgive me if
this is fixed already.

Isn't the following in `toggle-viper-mode' strange?

        ;;;###autoload
        (defun toggle-viper-mode ()
          "Toggle Viper on/off.
        If Viper is enabled, turn it off.  Otherwise, turn it on."
          (interactive)
          (if (eq viper-mode t)
              (viper-go-away)
==>         (setq viper-mode nil)
            (viper-mode)))

Looking at the indentation I'd expect the if expression to end where the
arrow points, but it doesn't.  Or is an implicit (progn ...) added
automatically by Emacs around the third ... N-th elements of the if
expression?

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

* Re: toggle-viper-mode strangeness
  2006-01-19  1:13 toggle-viper-mode strangeness Giorgos Keramidas
@ 2006-01-19 21:43 ` Kevin Rodgers
  2006-01-20  1:14 ` Richard M. Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2006-01-19 21:43 UTC (permalink / raw)


Giorgos Keramidas wrote:
> It's been several days since I updated cvs-emacs here, so forgive me if
> this is fixed already.
> 
> Isn't the following in `toggle-viper-mode' strange?
> 
>         ;;;###autoload
>         (defun toggle-viper-mode ()
>           "Toggle Viper on/off.
>         If Viper is enabled, turn it off.  Otherwise, turn it on."
>           (interactive)
>           (if (eq viper-mode t)
>               (viper-go-away)
> ==>         (setq viper-mode nil)
>             (viper-mode)))
> 
> Looking at the indentation I'd expect the if expression to end where the
> arrow points, but it doesn't.  Or is an implicit (progn ...) added
> automatically by Emacs around the third ... N-th elements of the if
> expression?

Yes:

,----[ C-h f if RET ]
| if is a special form.
| (if COND THEN ELSE...)
|
| If COND yields non-nil, do THEN, else do ELSE...
| Returns the value of THEN or the value of the last of the ELSE's.
| THEN must be one expression, but ELSE... can be zero or more expressions.
| If COND yields nil, and there are no ELSE's, the value is nil.
`----

-- 
Kevin Rodgers

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

* Re: toggle-viper-mode strangeness
  2006-01-19  1:13 toggle-viper-mode strangeness Giorgos Keramidas
  2006-01-19 21:43 ` Kevin Rodgers
@ 2006-01-20  1:14 ` Richard M. Stallman
  2006-01-20  2:35   ` Giorgos Keramidas
  1 sibling, 1 reply; 8+ messages in thread
From: Richard M. Stallman @ 2006-01-20  1:14 UTC (permalink / raw)
  Cc: emacs-devel

Here's what that code does:

	      (if (eq viper-mode t)
	          ;; Turn the mode off.
		  (viper-go-away)
		;; Turn the mode on.
		(setq viper-mode nil)
		(viper-mode)))

It looks correct to me, except perhaps for the eq call,
which treats non-nil non-t values as "off" rather than "on".
That is peculiar, but I don't know whether it is wrong.

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

* Re: toggle-viper-mode strangeness
  2006-01-20  1:14 ` Richard M. Stallman
@ 2006-01-20  2:35   ` Giorgos Keramidas
  2006-01-20  3:38     ` Johan Bockgård
  2006-01-20  4:03     ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Giorgos Keramidas @ 2006-01-20  2:35 UTC (permalink / raw)
  Cc: emacs-devel

On 2006-01-19 20:14, "Richard M. Stallman" <rms@gnu.org> wrote:
> Here's what that code does:
>
> 	      (if (eq viper-mode t)
> 	          ;; Turn the mode off.
> 		  (viper-go-away)
> 		;; Turn the mode on.
> 		(setq viper-mode nil)
> 		(viper-mode)))
>
> It looks correct to me, except perhaps for the eq call,
> which treats non-nil non-t values as "off" rather than "on".
> That is peculiar, but I don't know whether it is wrong.

I was under the impression that an (if cond then else) expression can
only have 4 parts within the parentheses.  This means that the above
would require a (progn) around the final two parts, i.e.:

        (if (eq viper-mode t)
            ;; Turn the mode off.
            (viper-go-away)
          ;; Turn the mode on.
          (progn
            (setq viper-mode nil)
            (viper-mode)))

It looks like I was wrong, and the else part can contain more than one
s-exp, returning the value of the last one.  Thanks :)

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

* Re: toggle-viper-mode strangeness
  2006-01-20  2:35   ` Giorgos Keramidas
@ 2006-01-20  3:38     ` Johan Bockgård
  2006-01-20  4:03     ` Stefan Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Johan Bockgård @ 2006-01-20  3:38 UTC (permalink / raw)


Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

> I was under the impression that an (if cond then else) expression
> can only have 4 parts within the parentheses.

Different Lisp dialects are different in this respect.

-- 
Johan Bockgård

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

* Re: toggle-viper-mode strangeness
  2006-01-20  2:35   ` Giorgos Keramidas
  2006-01-20  3:38     ` Johan Bockgård
@ 2006-01-20  4:03     ` Stefan Monnier
  2006-01-20  4:14       ` Luc Teirlinck
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2006-01-20  4:03 UTC (permalink / raw)
  Cc: Richard M. Stallman, emacs-devel

> I was under the impression that an (if cond then else) expression can
> only have 4 parts within the parentheses.  This means that the above

You're confusing Scheme and Lisp.


        Stefan

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

* Re: toggle-viper-mode strangeness
  2006-01-20  4:03     ` Stefan Monnier
@ 2006-01-20  4:14       ` Luc Teirlinck
  2006-01-20 12:45         ` Giorgos Keramidas
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Teirlinck @ 2006-01-20  4:14 UTC (permalink / raw)
  Cc: keramida, rms, emacs-devel

Stefan Monnier wrote:

   > I was under the impression that an (if cond then else) expression can
   > only have 4 parts within the parentheses.  This means that the above

   You're confusing Scheme and Lisp.

Or Common Lisp (in which the `else' is _not_ an implicit progn) and Elisp.

Sincerely,

Luc.

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

* Re: toggle-viper-mode strangeness
  2006-01-20  4:14       ` Luc Teirlinck
@ 2006-01-20 12:45         ` Giorgos Keramidas
  0 siblings, 0 replies; 8+ messages in thread
From: Giorgos Keramidas @ 2006-01-20 12:45 UTC (permalink / raw)
  Cc: Richard M. Stallman, emacs-devel

On 2006-01-19 23:03, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > I was under the impression that an (if cond then else) expression can
> > only have 4 parts within the parentheses.  This means that the above
>
> You're confusing Scheme and Lisp.

On 2006-01-19 22:14, Luc Teirlinck <teirllm@dms.auburn.edu> wrote:
> Or Common Lisp (in which the `else' is _not_ an implicit progn) and Elisp.

Common Lisp, in fact.  Too much ``M-x slime'' these last few days.

Thanks for the clarification everyone.  I'll make sure to check with the
info docs before I create more noise :)

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

end of thread, other threads:[~2006-01-20 12:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-19  1:13 toggle-viper-mode strangeness Giorgos Keramidas
2006-01-19 21:43 ` Kevin Rodgers
2006-01-20  1:14 ` Richard M. Stallman
2006-01-20  2:35   ` Giorgos Keramidas
2006-01-20  3:38     ` Johan Bockgård
2006-01-20  4:03     ` Stefan Monnier
2006-01-20  4:14       ` Luc Teirlinck
2006-01-20 12:45         ` Giorgos Keramidas

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.