From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrii Kolomoiets Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Support "\n" in icomplete-separator Date: Mon, 09 Nov 2020 23:04:01 +0200 Message-ID: References: <20201105235735.oxouuek66ehu5o45@Ergus> <20201106151541.dpgep7borlja25su@Ergus> <837dqv5huk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33103"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: spacibba@aol.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 09 22:05:15 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 1kcELj-0008SZ-2g for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Nov 2020 22:05:15 +0100 Original-Received: from localhost ([::1]:36496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcELi-0005MA-17 for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Nov 2020 16:05:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcEKi-0004uv-1J for emacs-devel@gnu.org; Mon, 09 Nov 2020 16:04:12 -0500 Original-Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:33480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcEKf-0002jd-FE; Mon, 09 Nov 2020 16:04:11 -0500 Original-Received: by mail-lf1-x12a.google.com with SMTP id l2so14464250lfk.0; Mon, 09 Nov 2020 13:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=bPaKd+Y+26K/NxhMHP2q6rCae4HOTxq/V3OUG9xY3wo=; b=ROOaskHA8zkLYQrMhZ4hnhyLSbobmHjfUp6DGi3epj/CZYIBxNopMtJ317n16BJHBL Rc5jAcgeFcKK2X6na/o3RuF20V5777OjjVQDilJdruev6DAKrEW40Pjx4qrWr8BGY0lQ DmviJJoDWk9MIpFYl2Eb3JzC7FUaNZPAIKTBS/OUneAkzeWRqENEuEsOYd0OEL/Y/WnW IUzTvDFAqy8SD3AauCKdaarpuD1wegvBDKvFuctJM7M6MunKwRArn6RbazgOn0D80G0m cA9fFLvlIPcVoqlX4wDLnAHP6K7GFC4cxhjn21xSVE8SwWAKObsJOmITOMdBk8GmCuHy +HPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=bPaKd+Y+26K/NxhMHP2q6rCae4HOTxq/V3OUG9xY3wo=; b=epZH9A1g5VLMN4ub+qrt0SoR9ob+9x2jd4y8vNNwZhaUO3+jO3ATIdE4KNNbmJ319k YSpm1c+rPM7GBBMAWxqXAjHuKgYyr67HZsDJcuj0H/i2sHJm3jQrPP7fdlXBzpgIviEc VpHzb/OF4chHU20y3RIHjM/N3fCbuzu+8nEy04Tkz1j//yoCqxpT1ueMj7TnbTmcrsWp OxyUkero+K9Y0X2HtSXVh6/6dyVfp8DEf8OUeUTOFyVwXHPNY/js7RLx/8AMQ1FX2tfH xThLtnhPw+tXuJ3C7fdF/4MTIw1TKwWU29Kkj/1G27o6vE2r5je2pQcQ6TuNz+Q+AKK2 hjBw== X-Gm-Message-State: AOAM531xPIy8nxYNwWy3JclVOXm/YYopV4KNQa15q5t8aS8rCptjjDje 6Y8Q/rE3qO82ZNnBvwK+cXn43WWk+xTHVQ== X-Google-Smtp-Source: ABdhPJyzNya8f2Gh2ewPKidcTYN2u4MpOLKO8a86HzWaZ56oW99tCfUP5758rl2Fcef/N32tMkqZew== X-Received: by 2002:ac2:48ac:: with SMTP id u12mr158428lfg.211.1604955844384; Mon, 09 Nov 2020 13:04:04 -0800 (PST) Original-Received: from muffinmac ([91.206.110.192]) by smtp.gmail.com with ESMTPSA id 3sm2304486ljq.96.2020.11.09.13.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 13:04:03 -0800 (PST) In-Reply-To: <837dqv5huk.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 09 Nov 2020 05:28:35 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=andreyk.mad@gmail.com; helo=mail-lf1-x12a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:258957 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Andrii Kolomoiets >> Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca, eliz@gnu.org >> Date: Sun, 08 Nov 2020 22:14:07 +0200 >> >> I didn't saw the prompt issue. Stefan and Eli, can you please confirm >> that the prompt issue is totally gone? > > Can you show the recipe (or recipes) which I should try in order to > answer your question? While preparing receipt, I've found that the bug with the prompt is still exists. The receipt should be checked using feature/icomplete-vertical branch and using patched master branch (patch attached). Code that need to be put to the *scratch* buffer: (setq resize-mini-frames t) (icomplete-mode 1) (setq icomplete-separator "\n--\n") (setq icomplete-show-matches-on-no-input t) (setq icomplete-hide-common-prefix nil) (setq icomplete-prospects-height 10) (add-hook 'minibuffer-setup-hook (lambda () (set (make-local-variable 'face-remapping-alist) '((default :height 1.3))))) (setq completion-items (mapcar (lambda (x) (format "Multiline completion item to occupy \ several lines %s" x)) '(1 2 3 4 5 6 7 8 9 0))) (completing-read "This prompt is visible: " completion-items) (completing-read "This line of the prompt is not visible because the propmt \ occupy several lines: " completion-items) Part one. 1. emacs -Q 2. Put the code above to the *scratch* buffer 3. M-x eval-buffer feature/icomplete-vertical and patched master: Prompt is visible. 4. TAB (to complete the common part) feature/icomplete-vertical: Prompt is visible. Patched master: Prompt is hidden. 5. RET feature/icomplete-vertical: Prompt is visible. Patched master: The firs line of the prompt is hidden. 6. TAB feature/icomplete-vertical: Prompt is visible. Patched master: Prompt is hidden. Part two. 1. emacs -Q --eval "(setq default-frame-alist '((minibuffer . nil)))" 2. Put the code above to the *scratch* buffer 3. M-x eval-buffer feature/icomplete-vertical: Minibuffer frame remains minimum height and width, prompt is hidden. Patched master: Prompt is visible, minibuffer frame resized to fit all the 10 completion items. Well, the "part one" is for sure the answer to my own question :) But because of the "part two" I'm still very like the idea to treat 'icomplete-prospects-height' as completions count and not as the lines count. So I have another question: that prompt issue in patched master from the "part one" must be solved in icomplete-mode or somewhere in the display engine? Thanks! --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=icomplete-vertical.diff Content-Transfer-Encoding: quoted-printable diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 4e546807b7..2fe740292c 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -687,33 +687,32 @@ icomplete-completions ;; a prefix of most, or something else. (compare (compare-strings name nil nil most nil nil completion-ignore-case)) - (ellipsis (if (char-displayable-p ?=E2=80=A6) "=E2=80=A6" "...")) (determ (unless (or (eq t compare) (eq t most-try) (=3D (setq compare (1- (abs compare))) (length most))) (concat open-bracket - (cond - ((=3D compare (length name)) + ;; Don't bother truncating if it doesn't ga= in + ;; us at least 2 columns. + (if (< compare 2) + most ;; Typical case: name is a prefix. - (substring most compare)) - ;; Don't bother truncating if it doesn't g= ain - ;; us at least 2 columns. - ((< compare (+ 2 (string-width ellipsis))) most) - (t (concat ellipsis (substring most compare)))) + (substring most compare)) close-bracket))) + (vertical (string-match "\n" icomplete-separator)) ;;"-prospects" - more than one candidate - (prospects-len (+ (string-width - (or determ (concat open-bracket close-bracket))) - (string-width icomplete-separator) - (+ 2 (string-width ellipsis)) ;; take {=E2=80=A6} into account - (string-width (buffer-string)))) + (prospects-len (unless vertical + (+ (string-width + (if determ (concat determ "{") open-bracket)) + (string-width (buffer-string))))) (prospects-max - ;; Max total length to use, including the minibuffer content. - (* (+ icomplete-prospects-height - ;; If the minibuffer content already uses up more than - ;; one line, increase the allowable space accordingly. - (/ prospects-len (window-width))) - (window-width))) + (if vertical + icomplete-prospects-height + ;; Max total length to use, including the minibuffer conte= nt. + (* (+ icomplete-prospects-height + ;; If the minibuffer content already uses up more th= an + ;; one line, increase the allowable space accordingl= y. + (/ prospects-len (window-width))) + (window-width)))) ;; Find the common prefix among `comps'. ;; We can't use the optimization below because its assumptions ;; aren't always true, e.g. when completion-cycling (bug#1085= 0): @@ -730,7 +729,9 @@ icomplete-completions ;; is already displayed via `most'. (string-prefix-p prefix most t) (length prefix))) ;;) - prospects comp limit) + (limit (when vertical + (> (length comps) prospects-max))) + prospects comp) (if (or (eq most-try t) (not (consp (cdr comps)))) (setq prospects nil) (when (member name comps) @@ -753,24 +754,38 @@ icomplete-completions ;; completion field. (setq determ (concat open-bracket "" close-bracket))) ;; Compute prospects for display. - (while (and comps (not limit)) - (setq comp - (if prefix-len (substring (car comps) prefix-len) (car comps)) - comps (cdr comps)) - (setq prospects-len - (+ (string-width comp) - (string-width icomplete-separator) - prospects-len)) - (if (< prospects-len prospects-max) - (push comp prospects) - (setq limit t)))) - (setq prospects (nreverse prospects)) - ;; Decorate first of the prospects. - (when prospects - (let ((first (copy-sequence (pop prospects)))) - (put-text-property 0 (length first) - 'face 'icomplete-first-match first) - (push first prospects))) + (if vertical + (while (and comps (> prospects-max 0)) + (setq prospects-max (1- prospects-max)) + (push (if prefix-len + (substring (pop comps) prefix-len) + (pop comps)) + prospects)) + (while (and comps (not limit)) + (setq comp (if prefix-len + (substring (pop comps) prefix-len) + (pop comps))) + (setq prospects-len + (+ (string-width comp) + prospects-len)) + ;; There be the } after last comp. Add 1 to prospects-len i= f last comp. + (if (<=3D (+ (if comps 0 1) prospects-len) prospects-max) + (push comp prospects) + (setq limit t)) + ;; Add separator if there are more comps + (when (and comps (not limit)) + (setq prospects-len + (+ (string-width icomplete-separator) + prospects-len)) + (unless (<=3D prospects-len prospects-max) + (setq limit t))))) + (when prospects + (setq prospects (nreverse prospects)) + ;; Decorate first of the prospects. + (let ((first (copy-sequence (pop prospects)))) + (put-text-property 0 (length first) + 'face 'icomplete-first-match first) + (push first prospects)))) ;; Restore the base-size info, since completion-all-sorted-complet= ions ;; is cached. (if last (setcdr last base-size)) @@ -778,8 +793,7 @@ icomplete-completions (concat determ "{" (mapconcat 'identity prospects icomplete-separator) - (and limit (concat icomplete-separator ellipsis)) - "}") + (unless limit "}")) (concat determ " [Matched]")))))) =20 ;;; Iswitchb compatibility --=-=-=--