summaryrefslogtreecommitdiffhomepage
path: root/attic
diff options
context:
space:
mode:
Diffstat (limited to 'attic')
-rw-r--r--attic/misc.org118
1 files changed, 90 insertions, 28 deletions
diff --git a/attic/misc.org b/attic/misc.org
index 3aac8c7..a5bc802 100644
--- a/attic/misc.org
+++ b/attic/misc.org
@@ -848,41 +848,103 @@
#+end_src
* vertico
#+begin_src emacs-lisp
- (use-package vertico
- :ensure t
- :init
- (setq vertico-count 10
- vertico-cycle t
- vertico-resize t
- org-refile-use-outline-path t
- resize-mini-windows nil)
-
- (vertico-mode)
-
- :bind (:map vertico-map (("RET" . vertico-directory-enter)
- ("M-<backspace>" . vertico-directory-delete-word)
- ("<backspace>" . vertico-directory-delete-char))))
-
- (use-package vertico-directory
- :after vertico)
-
- (use-package vertico-reverse
- :after vertico
- :init (vertico-reverse-mode))
-
(use-package vertico-repeat
:after vertico
:config (add-hook 'minibuffer-setup-hook #'vertico-repeat-save)
:bind (("M-R" . vertico-repeat)))
- ;; (use-package vertico-buffer
- ;; :after vertico
- ;; :init
- ;; (setq vertico-buffer-display-action
- ;; '(display-buffer-at-bottom (window-height . ,(+ 3 vertico-count))))
- ;; (vertico-buffer-mode -1))
+ (use-package vertico-buffer
+ :after vertico
+ :init
+ (setq vertico-buffer-display-action
+ '(display-buffer-at-bottom (window-height . ,(+ 3 vertico-count))))
+ (vertico-buffer-mode -1))
+ #+end_src
+* orderless
+ #+begin_src emacs-lisp
+ (defun orderless--strict-*-initialism (component &optional anchored)
+ (orderless--separated-by
+ '(seq (zero-or-more alpha) word-end (zero-or-more (not alpha)))
+ (cl-loop for char across component collect `(seq word-start ,char))
+ (when anchored '(seq (group buffer-start) (zero-or-more (not alpha))))
+ (when (eq anchored 'both)
+ '(seq (zero-or-more alpha) word-end (zero-or-more (not alpha)) eol))))
+
+ (defun orderless-strict-initialism (component)
+ (orderless--strict-*-initialism component))
+
+ (defun orderless-strict-leading-initialism (component)
+ (orderless--strict-*-initialism component 'start))
+
+ (defun orderless-strict-full-initialism (component)
+ (orderless--strict-*-initialism component 'both))
+
+ (defun jao-orderless--dispatch (pattern index _total)
+ (cond ((and (zerop index) (string-prefix-p "-" pattern))
+ `(orderless-strict-full-initialism . ,(substring pattern 1)))
+ ((string-suffix-p "%" pattern)
+ `(orderless-regexp . ,(substring pattern 0 -1)))
+ ((string-equal "!" pattern)
+ '(orderless-literal . ""))
+ ((string-prefix-p "!" pattern)
+ `(orderless-without-literal . ,(substring pattern 1)))))
+ (setq orderless-style-dispatchers '(jao-orderless--dispatch))
#+end_src
+* consult dir
+ #+begin_src emacs-lisp :tangle no
+ (use-package consult-dir
+ :ensure t
+ :bind (("C-x C-d" . consult-dir)
+ :map minibuffer-local-completion-map
+ (("C-x C-d" . consult-dir)
+ ("C-x C-j" . consult-dir-jump-file))))
+ #+end_src
+* embark
+*** prompt format
+ #+begin_src emacs-lisp
+ (defvar jao-embark--brx
+ "^\\(\\([^ ] \\)+\\|RET\\|TAB\\|SPC\\)\\( *\\)\\([^ ]+ +\\)\\(.*\\)$")
+
+ (defun jao-embark--cmp (x y)
+ (let* ((lxk (get-text-property 0 'kbd x))
+ (lyk (get-text-property 0 'kbd y)))
+ (if (= lxk lyk) (string< x y) (< lxk lyk))))
+
+ (defun jao-embark--cmd-doc (cmd)
+ (propertize (car (split-string (or (embark--function-doc cmd) "") "\n"))
+ 'face 'embark-verbose-indicator-documentation))
+
+ (defun jao--max-len (strs)
+ (seq-reduce (lambda (m x) (max m (length x))) strs 0))
+
+ (cl-defun jao-embark--other (&key shadowed-targets &allow-other-keys)
+ (propertize (format "%s" (or shadowed-targets ""))
+ 'face 'embark-verbose-indicator-shadowed))
+
+ (cl-defun jao-embark--bindings (&key bindings &allow-other-keys)
+ (let* ((cmds (mapcar #'caddr bindings))
+ (docs (mapcar #'jao-embark--cmd-doc cmds))
+ (keys (mapcar (lambda (b)
+ (propertize (car (last b))
+ 'face 'embark-keybinding))
+ bindings))
+ (cmds (mapcar (lambda (b)
+ (propertize (cadr b) 'face 'embark-command))
+ bindings))
+ (fmt (format "%%-%ds %%-%ds %%s\n"
+ (jao--max-len cmds) (jao--max-len keys)))
+ (res (seq-mapn (lambda (c k d)
+ (let ((n (if (string-prefix-p "embark-" c)
+ 10
+ (length k))))
+ (propertize (format fmt c k d) 'kbd n)))
+ cmds keys docs)))
+ (apply #'concat (seq-sort #'jao-embark--cmp res))))
+
+ (setq embark-verbose-indicator-buffer-sections
+ '(jao-embark--bindings "\n" target " " jao-embark--other))
+ #+end_src
* window config persistence
#+begin_src emacs-lisp
(use-package bookmark-view