Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sync completion changes (Corfu) in Beacon mode? #530

Closed
ahan98 opened this issue Dec 31, 2023 · 3 comments
Closed

How to sync completion changes (Corfu) in Beacon mode? #530

ahan98 opened this issue Dec 31, 2023 · 3 comments

Comments

@ahan98
Copy link

ahan98 commented Dec 31, 2023

Hi, thanks for all your hard work on this excellent package.

I'm wondering how to apply autocompletions to all the fake cursors in Beacon mode.

For example:

(def)
(def)

From line 1: xxGbeiu<tab><esc> results in

(def)
(defun)

Is there any way to apply the completion to all cursors in Beacon? I'm using Corfu, but the type of completion probably doesn't matter. I'm using the default config suggested on the Corfu repo.

I am using only the default QWERTY (meow-setup).

@DogLooksGood
Copy link
Collaborator

The beacon mode is a wrapper for keyboard macro, which doesn't work well with operations without deterministic result. The outputs from completions are dynamic, the first option may change on different lines. For such use case, you probably want to do it with query-replace or query-replace-regexp.

@ahan98
Copy link
Author

ahan98 commented Dec 31, 2023

Thanks for the fast reply. I see your point. But, I wonder if we can do something like this (I couldn't get this to work, and it is a little silly, but I think the idea is interesting):

(defun corfu-insert-advice (orig-fun &rest args)
  (let ((start (point)))
    (apply orig-fun args)
    (when-let* ((end (point))
		(suffix (buffer-substring-no-properties start end)))
      (message "completed suffix: %s" suffix)
      (delete-region start end)
      (insert suffix))))
(advice-add 'corfu-complete :around 'corfu-insert-advice)

I'm actually surprised that this doesn't work because I would think the macro should treat the insertion as literal keyboard presses right?

Anyway, I guess there's not much to do here, so I'll close the issue, but it's an interesting thought experiment at least...

@ahan98 ahan98 closed this as completed Dec 31, 2023
@DogLooksGood
Copy link
Collaborator

A keyboard macro is a sequence of key inputs. So it only tracks your keyboard input as KEYS, not even commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants