From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Unknown Newsgroups: gmane.emacs.bugs Subject: bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default Date: Sun, 13 Dec 2020 02:23:13 +0100 Message-ID: References: <87o8iy975l.fsf@gnus.org> Reply-To: =?UTF-8?Q?Reply-to=3A_Daniel_Mart=C3=83=C2=ADn_=3Cmardani29=40yahoo=2Ees?= =?UTF-8?Q?=3E=0A?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22143"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cc: 45199@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 13 02:24:27 2020 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 1koG7f-0005fx-0a for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 02:24:27 +0100 Original-Received: from localhost ([::1]:34170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koG7c-0000zm-Nf for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Dec 2020 20:24:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koG7G-0000za-Gd for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 20:24:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koG7G-0001Ii-9U for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 20:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koG7G-0005Q5-4u for bug-gnu-emacs@gnu.org; Sat, 12 Dec 2020 20:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Dec 2020 01:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45199 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45199-submit@debbugs.gnu.org id=B45199.160782261420793 (code B ref 45199); Sun, 13 Dec 2020 01:24:02 +0000 Original-Received: (at 45199) by debbugs.gnu.org; 13 Dec 2020 01:23:34 +0000 Original-Received: from localhost ([127.0.0.1]:47175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koG6o-0005PI-6J for submit@debbugs.gnu.org; Sat, 12 Dec 2020 20:23:34 -0500 Original-Received: from sonic303-21.consmr.mail.ir2.yahoo.com ([77.238.178.202]:39066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koG6h-0005Oq-69 for 45199@debbugs.gnu.org; Sat, 12 Dec 2020 20:23:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1607822598; bh=XKBxksztnDeJGrvzwbstprr3qVTFsz8PfzOTybu0Bw0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject; b=eD1AjlNLWSbXE4rlh41HNMsfu/5tikjBrWIChxS8QkuG6kuCTTf1JtfE2HLLMyNpsnBmgFIokpKEDPvs4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IClpXx1iegfmWGjv5J4cCqlqx.EmIKf7W6veZNYC43Uto_.42VzGq EW8hD6zenrI8Ajeof90ueqU41d83im1koyQQcNcxSgQxjRINKSIpcuT7MO44h_dNjaQrwU_rye_N lgjXsjDRDtWxmWXCoysdbrwSGXu9cHk9FPmXillkWDr7NNonIZUJj3VGecBVnMoW.s.j.5DNJJAi KD8hzdxA7R5qro1iLBy54Xzh6cgvVgcdvSGwzGWifVKg0SPkYPvmEoLbjk_eX4EO5VDa7iGniTgj 9VSPDDIv031l7IDufYVWz3vm7xXAm.6Gv3yrW.uDn1fNrMNiOjUKMCFKKLhb9KTQLBpvKNVxEldH GnvjwnEqp7Kwiyf8WSSeScYD03ERqmP8cwhPYcu3Yhu7gCXMvPjI03KujtMhm_GqrPoNNnBedPQK vdVD79mM0iS9DAhFeLB..qZdjPpf540McMo78TsCSaRCYAnzd4LxBF1n_Al7dPxDOubhdyrh7_Ik QSghhKIeEwKBiI_PJE4m4ulbh_WML.w6SERoD0ltn. Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Sun, 13 Dec 2020 01:23:18 +0000 Original-Received: by smtp415.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 2e0316d90f463f3736a6af530bdb6fed; Sun, 13 Dec 2020 01:23:14 +0000 (UTC) In-Reply-To: <87o8iy975l.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 12 Dec 2020 20:05:42 +0100") X-Mailer: WebService/1.1.17278 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) 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" Original-From: Xref: news.gmane.io gmane.emacs.bugs:195924 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > > I think it would be better to put this in a helper function in subr.el, > for instance. > > And there's also `number-at-point', could perhaps be used here? Oh, I forgot about number-at-point. It extracts numbers that don't make sense here (like floating point or negative numbers), but we can easily filter them with natnump. I've attached a new patch; do you feel it's still necessary to extract the logic in a helper? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-goto-char-offer-the-number-at-point-as-default.patch >From 499618f25e78cb1ab9803e44123b249b40b9d4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sat, 12 Dec 2020 17:10:05 +0100 Subject: [PATCH] Make goto-char offer the number at point as default * src/editfns.c (Fgoto_char): Expand the interactive definition of goto-char to offer the number at point as default. Note that only numbers that make sense as character positions will be offered. Also expand the docstring to document this new interactive behavior. * doc/emacs/basic.texi (Moving Point): Expand the Emacs manual to document this new behavior. * etc/NEWS: And announce it. --- doc/emacs/basic.texi | 5 ++++- etc/NEWS | 4 ++++ src/editfns.c | 13 +++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi index cd1ffbebd7..77c8054746 100644 --- a/doc/emacs/basic.texi +++ b/doc/emacs/basic.texi @@ -310,7 +310,10 @@ Moving Point @kindex M-g c @findex goto-char Read a number @var{n} and move point to buffer position @var{n}. -Position 1 is the beginning of the buffer. +Position 1 is the beginning of the buffer. If point is on or just +after a number in the buffer, that is the default for @var{n}. Just +type @key{RET} in the minibuffer to use it. You can also specify +@var{n} by giving @kbd{M-g c} a numeric prefix argument. @item M-g M-g @itemx M-g g diff --git a/etc/NEWS b/etc/NEWS index 514209516d..13ff0bb171 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -257,6 +257,10 @@ When 'widen-automatically' is non-nil, 'goto-line' widens the narrowed buffer to be able to move point to the inaccessible portion. 'goto-line-relative' is bound to 'C-x n g'. ++++ +** When called interactively, 'goto-char' now offers the number at + point as default. + +++ ** When 'suggest-key-bindings' is non-nil, the completion list of 'M-x' shows equivalent key bindings for all commands that have them. diff --git a/src/editfns.c b/src/editfns.c index 4104edd77f..a6f9d30a7c 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -188,11 +188,20 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0, return build_marker (current_buffer, PT, PT_BYTE); } -DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ", +DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, + "(if (and current-prefix-arg (not (consp current-prefix-arg)))\ + (list (prefix-numeric-value current-prefix-arg))\ + (let* ((number (number-at-point))\ + (default (and (natnump number) number)))\ + (list (read-number \"Goto char: \" default))))", doc: /* Set point to POSITION, a number or marker. Beginning of buffer is position (point-min), end is (point-max). -The return value is POSITION. */) +The return value is POSITION. + +If called interactively, a numeric prefix argument specifies +POSITION; without a numeric prefix argument, read POSITION from the +minibuffer. */) (register Lisp_Object position) { if (MARKERP (position)) -- 2.28.0 --=-=-=--