From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: A solution to display completion candidates after point in a minibuffer Date: Fri, 02 Oct 2020 18:44:31 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7066"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Gregory Heytings Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 03 00:45:26 2020 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 1kOTnq-0001kE-E2 for ged-emacs-devel@m.gmane-mx.org; Sat, 03 Oct 2020 00:45:26 +0200 Original-Received: from localhost ([::1]:58302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOTnp-00035b-Gp for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Oct 2020 18:45:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOTnG-0002eW-1j for emacs-devel@gnu.org; Fri, 02 Oct 2020 18:44:50 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOTnC-0003l9-Ml for emacs-devel@gnu.org; Fri, 02 Oct 2020 18:44:48 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E7F3410031E; Fri, 2 Oct 2020 18:44:44 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5F88010023C; Fri, 2 Oct 2020 18:44:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1601678683; bh=j+VUvRWgI3HRANw238OA7vRqhkrdkR+uH1hcCQLHmgQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=fgwUnDh0mohhRMrwX4V7r+sVKfHg9KzErjv4ToNtY7aI/elkD2tM1aM06vFrM+s+q cNQaubJssvsNuRcTH5sNN7GFGY3W/bZvixnk8zMDK2MjoQCB0Tz1qxlEb4DRfI5s4x iKTFH7Ch+pZJTe57FQBbaFADFT9aw34a72TwYFFb7FBniXk5chIgtLLEVPMm5huNhI YpIsGAj6KumhX5waDl0pvS68H2CHfpnB/qWBO9cAvlicX4kq7Fom2Y2TnhdJB/HQ/W h2nSQK/5JrXn3Z+Kk8i8IXjLHkKPnOowlaQnZXxv3q4ywJTEu9HZw28GpbT21M4bpp wlTEVcknboFVQ== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 39CBC120682; Fri, 2 Oct 2020 18:44:43 -0400 (EDT) In-Reply-To: (Gregory Heytings's message of "Fri, 02 Oct 2020 21:30:15 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 18:44:45 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.23 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:256977 Archived-At: >>>> Also this has some problematic aspects: - it focuses all its energy on >>>> showing the text before point, which is often the right choice, but >>>> not always. >>> Indeed, that's not always the right choice, which is why this solution >>> does this if, and only if, the buffer-local variable >>> start-display-at-beginning-of-minibuffer has been set, in >>> minibuffer-setup-hook. >> But it depends on other factors than "displaying the minibuffer". It can >> vary over the lifetime of the very same minibuffer. > Here I admit I have no idea what you mean. In your example recipe, the first line is hidden. I agree that it's probably a bad idea *when you enter the minibuffer*. But this same display is probably a better choice after the user read the prompt and knows what's the current directory, at which point the list of remaining completions is likely going to the main focus. >>> This I cannot do, alas, I'm not an expert. I tried this solution >>> extensively, on different Emacs versions. Perhaps there are cases where >>> it does not work, but I doubt it. >> I'd be uneasy using such code without some vague understanding about *why* >> it works. > The code of xdisp.c is rather intricate (to say the least), but if a vague > understanding is enough, I can explain what I understood. > After resize_mini_window(), redisplay_window() is called, and its > force_start part is executed, where run_window_scroll_functions() is called, > which updates startp and therefore w->start. This gives the user the > possibility (and as far as I can see it is the only possibility for the > user, with Lisp functions) to update window-start between > resize_mini_window() and redisplay. So set-window-start works, while other > operations (such as an explicit scroll-up or scroll-down) might not. After `set-window-start`, the redisplay will be inevitably re-started, which in turn might decide to scroll and thus `run_window_scroll_functions`, etc... IIRC the reason it won't scroll the second time around is because point should be visible (and redisplay would only scroll in order to move point within view). >>>> I don't understand why the kind of face in use would make a difference >>>> w.r.t needing to use `post-command-hook`. >>> >>> I don't understand it either, alas. An example, which does not work >>> without start-display-at-beginning-of-minibuffer in post-command-hook >>> with Emacs 26.3 (but works without it with Emacs 27.1): >> >> Thanks for the example. I think this highlights the need to better >> understand how/why this works. > In fact I think this example demonstrates a (minor) bug in Emacs, given that > the exact same code gives a different behavior with different versions of > Emacs. I could only reproduce this bug with variable width faces, with > which I guess that some rounding approximations happen here and there. Maybe because from the redisplay's point of view, there is no scrolling involved on the first redisplay of the minibuffer? Stefan