help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

can vertico approximate this ido setup?


From: Samuel Wales
Subject: can vertico approximate this ido setup?
Date: Sat, 3 Jun 2023 18:40:04 -0700

i have used ido, with this set of libraries:

  ido
  ido-hacks [speeds up ido and makes it run most places]
  ido-clever-match [really good matching]
  a line that makes it vertical, not horizontal

it generally works well in /most/ places in emacs, including
org-refile.  i /usually/ get the candidate i want with supernatural
efficiency.  there are maybe a few glitches, but they are really small
with my setup, which is below.

sometimes i do c-x c-f and then c-f again to get regular find-file so
i can do tramp or so.

this ido setup works well enough for me, but i fear it might not work
in a future emacs upgrade.  i currently use emacs 27.1.  in at least
one past upgrade i have had to upgrade something or make a change to
get it to work.  i don't want that.


recently, vertico and orderless and friends have come along, and they
use the standard completion mechanism, and have more features, and
they feel like they are well maintained and configurable and will
stick around.

i'd like to set them up to work approximately like my vertical and
clever matching ido setup, at least initially.  to try.

but my initial attempts were worse than my ido setup.  i do NOT know
what i am doing here.  but e.g.

  - my selections are very wrong compared to clever match
  - faces don't seem to get recognized when i specify them
    - also i don't get variable pitch
    - also i don't understand the completion-first-difference face
  - not sure how to get a less-busy marginalia [not critical]
  - still figuring out things like m-ret for create new dir
  - have not tried consult yet
  - embark uses more than window height or confuses

i am very limited in computer use, so before i try new things or
search, i want to know if it is worth trying to configure vertico to
work approximately like my setup.  my question is whether it is
configurable to come close-ish to my ido.

i do not use ido fancy features like virtual buffers or directory merge stuff.

here are my notes in my old color-theme on the faces:

       ;; vertico uses this
       ;; this isn't reflected in results when changed here
       ;; fixme variable pitch
       ;; mode or my direct
       (completions-annotation ((t (:background "black" :foreground
"#d44400"))))
       ;; default is italic
       ;; this is not respected by marginalia for some reason so
       ;; marginalia tends to be an overly bright copper for e.g.
       ;; docstrings
       ;; (completions-annotation ((t (:background "black" :foreground
"#f48400"))))
       ;; (completions-annotation ((t (:background "black" :foreground
"#e46400"))))

       (completions-common-part ((t (:background "black" :foreground
"#aaaa00"))))
       ;; (completions-common-part ((t (:background "black"
:foreground "#666600"))))
       ;; (completions-common-part ((t (:background "black"
:foreground "grey60"))))

       ;; fixme idk if this is correct in vertico
       ;; supposed to be first char after point
       ;; and so it is
       ;; but if you enter that char,
       ;; you might get a different line than you expected
       ;; so what is it good for?
       (completions-first-difference ((t (:foreground "OrangeRed2"))))

here is my vertico and friends setup:

