From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: move_it_vertically_backward question Date: Tue, 14 Dec 2021 21:28:44 +0800 Message-ID: <875yrrtiwj.fsf@yahoo.com> References: <87lf0pw78r.fsf.ref@yahoo.com> <87lf0pw78r.fsf@yahoo.com> <837dc8mue3.fsf@gnu.org> <874k7cuhv4.fsf@yahoo.com> <83lf0nl56t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38790"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 14 14:53:27 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mx8FD-0009sL-0c for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Dec 2021 14:53:27 +0100 Original-Received: from localhost ([::1]:42302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mx8FB-0005Mz-NA for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Dec 2021 08:53:25 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mx7rZ-0006VU-3m for emacs-devel@gnu.org; Tue, 14 Dec 2021 08:29:01 -0500 Original-Received: from sonic315-20.consmr.mail.ne1.yahoo.com ([66.163.190.146]:44972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mx7rW-00032H-JT for emacs-devel@gnu.org; Tue, 14 Dec 2021 08:29:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1639488536; bh=6gbaGdrtePFqEXPV5UqBF5UFqoqdGNw2jwPwTljOVfw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=QggO/EBGNmae6ujnucSZrRUdc0RUwSjlinHg83beMmp8Ly+fWwWFytCii5qCy2md7DFABILFn3I9Qn7awfNGctCIyrhl9s+3dmLm+QWAdvRQ4+Rs6zJEXuiiI5HN41NHVpWyHb3bC9yuP9kxKdkpEYNDn3E5G2PT18TZ0yULu7UpIn6/VqA1ao125tgoEYs924sJBRU4bLrLSbP+iblSkXZt/L9lahTONID8uEyxHxz6Xurd8HTv0x3nveHVVNVak1xB+he4L8PihJ9h9VdgwBfrkeROkK0UpuA45sg3qMuX5jxeGYpkhMggV/Q/22aubdf3dVI0Om9xN3ZA5yWTfg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1639488536; bh=jIeiKyZ8macjCXDSgCCTdDZwnzn6hSHbztGi9DijEo6=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=SCcGn0qtRdkjPR5TBnT3WaROTKhSJCqQV7Ug7OYEX91+tXNCk5yoPwcjh1Qv4B3Tdx8CyQuI+uUtr+HKmz9nJefA4W5nm5dxBJ2mKTU67N4qFn3JyhizLnFzNmQTjqXV+yAyiqwP622UVB2KljPWMJU6dYMrIj3jnoNCZKt3qaJkrI6zIlgBOyerRm0FeVJgJ2M8NTPv0kv2W2P7yoFpIuvE2QkB2UDRdHpQdOvoPFUy9mQgbkViLXY/H1YMIwFG8D6MlOvYn9nBd+ZTtkJORmxB/OW99CEwPQ4XRBW0UuIOTakRZRTySWp46Z8j2QgTD6S1CJCi/2VMorNfUbNOrQ== X-YMail-OSG: T57np_EVM1l7SAI3SeBvy2YjmKXEgnuovtKACYcmLXxIPxLjXg0iO7TMXRpn8R0 FqS_CKB75_dkDl2gVn7uFKRIaQfFD1Fjriz4SPR3ezzFREDwg9KeqDa0cwN3sjdOgFutH3j1U1nO rhRyiOucM953Gln92Az3fv67JYyalyUUacprxBrgguJE1NVlPxW_LRQsdBDFgO5MCaD6U0KZD21B BLGnko49px6USCFuV3nIrtMHUiSweEyN_7sSX2babFtIKmb5TE_743782PmkdA0GW.s1mzn56iqN qPC4hWssiNKa2zGPBAVCfngXgmGi9HskVWei0kvyLMMdqcsx1ptOZHuvYjWHQbuZA8TIxR5yZbIg ZVQKBsjGh6P8XJbc7BlshHGVkNOMyHK.5aEs5iSkd2yRYhnbC4YFghpufo0s7JuKYVuX.q5mNln7 8tt8oDsaGskwGzunK52yueqi3OStsVY8qBo7cyQDAntvTspeK_81NERSGzkkgdGWEVpAQP8Z3.CX .853ulBrQZSJDgrTsMLgSDTS4g7ab.gCTnyS1SnUXo.6ERTBcfcLjI331zXKYyNjg8BKgr01ALro c7iDrcoiIJZMUN7pqJvDODCl9t8Yds.bj1iZn1SovCw3uJfO2DCozEUDR02WE6WLe7qgDjhzuSv8 xjOANIupV7s.KjiCAZYDcp91hQlItR36kzCX_JJz_JiZTQBEFgXsUNBYBPLeYT8072vzPg0138G9 gPZ8pXYZgKOznZQPRTCh1mRwJfAXmeGxUsZtTHCS13M2mjmauxrolmZqeeBSb5PxefRamlHBgcpt GOWKg5j1lcjsl.1L2EyysLK9mGIqOuvAzoqOWCMknh X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Tue, 14 Dec 2021 13:28:56 +0000 Original-Received: by kubenode510.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 44637dd3d6e3a2d6ccdc0bf61cc0af78; Tue, 14 Dec 2021 13:28:49 +0000 (UTC) In-Reply-To: <83lf0nl56t.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 14 Dec 2021 14:52:10 +0200") X-Mailer: WebService/1.1.19415 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.190.146; envelope-from=luangruo@yahoo.com; helo=sonic315-20.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:281898 Archived-At: Eli Zaretskii writes: > Extending an existing primitive will give you the same performance as > a new primitive. But it will also save you from reinventing the wheel > and from having to deal with all the subtleties of primitives that > simulate display to find some place or measure of the text as it will > be on display. > I'm saying that extending an existing primitive to cover your use case > might be a better way forward. I don't know of any existing primitive that may make sense to extend in this manner though. > Which might mean that window-text-pixel-size should support a > specification of FROM and TO that is not just buffer position, but > something like "beginning of previous line". Yes, but that would still entail having to repetitively loop in Lisp until the desired position is found, assuming the delta by which we are scrolling is larger than the height of the previous screen line, while this primitive looks for a line that is at least a specified amount of pixels above the window start, which lets us avoid the extra looping in Lisp if the line is not tall enough. Also, for the result to be useful, `window-text-pixel-size' would also have to return the buffer position of the measured line's start, which doesn't make sense for a function that is only intended to measure size. > So to move back, you need first go far enough back (e.g., with > move_it_vertically_backward), then move forward to find the place > where you wanted to find yourself wrt the starting point. Se an > example in move_it_by_lines. Thanks. Something like this seems to work: while (-it.current_y < pix) { last_y = it.current_y; move_it_by_lines (&it, -1); } But I have a few questions: what is TRT if `move_it_by_lines' can't move further back? And also, does `move_it_by_lines' (or for that matter, the move_it_* functions in general) only move within the accessible portion of the buffer, or does narrowing have to be handled in some specific manner? Thanks.