GitHunt
ID

ideasman42/dot-mode

dot-mode.el is a minor mode for GNU Emacs / XEmacs that emulates the '.' command in vi.

  • dot-mode.el

dot-mode.el is a minor mode for GNU Emacs that emulates the '.' command in vi.

See: http://wyrick.org/source/elisp/dot-mode/

** Aim
This mode is written to address one argument in the emacs vs. vi jihad :-) It
emulates the vi `redo' command, repeating the immediately preceding sequence of
commands.
This is done by recording input commands which change the buffer, i.e. not
motion commands.
** Use
*** Installation
Add to =load-path=, and =(require 'dot-mode)=.
Run the command =dot-mode= to start =dot-mode=, if you want =dot-mode= to be
enabled in all buffers you can have the sexp =(global-dot-mode t)= in your
config.
*** Customization
There are three variables that allow you to modify how dot-mode
behaves:
#+BEGIN_SRC elisp
dot-mode-verbose
dot-mode-ignore-undo
dot-mode-global-mode
#+END_SRC

=dot-mode-ignore-undo= defaults to t.
When nil, it will record keystrokes that generate an undo just like any other
keystroke that changed the buffer. I personally find that annoying, but if you
want dot-mode to always remember your undo's:
: (setq dot-mode-ignore-undo nil)
Besides, you can always use dot-mode-override to record an undo when you need to
(or even M-x undo).

=dot-mode-global-mode= - defaults to t.
When t, dot-mode only has one keyboard command buffer.
That means you can make a change in one buffer, switch buffers, then repeat the
change.
When set to nil, each buffer gets its own command buffer.
That means that after making a change in a buffer, if you switch buffers, that
change cannot repeated.
If you switch back to the first buffer, your change can then be repeated again.
This has a nasty side effect if your change yanks from the =kill-ring= (You
could end up yanking text you killed in a different buffer).
If you want to set this to nil, you should do so before dot-mode is activated on
any buffers.
Otherwise, you may end up with some buffers having a local command buffer and
others using the global one.
*** Usage instructions

`C-.' is bound to =dot-mode-execute=, which executes the buffer of
stored commands as a keyboard macro.

`C-M-.' is bound to =dot-mode-override=, which will cause =dot-mode=
to remember the next keystroke regardless of whether it
changes the buffer and regardless of the value of the
=dot-mode-ignore-undo= variable.

C-c-.' is bound to =dot-mode-copy-to-last-kbd-macro=, which will copy the current dot mode keyboard macro to the =last-kbd-macro= variable. It can then be executed via =call-last-kbd-macro= (normally bound to C-x-e'), named via =name-last-kbd-macro=,
and then inserted into your .emacs via =insert-kbd-macro=.
** For Contributors
Installation of the development environment can be done with =cask install=.

Tests are written using [[https://github.com/ecukes/ecukes][ecukes]], and can be run with =cask exec ecukes=.

The script =./testrun.sh= starts an emacs instance in the environment that the
tests are run under. This instance begins with =dot-mode= loaded, but not turned
on.

Languages

Emacs Lisp73.9%Gherkin25.8%Shell0.3%

Contributors

Created February 27, 2025
Updated February 27, 2025