gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
388 stars 36 forks source link

evil-digit-argument-or-evil-org-beginning-of-line is a function alias and I can't figure out how to make it a known command #118

Open aaronjensen opened 3 years ago

aaronjensen commented 3 years ago

when evil-org is used, evil-digit-argument-or-evil-org-beginning-of-line is a function alias for an anonymous lambda. When I attempt to add it to evil-mc-custom-known-commands, it doesn't appear to work. Is there another way to add it?

aaronjensen commented 3 years ago

Here's my workaround for now:

(evil-define-motion org-beginning-of-line-or-digit-argument ()
    "Move the cursor to the beginning of the current line.
This function passes its command to `digit-argument' (usually a 0)
if it is not the first event."
    :type exclusive
    (cond
     (current-prefix-arg
      (setq this-command #'digit-argument)
      (call-interactively #'digit-argument))
     (t
      (setq this-command #'org-beginning-of-line)
      (call-interactively #'org-beginning-of-line))))

(evil-define-minor-mode-key 'motion 'evil-org-mode "0" #'org-beginning-of-line-or-digit-argument)

(add-to-list 'evil-mc-custom-known-commands
               '(org-beginning-of-line-or-digit-argument
                 (:default . evil-mc-execute-default-call)
                 (visual . evil-mc-execute-visual-call)))
dschrempf commented 7 months ago

Maybe some things have changed in the meantime, but I managed to solve this problem using

  (add-to-list 'evil-mc-custom-known-commands
               '(evil-org-beginning-of-line . ((:default . evil-mc-execute-default-call-with-count)))

I think we could add this to the known commands of the package. (I think other evil-org bindings are included there already).

aaronjensen commented 7 months ago

This doesn't work for me. Setting this up, then creating a text buffer in org-mode with:

foo
foo

And using evil-mc to create cursors on each foo (w/ the cursor at the end of the word) then pressing 0 only moves the first cursor to the beginning of the line

dschrempf commented 7 months ago

Interesting. It does work for me... Thanks for checking anyways!