axelf4 / hotfuzz Goto Github PK
View Code? Open in Web Editor NEW🚓 Fuzzy Emacs completion style
License: GNU General Public License v3.0
🚓 Fuzzy Emacs completion style
License: GNU General Public License v3.0
load-path
and the dynamic module compiledemacs -Q
(require 'hotfuzz)
(setq completion-ignore-case nil completion-styles '(hotfuzz))
M-x ico TAB
Debugger entered--Lisp error: (args-out-of-range -1 0)
hotfuzz-highlight("ico" "Info-copy-current-node-name")
hotfuzz-all-completions("ico" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>) 3)
#f(compiled-function (style) #<bytecode -0x15acac061a767570>)(hotfuzz)
completion--some(#f(compiled-function (style) #<bytecode -0x15acac061a767570>) (hotfuzz))
completion--nth-completion(2 "ico" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>) 3 (metadata (affixation-function . read-extended-command--affixation) (category . command)))
completion-all-completions("ico" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>) 3 (metadata (affixation-function . read-extended-command--affixation) (category . command)))
minibuffer-completion-help(5 8)
completion--do-completion(5 8)
completion--in-region-1(5 8)
#f(compiled-function (start end collection predicate) #<bytecode -0x14449fda63109437>)(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>))
apply(#f(compiled-function (start end collection predicate) #<bytecode -0x14449fda63109437>) (5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>)))
#f(compiled-function (funs global args) #<bytecode 0x14cbe248837bd538>)(nil nil (5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>)))
completion--in-region(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>))
completion-in-region(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>))
minibuffer-complete()
funcall-interactively(minibuffer-complete)
command-execute(minibuffer-complete)
completing-read-default("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_53> #f(compiled-function (sym) #<bytecode -0xf5766db6d1bf19>) t nil extended-command-history nil nil)
read-extended-command()
byte-code("\302\30\11\303 \10E)\207" [execute-extended-command--last-typed current-prefix-arg nil read-extended-command] 3)
command-execute(execute-extended-command)
My understanding is that:
hotfuzz-filter
, using the dynamic module, lets Info-copy-current-node-name
through due to unconditional case-insensitivity.hotfuzz-highlight
fails because it then tries to recompute some stuff using the case-sensitive Lisp code.Why does hotfuzz-highlight
need to call hotfuzz--calc-bonus
and hotfuzz--match-row
? Can’t it re-use the vectors filled by hotfuzz-filter
?
When compiling the dynamic module on NixOS, this error occurs.
-- The C compiler identification is Clang 12.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /etc/profiles/per-user/cory/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
CMake Error at CMakeLists.txt:17 (find_path):
Could not find EMACS_INCLUDE_DIR using the following files: emacs-module.h
-- Configuring incomplete, errors occurred!
See also "/tmp/hotfuzz/build/CMakeFiles/CMakeOutput.log".
Steps to replicate:
mkdir build
cd build
cmake -DCMAKE_C_FLAGS='-O3 -march=native' .. && cmake --build .
I cannot find what the variable EMACS_INCLUDE_DIR is on normal machines so I cannot set it to the appropriate path for NixOS.
I would assume Guix probably has a similar issue.
Hi @axelf4 I just found out about this project. I'm the guy who created flex
. As far as I can see, hotfuzz is like flex
but presumably better in every possible way. If that is true, I think we should just replace Emacs's flex
with it, so long as you're willing to contribute the code to GNU Emacs (signing FSF papers, etc). WDYT?
hotfuzz is super-quick and sorting looks great, so hoping I can get this working! I haven't worked out why yet, but when I set completion-styles
to '(hotfuzz)
, it breaks how vertico-directory works, removes all-the-icons icons, and removes margnalia's info from find-file. Interestingly marginalia still works M-x
and hotfuzz, just not find-file
.
Below is a minimal init.el that you can put in a directory, e.g. /tmp/emacs-init, and run emacs with e.g. emacs --init-directory /tmp/emacs-init
to observe this:
;; Bootstrap straight.
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(use-package vertico
:straight (vertico :files (:defaults "extensions/*"))
:hook after-init
:bind (:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word)))
(use-package marginalia
:hook after-init
:custom
(marginalia-max-relative-age 0)
(marginalia-align 'left))
(use-package all-the-icons
:if (display-graphic-p))
(use-package all-the-icons-completion
:if (display-graphic-p)
:after marginalia
:hook ((after-init)
(marginalia-mode . all-the-icons-completion-marginalia-setup)))
(use-package hotfuzz
:hook (vertico-mode . hotfuzz-vertico-mode)
:custom (completion-styles '(hotfuzz)))
If you comment out the hotfuzz use-package and test find-file
everything works as usual. Any ideas?
(cc @minad — as the owner of some of the affected packages I wonder if you might see an obvious issue we can fix? :)
Consult apparently tags strings with invalid character; see https://www.reddit.com/r/emacs/comments/n43mdo/problem_with_narrowing_minibuffer_items_with/
Minimal example: (hotfuzz--filter-c "tet" (list (concat "test" (char-to-string #x200000))))
The following error message is displayed in the minibuffer when inserting a link into an Org file when Fido is enabled and hotfuzz is the completion style:
[Error in post-command-hook (icomplete-post-command-hook): (wrong-type-argument listp 0)]
The error occurs during the completion of a link's protocol. The error occurs immediately after the first character is entered. The error message disappears immediately after a subsequent character is entered.
The error does not occur with any other completion style that I tested.
I found two Icomplete settings that prevent the error. Either of the following settings does the trick:
(setq icomplete-max-delay-chars 0)
(advice-add 'icomplete--fido-mode-setup :after
(lambda () (setq-local icomplete-show-matches-on-no-input nil)))
Hi, I use a build from emacsformacos and the Emacs installation structure is non-standard for its build.
FWIW, to compile hotfuzz on such non-standard setup one will need to set the environment variable
EMACS_ROOT
to the root directory of Emacs (i.e. the directory contains the include/
, lisp/
, site-lisp/
, etc.)
For emacsformacos, one should set to it to EMACS_ROOT
to '/Applications/Emacs.app/Contents/Resources/'
.
Maybe these information should be added to README.
I've been playing around with the hotfuzz-module and it's so fast — just ran into one issue with consult which uses these 'tofu' characters in candidates which breaks with this error:
Debugger entered--Lisp error: (wrong-type-argument unicode-string-p #(".gitignore�" 0 10 (face consult-file multi-category (file . ".gitignore")) 10 11 (invisible t consult-strip t)))
hotfuzz--filter-c("m" (#(".gitignore�" 0 10 (face consult-file multi-category (file . ".gitignore")) 10 11 (invisible t consult-strip t)) #("README.md�" 0 9 (face consult-file multi-category (file . "README.md")) 9 10 (invisible t consult-strip t))
...
Any ideas how I can work around this? I've tried stripping out those characters but to no avail so far. Oddly enough it works fine without the compiled module (albeit much slower), so it might actually be an issue with my system/compiled module.
Hello,
When using orderless
(or in fact any other completion style I know of), when typing, say M-x
, I get the most recently called commands first. This is not the case with hotfuzz
however. This is a major usability issue for me.
Best and thank you for this code.
You mention these other completion styles but fail to say which major fuzzy completion features hotfuzz does or does not implement.
For example, it would be useful to know if it supports soace-separated, out of order matches like orderless. Please consider summarizing its features for potential new users.
Hotfuzz seems to be working brilliantly with vertico, but there is no indication of which parts of the results are resulting from matching which letters. Is that something that would need to be implemented on the hotfuzz side or vertico side?
Does this package work with company-mode
?
Regards,
Zhao
See oantolin/orderless#151 and minad/vertico@b11040e for reference.
I've written a function like this:
(defun zsh-history ()
"Copy a command from ~/.zsh_history."
(interactive)
;; https://emacs.stackexchange.com/questions/8115/make-completing-read-respect-sorting-order-of-a-collection
(let* ((my-presorted-completion-table-fn
(defun my-presorted-completion-table (completions)
(lambda (string pred action)
(if (eq action 'metadata)
`(metadata (display-sort-function . ,#'identity))
(complete-with-action action completions string pred)))))
(command
(with-temp-buffer
(insert-file-contents-literally "~/.zsh_history")
(let ((history-list
(split-string (buffer-string)
"^:[[:space:]][[:digit:]]+:0;"
t
"\n")))
(completing-read
"Command: "
(funcall my-presorted-completion-table-fn
(reverse history-list)))))))
(when command
(message (format "Copying %s to clipboard." command))
(kill-new command))))
My .zsh_history has quite a few lines of upwards of 20,000 characters, etc. With the hotfuzz completion-style, this will fail and crash/stall the entire completion.
I integrated your scoring algorithm into its own scoring function here: https://github.com/jojojames/fussy#hotfuzz to see if I can get past this issue.
Commit: jojojames/fussy@59d7581
I have a defcustom/variable here https://github.com/jojojames/fussy/blob/59d75816e111bfc4be8342cee59df0035a181a95/fussy.el#L78 to control the max length of a string to attempt to score. It's at 1000 by default (will probably change it to 500 soon) and even that fails. Once I change this variable's to something like 500, hotfuzz is able to work with my zsh-history completing-read function.
Integration here: https://github.com/jojojames/fussy/blob/59d75816e111bfc4be8342cee59df0035a181a95/fussy.el#L732
I noticed hotfuzz doesn't yet have highlighting with vertico (looks like that's in progress here: #3). Highlighting+hotfuzz works in fussy leveraging the built-in highlighting code, though it may not be 100% perfect.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.