From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: feature/icomplete-vertical Date: Mon, 05 Oct 2020 07:52:17 +0000 Message-ID: References: <20200912133311.6ujtgczj6wyclufy@Ergus> <20200920130435.heye7bk73pm252km@Ergus> <83sgbczj0i.fsf@gnu.org> <83lfh4zfml.fsf@gnu.org> <838sd4z6lz.fsf@gnu.org> <20201001164804.mqqyxtet4ttweuyv@Ergus> Reply-To: Gregory Heytings Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="-212064758-1008441612-1601883363=:2696" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22099"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Alpine 2.22 (NEB 394 2020-01-19) Cc: Ergus , Eli Zaretskii , Yuan Fu , emacs-devel , Juri Linkov To: =?ISO-8859-15?Q?Jo=E3o_T=E1vora?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 05 09:53:52 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 1kPLJg-0005eY-6A for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Oct 2020 09:53:52 +0200 Original-Received: from localhost ([::1]:41432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPLJe-0006q4-R3 for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Oct 2020 03:53:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPLIR-0006Jl-6U for emacs-devel@gnu.org; Mon, 05 Oct 2020 03:52:35 -0400 Original-Received: from mx.sdf.org ([205.166.94.24]:57071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPLIO-0003JR-35; Mon, 05 Oct 2020 03:52:34 -0400 Original-Received: from sdf.org (IDENT:ghe@otaku.sdf.org [205.166.94.8]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 0957qKHj009585 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Mon, 5 Oct 2020 07:52:20 GMT Original-Received: (from ghe@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 0957qegj016413; Mon, 5 Oct 2020 07:52:40 GMT In-Reply-To: Content-ID: Received-SPF: pass client-ip=205.166.94.24; envelope-from=ghe@sdf.org; helo=mx.sdf.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/05 02:57:02 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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:257084 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---212064758-1008441612-1601883363=:2696 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: Hi Ergus and Jo=E3o, As I explained in a separate thread, at the moment the best way to=20 implement icomplete-vertical (and in general to display completion=20 candidates in the minibuffer) is to convince Emacs to start displaying the= =20 minibuffer at its beginning. This avoids all known problems. With this solution, displaying completion candidates after point in a=20 minibuffer is a trivial task: it suffices to insert the completion=20 candidates in the minibuffer, and Emacs will display as many of these=20 candidates as possible, given the user preferences=20 (max-mini-window-height, resize-mini-windows, ...), the size of the Emacs= =20 frame, the phase of the moon, ... This works on Emacs 24, 25, 26, 27 and= =20 28, with fixed and variable width fonts. Part 1 of the solution (which solves the "root" problem, and is not=20 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-minibuff= er) (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-a= t-beginning-of-minibuffer t))) (defun icomplete-vertical-reformat-completions (completions) (save-match-data (if (string-match "^\\((.*)\\|\\[.+\\]\\)?{\\(\\(?:.\\|\n\\)+\\)}" com= pletions) (format "%s \n%s" (or (match-string 1 completions) "") (match-stri= ng 2 completions)) completions))) (advice-add 'icomplete-completions :filter-return #'icomplete-vertical-refo= rmat-completions) The only limit of this solution is that is is not possible to display an=20 ellipsis ("...") at the end of the completion candidates list, to indicate= =20 that some completion candidates are not displayed. This is a minor=20 limitation, and IMO using one screen line just to display "..." is a waste= =20 of resources. Gregory ---212064758-1008441612-1601883363=:2696--