all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* upgrading from 21.2.1 to 21.3.50.1
@ 2006-10-26 20:16 Eric Twietmeyer
  2006-10-26 23:53 ` Eric Twietmeyer
  2006-10-27  8:50 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Twietmeyer @ 2006-10-26 20:16 UTC (permalink / raw)


Hello,

I just upgraded my local emacs to version 21.3.50.1 (which may be
cygwin specific, and which according to
http://www.cygwin.com/ml/cygwin/2005-03/msg00529.html is the same as
22.0.50).

The problem I'm having is that a library I have been carrying around
with me for about 10 years now has stopped working as it used to.  It
is a very small thing, but I don't know enough about debugging elisp to
know how to fix it.  Basically it simply defines 3 sparse keymaps for
the f1, f3, and f4 keys so that you can hit "<f1> <up>" for instance
and move to the window in the current frame "above" the currently
active window.

Now that I have upgraded, the <left> and <right> directions work to
move to, create, or delete a window, but the <up> and <down> directions
don't work.  They don't work if I execute the command directly either,
so somehow things changed internally, it isn't something as simple as
the key bindings being screwed up.

Anyway, here is the code.  Any help would be hugely appreciated.
Thanks so much!

-Eric Twietmeyer


;; Brief-like window manipulation
;; Dan Schmidt, 5/6/96
;;
;; F1 plus a direction goes to that window
;; F3 plus a direction creates a window over there
;; F4 plus a direction deletes that window
;;
;; To do:
;;
;; - F2 window resizing
;;
;; - F1 should work across frames, argh

(defun find-nearby-window (dx dy)
  "Return the nearest window in the direction of DX DY,
or nil if there is none."
  (let* ((this-window (selected-window)) ; current window
         (we (window-edges))            ; its coordinates
         (x0 (nth 0 we))
         (y0 (nth 1 we))
         (x1 (nth 2 we))
         (y1 (nth 3 we))
;        (x (/ (+ x0 x1) 2))            ; x-y location of
;        (y (/ (+ y0 y1) 2))            ; center of window
;        (x x0) (y y0)                  ; I think UL of window works
better
	 (x (+ x0 (current-column)))
	 (y (+ y0
	       (if (= (point) (point-max))
		   (+ 1 (count-lines (window-start) (point)))
	       (count-lines (window-start) (+ 1 (point))))))
         (new-window))
    (catch 'look
      (while t
        (setq x (+ x dx))               ; keep moving
        (setq y (+ y dy))
        (setq new-window (window-at x y))
        ;; Don't go off-screen, or into the minibuffer unless it's
active.
        (if (or (null new-window)
                (and (window-minibuffer-p new-window)
                     (not (eq new-window (active-minibuffer-window)))))
            (throw 'look nil))          ; off screen
        (if (not (equal new-window this-window))
            (throw 'look new-window)))))) ; found a new one


(defun move-to-nearby-window (dx dy)
  "Move to the nearest window in the direction of DX DY if possible."
  (let ((new-window (find-nearby-window dx dy)))
    (if new-window
        (select-window new-window))))

(defun delete-nearby-window (dx dy)
  "Delete the nearest window in the direction of DX DY if possible."
  (let ((new-window (find-nearby-window dx dy)))
    (if new-window
        (delete-window new-window))))



(defun create-new-window-up ()
  "Create a new window above the current one."
  (interactive)
  (let ((this-window (selected-window))
        (new-window (split-window-vertically)))
    ;; We've split the window vertically, now make sure that
    ;; the new window is above the current one.
    (if (< (nth 1 (window-edges new-window))
           (nth 1 (window-edges this-window)))
        (select-window new-window))))

(defun create-new-window-down ()
  "Create a new window below the current one."
  (interactive)
  (let ((this-window (selected-window))
        (new-window (split-window-vertically)))
    (if (> (nth 1 (window-edges new-window))
           (nth 1 (window-edges this-window)))
        (select-window new-window))))

(defun create-new-window-left ()
  "Create a new window to the left of the current one."
  (interactive)
  (let ((this-window (selected-window))
        (new-window (split-window-horizontally)))
    (if (< (nth 0 (window-edges new-window))
           (nth 0 (window-edges this-window)))
        (select-window new-window))))

(defun create-new-window-right ()
  "Create a new window to the right of the current one."
  (interactive)
  (let ((this-window (selected-window))
        (new-window (split-window-horizontally)))
    (if (> (nth 0 (window-edges new-window))
           (nth 0 (window-edges this-window)))
        (select-window new-window))))



(defun move-up-to-window ()
  "Move up to the next window."
  (interactive)
  (move-to-nearby-window 0 -1))

(defun move-down-to-window ()
  "Move down to the next window."
  (interactive)
  (move-to-nearby-window 0 1))

(defun move-left-to-window ()
  "Move left to the next window."
  (interactive)
  (move-to-nearby-window -1 0))

(defun move-right-to-window ()
  "Move right to the next window."
  (interactive)
  (move-to-nearby-window 1 0))



(defun delete-up-window ()
  "Delete the window above this one."
  (interactive)
  (delete-nearby-window 0 -1))

(defun delete-down-window ()
  "Delete the window below this one."
  (interactive)
  (delete-nearby-window 0 1))

(defun delete-left-window ()
  "Delete the window to the left of this one."
  (interactive)
  (delete-nearby-window -1 0))

(defun delete-right-window ()
  "Delete the window to the right of this one."
  (interactive)
  (delete-nearby-window 1 0))


(defvar f1-map (make-sparse-keymap) "Keymap for F1.")
(define-key global-map [f1]       f1-map)

(define-key f1-map     [up]      'move-up-to-window)
(define-key f1-map     [down]    'move-down-to-window)
(define-key f1-map     [left]    'move-left-to-window)
(define-key f1-map     [right]   'move-right-to-window)


(defvar f3-map (make-sparse-keymap) "Keymap for F3.")
(define-key global-map [f3]       f3-map)

(define-key f3-map     [up]      'create-new-window-up)
(define-key f3-map     [down]    'create-new-window-down)
(define-key f3-map     [left]    'create-new-window-left)
(define-key f3-map     [right]   'create-new-window-right)


(defvar f4-map (make-sparse-keymap) "Keymap for F4.")
(define-key global-map [f4]       f4-map)

(define-key f4-map     [up]      'delete-up-window)
(define-key f4-map     [down]    'delete-down-window)
(define-key f4-map     [left]    'delete-left-window)
(define-key f4-map     [right]   'delete-right-window)

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

* Re: upgrading from 21.2.1 to 21.3.50.1
  2006-10-26 20:16 upgrading from 21.2.1 to 21.3.50.1 Eric Twietmeyer
@ 2006-10-26 23:53 ` Eric Twietmeyer
  2006-10-27  8:50 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Twietmeyer @ 2006-10-26 23:53 UTC (permalink / raw)


