emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1a7033f: * lisp/simple.el (goto-line-read-args): Use number-at-po


From: Juri Linkov
Subject: master 1a7033f: * lisp/simple.el (goto-line-read-args): Use number-at-point (bug#45199)
Date: Sun, 20 Dec 2020 15:06:08 -0500 (EST)

branch: master
commit 1a7033f1f3de4ad8c1bfd68b54e6c9d8444a3bcc
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/simple.el (goto-line-read-args): Use number-at-point (bug#45199)
    
    * lisp/subr.el (goto-char--read-natnum-interactive): Add the value of
    point to the end of default values, and move function slightly higher.
---
 lisp/simple.el | 12 ++----------
 lisp/subr.el   | 18 +++++++++---------
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index b1c949d..2b13a0d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1264,7 +1264,6 @@ that uses or sets the mark."
   ;; minibuffer, this is at the end of the prompt.
   (goto-char (minibuffer-prompt-end)))
 
-
 ;; Counting lines, one way or another.
 
 (defvar goto-line-history nil
@@ -1276,15 +1275,8 @@ that uses or sets the mark."
   (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)
diff --git a/lisp/subr.el b/lisp/subr.el
index cb64b3f..9527f71 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2719,6 +2719,15 @@ floating point support."
            (push (cons t read) unread-command-events)
            nil))))))
 
+(defun goto-char--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 (list default (point)))))))
+
 
 (defvar read-char-history nil
   "The default history for the `read-char-from-minibuffer' function.")
@@ -2820,15 +2829,6 @@ There is no need to explicitly add `help-char' to CHARS;
     (message "%s%s" prompt (char-to-string char))
     char))
 
-(defun goto-char--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)))))
-
 
 ;; Behind display-popup-menus-p test.
 (declare-function x-popup-dialog "menu.c" (position contents &optional header))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]