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 02:29:55 +0000 Message-ID: <20170525022955.GA2859@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="yEPQxsgoJgBvi8ip" X-Trace: blaine.gmane.org 1495726362 27013 195.159.176.226 (25 May 2017 15:32:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 25 May 2017 15:32:42 +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:38 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 1dDukd-0006rg-7A for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 May 2017 17:32:35 +0200 Original-Received: from localhost ([::1]:60531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDuki-0002X6-PE for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 May 2017 11:32:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDukD-0001pl-1j for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuk8-0004SX-49 for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dDuk8-0004SQ-0g 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 1dDuk7-0002UI-Qr for bug-gnu-emacs@gnu.org; Thu, 25 May 2017 11:32:03 -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:03 +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.14957263009470 (code B ref 27056); Thu, 25 May 2017 15:32:03 +0000 Original-Received: (at 27056) by debbugs.gnu.org; 25 May 2017 15:31:40 +0000 Original-Received: from localhost ([127.0.0.1]:37806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDujk-0002Sc-Cp for submit@debbugs.gnu.org; Thu, 25 May 2017 11:31:40 -0400 Original-Received: from onethreetwo.vfemail.net ([199.16.11.132]:25715 helo=vfemail.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDshA-0007kL-FT for 27056@debbugs.gnu.org; Thu, 25 May 2017 09:20:53 -0400 Original-Received: (qmail 68857 invoked by uid 89); 25 May 2017 13:20:45 -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:20:43 -0000 Original-Received: (qmail 17634 invoked by uid 89); 25 May 2017 02:29:48 -0000 Original-Received: by simscan 1.4.0 ppid: 17631, pid: 17633, t: 0.0032s scanners:none Original-Received: from unknown (HELO smtp102-2.vfemail.net) (172.16.100.62) by FreeQueue with SMTP; 25 May 2017 02:29:48 -0000 Original-Received: (qmail 14409 invoked by uid 89); 25 May 2017 02:29:48 -0000 Original-Received: by simscan 1.4.0 ppid: 14370, pid: 14403, t: 1.0306s scanners:none Original-Received: from unknown (HELO vfemail.net) (a3djM2l5d2JAdmZlbWFpbC5uZXQ=@195.154.217.29) by 172.16.100.62 with ESMTPA; 25 May 2017 02:29:47 -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:132832 Archived-At: --yEPQxsgoJgBvi8ip Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline --dDRMvlgZJXvWKvBx 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's the patch. --dDRMvlgZJXvWKvBx 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 --dDRMvlgZJXvWKvBx-- --yEPQxsgoJgBvi8ip Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEwDlXGhappiWTpfDDYMrq6KZEr9sFAlkmQaEACgkQYMrq6KZE r9suqA/8CVOt8vbK9pNDQBPtQFr7anpXGPsnc2ygWmLVEBEXEOGIGTo7eUI2ttCR 0j1EQ3nJnvgLESUl3m3ZolndpYt2d/xh18ZLie1DhzjChUl3WQtpPYez//VqtJPp fiMlDbO16vzJBPMETCX8O5SvCLofqgFbhvK0IX4RDsy2ntC+dfI9CDSZI4dvyNfn toPLqyMx1iSGuFTWTewBVBP+O7TV7PkaM3bRc7phAXJvyMs1RgSPhy9TYkDrTiEk M5hmjLJrZE1JHXKnSOulRm8YaUqtmhW/DnHM9qwKiZhSIPRHKRtU20ZEF1aPH3CM bztb4Pff2HupjXHTTCUC8vgDEEZuhKjxwzbGxyiLs9EI8P5HPfSADdOwoVFQobif h5ylpKhj5nsDpsuplEcRzzx8KlUofM3tJKTYiqFl2XBNprpA2vqIUnu/73lChD42 2VR0dGyEhtS7w2Kw+OdhCic6Ykqijs6qghDAtmNe8WIhZSpE6KgTCsDdQS3YcqAs 1199f746zUh8iWSNRBE0vZbTqM8BDQ0u/Y7cYKnwY1iQHzevlnTPOtc4RnQ928f1 jsGDcdtCCPlyy2TPd0rhq5G1mIQoP/E6XmFHL4TFMG4aT0BpXYcWsxGqnAFDN2/M dxH3YxLiLMa+fNgVVKLTMF7qC2rOIiDdp8DMP8isE9E90SLYmd8= =800f -----END PGP SIGNATURE----- --yEPQxsgoJgBvi8ip--