gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

elisp.m4


From: Thien-Thi Nguyen
Subject: elisp.m4
Date: Sun, 06 Nov 2016 03:58:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Greetings earthlings,

Sneaky old EDB must reform, so sez Emacs 25:

 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=840748

Please find attached elisp.m4 (serial 1) that we will try to use
for a smooth(er) transition.  I'm posting it separately from EDB
after having briefly searched gnulib and autoconf-archives for
something similar (and failed).  What am i missing?  Pointers to
related work welcome!

dnl elisp.m4 --- discover Emacs reality w/ Emacs Lisp
dnl serial 1

dnl Copyright (C) 2016 Thien-Thi Nguyen
dnl
dnl This file is part of EDB.
dnl
dnl EDB is free software; you can redistribute it and/or modify it under
dnl the terms of the GNU General Public License as published by the Free
dnl Software Foundation; either version 3, or (at your option) any later
dnl version.
dnl
dnl EDB is distributed in the hope that it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dnl FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dnl for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with EDB.  If not, see <http://www.gnu.org/licenses/>.

dnl Commentary:

dnl This is a simple library to check the Emacs reality by way
dnl of Emacs Lisp forms evaluated under ‘$EMACS --batch -Q’.
dnl "Exported" (user-facing) macros are named w/ prefix "ELISP_":
dnl   ELISP_CONFIG_FILE
dnl   ELISP_CHECK
dnl   ELISP_CHECK_FBOUNDP
dnl   ELISP_CHECK_BOUNDP
dnl Internal macros have prefix "_ELISP_" (for actions)
dnl or "__ELISP_" (for state, like filenames, and so on).
dnl
dnl TODO:
dnl - Add error checking (see FIXME below).
dnl - Validate m4 mumblings -- is this the right crazy?!
dnl - Add ELISP_CONFIG_VAR as alternate to ELISP_CONFIG_FILE.
dnl - Add customization of $EMACS invocation.
dnl - Contribute to Autoconf Archive.

dnl Code:


AC_DEFUN([ELISP_CONFIG_FILE],[dnl
dnl 1 -- relative filename (from ‘top_srcdir’)
m4_define([__ELISP_CONFIG_FILENAME],[$1])dnl
])dnl


AC_DEFUN([_ELISP_PREP],[dnl
AS_IF([AS_VAR_TEST_SET([EMACS])],,dnl
  [AC_MSG_ERROR([No value for EMACS])])
dnl FIXME: Check at autoconf-time that __ELISP_CONFIG_FILENAME is set.
dnl        (If not, or if the value is unsuitable, throw fatal error.)
rm -f __ELISP_CONFIG_FILENAME
touch __ELISP_CONFIG_FILENAME
])dnl


AC_DEFUN([ELISP_CHECK],[dnl
dnl 1 -- Emacs Lisp symbol to add to config file if "success"
dnl 2 -- description
dnl 3 -- Emacs Lisp body (zero or more forms)
dnl 4 -- Emacs Lisp expression for "success"
AC_REQUIRE([_ELISP_PREP])dnl
AS_VAR_PUSHDEF([CV],[edb_cv_$1])dnl
AC_CACHE_CHECK([$2],[CV],[dnl
cat >conftest.el <<__ELISP_EOF
$3
(kill-emacs (if $4 0 1))
__ELISP_EOF
AS_IF([$EMACS --batch -Q -l conftest.el],[CV=yes],[CV=no])])
AS_IF([test yes = $[]CV],[echo "$1" >> __ELISP_CONFIG_FILENAME])
AS_VAR_POPDEF([CV])dnl
])dnl


AC_DEFUN([ELISP_CHECK_FBOUNDP],[dnl
dnl 1 -- Emacs Lisp symbol
dnl 2 -- (optional) space-separated list of features to ‘require’
ELISP_CHECK([$1],[if ‘$1’ is defined],[dnl
m4_foreach([FEATURE],m4_split(m4_normalize($2)),[dnl
(require 'FEATURE)
])],[(fboundp '$1)])])dnl


AC_DEFUN([ELISP_CHECK_BOUNDP],[dnl
dnl 1 -- Emacs Lisp symbol
dnl 2 -- (optional) space-separated list of features to ‘require’
ELISP_CHECK([$1],[if ‘$1’ is defined],[dnl
m4_foreach([FEATURE],m4_split(m4_normalize($2)),[dnl
(require 'FEATURE)
])],[(boundp '$1)])])dnl


dnl History
dnl -  1 -- initial release

dnl Local variables:
dnl mode: autoconf
dnl End:
dnl elisp.m4 ends here
Example usage (excerpted from EDB configure.ac):

 m4_include([build-aux/elisp.m4])
 ELISP_CONFIG_FILE([lisp/cfg.el])
 ELISP_CHECK_FBOUNDP([with-selected-window])
 ELISP_CHECK_FBOUNDP([number-sequence])
 ELISP_CHECK_FBOUNDP([help-function-arglist],[help-fns])
 ELISP_CHECK([defstruct-reflects-struct-slots],
   [if ‘cl-defstruct’ reflects in ‘cl-struct-slots’],
   [(require 'cl) (cl-defstruct zow one two)],
   [(get 'zow 'cl-struct-slots)])

The first line is in lieu of proper aclocal support (EDB uses
only GNU Autoconf, for now) -- works fine.  The second line sets
the output file -- to be done before the checks.  The rest are
the checks.

Next EDB release will use this, so you can grok in full w/ the
generated configure script (and if/how it runs), then.  In the
meantime, bug reports along the lines of "elisp is a pejorative"
or "U+2018, U+2019 is so un{kind,couth,cool}" to /dev/null.  :-D

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (type via)
   (case type
     (technical (eq 'mailing-list via))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]