From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations Date: Thu, 14 Jan 2021 20:59:29 +0200 Organization: LINKOV.NET Message-ID: <87h7nj2vla.fsf@mail.linkov.net> References: <9b1409af-58b9-3a62-4162-343fd25293ca@posteo.net> <87ft378gjk.fsf@mail.linkov.net> <8735z6xx11.fsf@mail.linkov.net> <7763f3e7-475c-9adb-ce62-7801faf47a90@posteo.net> <875z3z50if.fsf@mail.linkov.net> <4779a90d-a475-0490-7de2-de072efe64f5@posteo.net> 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="5581"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 45780@debbugs.gnu.org To: Clemens Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 14 20:14:47 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1l0851-0001Me-Bb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Jan 2021 20:14:47 +0100 Original-Received: from localhost ([::1]:40562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0850-00086R-3X for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Jan 2021 14:14:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l084J-00083G-8T for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2021 14:14:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l084I-0008Lh-LM for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2021 14:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l084I-0001lC-HA for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2021 14:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jan 2021 19:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45780 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45780-submit@debbugs.gnu.org id=B45780.16106516026671 (code B ref 45780); Thu, 14 Jan 2021 19:14:02 +0000 Original-Received: (at 45780) by debbugs.gnu.org; 14 Jan 2021 19:13:22 +0000 Original-Received: from localhost ([127.0.0.1]:39272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l083e-0001jX-1i for submit@debbugs.gnu.org; Thu, 14 Jan 2021 14:13:22 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:49485) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l083b-0001j9-A3 for 45780@debbugs.gnu.org; Thu, 14 Jan 2021 14:13:20 -0500 X-Originating-IP: 91.129.98.64 Original-Received: from mail.gandi.net (m91-129-98-64.cust.tele2.ee [91.129.98.64]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id C51BBC000E; Thu, 14 Jan 2021 19:13:11 +0000 (UTC) In-Reply-To: <4779a90d-a475-0490-7de2-de072efe64f5@posteo.net> (Clemens's message of "Thu, 14 Jan 2021 18:21:00 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197958 Archived-At: --=-=-= Content-Type: text/plain >> Do you want to use the completion-annotations face conditionally only >> for annotations, i.e. when only the suffix is provided by the client? >> Because when a prefix is provided as well, then it's not an annotation >> anymore, so the completion-annotations face is not applicable to prefixes. > > I see, personally I think of all strings besides the completions themselves > as annotations ;) Makes sense to do it only for the suffix then. > >> Doing this is not something new, we already have the same logic >> in minibuffer-message: >> (unless (or (null minibuffer-message-properties) >> ;; Don't overwrite the face properties the caller has set >> (text-properties-at 0 message)) >> (setq message (apply #'propertize message minibuffer-message-properties))) >> Is this logic suitable for completion-annotations? > > I guess this could also be used, the version I posted earlier only checks > for the face property and then also check the whole string: > > (if (text-property-not-all 0 (length str) 'face nil str) > str > (propertize str 'face face)) > > When only the face matters my proposed version might be better? I agree its purpose is quite different from the example above. Then maybe something like this should do what you want: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion--insert-strings-text-property-not-all.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 315f2d369a..31d7be3441 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1785,14 +1800,7 @@ completion--insert-strings (when prefix (let ((beg (point)) (end (progn (insert prefix) (point)))) - (put-text-property beg end 'mouse-face nil) - ;; When both prefix and suffix are added - ;; by the caller via affixation-function, - ;; then allow the caller to decide - ;; what faces to put on prefix and suffix. - (unless prefix - (font-lock-prepend-text-property - beg end 'face 'completions-annotations)))) + (put-text-property beg end 'mouse-face nil))) (put-text-property (point) (progn (insert (car str)) (point)) 'mouse-face 'highlight) (let ((beg (point)) @@ -1800,7 +1808,12 @@ completion--insert-strings (put-text-property beg end 'mouse-face nil) ;; Put the predefined face only when suffix ;; is added via annotation-function. - (unless prefix + ;; Otherwise, when only suffix is added + ;; by the caller via annotation-function, + ;; then allow the caller to decide + ;; what faces to put on suffix. + (unless (or prefix (text-property-not-all + 0 (length suffix) 'face nil suffix)) (font-lock-prepend-text-property beg end 'face 'completions-annotations))))) (cond --=-=-=--