A place to keep aliases to built-in constants when needed
authorSteve Youngs <steve@sxemacs.org>
Sat, 26 Dec 2015 02:12:26 +0000 (12:12 +1000)
committerSteve Youngs <steve@sxemacs.org>
Sat, 26 Dec 2015 02:12:26 +0000 (12:12 +1000)
* merges:
  Add logged, but missing change from previous commit.
  Segregate aliases to DEFVAR_CONST
  Revert "Fix the fix, make pi a normal lisp var (Closes bug #176)"

lisp/Makefile.am
lisp/const-aliases.el [new file with mode: 0644]
lisp/startup.el
src/ent/ent-mpfr.c
src/ent/ent-mpfr.h

index faa1730..9806abd 100644 (file)
@@ -76,16 +76,16 @@ corelispels =                                                               \
        build-rpt.el byte-optimize.el bytecomp-runtime.el bytecomp.el   \
        callers-of-rpt.el cl-compat.el cl-extra.el cl-macs.el cl-seq.el \
        cl.el cmdloop.el code-cmds.el code-files.el code-process.el     \
-       coding.el compat.el config.el console.el cus-dep.el             \
-       cus-edit.el cus-face.el cus-file.el cus-load.el cus-start.el    \
-       custom.el derived.el device.el dialog-items.el dialog.el        \
-       disass.el disp-table.el dragdrop.el easy-mmode.el easymenu.el   \
-       emod-utils.el etags.el events.el extents.el faces.el ffi.el     \
-       files-nomule.el files.el fill.el float-sup.el font-lock.el      \
-       font-menu.el font.el fontl-hooks.el format.el frame.el          \
-       glyphs.el gnuserv.el gpm.el gui.el gutter-items.el gutter.el    \
-       help-macro.el help-nomule.el help.el hyper-apropos.el indent.el \
-       info.el isearch-mode.el iso8859-1.el issue-tracker.el           \
+       coding.el compat.el config.el console.el const-aliases.el       \
+       cus-dep.el cus-edit.el cus-face.el cus-file.el cus-load.el      \
+       cus-start.el custom.el derived.el device.el dialog-items.el     \
+       dialog.el disass.el disp-table.el dragdrop.el easy-mmode.el     \
+       easymenu.el emod-utils.el etags.el events.el extents.el         \
+       faces.el ffi.el files-nomule.el files.el fill.el float-sup.el   \
+       font-lock.el font-menu.el font.el fontl-hooks.el format.el      \
+       frame.el glyphs.el gnuserv.el gpm.el gui.el gutter-items.el     \
+       gutter.el help-macro.el help-nomule.el help.el hyper-apropos.el \
+       indent.el info.el isearch-mode.el iso8859-1.el issue-tracker.el \
        itimer-autosave.el itimer.el keydefs.el keymap.el ldap.el       \
        lib-complete.el lisp-initd.el lisp-mnt.el lisp-mode.el lisp.el  \
        list-mode.el loaddefs.el loadhist.el map-ynp.el                 \
diff --git a/lisp/const-aliases.el b/lisp/const-aliases.el
new file mode 100644 (file)
index 0000000..379d5ca
--- /dev/null
@@ -0,0 +1,40 @@
+;;; const-aliases --- define alias for C defconsts to allow let-bind
+
+;; Copyright (C) 2015 Nelson Ferreira
+
+;; Author: Nelson Ferreira <nelson.ferreira@ieee.org>
+;; Maintainer: SXEmacs Development Team
+;; Keywords: internal
+
+;; This file is part of SXEmacs.
+
+;; SXEmacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; SXEmacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Synched up with: Not synched with FSF.
+
+;;; Commentary:
+
+;; The following code is required at startup to define all the
+;; necessary defconst alias for C DEFVAR_CONST that we wish to
+;; allow let-bind to succeed.
+
+\f
+;;; Code:
+
+(when (featurep 'bigfr)
+  (defconst pi bigfr-pi "The value of Pi (3.1415926...)")
+  (defconst e euler "The value of e (2.7182818...)"))
+
+(provide 'const-aliases)
+
index a58eca7..f2ffff6 100644 (file)
@@ -763,6 +763,9 @@ If this is nil, no message will be displayed.")
 
 ;;; Load user's init file and default ones.
 (defun load-init-file ()
+
+  (require 'const-aliases)
+
   (run-hooks 'before-init-hook)
 
   ;; Run the site-start library if it exists.  The point of this file is
index b032433..dbca26a 100644 (file)
@@ -35,7 +35,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 \f
 Lisp_Object Veuler;
 Lisp_Object Veuler_mascheroni;
-Lisp_Object Vpi;
+Lisp_Object Vbigfr_pi;
 
 bigfr ent_scratch_bigfr;
 static ase_nullary_operation_f Qent_mpfr_zero, Qent_mpfr_one;
@@ -1599,8 +1599,8 @@ void init_ent_mpfr(void)
        Veuler_mascheroni = make_bigfr(0.0, 2048UL);
        mpfr_const_euler(XBIGFR_DATA(Veuler_mascheroni), GMP_RNDN);
 
-       Vpi = make_bigfr(0.0, 2048UL);
-       mpfr_const_pi(XBIGFR_DATA(Vpi), GMP_RNDN);
+       Vbigfr_pi = make_bigfr(0.0, 2048UL);
+       mpfr_const_pi(XBIGFR_DATA(Vbigfr_pi), GMP_RNDN);
 }
 
 void syms_of_ent_mpfr(void)
@@ -1620,7 +1620,7 @@ void vars_of_ent_mpfr(void)
        /* just some dummy values atm, to make the dumper smile */
        Veuler = make_int(1L);
        Veuler_mascheroni = make_int(1L);
-       Vpi = make_int(1L);
+       Vbigfr_pi = make_int(1L);
 
        DEFVAR_CONST_LISP("euler", &Veuler /*
 The value of Euler's constant e (2.7182818...).
@@ -1628,11 +1628,7 @@ The value of Euler's constant e (2.7182818...).
        DEFVAR_CONST_LISP("euler-mascheroni", &Veuler_mascheroni /*
 The value of the Euler-Mascheroni constant (0.5772156...).
                                                                 */);
-       /*
-        * See http://issues.sxemacs.org/show_bug.cgi?id=176 for why this
-        * is no longer a constant. -SY.
-        */
-       DEFVAR_LISP("pi", &Vpi /*
+       DEFVAR_CONST_LISP("bigfr-pi", &Vbigfr_pi /*
 The value of pi (3.1415926...).
                                     */);
 
index 30e7b5f..143bd08 100644 (file)
@@ -41,7 +41,7 @@ extern Lisp_Object Qbigfrp;
 
 extern Lisp_Object Veuler;
 extern Lisp_Object Veuler_mascheroni;
-extern Lisp_Object Vpi;
+extern Lisp_Object Vbigfr_pi;
 
 \f
 typedef struct Lisp_Bigfr Lisp_Bigfr;