0

I have some experience in Emacs-LISP. Today I spent 6 hours writing LISP code that I guess-timate would have taken 1h30 to write in Python because my workflow to develop and debug is very clunky. In Python I would log successive values with print("Stage N: " + value) at different stages. I am looking for something better.

I give two examples below. I'm sure other people are more productive given the high reputation of LISP. What workflows do coders use for development and debugging in Emacs-LISP?

One example

Automated testing with ERT does not indicate the line of an error. This is so strange that I made it into its own question).

Another example

In debugging a function with an optional argument, I was unable to log that value to the *Messages* buffer as I could not find how to convert t and nil to string. In the *scratch* buffer:

(message (concat "Value is: " (string t))) ;; concat: Wrong type argument: characterp, t

(message (concat "Value is: " (string nil))) ;; concat: Wrong type argument: characterp, nil

(message (concat "Value is: " t)) ;; message: Wrong type argument: sequencep, t

(message (concat "Value is: " nil))
"Value is: "
| improve this question | | | | |
  • 3
    The question is too broad, and possibly opinion-based (e.g. what is a "productive framework"?). Please try to pose a specific question that is likely to solicit useful, specific answers. – Drew Dec 14 '19 at 16:54
  • 3
    Simply (message "Value is %s" whatever). I suggest C-h f message`. – JeanPierre Dec 14 '19 at 18:06
  • 1
    One possiblity is edebug. – NickD Dec 14 '19 at 21:36
  • 1
    FYI python also has a perfectly good debugger, pdb. (The last time I was using python, the third-party ipdb was a much nicer user interface to it.) You can read about the Emacs debuggers (plural) at C-h i g (elisp)Debugging – phils Dec 16 '19 at 1:28
  • 1
    I culled the bits from the comments above and started a Community answer. Feel free to update. – NickD Dec 18 '19 at 20:04
1

Here is the beginnings of a list of useful techniques culled from the comments. Please add any others that you find useful by editing this answer:

  • The elisp analog of sprinkling printfs in a program to show values of variables: (message "Value is %s" whatever).

  • Using a debugger: possibilities include the Lisp Debugger, and edebug.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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