help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Movable position registers?


From: John Mastro
Subject: Re: Movable position registers?
Date: Mon, 12 Sep 2016 13:52:56 -0700

Nikolay Kudryavtsev <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]