all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 16017@debbugs.gnu.org
Subject: bug#16017: 24.3.50; windmove is broken
Date: Tue, 03 Dec 2013 12:44:23 +0100	[thread overview]
Message-ID: <529DC417.1080806@gmx.at> (raw)
In-Reply-To: <529CD9F0.3000403@yandex.ru>

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

 >> I'll into this as soon as I sorted out bug 16013 (unless you wanted to
 >> have a look).
 >
 > Please do. I'm sure you understand the problem area better, and there
 > are other issues I'd rather devote attention to.

IIUC the bug happens only in a window whose subwindow does not have an
integral number of lines like in a maximized frame.  Is that correct?

Here on a maximized frame with two windows above each other and the
upper one selected the following happens

(window-height) => 30
(window-pixel-height) => 484

so the selected window has 484 / 16 lines which is larger than 30.

Now `windmove-other-window-loc' with DIR 'down does

             (+ (1- (nth 3 edges))
                windmove-window-distance-delta))) ; (x, y1+d-1)

and returns 30.  `window-at' returns the selected window since that
window extends until after line 30 and windmove doesn't move because the
target window is the selected one.

In the long run I'd like to use `window-in-direction' here because it
doesn't suffer this problem. Meanwhile I can offer the attached patch
(although I'm not sure whether it is really better than customizing
`windmove-window-distance-delta').

martin


BTW: If you want to test `window-in-direction' directly you can try the
following instead:

(defun select-window-on-left ()
   "Select window on the left."
   (interactive)
   (select-window (window-in-direction 'left)))

(defun select-window-above ()
   "Select window above."
   (interactive)
   (select-window (window-in-direction 'above)))

(defun select-window-on-right ()
   "Select window on the right."
   (interactive)
   (select-window (window-in-direction 'right)))

(defun select-window-below ()
   "Select window below."
   (interactive)
   (select-window (window-in-direction 'below)))

(defun select-window-keybindings (&optional modifier)
   "Set up keybindings as in windmove."
   (interactive)
   (unless modifier (setq modifier 'shift))
   (global-set-key (vector (list modifier 'left))  'select-window-on-left)
   (global-set-key (vector (list modifier 'right)) 'select-window-on-right)
   (global-set-key (vector (list modifier 'up))    'select-window-above)
   (global-set-key (vector (list modifier 'down))  'select-window-below))

[-- Attachment #2: windmove.diff --]
[-- Type: text/plain, Size: 1642 bytes --]

=== modified file 'lisp/windmove.el'
--- lisp/windmove.el	2013-01-01 09:11:05 +0000
+++ lisp/windmove.el	2013-12-03 10:19:43 +0000
@@ -438,24 +438,28 @@
 to.  DIR is one of `left', `up', `right', or `down'; an optional ARG
 is handled as by `windmove-reference-loc'; WINDOW is the window that
 movement is relative to."
-  (let ((edges (window-edges window))   ; edges: (x0, y0, x1, y1)
+  (let ((edges (window-pixel-edges window))   ; edges: (x0, y0, x1, y1)
         (refpoint (windmove-reference-loc arg window))) ; (x . y)
     (cond
      ((eq dir 'left)
-      (cons (- (nth 0 edges)
+      (cons (- (ceiling (nth 0 edges)
+			(frame-char-width (window-frame window)))
                windmove-window-distance-delta)
             (cdr refpoint)))            ; (x0-d, y)
      ((eq dir 'up)
       (cons (car refpoint)
-            (- (nth 1 edges)
+            (- (ceiling (nth 1 edges)
+			(frame-char-height (window-frame window)))
                windmove-window-distance-delta))) ; (x, y0-d)
      ((eq dir 'right)
-      (cons (+ (1- (nth 2 edges))	; -1 to get actual max x
+      (cons (+ (1- (ceiling (nth 2 edges)
+			    (frame-char-width (window-frame window))))	; -1 to get actual max x
                windmove-window-distance-delta)
             (cdr refpoint)))            ; (x1+d-1, y)
      ((eq dir 'down)			; -1 to get actual max y
       (cons (car refpoint)
-            (+ (1- (nth 3 edges))
+            (+ (1- (ceiling (nth 3 edges)
+			    (frame-char-height (window-frame window))))
                windmove-window-distance-delta))) ; (x, y1+d-1)
      (t (error "Invalid direction of movement: %s" dir)))))




  reply	other threads:[~2013-12-03 11:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-01  1:52 bug#16017: 24.3.50; windmove is broken Dmitry Gutov
2013-12-02  7:38 ` martin rudalics
2013-12-02 10:29   ` Dmitry Gutov
2013-12-02 14:38     ` Stefan Monnier
2013-12-02 18:16       ` martin rudalics
2013-12-02 18:16     ` martin rudalics
2013-12-02 19:05       ` Dmitry Gutov
2013-12-03 11:44         ` martin rudalics [this message]
2013-12-04  0:58           ` Dmitry Gutov
2013-12-04 14:31             ` martin rudalics
2013-12-04 22:13               ` Dmitry Gutov
2013-12-05  6:59                 ` martin rudalics
2013-12-05 10:53                   ` Dmitry Gutov
2013-12-13 17:23                     ` martin rudalics
2013-12-15 13:49                       ` Dmitry Gutov
2013-12-16 10:13                         ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=529DC417.1080806@gmx.at \
    --to=rudalics@gmx.at \
    --cc=16017@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.