emacs/lisp/calc/calc-keypd.el

618 lines
21 KiB
EmacsLisp
Raw Normal View History

* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;;; calc-keypd.el --- mouse-capable keypad input for Calc -*- lexical-binding:t -*-
2022-01-01 02:45:51 -05:00
;; Copyright (C) 1990-1993, 2001-2022 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
2001-11-06 18:59:06 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs 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.
2001-11-06 18:59:06 +00:00
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2001-11-06 18:59:06 +00:00
;;; Commentary:
;;; Code:
2001-11-06 18:59:06 +00:00
;; This file is autoloaded from calc-ext.el.
(require 'calc-ext)
2001-11-06 18:59:06 +00:00
(require 'calc-macs)
(defvar calc-keypad-buffer nil)
(defvar calc-keypad-menu 0)
(defvar calc-keypad-full-layout nil)
(defvar calc-keypad-input nil)
(defvar calc-keypad-prev-input nil)
(defvar calc-keypad-said-hello nil)
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; | ENTER |+/- |EEX |UNDO| <- |
;; |-----+---+-+--+--+-+---++----|
;; | INV | 7 | 8 | 9 | / |
;; |-----+-----+-----+-----+-----|
;; | HYP | 4 | 5 | 6 | * |
;; |-----+-----+-----+-----+-----|
;; |EXEC | 1 | 2 | 3 | - |
;; |-----+-----+-----+-----+-----|
;; | OFF | 0 | . | PI | + |
;; |-----+-----+-----+-----+-----|
(defvar calc-keypad-layout
'( ( ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
( "+/-" calc-change-sign calc-inv (progn -4 calc-pack) )
( "EEX" ("e") (progn calc-num-prefix calc-pack-interval)
(progn -5 calc-pack) )
( "UNDO" calc-undo calc-redo calc-last-args )
( "<-" calc-pop (progn 0 calc-pop)
(progn calc-num-prefix calc-pop) ) )
( ( "INV" calc-inverse )
( "7" ("7") calc-round )
( "8" ("8") (progn 2 calc-clean-num) )
( "9" ("9") calc-float )
( "/" calc-divide (progn calc-inverse calc-power) ) )
( ( "HYP" calc-hyperbolic )
( "4" ("4") calc-ln calc-log10 )
( "5" ("5") calc-exp calc-exp10 )
( "6" ("6") calc-abs )
( "*" calc-times calc-power ) )
( ( "EXEC" calc-keypad-execute )
( "1" ("1") calc-arcsin calc-sin )
( "2" ("2") calc-arccos calc-cos )
( "3" ("3") calc-arctan calc-tan )
( "-" calc-minus calc-conj ) )
( ( "OFF" calc-keypad-off )
( "0" ("0") calc-imaginary )
( "." (".") calc-precision )
( "PI" calc-pi )
( "+" calc-plus calc-sqrt ) ) ))
(defvar calc-keypad-menus '( calc-keypad-math-menu
calc-keypad-funcs-menu
calc-keypad-binary-menu
calc-keypad-vector-menu
calc-keypad-modes-menu
calc-keypad-user-menu ) )
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; |FLR |CEIL|RND |TRNC|CLN2|FLT |
;; |----+----+----+----+----+----|
;; | LN |EXP | |ABS |IDIV|MOD |
;; |----+----+----+----+----+----|
;; |SIN |COS |TAN |SQRT|y^x |1/x |
(defvar calc-keypad-math-menu
'( ( ( "FLR" calc-floor )
( "CEIL" calc-ceiling )
( "RND" calc-round )
( "TRNC" calc-trunc )
( "CLN2" (progn 2 calc-clean-num) )
( "FLT" calc-float ) )
( ( "LN" calc-ln )
( "EXP" calc-exp )
( "" nil )
( "ABS" calc-abs )
( "IDIV" calc-idiv )
( "MOD" calc-mod ) )
( ( "SIN" calc-sin )
( "COS" calc-cos )
( "TAN" calc-tan )
( "SQRT" calc-sqrt )
( "y^x" calc-power )
( "1/x" calc-inv ) ) ))
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; |IGAM|BETA|IBET|ERF |BESJ|BESY|
;; |----+----+----+----+----+----|
;; |IMAG|CONJ| RE |ATN2|RAND|RAGN|
;; |----+----+----+----+----+----|
;; |GCD |FACT|DFCT|BNOM|PERM|NXTP|
(defvar calc-keypad-funcs-menu
'( ( ( "IGAM" calc-inc-gamma )
( "BETA" calc-beta )
( "IBET" calc-inc-beta )
( "ERF" calc-erf )
( "BESJ" calc-bessel-J )
( "BESY" calc-bessel-Y ) )
( ( "IMAG" calc-imaginary )
( "CONJ" calc-conj )
( "RE" calc-re calc-im )
( "ATN2" calc-arctan2 )
( "RAND" calc-random )
( "RAGN" calc-random-again ) )
( ( "GCD" calc-gcd calc-lcm )
( "FACT" calc-factorial calc-gamma )
( "DFCT" calc-double-factorial )
( "BNOM" calc-choose )
( "PERM" calc-perm )
( "NXTP" calc-next-prime calc-prev-prime ) ) ))
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; |AND | OR |XOR |NOT |LSH |RSH |
;; |----+----+----+----+----+----|
;; |DEC |HEX |OCT |BIN |WSIZ|ARSH|
;; |----+----+----+----+----+----|
;; | A | B | C | D | E | F |
(defvar calc-keypad-binary-menu
'( ( ( "AND" calc-and calc-diff )
( "OR" calc-or )
( "XOR" calc-xor )
( "NOT" calc-not calc-clip )
( "LSH" calc-lshift-binary calc-rotate-binary )
( "RSH" calc-rshift-binary ) )
( ( "DEC" calc-decimal-radix )
( "HEX" calc-hex-radix )
( "OCT" calc-octal-radix )
( "BIN" calc-binary-radix )
( "WSIZ" calc-word-size )
( "ARSH" calc-rshift-arith ) )
( ( "A" ("A") )
( "B" ("B") )
( "C" ("C") )
( "D" ("D") )
( "E" ("E") )
( "F" ("F") ) ) ))
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; |SUM |PROD|MAX |MAP*|MAP^|MAP$|
;; |----+----+----+----+----+----|
;; |INV |DET |TRN |IDNT|CRSS|"x" |
;; |----+----+----+----+----+----|
;; |PACK|UNPK|INDX|BLD |LEN |... |
(defvar calc-keypad-vector-menu
'( ( ( "SUM" calc-vector-sum calc-vector-alt-sum calc-vector-mean )
( "PROD" calc-vector-product nil calc-vector-sdev )
( "MAX" calc-vector-max calc-vector-min calc-vector-median )
( "MAP*" (lambda () (interactive)
(calc-map '(2 calcFunc-mul "*"))) )
( "MAP^" (lambda () (interactive)
(calc-map '(2 calcFunc-pow "^"))) )
( "MAP$" calc-map-stack ) )
( ( "MINV" calc-inv )
( "MDET" calc-mdet )
( "MTRN" calc-transpose calc-conj-transpose )
( "IDNT" (progn calc-num-prefix calc-ident) )
( "CRSS" calc-cross )
( "\"x\"" "\excalc-algebraic-entry\rx\r"
"\excalc-algebraic-entry\ry\r"
"\excalc-algebraic-entry\rz\r"
"\excalc-algebraic-entry\rt\r") )
( ( "PACK" calc-pack )
( "UNPK" calc-unpack )
( "INDX" (progn calc-num-prefix calc-index) "\C-u\excalc-index\r" )
( "BLD" (progn calc-num-prefix calc-build-vector) )
( "LEN" calc-vlength )
( "..." calc-full-vectors ) ) ))
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
;; |----+----+----+----+----+----|
;; |FLT |FIX |SCI |ENG |GRP | |
;; |----+----+----+----+----+----|
;; |RAD |DEG |FRAC|POLR|SYMB|PREC|
;; |----+----+----+----+----+----|
;; |SWAP|RLL3|RLL4|OVER|STO |RCL |
(defvar calc-keypad-modes-menu
'( ( ( "FLT" calc-normal-notation
(progn calc-num-prefix calc-normal-notation) )
( "FIX" (progn 2 calc-fix-notation)
(progn calc-num-prefix calc-fix-notation) )
( "SCI" calc-sci-notation
(progn calc-num-prefix calc-sci-notation) )
( "ENG" calc-eng-notation
(progn calc-num-prefix calc-eng-notation) )
( "GRP" calc-group-digits "\C-u-3\excalc-group-digits\r" )
( "" nil ) )
( ( "RAD" calc-radians-mode )
( "DEG" calc-degrees-mode )
( "FRAC" calc-frac-mode )
( "POLR" calc-polar-mode )
( "SYMB" calc-symbolic-mode )
( "PREC" calc-precision ) )
( ( "SWAP" calc-roll-down )
( "RLL3" (progn 3 calc-roll-up) (progn 3 calc-roll-down) )
( "RLL4" (progn 4 calc-roll-up) (progn 4 calc-roll-down) )
( "OVER" calc-over )
( "STO" calc-keypad-store )
( "RCL" calc-keypad-recall ) ) ))
(define-derived-mode calc-keypad-mode fundamental-mode "Calculator"
"Major mode for Calc keypad input."
(define-key calc-keypad-mode-map " " 'calc-keypad-press)
(define-key calc-keypad-mode-map (kbd "RET") 'calc-keypad-press)
(define-key calc-keypad-mode-map (kbd "TAB") 'calc-keypad-menu)
(define-key calc-keypad-mode-map "q" 'calc-keypad-off)
(define-key calc-keypad-mode-map [down-mouse-1] 'ignore)
(define-key calc-keypad-mode-map [drag-mouse-1] 'ignore)
(define-key calc-keypad-mode-map [double-mouse-1] 'ignore)
(define-key calc-keypad-mode-map [triple-mouse-1] 'ignore)
(define-key calc-keypad-mode-map [down-mouse-2] 'ignore)
(define-key calc-keypad-mode-map [drag-mouse-2] 'ignore)
(define-key calc-keypad-mode-map [double-mouse-2] 'ignore)
(define-key calc-keypad-mode-map [triple-mouse-2] 'ignore)
(define-key calc-keypad-mode-map [down-mouse-3] 'ignore)
(define-key calc-keypad-mode-map [drag-mouse-3] 'ignore)
(define-key calc-keypad-mode-map [double-mouse-3] 'ignore)
(define-key calc-keypad-mode-map [triple-mouse-3] 'ignore)
(define-key calc-keypad-mode-map [mouse-3] 'calc-keypad-right-click)
(define-key calc-keypad-mode-map [mouse-2] 'calc-keypad-middle-click)
(define-key calc-keypad-mode-map [mouse-1] 'calc-keypad-left-click)
(put 'calc-keypad-mode 'mode-class 'special)
(make-local-variable 'calc-main-buffer))
2001-11-06 18:59:06 +00:00
(defun calc-do-keypad (&optional full-display interactive)
(calc-create-buffer)
(let ((calcbuf (current-buffer)))
(unless (bufferp calc-keypad-buffer)
(set-buffer (setq calc-keypad-buffer (get-buffer-create "*Calc Keypad*")))
(calc-keypad-mode)
(setq calc-main-buffer calcbuf)
(calc-keypad-redraw)
(calc-trail-buffer))
2001-11-06 18:59:06 +00:00
(let ((width 29)
(height 17)
win old-win)
(if (setq win (get-buffer-window "*Calculator*"))
(delete-window win))
(if (setq win (get-buffer-window "*Calc Trail*"))
(if (one-window-p)
(switch-to-buffer (other-buffer))
(delete-window win)))
(if (setq win (get-buffer-window calc-keypad-buffer))
(progn
(bury-buffer "*Calculator*")
(bury-buffer "*Calc Trail*")
(bury-buffer calc-keypad-buffer)
(if (one-window-p)
(switch-to-buffer (other-buffer))
(delete-window win)))
2001-11-06 18:59:06 +00:00
(setq calc-was-keypad-mode t
old-win (get-largest-window))
(if (or (< (window-height old-win) (+ height 6))
(< (window-width old-win) (+ width 15))
full-display)
(delete-other-windows old-win))
(if (< (window-height old-win) (+ height 4))
(error "Screen is not tall enough for this mode"))
(if full-display
(progn
(setq win (split-window old-win (- (window-height old-win)
height 1)))
(set-window-buffer old-win (calc-trail-buffer))
(set-window-buffer win calc-keypad-buffer)
(set-window-start win 1)
(setq win (split-window win (+ width 7) t))
2001-11-06 18:59:06 +00:00
(set-window-buffer win calcbuf))
(if (or t ; left-side keypad not yet fully implemented
(< (with-current-buffer (window-buffer old-win)
2001-11-06 18:59:06 +00:00
(current-column))
(/ (window-width) 2)))
(setq win (split-window old-win (- (window-width old-win)
width 2)
t))
(setq old-win (split-window old-win (+ width 2) t)))
(set-window-buffer win calc-keypad-buffer)
(set-window-start win 1)
(split-window win (- (window-height win) height 1))
(set-window-buffer win calcbuf))
(select-window old-win)
(message "Welcome to GNU Emacs Calc! Use the left and right mouse buttons")
2001-11-06 18:59:06 +00:00
(run-hooks 'calc-keypad-start-hook)
(and calc-keypad-said-hello interactive
(progn
(sit-for 2)
(message "")))
(setq calc-keypad-said-hello t)))
(setq calc-keypad-input nil)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-off ()
(interactive)
(if calc-standalone-flag
(save-buffers-kill-emacs nil)
(calc-keypad)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-redraw ()
(set-buffer calc-keypad-buffer)
(setq buffer-read-only t)
(setq calc-keypad-full-layout (append (symbol-value (nth calc-keypad-menu
calc-keypad-menus))
calc-keypad-layout))
(let ((buffer-read-only nil)
(row calc-keypad-full-layout)
(y 0))
(erase-buffer)
(insert "\n")
(while row
(let ((col (car row)))
(while col
(let* ((key (car col))
(cwid (if (>= y 4)
5
(if (and (= y 3) (eq col (car row)))
(progn (setq col (cdr col)) 9)
4)))
(name (if (and calc-standalone-flag
(eq (nth 1 key) 'calc-keypad-off))
"EXIT"
(if (> (length (car key)) cwid)
(substring (car key) 0 cwid)
(car key))))
(wid (length name)))
2001-11-06 18:59:06 +00:00
(insert (make-string (/ (- cwid wid) 2) 32)
name
(make-string (/ (- cwid wid -1) 2) 32)
(if (equal name "MENU")
(int-to-string (1+ calc-keypad-menu))
"|")))
(or (setq col (cdr col))
(insert "\n")))
(insert (if (>= y 4)
"-----+-----+-----+-----+-----"
(if (= y 3)
"-----+---+-+--+--+-+---++----"
"----+----+----+----+----+----"))
(if (= y 7) "+\n" "|\n"))
(setq y (1+ y)
row (cdr row)))))
(setq calc-keypad-prev-input t)
(calc-keypad-show-input)
(goto-char (point-min)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-show-input ()
(or (equal calc-keypad-input calc-keypad-prev-input)
(let ((buffer-read-only nil))
(save-excursion
(goto-char (point-min))
(forward-line 1)
(delete-region (point-min) (point))
(if calc-keypad-input
(insert "Calc: " calc-keypad-input "\n")
(insert "----+----+--Calc---+----+----"
2001-11-06 18:59:06 +00:00
(int-to-string (1+ calc-keypad-menu))
"\n")))))
(setq calc-keypad-prev-input calc-keypad-input))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-press ()
(interactive)
(unless (eq major-mode 'calc-keypad-mode)
(error "Must be in *Calc Keypad* buffer for this command"))
(let* ((row (count-lines (point-min) (line-beginning-position)))
2001-11-06 18:59:06 +00:00
(y (/ row 2))
(x (/ (current-column) (if (>= y 4) 6 5)))
radix frac inv
(hyp (with-current-buffer calc-main-buffer
2001-11-06 18:59:06 +00:00
(setq radix calc-number-radix
frac calc-prefer-frac
inv calc-inverse-flag)
calc-hyperbolic-flag))
(invhyp t)
(input calc-keypad-input)
(iexpon (and input
(or (string-match "\\*[0-9]+\\.\\^" input)
(and (<= radix 14) (string-match "e" input)))
(match-end 0)))
(key (nth x (nth y calc-keypad-full-layout)))
(cmd (or (nth (if inv (if hyp 4 2) (if hyp 3 99)) key)
(setq invhyp nil)
(nth 1 key)))
(isstring (and (consp cmd) (stringp (car cmd))))
(calc-is-keypad-press t))
(if invhyp (calc-wrapper)) ; clear Inv and Hyp flags
(unwind-protect
(cond ((or (null cmd)
(= (% row 2) 0))
(beep))
((and (> (minibuffer-depth) 0))
(cond (isstring
(push (aref (car cmd) 0) unread-command-events))
2001-11-06 18:59:06 +00:00
((eq cmd 'calc-pop)
(push ?\177 unread-command-events))
2001-11-06 18:59:06 +00:00
((eq cmd 'calc-enter)
(push 13 unread-command-events))
2001-11-06 18:59:06 +00:00
((eq cmd 'calc-undo)
(push 7 unread-command-events))
2001-11-06 18:59:06 +00:00
(t
(beep))))
((and input (string-match "STO\\|RCL" input))
(cond ((and isstring (string-match "[0-9]" (car cmd)))
(setq calc-keypad-input nil)
(let ((var (intern (concat "var-q" (car cmd)))))
(cond ((equal input "STO+") (calc-store-plus var))
((equal input "STO-") (calc-store-minus var))
((equal input "STO*") (calc-store-times var))
((equal input "STO/") (calc-store-div var))
((equal input "STO^") (calc-store-power var))
((equal input "STOn") (calc-store-neg 1 var))
((equal input "STO&") (calc-store-inv 1 var))
((equal input "STO") (calc-store-into var))
(t (calc-recall var)))))
((memq cmd '(calc-pop calc-undo))
(setq calc-keypad-input nil))
((and (equal input "STO")
(setq frac (assq cmd '( ( calc-plus . "+" )
( calc-minus . "-" )
( calc-times . "*" )
( calc-divide . "/" )
( calc-power . "^")
( calc-change-sign . "n")
( calc-inv . "&") ))))
(setq calc-keypad-input (concat input (cdr frac))))
(t
(beep))))
(isstring
(setq cmd (car cmd))
(if (or (and (equal cmd ".")
input
(string-match "[.:e^]" input))
(and (equal cmd "e")
input
(or (and (<= radix 14) (string-match "e" input))
(string-match "\\^\\|[-.:]\\'" input)))
(and (not (equal cmd "."))
(let ((case-fold-search nil))
(string-match cmd "0123456789ABCDEF"
(if (string-match
"[e^]" (or input ""))
10 radix)))))
(beep)
(setq calc-keypad-input (concat
(and (/= radix 10)
(or (not input)
(equal input "-"))
(format "%d#" radix))
(and (or (not input)
(equal input "-"))
(or (and (equal cmd "e") "1")
(and (equal cmd ".")
(if frac "1" "0"))))
input
(if (and (equal cmd ".") frac)
":"
(if (and (equal cmd "e")
(or (not input)
Use string-search instead of string-match[-p] `string-search` is easier to understand, less error-prone, much faster, does not pollute the regexp cache, and does not mutate global state. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-canonical-file-name) (authors-scan-change-log): * lisp/apropos.el (apropos-command) (apropos-documentation-property, apropos-symbols-internal): * lisp/arc-mode.el (archive-arc-summarize) (archive-zoo-summarize): * lisp/calc/calc-aent.el (math-read-factor): * lisp/calc/calc-ext.el (math-read-big-expr) (math-format-nice-expr, math-format-number-fancy): * lisp/calc/calc-forms.el (math-read-angle-brackets): * lisp/calc/calc-graph.el (calc-graph-set-range): * lisp/calc/calc-keypd.el (calc-keypad-press): * lisp/calc/calc-lang.el (tex, latex, math-read-big-rec): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-user-define-permanent, math-define-exp): * lisp/calc/calc.el (calc-record, calcDigit-key) (calc-count-lines): * lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots) (math-do-integral): * lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum) (calc-get-fit-variables): * lisp/cedet/ede/speedbar.el (ede-tag-expand): * lisp/cedet/semantic/java.el (semantic-java-expand-tag): * lisp/cedet/semantic/sb.el (semantic-sb-show-extra) (semantic-sb-expand-group): * lisp/cedet/semantic/wisent/python.el (semantic-python-instance-variable-p): * lisp/cus-edit.el (get): * lisp/descr-text.el (describe-text-sexp): * lisp/dired-aux.el (dired-compress-file): * lisp/dired-x.el (dired-make-relative-symlink): * lisp/dired.el (dired-glob-regexp): * lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename): * lisp/edmacro.el (edmacro-format-keys): * lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand): * lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand): * lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list): * lisp/emacs-lisp/warnings.el (display-warning): * lisp/emulation/viper-ex.el (viper-ex-read-file-name) (ex-print-display-lines): * lisp/env.el (read-envvar-name, setenv): * lisp/epa-mail.el (epa-mail-encrypt): * lisp/epg.el (epg--start): * lisp/erc/erc-backend.el (erc-parse-server-response): * lisp/erc/erc-dcc.el (erc-dcc-member): * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server) (erc-speedbar-expand-channel, erc-speedbar-expand-user): * lisp/erc/erc.el (erc-send-input): * lisp/eshell/em-glob.el (eshell-glob-entries): * lisp/eshell/esh-proc.el (eshell-needs-pipe-p): * lisp/eshell/esh-util.el (eshell-convert): * lisp/eshell/esh-var.el (eshell-envvar-names): * lisp/faces.el (x-resolve-font-name): * lisp/ffap.el (ffap-file-at-point): * lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern): * lisp/forms.el (forms--update): * lisp/frameset.el (frameset-filter-unshelve-param): * lisp/gnus/gnus-art.el (article-decode-charset): * lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc) (gnus-inews-insert-gcc): * lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body): * lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output) (gnus-search--complete-key-data): * lisp/gnus/gnus-spec.el (gnus-parse-simple-format): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-extract-address-components) (gnus-newsgroup-directory-form): * lisp/gnus/gnus-uu.el (gnus-uu-grab-view): * lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name): * lisp/gnus/message.el (message-check-news-header-syntax) (message-make-message-id, message-user-mail-address) (message-make-fqdn, message-get-reply-headers, message-followup): * lisp/gnus/mm-decode.el (mm-dissect-buffer): * lisp/gnus/nnheader.el (nnheader-insert): * lisp/gnus/nnimap.el (nnimap-process-quirk) (nnimap-imap-ranges-to-gnus-ranges): * lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix): * lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path): * lisp/gnus/nnrss.el (nnrss-match-macro): * lisp/gnus/nntp.el (nntp-find-group-and-number): * lisp/help-fns.el (help--symbol-completion-table-affixation): * lisp/help.el (help-function-arglist): * lisp/hippie-exp.el (he-concat-directory-file-name): * lisp/htmlfontify.el (hfy-relstub): * lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word) (ido-exhibit): * lisp/image/image-converter.el (image-convert-p): * lisp/info-xref.el (info-xref-docstrings): * lisp/info.el (Info-toc-build, Info-follow-reference) (Info-backward-node, Info-finder-find-node) (Info-speedbar-expand-node): * lisp/international/mule-diag.el (print-fontset-element): * lisp/language/korea-util.el (default-korean-keyboard): * lisp/linum.el (linum-after-change): * lisp/mail/ietf-drums.el (ietf-drums-parse-address): * lisp/mail/mail-utils.el (mail-dont-reply-to): * lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rmailkwd.el (rmail-set-label): * lisp/mail/rmailsum.el (rmail-header-summary): * lisp/mail/smtpmail.el (smtpmail-maybe-append-domain) (smtpmail-user-mail-address): * lisp/mail/uce.el (uce-reply-to-uce): * lisp/man.el (Man-default-man-entry): * lisp/mh-e/mh-alias.el (mh-alias-gecos-name) (mh-alias-minibuffer-confirm-address): * lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject): * lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output): * lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter) (mh-folder-completion-function): * lisp/minibuffer.el (completion--make-envvar-table) (completion-file-name-table, completion-flex-try-completion) (completion-flex-all-completions): * lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p) (mpc-constraints-tag-lookup): * lisp/net/ange-ftp.el (ange-ftp-send-cmd) (ange-ftp-allow-child-lookup): * lisp/net/mailcap.el (mailcap-mime-types): * lisp/net/mairix.el (mairix-search-thread-this-article): * lisp/net/pop3.el (pop3-open-server): * lisp/net/soap-client.el (soap-decode-xs-complex-type): * lisp/net/socks.el (socks-filter): * lisp/nxml/nxml-outln.el (nxml-highlighted-qname): * lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype): * lisp/nxml/rng-uri.el (rng-uri-file-name-1): * lisp/obsolete/complete.el (partial-completion-mode) (PC-do-completion): * lisp/obsolete/longlines.el (longlines-encode-string): * lisp/obsolete/nnir.el (nnir-compose-result): * lisp/obsolete/terminal.el (te-quote-arg-for-sh): * lisp/obsolete/tpu-edt.el (tpu-check-search-case): * lisp/obsolete/url-ns.el (isPlainHostName): * lisp/pcmpl-unix.el (pcomplete/scp): * lisp/play/dunnet.el (dun-listify-string2, dun-get-path) (dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface): * lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment): * lisp/progmodes/gdb-mi.el (gdb-var-delete) (gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result): * lisp/progmodes/gud.el (gud-find-expr): * lisp/progmodes/idlw-help.el (idlwave-do-context-help1): * lisp/progmodes/idlw-shell.el (idlwave-shell-mode) (idlwave-shell-filter-hidden-output, idlwave-shell-filter): * lisp/progmodes/idlwave.el (idlwave-skip-label-or-case) (idlwave-routine-info): * lisp/progmodes/octave.el (inferior-octave-completion-at-point): * lisp/progmodes/sh-script.el (sh-add-completer): * lisp/progmodes/sql.el (defun): * lisp/progmodes/xscheme.el (xscheme-process-filter): * lisp/replace.el (query-replace-compile-replacement) (map-query-replace-regexp): * lisp/shell.el (shell--command-completion-data) (shell-environment-variable-completion): * lisp/simple.el (display-message-or-buffer): * lisp/speedbar.el (speedbar-dired, speedbar-tag-file) (speedbar-tag-expand): * lisp/subr.el (split-string-and-unquote): * lisp/tar-mode.el (tar-extract): * lisp/term.el (term-command-hook, serial-read-name): * lisp/textmodes/bibtex.el (bibtex-print-help-message): * lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter) (ispell-parse-output, ispell-buffer-local-parsing): * lisp/textmodes/reftex-cite.el (reftex-do-citation): * lisp/textmodes/reftex-parse.el (reftex-notice-new): * lisp/textmodes/reftex-ref.el (reftex-show-entry): * lisp/textmodes/reftex.el (reftex-compile-variables): * lisp/textmodes/tex-mode.el (tex-send-command) (tex-start-tex, tex-append): * lisp/thingatpt.el (thing-at-point-url-at-point): * lisp/tmm.el (tmm-add-one-shortcut): * lisp/transient.el (transient-format-key): * lisp/url/url-auth.el (url-basic-auth) (url-digest-auth-directory-id-assoc): * lisp/url/url-news.el (url-news): * lisp/url/url-util.el (url-parse-query-string): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/wid-browse.el (widget-browse-sexp): * lisp/woman.el (woman-parse-colon-path, woman-mini-help) (WoMan-getpage-in-background, woman-negative-vertical-space): * lisp/xml.el: * test/lisp/emacs-lisp/check-declare-tests.el (check-declare-tests-warn): * test/lisp/files-tests.el (files-tests-file-name-non-special-dired-compress-handler): * test/lisp/net/network-stream-tests.el (server-process-filter): * test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode): Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 11:20:00 +02:00
(string-search
2001-11-06 18:59:06 +00:00
"#" input))
(> radix 14))
(format "*%d.^" radix)
cmd))))))
((and (eq cmd 'calc-change-sign)
input)
(let* ((epos (or iexpon 0))
(suffix (substring input epos)))
(setq calc-keypad-input (concat
(substring input 0 epos)
(if (string-match "\\`-" suffix)
(substring suffix 1)
(concat "-" suffix))))))
((and (eq cmd 'calc-pop)
input)
(if (equal input "")
(beep)
(setq calc-keypad-input (substring input 0
(or (string-match
"\\*[0-9]+\\.\\^\\'"
input)
-1)))))
((and (eq cmd 'calc-undo)
input)
(setq calc-keypad-input nil))
(t
(if input
(let ((val (math-read-number input)))
(setq calc-keypad-input nil)
(if val
(calc-wrapper
(calc-push-list (list (calc-record
(calc-normalize val)))))
(or (equal input "")
(beep))
(setq cmd nil))
(if (eq cmd 'calc-enter) (setq cmd nil))))
(setq prefix-arg current-prefix-arg)
(if cmd
(if (and (consp cmd) (eq (car cmd) 'progn))
(while (setq cmd (cdr cmd))
(if (integerp (car cmd))
(setq prefix-arg (car cmd))
(command-execute (car cmd))))
(command-execute cmd)))))
(set-buffer calc-keypad-buffer)
(calc-keypad-show-input))))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-left-click (event)
2001-11-06 18:59:06 +00:00
"Handle a left-button mouse click in Calc Keypad window."
;; FIXME: Why not use "@e" instead to select the buffer?
(interactive "e")
(with-current-buffer calc-keypad-buffer
(goto-char (posn-point (event-start event)))
(calc-keypad-press)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-right-click (_event)
2001-11-06 18:59:06 +00:00
"Handle a right-button mouse click in Calc Keypad window."
;; FIXME: Why not use "@e" instead to select the buffer?
(interactive "e")
(with-current-buffer calc-keypad-buffer
(calc-keypad-menu)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-middle-click (_event)
2001-11-06 18:59:06 +00:00
"Handle a middle-button mouse click in Calc Keypad window."
;; FIXME: Why not use "@e" instead to select the buffer?
(interactive "e")
(with-current-buffer calc-keypad-buffer
(calc-keypad-menu-back)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-menu ()
(interactive)
(unless (eq major-mode 'calc-keypad-mode)
(error "Must be in *Calc Keypad* buffer for this command"))
2001-11-06 18:59:06 +00:00
(while (progn (setq calc-keypad-menu (% (1+ calc-keypad-menu)
(length calc-keypad-menus)))
(not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
(calc-keypad-redraw))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-menu-back ()
(interactive)
(or (eq major-mode 'calc-keypad-mode)
2001-11-06 18:59:06 +00:00
(error "Must be in *Calc Keypad* buffer for this command"))
(while (progn (setq calc-keypad-menu (% (1- (+ calc-keypad-menu
(length calc-keypad-menus)))
(length calc-keypad-menus)))
(not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
(calc-keypad-redraw))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-store ()
(interactive)
(setq calc-keypad-input "STO"))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-recall ()
(interactive)
(setq calc-keypad-input "RCL"))
2001-11-06 18:59:06 +00:00
(defun calc-pack-interval (mode)
(interactive "p")
(if (or (< mode 0) (> mode 3))
(error "Open/close code should be in the range from 0 to 3"))
(calc-pack (- -6 mode)))
2001-11-06 18:59:06 +00:00
(defun calc-keypad-execute ()
(interactive)
(let* ((prompt "Calc keystrokes: ")
(prefix nil)
keys cmd)
(save-excursion
(calc-select-buffer)
(while (progn
(setq keys (read-key-sequence prompt))
(setq cmd (key-binding keys))
(if (or (memq cmd '(calc-inverse
calc-hyperbolic
universal-argument
digit-argument
negative-argument))
(and prefix (string-match "\\`\e?[-0-9]\\'" keys)))
(progn
(setq last-command-event (aref keys (1- (length keys))))
2001-11-06 18:59:06 +00:00
(command-execute cmd)
(setq prefix t
2001-11-06 18:59:06 +00:00
prompt (concat prompt (key-description keys) " ")))
nil)))) ; skip mouse-up event
2001-11-06 18:59:06 +00:00
(message "")
(if (commandp cmd)
(command-execute cmd)
(error "Not a Calc command: %s" (key-description keys)))))
2001-11-06 18:59:06 +00:00
(provide 'calc-keypd)
2001-11-06 18:59:06 +00:00
;;; calc-keypd.el ends here