6

I'm trying to make a function that moves to the end of line and inserts a newline.

(defun newline-below ()
    (interactive)
    (move-end-of-line)
    (newline)
)

However, I get a cryptic error when I try to run it.

newline-below: Wrong number of arguments: #[(arg) "

1 Answer 1

12

The function move-end-of-line needs an argument (try C-hf while the cursor is over the function). Just nil might work for your purpose:

(move-end-of-line nil)
Sign up to request clarification or add additional context in comments.

2 Comments

Handy trick: M-x toggle-debug-on-error. Now run your function, and you'll get a stack trace showing exactly where the error is coming from. See M-: (info "(elisp) Debugger") for details of how to use the debugger.
One more handy trick: M-x eldoc-mode - when your point is inside a function you can see the required and optional arguments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.