unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
       [not found] <m1h7orj7uw.fsf.ref@yahoo.es>
@ 2020-12-12 16:40 ` Unknown
  2020-12-12 19:05   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Unknown @ 2020-12-12 16:40 UTC (permalink / raw)
  To: 45199

[-- Attachment #1: Type: text/plain, Size: 686 bytes --]


My use case (there may be many) comes from working with PDFs at a low
level.  If you open a PDF file in fundamental-mode, towards the end of
the file you'll see text that resembles the following:

xref
0 26
0000000000 65535 f 
0000006459 00000 n 

This is a table where the first column contains file offsets that point
to where the PDF objects are defined.  I wanted to place the point on
the "0000006459", do M-g c, and easily go to file offset 6459 to see the
definition of the PDF object number 1 ("1 0 obj").  goto-char is useful
here because PDF files are open as unibyte in Emacs.

If you also find the behavior generally useful, feel free to install it
for Emacs 28.

Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-goto-char-offer-the-number-at-point-as-default.patch --]
[-- Type: text/x-patch, Size: 3338 bytes --]

From 92e0a5c1b7482c4399f86eee9d4d41732457d081 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sat, 12 Dec 2020 17:10:05 +0100
Subject: [PATCH] Make goto-char offer the number at point as default

* src/editfns.c (Fgoto_char): Expand the interactive definition of
goto-char to offer the number at point as default.  Note that only
numbers that make sense as character positions will be offered.  Also
expand the docstring to document this new interactive behavior.
* doc/emacs/basic.texi (Moving Point): Expand the Emacs manual to
document this new behavior.
* etc/NEWS: And announce it.
---
 doc/emacs/basic.texi |  5 ++++-
 etc/NEWS             |  4 ++++
 src/editfns.c        | 20 ++++++++++++++++++--
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index cd1ffbebd7..77c8054746 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -310,7 +310,10 @@ Moving Point
 @kindex M-g c
 @findex goto-char
 Read a number @var{n} and move point to buffer position @var{n}.
-Position 1 is the beginning of the buffer.
+Position 1 is the beginning of the buffer.  If point is on or just
+after a number in the buffer, that is the default for @var{n}.  Just
+type @key{RET} in the minibuffer to use it.  You can also specify
+@var{n} by giving @kbd{M-g c} a numeric prefix argument.
 
 @item M-g M-g
 @itemx M-g g
diff --git a/etc/NEWS b/etc/NEWS
index 514209516d..13ff0bb171 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -257,6 +257,10 @@ When 'widen-automatically' is non-nil, 'goto-line' widens the narrowed
 buffer to be able to move point to the inaccessible portion.
 'goto-line-relative' is bound to 'C-x n g'.
 
++++
+** When called interactively, 'goto-char' now offers the number at
+   point as default.
+
 +++
 ** When 'suggest-key-bindings' is non-nil, the completion list of 'M-x'
 shows equivalent key bindings for all commands that have them.
diff --git a/src/editfns.c b/src/editfns.c
index 4104edd77f..cd6ed90ee5 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -188,11 +188,27 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0,
   return build_marker (current_buffer, PT, PT_BYTE);
 }
 
-DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ",
+DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1,
+         "(if (and current-prefix-arg (not (consp current-prefix-arg)))\
+              (list (prefix-numeric-value current-prefix-arg))\
+            (let* ((default\
+	             (save-excursion\
+	               (skip-chars-backward \"0-9\")\
+	               (if (looking-at-p \"[0-9]\")\
+	                   (string-to-number\
+	                   (buffer-substring-no-properties\
+	                   (point)\
+	                   (progn (skip-chars-forward \"0-9\")\
+		                  (point))))))))\
+              (list (read-number \"Goto char: \" default))))",
        doc: /* Set point to POSITION, a number or marker.
 Beginning of buffer is position (point-min), end is (point-max).
 
-The return value is POSITION.  */)
+The return value is POSITION.
+
+If called interactively, a numeric prefix argument specifies
+POSITION; without a numeric prefix argument, read POSITION from the
+minibuffer.  */)
   (register Lisp_Object position)
 {
   if (MARKERP (position))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-12 16:40 ` bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default Unknown
@ 2020-12-12 19:05   ` Lars Ingebrigtsen
  2020-12-13  1:23     ` Unknown
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-12 19:05 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 45199

Daniel Martín <mardani29@yahoo.es> writes:

> * src/editfns.c (Fgoto_char): Expand the interactive definition of
> goto-char to offer the number at point as default.

I think this makes sense, but:

> -DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ",
> +DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1,
> +         "(if (and current-prefix-arg (not (consp current-prefix-arg)))\
> +              (list (prefix-numeric-value current-prefix-arg))\
> +            (let* ((default\
> +	             (save-excursion\
> +	               (skip-chars-backward \"0-9\")\
> +	               (if (looking-at-p \"[0-9]\")\
> +	                   (string-to-number\
> +	                   (buffer-substring-no-properties\
> +	                   (point)\
> +	                   (progn (skip-chars-forward \"0-9\")\
> +		                  (point))))))))\
> +              (list (read-number \"Goto char: \" default))))",

I think it would be better to put this in a helper function in subr.el,
for instance.

And there's also `number-at-point', could perhaps be used here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-12 19:05   ` Lars Ingebrigtsen
@ 2020-12-13  1:23     ` Unknown
  2020-12-13 13:14       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Unknown @ 2020-12-13  1:23 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 45199

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> I think it would be better to put this in a helper function in subr.el,
> for instance.
>
> And there's also `number-at-point', could perhaps be used here?

Oh, I forgot about number-at-point.  It extracts numbers that don't make
sense here (like floating point or negative numbers), but we can easily
filter them with natnump.  I've attached a new patch; do you feel it's
still necessary to extract the logic in a helper?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-goto-char-offer-the-number-at-point-as-default.patch --]
[-- Type: text/x-patch, Size: 3065 bytes --]

From 499618f25e78cb1ab9803e44123b249b40b9d4eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sat, 12 Dec 2020 17:10:05 +0100
Subject: [PATCH] Make goto-char offer the number at point as default

* src/editfns.c (Fgoto_char): Expand the interactive definition of
goto-char to offer the number at point as default.  Note that only
numbers that make sense as character positions will be offered.  Also
expand the docstring to document this new interactive behavior.
* doc/emacs/basic.texi (Moving Point): Expand the Emacs manual to
document this new behavior.
* etc/NEWS: And announce it.
---
 doc/emacs/basic.texi |  5 ++++-
 etc/NEWS             |  4 ++++
 src/editfns.c        | 13 +++++++++++--
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index cd1ffbebd7..77c8054746 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -310,7 +310,10 @@ Moving Point
 @kindex M-g c
 @findex goto-char
 Read a number @var{n} and move point to buffer position @var{n}.
-Position 1 is the beginning of the buffer.
+Position 1 is the beginning of the buffer.  If point is on or just
+after a number in the buffer, that is the default for @var{n}.  Just
+type @key{RET} in the minibuffer to use it.  You can also specify
+@var{n} by giving @kbd{M-g c} a numeric prefix argument.
 
 @item M-g M-g
 @itemx M-g g
diff --git a/etc/NEWS b/etc/NEWS
index 514209516d..13ff0bb171 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -257,6 +257,10 @@ When 'widen-automatically' is non-nil, 'goto-line' widens the narrowed
 buffer to be able to move point to the inaccessible portion.
 'goto-line-relative' is bound to 'C-x n g'.
 
++++
+** When called interactively, 'goto-char' now offers the number at
+   point as default.
+
 +++
 ** When 'suggest-key-bindings' is non-nil, the completion list of 'M-x'
 shows equivalent key bindings for all commands that have them.
diff --git a/src/editfns.c b/src/editfns.c
index 4104edd77f..a6f9d30a7c 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -188,11 +188,20 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0,
   return build_marker (current_buffer, PT, PT_BYTE);
 }
 
-DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ",
+DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1,
+         "(if (and current-prefix-arg (not (consp current-prefix-arg)))\
+              (list (prefix-numeric-value current-prefix-arg))\
+            (let* ((number (number-at-point))\
+                   (default (and (natnump number) number)))\
+              (list (read-number \"Goto char: \" default))))",
        doc: /* Set point to POSITION, a number or marker.
 Beginning of buffer is position (point-min), end is (point-max).
 
-The return value is POSITION.  */)
+The return value is POSITION.
+
+If called interactively, a numeric prefix argument specifies
+POSITION; without a numeric prefix argument, read POSITION from the
+minibuffer.  */)
   (register Lisp_Object position)
 {
   if (MARKERP (position))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-13  1:23     ` Unknown
@ 2020-12-13 13:14       ` Lars Ingebrigtsen
  2020-12-13 18:01         ` Unknown
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-13 13:14 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 45199

Daniel Martín <mardani29@yahoo.es> writes:

> Oh, I forgot about number-at-point.  It extracts numbers that don't make
> sense here (like floating point or negative numbers), but we can easily
> filter them with natnump.  I've attached a new patch; do you feel it's
> still necessary to extract the logic in a helper?

Yeah, I'd still rather have a helper function -- putting several lines
of Lisp code in a string in C isn't optimal.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-13 13:14       ` Lars Ingebrigtsen
@ 2020-12-13 18:01         ` Unknown
  2020-12-14 10:16           ` Robert Pluim
                             ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Unknown @ 2020-12-13 18:01 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 45199

[-- Attachment #1: Type: text/plain, Size: 177 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> Yeah, I'd still rather have a helper function -- putting several lines
> of Lisp code in a string in C isn't optimal.

OK, done.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-goto-char-offer-the-number-at-point-as-default.patch --]
[-- Type: text/x-patch, Size: 3673 bytes --]

From 62dffb016c1b95923e654f516f52780aa2eb966d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sat, 12 Dec 2020 17:10:05 +0100
Subject: [PATCH] Make goto-char offer the number at point as default

* lisp/subr.el (read-natnum-interactive): New function to read natural
numbers for interactive functions.
* src/editfns.c (Fgoto_char): Call read-natnum-interactive from the
interactive definition of goto-char to offer the number at point as
default.  Also expand the docstring to document this new interactive
behavior.
* doc/emacs/basic.texi (Moving Point): Expand the Emacs manual to
document this new behavior.
* etc/NEWS: And announce it.
---
 doc/emacs/basic.texi | 5 ++++-
 etc/NEWS             | 4 ++++
 lisp/subr.el         | 9 +++++++++
 src/editfns.c        | 9 +++++++--
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index cd1ffbebd7..77c8054746 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -310,7 +310,10 @@ Moving Point
 @kindex M-g c
 @findex goto-char
 Read a number @var{n} and move point to buffer position @var{n}.
-Position 1 is the beginning of the buffer.
+Position 1 is the beginning of the buffer.  If point is on or just
+after a number in the buffer, that is the default for @var{n}.  Just
+type @key{RET} in the minibuffer to use it.  You can also specify
+@var{n} by giving @kbd{M-g c} a numeric prefix argument.
 
 @item M-g M-g
 @itemx M-g g
diff --git a/etc/NEWS b/etc/NEWS
index 514209516d..13ff0bb171 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -257,6 +257,10 @@ When 'widen-automatically' is non-nil, 'goto-line' widens the narrowed
 buffer to be able to move point to the inaccessible portion.
 'goto-line-relative' is bound to 'C-x n g'.
 
++++
+** When called interactively, 'goto-char' now offers the number at
+   point as default.
+
 +++
 ** When 'suggest-key-bindings' is non-nil, the completion list of 'M-x'
 shows equivalent key bindings for all commands that have them.
diff --git a/lisp/subr.el b/lisp/subr.el
index ed235ee1f7..5e4f7dec7d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2820,6 +2820,15 @@ read-char-from-minibuffer
     (message "%s%s" prompt (char-to-string char))
     char))
 
+(defun read-natnum-interactive (prompt)
+  "Get a natural number argument, optionally prompting with PROMPT.
+If there is a natural number at point, use it as default."
+  (if (and current-prefix-arg (not (consp current-prefix-arg)))
+      (list (prefix-numeric-value current-prefix-arg))
+    (let* ((number (number-at-point))
+           (default (and (natnump number) number)))
+      (list (read-number prompt default)))))
+
 \f
 ;; Behind display-popup-menus-p test.
 (declare-function x-popup-dialog "menu.c" (position contents &optional header))
diff --git a/src/editfns.c b/src/editfns.c
index 4104edd77f..4723660b43 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -188,11 +188,16 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0,
   return build_marker (current_buffer, PT, PT_BYTE);
 }
 
-DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ",
+DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1,
+         "(read-natnum-interactive \"Go to char: \")",
        doc: /* Set point to POSITION, a number or marker.
 Beginning of buffer is position (point-min), end is (point-max).
 
-The return value is POSITION.  */)
+The return value is POSITION.
+
+If called interactively, a numeric prefix argument specifies
+POSITION; without a numeric prefix argument, read POSITION from the
+minibuffer.  */)
   (register Lisp_Object position)
 {
   if (MARKERP (position))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-13 18:01         ` Unknown
@ 2020-12-14 10:16           ` Robert Pluim
  2020-12-14 16:17           ` Lars Ingebrigtsen
  2020-12-14 19:29           ` Juri Linkov
  2 siblings, 0 replies; 12+ messages in thread
From: Robert Pluim @ 2020-12-14 10:16 UTC (permalink / raw)
  To: Daniel Martín; +Cc: Lars Ingebrigtsen, 45199

Daniel Martín <mardani29@yahoo.es> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>>
>> Yeah, I'd still rather have a helper function -- putting several lines
>> of Lisp code in a string in C isn't optimal.
>
> OK, done.
>

The docstring for the function needs to mention the new behaviour as
well.

Robert





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-13 18:01         ` Unknown
  2020-12-14 10:16           ` Robert Pluim
@ 2020-12-14 16:17           ` Lars Ingebrigtsen
  2020-12-14 19:29           ` Juri Linkov
  2 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-14 16:17 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 45199

Daniel Martín <mardani29@yahoo.es> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>>
>> Yeah, I'd still rather have a helper function -- putting several lines
>> of Lisp code in a string in C isn't optimal.
>
> OK, done.

Great; I've now applied this to Emacs 28 (but made the helper function
an internal function, and altered the doc string like Robert suggested).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-13 18:01         ` Unknown
  2020-12-14 10:16           ` Robert Pluim
  2020-12-14 16:17           ` Lars Ingebrigtsen
@ 2020-12-14 19:29           ` Juri Linkov
  2020-12-15  6:30             ` Lars Ingebrigtsen
  2 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2020-12-14 19:29 UTC (permalink / raw)
  To: 45199; +Cc: larsi, mardani29

>> Yeah, I'd still rather have a helper function -- putting several lines
>> of Lisp code in a string in C isn't optimal.
>
> OK, done.

Shouldn't goto-line use the same function to read a number?
The first version of your patch used the code similar to
goto-line-read-args, so wouldn't it make sense to use the
new function in goto-line-read-args as well?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-14 19:29           ` Juri Linkov
@ 2020-12-15  6:30             ` Lars Ingebrigtsen
  2020-12-20  8:55               ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-15  6:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 45199, mardani29

Juri Linkov <juri@linkov.net> writes:

>>> Yeah, I'd still rather have a helper function -- putting several lines
>>> of Lisp code in a string in C isn't optimal.
>>
>> OK, done.
>
> Shouldn't goto-line use the same function to read a number?
> The first version of your patch used the code similar to
> goto-line-read-args, so wouldn't it make sense to use the
> new function in goto-line-read-args as well?

Reusing it directly would be awkward, but goto-line-read-args could
indeed use number-at-point.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-15  6:30             ` Lars Ingebrigtsen
@ 2020-12-20  8:55               ` Juri Linkov
  2020-12-20 17:55                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2020-12-20  8:55 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 45199

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

>> Shouldn't goto-line use the same function to read a number?
>> The first version of your patch used the code similar to
>> goto-line-read-args, so wouldn't it make sense to use the
>> new function in goto-line-read-args as well?
>
> Reusing it directly would be awkward, but goto-line-read-args could
> indeed use number-at-point.

Here's a patch where it uses number-at-point:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: goto-line-read-args-number-at-point.patch --]
[-- Type: text/x-diff, Size: 909 bytes --]

diff --git a/lisp/simple.el b/lisp/simple.el
index f79543058b..e17f2b0fc2 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1276,15 +1276,8 @@ goto-line-read-args
   (if (and current-prefix-arg (not (consp current-prefix-arg)))
       (list (prefix-numeric-value current-prefix-arg))
     ;; Look for a default, a number in the buffer at point.
-    (let* ((default
-             (save-excursion
-               (skip-chars-backward "0-9")
-               (if (looking-at "[0-9]")
-                   (string-to-number
-                    (buffer-substring-no-properties
-                     (point)
-                     (progn (skip-chars-forward "0-9")
-                            (point)))))))
+    (let* ((number (number-at-point))
+           (default (and (natnump number) number))
            ;; Decide if we're switching buffers.
            (buffer
             (if (consp current-prefix-arg)

[-- Attachment #3: Type: text/plain, Size: 245 bytes --]


Also this patch adds the same useful property from goto-line to goto-char.
When there is no number at point, then M-n gets the current char position
number for editing, so the user can decrease or increase it
relative to the current position:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: goto-char-default-point.patch --]
[-- Type: text/x-diff, Size: 471 bytes --]

diff --git a/lisp/subr.el b/lisp/subr.el
index 275e224b55..c7b7ac6444 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2828,7 +2828,7 @@ goto-char--read-natnum-interactive
       (list (prefix-numeric-value current-prefix-arg))
     (let* ((number (number-at-point))
            (default (and (natnump number) number)))
-      (list (read-number prompt default)))))
+      (list (read-number prompt (list default (point)))))))
 
 \f
 ;; Behind display-popup-menus-p test.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-20  8:55               ` Juri Linkov
@ 2020-12-20 17:55                 ` Lars Ingebrigtsen
  2020-12-20 20:06                   ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-20 17:55 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 45199

Juri Linkov <juri@linkov.net> writes:

> Here's a patch where it uses number-at-point:

Looks good to me.

> Also this patch adds the same useful property from goto-line to goto-char.
> When there is no number at point, then M-n gets the current char position
> number for editing, so the user can decrease or increase it
> relative to the current position:

Yeah, that sounds useful.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default
  2020-12-20 17:55                 ` Lars Ingebrigtsen
@ 2020-12-20 20:06                   ` Juri Linkov
  0 siblings, 0 replies; 12+ messages in thread
From: Juri Linkov @ 2020-12-20 20:06 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 45199

>> Here's a patch where it uses number-at-point:
>
> Looks good to me.
>
>> Also this patch adds the same useful property from goto-line to goto-char.
>> When there is no number at point, then M-n gets the current char position
>> number for editing, so the user can decrease or increase it
>> relative to the current position:
>
> Yeah, that sounds useful.

Now pushed to master.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-20 20:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m1h7orj7uw.fsf.ref@yahoo.es>
2020-12-12 16:40 ` bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default Unknown
2020-12-12 19:05   ` Lars Ingebrigtsen
2020-12-13  1:23     ` Unknown
2020-12-13 13:14       ` Lars Ingebrigtsen
2020-12-13 18:01         ` Unknown
2020-12-14 10:16           ` Robert Pluim
2020-12-14 16:17           ` Lars Ingebrigtsen
2020-12-14 19:29           ` Juri Linkov
2020-12-15  6:30             ` Lars Ingebrigtsen
2020-12-20  8:55               ` Juri Linkov
2020-12-20 17:55                 ` Lars Ingebrigtsen
2020-12-20 20:06                   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).