iceman
iceman

Reputation: 2130

Elisp: simple function to split window and move cursor to new window

I feel dumb posting this but I really have no idea why this function doesn't compile:

(defun dc/split-window-below-and-move-cursor ()
  (interactive)
  (split-window-below)
  (other-window 1))

Am I overlooking something super obvious?

Here's the error message:

Symbol's function definition is void: split-window-below

Update: So I tried it in another file (on a fresh Emacs session) and it worked fine. (Taking out progn and putting in (interactive) didn't resolve it either - I've updated the code above to reflect this change.)

Update 2: Okay, this is just silly. The following code works fine but I still can't get the defun code above to work. Would still be very curious to understand what's causing this behavior, if anyone has ideas.

(global-set-key (kbd "s--") (lambda() (interactive) (split-window-below) (other-window 1)))

Upvotes: 1

Views: 555

Answers (1)

abo-abo
abo-abo

Reputation: 20372

No need for progn, but you need interactive:

(defun dc/split-window-below-and-move-cursor ()
  (interactive)
  (split-window-below)
  (other-window 1))

Upvotes: 2

Related Questions