[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 78241c4 15/46: tiny.el: fixed a bug for expansion of m5%x.
From: |
Oleh Krehel |
Subject: |
[elpa] master 78241c4 15/46: tiny.el: fixed a bug for expansion of m5%x. |
Date: |
Sun, 22 Mar 2015 17:42:29 +0000 |
branch: master
commit 78241c4edb2de6a2193f30dfedb846c3d3464a63
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
tiny.el: fixed a bug for expansion of m5%x.
---
tiny.el | 136 ++++++++++++++++++++++++++++++++-------------------------------
1 files changed, 69 insertions(+), 67 deletions(-)
diff --git a/tiny.el b/tiny.el
index 43a2df6..35444a7 100644
--- a/tiny.el
+++ b/tiny.el
@@ -304,77 +304,79 @@ Return nil if nothing was matched, otherwise
;; TODO: check for arity: this doesn't work: exptxy
(defun tiny-tokenize (str)
- (ignore-errors
- (let ((i 0)
- (j 1)
- (len (length str))
- sym
- s
- out
- (n-paren 0)
- (expect-fun t))
- (while (< i len)
- (setq s (substring str i j))
- (when (cond
- ((string= s "x")
- (push s out)
- (push " " out))
- ((string= s "y")
- (push s out)
- (push " " out))
- ((string= s " ")
- (error "unexpected \" \""))
- ((string= s "?")
- (setq s (format "%s" (read (substring str i (incf j)))))
- (push s out)
- (push " " out))
- ((string= s ")")
- ;; expect a close paren only if it's necessary
- (if (>= n-paren 0)
- (decf n-paren)
- (error "unexpected \")\""))
- (when (string= (car out) " ")
- (pop out))
- (push ") " out))
- ((string= s "(")
- ;; open paren is used sometimes
- ;; when there are numbers in the expression
- (incf n-paren)
- (push "(" out))
- ((progn (setq sym (intern-soft s))
- (cond
- ;; general functionp
- ((not (eq t (help-function-arglist sym)))
- (setq expect-fun)
- ;; (when (zerop n-paren)
- ;; (push "(" out))
- (push "(" out)
- (incf n-paren))
- ((and sym (boundp sym) (not expect-fun))
- t)))
- (push s out)
- (push " " out))
- ((numberp (read s))
- (let* ((num (string-to-number (substring str i)))
- (num-s (format "%s" num)))
- (push num-s out)
- (push " " out)
- (setq j (+ i (length num-s)))))
- (t
- (incf j)
- nil))
- (setq i j)
- (setq j (1+ i))))
- ;; last space
- (when (string= (car out) " ")
- (pop out))
- (concat
- (apply #'concat (nreverse out))
- (make-string n-paren ?\))))))
+ (unless (equal str "")
+ (ignore-errors
+ (let ((i 0)
+ (j 1)
+ (len (length str))
+ sym
+ s
+ out
+ (n-paren 0)
+ (expect-fun t))
+ (while (< i len)
+ (setq s (substring str i j))
+ (when (cond
+ ((string= s "x")
+ (push s out)
+ (push " " out))
+ ((string= s "y")
+ (push s out)
+ (push " " out))
+ ((string= s " ")
+ (error "unexpected \" \""))
+ ((string= s "?")
+ (setq s (format "%s" (read (substring str i (incf j)))))
+ (push s out)
+ (push " " out))
+ ((string= s ")")
+ ;; expect a close paren only if it's necessary
+ (if (>= n-paren 0)
+ (decf n-paren)
+ (error "unexpected \")\""))
+ (when (string= (car out) " ")
+ (pop out))
+ (push ") " out))
+ ((string= s "(")
+ ;; open paren is used sometimes
+ ;; when there are numbers in the expression
+ (incf n-paren)
+ (push "(" out))
+ ((progn (setq sym (intern-soft s))
+ (cond
+ ;; general functionp
+ ((not (eq t (help-function-arglist sym)))
+ (setq expect-fun)
+ ;; (when (zerop n-paren)
+ ;; (push "(" out))
+ (push "(" out)
+ (incf n-paren))
+ ((and sym (boundp sym) (not expect-fun))
+ t)))
+ (push s out)
+ (push " " out))
+ ((numberp (read s))
+ (let* ((num (string-to-number (substring str i)))
+ (num-s (format "%s" num)))
+ (push num-s out)
+ (push " " out)
+ (setq j (+ i (length num-s)))))
+ (t
+ (incf j)
+ nil))
+ (setq i j)
+ (setq j (1+ i))))
+ ;; last space
+ (when (string= (car out) " ")
+ (pop out))
+ (concat
+ (apply #'concat (nreverse out))
+ (make-string n-paren ?\)))))))
(defun tiny-mapconcat-parse-test ()
(let* ((tests
'(("m10" (nil nil "10" nil nil))
+ ("m5%x" (nil nil "5" nil "%x"))
("m5 10" ("5" " " "10" nil nil))
("m5,10" ("5" "," "10" nil nil))
("m5 10*xx" ("5" " " "10" "(* x x)" nil))
- [elpa] master 1baa50b 05/46: tiny.el: fixed some typos., (continued)
- [elpa] master 1baa50b 05/46: tiny.el: fixed some typos., Oleh Krehel, 2015/03/22
- [elpa] master 466e02c 06/46: tiny.el: added a use case for multiple TODO items in org-mode., Oleh Krehel, 2015/03/22
- [elpa] master cc8d243 02/46: tiny.el: Added new test snippets., Oleh Krehel, 2015/03/22
- [elpa] master 7cc4e00 07/46: tiny.el: x can be reused in format string., Oleh Krehel, 2015/03/22
- [elpa] master d053709 08/46: tiny.el: expr now can return a list., Oleh Krehel, 2015/03/22
- [elpa] master 03aef85 09/46: tiny.el: fixed a bug introduced by previous commit., Oleh Krehel, 2015/03/22
- [elpa] master 835c63e 12/46: tiny.el: fixed a small whitespace issue in `tiny-tokenize'., Oleh Krehel, 2015/03/22
- [elpa] master 36c8dc0 10/46: tiny.el: added missing functions., Oleh Krehel, 2015/03/22
- [elpa] master 067e820 11/46: tiny.el: improved `tiny-mapconcat` and `tiny-mapconcat-parse'., Oleh Krehel, 2015/03/22
- [elpa] master cad8e50 13/46: tiny.el: added the option to include %(sexps) into the format string., Oleh Krehel, 2015/03/22
- [elpa] master 78241c4 15/46: tiny.el: fixed a bug for expansion of m5%x.,
Oleh Krehel <=
- [elpa] master 29b5b76 16/46: Added README.md, Oleh Krehel, 2015/03/22
- [elpa] master b9c35e1 17/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 97b9fdf 14/46: tiny.el: fixed up the previous change., Oleh Krehel, 2015/03/22
- [elpa] master 80e64b8 18/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 2bd9abb 21/46: tiny.el: moved tests to tiny-test.el., Oleh Krehel, 2015/03/22
- [elpa] master b99315d 20/46: tiny.el: updated the doc., Oleh Krehel, 2015/03/22
- [elpa] master 11722a1 19/46: tiny.el: fixed typos., Oleh Krehel, 2015/03/22
- [elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize', Oleh Krehel, 2015/03/22
- [elpa] master 5df4f79 25/46: tiny.el: removed `tiny-beginning-of-string', Oleh Krehel, 2015/03/22
- [elpa] master 8a3cab0 27/46: tiny.el: removed `tiny-replace-preceding-sexp', Oleh Krehel, 2015/03/22