;; package-initialize seems not to take care of turning on modes
(vertico-mode)
(cl-pushnew 'orderless completion-styles)
(cl-pushnew 'flex completion-styles)
(cl-pushnew 'prefix completion-styles)
(cl-pushnew 'substring completion-styles)
;; (marginalia-mode)
;; try built in wth flex and also fido but need vertical q is in 28
(require 'orderless)
(with-eval-after-load 'orderless
  (add-to-list 'orderless-matching-styles 'orderless-flex))

and here is some messy years-old comments and setup for my pretty
comfortable vertical clever matching ido:

(progn
  ;;might not be nec if ido-everywhere
  (require 'ido)
  ;;prob not nec if require is used; require is not nec if this is used
  (ido-mode 1)
  ;;(ido-mode 0)
  ;;maybe this allows dired copying
  ;;(ido-everywhere 1)                      ;conflict with ido-hacks?
  ;; what is ido-ubiquitous?
  ;; do i need ido-completing-read-plus?
  ;; do i need ido-speed-hack?  ido-hacks is very fast as it is.

  ;; for pop-up-windows ido-default-buffer-method
  ;;
  ;; instead of raising frame if exists in another frame
  ;; (setq ido-default-file-method 'selected-window)

  (defadvice ido-switch-buffer
      (before ido-try-superstition activate compile)
    (switch-to-buffer (current-buffer)))

  ;; this is like orderless
  ;; (define-key ido-common-completion-map (kbd "SPC")
#'ido-restrict-to-matches)
  ;; (define-key ido-common-completion-map (kbd "SPC") #'ido-complete-space)

  ;;i think it gets the dir list to merge from the default dirs of
  ;;all open buffers -- so open a file then you can find others.
  ;;ka.
  (setq ido-auto-merge-work-directories-length -1)
;;; (setq ido-auto-merge-work-directories-length 5)
  ;;make / work better
  ;; (setq ido-enter-matching-directory 'first)
;;; (setq ido-enter-matching-directory 'only)
;;; (setq ido-enter-matching-directory t)

  ;;not sure what this does
  ;;(setq ido-rotate-file-list-default t)
  ;;(setq ido-rotate-file-list-default nil)
  ;;(setq ido-max-work-file-list 100)
  (setq ido-create-new-buffer 'always)
  ;; fixme dunno if this is needed
  (setq confirm-nonexistent-file-or-buffer nil)
  ;; (setq ido-confirm-unique-completion t)
  ;;(setq ido-confirm-unique-completion nil)
  ;;privacy leak if not there, but to default, just change
  ;;alpha-getenv to getenv.
  ;;this seems to work without a slash
  ;; (alpha-awhen (alpha-getenv "demacsbackup")
  ;;   (setq ido-save-directory-list-file
  ;;         (expand-file-name "emacs-ido-save-directory-list-file" it)))
  (setq ido-show-dot-for-dired t)
  ;;(setq resize-mini-windows t) ;emacs 22 default is grow-only
  ;;emacs 22 default is 0.25.  this is good for edebug.
  ;;(setq max-mini-window-height 0.33)
  (setq ido-max-window-height 0.66) ;overrides max-mini-window-height
  ;;default 12
  ;;(setq ido-max-prospects 12)
  ;;(setq ido-max-prospects 10)
  ;; buggy (setq ido-enable-tramp-completion nil)
  ;; (setq ido-enable-tramp-completion t)
  (setq ido-enable-flex-matching t)
  ;; uses completion-ignored-extensions to ignore .git
  ;; fixme maybe include this but remove ones with /
  (setq ido-ignore-extensions nil)
  ;; (setq ido-ignore-extensions t)
  ;;ido-ignore-buffers

  ;; (setq ido-use-filename-at-point t)
  (setq ido-use-filename-at-point nil)

  ;; vertical layout ka
  (setq ido-decorations
        (quote
         ("\n-> " ""
                  ;;see ido-separator
                  "\n   "
                  ;;ellipsis
                  ""
;;;                   "\n   ..."
                  "[" "]"
                  " [No match]"
                  " [Matched]"
                  " [Not readable]"
                  " [Too big]"
                  " [Confirm]")))
  (add-hook 'ido-setup-hook 'alpha-ido-my-keys)
  (defun alpha-ido-my-keys ()
    "Add my keybindings for ido."
    ;; i think spc in default ido (ido-complete-space) is just tab
    ;; that sometimes inserts spc.
    ;;
    ;; in at least org-mode olpath completion, such as for refiling,
    ;; at least with ido-hacks, spc by default always tries to
    ;; complete.  this behavior might or might not be related to
    ;; variables like (setq org-refile-use-outline-path 'file).
    ;;
    ;; we have tab already for completion, so spc is not necessary
    ;; for completion.  therefore i define spc to work globally in
    ;; ido like letters.
    ;;
    ;; i use ido-hacks.el, which runs ido all over emacs, so the
    ;; filename-centric assumption that filenames don't include
    ;; spaces, or the attempt at context-dependent insertion of
    ;; space, do not apply.
    (define-key ido-completion-map " " 'self-insert-command))

  ;;     (define-key ido-completion-map (kbd "C-n") 'ido-next-match)
  ;;     (define-key ido-completion-map (kbd "C-p") 'ido-prev-match))
  ;;   (add-hook 'ido-minibuffer-setup-hook 'ido-disable-line-truncation)

  (add-hook 'ido-setup-hook 'alpha-ido-setup-hook)
  ;; was ido-minibuffer-setup-hook
  (defun alpha-ido-setup-hook ()
    ;; notwork to fix the bug where / goes to the wrong dir
    ;; (define-key ido-completion-map (kbd "/") 'ido-exit-minibuffer)
    (define-key ido-completion-map [up] 'ido-prev-match)
    (define-key ido-completion-map [down] 'ido-next-match)
    ;; in horizontal ido
    ;;   up down is dirs (and history in org refiling and buffers)
    ;;   left right is choices
    ;; in this fixed vertical ido
    ;;   up down is choices
    ;;   left right is dirs (and dirs=nothing in org refiling and buffers)
    ;;     maybe i want this to be history when that makes sense
    ;;   c-up c-down is history
    (define-key ido-completion-map (kbd "C-<up>") 'previous-history-element)
    (define-key ido-completion-map (kbd "C-<down>") 'next-history-element)
    (define-key ido-completion-map [right] 'ido-next-match-dir)
    (define-key ido-completion-map [left] 'ido-prev-match-dir)
    ;; fixme if previous-history-element is on up down, then bind
    ;; it to left right -- or even control up down
    ;; fixme or history on left right, choices on up down, dir on
    ;; control up down
    ;; or c-n c-p for something
    ;; normally left right edits and up down is history
    ;; (set (make-local-variable 'truncate-lines) nil)
    )

  ;; fixme no ned to enable recentf.  just set this.
  ;; (setq ido-use-virtual-buffers t)
  ;;fixme privacy violations -- but see recentf-exclude
  ;;   =later presumably i meant if your buffer you wanted gone
  ;;(add-to-list 'recentf-exclude ...)

;;;Control-TAB buffer switching with Ido
;;;
;;;nXhtml tweaks Ido to do ControlTABbufferCycling combined
;;;with Ido’s normal buffer switching.

  (require 'ido-hacks)
  (with-no-warnings (ido-hacks-mode 1))
;;; (ido-hacks-mode 0)
;;; (ido-hacks-mode -1)
;;; (ido-hacks-mode nil)

  (when (require 'ido-clever-match nil t)
    ;; make header sort higher if substring earlier in header
    ;; (ido-clever-match-disable)
    (ido-clever-match-enable))

  ;; fixme why does this remapping not work?
  (define-key global-map [remap ido-write-file] 'alpha-ido-write-file)
  (define-key global-map [remap write-file] 'alpha-ido-write-file)
  (defun alpha-ido-write-file ()
    "fixed to include files.

Write current buffer to a file.
The file name is selected interactively by typing a substring.
For details of keybindings, see `ido-find-file'."
    (interactive)
    (let (
          ;; (ido-process-ignore-lists t)
          (ido-work-directory-match-only nil)
          ;; (ido-ignore-files (cons "[^/]\\'" ido-ignore-files))
          (ido-report-no-match nil)
          (ido-confirm-unique-completion t)
          (ido-auto-merge-work-directories-length -1))
      (ido-file-internal 'write 'write-file nil "Alpha Ido Write file:
" nil nil 'ignore))))


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]