unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Movable position registers?
@ 2016-09-12 18:06 Nikolay Kudryavtsev
  2016-09-12 20:52 ` John Mastro
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Kudryavtsev @ 2016-09-12 18:06 UTC (permalink / raw)
  To: help-gnu-emacs@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Movable position registers?
  2016-09-12 18:06 Movable position registers? Nikolay Kudryavtsev
@ 2016-09-12 20:52 ` John Mastro
  0 siblings, 0 replies; 2+ messages in thread
From: John Mastro @ 2016-09-12 20:52 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Nikolay Kudryavtsev <nikolay.kudryavtsev@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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-12 20:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 18:06 Movable position registers? Nikolay Kudryavtsev
2016-09-12 20:52 ` John Mastro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).