[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 35b5d29 230/348: New example to show how to associate valu
From: |
Oleh Krehel |
Subject: |
[elpa] master 35b5d29 230/348: New example to show how to associate values |
Date: |
Sat, 8 Apr 2017 11:04:04 -0400 (EDT) |
branch: master
commit 35b5d29a940c0fdd96d419fd0424f09458da7c1c
Author: jtbm37 <address@hidden>
Commit: Oleh Krehel <address@hidden>
New example to show how to associate values
Fixes #714
---
doc/ivy.org | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/doc/ivy.org b/doc/ivy.org
index b460e64..8b49ed2 100644
--- a/doc/ivy.org
+++ b/doc/ivy.org
@@ -1280,6 +1280,38 @@ that they appear:
we want to kill the running process created by
=counsel--async-command=.
- =caller= argument identifies this command for easier customization.
+** Example - =ivy-read-with-extra-properties=
+:PROPERTIES:
+:CUSTOM_ID: example---ivy-read-with-extra-properties
+:END:
+This is another example to show how to associate additional values to each
+displayed strings.
+
+#+BEGIN_SRC elisp
+(defun find-candidates-function (str pred _)
+ (let ((props '(1 2))
+ (strs '("foo" "foo2")))
+ (cl-mapcar (lambda (s p) (propertize s 'property p))
+ strs
+ props)))
+
+(defun find-candidates ()
+ (interactive)
+ (ivy-read "Find symbols: "
+ #'find-candidates-function
+ :action (lambda (x)
+ (message "Value: %s" (get-text-property 0 'property x)
+ ))))
+#+END_SRC
+
+Here are the interesting features of the above function:
+
+- =find-candidates-function= builds up a list of strings and associates "foo"
with
+ the value 1 and "foo2" with 2.
+- =find-candidates= is an interactive function.
+- =#'find-candidates= is passed as the =collection= argument.
+- =action= gets passed the selected string with the associated value. It
+ then retrieves that value and displays it.
* Variable Index
:PROPERTIES:
- [elpa] master 4e6921f 153/348: ivy.el: Apply alist change to ivy-occur, (continued)
- [elpa] master 4e6921f 153/348: ivy.el: Apply alist change to ivy-occur, Oleh Krehel, 2017/04/08
- [elpa] master 36b00cb 155/348: Use EVM in travis to test across multiple Emacs versions, Oleh Krehel, 2017/04/08
- [elpa] master f6bd64b 164/348: ivy.el (ivy--flx-featurep): New defvar, Oleh Krehel, 2017/04/08
- [elpa] master fc5c8fc 159/348: Fix ivy-occur-press for swiper, Oleh Krehel, 2017/04/08
- [elpa] master e98883f 162/348: Improve fuzzy swiper highlight, Oleh Krehel, 2017/04/08
- [elpa] master 9b28927 187/348: counsel.el (counsel-hydra-heads): Fixup, Oleh Krehel, 2017/04/08
- [elpa] master 00219da 181/348: Fix for older Emacs, Oleh Krehel, 2017/04/08
- [elpa] master 8f87f74 178/348: counsel.el (counsel-git-grep): Update for Windows, Oleh Krehel, 2017/04/08
- [elpa] master 79105a5 208/348: counsel.el (counsel-info-lookup-symbol): Add preselect, Oleh Krehel, 2017/04/08
- [elpa] master 222a5e6 217/348: ivy.el (ivy--virtual-buffers): Move to silence compiler, Oleh Krehel, 2017/04/08
- [elpa] master 35b5d29 230/348: New example to show how to associate values,
Oleh Krehel <=
- [elpa] master e9c274a 236/348: Allow to customize ivy-display-function per caller, Oleh Krehel, 2017/04/08
- [elpa] master c14ceac 245/348: Add support for counsel-find-library, Oleh Krehel, 2017/04/08
- [elpa] master ca84f24 269/348: Add highlighter function configuration to ivy, Oleh Krehel, 2017/04/08
- [elpa] master 5701444 314/348: ivy.el (ivy-occur-revert-buffer): Restore ivy-occur-last, Oleh Krehel, 2017/04/08
- [elpa] master 13def15 318/348: ivy.el (ivy-case-fold-search): Add additional value 'always, Oleh Krehel, 2017/04/08
- [elpa] master 54c5447 319/348: counsel.el (counsel-grep-function): Add shell-quote-argument, Oleh Krehel, 2017/04/08
- [elpa] master bf8dc5f 326/348: Make swiper-avy work with more regexp builders, Oleh Krehel, 2017/04/08
- [elpa] master 03f90af 324/348: ivy.el (ivy-rotate-sort): Guard against nil sort, Oleh Krehel, 2017/04/08
- [elpa] master ac944ea 325/348: ivy.el: Remove with-ivy-window, Oleh Krehel, 2017/04/08
- [elpa] master 18da759 320/348: ivy.el: Remove ivy--current, Oleh Krehel, 2017/04/08