From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: kwc3iywb@vfemail.net Newsgroups: gmane.emacs.bugs Subject: bug#27056: 25.2; goto-line doesn't default to current line when used interactively when the cursor isn't over a number Date: Thu, 25 May 2017 08:52:46 +0000 Message-ID: <20170525085246.GA4883@vfemail.net> References: <20170524111937.GA17052@vfemail.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oC1+HKm2/end4ao3" X-Trace: blaine.gmane.org 1495726378 28516 195.159.176.226 (25 May 2017 15:32:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 25 May 2017 15:32:58 +0000 (UTC) User-Agent: Mutt/1.8.2 (2017-04-18) Cc: 27056@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 25 17:32:54 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDukw-0007II-5L for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 May 2017 17:32:54 +0200 Original-Received: from localhost ([::1]:60533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDul1-00039A-Kg for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 May 2017 11:32:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDukD-0001qn-KW for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuk9-0004TJ-1B for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35143) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dDuk8-0004T7-V9 for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dDuk8-0002UY-Pc for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: kwc3iywb@vfemail.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 May 2017 15:32:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27056 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27056-submit@debbugs.gnu.org id=B27056.14957263039487 (code B ref 27056); Thu, 25 May 2017 15:32:04 +0000 Original-Received: (at 27056) by debbugs.gnu.org; 25 May 2017 15:31:43 +0000 Original-Received: from localhost ([127.0.0.1]:37810 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDujm-0002Sr-Jo for submit@debbugs.gnu.org; Thu, 25 May 2017 11:31:42 -0400 Original-Received: from onethreetwo.vfemail.net ([199.16.11.132]:55615 helo=vfemail.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDsi8-0007ml-Ja for 27056@debbugs.gnu.org; Thu, 25 May 2017 09:21:53 -0400 Original-Received: (qmail 72136 invoked by uid 89); 25 May 2017 13:21:46 -0000 Original-Received: from localhost (HELO freequeue.vfemail.net) (127.0.0.1) by localhost with (DHE-RSA-AES256-SHA encrypted) SMTP; 25 May 2017 13:21:45 -0000 Original-Received: (qmail 6632 invoked by uid 89); 25 May 2017 08:52:43 -0000 Original-Received: by simscan 1.4.0 ppid: 6628, pid: 6630, t: 0.0027s scanners:none Original-Received: from unknown (HELO smtp102-2.vfemail.net) (172.16.100.62) by FreeQueue with SMTP; 25 May 2017 08:52:43 -0000 Original-Received: (qmail 8958 invoked by uid 89); 25 May 2017 08:52:43 -0000 Original-Received: by simscan 1.4.0 ppid: 8906, pid: 8951, t: 1.4515s scanners:none Original-Received: from unknown (HELO vfemail.net) (a3djM2l5d2JAdmZlbWFpbC5uZXQ=@78.109.23.1) by 172.16.100.62 with ESMTPA; 25 May 2017 08:52:41 -0000 Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Thu, 25 May 2017 11:31:37 -0400 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: 208.118.235.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:132833 Archived-At: --oC1+HKm2/end4ao3 Content-Type: multipart/mixed; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 24, 2017 at 02:03:16PM -0400, Glenn Morris wrote: > kwc3iywb@vfemail.net wrote: > > > `read-number'. I've included the patch I used to fix this problem. > > It looks to me like you attached an empty file? > Sorry. Here is the patch. --TB36FDmn/VVEgNH/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Make-goto-line-default-to-current-line-when-cursor-i.patch" Content-Transfer-Encoding: quoted-printable =46rom 0317935b8af1701de3feb8d0469e5aea17b4f38a Mon Sep 17 00:00:00 2001 =46rom: kwc3iywb Date: Thu, 25 May 2017 02:07:18 +0000 Subject: [PATCH] Make goto-line default to current line when cursor isn't o= ver a number * lisp/simple.el (goto-line): When used interactively, default to current line if the cursor isn't over a number, and remain defaulting to the number under the cursor and putting the current line in the history when the cursor is over a number. * lisp/subr.el (read-number): Add in its description that it can accept a list of default values. --- lisp/simple.el | 4 +++- lisp/subr.el | 28 +++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index ea3a495fbc..bd865288b1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1157,7 +1157,9 @@ rather than line counts." ""))) ;; 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))) + (if default + (list default (line-number-at-pos)) + (line-number-at-pos))) buffer)))) ;; Switch to the desired buffer, one way or another. (if buffer diff --git a/lisp/subr.el b/lisp/subr.el index 8d5d2a779c..d9cb62b2db 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2312,25 +2312,23 @@ by doing (clear-string STRING)." (defun read-number (prompt &optional default) "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. +The value of DEFAULT is inserted into PROMPT. DEFAULT can also be a +list of numbers, in which case all the numbers are available in the +history, and the first is the default. This function is used by the `interactive' code letter `n'." + (if (not (listp default)) + (setq default (list default))) (let ((n nil) - (default1 (if (consp default) (car default) default))) - (when default1 - (setq prompt - (if (string-match "\\(\\):[ \t]*\\'" prompt) - (replace-match (format " (default %s)" default1) t t prompt 1) - (replace-regexp-in-string "[ \t]*\\'" - (format " (default %s) " default1) - prompt t t)))) + (default1 (car default)) + (default-str (mapcar 'number-to-string default))) + (when default + (cl-assert (string-match "\\(\\)\\(:[[:blank:]]*\\)?\\'" prompt)) + (setq prompt (replace-match + (format " (default %s)" (car default-str)) + t t prompt 1))) (while (progn - (let ((str (read-from-minibuffer - prompt nil nil nil nil - (when default - (if (consp default) - (mapcar 'number-to-string (delq nil default)) - (number-to-string default)))))) + (let ((str (read-string prompt nil nil default-str))) (condition-case nil (setq n (cond ((zerop (length str)) default1) --=20 2.12.2 --TB36FDmn/VVEgNH/-- --oC1+HKm2/end4ao3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEwDlXGhappiWTpfDDYMrq6KZEr9sFAlkmm14ACgkQYMrq6KZE r9uwuQ/+O28+hPfdmqqZh8m2a3r/VZEJixuVsrqywd3PpA8wuy/M6lTINHXDdZnq vfvV9KRR08mbJqGf/2K25TTqqWPGaVUYFJfKSYXx+7nSFM+7vBwlH94ArHZLdtVA PkDWkn2du1ErwiPZ8TYapVDLy0Hx2YoNNKQ8oYyT7UmktwYX3v+3x37TTgPFL+R6 vxXNihBA9mjiisWg7TOLicYbZHUBHCDiDiQdznClEdKgzo+zr8x/3bUCY23jYPQX 6M2Mh3jsPFnrmSY3mOm6tOaL0f63f+A91UH2WgyHrhl4+OD4xO9EBgo6cixhNsc6 CAsmsjCgqgksi+fIpNPmmaznmHAqLcqXiYZ2X38C4apoEP2jC+pvBlIZd1mEgpFZ VQOHzPtQ80x5QuE7KdRziqbWryRgXllNh6sFsS61/JfsNcZrZtfoHoxy4S4NJC/7 TzIMUJjPD/XJtvWSlDnlLJcf4NJctytk/cKqQabxsVKuipKElbKif1R0D8V5RAkt aY/9bXxXQW/OjtdSxJA3ii1YFhDSdIuI7m1SdFe2DRp6O0NnU53gRRYN9KOq7Kpu IDbYXTpNJFzfPCYTX6bb8swHiSiCzF77VQf+rwEMnQVfbNVD/HzbXUmV4oYiEpvo 362+YA/SNIlDINtLBtsdTXukgBo3JY6MsQcb5wwWtx17atwcF+g= =dOfl -----END PGP SIGNATURE----- --oC1+HKm2/end4ao3--