[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6de6233 205/399: counsel.el (counsel-compile): New counsel
From: |
Oleh Krehel |
Subject: |
[elpa] master 6de6233 205/399: counsel.el (counsel-compile): New counsel-compile-env helper |
Date: |
Sat, 20 Jul 2019 14:57:24 -0400 (EDT) |
branch: master
commit 6de6233995790f2a8dd53e0f68547e33e5c618bb
Author: Alex Bennée <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-compile): New counsel-compile-env helper
This helper allows us to tweak counsel-compile-env. We don't use
separate actions. We either add the environment variable if it doesn't
already exist or remove it if it does.
There is scope for better validation and dealing with setting ARCH=foo
when we have ARCH=bar in the environment already.
---
counsel.el | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/counsel.el b/counsel.el
index 3a6a991..0e16137 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5256,6 +5256,9 @@ Each element should be a string of the form
ENVVARNAME=VALUE. This
list is passed to `compilation-environment'."
:type '(repeat (string :tag "ENVVARNAME=VALUE")))
+(defvar counsel-compile-env-history nil
+ "History for `counsel-compile-env'.")
+
(defcustom counsel-compile-make-pattern "\\`\\(?:GNUm\\|[Mm]\\)akefile\\'"
"Regexp for matching the names of Makefiles."
:type 'regexp)
@@ -5438,6 +5441,40 @@ specified by the `blddir' property."
:action #'counsel-compile--action
:caller 'counsel-compile))
+
+(defun counsel-compile-env--format-hint (cands)
+ "Return a formatter for compile-env CANDS."
+ (let ((rmstr
+ (propertize "remove" 'face 'font-lock-warning-face))
+ (addstr
+ (propertize "add" 'face 'font-lock-variable-name-face)))
+ (ivy--format-function-generic
+ (lambda (selected)
+ (format "%s %s"
+ (if (member selected counsel-compile-env) rmstr addstr)
+ selected))
+ #'identity
+ cands
+ "\n")))
+
+(defun counsel-compile-env--update (var)
+ "Update `counsel-compile-env' either adding or removing VAR."
+ (if (member var counsel-compile-env)
+ (setq counsel-compile-env (delete var counsel-compile-env))
+ (add-to-list 'counsel-compile-env var)))
+
+;;;###autoload
+(defun counsel-compile-env ()
+ "Update `counsel-compile-env' interactively."
+ (interactive)
+ (let ((ivy-format-function #'counsel-compile-env--format-hint))
+ (ivy-read "Compile environment variable: "
+ (delete-dups (append
+ counsel-compile-env counsel-compile-env-history))
+ :action #'counsel-compile-env--update
+ :history 'counsel-compile-env-history
+ :caller 'counsel-compile-env)))
+
;;** `counsel-minor'
(defun counsel--minor-candidates ()
"Return completion alist for `counsel-minor'.
- [elpa] master d8136a2 200/399: doc/ivy.org: Remove outdated magit customization, (continued)
- [elpa] master d8136a2 200/399: doc/ivy.org: Remove outdated magit customization, Oleh Krehel, 2019/07/20
- [elpa] master ca8d5ba 197/399: ivy.el (ivy-partial): Adjust ivy-tab-space when one candidate, Oleh Krehel, 2019/07/20
- [elpa] master f28e00c 194/399: counsel.el (counsel-find-file): Improve delete action with ivy-call, Oleh Krehel, 2019/07/20
- [elpa] master afeda97 198/399: counsel.el (counsel-company): Add :caller, Oleh Krehel, 2019/07/20
- [elpa] master 3b25d30 206/399: counsel.el (counsel-compile): Add predicate to counsel-compile-env, Oleh Krehel, 2019/07/20
- [elpa] master 3d0887f 204/399: counsel.el (counsel-compile): Add counsel-compile-env, Oleh Krehel, 2019/07/20
- [elpa] master 605cee0 202/399: counsel.el (counsel-compile): Fix saving of blddir, Oleh Krehel, 2019/07/20
- [elpa] master c9f2318 203/399: counsel.el (counsel-compile): Add helper for formatting text, Oleh Krehel, 2019/07/20
- [elpa] master 276599c 201/399: doc/ivy.texi: Generate from doc/ivy.org, Oleh Krehel, 2019/07/20
- [elpa] master 3f27e25 207/399: counsel.el (counsel-compile): Don't squash default-directory, Oleh Krehel, 2019/07/20
- [elpa] master 6de6233 205/399: counsel.el (counsel-compile): New counsel-compile-env helper,
Oleh Krehel <=
- [elpa] master f628eb3 210/399: swiper.el (swiper-isearch-symbol-at-point): Add, Oleh Krehel, 2019/07/20
- [elpa] master bed783e 217/399: ivy-test.el (swiper-isearch-case-fold): Add test, Oleh Krehel, 2019/07/20
- [elpa] master 4147453 212/399: swiper.el (swiper-isearch-thing-at-point): Add, Oleh Krehel, 2019/07/20
- [elpa] master 9a2b110 214/399: ivy.el (ivy-insert-current): Insert text without properties, Oleh Krehel, 2019/07/20
- [elpa] master f1b3fa4 209/399: swiper.el (swiper-isearch): Support swiper-goto-start-of-match, Oleh Krehel, 2019/07/20
- [elpa] master bd958e7 208/399: counsel.el (counsel-org-files): Re-use org-attach-dir, Oleh Krehel, 2019/07/20
- [elpa] master 9c1e1c3 216/399: swiper.el (swiper-isearch-function): Obey ivy-case-fold-search-default, Oleh Krehel, 2019/07/20
- [elpa] master 6f56049 230/399: ivy.el (ivy--minibuffer-index-bounds): Make pure, Oleh Krehel, 2019/07/20
- [elpa] master 9eb5275 227/399: ivy.el (ivy--minibuffer-index-bounds): Extract, Oleh Krehel, 2019/07/20
- [elpa] master f292ed3 226/399: ivy.el (ivy-help): Reveal all Org contents, Oleh Krehel, 2019/07/20