The dot Command not able to repeat text inserted by "Auto-complete"

York Zhao gtdplatform at gmail.com
Thu Aug 18 23:14:39 CEST 2011


Hi,

It had happened a few times today that dot command was not repeating the
previous insertion, but rather some other command, e.g. it was repeating
"switch-buffer" a minute ago, and currently is repeating the "C-h k ."
command. Right now it is working properly again. I don't know how to
reproduce this yet.

York


On Tue, Aug 16, 2011 at 11:45 AM, York Zhao <gtdplatform at gmail.com> wrote:
Hi Frank,

Thank you very much for this. I just did a few quick tests which appeared to
be working perfectly fine. I'm using auto-complet a lot every day so I will
report back problems if I will notice any but my feeling is that it is going
to work. Thanks again for the wonderful works.


York


On Tue, Aug 16, 2011 at 5:59 AM, Frank Fischer <
frank.fischer at mathematik.tu-chemnitz.de> wrote:
Am Montag, 15. August 2011 schrieb Frank Fischer:
> Am Mon, 15 Aug 2011 14:54:44 -0400
>
> schrieb York Zhao <gtdplatform at gmail.com>:
> > Hi,
> >
> > I've been having this problem for a while and it is now my biggest
> > complain to Evil because other than Evil itself, "auto-complete" is
> > the next thing I can't be living without.
>
> In fact, the change based repeation system (in contrast to the
> key-stroke based one, I described both in another mail and it will
> hopefully find its way in the docs) is designed exactly for these
> cases and I'm quite confident that this is indeed not a big problem.
> I just haven't activated it yet, but I'm going to have a look at it
> in the next days.

In turned out to be a little bit more difficult than a thought.
Activating the change-based repeation for auto-complete worked well
except in one case: when the completion is done near the end of the
buffer. The reason is that in this case auto-complete adds a few
newlines to the end of the buffer in order to show its popup-menu
(those newlines are removed when the popup closes). The problem is that
these insertions/deletions are, well, buffer-changes and therefore
confused the recording. Even worse, the popup menu is triggered by a
timer and not by a command, therefore there is no command active when
the first buffer changes appear and this confuses the system even more.

Luckily, Evil had already had the ability to execute arbitrary functions
to realize a repeation, there just was no way to specify such a
function for a command. I added this functionality in d15b75a5. The
following code should equip auto-complete with working repeation. I'm
going to cleanup the repeation code, especially the definition of
user-defined repeation functions, a little bit, so don't assume this as
a stable example but feel free to test and tell us about problems.


(evil-set-command-properties 'ac-complete :repeat 'evil-ac-repeat)
(evil-set-command-properties 'ac-expand :repeat 'evil-ac-repeat)
(evil-set-command-properties 'ac-next :repeat 'ignore)
(evil-set-command-properties 'ac-previous :repeat 'ignore)

(defvar evil-ac-prefix-len nil
 "The length of the prefix of the current item to be completed.")

(defun evil-ac-repeat (flag)
 "Record the changes for auto-completion."
 (if (eq flag 'pre)
     (setq evil-ac-prefix-len (length ac-prefix))
   ;; Add change to remove the prefix
   (evil-repeat-record-change
    (list (- evil-ac-prefix-len) "" evil-ac-prefix-len))
   ;; Add change to insert the full completed text
   (evil-repeat-record-change
    (list (- evil-ac-prefix-len)
          (buffer-substring-no-properties (- evil-repeat-pos
                                             evil-ac-prefix-len)
                                          (point))
          0))
   ;; Finish repeation
   (evil-repeat-record-change)))


Hope it works,
Frank

_______________________________________________
implementations-list mailing list
implementations-list at lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ourproject.org/pipermail/implementations-list/attachments/20110818/d7225bd4/attachment.htm 


More information about the implementations-list mailing list