From 0495456fb904bf291a71ff87d59a5dda5d0c298d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 14 Jan 2022 21:03:36 -0600 Subject: [PATCH] Ch ch ch changes --- init.el | 13 ++++++++-- lisp/+consult.el | 2 +- lisp/+eww.el | 2 +- lisp/+init.el | 17 ++++++++----- lisp/+orderless.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 lisp/+orderless.el diff --git a/init.el b/init.el index 36c2bed..134b81a 100644 --- a/init.el +++ b/init.el @@ -920,7 +920,7 @@ (comint-mode-map . comint-mode-hook) (sly-mrepl-mode-map . sly-mrepl-hook))) (with-eval-after-load 'orderless - (:option consult--regexp-compiler 'consult--orderless-regexp-compiler)))) + (:option consult--regexp-compiler #'consult--orderless-regexp-compiler)))) (setup (:straight consult-dir) (:+key "C-x C-d" #'consult-dir) @@ -1278,7 +1278,16 @@ See also `crux-reopen-as-root-mode'." "C-e" #'mwim-end)) (setup (:straight orderless) - (:option completion-styles '(orderless))) + (:also-load +orderless) + (:option completion-styles '(substring orderless basic) + completion-category-defaults nil + completion-category-overrides + '((file (styles partial-completion)) + (command (styles +orderless-with-initialism)) + (variable (styles +orderless-with-initialism)) + (symbol (styles +orderless-with-initialism))) + orderless-component-separator #'orderless-escapable-split-on-space + orderless-style-dispatchers '(+orderless-dispatch))) (setup (:straight org-appear) (:option org-appear-autoemphasis t diff --git a/lisp/+consult.el b/lisp/+consult.el index 7b6a20f..0f5bf45 100644 --- a/lisp/+consult.el +++ b/lisp/+consult.el @@ -5,7 +5,7 @@ (defun +consult-project-root () "Return either the current project, or the VC root, of current file." (if (and (functionp 'project-current) - (project-current)) + (project-current)) (car (project-roots (project-current))) (vc-root-dir))) diff --git a/lisp/+eww.el b/lisp/+eww.el index aad602f..8d53571 100644 --- a/lisp/+eww.el +++ b/lisp/+eww.el @@ -65,7 +65,7 @@ (defun +eww-bookmark-setup () "Setup eww bookmark integration." - (setq-local bookmark-make-record-function #'eww-bookmark--make)) + (setq-local bookmark-make-record-function #'+eww-bookmark--make)) (provide '+eww) ;;; +eww.el ends here diff --git a/lisp/+init.el b/lisp/+init.el index c1f3cb5..a4c3b5a 100644 --- a/lisp/+init.el +++ b/lisp/+init.el @@ -80,12 +80,17 @@ are sorted lexigraphically." (defun +init-add-setup-to-imenu () "Recognize `setup' forms in `imenu'." ;; `imenu-generic-expression' automatically becomes buffer-local when set - (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal) - (list - (rx (: bol (* space) - "(setup" (+ space) - (group (? "(") (* nonl)))) - 1))) + (setf (alist-get "Setup" imenu-generic-expression nil nil #'equal) + (list + (rx (: "(setup" (+ space) + (group (? "(") (* nonl)))) + 1)) + (when (boundp 'consult-imenu-config) + (setf (alist-get ?s + (plist-get + (alist-get 'emacs-lisp-mode consult-imenu-config) + :types)) + '("Setup")))) ;;; Major mode diff --git a/lisp/+orderless.el b/lisp/+orderless.el new file mode 100644 index 0000000..b2f53b0 --- /dev/null +++ b/lisp/+orderless.el @@ -0,0 +1,60 @@ +;;; +orderless.el --- Mostly from minad -*- lexical-binding: t; -*- + +;;; Commentary: + +;; See https://github.com/minad/consult/wiki#minads-orderless-configuration + +;;; Code: + +(require 'orderless) + +;;; Dispataching + +(defvar +orderless-dispatch-alist '((?% . char-fold-to-regexp) + (?! . orderless-without-literal) + (?` . orderless-initialism) + (?= . orderless-literal) + (?~ . orderless-flex)) + "Charcters to dispatch styles on orderless segments.") + +(defun +orderless-dispatch (pattern index _total) + "Dispatch orderless segments of a search string. +Dispatchers are taken from `+orderless-dispatch-alist', and added +to the following defaults: + +- regexp$ :: matches REGEXP at the end of the pattern. +- .ext :: matches EXT (at end of pattern) + +Dispatch characters can be added at the beginning or ending of a +segment to make that segment match accordingly." + (cond + ;; Ensure that $ works with Consult commands, which add disambiguation + ;; suffixes + ((string-suffix-p "$" pattern) + (cons 'orderless-regexp + (concat (substring pattern 0 -1) "[\x100000-\x10FFFD]*$"))) + ;; File extensions + ((and + ;; Completing filename or eshell + (or minibuffer-completing-file-name + (derived-mode-p 'eshell-mode)) + ;; File extension + (string-match-p "\\`\\.." pattern)) + (cons orderless-regexp + (concat "\\." (substring pattern 1) "[\x100000-\x10FFFD]*$"))) + ;; Ignore single ! + ((string= "!" pattern) `(orderless-literal . "")) + ;; Prefix and suffix + ((if-let (x (assq (aref pattern 0) +orderless-dispatch-alist)) + (cons (cdr x) (substring pattern 1)) + (when-let (x (assq (aref pattern (1- (length pattern))) + +orderless-dispatch-alist)) + (cons (cdr x) (substring pattern 0 -1))))))) + +(orderless-define-completion-style +orderless-with-initialism + (orderless-matching-styles '(orderless-initialism + orderless-literal + orderless-regexp))) + +(provide '+orderless) +;;; +orderless.el ends here