From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Allowing point to be outside the window? Date: Sat, 04 Dec 2021 14:55:09 +0200 Message-ID: <83sfv85y36.fsf@gnu.org> References: <87ilwd7zaq.fsf.ref@yahoo.com> <87ilwd7zaq.fsf@yahoo.com> <83bl24yaed.fsf@gnu.org> <87sfvg7l51.fsf@yahoo.com> <83zgpowu23.fsf@gnu.org> <87zgpo5tws.fsf@yahoo.com> <83pmqkwi6r.fsf@gnu.org> <87v90c5su6.fsf@yahoo.com> <83o864wg2a.fsf@gnu.org> <87ilwb68ck.fsf@yahoo.com> <83zgpnunfo.fsf@gnu.org> <87fsrf3xmd.fsf@yahoo.com> <83y257ulfp.fsf@gnu.org> <8735ne4e0e.fsf@yahoo.com> <87czmcvcs1.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2770"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 04 13:56:04 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 1mtUaB-0000VY-Cj for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Dec 2021 13:56:03 +0100 Original-Received: from localhost ([::1]:45428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtUaA-0005yH-Ft for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Dec 2021 07:56:02 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtUZS-0005CQ-96 for emacs-devel@gnu.org; Sat, 04 Dec 2021 07:55:18 -0500 Original-Received: from [2001:470:142:3::e] (port=33612 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtUZS-0000Db-2K; Sat, 04 Dec 2021 07:55:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7c7QyGYibzMcnjkmYztnrcWJT0UWGxgo+xe5/TyIubA=; b=Dpstgq1u4jyK 1JjOP4WyrnilF05IWmb9I/dYv9LFcdb/vika7hMcTXL/C+i7Y/59tToKEoNmwChmcBsH3Hso0Tife kXQpqi3EQBxKHoOrPt+Re3TBy7+I7kNhYn08+hKjHQqjWPaiKkkKnl2hHJlAd879+qmSDWVWMvzKP v3m9BPaihgG6DzthAG0bTW5WXXTU6JN+dtH4c6+KK3uJzTBDB6uk2TuJknw9f4h5rd5IX0qenVOW+ ZRaoEdTuUidrqaxuoaa0sQqWdyQtKmJQcmCoDhGhfhBgC4LLi4YG4d6vRlnGXsdRHC/2GXVK6+iXf ujtNZPOjHjOQzFDeOT7YsA==; Original-Received: from [87.69.77.57] (port=2663 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtUZR-0004fZ-L4; Sat, 04 Dec 2021 07:55:18 -0500 In-Reply-To: <87czmcvcs1.fsf@yahoo.com> (message from Po Lu on Sat, 04 Dec 2021 19:18:38 +0800) 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:280912 Archived-At: > From: Po Lu > Cc: emacs-devel@gnu.org > Date: Sat, 04 Dec 2021 19:18:38 +0800 > > I haven't figured out most of the user level command things, but here's > a patch that allows point to be outside a window. > > Some redisplay optimizations are disabled, but I hope to solve that > soon. > > WDYT? Thanks. This "allows point to be outside a window" in what situations? In general, it's hard to provide useful feedback without understanding the main ideas of the changes. And you didn't add any comments to help in that. So I'm left to wonder whether some changes I don't think I understand are just my misunderstanding of your ideas, or your misunderstanding of the code. So just a few random thoughts I had while reading the changes: > @@ -16989,6 +16991,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, > comes from a text property, not from an overlay. */ > bool string_from_text_prop = false; > > + w->cursor_visible_p = false; > + > /* Don't even try doing anything if called for a mode-line or > header-line or tab-line row, since the rest of the code isn't > prepared to deal with such calamities. */ > @@ -17575,6 +17579,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, > CHARPOS (this_line_start_pos) = 0; > } > > + w->cursor_visible_p = true; > return true; > } Shouldn't set_cursor_from_row be disabled/bypassed in this mode? And I don't understand the dance with the cursor_visible_p flag: why do you reset it at entry and set back before exiting? Isn't the value of w->cursor enough to tell whether the cursor position was computed or not? > + if (!keep_point_visible) > + goto maybe_try_window; > + > try_to_scroll: I don't understand this change. Are you forcibly trying to avoid calling try_scrolling? If so, why? That function is only loosely related to scrolling commands; in fact, if you type C-v in "emacs -Q", you will never see it called. This function is an optimization of a window's redisplay, and that is needed even in this new mode you are implementing. > + maybe_try_window: > + > + /* Set the window start position here explicitly if it is outside > + the accessible portion of the buffer. */ > + > + if (CHARPOS (startp) < BEGV > + || CHARPOS (startp) > ZV) > + { > + if (CHARPOS (startp) < BEGV) > + set_marker_both (w->start, Qnil, BEGV, BEGV_BYTE); > + else > + set_marker_both (w->start, Qnil, ZV, ZV_BYTE); > + > + SET_TEXT_POS_FROM_MARKER (startp, w->start); > + > + /* Run scroll hooks. */ > + startp = run_window_scroll_functions (window, startp); > + } > + > + /* We invoke try_window and try_window_reusing_current_matrix below, > + and they manipulate the bidi cache. Save and restore the cache > + state of our iterator, so we could continue using it after that. */ > + itdata = bidi_shelve_cache (); This and the rest of this hunk is a copy of code we have elsewhere, and I'm not sure I understand why you needed that. > @@ -20875,6 +20956,8 @@ #define GIVE_UP(X) return 0 > row = row_containing_pos (w, PT, r0, NULL, 0); > if (row) > set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); > + else > + w->cursor_visible_p = false; > return 1; > } > } > @@ -20915,6 +20998,8 @@ #define GIVE_UP(X) return 0 > row = row_containing_pos (w, PT, r0, NULL, 0); > if (row) > set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0); > + else > + w->cursor_visible_p = false; > return 2; > } > } > @@ -21152,6 +21237,8 @@ #define GIVE_UP(X) return 0 > last_unchanged_at_beg_row + 1, 0); > if (row) > set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); > + else > + w->cursor_visible_p = false; > } > > /* Start from first_unchanged_at_end_row looking for PT. */ > @@ -21162,6 +21249,8 @@ #define GIVE_UP(X) return 0 > if (row) > set_cursor_from_row (w, row, w->current_matrix, delta, > delta_bytes, dy, dvpos); > + else > + w->cursor_visible_p = false; > } Are these really needed? why? > + if (w->cursor_visible_p) > + { > + int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); > + int cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; The condition above doesn't check the keep_point_visible flag, why? Thanks.