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 19:01:24 +0100 Message-ID: References: <87o8iy975l.fsf@gnus.org> <87k0tl4zmc.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="38092"; 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 19:02:18 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 1koVhI-0009kv-Qi for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 19:02:16 +0100 Original-Received: from localhost ([::1]:36742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koVhH-0004Pw-P1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 13:02:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koVh4-0004JK-Fe for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:02:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koVh4-0006IZ-5d for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koVh4-0002YK-07 for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:02: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 18:02:01 +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.16078824999779 (code B ref 45199); Sun, 13 Dec 2020 18:02:01 +0000 Original-Received: (at 45199) by debbugs.gnu.org; 13 Dec 2020 18:01:39 +0000 Original-Received: from localhost ([127.0.0.1]:50062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koVgh-0002Xf-61 for submit@debbugs.gnu.org; Sun, 13 Dec 2020 13:01:39 -0500 Original-Received: from sonic304-22.consmr.mail.ir2.yahoo.com ([77.238.179.147]:38901) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koVgd-0002XN-Ss for 45199@debbugs.gnu.org; Sun, 13 Dec 2020 13:01:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1607882486; bh=OThvixHriKoNFfu3N1k8TDqUBMhtCQdGXquAsl4U9cI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject; b=n+w510AIOdv/9+5ZeLXpBcaFnLChe+Hy8BYOcpE0C7RMzblcV5NOCU1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FOUA 43EztQCjcxT61ZDGpuacw7vnIHNQS794qYZkcjtLWGyAJg_IOUaup5k78tmMNeVJ4988Nk9_wiqc Sd.E5QPO5OLUbhGnNLkokGbWOGpifArUsMsGRdxP_NWZ4fTBwcPwKzpGTI7_EmA3_mo1F3TWo6wA xbL7UhNNWPRDd7wn8XZvcM274iANwxmwW._jZHazUnmfjZwnU0SbhYrfjPygTE0cistTrhBYnwJS dTWtH5BkrZC1ZNFw3E.ZHepC.XE.ui7Hd1i3gyInKXLP5iSvVU0PEBjX0Hm68FWBmhQ1kXMZLGO7 JxzKc97ydlZc8uHww9nfil6g6nMXCqh1Jgo5VhJwTyC_ap9l1ya4OXp3FI8DXd8JBMeM.89ljLh3 eBp0Ly2zmTjmT3LQDPRXF_q2oA2IqS4.joB1QQ.KPdgl1f6FBgF7wANfGMKrfuA_MEuf8eTyhf8d yxM32dVa7pNDMT8TdZKmSyeteMkhm5QhX9KFZvvhsN0MgyD6lwOX_qTdjmLuvELB2CW4c8hdKIPA kT3S6C3jwHaBUaRklbKWWtgxmp1TF5HXsHOGMKEDbO Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ir2.yahoo.com with HTTP; Sun, 13 Dec 2020 18:01:26 +0000 Original-Received: by smtp414.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID ad38b85bccaded2be746bdf447d40bcb; Sun, 13 Dec 2020 18:01:25 +0000 (UTC) In-Reply-To: <87k0tl4zmc.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 13 Dec 2020 14:14:19 +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:195986 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > > Yeah, I'd still rather have a helper function -- putting several lines > of Lisp code in a string in C isn't optimal. OK, done. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-goto-char-offer-the-number-at-point-as-default.patch >From 62dffb016c1b95923e654f516f52780aa2eb966d 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 * lisp/subr.el (read-natnum-interactive): New function to read natural numbers for interactive functions. * src/editfns.c (Fgoto_char): Call read-natnum-interactive from the interactive definition of goto-char to offer the number at point as default. 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 ++++ lisp/subr.el | 9 +++++++++ src/editfns.c | 9 +++++++-- 4 files changed, 24 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/lisp/subr.el b/lisp/subr.el index ed235ee1f7..5e4f7dec7d 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2820,6 +2820,15 @@ read-char-from-minibuffer (message "%s%s" prompt (char-to-string char)) char)) +(defun read-natnum-interactive (prompt) + "Get a natural number argument, optionally prompting with PROMPT. +If there is a natural number at point, use it as default." + (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 prompt default))))) + ;; Behind display-popup-menus-p test. (declare-function x-popup-dialog "menu.c" (position contents &optional header)) diff --git a/src/editfns.c b/src/editfns.c index 4104edd77f..4723660b43 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -188,11 +188,16 @@ 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, + "(read-natnum-interactive \"Go to char: \")", 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 --=-=-=--