compat: Support Mes.

* gash/compat.scm (if-guile-version-below) [mes]: Do nothing.
(when-mes): New syntax.
* .dir-locals.el: Tell Emacs how to indent it.
This commit is contained in:
Timothy Sample 2022-04-28 09:58:59 -06:00
parent a3123ab02a
commit ead347128a
2 changed files with 35 additions and 25 deletions

View File

@ -7,6 +7,7 @@
".dir-locals.el")))
(add-to-list 'geiser-guile-load-path top))))
(eval . (put 'if-guile-version-below 'scheme-indent-function 1))
(eval . (put 'when-mes 'scheme-indent-function 0))
(eval . (put '<sh-case> 'scheme-indent-function 1))
(eval . (put '<sh-defun> 'scheme-indent-function 1))
(eval . (put '<sh-exec-let> 'scheme-indent-function 1))

View File

@ -1,5 +1,5 @@
;;; Gash -- Guile As SHell
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2019, 2022 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Gash.
;;;
@ -18,7 +18,8 @@
(define-module (gash compat)
#:use-module (ice-9 match)
#:export (if-guile-version-below))
#:export (if-guile-version-below
when-mes))
;;; Commentary:
;;;
@ -27,30 +28,38 @@
;;;
;;; Code:
(define-syntax if-guile-version-below
(lambda (x)
(define (guile-version<? major minor micro)
(let ((g-major (string->number (major-version)))
(g-minor (string->number (minor-version)))
(g-micro (string->number (micro-version))))
(or (< g-major major)
(and (= g-major major)
(< g-minor minor))
(and (= g-major major)
(= g-minor minor)
(< g-micro micro)))))
(cond-expand
(guile
(define-syntax if-guile-version-below
(lambda (x)
(define (guile-version<? major minor micro)
(let ((g-major (string->number (major-version)))
(g-minor (string->number (minor-version)))
(g-micro (string->number (micro-version))))
(or (< g-major major)
(and (= g-major major)
(< g-minor minor))
(and (= g-major major)
(= g-minor minor)
(< g-micro micro)))))
(syntax-case x ()
((_ (maj min mic) consequent alternate)
(if (guile-version<? (syntax->datum #'maj)
(syntax->datum #'min)
(syntax->datum #'mic))
#'consequent
#'alternate))
((_ (maj min mic) consequent)
#'(if-guile-version-below (maj min mic)
consequent
(if #f #t))))))
(syntax-case x ()
((_ (maj min mic) consequent alternate)
(if (guile-version<? (syntax->datum #'maj)
(syntax->datum #'min)
(syntax->datum #'mic))
#'consequent
#'alternate))
((_ (maj min mic) consequent)
#'(if-guile-version-below (maj min mic)
consequent
(if #f #t))))))
(define-syntax-rule (when-mes . forms) (if #f #t)))
(mes
(define-macro (if-guile-version-below . forms)
'(begin))
(define-macro (when-mes . forms)
`(begin ,@forms))))
(if-guile-version-below (2 0 10)
(begin