unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* (other-window) with negative argument
@ 2018-12-21 16:55 H. Dieter Wilhelm
  2018-12-21 17:39 ` Stephen Berman
  0 siblings, 1 reply; 4+ messages in thread
From: H. Dieter Wilhelm @ 2018-12-21 16:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hello ()

I can't get a function to work with a negative argument of
(other-window).  When I'm using (other-window -1) in the *scratch*
buffer it is working as expected, as soon as I put it into a function
like the following

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

or 

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

and activate the function any call to (other-window -1) is opening the
debugger!

What am I doing wrong?

Thank you

      Dieter

I'm on "GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2018-06-17"
-- 
Best wishes
H. Dieter Wilhelm
Seeheim-Jugenheim, Germany




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (other-window) with negative argument
  2018-12-21 16:55 (other-window) with negative argument H. Dieter Wilhelm
@ 2018-12-21 17:39 ` Stephen Berman
  2018-12-21 17:46   ` Stephen Berman
  2018-12-21 17:50   ` H. Dieter Wilhelm
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Berman @ 2018-12-21 17:39 UTC (permalink / raw)
  To: H. Dieter Wilhelm; +Cc: help-gnu-emacs

On Fri, 21 Dec 2018 17:55:23 +0100 dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) wrote:

> Hello ()
>
> I can't get a function to work with a negative argument of
> (other-window).  When I'm using (other-window -1) in the *scratch*
> buffer it is working as expected, as soon as I put it into a function
> like the following
>
> (defun previous-window ()
>   (other-window -1))
>
> or 
>
> (defun previous-window ()
>   "blabla"
>   (interactive)
>   (other-window -1))
>
> and activate the function any call to (other-window -1) is opening the
> debugger!
>
> What am I doing wrong?

Redefining a function, previous-window, which is a primitive Emacs
function defined in C.  When other-window has a negative argument, it
calls the built-in previous-window with three arguments, which are
optional in the built-in version, and since your redefinition takes no
arguments, this raises the error.  If you name your function
e.g. my-previous-window, it will work as you expect.

Steve Berman



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (other-window) with negative argument
  2018-12-21 17:39 ` Stephen Berman
@ 2018-12-21 17:46   ` Stephen Berman
  2018-12-21 17:50   ` H. Dieter Wilhelm
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2018-12-21 17:46 UTC (permalink / raw)
  To: H. Dieter Wilhelm, help-gnu-emacs

On Fri, 21 Dec 2018 18:39:28 +0100 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Fri, 21 Dec 2018 17:55:23 +0100 dieter@duenenhof-wilhelm.de (H. Dieter
> Wilhelm) wrote:
>
>> Hello ()
>>
>> I can't get a function to work with a negative argument of
>> (other-window).  When I'm using (other-window -1) in the *scratch*
>> buffer it is working as expected, as soon as I put it into a function
>> like the following
>>
>> (defun previous-window ()
>>   (other-window -1))
>>
>> or 
>>
>> (defun previous-window ()
>>   "blabla"
>>   (interactive)
>>   (other-window -1))
>>
>> and activate the function any call to (other-window -1) is opening the
>> debugger!
>>
>> What am I doing wrong?
>
> Redefining a function, previous-window, which is a primitive Emacs
> function defined in C.  When other-window has a negative argument, it
> calls the built-in previous-window with three arguments, which are
> optional in the built-in version, and since your redefinition takes no
> arguments, this raises the error.  If you name your function
> e.g. my-previous-window, it will work as you expect.

Actually, I think it's irrelevant than previous-window is defined in C;
what causes the error is simply that other-window calls previous-window
with three arguments, but your redefinition takes no arguments.

Steve Berman




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (other-window) with negative argument
  2018-12-21 17:39 ` Stephen Berman
  2018-12-21 17:46   ` Stephen Berman
@ 2018-12-21 17:50   ` H. Dieter Wilhelm
  1 sibling, 0 replies; 4+ messages in thread
From: H. Dieter Wilhelm @ 2018-12-21 17:50 UTC (permalink / raw)
  To: help-gnu-emacs

Stephen Berman <stephen.berman@gmx.net> writes:

Hi Stephen

thank you very much for your prompt explanation. :-)

      Dieter

> On Fri, 21 Dec 2018 17:55:23 +0100 dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) wrote:
>
>> Hello ()
>>
>> I can't get a function to work with a negative argument of
>> (other-window).  When I'm using (other-window -1) in the *scratch*
>> buffer it is working as expected, as soon as I put it into a function
>> like the following
>>
>> (defun previous-window ()
>>   (other-window -1))
>>
>> or 
>>
>> (defun previous-window ()
>>   "blabla"
>>   (interactive)
>>   (other-window -1))
>>
>> and activate the function any call to (other-window -1) is opening the
>> debugger!
>>
>> What am I doing wrong?
>
> Redefining a function, previous-window, which is a primitive Emacs
> function defined in C.  When other-window has a negative argument, it
> calls the built-in previous-window with three arguments, which are
> optional in the built-in version, and since your redefinition takes no
> arguments, this raises the error.  If you name your function
> e.g. my-previous-window, it will work as you expect.
>
> Steve Berman
>
>

-- 
Best wishes
H. Dieter Wilhelm
Seeheim-Jugenheim, Germany




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-21 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-21 16:55 (other-window) with negative argument H. Dieter Wilhelm
2018-12-21 17:39 ` Stephen Berman
2018-12-21 17:46   ` Stephen Berman
2018-12-21 17:50   ` H. Dieter Wilhelm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).