diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-06-11 06:19:38 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-06-11 06:42:02 +0200 |
commit | 57c984c3b231c186d5a587fffcf2d56187ecb4d2 (patch) | |
tree | 5126b1a782c9784b241fe7009e699043506bb392 /helm-adaptive.el | |
parent | 5a69bc0b783035a0294c33c6f271b24a92a0e1f7 (diff) |
Handle multiline in adaptive.
First fix, an additional newline is added at end of display candidate
in adaptive, remove it to sort.
* helm-adaptive.el (helm-adaptive-sort): Do it.
Diffstat (limited to 'helm-adaptive.el')
-rw-r--r-- | helm-adaptive.el | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/helm-adaptive.el b/helm-adaptive.el index 29b675fa..3a378d47 100644 --- a/helm-adaptive.el +++ b/helm-adaptive.el @@ -184,13 +184,13 @@ This is a filtered candidate transformer you can use with the helm-pattern)) (cl-incf count (cdr pattern-info)) - ;; if current pattern is equal to the previously - ;; used one then this candidate has priority - ;; (that's why its count is boosted by 10000) and - ;; it only has to compete with other candidates - ;; which were also selected with the same pattern - (setq count (+ 10000 (cdr pattern-info))) - (cl-return))) + ;; if current pattern is equal to the previously + ;; used one then this candidate has priority + ;; (that's why its count is boosted by 10000) and + ;; it only has to compete with other candidates + ;; which were also selected with the same pattern + (setq count (+ 10000 (cdr pattern-info))) + (cl-return))) (cons (car candidate-info) count))) (cdr source-info)))) (if (and usage (consp usage)) @@ -202,20 +202,22 @@ This is a filtered candidate transformer you can use with the ;; put those candidates first which have the highest usage count (cl-loop for (info . _freq) in usage - for member = (cl-member info candidates - :test 'helm-adaptive-compare) - when member collect (car member) into sorted - and do - (setq candidates (cl-remove info candidates - :test 'helm-adaptive-compare)) - finally return (append sorted candidates))) - (message "Your `%s' is maybe corrupted or too old, \ + for mlinfo = (and (assq 'multiline source) + (replace-regexp-in-string "\n\\'" "" info)) + for member = (cl-member (or mlinfo info) candidates + :test 'helm-adaptive-compare) + when member collect (car member) into sorted + and do + (setq candidates (cl-remove (or mlinfo info) candidates + :test 'helm-adaptive-compare)) + finally return (append sorted candidates))) + (message "Your `%s' is maybe corrupted or too old, \ you should reinitialize it with `helm-reset-adaptive-history'" - helm-adaptive-history-file) - (sit-for 1) - candidates)) - ;; if there is no information stored for this source then do nothing - candidates))) + helm-adaptive-history-file) + (sit-for 1) + candidates)) + ;; if there is no information stored for this source then do nothing + candidates))) ;;;###autoload (defun helm-reset-adaptive-history () |