[helm] Fix dangerous implementation for helm-use-fuzzy

This variable caused Spacemacs to set all helm sources
to use fuzzy matching independently of whether this
was supported by the source.

This handling was very dangerous as using fuzzy for an
incompatible source can have all kind of side effects
causing unique bugs which will never be fixed by the
source package authors.

Therefore I have changed the implementation to
activate fuzzy matching via helm variables instead,
which should make sure we only activate this for
compatible sources.

If sources are found which do not longer do
fuzzy matching, the individual source should be
improved to support this feature and declare it's
compatibility towards helm.

We cannot fix helm in Spacemacs, instead the respective
package must be patched. Everything else is a maintenance
nightmare!

Fixes #15124
This commit is contained in:
Maxi Wolff 2022-06-19 19:43:04 +02:00
parent 9c44ecf13c
commit ee95121e6b
No known key found for this signature in database
GPG Key ID: 2DD07025BFDBD89A
4 changed files with 26 additions and 36 deletions

View File

@ -112,9 +112,10 @@ Default value is =bottom=.
** Enable fuzzy searching in Helm buffers
It is possible to control the fuzziness of Helm when searching for candidates.
By default this layer /tries/ to enable fuzzy search to all Helm sources.
You can limit the fuzzy search to helm own defaults by setting the layer
variable =helm-use-fuzzy= to the value ='source=.
By default this layer enable fuzzy search for all supported Helm sources.
It this creates issues please disable it by setting this value to ='source=.
In this case please open an issue so that this can be fixed.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(

View File

@ -183,7 +183,8 @@
;; helm-locate uses es (from everything on windows which doesn't like fuzzy)
(helm-locate-set-command)
(setq helm-locate-fuzzy-match (and (bound-and-true-p helm-use-fuzzy)
(string-match "locate" helm-locate-command)))
(string-match "locate" helm-locate-command)
t))
(setq helm-boring-buffer-regexp-list
(append helm-boring-buffer-regexp-list
spacemacs-useless-buffers-regexp))

View File

@ -47,15 +47,6 @@
:background nil
:inherit 'helm-ff-directory))
(defun spacemacs//helm-make-source (f &rest args)
"Function to be used as advice to activate fuzzy matching for all sources."
(let ((source-type (cadr args))
(props (cddr args)))
;; fuzzy matching is not supported in async sources
(unless (child-of-class-p source-type helm-source-async)
(plist-put props :fuzzy-match (eq 'always helm-use-fuzzy))))
(apply f args))
(defun spacemacs//helm-find-files-enable-helm--in-fuzzy ()
"Enabling `helm--in-fuzzy' with the hook:
`helm-find-files-after-init-hook'. Fixes the error:

View File

@ -27,8 +27,8 @@
(default-ivy-config :location built-in)
flx-ido
(ido :location built-in)
(ido-vertical-mode :location built-in)
))
(ido-vertical-mode :location built-in)))
(defun spacemacs-completion/init-default-helm-config ()
(setq helm-prevent-escaping-from-minibuffer t
@ -39,6 +39,7 @@
helm-echo-input-in-header-line t
helm-imenu-execute-action-at-once-if-one nil
helm-org-format-outline-path t
helm-completion-style (if (eq helm-use-fuzzy 'always) 'helm-fuzzy 'helm)
helm-display-function 'spacemacs//display-helm-window)
(with-eval-after-load 'helm
(spacemacs|hide-lighter helm-mode)
@ -61,10 +62,6 @@
(add-hook 'helm-find-files-after-init-hook
'spacemacs//helm-find-files-enable-helm--in-fuzzy)
;; setup advices
;; fuzzy matching for all the sources
(unless (eq helm-use-fuzzy 'source)
(advice-add 'helm-make-source :around #'spacemacs//helm-make-source))
(defadvice spacemacs/post-theme-init
(after spacemacs/helm-header-line-adv activate)
"Update defaults for `helm' header line whenever a new theme is loaded"
@ -118,23 +115,23 @@
("t" helm-toggle-visible-mark)
("T" helm-toggle-all-marks)
("v" helm-execute-persistent-action))
(define-key helm-map (kbd "M-SPC")
'spacemacs/helm-navigation-transient-state/body)
(define-key helm-map (kbd "s-M-SPC")
'spacemacs/helm-navigation-transient-state/body)
(define-key helm-map (kbd "M-SPC")
'spacemacs/helm-navigation-transient-state/body)
(define-key helm-map (kbd "s-M-SPC")
'spacemacs/helm-navigation-transient-state/body)
;; Swap default TAB and C-z commands.
;; For GUI.
(with-eval-after-load 'helm-files
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-find-files-map
(kbd "S-<tab>") 'helm-find-files-up-one-level)
(define-key helm-find-files-map
(kbd "<backtab>") 'helm-find-files-up-one-level)
;; For terminal.
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
(define-key helm-find-files-map
(kbd "S-TAB") 'helm-find-files-up-one-level)
(define-key helm-map (kbd "C-z") 'helm-select-action))))
(with-eval-after-load 'helm-files
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-find-files-map
(kbd "S-<tab>") 'helm-find-files-up-one-level)
(define-key helm-find-files-map
(kbd "<backtab>") 'helm-find-files-up-one-level)
;; For terminal.
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
(define-key helm-find-files-map
(kbd "S-TAB") 'helm-find-files-up-one-level)
(define-key helm-map (kbd "C-z") 'helm-select-action))))
(defun spacemacs-completion/init-default-ivy-config ()
(with-eval-after-load 'ivy
@ -146,14 +143,14 @@
(add-hook 'spacemacs-editing-style-hook 'spacemacs//ivy-hjkl-navigation)
;; key bindings
;; ensure that the correct bindings are set at startup
(spacemacs//ivy-hjkl-navigation dotspacemacs-editing-style)
(spacemacs//ivy-hjkl-navigation dotspacemacs-editing-style)))
;; load ivy-hydra
;; (require 'ivy-hydra)
;; Using the original ivy-hydra might lead to some buggy behavior. Therefore
;; previously a customized transient state was found here. This customized
;; transient state was removed after commit
;; d46eacd83842815b24afcb2e1fee5c80c38187c5
))
(defun spacemacs-completion/init-flx-ido ()
(use-package flx-ido