GNU bug report logs - #31240
mouse commands not aware of rectangle regions

Previous Next

Package: emacs;

Reported by: charles <at> aurox.ch (Charles A. Roelli)

Date: Sun, 22 Apr 2018 18:35:02 UTC

Severity: normal

Found in version 26.1

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


Message #70 received at 31240 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Federico Tedin <federicotedin <at> gmail.com>
Cc: 31240 <at> debbugs.gnu.org, charles <at> aurox.ch
Subject: Re: bug#31240: 26.1; mouse-save-then-kill does not kill rectangles
Date: Mon, 01 Oct 2018 10:33:52 +0200
> The problem with using just (count-lines (point-min) position) is that
> the return value
> is different when the point is on column 0 and when it is on column 1
> or greater.

OK.  (count-lines (point-min) (point-min)) returns 0 because START and
END are equal so let's assume you want to special-case that.  Now the
problem with your code is that

+          (line (progn
+                  (forward-line 0)
+                  (count-lines (point-min) position))))

probably doesn't do what you expect: The value of POSITION in the call
of 'count-lines' is the _same_ it was before the 'forward-line' call
because 'forward-line' only changes the value of point but not that of
POSITION.  So if you want a possible return value of 0 you have to
write

+          (line (progn
+                  (forward-line 0)
+                  (count-lines (point-min) (point)))))

instead.

> I
> needed to be sure that if the position was anywhere on line N, the
> result was N (with
> N starting at 0).

Agreed, once more.  You want to special-case POSITION on the first
line of the buffer.  But go the ends of the following two forms and
type C-x C-e on each:

(let ((position 3))
  (save-excursion
    (goto-char position)
    (forward-line 0)
    (count-lines (point-min) position)))

(let ((position 3))
  (save-excursion
    (goto-char position)
    (forward-line 0)
    (count-lines (point-min) (point))))

Here the first evaluation gets me 1 and the second 0.  I suppose it's
the latter you want.

martin




This bug report was last modified 6 years and 219 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.