From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Getting column position accounting for overlays Date: Sat, 08 Aug 2015 18:43:31 +0300 Message-ID: <831tfdrdjw.fsf@gnu.org> References: <83a8u6tplx.fsf@gnu.org> <55C1D323.50505@thregr.org> <831tfhu5ge.fsf@gnu.org> <55C25983.5040702@thregr.org> <83vbctsgo6.fsf@gnu.org> <55C4E756.5020607@thregr.org> <83r3nfq7uq.fsf@gnu.org> <8337ztrg98.fsf@gnu.org> <55C61DE6.7050706@thregr.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1439048638 32256 80.91.229.3 (8 Aug 2015 15:43:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Aug 2015 15:43:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: Yuri D'Elia Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 08 17:43:50 2015 Return-path: Envelope-to: ged-emacs-devel@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 1ZO6Hl-0007fm-6N for ged-emacs-devel@m.gmane.org; Sat, 08 Aug 2015 17:43:49 +0200 Original-Received: from localhost ([::1]:53123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZO6Hk-0003Bj-4F for ged-emacs-devel@m.gmane.org; Sat, 08 Aug 2015 11:43:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZO6HY-0003Bb-9u for emacs-devel@gnu.org; Sat, 08 Aug 2015 11:43:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZO6HV-0001Q9-3G for emacs-devel@gnu.org; Sat, 08 Aug 2015 11:43:36 -0400 Original-Received: from mtaout26.012.net.il ([80.179.55.182]:33628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZO6HU-0001Q5-RV for emacs-devel@gnu.org; Sat, 08 Aug 2015 11:43:33 -0400 Original-Received: from conversion-daemon.mtaout26.012.net.il by mtaout26.012.net.il (HyperSendmail v2007.08) id <0NSR00900T3LZ000@mtaout26.012.net.il> for emacs-devel@gnu.org; Sat, 08 Aug 2015 18:46:58 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout26.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NSR005LST6AB940@mtaout26.012.net.il>; Sat, 08 Aug 2015 18:46:58 +0300 (IDT) In-reply-to: <55C61DE6.7050706@thregr.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:188617 Archived-At: > From: Yuri D'Elia > Date: Sat, 8 Aug 2015 17:19:02 +0200 > > On 08/08/15 16:45, Eli Zaretskii wrote: > >> Ah yes, but that's precisely the problem: I need to calculate POS > >> beforehand. > > > > Yes, of course. But you will have the same problem if you do get the > > text dimensions: you need to compare that with something to do useful > > things with the value. Right? > > Getting text dimensions was/is sort of a work-around. > If I could get displayed text easily, the iteration over overlays > wouldn't be needed: I could just take the string length. Take the string length and do what with it? And please don't assume that given a string you can compute its visual length easily: you can't, not with variable-pitch fonts. And then you have images, stretches, etc. > Again, it would have problems on its own as we discussed, so far none of > the solutions work perfectly. Solutions to what problem(s)? > To be more concrete, what about a (visual-column) function, that just > gives what's currently needed? I've already shown you a way to compute that, several message ago. Let me repeat: (/ (car (window-text-pixel-size nil (line-beginning-position) (point))) (default-font-width)) > (visual-column &optional logical) > > Return the horizontal position of point. Beginning of the *visual* line > is column 0. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ This is contrary to current-column conventions: it counts from the beginning of the physical line, not visual line. If you want to count from the beginning of the visual line, replace line-beginning-position above with something like (save-excursion (beginning-of-visual-line) (point))