[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45780: 28.0.50; [PATCH] Face used for affixation function annotation
From: |
Juri Linkov |
Subject: |
bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations |
Date: |
Thu, 14 Jan 2021 20:59:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> 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:
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
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/11
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Juri Linkov, 2021/01/11
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/11
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Juri Linkov, 2021/01/12
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/13
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Juri Linkov, 2021/01/14
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/14
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations,
Juri Linkov <=
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/14
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Juri Linkov, 2021/01/25
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Juri Linkov, 2021/01/30
- bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations, Clemens, 2021/01/31