summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)))