summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2020-12-31 13:10:54 +0530
committerArun Isaac2020-12-31 15:07:20 +0530
commit70968110a28f40ca9f7bdb121b075c396040fda3 (patch)
treeb5c3d821db480ede8cb6b1a5cdfb83c4a41469f6
parent94861be30ad125f7af7357f0b4195706b7a4c5f0 (diff)
downloadksh-reports-70968110a28f40ca9f7bdb121b075c396040fda3.tar.gz
ksh-reports-70968110a28f40ca9f7bdb121b075c396040fda3.tar.lz
ksh-reports-70968110a28f40ca9f7bdb121b075c396040fda3.zip
Deprecate setfun.
* ksh-forms-improved.el (setfun): Delete function. (single-line-org-entry, multi-line-org-entry): Rewrite without setfun. (make-org-entry-function): Rename to ksh-forms-org-entry-function. Do not return a lambda function. Actually, do the work of that function.
-rw-r--r--ksh-forms-improved.el29
1 files changed, 13 insertions, 16 deletions
diff --git a/ksh-forms-improved.el b/ksh-forms-improved.el
index 3e9e333..cfa72b9 100644
--- a/ksh-forms-improved.el
+++ b/ksh-forms-improved.el
@@ -20,11 +20,6 @@
(defalias 'print-buffer 'print-report)
;; Utilities
-(defmacro setfun (function-name function)
- "Set functions like using define in scheme"
- `(defun ,function-name (&rest args)
- (apply ,function args)))
-
(defun set-values (record values)
"Set record RECORD to values in alist VALUES"
(mapc (lambda (field-value)
@@ -42,23 +37,25 @@
(setq forms-new-record-filter 'new-record-filter)
;; Entry creation functions for org export
-(defun make-org-entry-function (format-string)
- (lambda (label-field)
- (let* ((label (car label-field))
- (field-no (cdr label-field))
- (value (get-field field-no)))
- (if value
- (princ (format format-string label
- (replace-regexp-in-string "\n" "\n\n" value)))
- (user-error "Field \"%s\" should not be blank" label)))))
+(defun ksh-forms-org-entry-function (format-string label-field)
+ (pcase label-field
+ (`(,label . ,field-no)
+ (let ((value (get-field field-no)))
+ (if value
+ (princ (format format-string label
+ (replace-regexp-in-string "\n" "\n\n" value)))
+ (user-error "Field \"%s\" should not be blank" label))))))
(defun get-field (field)
"Parse form and return field FIELD from form"
(cond ((integerp field) (nth (1- field) (forms--parse-form)))
((stringp field) field)))
-(setfun single-line-org-entry (make-org-entry-function "*%s:* %s\n\n"))
-(setfun multi-line-org-entry (make-org-entry-function "\n* %s\n%s\n\n"))
+(defun single-line-org-entry (label-field)
+ (ksh-forms-org-entry-function "*%s:* %s\n\n" label-field))
+
+(defun multi-line-org-entry (label-field)
+ (ksh-forms-org-entry-function "\n* %s\n%s\n\n" label-field))
(defun text-if-non-blank (text)
(if (and text (not (string-blank-p text)))