From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean McAfee Newsgroups: gmane.emacs.bugs Subject: bug#74438: 29.1; global-mark-ring does not work as described Date: Thu, 21 Nov 2024 11:49:53 -0800 Message-ID: References: <37667f67-9c28-4543-a28a-c5d42878dbce@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000096f7130627719296" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20268"; mail-complaints-to="usenet@ciao.gmane.io" To: 74438@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 21 20:52:41 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tEDEH-00055f-7u for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Nov 2024 20:52:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEDDf-0006J5-Vy; Thu, 21 Nov 2024 14:52:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tEDDe-0006Ie-T2 for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:52:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEDDe-00086f-J6 for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:52:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=dtqfhwGQKA7vv8fBkGD08oh7ZRACVjgB1P5wIRy2VcA=; b=KyclzF77Z15uz7CoG+qK/f5GrZYIRnfoW0GFPLJmXr1gWXmNgLISQKPJRf2eUkozIzD3tujJmf5A0WLklbWMv8fnroWm4VfjauA7x2FSCmkqK+Vejsw/zXpYhWwBQBwPMUyZmY/cYLvw0M3h2kW1lOHsqfG1F+NGo1uBGSKOTzX62KkeZHV15hBUl/nrLx6SB6eg5uHw7eqrpanAqFCANUhd6to6BPwCoRMuBnhbUNsW40JUwLa55DkaVk3zKUnWjGUYNBt9olHuam3U2UcT4qi9i21jBy5eD6RAzQoembrIG+a1z9WXfdNlwSnEdlLjAZVndqzcpdLK6lCdV7wh3g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tEDDe-0003q8-0N for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2024 14:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Sean McAfee Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Nov 2024 19:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74438 X-GNU-PR-Package: emacs Original-Received: via spool by 74438-submit@debbugs.gnu.org id=B74438.173221867314682 (code B ref 74438); Thu, 21 Nov 2024 19:52:01 +0000 Original-Received: (at 74438) by debbugs.gnu.org; 21 Nov 2024 19:51:13 +0000 Original-Received: from localhost ([127.0.0.1]:51817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEDCq-0003ok-Oq for submit@debbugs.gnu.org; Thu, 21 Nov 2024 14:51:13 -0500 Original-Received: from mail-yw1-f178.google.com ([209.85.128.178]:61929) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEDCo-0003oO-Ai for 74438@debbugs.gnu.org; Thu, 21 Nov 2024 14:51:11 -0500 Original-Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6ee7ea48ad8so14134547b3.3 for <74438@debbugs.gnu.org>; Thu, 21 Nov 2024 11:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732218604; x=1732823404; darn=debbugs.gnu.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=dtqfhwGQKA7vv8fBkGD08oh7ZRACVjgB1P5wIRy2VcA=; b=HOY4TmbCHaulDe/38rgFLe+oXQcp9jFgpZbw5O8eOjPdpXxpvwFKhE0uFVB12Qx4Nq dQX5An8d94w4uYHq1RIofJAKe1wVX/BZJvveUvC7V74ke7jaZhwr/JqAVbDInpEP6pRv JZBQpUB0rkQs2AeECBHKa/wVQ6CWbI8lLGKv8taYcF5JLrPfupqJQFzbkt6S/Mhp/cVG 2RAFD5JDkFfSTP6XMJSKYyXzhtL03t0m+zdPGK8Tt7sRnRYtOnEnUolIR5t9zpWpsHV8 vATiXFn5FvhuctRGh64x1/70pyYi+vOQa26gdwQl/flOAJAXxB4A73CBKLup4zO8DJjw CSVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732218604; x=1732823404; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dtqfhwGQKA7vv8fBkGD08oh7ZRACVjgB1P5wIRy2VcA=; b=fTyS/X9WrVhpn4k5fSoF0XocEfKyeXq3VArxTFbBb62T7Ei4XLeD8tA3FAG6ZN37pH QVsP7IBpVZICmkdvFz8n2CjdXzwrFBfLUBCQ2GMd/ZuFuxhfMIZlsEAzytkSWyrf7Qx0 B0J1vSe331ESpbIc3z15fdLph7EUvWMS/lXBnrMudvwCVyLEH/cIuhLG5tqj4E3rGKob hiG8jXJwfWelvCei+C3DsyQintdSZgq0Xp4NmyoLl1Pzyp+LR5o9EyuGjwcjiV3KlJ/E VwiekThxx25JMu/5CjY4xcYG2GsGpOw6wwxZYWY3tKzSt8wNvNNfqsYqb87XPlGLQdpi ByLw== X-Gm-Message-State: AOJu0YyoD4kihOdDwFv+Co/UdlFfofymsmoxoePYqvSMLe7a95IJ+2DU 3s+DvesJpiqTc3Waw4qg1iJAIyzmwcaYLdvH+hUrXJU0vUN7twA3jShFTfnSLPwOSnEwDh/6evs xLFg4XEJ5HyE+bO4c1iFFlF4BABD+OQjO X-Gm-Gg: ASbGnctCmWfugHxTPVDtju4zdqOyauSVxIFitGnOUjNmOVvt+AvTt2smjZ8QMLZGXPv faxF1rvSfPUmvNebmJ3C2LnwLgEL46YOwRr6XfPVd7jeTshYVMzfeBGrFNGIplV2y X-Google-Smtp-Source: AGHT+IHAheBhT65kCwwqKuxGzoR/x2tTL9YWKCULs10EUpNWYHz3Dv2nMvKF2f/5cP+WUqdq0chFXPkCleNpW5D1OAc= X-Received: by 2002:a05:690c:6089:b0:6ea:4d3f:dfa6 with SMTP id 00721157ae682-6eee07b356fmr7493937b3.0.1732218604415; Thu, 21 Nov 2024 11:50:04 -0800 (PST) In-Reply-To: <37667f67-9c28-4543-a28a-c5d42878dbce@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295749 Archived-At: --00000000000096f7130627719296 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Nov 21, 2024 at 12:09=E2=80=AFAM Nikolay Kudryavtsev < nikolay.kudryavtsev@gmail.com> wrote: > Using the mark ring for programming purposes is generally seen as a faux > pas, see the docstrings for push-mark and set-mark, which explicitly > warn against this. > I've read those warnings, which seem to be about using the mark to keep track of positions within a single function execution. Here I'm writing a command that wants to use information recorded by a previous command, which seems like a legitimate use to me. > If you still insist, then nothing is really stopping you from short > circuiting this behavior by say doing a forward-char, set-mark, > backward-char, set-mark again. > I could do that, but conceptually I just want to set the mark, and I don't want to have to perpetually keep in mind that when I set the mark in this one specific context, I need to go through an extended routine like that. > But I also don't understand why do you need buffer 1 mark to be at the > front of the ring, because it's gonna reliably be as the second element > in it anyway. > But it won't; it could be anywhere in the global mark ring. - Go to a new buffer foo and press C-SPC; now buffer foo is first in the global mark ring. - Go to a new buffer bar and press C-SPC; now buffer foo is second in the ring. - Go to a new buffer baz and press C-SPC; now buffer foo is third in the ring. - Go back to buffer foo and press C-SPC; buffer foo is still third in the ring. And buffer foo won't be in the ring at all if more than global-mark-ring-max buffers are visited in this way. Anyway, it seems like a consensus is emerging that it's the documentation and not the code that needs to be updated. At least I've thought of a way to get the info I need without changing my workflow. Something like: (defvar last-global-mark (make-marker)) (defun my-set-mark-command (arg) (interactive "P") (set-mark-command arg) (unless (equal arg '(4)) (set-marker last-global-mark (point)))) (global-set-key [remap set-mark-command] #'my-set-mark-command) I wish it weren't necessary, but at least it's not very long. --00000000000096f7130627719296 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Nov 21, 2024 at 12:09=E2=80=AFAM = Nikolay Kudryavtsev <ni= kolay.kudryavtsev@gmail.com> wrote:
=
Using the mark ring for p= rogramming purposes is generally seen as a faux
pas, see the docstrings for push-mark and set-mark, which explicitly
warn against this.

