oantolin / orderless

Emacs completion style that matches multiple regexps in any order
GNU General Public License v3.0
745 stars 27 forks source link

Orderless doesn't work as desired. #139

Closed hongyi-zhao closed 1 year ago

hongyi-zhao commented 1 year ago

I try to test orderless using a customized init.el.debug file as follows:

werner@X10DAi:~/.emacs.d$ cat init.el.debug 
#!/usr/bin/env bash
:;# Testing steps using this script:
:;# 1. Create an empty directory EMACS_DEBUG as follows:
:;#    $ mkdir -p ~/.emacs.d/debug
:;# 2. $ mkdir -p $EMACS_DEBUG/.emacs.d
:;# 3. Name this script as $EMACS_DEBUG/.emacs.d/init.el
:;# 4. Test as following:
:;#    $ bash $EMACS_DEBUG/.emacs.d/init.el

:;#https://groups.google.com/g/comp.unix.shell/c/krxzfCd_8qM/m/ryoNs9AGCQAJ
:;# https://groups.google.com/g/comp.unix.shell/c/3vrq7pqoG-A/m/Hnk0lsKfAwAJ
:;# https://lists.gnu.org/archive/html/help-gnu-emacs/2021-10/msg00698.html
:;# https://github.com/company-mode/company-mode/discussions/1248#discussioncomment-1535692
:;# HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 /usr/local/bin/emacs -- "$@"; exit
:;# or
:;# HOME=$(dirname $(dirname $(realpath -e $0))) exec proxychains-ng-socks5 /usr/local/bin/emacs -- "$@"

:;# without proxychains
:; HOME=$(dirname $(dirname $(realpath -e $0))) exec /usr/local/bin/emacs -- "$@"

;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

;; https://github.com/raxod502/straight.el/issues/891#issuecomment-982449838

;; Your testing elisp code comes after here.
(use-package orderless
  :ensure t
  :custom
  (completion-styles '(orderless basic))
  (completion-category-overrides '((file (styles basic partial-completion)))))

(use-package swiper
  :bind ("C-s" . swiper)
  )  

See the testing results below:

image

But the following gives nothing:

image

Any tips for fixing this problem?

Regards, Zhao

oantolin commented 1 year ago

I haven't used Swiper or Ivy (the completion framework it depends on) recently, but at the time I wrote the Orderless documentation it used to be true that Ivy did not use completion-styles at all. I did write some separate Ivy integration instructions in the Orderless manual. That link just says to use this configuration:

(setq ivy-re-builders-alist '((t . orderless-ivy-re-builder)))
(add-to-list 'ivy-highlight-functions-alist '(orderless-ivy-re-builder . orderless-ivy-highlight))

Please let me know if that works.

hongyi-zhao commented 1 year ago

Thank you for your comments. The following configuration does the trick:

(use-package orderless
  :ensure t
  :custom
  (completion-styles '(orderless basic))
  (completion-category-overrides '((file (styles basic partial-completion)))))

;;https://writequit.org/denver-emacs/presentations/2017-04-11-ivy.html#orgc2d4898
(use-package ivy
  :demand
  :config
  (setq ivy-use-virtual-buffers t
        enable-recursive-minibuffers t
        ivy-count-format "%d/%d "
    ivy-re-builders-alist '((t . orderless-ivy-re-builder))
    )
  (add-to-list 'ivy-highlight-functions-alist '(orderless-ivy-re-builder . orderless-ivy-highlight))
  )

;;https://github.com/abo-abo/swiper/issues/2899#issuecomment-890300284
(use-package swiper
  :bind ("C-s" . swiper)
  )

image