emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: other-window-or-frame


From: Kevin Rodgers
Subject: Re: other-window-or-frame
Date: Wed, 01 Feb 2006 12:13:34 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Kevin Rodgers wrote:
Drew Adams wrote:
If a frame is `one-window-p', command `other-window' silently does nothing.
It might be better to let it do `other-frame' in that case. The optional
second arg to `other-window' is not accessible interactively anyway, so what
about this:

1. Bind a new command to `C-x o', to replace `other-window'. It would do the
same thing except when `one-window-p' - in that case, it would do
`other-frame'.

2. Keep function `other-window' as is (with its second arg), for Lisp.

IOW (but with a better doc string):

 (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)))

 (define-key ctl-x-map "o" 'other-window-or-frame)

Actually, now that you mention it, I've just added this to my .emacs:

(defadvice other-window (before one-window-p activate)
  "If there are no other windows, signal an error."
  (when (one-window-p)
    (error "No other windows")))

(defadvice other-frame (before one-frame-p activate)
  "If there are no other frames, signal an error."
  (when (= (length (frame-list)) 1)
    (error "No other frames")))

Just to follow up: Experience proved that to be completely unsatisfactory
since the advice affects all calls to those functions.  This is better:

(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")))

(setq debug-ignored-errors
      (cons "\\`No other \\(window\\|frame\\)s\\'" debug-ignored-errors))

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]