To follow up with this: It appears that the initial call to
(window-edges) is returning incorrect values.  When I put the point in
one of the windows and Esc - : to eval (window_edges), the 4 numbers I
get seem incorrect.  The y values are wrong.  For instance, if I have
my main frame split into 4 windows and place the point in the upper
left window, then I get a bottom left coordinate of (0,0), which is
obviously incorrect.  If I place the point in the lower left window and
execute (window-edges) then I get a lower left point of (0,52), which
is the coordinate of the lower left of the upper left window.

The x values always seem correct.  Is it possible that this version of
emacs has a bad implementation of (window_edges)?  It appears this
function is not implemented in elisp itself, so I don't have it
available.

Anyway, if anyone has further info...

Thanks!

Eric Twietmeyer

Eric Twietmeyer wrote:
> Hello,
>
> I just upgraded my local emacs to version 21.3.50.1 (which may be
> cygwin specific, and which according to
> http://www.cygwin.com/ml/cygwin/2005-03/msg00529.html is the same as
> 22.0.50).
>
> The problem I'm having is that a library I have been carrying around
> with me for about 10 years now has stopped working as it used to.  It
> is a very small thing, but I don't know enough about debugging elisp to
> know how to fix it.  Basically it simply defines 3 sparse keymaps for
> the f1, f3, and f4 keys so that you can hit "<f1> <up>" for instance
> and move to the window in the current frame "above" the currently
> active window.
>
> Now that I have upgraded, the <left> and <right> directions work to
> move to, create, or delete a window, but the <up> and <down> directions
> don't work.  They don't work if I execute the command directly either,
> so somehow things changed internally, it isn't something as simple as
> the key bindings being screwed up.
>
> Anyway, here is the code.  Any help would be hugely appreciated.
> Thanks so much!
>
> -Eric Twietmeyer
>
>
> ;; Brief-like window manipulation
> ;; Dan Schmidt, 5/6/96
> ;;
> ;; F1 plus a direction goes to that window
> ;; F3 plus a direction creates a window over there
> ;; F4 plus a direction deletes that window
> ;;
> ;; To do:
> ;;
> ;; - F2 window resizing
> ;;
> ;; - F1 should work across frames, argh
>
> (defun find-nearby-window (dx dy)
>   "Return the nearest window in the direction of DX DY,
> or nil if there is none."
>   (let* ((this-window (selected-window)) ; current window
>          (we (window-edges))            ; its coordinates
>          (x0 (nth 0 we))
>          (y0 (nth 1 we))
>          (x1 (nth 2 we))
>          (y1 (nth 3 we))
> ;        (x (/ (+ x0 x1) 2))            ; x-y location of
> ;        (y (/ (+ y0 y1) 2))            ; center of window
> ;        (x x0) (y y0)                  ; I think UL of window works
> better
> 	 (x (+ x0 (current-column)))
> 	 (y (+ y0
> 	       (if (= (point) (point-max))
> 		   (+ 1 (count-lines (window-start) (point)))
> 	       (count-lines (window-start) (+ 1 (point))))))
>          (new-window))
>     (catch 'look
>       (while t
>         (setq x (+ x dx))               ; keep moving
>         (setq y (+ y dy))
>         (setq new-window (window-at x y))
>         ;; Don't go off-screen, or into the minibuffer unless it's
> active.
>         (if (or (null new-window)
>                 (and (window-minibuffer-p new-window)
>                      (not (eq new-window (active-minibuffer-window)))))
>             (throw 'look nil))          ; off screen
>         (if (not (equal new-window this-window))
>             (throw 'look new-window)))))) ; found a new one
>
>
> (defun move-to-nearby-window (dx dy)
>   "Move to the nearest window in the direction of DX DY if possible."
>   (let ((new-window (find-nearby-window dx dy)))
>     (if new-window
>         (select-window new-window))))
>
> (defun delete-nearby-window (dx dy)
>   "Delete the nearest window in the direction of DX DY if possible."
>   (let ((new-window (find-nearby-window dx dy)))
>     (if new-window
>         (delete-window new-window))))
>
>
>
> (defun create-new-window-up ()
>   "Create a new window above the current one."
>   (interactive)
>   (let ((this-window (selected-window))
>         (new-window (split-window-vertically)))
>     ;; We've split the window vertically, now make sure that
>     ;; the new window is above the current one.
>     (if (< (nth 1 (window-edges new-window))
>            (nth 1 (window-edges this-window)))
>         (select-window new-window))))
>
> (defun create-new-window-down ()
>   "Create a new window below the current one."
>   (interactive)
>   (let ((this-window (selected-window))
>         (new-window (split-window-vertically)))
>     (if (> (nth 1 (window-edges new-window))
>            (nth 1 (window-edges this-window)))
>         (select-window new-window))))
>
> (defun create-new-window-left ()
>   "Create a new window to the left of the current one."
>   (interactive)
>   (let ((this-window (selected-window))
>         (new-window (split-window-horizontally)))
>     (if (< (nth 0 (window-edges new-window))
>            (nth 0 (window-edges this-window)))
>         (select-window new-window))))
>
> (defun create-new-window-right ()
>   "Create a new window to the right of the current one."
>   (interactive)
>   (let ((this-window (selected-window))
>         (new-window (split-window-horizontally)))
>     (if (> (nth 0 (window-edges new-window))
>            (nth 0 (window-edges this-window)))
>         (select-window new-window))))
>
>
>
> (defun move-up-to-window ()
>   "Move up to the next window."
>   (interactive)
>   (move-to-nearby-window 0 -1))
>
> (defun move-down-to-window ()
>   "Move down to the next window."
>   (interactive)
>   (move-to-nearby-window 0 1))
>
> (defun move-left-to-window ()
>   "Move left to the next window."
>   (interactive)
>   (move-to-nearby-window -1 0))
>
> (defun move-right-to-window ()
>   "Move right to the next window."
>   (interactive)
>   (move-to-nearby-window 1 0))
>
>
>
> (defun delete-up-window ()
>   "Delete the window above this one."
>   (interactive)
>   (delete-nearby-window 0 -1))
>
> (defun delete-down-window ()
>   "Delete the window below this one."
>   (interactive)
>   (delete-nearby-window 0 1))
>
> (defun delete-left-window ()
>   "Delete the window to the left of this one."
>   (interactive)
>   (delete-nearby-window -1 0))
>
> (defun delete-right-window ()
>   "Delete the window to the right of this one."
>   (interactive)
>   (delete-nearby-window 1 0))
>
>
> (defvar f1-map (make-sparse-keymap) "Keymap for F1.")
> (define-key global-map [f1]       f1-map)
>
> (define-key f1-map     [up]      'move-up-to-window)
> (define-key f1-map     [down]    'move-down-to-window)
> (define-key f1-map     [left]    'move-left-to-window)
> (define-key f1-map     [right]   'move-right-to-window)
>
>
> (defvar f3-map (make-sparse-keymap) "Keymap for F3.")
> (define-key global-map [f3]       f3-map)
>
> (define-key f3-map     [up]      'create-new-window-up)
> (define-key f3-map     [down]    'create-new-window-down)
> (define-key f3-map     [left]    'create-new-window-left)
> (define-key f3-map     [right]   'create-new-window-right)
>
>
> (defvar f4-map (make-sparse-keymap) "Keymap for F4.")
> (define-key global-map [f4]       f4-map)
>
> (define-key f4-map     [up]      'delete-up-window)
> (define-key f4-map     [down]    'delete-down-window)
> (define-key f4-map     [left]    'delete-left-window)
> (define-key f4-map     [right]   'delete-right-window)

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

* Re: upgrading from 21.2.1 to 21.3.50.1
  2006-10-26 20:16 upgrading from 21.2.1 to 21.3.50.1 Eric Twietmeyer
  2006-10-26 23:53 ` Eric Twietmeyer
@ 2006-10-27  8:50 ` Eli Zaretskii
  2006-10-27 12:12   ` Kim F. Storm
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2006-10-27  8:50 UTC (permalink / raw)


> From: "Eric Twietmeyer" <zimbus26@yahoo.com>
> Date: 26 Oct 2006 13:16:05 -0700
> 
> I just upgraded my local emacs to version 21.3.50.1 (which may be
> cygwin specific, and which according to
> http://www.cygwin.com/ml/cygwin/2005-03/msg00529.html is the same as
> 22.0.50).

I suggest to send messages about the CVS version of Emacs to
emacs-devel@gnu.org, not to this forum.  You will find much more help
there.

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

* Re: upgrading from 21.2.1 to 21.3.50.1
  2006-10-27  8:50 ` Eli Zaretskii
@ 2006-10-27 12:12   ` Kim F. Storm
  0 siblings, 0 replies; 4+ messages in thread
From: Kim F. Storm @ 2006-10-27 12:12 UTC (permalink / raw)
  Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Eric Twietmeyer" <zimbus26@yahoo.com>
>> Date: 26 Oct 2006 13:16:05 -0700
>> 
>> I just upgraded my local emacs to version 21.3.50.1 (which may be
>> cygwin specific, and which according to
>> http://www.cygwin.com/ml/cygwin/2005-03/msg00529.html is the same as
>> 22.0.50).
>
> I suggest to send messages about the CVS version of Emacs to
> emacs-devel@gnu.org, not to this forum.  You will find much more help
> there.

In any case, a version named 21.3.50.1 is a very old version of CVS emacs.
Try a more recent build to see if the problem still exists.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

end of thread, other threads:[~2006-10-27 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-26 20:16 upgrading from 21.2.1 to 21.3.50.1 Eric Twietmeyer
2006-10-26 23:53 ` Eric Twietmeyer
2006-10-27  8:50 ` Eli Zaretskii
2006-10-27 12:12   ` Kim F. Storm

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.