(t
(setq result (eshell-concat-1 quoted result i))))))))
-(defsubst eshell--numberlike-p (object)
- (or (numberp object)
- (and (stringp object) (get-text-property 0 'number object))))
-
(defun eshell-concat-1 (quoted first second)
"Concatenate FIRST and SECOND.
If QUOTED is nil and either FIRST or SECOND are numberlike, try to mark
the result as a number as well."
- (let ((result (concat (eshell-stringify first) (eshell-stringify second))))
+ (let ((result (concat (eshell-stringify first quoted)
+ (eshell-stringify second quoted))))
(remove-text-properties 0 (length result) '(number) result)
(when (and (not quoted)
- (or (eshell--numberlike-p first)
- (eshell--numberlike-p second)))
+ (or (numberp first) (eshell--numeric-string-p first)
+ (numberp second) (eshell--numeric-string-p second)))
(eshell-mark-numeric-string result))
result))
(eshell--do-mark-numeric-string string))
string)
+(defsubst eshell--numeric-string-p (string)
+ "Return non-nil if STRING has been marked as numeric."
+ (and (stringp string)
+ (length> string 0)
+ (not (text-property-not-all 0 (length string) 'number t string))))
+
(defun eshell-convert-to-number (string)
"Try to convert STRING to a number.
If STRING doesn't look like a number (or
(cond
((not (stringp string))
(if to-string
- (eshell-stringify string)
+ (eshell-stringify string t)
string))
(to-string (string-trim-right string "\n+"))
(t (let ((len (length string)))
(define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1")
-(defun eshell-stringify (object)
+(defun eshell-stringify (object &optional quoted)
"Convert OBJECT into a string value."
(cond
((stringp object) object)
((numberp object)
- (number-to-string object))
+ (if quoted
+ (number-to-string object)
+ (propertize (number-to-string object) 'number t)))
((and (eq object t)
(not eshell-stringify-t))
nil)
(t
(string-trim-right (pp-to-string object)))))
-(defsubst eshell-stringify-list (args)
+(defsubst eshell-stringify-list (args &optional quoted)
"Convert each element of ARGS into a string value."
- (mapcar #'eshell-stringify args))
+ (mapcar (lambda (i) (eshell-stringify i quoted)) args))
(defsubst eshell-list-to-string (list)
"Convert LIST into a single string separated by spaces."
- (mapconcat #'eshell-stringify list " "))
+ (mapconcat (lambda (i) (eshell-stringify i t)) list " "))
(defsubst eshell-flatten-and-stringify (&rest args)
"Flatten and stringify all of the ARGS into a single string."
(if splice
(setq value `(eshell-list-to-string ,value)
splice nil)
- (setq value `(eshell-stringify ,value))))
+ (setq value `(eshell-stringify ,value t))))
(setq value `(eshell-escape-arg ,value))
(when splice
(setq value `(eshell-splice-args ,value)))