help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (copy-marker nil)


From: Andreas Röhler
Subject: Re: (copy-marker nil)
Date: Mon, 7 May 2018 16:23:17 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 07.05.2018 15:39, John Mastro wrote:
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))))


Thanks. A way to deal with ;)





reply via email to

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