[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save-excursion and the mark
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: save-excursion and the mark |
Date: |
Sat, 25 Apr 2015 15:23:50 +0200 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Lars Magne Ingebrigtsen <address@hidden> writes:
> Stefan Monnier <address@hidden> writes:
>
>> (cl-letf (((mark))) ...) might do the trick.
>
> Thanks; that kinda cryptic incantation seems to do the trick
Actually, it just made things break in a different way.
The following code used to work, and is run from a process filter
(asynchronously):
(defun hashcash-insert-payment-async-2 (buffer process pay)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(save-excursion
(save-restriction
(setq hashcash-process-alist (delq
(assq process hashcash-process-alist)
hashcash-process-alist))
(message-goto-eoh)
(when pay
(insert-before-markers "X-Hashcash: " pay)))))))
If I put the mark somewhere in the buffer, and the text is then
inserted, then the mark suddenly has the same value as point.
If I wrap this code in the `cl-letf', the mark value doesn't change at
all, which means that it now points to somewhere else in the buffer.
(Since the X-Hashcash header is inserted before the mark.) That is, the
numerical value of the mark doesn't change, so it visually moves
backwards in the buffer, since text has been inserted before the mark.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: save-excursion and the mark, (continued)
- Re: save-excursion and the mark, Daniel Colascione, 2015/04/17
- Re: save-excursion and the mark, Richard Stallman, 2015/04/15
- Re: save-excursion and the mark, Phillip Lord, 2015/04/15
- Re: save-excursion and the mark, Oleh Krehel, 2015/04/19
- Re: save-excursion and the mark, Stefan Monnier, 2015/04/19
- Re: save-excursion and the mark, Andreas Röhler, 2015/04/20
save-excursion and the mark, Lars Magne Ingebrigtsen, 2015/04/17
Re: save-excursion and the mark, Frank Fischer, 2015/04/23