TAB-and-Go completion: (wrong-type-argument integer-or-marker-p nil)
#427
-
|
Hello! I use the TAB-and-Go completion, and, for awhile, I was a smidge annoyed that when I cycled through the candidates and pressed "SPC" that the candidate wasn't inserted and instead a space was added as a separator. I release that, by default,
Only just now did I see the following in the wiki:
(dolist (c (list (cons "SPC" " ")
(cons "." ".")
(cons "," ",")
(cons ":" ":")
(cons ")" ")")
(cons "}" "}")
(cons "]" "]")))
(define-key corfu-map (kbd (car c)) `(lambda ()
(interactive)
(corfu-insert)
(insert ,(cdr c)))))However this gives me the above mentioned error whenever I try to insert any of the characters after tabbing to any candidate in the completion list. Here's the debug output: Also I realize that my ;;;; Orderless
;;;;
(use-package orderless
:preface
(defun orderless:fast-dispatch (word index total)
"Dispatch orderless on a WORD where INDEX is 0 and TOTAL is at least 1 character.
Potentially speeds up completion a little bit."
(and (= index 0) (= total 1) (length< word 1)
`(orderless-regexp . ,(concat "^" (regexp-quote word)))))
:config
(orderless-define-completion-style orderless-fast
(orderless-style-dispatchers '(orderless:fast-dispatch))
(orderless-matching-styles '(orderless-literal orderless-initialism orderless-prefixes)))
(setq orderless-component-separator #'orderless-escapable-split-on-space
completion-styles '(orderless-fast basic)
completion-category-defaults nil
completion-category-overrides
'((file (styles . (orderless-fast partial-completion)))
(buffer (styles . (orderless-fast partial-completion)))
(info-menu (styles . (orderless-fast partial-completion)))))
(set-face-attribute 'completions-first-difference nil :inherit nil))
;;;; Corfu
;;;;
(use-package corfu
:hook (after-init . global-corfu-mode)
:general (:keymaps 'corfu-map
"TAB" #'corfu-next
"<tab>" #'corfu-next
[tab] #'corfu-next
"C-n" #'corfu-next
"S-TAB" #'corfu-previous
"<S-tab>" #'corfu-previous
"<backtab>" #'corfu-previous
[backtab] #'corfu-previous
"C-p" #'corfu-previous
;; "RET" #'ignore
;; "<return>" #'ignore
;; [return] #'ignore
;; "SPC" #'corfu-insert-separator
;; "<space>" #'corfu-insert-separator
;; [space] #'corfu-insert-separator
"M-d" #'corfu-show-documentation
"M-l" #'corfu-show-location)
:preface
(defun corfu:in-minibuffer ()
"Allow for Corfu in the minibuffer."
(unless (or (bound-and-true-p mct--active)
(bound-and-true-p vertico--input))
(setq-local corfu-auto nil)
(corfu-mode +1)))
(defun corfu:send-shell (&rest _)
"Send completion candidates when inside comint/shell."
(cond
((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
(eshell-send-input))
((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
(comint-send-input))))
(defun corfu:insert-shell-filter (&optional _)
"Insert completion candidate and send when inside comint/eshell."
(when (derived-mode-p 'eshell-mode 'comint-mode)
(lambda ()
(interactive)
(corfu-insert)
(corfu:send-shell))))
:custom
(corfu-cycle t)
(corfu-auto t)
(corfu-auto-delay 0.5)
(corfu-auto-prefix 2)
(corfu-preselect 'prompt)
(corfu-quit-no-match t)
(corfu-scroll-margin 6)
(corfu-echo-documentation nil)
(corfu-popupinfo-delay (cons 0.5 0.5))
:config
(add-hook 'minibuffer-setup-hook #'corfu:in-minibuffer 1)
(dolist (c (list (cons "SPC" " ")
(cons "." ".")
(cons "," ",")
(cons ":" ":")
(cons ")" ")")
(cons "}" "}")
(cons "]" "]")))
(define-key corfu-map (kbd (car c)) `(lambda ()
(interactive)
(corfu-insert)
(insert ,(cdr c)))))
(corfu-echo-mode +1)
(corfu-history-mode +1)
(corfu-popupinfo-mode +1))
So the expected behavior is:
Maybe this is just a documentation thing, or a I-can't-actually-read thing. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
I also should've mentioned this bit in the Wiki:
(setq corfu-separator 32)
;; highly recommanded to use corfu-separator with "32" (space)
(define-key corfu-map (kbd "SPC")
(lambda ()
(interactive)
(if current-prefix-arg
;;we suppose that we want leave the word like that, so do a space
(progn
(corfu-quit)
(insert " "))
(if (and (= (char-before) corfu-separator)
(or
;; check if space, return or nothing after
(not (char-after))
(= (char-after) ?\s)
(= (char-after) ?\n)))
(progn
(corfu-insert)
(insert " "))
(corfu-insert-separator)))))Which almost touches on what I would like. The thing is that I rarely, if ever, use A. When choosing a completion, you must hit enter to select the candidate, or Both of which follow If you press any other key, either the completion candidates change or the completion is canceled (the second would be in the case of special characters that are either syntactical or something else). Maybe I'm misunderstanding how to get Corfu and Orderless working together. |
Beta Was this translation helpful? Give feedback.
-
|
Hi! Sorry for not responding earlier. This question goes a little bit beyond what I can answer quickly, due to the amount of custom code and tweaks. Did you make progress? |
Beta Was this translation helpful? Give feedback.
Yes, apologizes. I'm not sure why but it seems like the following inside of the use-package
:configblock gives me what I want:Along with these settings for Corfu