summaryrefslogtreecommitdiff
path: root/helm-elisp.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-11-01 13:46:28 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-11-01 13:46:28 +0100
commitfe398b9578dcd9f4d2989e6f6463263ebeefd8d9 (patch)
treed5167ffb4c11a5ebbc199dd3ae43d997a637651d /helm-elisp.el
parentfe92240663f6b2314e79558f6eabbab955a797e3 (diff)
Add action to clean hist vars (#1906)
* helm-elisp.el (helm-apropos-clean-history-variable): New. (helm-def-source--emacs-variables): Add it to action-transformer.
Diffstat (limited to 'helm-elisp.el')
-rw-r--r--helm-elisp.el37
1 files changed, 24 insertions, 13 deletions
diff --git a/helm-elisp.el b/helm-elisp.el
index 5e744ce1..80b8a069 100644
--- a/helm-elisp.el
+++ b/helm-elisp.el
@@ -507,6 +507,15 @@ Filename completion happen if string start after or between a double quote."
candidates
(sort candidates #'helm-generic-sort-fn)))
+(defun helm-apropos-clean-history-variable (candidate)
+ (let* ((sym (intern-soft candidate))
+ (cands (symbol-value sym))
+ (mkds (and (listp cands)
+ (helm-comp-read "Delete entry: "
+ cands :marked-candidates t))))
+ (cl-assert (listp mkds) nil "Variable value is not a list")
+ (cl-loop for elm in mkds do (set sym (setq cands (delete elm cands))))))
+
(defun helm-def-source--emacs-variables (&optional default)
(helm-build-in-buffer-source "Variables"
:init (lambda ()
@@ -527,19 +536,21 @@ Filename completion happen if string start after or between a double quote."
:action-transformer
(lambda (actions candidate)
(let ((sym (helm-symbolify candidate)))
- (if (custom-variable-p sym)
- (append
- actions
- (let ((standard-value (eval (car (get sym 'standard-value)))))
- (unless (equal standard-value (symbol-value sym))
- `(("Reset Variable to default value" .
- ,(lambda (candidate)
- (let ((sym (helm-symbolify candidate)))
- (set sym standard-value)))))))
- '(("Customize variable" .
- (lambda (candidate)
- (customize-option (helm-symbolify candidate))))))
- actions)))))
+ (cond ((custom-variable-p sym)
+ (append
+ actions
+ (let ((standard-value (eval (car (get sym 'standard-value)))))
+ (unless (equal standard-value (symbol-value sym))
+ `(("Reset Variable to default value" .
+ ,(lambda (candidate)
+ (let ((sym (helm-symbolify candidate)))
+ (set sym standard-value)))))))
+ '(("Customize variable" .
+ (lambda (candidate)
+ (customize-option (helm-symbolify candidate)))))))
+ ((string-match-p "history" candidate)
+ (append actions '(("Clean variable" . helm-apropos-clean-history-variable))))
+ (t actions))))))
(defun helm-def-source--emacs-faces (&optional default)
"Create `helm' source for faces to be displayed with