[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (copy-marker nil)
From: |
John Mastro |
Subject: |
Re: (copy-marker nil) |
Date: |
Mon, 7 May 2018 06:39:27 -0700 |
Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:
> being surprised WRT behavior of copy-marker:
>
> (setq a (copy-marker nil)) -> #<marker in no buffer>
> (markerp a) -> t
> a -> #<marker in no buffer>
>
> Is taking nil by copy-marker reasonable?
>
> Wanted to check for a valid buffer position, which doesn't seem
> possible that way. While without copy-marker, the variable a would be
> set to nil, now the result evaluates to #<marker in no buffer>, which
> is a kind of t.
There are other ways to get a marker to no buffer, such as
(let ((a (point-marker)))
(set-marker a nil))
So if you don't control the creation of the marker, it's probably a
scenario you need to take care for either way.
Explicitly testing the marker's buffer should work:
(let ((a (copy-marker nil)))
(and (markerp a)
(buffer-live-p (marker-buffer a))))
--
John
- (copy-marker nil), Andreas Röhler, 2018/05/07
- Re: (copy-marker nil),
John Mastro <=
- Re: (copy-marker nil), Noam Postavsky, 2018/05/07
- Re: (copy-marker nil), Andreas Röhler, 2018/05/07
- RE: (copy-marker nil), Drew Adams, 2018/05/07
- Re: (copy-marker nil), Andreas Röhler, 2018/05/07
- Re: (copy-marker nil), Stefan Monnier, 2018/05/07
- Re: (copy-marker nil), Andreas Röhler, 2018/05/08
- Re: (copy-marker nil), Stefan Monnier, 2018/05/12