-2

Am using an optional argument and want to use cond to execute (do-this) if actm is present and matches 'regexp, and (do-that) otherwise. Is the following the correct way to do it, or am I missing something?

(defun kmsec (&optional actm)
  "Identify comment category ';; [Category]'."
  
(cond

   ((eq actm 'regexp)
       (do-this))

   (t
       (do-that)) ))

1 Answer 1

0

That is one way to do it. Given that there are only two alternatives, another way to do it is:

(defun kmsec (&optional actm)
  "Identify comment category ';; [Category]'."
  
  (if (eq actm 'regexp)
      (do-this)
    (do-that)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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