[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b843226 26/46: tiny.el: removed `tiny-replace-sexp-despera
From: |
Oleh Krehel |
Subject: |
[elpa] master b843226 26/46: tiny.el: removed `tiny-replace-sexp-desperately' |
Date: |
Sun, 22 Mar 2015 17:42:33 +0000 |
branch: master
commit b8432269f5cfa32acd24df747306acf8c3c7a5a0
Author: oleh <address@hidden>
Commit: oleh <address@hidden>
tiny.el: removed `tiny-replace-sexp-desperately'
---
tiny.el | 54 +++++++++++++++++++++++++-----------------------------
1 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/tiny.el b/tiny.el
index 071b842..a717e45 100644
--- a/tiny.el
+++ b/tiny.el
@@ -114,39 +114,35 @@ At the moment, only `tiny-mapconcat' is supported.
(defun tiny-setup-default ()
(global-set-key (kbd "C-;") 'tiny-expand))
-(defun tiny-replace-this-sexp ()
- "Intelligently replace current sexp."
- (interactive)
- (or
- (and (looking-back ")")
- (ignore-errors
- (let ((sexp (preceding-sexp)))
- (unless (eq (car sexp) 'lambda)
- (let ((value (eval sexp)))
- (kill-sexp -1)
- (insert (format "%s" value))
- t)))))
- (save-excursion (tiny-replace-sexp-desperately))))
+(defun tiny-replace-preceding-sexp ()
+ (unless (looking-back ")")
+ (error "bad location"))
+ (let ((sexp (preceding-sexp)))
+ (if (eq (car sexp) 'lambda)
+ (error "lambda evaluates to itself")
+ (let ((value (eval sexp)))
+ (kill-sexp -1)
+ (insert (format "%s" value))))))
-(defun tiny-replace-sexp-desperately ()
+(defun tiny-replace-this-sexp ()
"Eval and replace the current sexp.
-On error, go upwards and try again. Skip lambdas."
- (condition-case nil
- (tiny-up-list)
- (error "can't go up this list"))
- (let ((sexp (preceding-sexp)))
- (cond
- ;; since lambda evaluates to itself, skip it
- ((eq (car sexp) 'lambda)
- (tiny-replace-sexp-desperately))
- (t
- (condition-case nil
- (let ((value (eval sexp)))
- (kill-sexp -1)
- (insert (format "%s" value)))
- (error (tiny-replace-sexp-desperately)))))))
+On error go up list and try again."
+ (interactive)
+ (catch 'success
+ (while t
+ (ignore-errors
+ (tiny-replace-preceding-sexp)
+ (throw 'success t))
+ ;; if can't replace, go up list
+ (condition-case nil
+ (tiny-up-list)
+ (error
+ (message "reached the highest point, couldn't eval.")
+ (throw 'success nil))))))
(defun tiny-up-list ()
+ "An `up-list' that can exit from string.
+Must throw an error when can't go up further."
(interactive)
;; check if inside string
(let ((p (nth 8 (syntax-ppss))))
- [elpa] master 5df4f79 25/46: tiny.el: removed `tiny-beginning-of-string', (continued)
- [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
- [elpa] master f1d1a2e 22/46: tiny-test.el: switched to ERT., Oleh Krehel, 2015/03/22
- [elpa] master 4c87ade 29/46: tiny.el: fixed a bug in `tiny-mapconcat-parse'., Oleh Krehel, 2015/03/22
- [elpa] master a6e4144 30/46: tiny.el (tiny-extract-sexps): can handle e.g. %0.1f(...) style formatting., Oleh Krehel, 2015/03/22
- [elpa] master 80cd28f 28/46: tiny-test.el: added a test for `tiny-replace-this-sexp', Oleh Krehel, 2015/03/22
- [elpa] master 08ba593 24/46: tiny.el: fixed `tiny-tokenize', Oleh Krehel, 2015/03/22
- [elpa] master e6abbc6 31/46: tiny.el (tiny-date): renamed from t-date. In format string it's just "date", Oleh Krehel, 2015/03/22
- [elpa] master c59bc94 36/46: tiny.el (tiny-extract-sexps): add missing let binding, Oleh Krehel, 2015/03/22
- [elpa] master cf74dd1 34/46: tiny.el: fix docs, Oleh Krehel, 2015/03/22
- [elpa] master b843226 26/46: tiny.el: removed `tiny-replace-sexp-desperately',
Oleh Krehel <=
- [elpa] master 7893a02 35/46: tiny.el: add autoload to `tiny-expand', Oleh Krehel, 2015/03/22
- [elpa] master 075e4d0 33/46: Fix "m10|%0.2f", Oleh Krehel, 2015/03/22
- [elpa] master 4eef4e6 37/46: tiny.el: add a test case, Oleh Krehel, 2015/03/22
- [elpa] master 3a56283 38/46: tiny.el (tiny-mapconcat-parse): case-sensitive, Oleh Krehel, 2015/03/22
- [elpa] master dea7748 39/46: tiny.el (tiny-date): improve, Oleh Krehel, 2015/03/22
- [elpa] master ea7a184 42/46: tiny-test.el (tiny-mapconcat): Add test., Oleh Krehel, 2015/03/22
- [elpa] master d37646a 41/46: Add Travis CI testing and Coveralls.io reporting, Oleh Krehel, 2015/03/22
- [elpa] master fe0bade 43/46: tiny-test.el: Update, Oleh Krehel, 2015/03/22
- [elpa] master 5f25ce1 40/46: tiny.el: handle quotes in FMT part, Oleh Krehel, 2015/03/22
- [elpa] master fa90c2f 44/46: README.md: Add badges, Oleh Krehel, 2015/03/22