Re: error in unless





Gijs Hillenius wrote:
Hello,

I'm a beginner in lisp & programming, which explains why I'm not
seeing the mistake in the following bit of code:

I would like to add this to my .gnus:

(defun audacious-now-playing ()
"Insert the title of the song I'm currently listening to."
(let ((track (shell-command-to-string "audtool --current-song")))
(unless (string-equal "no song playing." track) (save-excursion
(goto-char (point-min))
(re-search-forward "^--text follows this line--")
(forward-line 0)
(insert "X-Now-Playing: " track)))))

(add-hook 'message-setup-hook 'audacious-now-playing)

The way I adapted this existing bit of code, the unless condition does
not work like intended and I end up with a "X-Now-Playing: No song
playing." x-header in emails.

I would appreciate it if someone could point out what I'm doing
wrong.


What I like to do in cases like this is, just before the unless, print out both the value of track and then the actual condition copied directly from the unless:

(print `(hunh? ,track ,(string-equal ...etc...)))

I am guessing you'll see a nil after the track value and then you can stop worrying about UNLESS and start worrying about your typing or something else.

kt

--
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
.



Relevant Pages

  • Re: error in unless
    ... I'm a beginner in lisp & programming, ... seeing the mistake in the following bit of code: ... I am guessing you'll see a nil after the track value and then you can stop worrying about UNLESS and start worrying about your typing or something else. ...
    (comp.lang.lisp)
  • Re: Keeping time
    ... the proper notes, without worrying about the timing. ... if you make a mistake, ... breathing) with the metronome, then syncing your playing with yourself. ...
    (alt.guitar.beginner)
  • Re: The answer to global warming
    ... Where was my head in all this?......Oh yea, worrying ... The only thing funnier than that mistake, was the 18.5MPG in the first ...
    (rec.motorcycles.dirt)