unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker potentially in a different buffer
@ 2016-07-18 16:23 Robert Weiner
  2016-07-19  0:05 ` npostavs
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Weiner @ 2016-07-18 16:23 UTC (permalink / raw)
  To: 24021

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

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)
  (cond ((not (markerp marker))
(error "Invalid marker: %s" marker))
((not (marker-buffer marker))
(error "Invalid marker buffer: %s" marker))
(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)))))

[-- Attachment #2: Type: text/html, Size: 3286 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-01 19:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 16:23 bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker potentially in a different buffer Robert Weiner
2016-07-19  0:05 ` npostavs
2016-07-19  2:05   ` Robert Weiner
2016-07-19  2:20     ` Noam Postavsky
2016-07-19 13:15   ` Robert Weiner
2016-07-20  1:55     ` npostavs
2021-12-01 19:49       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).