[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save-excursion and the mark
From: |
Ivan Shmakov |
Subject: |
Re: save-excursion and the mark |
Date: |
Wed, 25 Feb 2015 12:35:18 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
>>>>> Andreas Röhler <address@hidden> writes:
>>>>> On 25.02.2015 03:59, Stefan Monnier wrote:
>>> See for example indent-code-ridigly.
>> Can you give more details about how this requires save&restore of
>> the mark (or its "active" status)?
> Think a shifting code by TAB in python-mode.
FWIW, python.el doesn’t seem to use the mark.
> Mark might exist somewhere in line. Shifting will use its own region
> – but original region should be restored – if any. Shifting by
> itself should not create a region nor clutter the mark-ring.
There seem to be a misunderstanding; the notion of /Emacs Lisp/
region is different to that of /Emacs/ region, the former being
(more or less) a way of saying “from here to there”, and
does /not/ (generally) involve either mark or point.
For instance, indent-code-ridigly can be used from Lisp like:
(indent-code-ridigly 13 37)
Or perhaps:
(when-let ((here (re-search-backward "START" nil t))
(there (re-search-forward "END" nil t)))
(indent-code-ridigly here there))
With the common idiom being:
(let ((save (point)))
; Move point forward, by some amount.
(indent-code-ridigly save (point)))
As should be obvious, the mark is /not/ involved in either case.
And, arguably, it /should not/ be.
[…]
> commit b1d6ddd44614c84746f5ee494e1f29cd9be8a2d8
> Notable changes to goto-line, i. e. calling push-mark.
That makes a point, indeed: there’s a class of Emacs commands
intended first and foremost for interactive use. Naturally,
goto-line is one of them; to quote its docstring:
This function is for interactive use only;
in Lisp code use `forward-line' instead.
The proposed change to save-excursion would expose the bugs in
the code which uses such commands inside of save-excursion,
which now masks the unfortunate side-effects of such (mis)use.
--
FSF associate member #7257 np. Rule the World — Kamelot 3013 B6A0 230E 334A
- Re: save-excursion and the mark, (continued)
- Re: save-excursion and the mark, Stefan Monnier, 2015/02/24
- Re: save-excursion and the mark, Barry Warsaw, 2015/02/24
- Re: save-excursion and the mark, Artur Malabarba, 2015/02/24
- Re: save-excursion and the mark, Stefan Monnier, 2015/02/24
- Re: save-excursion and the mark, Artur Malabarba, 2015/02/24
- Re: save-excursion and the mark, Barry Warsaw, 2015/02/25
- Re: save-excursion and the mark, Stefan Monnier, 2015/02/25
Re: save-excursion and the mark, Andreas Röhler, 2015/02/24
Re: save-excursion and the mark, Ivan Shmakov, 2015/02/25