utilities.scm: centralize and modernize addto!

(define-macro) is discouraged in most scheme forms. Change
to (define-syntax), and centralize common macro to utilities.scm
This commit is contained in:
Christopher Lam 2018-05-03 08:52:59 +08:00
parent 4a27285edd
commit dda6730c44
10 changed files with 12 additions and 26 deletions

View File

@ -97,9 +97,6 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -33,14 +33,12 @@
(use-modules (srfi srfi-1))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
(use-modules (gnucash utilities))
(gnc:module-load "gnucash/report/report-system" 0)
(use-modules (gnucash report standard-reports))
(use-modules (gnucash report business-reports))
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -51,14 +51,12 @@
(use-modules (srfi srfi-1))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
(use-modules (gnucash utilities))
(gnc:module-load "gnucash/report/report-system" 0)
(use-modules (gnucash report standard-reports))
(use-modules (gnucash report business-reports))
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -27,14 +27,12 @@
(use-modules (srfi srfi-1))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
(use-modules (gnucash utilities))
(gnc:module-load "gnucash/report/report-system" 0)
(use-modules (gnucash report standard-reports))
(use-modules (gnucash report business-reports))
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -46,9 +46,6 @@
(define desc-header (N_ "Description"))
(define amount-header (N_ "Amount"))
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -117,9 +117,6 @@
(else
(_ "Vendor"))))
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -22,6 +22,8 @@
;; Boston, MA 02110-1301, USA gnu@gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (gnucash utilities))
;; returns a list with n #f (empty cell) values
(define (gnc:html-make-empty-cell) #f)
(define (gnc:html-make-empty-cells n)
@ -854,7 +856,7 @@
(disp value))))
(if (not (or (equal? default-value value)
(char=? (string-ref section 0) #\_)))
(set! render-list (cons retval render-list)))))
(addto! render-list retval))))
(gnc:options-for-each add-option-if-changed options)
(if plaintext?
(string-append

View File

@ -29,9 +29,6 @@
(gnc:module-load "gnucash/report/report-system" 0)
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table

View File

@ -40,7 +40,7 @@
(define-module (gnucash report standard-reports transaction))
(use-modules (gnucash utilities))
(use-modules (gnucash utilities))
(use-modules (srfi srfi-1))
(use-modules (srfi srfi-11))
(use-modules (srfi srfi-13))
@ -50,9 +50,6 @@
(gnc:module-load "gnucash/report/report-system" 0)
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
;; Define the strings here to avoid typos and make changes easier.
(define reportname (N_ "Transaction Report"))

View File

@ -42,6 +42,7 @@
(export gnc:error)
(export gnc:msg)
(export gnc:debug)
(export addto!)
;; Do this stuff very early -- but other than that, don't add any
;; executable code until the end of the file if you can help it.
@ -71,6 +72,10 @@
(define (gnc:debug . items)
(gnc-scm-log-debug (strify items)))
(define-syntax addto!
(syntax-rules ()
((addto! alist element)
(set! alist (cons element alist)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gnc:substring-replace