]> code.delx.au - gnu-emacs-elpa/commitdiff
tiny.el: removed `tiny-beginning-of-string'
authoroleh <wave@mail.ua>
Mon, 7 Oct 2013 18:28:21 +0000 (20:28 +0200)
committeroleh <wave@mail.ua>
Mon, 7 Oct 2013 18:28:21 +0000 (20:28 +0200)
tiny.el

diff --git a/tiny.el b/tiny.el
index b2dd391474c4c1c3499cb1e1b03a055cdecc8ec9..071b842a626ce97b18231689748b1b738d7e22eb 100644 (file)
--- a/tiny.el
+++ b/tiny.el
@@ -87,6 +87,7 @@
 (eval-when-compile
   (require 'cl))
 (require 'help-fns)
+(require 'org)
 
 (defvar tiny-beg nil
   "Last matched snippet start position.")
@@ -119,24 +120,17 @@ At the moment, only `tiny-mapconcat' is supported.
   (or
    (and (looking-back ")")
         (ignore-errors
-          (tiny-replace-last-sexp)))
+          (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-last-sexp ()
-  (interactive)
-  (let ((sexp (preceding-sexp)))
-    (unless (eq (car sexp) 'lambda)
-      (let ((value (eval sexp)))
-        (kill-sexp -1)
-        (insert (format "%s" value))
-        t))))
-
 (defun tiny-replace-sexp-desperately ()
-  "Try to eval the current sexp.
-Replace it if there's no error.
-Go upwards until it's possible to eval.
-Skip lambdas."
-  (interactive)
+  "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"))
@@ -152,16 +146,13 @@ Skip lambdas."
              (insert (format "%s" value)))
          (error (tiny-replace-sexp-desperately)))))))
 
-(defun tiny-beginning-of-string ()
-  "If inside string, move point to its beginning"
+(defun tiny-up-list ()
   (interactive)
+  ;; check if inside string
   (let ((p (nth 8 (syntax-ppss))))
     (when (eq (char-after p) ?\")
-      (goto-char p))))
-
-(defun tiny-up-list ()
-  (interactive)
-  (tiny-beginning-of-string)
+      ;; go to beginning for string
+      (goto-char p)))
   (up-list))
 
 (defun tiny-mapconcat ()
@@ -369,10 +360,10 @@ Return nil if nothing was matched, otherwise
          (make-string n-paren ?\)))))))
 
 (defun t-date (s &optional shift)
-  (let ((time (->> (current-time)
-                decode-time
-                (org-read-date-analyze s nil)
-                (apply 'encode-time))))
+  (let ((time (apply 'encode-time
+                     (org-read-date-analyze
+                      s nil
+                      (decode-time (current-time))))))
     (when shift
       (setq time (time-add time (days-to-time shift))))
     (format-time-string "%Y-%m-%d %a" time)))