[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master cf74dd1 34/46: tiny.el: fix docs
From: |
Oleh Krehel |
Subject: |
[elpa] master cf74dd1 34/46: tiny.el: fix docs |
Date: |
Sun, 22 Mar 2015 17:42:36 +0000 |
branch: master
commit cf74dd1cc2a1e34819645ed77e331c062b5d0f73
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
tiny.el: fix docs
---
tiny.el | 38 ++++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/tiny.el b/tiny.el
index 7213f79..3023d56 100644
--- a/tiny.el
+++ b/tiny.el
@@ -68,23 +68,25 @@
;; m\n8|**** TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(date "Oct
7" (* x 7))> DEADLINE: <%(date "Oct 14" (* x 7))>
;;
;; As you might have guessed, the syntax is as follows:
-;; m[<range start:=0>][<separator:= >]<range end>[lisp expr]|[format expr]
+;; m[<range start:=0>][<separator:= >]<range end>[Lisp expr]|[format expr]
;;
-;; x is the default var in the elisp expression. It will take one by one
+;; x is the default var in the elisp expression. It will take one by one
;; the value of all numbers in the range.
;;
;; | means that elisp expr has ended and format expr has begun.
;; It can be omitted if the format expr starts with %.
;; The keys are the same as for format.
-;; In addition %(sexp) forms are allowed. The sexp can depend on x.
+;; In addition %(sexp) forms are allowed. The sexp can depend on x.
;;
;; Note that multiple % can be used in the format expression.
;; In that case:
-;; * if the lisp expression returns a list, the members of this list
+;; * if the Lisp expression returns a list, the members of this list
;; are used in the appropriate place.
;; * otherwise, it's just the result of the expression repeated as
;; many times as necessary.
-
+
+;;; Code:
+
(eval-when-compile
(require 'cl))
(require 'help-fns)
@@ -113,6 +115,7 @@ At the moment, only `tiny-mapconcat' is supported.
(tiny-replace-this-sexp))))
(defun tiny-setup-default ()
+ "Setup shortcuts."
(global-set-key (kbd "C-;") 'tiny-expand))
(defun tiny-replace-this-sexp ()
@@ -130,10 +133,10 @@ On error go up list and try again."
(while t
(ignore-errors
(unless (looking-back ")")
- (error "bad location"))
+ (error "Bad location"))
(let ((sexp (preceding-sexp)))
(if (eq (car sexp) 'lambda)
- (error "lambda evaluates to itself")
+ (error "Lambda evaluates to itself")
(let ((value (eval sexp)))
(kill-sexp -1)
(insert (format "%s" value))
@@ -157,9 +160,8 @@ Must throw an error when can't go up further."
(up-list))
(defun tiny-mapconcat ()
- "Take the output of `tiny-mapconcat-parse' and replace
-the null values with defaults and return the formatted
-expression."
+ "Format output of `tiny-mapconcat-parse'.
+Defaults are used in place of null values."
(let ((parsed (tiny-mapconcat-parse)))
(when parsed
(let* ((n1 (or (nth 0 parsed) "0"))
@@ -203,8 +205,8 @@ expression."
flags width precision character)))
(defun tiny-extract-sexps (str)
- "Returns (STR & FORMS), where each element of FORMS
-corresponds to a `format'-style % form in STR.
+ "Return (STR & FORMS).
+Each element of FORMS corresponds to a `format'-style % form in STR.
* %% forms are skipped
* %(sexp) is replaced with %s in STR, and put in FORMS
@@ -241,7 +243,7 @@ m[START][SEPARATOR]END[EXPR]|[FORMAT]
* START - integer (defaults to 0)
* SEPARATOR - string (defaults to \" \")
* END - integer (required)
-* EXPR - lisp expression: function body with argument x (defaults to x)
+* EXPR - Lisp expression: function body with argument x (defaults to x)
Parens are optional if it's unambiguous:
- `(* 2 (+ x 3))' <-> *2+x3
- `(exp x)' <-> expx
@@ -300,7 +302,7 @@ Return nil if nothing was matched, otherwise
(progn
(setq expr (tiny-tokenize (match-string-no-properties 1
str)))
(setq fmt (match-string-no-properties 2 str)))
- (error "couldn't match %s" str)))
+ (error "Couldn't match %s" str)))
t)
(when (equal expr "")
(setq expr nil))
@@ -308,6 +310,7 @@ Return nil if nothing was matched, otherwise
;; TODO: check for arity: this doesn't work: exptxy
(defun tiny-tokenize (str)
+ "Transform shorthand Lisp expression STR to proper Lisp."
(if (equal str "")
""
(ignore-errors
@@ -325,7 +328,7 @@ Return nil if nothing was matched, otherwise
((string= s " ")
(if allow-spc
t
- (error "unexpected \" \"")))
+ (error "Unexpected \" \"")))
;; special syntax to read chars
((string= s "?")
(setq s (format "%s" (read (substring str i (incf j)))))
@@ -335,7 +338,7 @@ Return nil if nothing was matched, otherwise
;; expect a close paren only if it's necessary
(if (>= n-paren 0)
(decf n-paren)
- (error "unexpected \")\""))
+ (error "Unexpected \")\""))
(when (string= (car out) " ")
(pop out))
(push ")" out)
@@ -380,6 +383,9 @@ Return nil if nothing was matched, otherwise
(make-string n-paren ?\)))))))
(defun tiny-date (s &optional shift)
+ "Return date representation of S.
+`org-mode' format is used.
+Optional SHIFT argument is the integer amount of days to shift."
(let ((time (apply 'encode-time
(org-read-date-analyze
s nil
- [elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize', (continued)
- [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
- [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 <=
- [elpa] master b843226 26/46: tiny.el: removed `tiny-replace-sexp-desperately', Oleh Krehel, 2015/03/22
- [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