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: Sun, 19 Dec 2021 08:54:29 +0800 Message-ID: <87pmptbeii.fsf@yahoo.com> References: <87lf0pw78r.fsf.ref@yahoo.com> <837dc8mue3.fsf@gnu.org> <874k7cuhv4.fsf@yahoo.com> <83lf0nl56t.fsf@gnu.org> <875yrrtiwj.fsf@yahoo.com> <837dc7l2pa.fsf@gnu.org> <87ilvqty24.fsf@yahoo.com> <8335muj8zk.fsf@gnu.org> <87h7bang3d.fsf@yahoo.com> <83mtl1j527.fsf@gnu.org> <87zgp1mldh.fsf@yahoo.com> <83tuf9gdg5.fsf@gnu.org> <87pmpwkikp.fsf@yahoo.com> <83mtl0hnm5.fsf@gnu.org> <87czlwkfpk.fsf@yahoo.com> <8735mskal2.fsf@yahoo.com> <83ee6che8h.fsf@gnu.org> <87y24kisgf.fsf@yahoo.com> <838rwkhcqb.fsf@gnu.org> <87r1achulq.fsf@yahoo.com> <83pmpub41v.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="27541"; 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 Sun Dec 19 01:55:25 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 1mykU1-0006wh-9I for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Dec 2021 01:55:25 +0100 Original-Received: from localhost ([::1]:47572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mykTz-0004Rd-Cp for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 19:55:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mykTJ-0003lF-Dr for emacs-devel@gnu.org; Sat, 18 Dec 2021 19:54:41 -0500 Original-Received: from sonic304-22.consmr.mail.ne1.yahoo.com ([66.163.191.148]:35775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mykTH-0003ag-QN for emacs-devel@gnu.org; Sat, 18 Dec 2021 19:54:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1639875278; bh=euXa2KVvqHwe9K8jYS+DYZtWpe6KUqUjZvXwjJWy6fY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=tWseSJXwFQpqjvOaPpPrgzOuFSH2As/2jKsBv9eTswLPNEt6Mnqb+9kWYCuvcI+UOOvqRlrchGgyr+F9GlsuEqDH6hs84U8NVwZTO4vDcKTPlYh0CAeLCI7y36NYDrFDKv3eFKb1Wa4PpLCHI3tWdO3PUoIQOdqfD7WupbH3MameiasHV8ICyND/Z/1V3L2QqMm7AzqaRS0R32MhSDWUKHQzjc5z1oKbI8jePtv7l9ItVCWY4ElHCd+OMrCLWtECyYYW1+gAZ4kU67OET1neLeWCYLut9jijpLlnH9O3cnh5OtmRAE+vQ9sJeCg5mvCU3xJ/bKNHRyXMCWJbZVBzPA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1639875278; bh=Lj7kU/T8AUnnrzX7LHq4PYzfRG6/iDfOxgEchRRsrx6=; h=X-Sonic-MF:From:To:Subject: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OtGWuGwp2i9WYsolH96KfD77slT4b4C2hApxmyF.RoKSi .4SPJlRhhfNA27H5UFJE7ZifKitKPa0aJmh19kLSn_.9L3mFLxk8jtOOUB0lIRo8N7P3jfCNsbxQ 3.N6mFvm62RDVbnm4azLnUMs4iafNMVg4Z8ttbWmxA X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Sun, 19 Dec 2021 00:54:38 +0000 Original-Received: by kubenode515.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 12370dc652c048adbe12ca9e6256287b; Sun, 19 Dec 2021 00:54:33 +0000 (UTC) In-Reply-To: <83pmpub41v.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Dec 2021 12:28:12 +0200") X-Mailer: WebService/1.1.19498 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.148; envelope-from=luangruo@yahoo.com; helo=sonic304-22.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:282352 Archived-At: Eli Zaretskii writes: >> @@ -10866,6 +10867,13 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, Li >> break; >> } >> } >> + else if (CONSP (from)) >> + { >> + start = clip_to_bounds (BEGV, fix_position (XCAR (from)), ZV); >> + bpos = CHAR_TO_BYTE (start); >> + CHECK_FIXNAT (XCDR (from)); >> + movement = XFIXNAT (XCDR (from)); >> + } >> else >> { >> start = clip_to_bounds (BEGV, fix_position (from), ZV); > There's code duplication here, which it would be good to avoid: the > calculation of bpos and the call to clip_to_bounds in calculation of > start. I don't think the duplication here is a particularly big problem. The code takes the car of FROM, and then checks that the cdr of FROM is a positive fixnum, which is a subtle difference from the other code. > The name 'movement' is not the best name. I would suggest 'offset' or > maybe even 'y_offset' instead. Thanks. > Also, the assumption that this offset is always positive, and that it > means the position _before_ FROM, is also something that makes the > function less general than it could be. It would be better to have > positive values mean _after_ FROM and negative values to mean before > it. Then you could use move_it_vertically instead of > move_it_vertically_backward. Does `move_it_vertically' have the same limitation of `move_it_vertically_backwards' where the iterator might end up either before or after the target position? >> + if (movement > 0) >> + { >> + int last_y; >> + it.current_y = 0; >> + >> + move_it_by_lines (&it, 0); > Why is this needed? That will move the iterator to the beginning of the visual line. I don't think it makes any sense to move it elsewhere, as IIUC the behaviour of moving an iterator upwards from a non-beginning position is not very well defined. >> + while (-it.current_y < movement) >> + { >> + last_y = it.current_y; >> + move_it_vertically_backward (&it, movement + it.current_y); >> + >> + if (it.current_y == last_y) >> + break; >> + } >> + >> + it.current_y = 0; >> + start = clip_to_bounds (BEGV, IT_CHARPOS (it), ZV); >> + } >> + >> int start_y = it.current_y; >> /* It makes no sense to measure dimensions of region of text that >> crosses the point where bidi reordering changes scan direction. > The code that follows this, which you leave intact, will reseat the > iterator to the beginning of the visual line where you ended up after > the loop that goes backward. Is that really TRT? what if there's a > multi-line display or overlay string at that place? Did you test the > code in that case? AFAIU, you have already assured that you are at > the beginning of a visual line, so the reseat, and the following > return to the START position, might not be needed. When you return to > START, you may end up very far from where the loop going backward > ended, if START is "covered" by a display property or overlay string. Yes, that's the correct behaviour here, at least for the pixel scrolling code (which I tested with both overlays and multi-line display properties). Thanks.