all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: 路客 <luke.yx.lee@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: [ELPA] New package: cursor-undo
Date: Sat, 20 Jul 2024 23:03:43 +0800	[thread overview]
Message-ID: <CAA=xLRN6sc5wCYtEqjWQJDrsXBxkUMo1JrQzvBrtQ38m4PtC+g@mail.gmail.com> (raw)

Hi all,
I've just pushed my new package into ELPA.

Cursor-undo allows you to undo cursor movement commands using the Emacs
standard `undo' command.

For frequent cursor movements such as up/down/left/right, it
combines the movements of the same direction into a single undo entry.
This prevents the undo command from reversing each individual
character movement separately.  For example, if you move the cursor 20
characters to the right and then 10 lines up, the first undo will go
down 10 lines back, and the next undo move back 20 characters left.
On the other hand, for search commands that often jump across multiple
pages, each search command has its own undo entry, allowing you to
undo them one at a time rather than as a combined operation.

This cursor-undo functionality has existed in my local Emacs init file
for over 11+ years, since version 0 on 2013-06-26.  It was originally
intended to support my Brief Editor Mode only, but I later found it
would be more useful if implemented in a more generalized way.  For
years I have hoped for an official implementation of this feature,
which is commonly seen among various editors.  Considering my
implementation using advice functions a bit inelegant so I have always
hesitated to release it till recently.

Until there is official support for the cursor undo feature, this
package serves most common daily needs.  The core design is to align
with Emacs's native `undo' function by recording cursor positions
and screen-relative position undo entries in the `buffer-undo-list'
in accordance with its documentation.

As this package primarily consists of advice functions to wrap cursor
movement commands, each cursor movement command needs to be manually
wrapped with `def-cursor-undo'.  For interactive functions that
heavily invoke advised cursor movement commands, you may even need to
advise them with `disable-cursor-tracking' to prevent generating
numerous distinct cursor undo entries from a single command.  For user
convenience, we have prepared ready `def-cursor-undo' advice sets for
standard Emacs cursor movement commands, Brief Editor mode, Viper
mode, and EVIL mode.

Usage:

  In theory, once this package is installed, you should already have
  cursor-undo autoloaded and enabled.  If not, or if you downloaded this
  package as source, put "cursor-undo.el" file in a `load-path' and add
  the following line into your Emacs init file .emacs or init.el:

    (require 'cursor-undo)

Notes for EVIL mode user:

  If you choose to use default Emacs `undo' system, you should be able
  to use `evil-undo' to undo cursor movements.  If your choice is
  tree-undo or another undo system, you might need to use Emacs default
  `undo' (C-_, C-/ or C-x u ...) to undo cursor movements.

Notes for Viper mode user:

  The default `viper-undo' is advised to allow cursor-undo.  If you
  find the advised function not working properly, consider comment out
  the following source code `(define-advice viper-undo ...' to restore
  the original `viper-undo' function and use Emacs default `undo'
  (C-_, C-/ or C-x u ...) to undo cursor movements.


-- 
Best regards,
Luke Lee



             reply	other threads:[~2024-07-20 15:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-20 15:03 路客 [this message]
2024-07-21 10:57 ` [ELPA] New package: cursor-undo Philip Kaludercic
2024-07-22 11:55   ` 路客
2024-07-26  6:52     ` Philip Kaludercic
2024-07-26 10:00       ` Luke Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA=xLRN6sc5wCYtEqjWQJDrsXBxkUMo1JrQzvBrtQ38m4PtC+g@mail.gmail.com' \
    --to=luke.yx.lee@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.