[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which h
From: |
Daniel Colascione |
Subject: |
Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior |
Date: |
Mon, 04 May 2015 15:37:47 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 05/04/2015 03:16 PM, Stefan Monnier wrote:
>> + (let ((mark (mark-marker)))
>> + (and mark (marker-position mark) (copy-marker mark)))
>
> Here you consider that (mark-marker) can return nil.
>
>> +(defun save-mark-and-excursion--restore (saved-mark-info)
>> + (let ((saved-mark (car saved-mark-info))
>> + (omark (marker-position (mark-marker)))
>
> But here you assume it's always a marker.
It is always a marker, isn't it? Some other parts of simple.el assume it
always returns non-nil. I'll remove the nil check.
>> + (let ((cur-mark-active mark-active))
>> + (setf mark-active saved-mark-active)
>> + ;; If mark is active now, and either was not active or was at a
>> + ;; different place, run the activate hook.
>> + (if saved-mark-active
>> + (unless (eq omark nmark)
>> + (run-hooks 'activate-mark-hook))
>
> IIUC activate-mark-hook should also be run when (eq omark nmark) but
> cur-mark-active was nil.
Huh. I just mechanically translated the original save-excursion C code.
Doesn't that code have the same mismatch between the comment and the
behavior?
/* If mark is active now, and either was not active
or was at a different place, run the activate hook. */
tem = XSAVE_OBJECT (info, 3); // saved-mark-active
...
if (! NILP (tem))
{
if (! EQ (omark, nmark))
run_hook (intern ("activate-mark-hook"));
}
/* If mark has ceased to be active, run deactivate hook. */
else if (! NILP (tem1))
run_hook (intern ("deactivate-mark-hook"));
I'll change the code to match the comment.
signature.asc
Description: OpenPGP digital signature