"Fossies" - the Fresh Open Source Software Archive

Member "TeXmacs-2.1.2-src/plugins/maxima/progs/maxima-menus.scm" (5 May 2022, 6443 Bytes) of package /linux/misc/TeXmacs-2.1.2-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lisp source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    3 ;;
    4 ;; MODULE      : maxima-menus.scm
    5 ;; DESCRIPTION : Menus for the maxima plugin
    6 ;; COPYRIGHT   : (C) 2005  Joris van der Hoeven
    7 ;;
    8 ;; This software falls under the GNU general public license version 3 or later.
    9 ;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
   10 ;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
   11 ;;
   12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   13 
   14 (texmacs-module (maxima-menus)
   15   (:use (utils plugins plugin-cmd)
   16     (doc help-funcs)
   17     (dynamic scripts-edit)
   18         (dynamic session-menu)
   19     (convert tools tmconcat)))
   20 
   21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   22 ;; Several subroutines for the evaluation of Maxima expressions
   23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   24 
   25 (define (maxima-spaces? t)
   26   (and (string? t) (in? t (list "" " " "  " "   " "    "))))
   27 
   28 (define (maxima-prompt? t)
   29   (or (match? t '(text (with "font-family" "tt" "color" "red" :*)))
   30       (match? t '(with "font-family" "tt" "color" "red" :*))
   31       (match? t '(with "mode" "text" "font-family" "tt" "color" "red" :*))))
   32 
   33 (define (maxima-output-simplify t)
   34   ;;(display* "Simplify " t "\n")
   35   (cond ((and (func? t 'concat) (> (length t) 2) (maxima-prompt? (cadr t)))
   36      (plugin-output-std-simplify "maxima" (cons 'concat (cddr t))))
   37     ((match? t '(with "math-display" "true" :%1))
   38      (maxima-output-simplify (cAr t)))
   39     ((match? t '(with "mode" "math" "math-display" "true" :%1))
   40      `(math ,(maxima-output-simplify (cAr t))))
   41     ((func? t 'text 1)
   42      `(text ,(maxima-output-simplify (cAr t))))
   43     ((func? t 'math 1)
   44      `(math ,(maxima-output-simplify (cAr t))))
   45     ((func? t 'with 1)
   46      (maxima-output-simplify (cAr t)))
   47     ((func? t 'with)
   48      (rcons (cDr t) (maxima-output-simplify (cAr t))))
   49         ((and (func? t 'concat) (pair? (cdr t)) (maxima-spaces? (cadr t)))
   50          (maxima-output-simplify (cons (car t) (cddr t))))
   51     ((func? t 'concat)
   52      (apply tmconcat (map maxima-output-simplify (cdr t))))
   53     (else (plugin-output-std-simplify "maxima" t))))
   54 
   55 (define (maxima-contains-prompt? t)
   56   (cond ((maxima-prompt? t) #t)
   57     ((func? t 'concat)
   58      (list-or (map maxima-contains-prompt? (cdr t))))
   59     ((and (func? t 'with) (nnull? (cdr t)))
   60      (maxima-contains-prompt? (cAr t)))
   61     ((or (func? t 'text 1) (func? t 'math 1))
   62      (maxima-contains-prompt? (cAr t)))
   63     (else #f)))
   64 
   65 (tm-define (plugin-output-simplify name t)
   66   (:require (== name "maxima"))
   67   ;;(display* "Simplify output " t "\n")
   68   (if (func? t 'document)
   69       (with u (list-find (cdr t) maxima-contains-prompt?)
   70     (if u (maxima-output-simplify u) (maxima-output-simplify t)))
   71       (maxima-output-simplify t)))
   72 
   73 (define maxima-apply script-apply)
   74 
   75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   76 ;; The Maxima menu
   77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   78 
   79 (menu-bind maxima-menu
   80   (if (not-in-session?)
   81       (link scripts-eval-menu)
   82       ---)
   83   (-> "Simplification"
   84       ("Simplify" (maxima-apply "fullratsimp"))
   85       ("Factor" (maxima-apply "factor"))
   86       ("Expand" (maxima-apply "expand"))
   87       ((eval '(concat "Expand " "w.r.t."))
   88        (maxima-apply "expandwrt" 2)))
   89   (-> "Solving equations"
   90       ("Solve" (maxima-apply "solve"))
   91       ("Solve in" (maxima-apply "solve" 2)))
   92   (-> "Arithmetic"
   93       ("Factor" (maxima-apply "factor"))
   94       ("Gcd" (maxima-apply "gcd"))
   95       ("Lcm" (maxima-apply "lcm")))
   96   (-> "Logarithms"
   97       ("Exponential" (maxima-apply "exp"))
   98       ("Logarithm" (maxima-apply "log"))
   99       ("Square root" (maxima-apply "sqrt"))
  100       ---
  101       ("Contract logarithms" (maxima-apply "logcontract"))
  102       ("Expand logarithms" (maxima-apply "logexpand")))
  103   (-> "Trigonometry"
  104       ("Cosine" (maxima-apply "cos"))
  105       ("Sine" (maxima-apply "sin"))
  106       ("Tangent" (maxima-apply "tan"))
  107       ("Arc cosine" (maxima-apply "acos"))
  108       ("Arc sine" (maxima-apply "asin"))
  109       ("Arc tangent" (maxima-apply "atan"))
  110       ---
  111       ("Reduce trigonometric functions" (maxima-apply "trigreduce"))
  112       ((eval '(concat "Reduce trigonometric functions " "w.r.t."))
  113        (maxima-apply "trigreduce" 2))
  114       ("Expand trigonometric functions" (maxima-apply "trigexpand")))
  115   (-> "Special functions"
  116       ("Airy" (maxima-apply "Airy"))
  117       ("Erf" (maxima-apply "erf"))
  118       ("Gamma" (maxima-apply "Gamma"))
  119       ("Psi" (maxima-apply "Psi")))
  120   (-> "Calculus"
  121       ("Differentiate" (maxima-apply "diff" 2))
  122       ("Integrate" (maxima-apply "integrate" 2)))
  123   (-> "Linear algebra"
  124       ("Determinant" (maxima-apply "determinant"))
  125       ("Echelon" (maxima-apply "echelon"))
  126       ("Eigenvalues" (maxima-apply "eigenvalues"))
  127       ("Invert" (maxima-apply "invert"))
  128       ("Rank" (maxima-apply "rank"))
  129       ("Transpose" (maxima-apply "transpose"))
  130       ("Triangularize" (maxima-apply "triangularize")))
  131   (if (not-in-session?)
  132       ---
  133       (link scripts-eval-toggle-menu)))
  134 
  135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  136 ;; Additional icons
  137 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  138 
  139 (define (car-or-false l)
  140   (if (null? l) #f
  141       (car l)))
  142 
  143 (define (maxima-dirs)
  144   (if (os-mingw?)
  145       (map (lambda (x) (string-drop-right x 1))
  146            (string-split (var-eval-system "maxima.bat -d") #\newline))
  147       (string-split (var-eval-system "maxima -d") #\newline)))
  148 
  149 (define (maxima-htmldir)
  150   (map (lambda (x) (string-drop x (string-length "maxima-htmldir=")))
  151    (filter (lambda (x) (string-starts? x "maxima-htmldir="))
  152            (maxima-dirs))))
  153 
  154 (define (maxima-help) 
  155   (with htmldir (car-or-false (maxima-htmldir))
  156    (define (concat-html-path html)
  157      (string-append (string-append htmldir "/")
  158                     html))
  159    (car-or-false (filter url-exists?
  160                   (map concat-html-path
  161                    (list "maxima_toc.html" "maxima_0.html"))))))
  162 
  163 (menu-bind maxima-help-icons
  164   (with help (maxima-help)
  165    (if (and (in-maxima?) help)
  166       /
  167       ((balloon (icon "tm_help.xpm") "Maxima manual")
  168        (load-buffer help)))))
  169 
  170 (menu-bind session-help-icons
  171   (:require (and (in-maxima?) (in-session?)))
  172   (link maxima-help-icons))
  173 
  174 (menu-bind plugin-menu
  175   (:require (or (in-maxima?) (and (not-in-session?) (maxima-scripts?))))
  176   (=> "Maxima" (link maxima-menu)))