From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.bugs Subject: bug#24021: FEATURE ADDITION: 25.0.94: goto-marker, jumps to a marker potentially in a different buffer Date: Mon, 18 Jul 2016 12:23:02 -0400 Message-ID: Reply-To: rswgnu@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113ce4dca709090537eb631b X-Trace: ger.gmane.org 1468859067 10249 80.91.229.3 (18 Jul 2016 16:24:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jul 2016 16:24:27 +0000 (UTC) To: 24021@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 18 18:24:16 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bPBL5-000340-D8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 18:24:15 +0200 Original-Received: from localhost ([::1]:48840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBL4-0006zw-O9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 12:24:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBKx-0006ws-7t for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:24:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPBKs-0001rX-Qi for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:24:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBKs-0001r9-NC for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bPBKs-0002CK-GQ for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Weiner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Jul 2016 16:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24021 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14688590298425 (code B ref -1); Mon, 18 Jul 2016 16:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jul 2016 16:23:49 +0000 Original-Received: from localhost ([127.0.0.1]:55914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPBKe-0002Bp-Of for submit@debbugs.gnu.org; Mon, 18 Jul 2016 12:23:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPBKd-0002Bc-2o for submit@debbugs.gnu.org; Mon, 18 Jul 2016 12:23:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPBKX-0001ga-0k for submit@debbugs.gnu.org; Mon, 18 Jul 2016 12:23:41 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43833) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBKW-0001gS-Ta for submit@debbugs.gnu.org; Mon, 18 Jul 2016 12:23:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBKU-0006SU-PH for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:23:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPBKQ-0001fb-Kj for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:23:38 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPBKQ-0001f6-Gq for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:23:34 -0400 Original-Received: from mail-oi0-f51.google.com ([209.85.218.51]:36670) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bPBKP-0004lB-0r for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 12:23:33 -0400 Original-Received: by mail-oi0-f51.google.com with SMTP id w18so259668035oiw.3 for ; Mon, 18 Jul 2016 09:23:32 -0700 (PDT) X-Gm-Message-State: ALyK8tJKO9HOe0KCFKm1dJZgacZ8nL/HonIBjM/7UhlxAfoHL57DXPKgzEtKe62Oih5MsRUYxghVWBmEPwkWRw== X-Received: by 10.202.173.212 with SMTP id w203mr17196750oie.119.1468859012282; Mon, 18 Jul 2016 09:23:32 -0700 (PDT) Original-Received: by 10.202.199.143 with HTTP; Mon, 18 Jul 2016 09:23:02 -0700 (PDT) X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121225 Archived-At: --001a113ce4dca709090537eb631b Content-Type: text/plain; charset=UTF-8 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))))) --001a113ce4dca709090537eb631b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Since goto-char signals an error when given a marker pointing to a b= uffer other than the current one (probably to prevent programming errors) a= nd 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.=C2=A0 = The following function does that and is based on pop-global-mark.=C2=A0 Ple= ase consider adding it to simple.el.

Bob

(defun goto-marker (marker)
=C2=A0 "Make M= ARKER's buffer and position current."
=C2=A0 (interactive)
=C2= =A0 (cond ((not (markerp marker))
= (error "Invalid marker: %s" marker))
((not (marker-buffer marker))
(error "Invalid marke= r buffer: %s" marker))
<= /span>(t (let* ((buffer (marker-buffer marker))
=C2=A0(position (marker-position marker)))
=C2=A0 =C2=A0 (set-buffer= buffer)
=C2=A0 =C2= =A0 (or (and (>=3D position (point-min))
=C2=A0 =C2=A0 =C2=A0(<=3D position (point-max)))=
(if widen-automatic= ally
=C2=A0 =C2=A0 (= widen)
=C2=A0 (error= "Marker position is outside accessible part of buffer: %s" marke= r)))
=C2=A0 =C2=A0 (g= oto-char position)
= =C2=A0 =C2=A0 (switch-to-buffer buffer)))))
--001a113ce4dca709090537eb631b--