[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Character repeation detection
From: |
Tom |
Subject: |
Re: Character repeation detection |
Date: |
Sun, 9 Mar 2014 20:20:54 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Tom <adatgyujto <at> gmail.com> writes:
>
> It seems to me it would be more convenient than typing multikey
> hotkeys and it would give lots of new free bindings in addition to
> the existing ones.
>
I created a crude implementation to test the concept.
It invokes occur if you press o 3 times or press o and
keep it pressed. It is active only in buffers with emacs-lisp-mode
major mode for now.
It works, but looks a bit unconventional as the o characters are
deleted automatically.
The only thing missing is restoring the unmodified status
of the buffer if it was unmodified before.
(setq my-char-to-check ?o)
(setq my-char-count 0)
(setq my-start-pos nil)
(defun my-post-command-hook ()
(when (and (eq major-mode 'emacs-lisp-mode)
(eq this-command 'self-insert-command))
(if (not (eq last-command-char my-char-to-check))
(setq my-char-count 0)
(if (eq my-char-count 0)
(setq my-start-pos (1- (point))))
(incf my-char-count)
(when (eq my-char-count 3)
(setq my-char-count 0)
;; should restore buffer modified status here
(delete-region my-start-pos (point))
(run-with-idle-timer
0 nil
(lambda ()
(add-hook 'post-command-hook 'my-remove-excess-chars)
(call-interactively 'occur)))))))
(add-hook 'post-command-hook 'my-post-command-hook)
(defun my-remove-excess-chars ()
(when (sit-for 0.1)
(delete-region (point) (line-beginning-position))
(remove-hook 'post-command-hook 'my-remove-excess-chars)))
- Character repeation detection, Tom, 2014/03/09
- Re: Character repeation detection, Jambunathan K, 2014/03/09
- Re: Character repeation detection, Tom, 2014/03/09
- Re: Character repeation detection, Tom, 2014/03/09
- Re: Character repeation detection, Marcin Borkowski, 2014/03/09
- Re: Character repeation detection, Jambunathan K, 2014/03/09
- Re: Character repeation detection, Tom, 2014/03/09
- Re: Character repeation detection, Marcin Borkowski, 2014/03/09
- Re: Character repeation detection, Andreas Röhler, 2014/03/09
- Re: Character repeation detection, Tom, 2014/03/09
- Re: Character repeation detection,
Tom <=
- Re: Character repeation detection, Stefan Monnier, 2014/03/09
- Message not available
- Re: Character repeation detection, Dan Espen, 2014/03/09
- Re: Character repeation detection, Tom, 2014/03/09
- Message not available
- Re: Character repeation detection, Joost Kremers, 2014/03/09
- Re: Character repeation detection, Eric Abrahamsen, 2014/03/09
Re: Character repeation detection, Yuri Khan, 2014/03/09
Message not available