[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as
From: |
Juri Linkov |
Subject: |
bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default |
Date: |
Sun, 20 Dec 2020 10:55:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> 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:
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)
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:
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.
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Daniel Martín, 2020/12/12
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Lars Ingebrigtsen, 2020/12/12
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Daniel Martín, 2020/12/12
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Lars Ingebrigtsen, 2020/12/13
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Daniel Martín, 2020/12/13
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Robert Pluim, 2020/12/14
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Lars Ingebrigtsen, 2020/12/14
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Juri Linkov, 2020/12/14
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Lars Ingebrigtsen, 2020/12/15
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default,
Juri Linkov <=
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Lars Ingebrigtsen, 2020/12/20
- bug#45199: 28.0.50; [PATCH] Make goto-char offer the number at point as default, Juri Linkov, 2020/12/20