-
Notifications
You must be signed in to change notification settings - Fork 7
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
better api for programmatic use #2
Comments
fwiw, what i am using right now to integrate with evil is this: (evil-define-operator my-copy-as-format (beg end type)
:move-point nil
:repeat nil
(interactive "<R>")
(save-excursion
(goto-char beg)
(when (eq type 'line)
(beginning-of-line))
(push-mark (point) t t)
(goto-char end)
(when (eq type 'line)
(forward-line -1)
(end-of-line))
(let ((current-prefix-arg t))
(copy-as-format))
(pop-mark))) |
Yes I agree, some improvements are needed.
Why not just change
Sounds good. Maybe Maybe a better signature for this and
Sounds good! |
I made |
I ended writing something that I just committed. It attempts to provide an interactive and non-interactive behavior for Also multiline checking now seems a bit dirty. Suggestions welcome. I'll have another crack at it as some point . |
thanks, i'll have a look later! |
I think it would be more robust to have two functions, one for interactive and one for non-interactive use. The interactive version can be simply a very light wrapper just passing the arguments along and killing the extracted region (which the non-interactive version can return along with the boundaries). |
Seems to be the way to go. Especially considering Suggestions for name? |
right now the only api is the
copy-as-format
function which inspects the prefix argument and relies on the region being active.it would be nice to have a public function that would take two positions (begin and end) and a format argument (string,
t
to prompt for format, nil for default format) that would copy the text in between those two positions using the specified format.something like this:
this would allow for better use in custom commands, and also for better integration with
evil-mode
, which has its own concepts to define various regions (e.g. with text objects).even better, there should be an option to not copy but only return the formatted text, which would mean it can be used in other functions.
what do you think about this? i could come up with a pr if you agree this makes sense to have.
The text was updated successfully, but these errors were encountered: