🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98593

Re: variables

#98593
From: Barry Margolin
Date: Thu, 02 May 1991 22:47
44 lines
2255 bytes
I tried to mail this, but somewhere between here and oakhill the
".sps.mot.com" suffix was being stripped off.

In article <1991Apr30.222526.2541@oakhill.sps.mot.com> mlee@oakhill.sps.mot.com (May Lee) writes:
>(defun
>  toggle-wrap ()
>      (if (= truncate-lines nil)
>        (setq truncate-lines 1))
>      (if (> truncate-lines nil)
>        (setq truncate-lines nil))
>)
>
>Is there anything wrong with this?

= and > are only meaningful for numbers, and nil isn't a number.  So

	(= truncate-lines nil)
 and
	(> truncate-lines nil)

are invalid.  The generic equivalence function in Lisp is EQ.  Another
problem with the above code is that if = and > did what you expected, it
still wouldn't have worked; when the first IF statement succeeds, the
second one will also succeed (because the first one sets truncate-lines to
1) and then it will set it back to NIL!  You should have used the "else"
clause of the IF statement, rather than a second IF statement.

>What it is supposed to do is when the line is wrapped and R6 is depressed
>it should unwrap it and vice-a-versa.

Try:

(defun toggle-wrap ()
  (interactive)
  (setq truncate-lines (not truncate-lines)))

The "(interactive)" is there because this command is intended to be used
interactively by the user (as opposed to being just a subroutine for use by
other commands).  This makes it available in the M-x prompt.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar
Technical Details
Message-ID: <1991May2.224729.29231@Think.COM>
Path: arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!sdd.hp.com!ucsd!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage
References: <1991Apr30.222526.2541@oakhill.sps.mot.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,e8ad000a43bb9eb4
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-05-02 15:47:29 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!sdd.hp.com!ucsd!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage
From: think!barmar@BLOOM-BEACON.MIT.EDU (Barry Margolin)
Newsgroups: gnu.emacs.bug
Subject: Re: variables
Message-ID: <1991May2.224729.29231@Think.COM>
Date: 2 May 91 22:47:29 GMT
References: <1991Apr30.222526.2541@oakhill.sps.mot.com>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 44
Approved: bug-gnu-emacs@prep.ai.mit.edu