[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker pot
From: |
Robert Weiner |
Subject: |
bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker potentially in a different buffer |
Date: |
Mon, 18 Jul 2016 22:05:33 -0400 |
Thanks for the feedback. I will work on an update.
-- Bob
> On Jul 18, 2016, at 8:05 PM, npostavs@users.sourceforge.net wrote:
>>
>> (defun goto-marker (marker)
>> "Make MARKER's buffer and position current."
>> (interactive)
>
> The interactive spec doesn't match the parameter list. I'm not sure if
> it makes sense for this to be interactive (how would the user enter a
> marker?).
That interactive spec should not be in there.
>
>> (cond ((not (markerp marker))
>> (error "Invalid marker: %s" marker))
>> ((not (marker-buffer marker))
>> (error "Invalid marker buffer: %s" marker))
>
> I think these checks are redundant, you'll get the same errors when you
> call marker-buffer and set-buffer, below.
I will take a look.
>
>> (t (let* ((buffer (marker-buffer marker))
>> (position (marker-position marker)))
>> (set-buffer buffer)
>> (or (and (>= position (point-min))
>> (<= position (point-max)))
>> (if widen-automatically
>> (widen)
>> (error "Marker position is outside accessible part of
>> buffer: %s" marker)))
>> (goto-char position)
>> (switch-to-buffer buffer)))))
>
> If this is just a "simple function" (not an interactive command), it
> shouldn't widen, or call switch-to-buffer.
But it does need to do these things to leave the selected buffer and point
where the marker points. It only widens if the marker position is outside the
restricted range. It can be wrapped in save-restriction and save-excursion for
times when it is used for temporary effect, e.g. to find the column of the
marker position.
Bob