[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b3cca57 057/348: Make ivy prompt face overriding modular
From: |
Oleh Krehel |
Subject: |
[elpa] master b3cca57 057/348: Make ivy prompt face overriding modular |
Date: |
Sat, 8 Apr 2017 11:03:24 -0400 (EDT) |
branch: master
commit b3cca57f27423a7c859557b01b7c4e3f8f16b89d
Author: Kaushal Modi <address@hidden>
Commit: Kaushal Modi <address@hidden>
Make ivy prompt face overriding modular
* ivy--insert-prompt: The ivy--set-match-props calls inside this
function have been moved to the new variable
ivy--prompt-text-prop-override-function. That way, a user can override
this variable using add-function, if needed.
* ivy--set-match-props: To add granular control to text property
overrides, now function accepts an optional fourth argument SUBEXP. By
default, the PROPS text property is applied to the whole input string
STR if it matches the regexp MATCH. Now it is possible to apply the
text property only to a sub-expression. The default behavior is
retained.
---
ivy.el | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/ivy.el b/ivy.el
index 30d9f0a..093ae1b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1920,6 +1920,17 @@ depending on the number of candidates."
(goto-char (minibuffer-prompt-end))
(delete-region (line-end-position) (point-max))))
+(defvar ivy--prompt-text-prop-override-function
+ (lambda (prompt std-props)
+ (ivy--set-match-props prompt "confirm"
+ `(face ivy-confirm-face ,@std-props))
+ (ivy--set-match-props prompt "match required"
+ `(face ivy-match-required-face ,@std-props))
+ prompt)
+ "Function to override the text properties of the default ivy prompt.
+Called with two arguments, PROMPT and STD-PROPS.
+The returned value should be the updated PROMPT.")
+
(defun ivy--insert-prompt ()
"Update the prompt according to `ivy--prompt'."
(when ivy--prompt
@@ -1973,20 +1984,21 @@ depending on the number of candidates."
(set-text-properties 0 (length n-str)
`(face minibuffer-prompt ,@std-props)
n-str)
- (ivy--set-match-props n-str "confirm"
- `(face ivy-confirm-face ,@std-props))
- (ivy--set-match-props n-str "match required"
- `(face ivy-match-required-face ,@std-props))
+ (setq n-str (funcall ivy--prompt-text-prop-override-function
+ n-str std-props))
(insert n-str))
;; get out of the prompt area
(constrain-to-field nil (point-max))))))
-(defun ivy--set-match-props (str match props)
- "Set STR text properties that match MATCH to PROPS."
+(defun ivy--set-match-props (str match props &optional subexp)
+ "Set STR text properties for regexp group SUBEXP that match MATCH to PROPS.
+If SUBEXP is nil, the text properties are applied to the whole match."
+ (when (null subexp)
+ (setq subexp 0))
(when (string-match match str)
(set-text-properties
- (match-beginning 0)
- (match-end 0)
+ (match-beginning subexp)
+ (match-end subexp)
props
str)))
- [elpa] master 8c7a7fc 028/348: When reading file names, check preselect and initial-input compat, (continued)
- [elpa] master 8c7a7fc 028/348: When reading file names, check preselect and initial-input compat, Oleh Krehel, 2017/04/08
- [elpa] master 5d0fec1 032/348: ivy.el: Fix some checkdoc warnings, Oleh Krehel, 2017/04/08
- [elpa] master 2e1cebc 036/348: counsel.el (counsel-bookmark): Add, Oleh Krehel, 2017/04/08
- [elpa] master a566403 044/348: ivy.el (ivy-read): Document all args, Oleh Krehel, 2017/04/08
- [elpa] master baf89c0 054/348: ivy-test.el (colir-color-parse): Add test, Oleh Krehel, 2017/04/08
- [elpa] master be24b57 049/348: Revert "ivy.el (ivy-completion-in-region): Fix double insert bug", Oleh Krehel, 2017/04/08
- [elpa] master 77fb030 052/348: ivy.el (ivy-completion-in-region): Fix common length longer than str, Oleh Krehel, 2017/04/08
- [elpa] master 7280e19 050/348: ivy.el (ivy-completion-common-length): Fix double insert bug, Oleh Krehel, 2017/04/08
- [elpa] master 288723e 065/348: counsel.el (counsel-set-variable): Allow new symbols, Oleh Krehel, 2017/04/08
- [elpa] master fe32959 066/348: ivy.el (ivy--actionp): Fix lambda being considered a list of actions, Oleh Krehel, 2017/04/08
- [elpa] master b3cca57 057/348: Make ivy prompt face overriding modular,
Oleh Krehel <=
- [elpa] master 6067454 068/348: Improve readability of imenu candidates, Oleh Krehel, 2017/04/08
- [elpa] master a300514 071/348: counsel.el (hydra-keyboard-quit): Declare function, Oleh Krehel, 2017/04/08
- [elpa] master e54aa18 067/348: Add prefix arg for action functions, Oleh Krehel, 2017/04/08
- [elpa] master 2ee5618 085/348: ivy.el: Add face customizations to ivy-switch-buffer, Oleh Krehel, 2017/04/08
- [elpa] master fe93cc6 084/348: counsel.el (counsel-M-x): Fix interaction with repeat, Oleh Krehel, 2017/04/08
- [elpa] master aaad354 088/348: counsel.el (counsel-find-file): Switch directory with "M-o b", Oleh Krehel, 2017/04/08
- [elpa] master e38b23c 091/348: Make counsel-ag extensible, Oleh Krehel, 2017/04/08
- [elpa] master 4dbd8c3 090/348: counsel.el (counsel-semantic): Fix let paren, Oleh Krehel, 2017/04/08
- [elpa] master 2e3cd39 099/348: Support custom command for counsel-git, Oleh Krehel, 2017/04/08
- [elpa] master 94e22bf 096/348: counsel.el (counsel-describe-face): New command, Oleh Krehel, 2017/04/08