[Top][All Lists]

[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: npostavs
Subject: bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker potentially in a different buffer
Date: Mon, 18 Jul 2016 20:05:21 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux)

severity 24021 wishlist

Robert Weiner <rsw@gnu.org> writes:

> Since goto-char signals an error when given a marker pointing to a
> buffer other than the current one (probably to prevent programming
> errors) and pop-global-mark only works on the global-mark-ring, there
> is a need for a simple function that jumps to the location of an
> arbitrary marker. The following function does that and is based on
> pop-global-mark. Please consider adding it to simple.el.
> Bob
> (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

>   (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.

>         (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.

reply via email to

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