[Top][All Lists]

[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

(defun hashcash-insert-payment-async-2 (buffer process pay)
  (when (buffer-live-p buffer)
    (with-current-buffer buffer
          (setq hashcash-process-alist (delq
                                        (assq process hashcash-process-alist)
          (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

reply via email to

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