Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Movable position registers?

4 views
Skip to first unread message

Nikolay Kudryavtsev

unread,
Sep 12, 2016, 4:28:44 PM9/12/16
to help-gn...@gnu.org
From time to time I have this question, but always forget to ask.

Is there a way to put the position of comint input into a register, so
whenever its position changes, the register moves with it? So I can use
registers for irc buffers, sql buffers and shell buffers without the
need for an extra end-of-buffer command.

--
Best Regards,
Nikolay Kudryavtsev


John Mastro

unread,
Sep 12, 2016, 4:54:46 PM9/12/16
to help-gn...@gnu.org
Nikolay Kudryavtsev <nikolay.k...@gmail.com> wrote:
> From time to time I have this question, but always forget to ask.
>
> Is there a way to put the position of comint input into a register, so
> whenever its position changes, the register moves with it? So I can use
> registers for irc buffers, sql buffers and shell buffers without the need
> for an extra end-of-buffer command.

If I understand correctly, I think perhaps you just need to use
`set-marker-insertion-type' so that the marker moves when text is
inserted at its position.

Here's an example of a modified/simplified version of
`point-to-register' that does so:

(defun my-point-to-register-with-insertion-type-t (register)
(interactive
(list (register-read-with-preview "Point to register: ")))
(add-hook 'kill-buffer-hook 'register-swap-out nil t)
(let ((marker (copy-marker (point))))
(set-marker-insertion-type marker t)
(set-register register marker)))

Hope that helps

John

0 new messages