From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Uberti Newsgroups: gmane.emacs.devel Subject: Re: feature/icomplete-vertical Date: Mon, 5 Oct 2020 10:22:10 +0200 Message-ID: References: <20200912133311.6ujtgczj6wyclufy@Ergus> <20200920130435.heye7bk73pm252km@Ergus> <83sgbczj0i.fsf@gnu.org> <83lfh4zfml.fsf@gnu.org> <838sd4z6lz.fsf@gnu.org> <20201001164804.mqqyxtet4ttweuyv@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9200"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: Ergus , Juri Linkov , Yuan Fu , Eli Zaretskii , emacs-devel To: Gregory Heytings , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 05 10:27:05 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 1kPLpn-0002EM-N0 for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Oct 2020 10:27:03 +0200 Original-Received: from localhost ([::1]:57116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPLpl-0001jp-5U for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Oct 2020 04:27:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPLlO-0006Nc-PZ for emacs-devel@gnu.org; Mon, 05 Oct 2020 04:22:30 -0400 Original-Received: from devianza.investici.org ([198.167.222.108]:57191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPLlM-00077g-9P; Mon, 05 Oct 2020 04:22:30 -0400 Original-Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4C4YVY0rDtz6vBM; Mon, 5 Oct 2020 08:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inventati.org; s=stigmate; t=1601886133; bh=5uLReqveWrhgOplcvIyrLdktKh9Ox9syw4Zt5MKpC30=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=CrsIjnFI97DZuFGMI6Xn5pZJi+hwXcbZa0jCJ4oKrZQmrPxV9yyBCHRkmjRjQutwH DFweEyo6RwKNNhJVnlDAh5wHN1xXlVADITwrWLsI/lM2i4CzJBU8YQRJENGHidwvV8 tmU4X+TgjuRNJV88h5d66Ma7QZmPLpUzoDd2k1BA= Original-Received: from [198.167.222.108] (mx2.investici.org [198.167.222.108]) (Authenticated sender: manuel.uberti@inventati.org) by localhost (Postfix) with ESMTPSA id 4C4YVX4QhNz6v7p; Mon, 5 Oct 2020 08:22:12 +0000 (UTC) Autocrypt: addr=manuel.uberti@inventati.org; prefer-encrypt=mutual; keydata= mQENBFTh+8QBCADM+TpOAlO6NIM+GCSLZd4hZQCU2WV7Z1cLYLnE2NHdEaKGnaVlkcf9dGeL 6nlX7j20AYL7KqF4h9IX5d4lc1w8Izk0V2ijtqNeqbRdiTZ8mF+cFEwbALjHIs/YNUjr8IMK pJ+5rQ4DN6dsLVuJ7NJCB54AtAqqvoTodEPxLCT2Gq6YyGaobiEGeczk/3SPsQZYQnKfJ2zM JxIQDy4Dg9owrPpX/WWOfmcTkDoWovX9nsojErYXhIXP7r6+V3cV9stQeOwMhfmnZ1k7LO7y tyvYNIZGfh+JrYBakGttYGSj/C47hJV9MBiY08/Wr3QeDVtV7UTB5qXVYMrYQk63UssNABEB AAG0QU1hbnVlbCBVYmVydGkgKEF1dGlzdGljaS9JbnZlbnRhdGkpIDxtYW51ZWwudWJlcnRp QGludmVudGF0aS5vcmc+iQE6BBMBCgAkAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheABQJZ pBuqAhkBAAoJEE5XpsTKpI9iEBoIAJLAIZfNVT2KoO9iMM92kuCih6BA1lvpDWreoqRvwW8A iEnS6pwvpiuXldhZgcB4drpy97XBudBFx/b96Sqb4RvGxIHKpt4oLlpXzcohL28oP1CJiN+O bHEbRhzF8fuTrNh7v76z88WRkplUT/7nrO7YLVOM2DS/2QYccOrPkW4C5F03JyVkzSNisz5R VcmUTWcdnqo8VBd/DP3P96ayRj3VPKa9IdQIAxbjbhP+kEQbq9XDiZpGpcOHhFjWeLAWlFCm nES1C7Wb In-Reply-To: Content-Language: en-GB Received-SPF: pass client-ip=198.167.222.108; envelope-from=manuel.uberti@inventati.org; helo=devianza.investici.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/05 04:22:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-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:257087 Archived-At: On 05/10/20 09:52, Gregory Heytings via Emacs development discussions. wrote: > > Hi Ergus and Joćo, > > As I explained in a separate thread, at the moment the best way to implement > icomplete-vertical (and in general to display completion candidates in the > minibuffer) is to convince Emacs to start displaying the minibuffer at its > beginning.  This avoids all known problems. > > With this solution, displaying completion candidates after point in a minibuffer > is a trivial task: it suffices to insert the completion candidates in the > minibuffer, and Emacs will display as many of these candidates as possible, > given the user preferences (max-mini-window-height, resize-mini-windows, ...), > the size of the Emacs frame, the phase of the moon, ...  This works on Emacs 24, > 25, 26, 27 and 28, with fixed and variable width fonts. > > Part 1 of the solution (which solves the "root" problem, and is not specific to > icomplete-vertical): > > (defvar-local start-display-at-beginning-of-minibuffer nil) > (defun start-display-at-beginning-of-minibuffer (&rest args) >   (when (and start-display-at-beginning-of-minibuffer (minibufferp)) >     (set-window-start-at-begin (point-min) (point)))) > (defun set-window-start-at-begin (beg end) >   (when (< (+ beg 2) end) >     (set-window-start nil beg) >     (unless (pos-visible-in-window-p end nil t) >       (set-window-start-at-begin (+ beg (/ (- end beg) 2)) end)))) > (add-hook 'window-scroll-functions #'start-display-at-beginning-of-minibuffer) > (add-hook 'post-command-hook #'start-display-at-beginning-of-minibuffer) > > Part 2 of the solution (which implements icomplete-vertical): > > (setq icomplete-separator "\n") > (add-hook 'icomplete-minibuffer-setup-hook (lambda () (setq > start-display-at-beginning-of-minibuffer t))) > (defun icomplete-vertical-reformat-completions (completions) >   (save-match-data >     (if (string-match "^\\((.*)\\|\\[.+\\]\\)?{\\(\\(?:.\\|\n\\)+\\)}" completions) >         (format "%s \n%s" (or (match-string 1 completions) "") (match-string 2 > completions)) >       completions))) > (advice-add 'icomplete-completions :filter-return > #'icomplete-vertical-reformat-completions) > > The only limit of this solution is that is is not possible to display an > ellipsis ("...") at the end of the completion candidates list, to indicate that > some completion candidates are not displayed.  This is a minor limitation, and > IMO using one screen line just to display "..." is a waste of resources. > > Gregory Hi Gregory, FWIW, your code works absolutely fine for me and I was able to replace the external icomplete-vertical package with your solution. Thanks for working on this. -- Manuel Uberti www.manueluberti.eu