2

I am trying to define this seemingly innocuous function:

(defun previous-window () (interactive) (other-window -1)) (define-key evil-window-map (kbd "o") 'previous-window)

and I am running into this problem:

Debugger entered--Lisp error: (wrong-number-of-arguments (lambda nil (interactive) (other-window -1)) 3) previous-window(#<window 6 on *scratch*> nil nil) byte-code(...) #[(count &optional all-frames) "..." ad-Advice-other-window(#[(count &optional all-frames) "..." apply(ad-Advice-other-window #[(count &optional all-frames) "..." other-window(-1) previous-window() call-interactively(previous-window nil nil) command-execute(previous-window)

If I change that -1 to 1, everything works fine. The documentation for other-window

other-window is an interactive compiled Lisp function in `window.el'.

It is bound to C-x o.

(other-window COUNT &optional ALL-FRAMES)

:around advice: `ad-Advice-other-window'

Select another window in cyclic ordering of windows. COUNT specifies the number of windows to skip, starting with the selected window, before making the selection. If COUNT is positive, skip COUNT windows forwards. If COUNT is negative, skip -COUNT windows backwards. COUNT zero means do not skip any window, so select the selected window. In an interactive call, COUNT is the numeric prefix argument. Return nil.

states clearly that negative arguments are used to cycle backwards. Therefore, this is really weird to me. Has it got anything to do with an interactive call? Can someone please explain what is going on here?

I am using GNU Emacs 24.5.1.

Thanks.

  • Possibly related to the advice? Try removing it to see if the problem persists. M-: (advice-remove 'other-window 'ad-Advice-other-window). – JeanPierre Mar 10 '16 at 6:48
  • Hi @JeanPierre. Thanks for helping. Removing the advice made no difference. :( – asb Mar 10 '16 at 8:54
2

The problem is that there's a function previous-window that is called by other-window. Use another name:

(defun my-previous-window ()
  (interactive)
  (other-window -1))
| improve this answer | |
  • 1
    Ah, crap! Thank you so much. This was ridiculous. – asb Mar 10 '16 at 9:46

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.