From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 45199@debbugs.gnu.org
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 [thread overview]
Message-ID: <87o8iorh4q.fsf@mail.linkov.net> (raw)
In-Reply-To: <87eejr1sym.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 15 Dec 2020 07:30:57 +0100")
[-- 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.
next prev parent reply other threads:[~2020-12-20 8:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
2020-12-20 17:55 ` Lars Ingebrigtsen
2020-12-20 20:06 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o8iorh4q.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=45199@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.