all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* other-window: say there is none if none
@ 2006-11-10 19:22 Dan Jacobson
  2006-11-13  0:39 ` Drew Adams
  2006-11-13 15:50 ` Kevin Rodgers
  0 siblings, 2 replies; 9+ messages in thread
From: Dan Jacobson @ 2006-11-10 19:22 UTC (permalink / raw)


C-x o runs the command other-window. But if there is none, it should
say something, else dumbo me will just keep hitting it.

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

* RE: other-window: say there is none if none
  2006-11-10 19:22 other-window: say there is none if none Dan Jacobson
@ 2006-11-13  0:39 ` Drew Adams
  2006-11-13 15:50 ` Kevin Rodgers
  1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2006-11-13  0:39 UTC (permalink / raw)


> C-x o runs the command other-window. But if there is none, it
> should say something, else dumbo me will just keep hitting it.

It might not be what you would like, but another approach is to call
`other-frame' if there is no other window in the same frame. I bind `C-x o'
to this:

(defun other-window-or-frame (arg)
  "`other-frame', if `one-window-p'; otherwise, `other-window'."
  (interactive "p")
  (if (one-window-p) (other-frame arg) (other-window arg)))

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

* Re: other-window: say there is none if none
  2006-11-10 19:22 other-window: say there is none if none Dan Jacobson
  2006-11-13  0:39 ` Drew Adams
@ 2006-11-13 15:50 ` Kevin Rodgers
  2006-11-13 17:19   ` Juanma Barranquero
  1 sibling, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2006-11-13 15:50 UTC (permalink / raw)


Dan Jacobson wrote:
> C-x o runs the command other-window. But if there is none, it should
> say something, else dumbo me will just keep hitting it.

Here's what I use:

(defadvice other-window (before one-window-p activate)
   "When called interactively, signal an error if there are no other 
windows."
   (when (and (interactive-p) (one-window-p))
     (error "No other windows")))

(defadvice other-frame (before one-frame-p activate)
   "When called interactively, signal an error if there are no other 
frames."
   (when (and (interactive-p) (= (length (frame-list)) 1))
     (error "No other frames")))

-- 
Kevin

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

* Re: other-window: say there is none if none
  2006-11-13 15:50 ` Kevin Rodgers
@ 2006-11-13 17:19   ` Juanma Barranquero
  2006-11-14 12:26     ` Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Juanma Barranquero @ 2006-11-13 17:19 UTC (permalink / raw)
  Cc: bug-gnu-emacs

On 11/13/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:

> (defadvice other-window (before one-window-p activate)
>    "When called interactively, signal an error if there are no other
> windows."
>    (when (and (interactive-p) (one-window-p))
>      (error "No other windows")))

All in all, perhaps something like the following attached patch (based
in your code) would be useful.

                    /L/e/k/t/u


Index: lisp/frame.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/frame.el,v
retrieving revision 1.241
diff -u -2 -r1.241 frame.el
--- lisp/frame.el	23 Sep 2006 09:16:40 -0000	1.241
+++ lisp/frame.el	13 Nov 2006 16:33:56 -0000
@@ -728,5 +728,7 @@
 	(setq frame (previous-frame frame)))
       (setq arg (1+ arg)))
