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: Thu, 21 Nov 2019 23:06:14 +0100 Message-ID: <87a78olwa1.fsf@gmail.com> References: <877e3va66f.fsf@gmail.com> <871ru1z6ax.fsf@gnus.org> <878so9uugg.fsf@gmx.de> <87h82xw21s.fsf@gnus.org> <87imndkr3f.fsf@gmail.com> 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="84631"; 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, Robert Pluim , Michael Albinus To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 21 23:07:21 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 1iXubf-000LrT-QQ for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Nov 2019 23:07:19 +0100 Original-Received: from localhost ([::1]:46094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXube-0000h2-Nq for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Nov 2019 17:07:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54476) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXubV-0000gu-EB for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2019 17:07:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXubR-0003au-Hp for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2019 17:07:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44616) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iXubR-0003am-9p for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2019 17:07:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iXubO-0004Gu-Cm for bug-gnu-emacs@gnu.org; Thu, 21 Nov 2019 17:07:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Nov 2019 22:07: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.157437398716372 (code B ref 38282); Thu, 21 Nov 2019 22:07:02 +0000 Original-Received: (at 38282) by debbugs.gnu.org; 21 Nov 2019 22:06:27 +0000 Original-Received: from localhost ([127.0.0.1]:53437 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXuao-0004G0-Vy for submit@debbugs.gnu.org; Thu, 21 Nov 2019 17:06:27 -0500 Original-Received: from mail-wr1-f66.google.com ([209.85.221.66]:35819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXuam-0004Fm-O9 for 38282@debbugs.gnu.org; Thu, 21 Nov 2019 17:06:25 -0500 Original-Received: by mail-wr1-f66.google.com with SMTP id s5so6337010wrw.2 for <38282@debbugs.gnu.org>; Thu, 21 Nov 2019 14:06: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=R+iGFnqje7Ph2qNiQnCcKk9j4VuEMQBnkhp5dU35liQ=; b=VM238vW0KZEkKs6xRyrf7ZWSALmqfVXHyDlud+QToxJjv0AWjRJJWrwsFCAVOzQI7n Pj9NH6cbPTqcGbH7Gx/6rXztEjWAewo48y6XkfHL7HzmPuqEI6ynMb64pjt5qQTgGPLa PqCdrKyTOKzj7cq64kf0G5NWf9mJ6bsDnlfU+MAza8DMCrb+mvoVokRWMFOAokkizDhY 62/AwGTSGtdfILP3hGWjC+4A9B1ksNkQS28O5BIIAE7ZQnRJuHDE8lt8mZVEhQ8GC4bH J/WdBIjFbBCTaFcVWKIhqVnWh5+9M+PonBJ3bX82RhUUZje7Ue4mXinNbS3NU3QxBol/ Amhg== 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=R+iGFnqje7Ph2qNiQnCcKk9j4VuEMQBnkhp5dU35liQ=; b=bkNJwjd05ak4jp5qIPKD+6MbPw3YNf5YUWFJfX2p5/JBl6NuYHrfld3aGgKLq/IPWR mx+/LDpLWIsWecq9zZ3zJPUniIwetQZqlteZALAG1UmdXGbkCVfXxcG4T8FhPB6PIRrG 0Kikr/HR96U4F1EI1w/ByQ50aACmUuAWaZUOQ5ctL2GEAAsoja+rUVjiOvJifxyvPM1K 41ZrONNW7KLMj4iI0oPVezCg7duQywu96EKiSJ58TmcIhIFjcdN/DotmGjL0bUEeOoLB IS34wtCDZ4fBNXwu+S33hOvN+ZPOLeC/eWMYagasiC7ASDE3j2Htx+cXbAfDygG/bk/Q aqlg== X-Gm-Message-State: APjAAAXyiZJw1A1hjCZzbq3n02fwX8lGj8j8OaWSzF20FwFlVgzYJS5U aXTrNmjxuhmF744QjNDfEKc= X-Google-Smtp-Source: APXvYqwB7IhBfOp6akWlOcFu9KlfWKWpSUk5Hkhagxys+BXAqpfK6l/N/DGxgYPbR7DCd4qsOI3ltA== X-Received: by 2002:a05:6000:150:: with SMTP id r16mr13503098wrx.313.1574373978821; Thu, 21 Nov 2019 14:06:18 -0800 (PST) Original-Received: from lead ([2a02:8109:8ac0:2ff0:d17f:44c3:a5fa:4c03]) by smtp.gmail.com with ESMTPSA id w132sm1226173wma.6.2019.11.21.14.06.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Nov 2019 14:06:16 -0800 (PST) In-Reply-To: <87imndkr3f.fsf@gmail.com> (Federico Tedin's message of "Thu, 21 Nov 2019 19:43:32 +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:172168 Archived-At: --=-=-= Content-Type: text/plain > It seems like `read-from-minibuffer' doesn't like having its HIST > parameter be buffer-local (but I may have misunderstood the problem). > I'm going to look into it more on depth these days. Here's my first attempt at implementing this - I managed to get around the `read-from-minibuffer' problem with some help from the Emacs StackOverflow (but created a separate bug report for it: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38317). I'm attaching a small patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=goto-line.patch Content-Description: patch >From 3994fa53d0cf210e7f109dc2059ee78a96215547 Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Thu, 21 Nov 2019 23:01:23 +0100 Subject: [PATCH 1/1] Make input history buffer-local for 'goto-line' * lisp/simple.el (goto-line-history): New buffer-local variable which holds the input history for 'goto-line'. (goto-line): Use the new variable as input history (Bug#38282). * etc/NEWS: Announce changes. --- etc/NEWS | 5 +++++ lisp/simple.el | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7a51106add..0bbb40dfa2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -589,6 +589,11 @@ If the region is active, the command joins all the lines in the region. When there's no active region, the command works on the current and the previous or the next line, as before. +--- +** 'goto-line' now keeps a separate input history for each buffer. +Additionally, the line number input history will be kept separate from +the input history for other commands. + * Changes in Specialized Modes and Packages in Emacs 27.1 diff --git a/lisp/simple.el b/lisp/simple.el index c61ccd511c..dd8e8a291a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1212,6 +1212,11 @@ mark-whole-buffer ;; Counting lines, one way or another. +(defvar goto-line-history nil + "Input history for `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 @@ -1253,7 +1258,14 @@ goto-line (buffer-prompt (if buffer (concat " in " (buffer-name buffer)) - ""))) + "")) + ;; It would be better to use `goto-line-history' as a HIST + ;; parameter to `read-from-minibuffer' (through + ;; `read-number'), but using buffer-local variables + ;; doesn't work for that purpose. (Bug#38317) + (minibuffer-history + (buffer-local-value 'goto-line-history (or buffer + (current-buffer))))) ;; 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))) @@ -1271,7 +1283,10 @@ goto-line (goto-char (point-min)) (if (eq selective-display t) (re-search-forward "[\n\C-m]" nil 'end (1- line)) - (forward-line (1- line))))) + (forward-line (1- line)))) + ;; Save the line number in the input history list. + (with-current-buffer (or buffer (current-buffer)) + (add-to-history 'goto-line-history (int-to-string line)))) (defun count-words-region (start end &optional arg) "Count the number of words in the region. -- 2.17.1 --=-=-=--