From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#38282: 26.3; goto-line should not share input history with other commands Date: Tue, 17 Dec 2019 22:19:44 +0100 Message-ID: <87mubqabv3.fsf@gmail.com> References: <877e3va66f.fsf@gmail.com> <871ru1z6ax.fsf@gnus.org> <878so9uugg.fsf@gmx.de> <87h82xw21s.fsf@gnus.org> <87imndkr3f.fsf@gmail.com> <87a78olwa1.fsf@gmail.com> <87pnhkt8nx.fsf@gnus.org> <87tv6uikv7.fsf@gmail.com> <87o8wxfslj.fsf@gnus.org> <87tv6d3xvs.fsf@gmail.com> <837e2z6si5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="102406"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: larsi@gnus.org, 38282@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 17 22:20:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ihKGK-000QQx-QX for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Dec 2019 22:20:12 +0100 Original-Received: from localhost ([::1]:46376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihKGJ-0001i7-6c for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Dec 2019 16:20:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53762) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihKGB-0001i0-RQ for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2019 16:20:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihKGA-0008Bu-GD for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2019 16:20:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36476) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihKGA-0008Bo-CV for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2019 16:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ihKGA-0004Dw-8X for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2019 16:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Dec 2019 21:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38282 X-GNU-PR-Package: emacs Original-Received: via spool by 38282-submit@debbugs.gnu.org id=B38282.157661759316218 (code B ref 38282); Tue, 17 Dec 2019 21:20:02 +0000 Original-Received: (at 38282) by debbugs.gnu.org; 17 Dec 2019 21:19:53 +0000 Original-Received: from localhost ([127.0.0.1]:42449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihKG1-0004DV-Cd for submit@debbugs.gnu.org; Tue, 17 Dec 2019 16:19:53 -0500 Original-Received: from mail-ed1-f47.google.com ([209.85.208.47]:38203) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihKG0-0004DI-7U for 38282@debbugs.gnu.org; Tue, 17 Dec 2019 16:19:52 -0500 Original-Received: by mail-ed1-f47.google.com with SMTP id i16so8211216edr.5 for <38282@debbugs.gnu.org>; Tue, 17 Dec 2019 13:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=e48vVvpIE1pnKd5eUgk3QGgRQIsvF4G6bUpVz6S80oM=; b=cHsr1XXv9gcQDwWu3O7/uJEGPCehI2oALkhsJ2lAaNgCpPBEHIR99H+cZ4XOQLPen+ FhiXYsogxlfHdsy0DaW2pWKFKh2BOOIyyCJousEPhTKJpGykJQv0o1pWCt6veTfvJwY3 /z5ZV9iT5wDpdqEDvX+04XPLA6ZLI2S6yj9h4PN2fd4pL2V4up+H3JaFXkrwIa8MBz3U fBr/6WTaW9XwG5vRcnacBpDC5Qsepof0FezQ3RT0lA8a3mKJ5miduQ2liVz1w4A8Az59 hHvllN8d7dEBpEa5JCWxbWK3e0uFIVSnwuoRh7GriYG++Jvqq9XcjfIHB4atYVzud6G5 C3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=e48vVvpIE1pnKd5eUgk3QGgRQIsvF4G6bUpVz6S80oM=; b=Di2sVtW8Q68ffrvU0/ZTANrndk+yWhjKLu8AUYeRpA22ibJU2FmI8x5P1qn1dBg3MZ rCMSikvzYV0SQDrgQgd9aUgtS0URRCIha0/soyWL8sXdRRSBgz3gzM7eMbyf+8m4+M+b 2fpb0peIv26LfeXw60FRArEJndZIeHkO0QCMa6LeMdLRFGMa8wURxENfMt9Qw4cUWqGY 8CYfXbQtWfJDp4JYrnqyR+JBHcSYayWxK2LHMSg3Zz8CyeDHOhTjuAAazeAJ1LxBePiT /9XqYUoxG6siijtEkBM3tIWi1eEDm3r9zBcEJ5txl3eP6864jSgak59MGKWV+bwdvpa6 pYeQ== X-Gm-Message-State: APjAAAV+WBNU+eKpW0i2pdFDHnDkI4KNdgCl+N9v7fTxg6Mkg8FH08rS DV8O7wcfAHjiAXtlmcbc9Z5K02h0 X-Google-Smtp-Source: APXvYqytLeosjsMMQggw9OLvsInIpNNRUjyYssd2ywm0cFFeA4/1yYdoe9xCTxO7K2Rmu4PhPnmuKQ== X-Received: by 2002:a17:906:1690:: with SMTP id s16mr166654ejd.14.1576617586033; Tue, 17 Dec 2019 13:19:46 -0800 (PST) Original-Received: from lead ([2a02:8109:8ac0:2ff0:695b:ded2:cb39:e6d9]) by smtp.gmail.com with ESMTPSA id 2sm803083edv.87.2019.12.17.13.19.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Dec 2019 13:19:44 -0800 (PST) In-Reply-To: <837e2z6si5.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Dec 2019 13:44:50 +0200") 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: 209.51.188.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:173499 Archived-At: --=-=-= Content-Type: text/plain > Thanks, I think this variable should be mentioned in the ELisp manual > (in the "Minibuffer History" node) and in NEWS. Sorry, forgot to do that. I've now documented both new variables (the one for `read-number' and the one for `goto-line'). I'm attaching a new patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=goto-line.patch Content-Description: patch >From 67e2d243473c52c1b52102203cf069dbed4165cc Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Tue, 17 Dec 2019 22:13:55 +0100 Subject: [PATCH 1/1] Make goto-line keep a separate input history per buffer * lisp/simple.el (goto-line-history): New history variable. (goto-line): Use new (buffer-local) variable as input history (Bug#38282). * lisp/subr.el (read-number-history): New history variable. (read-number): Use the new variable as default input history. * doc/lispref/minibuf.texi (Minibuffer History): Document read-number-history and goto-line-history variables. * etc/NEWS: Announce changes. --- doc/lispref/minibuf.texi | 9 +++++++++ etc/NEWS | 11 +++++++++++ lisp/simple.el | 7 ++++++- lisp/subr.el | 9 +++++++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index dde30ce67f..2c2ef9747b 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -645,6 +645,15 @@ Minibuffer History @code{read-variable}. @end defvar +@defvar read-number-history +A history list for numbers read by @code{read-number}. +@end defvar + +@defvar goto-line-history +A history list for arguments to @code{goto-line}. This variable is +buffer local. +@end defvar + @c Less common: coding-system-history, input-method-history, @c command-history, grep-history, grep-find-history, @c read-envvar-name-history, setenv-history, yes-or-no-p-history. diff --git a/etc/NEWS b/etc/NEWS index cf4e705a52..dc17445757 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -533,6 +533,17 @@ The HIST argument of 'read-from-minibuffer' now works correctly with buffer-local variables. This means that different buffers can have their own separated input history list if desired. ++++ +** 'read-number' now has its own history variable. +Additionally, the function now accepts a HIST argument which can be +used to specify a custom history variable. + ++++ +** Input history for 'goto-line' is now local to every buffer. +Each buffer will keep a separate history of line numbers used with +'goto-line'. This should help making faster the process of finding +line numbers that were previously jumped to. + * Editing Changes in Emacs 27.1 diff --git a/lisp/simple.el b/lisp/simple.el index 6d5030073b..6219986da0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1212,6 +1212,10 @@ mark-whole-buffer ;; Counting lines, one way or another. +(defvar goto-line-history nil + "History of values entered with `goto-line'.") +(make-variable-buffer-local 'goto-line-history) + (defun goto-line (line &optional buffer) "Go to LINE, counting from line 1 at beginning of buffer. If called interactively, a numeric prefix argument specifies @@ -1256,7 +1260,8 @@ goto-line ""))) ;; Read the argument, offering that number (if any) as default. (list (read-number (format "Goto line%s: " buffer-prompt) - (list default (line-number-at-pos))) + (list default (line-number-at-pos)) + 'goto-line-history) buffer)))) ;; Switch to the desired buffer, one way or another. (if buffer diff --git a/lisp/subr.el b/lisp/subr.el index ed55853bb2..f5b7c98f50 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2518,10 +2518,15 @@ read-passwd ;; And of course, don't keep the sensitive data around. (erase-buffer)))))))) -(defun read-number (prompt &optional default) +(defvar read-number-history nil + "The default history for the `read-number' function.") + +(defun read-number (prompt &optional default hist) "Read a numeric value in the minibuffer, prompting with PROMPT. DEFAULT specifies a default value to return if the user just types RET. The value of DEFAULT is inserted into PROMPT. +HIST specifies a history list variable. See `read-from-minibuffer' +for details of the HIST argument. This function is used by the `interactive' code letter `n'." (let ((n nil) (default1 (if (consp default) (car default) default))) @@ -2535,7 +2540,7 @@ read-number (while (progn (let ((str (read-from-minibuffer - prompt nil nil nil nil + prompt nil nil nil (or hist 'read-number-history) (when default (if (consp default) (mapcar 'number-to-string (delq nil default)) -- 2.17.1 --=-=-=--