From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#18385: 24.3.93; posn-at-point doesn't account for tab-width Date: Thu, 04 Sep 2014 02:10:42 +0400 Message-ID: <540791E2.5070706@yandex.ru> References: <86ppffuhx3.fsf@yandex.ru> <83k35mf3kz.fsf@gnu.org> <86ha0plhx9.fsf@yandex.ru> <8338c8fzt1.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1409782293 2632 80.91.229.3 (3 Sep 2014 22:11:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Sep 2014 22:11:33 +0000 (UTC) Cc: 18385@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 00:11:24 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XPIls-0001aK-Hx for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Sep 2014 00:11:20 +0200 Original-Received: from localhost ([::1]:47851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPIls-0004jU-1m for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Sep 2014 18:11:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPIli-0004iY-0Q for bug-gnu-emacs@gnu.org; Wed, 03 Sep 2014 18:11:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPIla-000428-Gh for bug-gnu-emacs@gnu.org; Wed, 03 Sep 2014 18:11:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPIla-000424-Ck for bug-gnu-emacs@gnu.org; Wed, 03 Sep 2014 18:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XPIlZ-0000Ld-Kc for bug-gnu-emacs@gnu.org; Wed, 03 Sep 2014 18:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Sep 2014 22:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18385-submit@debbugs.gnu.org id=B18385.14097822551325 (code B ref 18385); Wed, 03 Sep 2014 22:11:01 +0000 Original-Received: (at 18385) by debbugs.gnu.org; 3 Sep 2014 22:10:55 +0000 Original-Received: from localhost ([127.0.0.1]:58189 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPIlS-0000LI-Pl for submit@debbugs.gnu.org; Wed, 03 Sep 2014 18:10:55 -0400 Original-Received: from mail-la0-f54.google.com ([209.85.215.54]:35630) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPIlP-0000L2-Tk for 18385@debbugs.gnu.org; Wed, 03 Sep 2014 18:10:52 -0400 Original-Received: by mail-la0-f54.google.com with SMTP id b17so10856867lan.27 for <18385@debbugs.gnu.org>; Wed, 03 Sep 2014 15:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Mhc+xHVOe0U0WgbeI1Y0VKcavkum9mFzHfYj7CITVJ4=; b=n9u+2fnYBRMgUX0ASs3mVF6WgFeRyuDl6M7zjtQCrEnxa5E2ZlFwZUMecqqYgVvwKO 9btvxInOvcBpswKbFRraVbJpOrfrNLDmgP60rqDK16WC+EBTaOQqaI0bnrBtwtBvVKTR japieUW7PCoS4f7Nt6DiIrLOz4g4FFsWYXGGN1ZUX45xnvhXhGbmQ0taKkXZMkSKhdsX QffG6d7DI15Iyfe8Jsp1JDOQVjvhpCUkhG40JYzT+ZT9fcINfCCYTlci2tQXPk0VyE0H YuOfXA1n2lZ1wJn6XPQdumKFwYF2AakNeBb5iDJSH/kg6Mr83aKVquuv9ulx1tRwlSuS kZ0w== X-Received: by 10.112.173.136 with SMTP id bk8mr244269lbc.88.1409782245845; Wed, 03 Sep 2014 15:10:45 -0700 (PDT) Original-Received: from [192.168.1.3] ([178.252.98.87]) by mx.google.com with ESMTPSA id gn7sm9410009lbc.10.2014.09.03.15.10.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Sep 2014 15:10:44 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: <8338c8fzt1.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:93009 Archived-At: On 09/03/2014 08:12 PM, Eli Zaretskii wrote: > If you want a more accurate description of what happens, it is this: > Glyphs collected for each display line are stored in an array of > structures which specify how to display each glyph (and that includes > the calculated pixel width of the glyphs). What posn-actual-col-row > gives you is the _index_ of the corresponding glyph structure in that > array. Thank you. >> I believe this value wouldn't be properly correct in most contexts, >> even in tty, where the major pitfalls you described can't happen. > > First, ':align-to' display properties are supported on a TTY as well, > as are TABs (of course). But this is actually one more subtle issue > with posn-actual-col-row, because if you try your recipe in a > text-mode frame, you will see that there posn-actual-col-row counts > the TAB as 7 columns, and your recipe works as you expected! Looks like yet another reason not to use this from Lisp code. :) > generates, so it knows what is there. In addition, the "column" > returned by posn-actual-col-row is used there to index into the > header-line string, so again, a pure character count is TRT. Ah, indeed. It's a different application from what I had in mind. > But every complex data structure should have accessor functions to its > parts, and the event structure is no exception. I guess its docstring was that tripped me up. "Actual column" sounds too close to the name of `current-column', which does count character widths. Do you think something like this change would make sense? Or, also, instead of "contain", maybe use "correspond to" (unrelated to the present discussion). === modified file 'lisp/subr.el' --- lisp/subr.el 2014-09-02 15:16:42 +0000 +++ lisp/subr.el 2014-09-03 22:09:02 +0000 @@ -1149,10 +1149,13 @@ (/ (cdr pair) (+ (frame-char-height frame) spacing)))))))) (defun posn-actual-col-row (position) - "Return the actual column and row in POSITION, measured in characters. -These are the actual row number in the window and character number in that row. -Return nil if POSITION does not contain the actual position; in that case + "Return the actual row character number and row number in POSITION. +Return nil if POSITION does not contain an actual position; in that case `posn-col-row' can be used to get approximate values. + +Consider using `posn-col-row' instead either way, because this +function doesn't take character widths into account. + POSITION should be a list of the form returned by the `event-start' and `event-end' functions." (nth 6 position))