I've read those = warnings, which seem to be about using the mark to keep track of positions = within a single function execution.=C2=A0 Here I'm writing a command th= at wants to use information recorded by a previous command, which seems lik= e a legitimate use to me.
=C2=A0
If you still insist, then nothing is really stopping you from short
circuiting this behavior by say doing a forward-char, set-mark,
backward-char, set-mark again.

I could = do that, but conceptually I just want to set the mark, and I don't want= to have to perpetually keep in mind that when I set the mark in this one s= pecific context, I need to go through an extended routine like that.
=C2=A0
But I also don't understand why do you need buffer 1 mark to be at the =
front of the ring, because it's gonna reliably be as the second element=
in it anyway.

But it won't; it coul= d be anywhere in the global mark ring.

- Go to a n= ew buffer foo and press C-SPC; now buffer foo is first in the global mark r= ing.
- Go to a new buffer bar and press C-SPC; now buffer foo is = second in the ring.
- Go to a new buffer baz and press C-SPC; now= buffer foo is third in the ring.
- Go back to buffer foo and pre= ss C-SPC; buffer foo is still third in the ring.

A= nd buffer foo won't be in the ring at all if more than global-mark-ring= -max buffers are visited in this way.

Anyway, = it seems like a consensus is emerging that it's the documentation and n= ot the code that needs to be updated.=C2=A0 At least I've thought of a = way to get the info I need without changing my workflow.=C2=A0 Something li= ke:

=C2=A0=C2=A0=C2=A0 (defvar last-global-mar= k (make-marker))

=C2=A0=C2=A0=C2=A0 (defun my-set-= mark-command (arg)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (interactive &q= uot;P")
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (set-mark-command arg= )
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless (equal arg '(4))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (set-marker last-global-m= ark (point))))

=C2=A0=C2=A0=C2=A0 (global-set-key = [remap set-mark-command] #'my-set-mark-command)

I wish it weren't necessary, but at least it's not very long.

--00000000000096f7130627719296--