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: Fri, 06 Dec 2019 23:14:15 +0100 Message-ID: <87tv6d3xvs.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> 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="168429"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 38282@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 06 23:15:18 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 1idLsb-000hae-OA for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 23:15:17 +0100 Original-Received: from localhost ([::1]:45868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idLsa-0002BF-B2 for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 17:15:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56491) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idLsP-00027h-5Q for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:15:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1idLsN-0002ZI-Pt for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:15:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1idLsM-0002QH-Gy for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:15:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1idLsM-0006XF-9q for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:15: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: Fri, 06 Dec 2019 22:15: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.157567046725025 (code B ref 38282); Fri, 06 Dec 2019 22:15:02 +0000 Original-Received: (at 38282) by debbugs.gnu.org; 6 Dec 2019 22:14:27 +0000 Original-Received: from localhost ([127.0.0.1]:47137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1idLrm-0006VY-Ui for submit@debbugs.gnu.org; Fri, 06 Dec 2019 17:14:27 -0500 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:39443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1idLrk-0006Uu-Fr for 38282@debbugs.gnu.org; Fri, 06 Dec 2019 17:14:25 -0500 Original-Received: by mail-wm1-f45.google.com with SMTP id s14so8823615wmh.4 for <38282@debbugs.gnu.org>; Fri, 06 Dec 2019 14:14:24 -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=ogwOsO97zCxjEA6yGYSijCqVU6nhbAGAk3jcD8L9gr4=; b=WIwQXnk9LwyHbhaHBXFOKORXiho6tBsqfFm0Rgz9xW1fjAd0oTzAiJ2HoKY1V0Hr2n bkUil1RaxywTH90t4k2jTTgT+z6z1we5Dy0Q6JN2OuK3TOO0QolBMa/B8BfVuES6Zv+y ZpWD/9rH9eJaZD8J+EHKeuW5oUtb8ZByC1ynBgDG7IsyS64OcYgvq2eh9uXzc11LFVnT +lthAwlAb3SqXHSKDCx/Ew/ArvMdCMlgZ/kLFA/P1+eI7FY8wmWhNy/XIBYqF6qtJZNx v1fU+Ra+l/3AnNXvDTltU1QJVRL70KWOc/oUn33vFfkbT9N4qZJ0WPiiVlV1XYm3Q1Xp yAmA== 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=ogwOsO97zCxjEA6yGYSijCqVU6nhbAGAk3jcD8L9gr4=; b=KVI4xE9s1H1SrktCik0VoPATFeQsn8ipNEaw2aQ/232Mh74SfCFmj44hJho21kmVt7 mtEeXLUmZAkqHoXQ91itLq/XbmLYHPoZ+/E9gD7SXvyOQOou4RAEs9idqQcjDgtXyij/ Tx8A/utzOg+UpVWLZSvcqUyMwUgjJBTnmGIHXke2SbTtRjf0sBjqxBi/W6GgbXrzqYAJ 2iShrWc3Gm+gUHXQxepAIggDzz3I3+LviAiZH3rIsS8UeIBVZjvfwdQ77OmeTUNEzk1r TSc1sO+B6/uJ4cCqAe5iJ1ogztdLs8RSLWMNtfpqhniXWCkiuQTk5m794Zeuo9Oq3bP3 J83w== X-Gm-Message-State: APjAAAV9VIoJukYHwMh8PpKg9k9c5opu2J6PJrXgqr+IeoYVHokfabK8 UUQiUh4SIpDgfWMUvYNJGeT04w4X X-Google-Smtp-Source: APXvYqzOd8+jZUy9ENN2hRYifbVt98a4yfaVCkTPomapBnYVjBo6vCJj/XLCBTx9iqGzuFhRDOs8LA== X-Received: by 2002:a05:600c:305:: with SMTP id q5mr12958176wmd.167.1575670458265; Fri, 06 Dec 2019 14:14:18 -0800 (PST) Original-Received: from lead ([2a02:8109:8ac0:2ff0:d5b4:13cf:d83f:ac39]) by smtp.gmail.com with ESMTPSA id b185sm5273088wme.36.2019.12.06.14.14.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2019 14:14:17 -0800 (PST) In-Reply-To: <87o8wxfslj.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 27 Nov 2019 12:48:08 +0100") 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:172985 Archived-At: --=-=-= Content-Type: text/plain > I think it makes sense for read-number to use its own history variable, > but it should not be buffer local. Most inputs are not naturally buffer > local. No problem - I've added an input history variable for `read-number', and a buffer-local one for `goto-line'. I'm attaching a patch with my changes. - Fede --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=goto-line.patch Content-Description: patch >From 249ccb59be23d94018a01b4f8b1577356732d1da Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Fri, 6 Dec 2019 23:07:27 +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. * lisp/subr.el (read-number-history): New history variable. (read-number): Use the new variable as default input history. --- lisp/simple.el | 7 ++++++- lisp/subr.el | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 67ddab3d34..c14718de1c 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 de7d919abf..8f7a9128fa 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 --=-=-=--