简体   繁体   中英

Emacs Defining Function Calling other-window with an Argument Doesn't Work

In Emacs, I would like to define a lisp function to call other-window with an argument of -1 in order to switch to the previous window in the same frame. According to my best research, it should be possible to do this as follows in my emacs file:

(defun previous-window ()
  (interactive)
  (other-window -1))

However, when I run the function:

M-x previous-window

I get this:

Wrong number of arguments: (lambda nil (interactive) (other-window -1)), 3

Also, weirdly, now when I do this:

C-u - C-x o

I get:

Wrong number of arguments: (lambda nil (interactive) (other-window -1)), 3

If I remove the above function definition from my emacs file, and do this:

C-u - C-x o

the behavior is as expected.

There does not seem to be a previous definition of previous-window in emacs.

Scratching my head here.

您可以使用Cu - C xo (其中C xoother-window的常规键绑定,但是您使用的更长的Mx other-window方法也可以使用),因为-本身表示数字前缀参数-1。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM