GNU bug report logs -
#45199
28.0.50; [PATCH] Make goto-char offer the number at point as default
Previous Next
Reported by: Daniel MartÃn <mardani29 <at> yahoo.es>
Date: Sat, 12 Dec 2020 18:21:02 UTC
Severity: normal
Tags: confirmed, fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
>> 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:
[goto-line-read-args-number-at-point.patch (text/x-diff, inline)]
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)
[Message part 3 (text/plain, inline)]
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:
[goto-char-default-point.patch (text/x-diff, inline)]
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)))))))
;; Behind display-popup-menus-p test.
This bug report was last modified 4 years and 211 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.