-    (select-frame-set-input-focus frame)))
+    (if (eq frame (next-frame frame))
+        (error "No other frames")
+      (select-frame-set-input-focus frame))))

 (defun iconify-or-deiconify-frame ()
Index: src/window.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.c,v
retrieving revision 1.564
diff -u -2 -r1.564 window.c
--- src/window.c	28 Oct 2006 22:03:51 -0000	1.564
+++ src/window.c	13 Nov 2006 17:12:57 -0000
@@ -1981,8 +1981,9 @@
 {
   Lisp_Object window;
+  Lisp_Object old;
   int i;

   CHECK_NUMBER (arg);
-  window = selected_window;
+  old = window = selected_window;

   for (i = XINT (arg); i > 0; --i)
@@ -1991,5 +1992,9 @@
     window = Fprevious_window (window, Qnil, all_frames);

-  Fselect_window (window, Qnil);
+  if (!EQ (window, old))
+    Fselect_window (window, Qnil);
+  else if (Finteractive_p () && EQ (window, Fnext_window (window, Qnil, Qnil)))
+    error ("No other windows");
+
   return Qnil;
 }

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

* Re: other-window: say there is none if none
  2006-11-13 17:19   ` Juanma Barranquero
@ 2006-11-14 12:26     ` Richard Stallman
  2006-11-14 15:31       ` Juanma Barranquero
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2006-11-14 12:26 UTC (permalink / raw)
  Cc: ihs_4664, bug-gnu-emacs

    -  Fselect_window (window, Qnil);
    +  if (!EQ (window, old))
    +    Fselect_window (window, Qnil);
    +  else if (Finteractive_p () && EQ (window, Fnext_window (window, Qnil, Qnil)))
    +    error ("No other windows");

I am not sure this is a good idea.  Displaying a message can't hurt
when the command is called interactively, but this change would cause
programs that call other-window to get errors where they didn't get
errors before.

This doesn't need to be changed now, so please leave it alone.

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

* Re: other-window: say there is none if none
  2006-11-14 12:26     ` Richard Stallman
@ 2006-11-14 15:31       ` Juanma Barranquero
  0 siblings, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2006-11-14 15:31 UTC (permalink / raw)
  Cc: bug-gnu-emacs

On 11/14/06, Richard Stallman <rms@gnu.org> wrote:

>     -  Fselect_window (window, Qnil);
>     +  if (!EQ (window, old))
>     +    Fselect_window (window, Qnil);
>     +  else if (Finteractive_p () && EQ (window, Fnext_window (window, Qnil, Qnil)))
>     +    error ("No other windows");
>
> Displaying a message can't hurt
> when the command is called interactively, but this change would cause
> programs that call other-window to get errors where they didn't get
> errors before.

Hmmm. According to interactive-p's docstring:

  Return t if the function was run directly by user input.
  This means that the function was called with `call-interactively'
  (which includes being called as the binding of a key)
  and input is currently coming from the keyboard (not in keyboard macro),
  and Emacs is not running in batch mode (`noninteractive' is nil).

so if a program gets an error from a section of code protected by
interactive-p, it is trying *very hard* to fake being interactive, and
it gets what it asked for. :)

> This doesn't need to be changed now, so please leave it alone.

Of course. I was just trying to be helpful. Perhaps Dan wants to patch
his own Emacs :)

                    /L/e/k/t/u

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

* Re: other-window: say there is none if none
@ 2006-11-20 11:32 Dan Jacobson
  2006-11-21 16:14 ` Kevin Rodgers
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Jacobson @ 2006-11-20 11:32 UTC (permalink / raw)


As Juanma showed, RMS's objection is invalid. Proceed with the patch!
...lest the original poster just keep hitting the key.

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

* Re: other-window: say there is none if none
  2006-11-20 11:32 Dan Jacobson
@ 2006-11-21 16:14 ` Kevin Rodgers
  2006-11-21 16:24   ` Juanma Barranquero
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2006-11-21 16:14 UTC (permalink / raw)


Dan Jacobson wrote:
> As Juanma showed, RMS's objection is invalid. Proceed with the patch!
> ...lest the original poster just keep hitting the key.

RMS's objection was two-fold.  Juanma responded with a counterargument
to the first objection, but agreed with the second objection (that this
doesn't *need* to be changed *now*).

If *you* want this behavior, *you* can either patch the source and build
it *yourself* or *you* can customize it via *your* .emacs (like I have
done).

-- 
Kevin

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

* Re: other-window: say there is none if none
  2006-11-21 16:14 ` Kevin Rodgers
@ 2006-11-21 16:24   ` Juanma Barranquero
  0 siblings, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2006-11-21 16:24 UTC (permalink / raw)
  Cc: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

On 11/21/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:

> If *you* want this behavior, *you* can either patch the source and build
> it *yourself*

In fact, here's the patch, with a small fix.

                    /L/e/k/t/u

[-- Attachment #2: dan.patch --]
[-- Type: application/octet-stream, Size: 1446 bytes --]

Index: lisp/frame.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/frame.el,v
retrieving revision 1.241
diff -u -2 -r1.241 frame.el
--- lisp/frame.el	23 Sep 2006 09:16:40 -0000	1.241
+++ lisp/frame.el	15 Nov 2006 16:41:34 -0000
@@ -728,5 +728,7 @@
 	(setq frame (previous-frame frame)))
       (setq arg (1+ arg)))
-    (select-frame-set-input-focus frame)))
+    (if (and (interactive-p) (eq frame (next-frame frame)))
+        (error "No other frames")
+      (select-frame-set-input-focus frame))))
 
 (defun iconify-or-deiconify-frame ()
Index: src/window.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.c,v
retrieving revision 1.564
diff -u -2 -r1.564 window.c
--- src/window.c	28 Oct 2006 22:03:51 -0000	1.564
+++ src/window.c	15 Nov 2006 16:40:43 -0000
@@ -1981,8 +1981,9 @@
 {
   Lisp_Object window;
+  Lisp_Object old;
   int i;
 
   CHECK_NUMBER (arg);
-  window = selected_window;
+  old = window = selected_window;
 
   for (i = XINT (arg); i > 0; --i)
@@ -1991,5 +1992,9 @@
     window = Fprevious_window (window, Qnil, all_frames);
 
-  Fselect_window (window, Qnil);
+  if (!EQ (window, old))
+    Fselect_window (window, Qnil);
+  else if (Finteractive_p () && EQ (window, Fnext_window (window, Qnil, Qnil)))
+    error ("No other windows");
+
   return Qnil;
 }

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

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

end of thread, other threads:[~2006-11-21 16:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-10 19:22 other-window: say there is none if none Dan Jacobson
2006-11-13  0:39 ` Drew Adams
2006-11-13 15:50 ` Kevin Rodgers
2006-11-13 17:19   ` Juanma Barranquero
2006-11-14 12:26     ` Richard Stallman
2006-11-14 15:31       ` Juanma Barranquero
  -- strict thread matches above, loose matches on Subject: below --
2006-11-20 11:32 Dan Jacobson
2006-11-21 16:14 ` Kevin Rodgers
2006-11-21 16:24   ` Juanma Barranquero

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.