Confused by what command is "dot repeatable"
Hi, I still find myself confused by the "dot repeating" in Evil. I have many commands, some of them are "automatically" dot repeatable but others are not. For example, I have these two commands: (defun foo () (interactive) ... (kill-region beg end) ... (insert ...) ...) (defun bar () (interactive) ... (insert ...)) I don't see any essential difference between these two commands, except that `foo' was being executed in org-mode while `bar' in c++-mode. And I have no idea why command "foo" is dot repeatable but "bar" is not. I had tried using (evil-declare-change-repeat 'bar) but still, "bar" is not "dot" repeatable. I'm confused by what has made "foo" repeatable. I don't have time to look deeply in the repeat system in Evil so I would appreciate it if someone could give me some quick answer to my question. Thanks, York
Hi,
I still find myself confused by the "dot repeating" in Evil. I have many commands, some of them are "automatically" dot repeatable but others are not. For example, I have these two commands:
(defun foo () (interactive)
...
(kill-region beg end)
...
(insert ...)
...)
(defun bar () (interactive)
... (insert ...))
I don't see any essential difference between these two commands, except that `foo' was being executed in org-mode while `bar' in c++-mode. And I have no idea why command "foo" is dot repeatable but "bar" is not. I had tried using
(evil-declare-change-repeat 'bar)
but still, "bar" is not "dot" repeatable. I'm confused by what has made "foo" repeatable. I don't have time to look deeply in the repeat system in Evil so I would appreciate it if someone could give me some quick answer to my question.
Thanks, York
Anybody?
Hi York, sorry for not answering immediately, but I've been on a business trip last weak and had simply no time. The same will be true for large parts of the next few months so please excuse if responses take some time. I'll always try to answer as soon as possible. On 2012-07-12, York Zhao <[email protected]> wrote:
Hi,
I still find myself confused by the "dot repeating" in Evil. I have many commands, some of them are "automatically" dot repeatable but others are not. For example, I have these two commands:
(defun foo () (interactive)
...
(kill-region beg end)
...
(insert ...)
...)
(defun bar () (interactive)
... (insert ...))
I'm not sure what the problem is. I've just tried the following example (defun bar () (interactive) (save-excursion (insert "abc"))) (define-key evil-normal-state-map (kbd "C-q") 'bar) and then in some empty buffer (after :new) 'C-q .' resulting in the buffer content "abcabc" as expected. Note that currently repeating only works for commands bound to some key-bindings, calling them via M-x COMMAND RET may fail. So please provide a complete example (full function definition, key sequences, ...), preferably starting from a fresh emacs instance, that demonstrates the problem. Otherwise it is really hard to isolate the problem.
I don't see any essential difference between these two commands, except that `foo' was being executed in org-mode while `bar' in c++-mode. And I have no idea why command "foo" is dot repeatable but "bar" is not. I had tried using
The mode *should* not make difference ...
(evil-declare-change-repeat 'bar)
but still, "bar" is not "dot" repeatable. I'm confused by what has made "foo" repeatable. I don't have time to look deeply in the repeat system in Evil so I would appreciate it if someone could give me some quick answer to my question.
The repeat system is always triggered by pre-command-hooks, post-command-hooks and sometimes after-change-functions. Maybe some calls in the body of "bar" confuse the system (something like call-interactively could do, possibly others), but without an example it's hard to give a definite answer. Bye, Frank
sorry for not answering immediately, but I've been on a business trip last weak and had simply no time. The same will be true for large parts of the next few months so please excuse if responses take some time. I'll always try to answer as soon as possible.
Really appreciate that you have taken your valuable time to answer my question, and your answer have been very useful so far.
Note that currently repeating only works for commands bound to some key-bindings, calling them via M-x COMMAND RET may fail.
Yes, you are right, I never binded these functions to any key, I used "M-x". And if I bind my command "bar" to a key the dot repeating works. What I still don't understand however, is that "M-x foo" is dot repeatable but not "M-x bar".
So please provide a complete example (full function definition, key sequences, ...), preferably starting from a fresh emacs instance, that demonstrates the problem. Otherwise it is really hard to isolate the problem.
Here's the scenario: First, in "scratch" buffer, input the following: (defun york-bar () (interactive) (save-excursion (insert "printf(\"checkpoint\")"))) Type "C-M-x" to instrument the command `york-bar'. Then open a file in c++-mode and "M-x york-bar", "printf()" function call gets inserted. Hit ".", but nothing wouldn't get inserted again.
The mode *should* not make difference ...
Yes, I've tried "M-x york-bar" in an org-mode buffer and got the same results. On the other hand, the command `york-foo' which is dot repeatable even when being executed by "M-x", is way more complicated, I have tried to isolate it but failed, it had been tightly "connected" with my other part of configuration files (huge). The bottom line is, however, `york-bar' is dot repeatable if having it binded to some key. Thanks again for the help. York
I defined york-bar the same as you and invoked M-x york-bar while in normal state. Then I did the . command and entered the elisp debugger because of error: Debugger entered--Lisp error: (void-variable p) eval(p nil) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp nil nil) execute-kbd-macro([115 101 120]) evil-execute-repeat-info(([115 101 120])) evil-execute-repeat-info-with-count(nil ([115 101 120])) evil-repeat(nil nil) call-interactively(evil-repeat nil nil) If I try to exit Emacs (such as clicking the Frame's close), the minibuffer simply reports: "After 0 kbd macro iterations: Symbol's function definition is void: t". Only when I exit the debugger am I able to quit Emacs. I discovered that if I have an edit in the repeat ring, I witness the behavior York describes instead of the the elisp errors. I pasted the york-bar from my web browser using X11, so it didn't go into the repeat ring. On 7/13/12, York Zhao <[email protected]> wrote:
sorry for not answering immediately, but I've been on a business trip last weak and had simply no time. The same will be true for large parts of the next few months so please excuse if responses take some time. I'll always try to answer as soon as possible.
Really appreciate that you have taken your valuable time to answer my question, and your answer have been very useful so far.
Note that currently repeating only works for commands bound to some key-bindings, calling them via M-x COMMAND RET may fail.
Yes, you are right, I never binded these functions to any key, I used "M-x". And if I bind my command "bar" to a key the dot repeating works. What I still don't understand however, is that "M-x foo" is dot repeatable but not "M-x bar".
So please provide a complete example (full function definition, key sequences, ...), preferably starting from a fresh emacs instance, that demonstrates the problem. Otherwise it is really hard to isolate the problem.
Here's the scenario:
First, in "scratch" buffer, input the following:
(defun york-bar () (interactive) (save-excursion (insert "printf(\"checkpoint\")")))
Type "C-M-x" to instrument the command `york-bar'.
Then open a file in c++-mode and "M-x york-bar", "printf()" function call gets inserted.
Hit ".", but nothing wouldn't get inserted again.
The mode *should* not make difference ...
Yes, I've tried "M-x york-bar" in an org-mode buffer and got the same results.
On the other hand, the command `york-foo' which is dot repeatable even when being executed by "M-x", is way more complicated, I have tried to isolate it but failed, it had been tightly "connected" with my other part of configuration files (huge).
The bottom line is, however, `york-bar' is dot repeatable if having it binded to some key. Thanks again for the help.
York
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
participants (3)
-
Barry OReilly -
Frank Fischer -
York Zhao