Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Why doesn't this work?

(defun load-browser (app)
    (interactive "sChoose Browser? ")
    (cond ((string= app '"c")
        (setq browse-url-generic-program "chromium")
        (setq browse-url-browser-function 'browse-url-generic))
    (message "Else case Typed %s" app)
    )
)

It fails to work in the Else case where the input string/char is not "c".

share|improve this question

1 Answer 1

  1. No need to quote a string: use "c" instead of '"c". Strings evaluate to themselves.

  2. You second cond clause is invalid. It is this: (message "Else case Typed %s" app). That tests the symbol message as a variable, and it is no doubt an undefined variable, which raises an error.

What you are probably trying to get is this as your second cond clause:

 (t (message "Else case Typed %s" app)) ; If not first clause, show message.

Read the doc about cond. And always use correct indentation. See C-h k C-M-q in Emacs-Lisp mode.

share|improve this answer
    
That should be C-h k C-M-q. I tried to edit it, but apparently edits have to be at least six characters. –  jbm Feb 8 '14 at 3:04
    
@jbm: Right; thanks. Corrected C-h f to C-h k. –  Drew Feb 8 '14 at 14:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.