read-number function missing in emacs21?

Developers
David Coe
2002-01-04
2003-02-03
  • David Coe

    David Coe - 2002-01-04

    Hi Bob, or anyone else who knows:

    One of the chnages between 4.07 and 4.08
    replaced (in br-env.el)

      (string-to-int
        (read-string (concat lang-prompt ": ") ""))))

    with

      (read-number (concat lang-prompt ": ") t)))

    but under emacs21, at least, read-string is
    not defined.  Where should that come from?

    Reverting the above change seems to work.

    Thanks.

     
    • Christopher Smith

      I'm having this exact same problem, and I'm noticing that this is far from the only place where read-string exists.

       
    • Magnus Hulthén

      Magnus Hulthén - 2003-02-03

      The read-number function is defined in XEmacs and not in Emacs.

      If you place the following code (stolen from XEmacs) in your .emacs file you should be OK.

      (defun read-number (&optional prompt default)
        "Read a number from the minibuffer.
      Optional arguments: PROMPT DEFAULT.

      If DEFAULT is non-nil, it is written within parenthesis after the prompt.
      DEFAULT can be either a number, or of the type which `(interactive P)'
      generates."
        (let ((numdefault (cond ((null default) nil)
                    ((integerp default) default)
                    ((listp default) (car default))
                    (t nil)))
          (number nil)
          (numstr nil))

          (while (not number)
            (setq numstr (read-string
                  (concat (if prompt
                      prompt
                        "Enter a number: ")
                      (if numdefault
                      (format "(%d) " numdefault)))))
            (cond ((and (string= numstr "")
                numdefault)
               (setq number numdefault))
              ((string-match "\\`[0-9]+\\'" numstr)
               (setq number (string-to-int numstr)))
              (t (beep))))
          number))

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks