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"))) ".dir-locals.el")))
(add-to-list 'geiser-guile-load-path top)))) (add-to-list 'geiser-guile-load-path top))))
(eval . (put 'if-guile-version-below 'scheme-indent-function 1)) (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-case> 'scheme-indent-function 1))
(eval . (put '<sh-defun> 'scheme-indent-function 1)) (eval . (put '<sh-defun> 'scheme-indent-function 1))
(eval . (put '<sh-exec-let> 'scheme-indent-function 1)) (eval . (put '<sh-exec-let> 'scheme-indent-function 1))

View File

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