Re: error in unless





Ken Tilton wrote:


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.


Oh, hang on, UNLESS goes the other way, so I am guessing you see a t after the track value.

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: ... (unless (string-equal "no song playing." ... 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: Alan Dershowitz - Norman Finkelstein Tenure Fight
    ... I'm guessing the person who wrote the story is not a Catholic and ... The mistake should have been caught by somebody at the copy desk. ... - Reb Nachman of Breslov ...
    (soc.culture.jewish.moderated)
  • Re: PASSWORD
    ... I am guessing he put a space or some other character in it by mistake. ... Earle Horton -- earleh@xxxxxxxxxx ...
    (microsoft.public.office.misc)
  • Re: How to avoid "f.close" (no parens) bug?
    ... > I've just spent several very frustrating hours tracking down a bug in ... I have *never* made this particular mistake in Python, nor, as ... have any of the several dozen Python programmers ... I'm guessing that is the reason you are making this mistake. ...
    (comp.lang.python)
  • Re: Dvorak?
    ... mistake. ... did he say he was goin' home? ... I'm guessing that may be a bit too subtle for most people. ...
    (rec.arts.sf.fandom)