home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-31 | 55.2 KB | 1,577 lines |
- Newsgroups: comp.sources.misc
- From: daveg@synaptics.com (David Gillespie)
- Subject: v24i078: gnucalc - GNU Emacs Calculator, v2.00, Part30/56
- Message-ID: <1991Oct31.214347.2175@sparky.imd.sterling.com>
- X-Md4-Signature: cf8d2e12ed03bc78396f03a9c004e8e0
- Date: Thu, 31 Oct 1991 21:43:47 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: daveg@synaptics.com (David Gillespie)
- Posting-number: Volume 24, Issue 78
- Archive-name: gnucalc/part30
- Environment: Emacs
- Supersedes: gmcalc: Volume 13, Issue 27-45
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file calc-yank.el continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 30; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping calc-yank.el'
- else
- echo 'x - continuing file calc-yank.el'
- sed 's/^X//' << 'SHAR_EOF' >> 'calc-yank.el' &&
- X (setq calc-edit-handler handler)
- X (make-local-variable 'calc-restore-trail)
- X (setq calc-restore-trail (get-buffer-window (calc-trail-buffer)))
- X (make-local-variable 'calc-allow-ret)
- X (setq calc-allow-ret allow-ret)
- X (erase-buffer)
- X (insert (or title title "Calc Edit Mode")
- X ". Press "
- X (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch)
- X "M-# M-# or C-c C-c"
- X (if allow-ret "C-c C-c" "RET"))
- X " to finish, "
- X (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch)
- X "M-# x"
- X "C-x k RET")
- X " to cancel.\n"))
- )
- (put 'calc-edit-mode 'mode-class 'special)
- X
- (defun calc-show-edit-buffer ()
- X (let ((buf (current-buffer)))
- X (if (and (one-window-p t) pop-up-windows)
- X (pop-to-buffer (get-buffer-create "*Calc Edit*"))
- X (and calc-embedded-info (get-buffer-window (aref calc-embedded-info 1))
- X (select-window (get-buffer-window (aref calc-embedded-info 1))))
- X (switch-to-buffer (get-buffer-create "*Calc Edit*")))
- X (setq calc-return-buffer buf)
- X (if (and (< (window-width) (screen-width))
- X calc-display-trail)
- X (let ((win (get-buffer-window (calc-trail-buffer))))
- X (if win
- X (delete-window win))))
- X (set-buffer-modified-p nil)
- X (goto-char (point-min))
- X (forward-line 1))
- )
- X
- (defun calc-edit-return ()
- X (interactive)
- X (if (and (boundp 'calc-allow-ret) calc-allow-ret)
- X (newline)
- X (calc-edit-finish))
- )
- X
- (defun calc-edit-finish (&optional keep)
- X "Finish calc-edit mode. Parse buffer contents and push them on the stack."
- X (interactive "P")
- X (message "Working...")
- X (or (and (boundp 'calc-original-buffer)
- X (boundp 'calc-return-buffer)
- X (boundp 'calc-one-window)
- X (boundp 'calc-edit-handler)
- X (boundp 'calc-restore-trail)
- X (eq major-mode 'calc-edit-mode))
- X (error "This command is valid only in buffers created by calc-edit."))
- X (let ((buf (current-buffer))
- X (original calc-original-buffer)
- X (return calc-return-buffer)
- X (one-window calc-one-window)
- X (disp-trail calc-restore-trail))
- X (save-excursion
- X (if (or (null (buffer-name original))
- X (progn
- X (set-buffer original)
- X (not (eq major-mode 'calc-mode))))
- X (error "Original calculator buffer has been corrupted.")))
- X (goto-char (point-min))
- X (if (looking-at "Calc Edit\\|Editing ")
- X (forward-line 1))
- X (if (buffer-modified-p)
- X (eval calc-edit-handler))
- X (if one-window
- X (delete-window))
- X (if (get-buffer-window return)
- X (select-window (get-buffer-window return))
- X (switch-to-buffer return))
- X (if keep
- X (bury-buffer buf)
- X (kill-buffer buf))
- X (if disp-trail
- X (calc-wrapper
- X (calc-trail-display 1 t)))
- X (message ""))
- )
- X
- (defun calc-edit-cancel ()
- X "Cancel calc-edit mode. Ignore the Calc Edit buffer and don't change stack."
- X (interactive)
- X (let ((calc-edit-handler nil))
- X (calc-edit-finish))
- X (message "(Cancelled)")
- )
- X
- (defun calc-finish-stack-edit (num)
- X (let ((buf (current-buffer))
- X (str (buffer-substring (point) (point-max)))
- X (start (point))
- X pos)
- X (if (and (integerp num) (> num 1))
- X (while (setq pos (string-match "\n." str))
- X (aset str pos ?\,)))
- X (switch-to-buffer calc-original-buffer)
- X (let ((vals (let ((calc-language nil)
- X (math-expr-opers math-standard-opers))
- X (and (string-match "[^\n\t ]" str)
- X (math-read-exprs str)))))
- X (if (eq (car-safe vals) 'error)
- X (progn
- X (switch-to-buffer buf)
- X (goto-char (+ start (nth 1 vals)))
- X (error (nth 2 vals))))
- X (calc-wrapper
- X (if (symbolp num)
- X (progn
- X (set num (car vals))
- X (calc-refresh-evaltos num))
- X (if disp-trail
- X (calc-trail-display 1 t))
- X (and vals
- X (if (>= num 0)
- X (calc-enter-result num "edit" vals)
- X (calc-enter-result 1 "edit" vals (- num))))))))
- )
- X
- X
- X
- X
- SHAR_EOF
- echo 'File calc-yank.el is complete' &&
- chmod 0644 calc-yank.el ||
- echo 'restore of calc-yank.el failed'
- Wc_c="`wc -c < 'calc-yank.el'`"
- test 17330 -eq "$Wc_c" ||
- echo 'calc-yank.el: original size 17330, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= macedit.el ==============
- if test -f 'macedit.el' -a X"$1" != X"-c"; then
- echo 'x - skipping macedit.el (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting macedit.el (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'macedit.el' &&
- ;; Keyboard macro editor for GNU Emacs. Version 1.05.
- ;; Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- ;; Written by Dave Gillespie, daveg@csvax.cs.caltech.edu.
- X
- ;; This file is part of GNU Emacs.
- X
- ;; GNU Emacs is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY. No author or distributor
- ;; accepts responsibility to anyone for the consequences of using it
- ;; or for whether it serves any particular purpose or works at all,
- ;; unless he says so in writing. Refer to the GNU Emacs General Public
- ;; License for full details.
- X
- ;; Everyone is granted permission to copy, modify and redistribute
- ;; GNU Emacs, but only under the conditions described in the
- ;; GNU Emacs General Public License. A copy of this license is
- ;; supposed to have been given to you along with GNU Emacs so you
- ;; can know your rights and responsibilities. It should be in a
- ;; file named COPYING. Among other things, the copyright notice
- ;; and this notice must be preserved on all copies.
- X
- ;; Installation:
- ;; (autoload 'edit-kbd-macro "macedit" "Edit a named keyboard macro" t)
- ;; (autoload 'edit-last-kbd-macro "macedit" "Edit a keyboard macro" t)
- ;; (autoload 'read-kbd-macro "macedit" "Parse region as keyboard macro" t)
- X
- X
- X
- ;; To use, type `M-x edit-last-kbd-macro' to edit the most recently
- ;; defined keyboard macro. If you have used `M-x name-last-kbd-macro'
- ;; to give a keyboard macro a name, type `M-x edit-kbd-macro' to edit
- ;; the macro by name. When you are done editing, type `C-c C-c' to
- ;; record your changes back into the original keyboard macro.
- X
- X
- X
- X
- ;;; The user-level commands for editing macros.
- X
- ;;;###autoload
- (defun edit-last-kbd-macro (&optional prefix buffer hook)
- X "Edit the most recently defined keyboard macro."
- X (interactive "P")
- X (MacEdit-edit-macro last-kbd-macro
- X (function (lambda (x arg) (setq last-kbd-macro x)))
- X prefix buffer hook)
- )
- X
- ;;;###autoload
- (defun edit-kbd-macro (cmd &optional prefix buffer hook in-hook out-hook)
- X "Edit a keyboard macro which has been assigned a name by name-last-kbd-macro.
- \(See also edit-last-kbd-macro.)"
- X (interactive "CCommand name: \nP")
- X (and cmd
- X (MacEdit-edit-macro (if in-hook
- X (funcall in-hook cmd)
- X (symbol-function cmd))
- X (or out-hook
- X (list 'lambda '(x arg)
- X (list 'fset
- X (list 'quote cmd)
- X 'x)))
- X prefix buffer hook cmd))
- )
- X
- ;;;###autoload
- (defun read-kbd-macro (start &optional end)
- X "Read the region as a keyboard macro definition.
- The region is interpreted as spelled-out keystrokes, e.g., `M-x abc RET'.
- The resulting macro is installed as the \"current\" keyboard macro.
- X
- Symbols: RET, SPC, TAB, DEL, LFD, NUL; C-key; M-key. (Must be uppercase.)
- X REM marks the rest of a line as a comment.
- X Whitespace is ignored; other characters are copied into the macro."
- X (interactive "r")
- X (if (stringp start)
- X (setq last-kbd-macro (MacEdit-parse-keys start))
- X (setq last-kbd-macro (MacEdit-parse-keys (buffer-substring start end)))
- X (if (and (string-match "\\`\C-x(" last-kbd-macro)
- X (string-match "\C-x)\\'" last-kbd-macro))
- X (setq last-kbd-macro (substring last-kbd-macro 2 -2))))
- )
- X
- X
- X
- X
- ;;; Formatting a keyboard macro as human-readable text.
- X
- (defun MacEdit-print-macro (macro-str local-map)
- X (let ((save-map (current-local-map))
- X (print-escape-newlines t)
- X key-symbol key-str key-last prefix-arg this-prefix)
- X (unwind-protect
- X (progn
- X (use-local-map local-map)
- X (while (MacEdit-peek-char)
- X (MacEdit-read-key)
- X (setq this-prefix prefix-arg)
- X (or (memq key-symbol '(digit-argument
- X negative-argument
- X universal-argument))
- X (null prefix-arg)
- X (progn
- X (cond ((consp prefix-arg)
- X (insert (format "prefix-arg (%d)\n"
- X (car prefix-arg))))
- X ((eq prefix-arg '-)
- X (insert "prefix-arg -\n"))
- X ((numberp prefix-arg)
- X (insert (format "prefix-arg %d\n" prefix-arg))))
- X (setq prefix-arg nil)))
- X (cond ((null key-symbol)
- X (insert "type \"")
- X (MacEdit-insert-string macro-str)
- X (insert "\"\n")
- X (setq macro-str ""))
- X ((stringp key-symbol) ; key defined by another kbd macro
- X (insert "type \"")
- X (MacEdit-insert-string key-symbol)
- X (insert "\"\n"))
- X ((eq key-symbol 'digit-argument)
- X (MacEdit-prefix-arg key-last nil prefix-arg))
- X ((eq key-symbol 'negative-argument)
- X (MacEdit-prefix-arg ?- nil prefix-arg))
- X ((eq key-symbol 'universal-argument)
- X (let* ((c-u 4) (argstartchar key-last)
- X (char (MacEdit-read-char)))
- X (while (= char argstartchar)
- X (setq c-u (* 4 c-u)
- X char (MacEdit-read-char)))
- X (MacEdit-prefix-arg char c-u nil)))
- X ((eq key-symbol 'self-insert-command)
- X (insert "insert ")
- X (if (and (>= key-last 32) (<= key-last 126))
- X (let ((str ""))
- X (while (or (and (eq key-symbol
- X 'self-insert-command)
- X (< (length str) 60)
- X (>= key-last 32)
- X (<= key-last 126))
- X (and (memq key-symbol
- X '(backward-delete-char
- X delete-backward-char
- X backward-delete-char-untabify))
- X (> (length str) 0)))
- X (if (eq key-symbol 'self-insert-command)
- X (setq str (concat str
- X (char-to-string key-last)))
- X (setq str (substring str 0 -1)))
- X (MacEdit-read-key))
- X (insert "\"" str "\"\n")
- X (MacEdit-unread-chars key-str))
- X (insert "\"")
- X (MacEdit-insert-string (char-to-string key-last))
- X (insert "\"\n")))
- X ((and (eq key-symbol 'quoted-insert)
- X (MacEdit-peek-char))
- X (insert "quoted-insert\n")
- X (let ((ch (MacEdit-read-char))
- X ch2)
- X (if (and (>= ch ?0) (<= ch ?7))
- X (progn
- X (setq ch (- ch ?0)
- X ch2 (MacEdit-read-char))
- X (if ch2
- X (if (and (>= ch2 ?0) (<= ch2 ?7))
- X (progn
- X (setq ch (+ (* ch 8) (- ch2 ?0))
- X ch2 (MacEdit-read-char))
- X (if ch2
- X (if (and (>= ch2 ?0) (<= ch2 ?7))
- X (setq ch (+ (* ch 8) (- ch2 ?0)))
- X (MacEdit-unread-chars ch2))))
- X (MacEdit-unread-chars ch2)))))
- X (if (or (and (>= ch ?0) (<= ch ?7))
- X (< ch 32) (> ch 126))
- X (insert (format "type \"\\%03o\"\n" ch))
- X (insert "type \"" (char-to-string ch) "\"\n"))))
- X ((memq key-symbol '(isearch-forward
- X isearch-backward
- X isearch-forward-regexp
- X isearch-backward-regexp))
- X (insert (symbol-name key-symbol) "\n")
- X (MacEdit-isearch-argument))
- X ((eq key-symbol 'execute-extended-command)
- X (MacEdit-read-argument obarray 'commandp))
- X (t
- X (let ((cust (get key-symbol 'MacEdit-print)))
- X (if cust
- X (funcall cust)
- X (insert (symbol-name key-symbol))
- X (indent-to 30)
- X (insert " # ")
- X (MacEdit-insert-string key-str)
- X (insert "\n")
- X (let ((int (MacEdit-get-interactive key-symbol)))
- X (if (string-match "\\`\\*" int)
- X (setq int (substring int 1)))
- X (while (> (length int) 0)
- X (cond ((= (aref int 0) ?a)
- X (MacEdit-read-argument
- X obarray nil))
- X ((memq (aref int 0) '(?b ?B ?D ?f ?F ?n
- X ?s ?S ?x ?X))
- X (MacEdit-read-argument))
- X ((and (= (aref int 0) ?c)
- X (MacEdit-peek-char))
- X (insert "type \"")
- X (MacEdit-insert-string
- X (char-to-string
- X (MacEdit-read-char)))
- X (insert "\"\n"))
- X ((= (aref int 0) ?C)
- X (MacEdit-read-argument
- X obarray 'commandp))
- X ((= (aref int 0) ?k)
- X (MacEdit-read-key)
- X (if key-symbol
- X (progn
- X (insert "type \"")
- X (MacEdit-insert-string key-str)
- X (insert "\"\n"))
- X (MacEdit-unread-chars key-str)))
- X ((= (aref int 0) ?N)
- X (or this-prefix
- X (MacEdit-read-argument)))
- X ((= (aref int 0) ?v)
- X (MacEdit-read-argument
- X obarray 'user-variable-p)))
- X (let ((nl (string-match "\n" int)))
- X (setq int (if nl
- X (substring int (1+ nl))
- X "")))))))))))
- X (use-local-map save-map)))
- )
- X
- (defun MacEdit-prefix-arg (char c-u value)
- X (let ((sign 1))
- X (if (and (numberp value) (< value 0))
- X (setq sign -1 value (- value)))
- X (if (eq value '-)
- X (setq sign -1 value nil))
- X (while (and char (= ?- char))
- X (setq sign (- sign) c-u nil)
- X (setq char (MacEdit-read-char)))
- X (while (and char (>= char ?0) (<= char ?9))
- X (setq value (+ (* (if (numberp value) value 0) 10) (- char ?0)) c-u nil)
- X (setq char (MacEdit-read-char)))
- X (setq prefix-arg
- X (cond (c-u (list c-u))
- X ((numberp value) (* value sign))
- X ((= sign -1) '-)))
- X (MacEdit-unread-chars char))
- )
- X
- (defun MacEdit-insert-string (str)
- X (let ((i 0) j ch)
- X (while (< i (length str))
- X (if (and (> (setq ch (aref str i)) 127)
- X (< ch 160))
- X (progn
- X (setq ch (- ch 128))
- X (insert "\\M-")))
- X (if (< ch 32)
- X (cond ((= ch 8) (insert "\\b"))
- X ((= ch 9) (insert "\\t"))
- X ((= ch 10) (insert "\\n"))
- X ((= ch 13) (insert "\\r"))
- X ((= ch 27) (insert "\\e"))
- X (t (insert "\\C-" (char-to-string (downcase (+ ch 64))))))
- X (if (< ch 127)
- X (if (or (= ch 34) (= ch 92))
- X (insert "\\" (char-to-string ch))
- X (setq j i)
- X (while (and (< (setq i (1+ i)) (length str))
- X (>= (setq ch (aref str i)) 32)
- X (/= ch 34) (/= ch 92)
- X (< ch 127)))
- X (insert (substring str j i))
- X (setq i (1- i)))
- X (if (memq ch '(127 255))
- X (insert (format "\\%03o" ch))
- X (insert "\\M-" (char-to-string (- ch 128))))))
- X (setq i (1+ i))))
- )
- X
- (defun MacEdit-lookup-key (map)
- X (let ((loc (and map (lookup-key map macro-str)))
- X (glob (lookup-key (current-global-map) macro-str))
- X (loc-str macro-str)
- X (glob-str macro-str))
- X (and (integerp loc)
- X (setq loc-str (substring macro-str 0 loc)
- X loc (lookup-key map loc-str)))
- X (and (consp loc)
- X (setq loc nil))
- X (or loc
- X (setq loc-str ""))
- X (and (integerp glob)
- X (setq glob-str (substring macro-str 0 glob)
- X glob (lookup-key (current-global-map) glob-str)))
- X (and (consp glob)
- X (setq glob nil))
- X (or glob
- X (setq glob-str ""))
- X (if (> (length glob-str) (length loc-str))
- X (setq key-symbol glob
- X key-str glob-str)
- X (setq key-symbol loc
- X key-str loc-str))
- X (setq key-last (and (> (length key-str) 0)
- X (logand (aref key-str (1- (length key-str))) 127)))
- X key-symbol)
- )
- X
- (defun MacEdit-read-argument (&optional obarray pred) ;; currently ignored
- X (let ((str "")
- X (min-bsp 0)
- X (exec (eq key-symbol 'execute-extended-command))
- X str-base)
- X (while (progn
- X (MacEdit-lookup-key (current-global-map))
- X (or (and (eq key-symbol 'self-insert-command)
- X (< (length str) 60))
- X (memq key-symbol
- X '(backward-delete-char
- X delete-backward-char
- X backward-delete-char-untabify))
- X (eq key-last 9)))
- X (setq macro-str (substring macro-str (length key-str)))
- X (or (and (eq key-last 9)
- X obarray
- X (let ((comp (try-completion str obarray pred)))
- X (and (stringp comp)
- X (> (length comp) (length str))
- X (setq str comp))))
- X (if (or (eq key-symbol 'self-insert-command)
- X (and (or (eq key-last 9)
- X (<= (length str) min-bsp))
- X (setq min-bsp (+ (length str) (length key-str)))))
- X (setq str (concat str key-str))
- X (setq str (substring str 0 -1)))))
- X (setq str-base str
- X str (concat str key-str)
- X macro-str (substring macro-str (length key-str)))
- X (if exec
- X (let ((comp (try-completion str-base obarray pred)))
- X (if (if (stringp comp)
- X (and (commandp (intern comp))
- X (setq str-base comp))
- X (commandp (intern str-base)))
- X (insert str-base "\n")
- X (insert "execute-extended-command\n")
- X (insert "type \"")
- X (MacEdit-insert-string str)
- X (insert "\"\n")))
- X (if (> (length str) 0)
- X (progn
- X (insert "type \"")
- X (MacEdit-insert-string str)
- X (insert "\"\n")))))
- )
- X
- (defun MacEdit-isearch-argument ()
- X (let ((str "")
- X (min-bsp 0)
- X ch)
- X (while (and (setq ch (MacEdit-read-char))
- X (or (<= ch 127) (not search-exit-option))
- X (not (eq ch search-exit-char))
- X (or (eq ch search-repeat-char)
- X (eq ch search-reverse-char)
- X (eq ch search-delete-char)
- X (eq ch search-yank-word-char)
- X (eq ch search-yank-line-char)
- X (eq ch search-quote-char)
- X (eq ch ?\r)
- X (eq ch ?\t)
- X (not search-exit-option)
- X (and (/= ch 127) (>= ch 32))))
- X (if (and (eq ch search-quote-char)
- X (MacEdit-peek-char))
- X (setq str (concat str (char-to-string ch)
- X (char-to-string (MacEdit-read-char)))
- X min-bsp (length str))
- X (if (or (and (< ch 127) (>= ch 32))
- X (eq ch search-yank-word-char)
- X (eq ch search-yank-line-char)
- X (and (or (not (eq ch search-delete-char))
- X (<= (length str) min-bsp))
- X (setq min-bsp (1+ (length str)))))
- X (setq str (concat str (char-to-string ch)))
- X (setq str (substring str 0 -1)))))
- X (if (eq ch search-exit-char)
- X (if (= (length str) 0) ;; non-incremental search
- X (progn
- X (setq str (concat str (char-to-string ch)))
- X (and (eq (MacEdit-peek-char) ?\C-w)
- X (progn
- X (setq str (concat str "\C-w"))
- X (MacEdit-read-char)))
- X (if (> (length str) 0)
- X (progn
- X (insert "type \"")
- X (MacEdit-insert-string str)
- X (insert "\"\n")))
- X (MacEdit-read-argument)
- X (setq str "")))
- X (MacEdit-unread-chars ch))
- X (if (> (length str) 0)
- X (progn
- X (insert "type \"")
- X (MacEdit-insert-string str)
- X (insert "\\e\"\n"))))
- )
- X
- ;;; Get the next keystroke-sequence from the input stream.
- ;;; Sets key-symbol, key-str, and key-last as a side effect.
- (defun MacEdit-read-key ()
- X (MacEdit-lookup-key (current-local-map))
- X (and key-symbol
- X (setq macro-str (substring macro-str (length key-str))))
- )
- X
- (defun MacEdit-peek-char ()
- X (and (> (length macro-str) 0)
- X (aref macro-str 0))
- )
- X
- (defun MacEdit-read-char ()
- X (and (> (length macro-str) 0)
- X (prog1
- X (aref macro-str 0)
- X (setq macro-str (substring macro-str 1))))
- )
- X
- (defun MacEdit-unread-chars (chars)
- X (and (integerp chars)
- X (setq chars (char-to-string chars)))
- X (and chars
- X (setq macro-str (concat chars macro-str)))
- )
- X
- (defun MacEdit-dump (mac)
- X (set-mark-command nil)
- X (insert "\n\n")
- X (MacEdit-print-macro mac (current-local-map))
- )
- X
- X
- X
- ;;; Parse a string of spelled-out keystrokes, as produced by key-description.
- X
- (defun MacEdit-parse-keys (str)
- X (let ((pos 0)
- X (mac "")
- X part)
- X (while (and (< pos (length str))
- X (string-match "[^ \t\n]+" str pos))
- X (setq pos (match-end 0)
- X part (substring str (match-beginning 0) (match-end 0))
- X mac (concat mac
- X (if (and (> (length part) 2)
- X (= (aref part 1) ?-)
- X (= (aref part 0) ?M))
- X (progn
- X (setq part (substring part 2))
- X "\e")
- X (if (and (> (length part) 4)
- X (= (aref part 0) ?C)
- X (= (aref part 1) ?-)
- X (= (aref part 2) ?M)
- X (= (aref part 3) ?-))
- X (progn
- X (setq part (concat "C-" (substring part 4)))
- X "\e")
- X ""))
- X (or (cdr (assoc part '( ( "NUL" . "\0" )
- X ( "RET" . "\r" )
- X ( "LFD" . "\n" )
- X ( "TAB" . "\t" )
- X ( "ESC" . "\e" )
- X ( "SPC" . " " )
- X ( "DEL" . "\177" )
- X ( "C-?" . "\177" )
- X ( "C-2" . "\0" )
- X ( "C-SPC" . "\0") )))
- X (and (equal part "REM")
- X (setq pos (or (string-match "\n" str pos)
- X (length str)))
- X "")
- X (and (= (length part) 3)
- X (= (aref part 0) ?C)
- X (= (aref part 1) ?-)
- X (char-to-string (logand (aref part 2) 31)))
- X part))))
- X mac)
- )
- X
- X
- X
- X
- ;;; Parse a keyboard macro description in MacEdit-print-macro's format.
- X
- (defun MacEdit-read-macro (&optional map)
- X (or map (setq map (current-local-map)))
- X (let ((macro-str ""))
- X (while (not (progn
- X (skip-chars-forward " \t\n")
- X (eobp)))
- X (cond ((looking-at "#")) ;; comment
- X ((looking-at "prefix-arg[ \t]*-[ \t]*\n")
- X (MacEdit-append-chars "\C-u-"))
- X ((looking-at "prefix-arg[ \t]*\\(-?[0-9]+\\)[ \t]*\n")
- X (MacEdit-append-chars (concat "\C-u" (MacEdit-match-string 1))))
- X ((looking-at "prefix-arg[ \t]*(\\([0-9]+\\))[ \t]*\n")
- X (let ((val (string-to-int (MacEdit-match-string 1))))
- X (while (> val 1)
- X (or (= (% val 4) 0)
- X (error "Bad prefix argument value"))
- X (MacEdit-append-chars "\C-u")
- X (setq val (/ val 4)))))
- X ((looking-at "prefix-arg")
- X (error "Bad prefix argument syntax"))
- X ((looking-at "insert ")
- X (forward-char 7)
- X (MacEdit-append-chars (read (current-buffer)))
- X (if (< (current-column) 7)
- X (forward-line -1)))
- X ((looking-at "type ")
- X (forward-char 5)
- X (MacEdit-append-chars (read (current-buffer)))
- X (if (< (current-column) 5)
- X (forward-line -1)))
- X ((looking-at "keys \\(.*\\)\n")
- X (goto-char (1- (match-end 0)))
- X (MacEdit-append-chars (MacEdit-parse-keys
- X (buffer-substring (match-beginning 1)
- X (match-end 1)))))
- X ((looking-at "\\([-a-zA-z0-9_]+\\)[ \t]*\\(.*\\)\n")
- X (let* ((func (intern (MacEdit-match-string 1)))
- X (arg (MacEdit-match-string 2))
- X (cust (get func 'MacEdit-read)))
- X (if cust
- X (funcall cust arg)
- X (or (commandp func)
- X (error "Not an Emacs command"))
- X (or (equal arg "")
- X (string-match "\\`#" arg)
- X (error "Unexpected argument to command"))
- X (let ((keys
- X (or (where-is-internal func map t)
- X (where-is-internal func (current-global-map) t))))
- X (if keys
- X (MacEdit-append-chars keys)
- X (MacEdit-append-chars (concat "\ex"
- X (symbol-name func)
- X "\n")))))))
- X (t (error "Syntax error")))
- X (forward-line 1))
- X macro-str)
- )
- X
- (defun MacEdit-append-chars (chars)
- X (setq macro-str (concat macro-str chars))
- )
- X
- (defun MacEdit-match-string (n)
- X (if (match-beginning n)
- X (buffer-substring (match-beginning n) (match-end n))
- X "")
- )
- X
- X
- X
- (defun MacEdit-get-interactive (func)
- X (if (symbolp func)
- X (let ((cust (get func 'MacEdit-interactive)))
- X (if cust
- X cust
- X (MacEdit-get-interactive (symbol-function func))))
- X (or (and (eq (car-safe func) 'lambda)
- X (let ((int (if (consp (nth 2 func))
- X (nth 2 func)
- X (nth 3 func))))
- X (and (eq (car-safe int) 'interactive)
- X (stringp (nth 1 int))
- X (nth 1 int))))
- X ""))
- )
- X
- (put 'search-forward 'MacEdit-interactive "s")
- (put 'search-backward 'MacEdit-interactive "s")
- (put 'word-search-forward 'MacEdit-interactive "s")
- (put 'word-search-backward 'MacEdit-interactive "s")
- (put 're-search-forward 'MacEdit-interactive "s")
- (put 're-search-backward 'MacEdit-interactive "s")
- (put 'switch-to-buffer 'MacEdit-interactive "B")
- (put 'kill-buffer 'MacEdit-interactive "B")
- (put 'rename-buffer 'MacEdit-interactive "B\nB")
- (put 'goto-char 'MacEdit-interactive "N")
- (put 'global-set-key 'MacEdit-interactive "k\nC")
- (put 'global-unset-key 'MacEdit-interactive "k")
- (put 'local-set-key 'MacEdit-interactive "k\nC")
- (put 'local-unset-key 'MacEdit-interactive "k")
- X
- ;;; Think about kbd-macro-query
- X
- X
- X
- ;;; Edit a keyboard macro in another buffer.
- ;;; (Prefix argument is currently ignored.)
- X
- (defun MacEdit-edit-macro (mac repl &optional prefix buffer hook arg)
- X (or (stringp mac)
- X (error "Not a keyboard macro"))
- X (let ((oldbuf (current-buffer))
- X (from-calc (and (get-buffer-window "*Calculator*")
- X (eq (lookup-key (current-global-map) "\e#")
- X 'calc-dispatch)))
- X (local (current-local-map))
- X (buf (get-buffer-create (or buffer "*Edit Macro*"))))
- X (set-buffer buf)
- X (kill-all-local-variables)
- X (use-local-map MacEdit-mode-map)
- X (setq buffer-read-only nil)
- X (setq major-mode 'MacEdit-mode)
- X (setq mode-name "Edit Macro")
- X (make-local-variable 'MacEdit-original-buffer)
- X (setq MacEdit-original-buffer oldbuf)
- X (make-local-variable 'MacEdit-replace-function)
- X (setq MacEdit-replace-function repl)
- X (make-local-variable 'MacEdit-replace-argument)
- X (setq MacEdit-replace-argument arg)
- X (make-local-variable 'MacEdit-finish-hook)
- X (setq MacEdit-finish-hook hook)
- X (erase-buffer)
- X (insert "# Keyboard Macro Editor. Press "
- X (if from-calc "M-# M-#" "C-c C-c")
- X " to finish; press "
- X (if from-calc "M-# x" "C-x k RET")
- X " to cancel.\n")
- X (insert "# Original keys: " (key-description mac) "\n\n")
- X (message "Formatting keyboard macro...")
- X (MacEdit-print-macro mac local)
- X (switch-to-buffer buf)
- X (goto-char (point-min))
- X (forward-line 3)
- X (recenter '(4))
- X (set-buffer-modified-p nil)
- X (message "Formatting keyboard macro...done")
- X (run-hooks 'MacEdit-format-hook))
- )
- X
- (defun MacEdit-finish-edit ()
- X (interactive)
- X (or (and (boundp 'MacEdit-original-buffer)
- X (boundp 'MacEdit-replace-function)
- X (boundp 'MacEdit-replace-argument)
- X (boundp 'MacEdit-finish-hook)
- X (eq major-mode 'MacEdit-mode))
- X (error "This command is valid only in buffers created by edit-kbd-macro."))
- X (let ((buf (current-buffer))
- X (str (buffer-string))
- X (func MacEdit-replace-function)
- X (arg MacEdit-replace-argument)
- X (hook MacEdit-finish-hook))
- X (goto-char (point-min))
- X (and (buffer-modified-p)
- X func
- X (progn
- X (message "Compiling keyboard macro...")
- X (run-hooks 'MacEdit-compile-hook)
- X (let ((mac (MacEdit-read-macro
- X (and (buffer-name MacEdit-original-buffer)
- X (save-excursion
- X (set-buffer MacEdit-original-buffer)
- X (current-local-map))))))
- X (and (buffer-name MacEdit-original-buffer)
- X (switch-to-buffer MacEdit-original-buffer))
- X (funcall func mac arg))
- X (message "Compiling keyboard macro...done")))
- X (kill-buffer buf)
- X (if hook
- X (funcall hook arg)))
- )
- X
- (defun MacEdit-cancel-edit ()
- X (interactive)
- X (if (eq major-mode 'MacEdit-mode)
- X (set-buffer-modified-p nil))
- X (MacEdit-finish-edit)
- X (message "(Cancelled)")
- )
- X
- (defun MacEdit-mode ()
- X "Keyboard Macro Editing mode. Press C-c C-c to save and exit.
- To abort the edit, just kill this buffer with C-x k RET.
- X
- The keyboard macro is represented as a series of M-x style command names.
- Keystrokes which do not correspond to simple M-x commands are written as
- \"type\" commands. When you press C-c C-c, MacEdit converts each command
- back into a suitable keystroke sequence; \"type\" commands are converted
- directly back into keystrokes."
- X (interactive)
- X (error "This mode can be enabled only by edit-kbd-macro or edit-last-kbd-macro.")
- )
- (put 'MacEdit-mode 'mode-class 'special)
- X
- (defvar MacEdit-mode-map nil)
- (if MacEdit-mode-map
- X ()
- X (setq MacEdit-mode-map (make-sparse-keymap))
- X (define-key MacEdit-mode-map "\C-c\C-c" 'MacEdit-finish-edit)
- )
- X
- SHAR_EOF
- chmod 0644 macedit.el ||
- echo 'restore of macedit.el failed'
- Wc_c="`wc -c < 'macedit.el'`"
- test 22571 -eq "$Wc_c" ||
- echo 'macedit.el: original size 22571, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= calc.texinfo ==============
- if test -f 'calc.texinfo' -a X"$1" != X"-c"; then
- echo 'x - skipping calc.texinfo (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting calc.texinfo (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'calc.texinfo' &&
- \input texinfo @c -*-texinfo-*-
- @comment %**start of header (This is for running Texinfo on a region.)
- @c smallbook
- @setfilename calc.info
- @c [title]
- @settitle GNU Emacs Calc 2.00 Manual
- @setchapternewpage odd
- @comment %**end of header (This is for running Texinfo on a region.)
- X
- @tex
- % Some special kludges to make TeX formatting prettier.
- % Because makeinfo.c exists, we can't just define new commands.
- % So instead, we take over little-used existing commands.
- %
- % Redefine @cite{text} to act like $text$ in regular TeX.
- % Info will typeset this same as @samp{text}.
- \gdef\goodtex{\tex \let\rm\goodrm \let\t\ttfont \turnoffactive}
- \gdef\goodrm{\fam0\tenrm}
- \gdef\cite{\goodtex$\citexxx}
- \gdef\citexxx#1{#1$\Etex}
- %
- % Redefine @i{text} to be equivalent to @cite{text}, i.e., to use math mode.
- % This looks the same in TeX but omits the surrounding ` ' in Info.
- \global\let\i=\cite
- %
- % Redefine @c{tex-stuff} \n @whatever{info-stuff}.
- \gdef\c{\futurelet\next\mycxxx}
- \gdef\mycxxx{\ifx\next\bgroup\goodtex\let\next\mycxxy\else\let\next\comment\fi\next}
- \gdef\mycxxy#1#2{#1\Etex\mycxxz}
- \gdef\mycxxz#1{}
- @end tex
- X
- @c Fix some things to make math mode work properly.
- @iftex
- @textfont0=@tenrm
- @font@teni=cmmi10 scaled @magstephalf @textfont1=@teni
- @font@seveni=cmmi7 scaled @magstephalf @scriptfont1=@seveni
- @font@fivei=cmmi5 scaled @magstephalf @scriptscriptfont1=@fivei
- @font@tensy=cmsy10 scaled @magstephalf @textfont2=@tensy
- @font@sevensy=cmsy7 scaled @magstephalf @scriptfont2=@sevensy
- @font@fivesy=cmsy5 scaled @magstephalf @scriptscriptfont2=@fivesy
- @font@tenex=cmex10 scaled @magstephalf @textfont3=@tenex
- @scriptfont3=@tenex @scriptscriptfont3=@tenex
- @textfont7=@tentt @scriptfont7=@tentt @scriptscriptfont7=@tentt
- @end iftex
- X
- @c Fix some other things specifically for this manual.
- @iftex
- @finalout
- @mathcode`@:=`@: @c Make Calc fractions come out right in math mode
- @tocindent=.5pc @c Indent subsections in table of contents less
- @rightskip=0pt plus 2pt @c Favor short lines rather than overfull hboxes
- @tex
- \gdef\trademark{${}^{\rm TM}$}
- \gdef\group{\par\vskip2pt\begingroup
- \def\Egroup{\egroup\endgroup}%
- \let\aboveenvbreak=\relax % so that nothing gets between vtop and first box
- \def\singlespace{\baselineskip=\singlespaceskip}%
- \vtop\bgroup}
- @end tex
- @ifx@turnoffactive@undefinedzzz@def@turnoffactive{}@fi
- @ifx@ninett@undefinedzzz@font@ninett=cmtt9@fi
- @catcode`@\=0 \catcode`\@=11
- \r@ggedbottomtrue
- \catcode`\@=0 @catcode`@\=@active
- @end iftex
- X
- @ifinfo
- This file documents Calc, the GNU Emacs calculator.
- X
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- X
- Permission is granted to make and distribute verbatim copies of this
- manual provided the copyright notice and this permission notice are
- preserved on all copies.
- X
- @ignore
- Permission is granted to process this file through TeX and print the
- results, provided the printed document carries copying permission notice
- identical to this one except for the removal of this paragraph (this
- paragraph not being relevant to the printed manual).
- X
- @end ignore
- Permission is granted to copy and distribute modified versions of this
- manual under the conditions for verbatim copying, provided also that the
- section entitled ``GNU General Public License'' is included exactly as
- in the original, and provided that the entire resulting derived work is
- distributed under the terms of a permission notice identical to this one.
- X
- Permission is granted to copy and distribute translations of this manual
- into another language, under the above conditions for modified versions,
- except that the section entitled ``GNU General Public License'' may be
- included in a translation approved by the author instead of in the
- original English.
- @end ifinfo
- X
- @titlepage
- @sp 6
- @center @titlefont{Calc Manual}
- @sp 4
- @center GNU Emacs Calc Version 2.00
- @c [volume]
- @sp 1
- @center October 1991
- @sp 5
- @center Dave Gillespie
- @center daveg@@synaptics.com
- @page
- X
- @vskip 0pt plus 1filll
- Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc.
- X
- Permission is granted to make and distribute verbatim copies of
- this manual provided the copyright notice and this permission notice
- are preserved on all copies.
- X
- @ignore
- Permission is granted to process this file through TeX and print the
- results, provided the printed document carries copying permission notice
- identical to this one except for the removal of this paragraph (this
- paragraph not being relevant to the printed manual).
- X
- @end ignore
- Permission is granted to copy and distribute modified versions of this
- manual under the conditions for verbatim copying, provided also that the
- section entitled ``GNU General Public License'' is included exactly as
- in the original, and provided that the entire resulting derived work is
- distributed under the terms of a permission notice identical to this one.
- X
- Permission is granted to copy and distribute translations of this manual
- into another language, under the above conditions for modified versions,
- except that the section entitled ``GNU General Public License'' may be
- included in a translation approved by the author instead of in the
- original English.
- @end titlepage
- X
- @c [begin]
- @ifinfo
- @node Top, Getting Started,, (dir)
- @ichapter The GNU Emacs Calculator
- X
- @noindent
- @dfn{Calc 2.00} is an advanced desk calculator and mathematical tool
- that runs as part of the GNU Emacs environment.
- X
- This manual is divided into three major parts: "Getting Started," the
- "Calc Tutorial," and the "Calc Reference." The Tutorial introduces all
- the major aspects of Calculator use in an easy, hands-on way. The
- remainder of the manual is a complete reference to the features of the
- Calculator.
- X
- For help in the Emacs Info system (which you are using to read this
- file), type @kbd{?}. (You can also type @kbd{h} to run through a
- longer Info tutorial.)
- X
- @end ifinfo
- @menu
- * Copying:: How you can copy and share Calc.
- X
- * Getting Started:: General description and overview.
- * Tutorial:: A step-by-step introduction for beginners.
- X
- * Introduction:: Introduction to the Calc reference manual.
- * Data Types:: Types of objects manipulated by Calc.
- * Stack and Trail:: Manipulating the stack and trail buffers.
- * Mode Settings:: Adjusting display format and other modes.
- * Arithmetic:: Basic arithmetic functions.
- * Scientific Functions:: Transcendentals and other scientific functions.
- * Matrix Functions:: Operations on vectors and matrices.
- * Algebra:: Manipulating expressions algebraically.
- * Units:: Operations on numbers with units.
- * Store and Recall:: Storing and recalling variables.
- * Graphics:: Commands for making graphs of data.
- * Kill and Yank:: Moving data into and out of Calc.
- * Embedded Mode:: Working with formulas embedded in a file.
- * Programming:: Calc as a programmable calculator.
- X
- * Installation:: Installing Calc as a part of GNU Emacs.
- * Reporting Bugs:: How to report bugs and make suggestions.
- X
- * Summary:: Summary of Calc commands and functions.
- X
- * Key Index:: The standard Calc key sequences.
- * Command Index:: The interactive Calc commands.
- * Function Index:: Functions (in algebraic formulas).
- * Concept Index:: General concepts.
- * Variable Index:: Variables used by Calc (both user and internal).
- * Lisp Function Index:: Internal Lisp math functions.
- @end menu
- X
- @node Copying, Getting Started, Top, Top
- @unnumbered GNU GENERAL PUBLIC LICENSE
- @center Version 1, February 1989
- X
- @display
- Copyright @copyright{} 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- X
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
- @end display
- X
- @unnumberedsec Preamble
- X
- X The license agreements of most software companies try to keep users
- at the mercy of those companies. By contrast, our General Public
- License is intended to guarantee your freedom to share and change free
- software---to make sure the software is free for all its users. The
- General Public License applies to the Free Software Foundation's
- software and to any other program whose authors commit to using it.
- You can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- price. Specifically, the General Public License is designed to make
- sure that you have the freedom to give away or sell copies of free
- software, that you receive source code or can get it if you want it,
- that you can change the software or use pieces of it in new free
- programs; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- anyone to deny you these rights or to ask you to surrender the rights.
- These restrictions translate to certain responsibilities for you if you
- distribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- gratis or for a fee, you must give the recipients all the rights that
- you have. You must make sure that they, too, receive or can get the
- source code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- (2) offer you this license which gives you legal permission to copy,
- distribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- that everyone understands that there is no warranty for this free
- software. If the software is modified by someone else and passed on, we
- want its recipients to know that what they have is not the original, so
- that any problems introduced by others will not reflect on the original
- authors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- modification follow.
- X
- @iftex
- @unnumberedsec TERMS AND CONDITIONS
- @end iftex
- @ifinfo
- @center TERMS AND CONDITIONS
- @end ifinfo
- X
- @enumerate
- @item
- This License Agreement applies to any program or other work which
- contains a notice placed by the copyright holder saying it may be
- distributed under the terms of this General Public License. The
- ``Program'', below, refers to any such program or work, and a ``work based
- on the Program'' means either the Program or any work containing the
- Program or a portion of it, either verbatim or with modifications. Each
- licensee is addressed as ``you''.
- X
- @item
- You may copy and distribute verbatim copies of the Program's source
- code as you receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice and
- disclaimer of warranty; keep intact all the notices that refer to this
- General Public License and to the absence of any warranty; and give any
- other recipients of the Program a copy of this General Public License
- along with the Program. You may charge a fee for the physical act of
- transferring a copy.
- X
- @item
- You may modify your copy or copies of the Program or any portion of
- it, and copy and distribute such modifications under the terms of Paragraph
- 1 above, provided that you also do the following:
- X
- @itemize @bullet
- @item
- cause the modified files to carry prominent notices stating that
- you changed the files and the date of any change; and
- X
- @item
- cause the whole of any work that you distribute or publish, that
- in whole or in part contains the Program or any part thereof, either
- with or without modifications, to be licensed at no charge to all
- third parties under the terms of this General Public License (except
- that you may choose to grant warranty protection to some or all
- third parties, at your option).
- X
- @item
- If the modified program normally reads commands interactively when
- run, you must cause it, when started running for such interactive use
- in the simplest and most usual way, to print or display an
- announcement including an appropriate copyright notice and a notice
- that there is no warranty (or else, saying that you provide a
- warranty) and that users may redistribute the program under these
- conditions, and telling the user how to view a copy of this General
- Public License.
- X
- @item
- You may charge a fee for the physical act of transferring a
- copy, and you may at your option offer warranty protection in
- exchange for a fee.
- @end itemize
- X
- Mere aggregation of another independent work with the Program (or its
- derivative) on a volume of a storage or distribution medium does not bring
- the other work under the scope of these terms.
- X
- @item
- You may copy and distribute the Program (or a portion or derivative of
- it, under Paragraph 2) in object code or executable form under the terms of
- Paragraphs 1 and 2 above provided that you also do one of the following:
- X
- @itemize @bullet
- @item
- accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Paragraphs 1 and 2 above; or,
- X
- @item
- accompany it with a written offer, valid for at least three
- years, to give any third party free (except for a nominal charge
- for the cost of distribution) a complete machine-readable copy of the
- corresponding source code, to be distributed under the terms of
- Paragraphs 1 and 2 above; or,
- X
- @item
- accompany it with the information you received as to where the
- corresponding source code may be obtained. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form alone.)
- @end itemize
- X
- Source code for a work means the preferred form of the work for making
- modifications to it. For an executable file, complete source code means
- all the source code for all modules it contains; but, as a special
- exception, it need not include source code for modules which are standard
- libraries that accompany the operating system on which the executable
- file runs, or for standard header files or definitions files that
- accompany that operating system.
- X
- @item
- You may not copy, modify, sublicense, distribute or transfer the
- Program except as expressly provided under this General Public License.
- Any attempt otherwise to copy, modify, sublicense, distribute or transfer
- the Program is void, and will automatically terminate your rights to use
- the Program under this License. However, parties who have received
- copies, or rights to use copies, from you under this General Public
- License will not have their licenses terminated so long as such parties
- remain in full compliance.
- X
- @item
- By copying, distributing or modifying the Program (or any work based
- on the Program) you indicate your acceptance of this license to do so,
- and all its terms and conditions.
- X
- @item
- Each time you redistribute the Program (or any work based on the
- Program), the recipient automatically receives a license from the original
- licensor to copy, distribute or modify the Program subject to these
- terms and conditions. You may not impose any further restrictions on the
- recipients' exercise of the rights granted herein.
- X
- @item
- The Free Software Foundation may publish revised and/or new versions
- of the General Public License from time to time. Such new versions will
- be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
- X
- Each version is given a distinguishing version number. If the Program
- specifies a version number of the license which applies to it and ``any
- later version'', you have the option of following the terms and conditions
- either of that version or of any later version published by the Free
- Software Foundation. If the Program does not specify a version number of
- the license, you may choose any version ever published by the Free Software
- Foundation.
- X
- @item
- If you wish to incorporate parts of the Program into other free
- programs whose distribution conditions are different, write to the author
- to ask for permission. For software which is copyrighted by the Free
- Software Foundation, write to the Free Software Foundation; we sometimes
- make exceptions for this. Our decision will be guided by the two goals
- of preserving the free status of all derivatives of our free software and
- of promoting the sharing and reuse of software generally.
- X
- @iftex
- @heading NO WARRANTY
- @end iftex
- @ifinfo
- @center NO WARRANTY
- @end ifinfo
- X
- @item
- BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- REPAIR OR CORRECTION.
- X
- @item
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
- ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
- ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
- LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
- SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
- WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- @end enumerate
- X
- @node Getting Started, Tutorial, Top, Top
- @chapter Getting Started
- X
- @noindent
- This chapter provides a general overview of Calc, the GNU Emacs
- Calculator: What it is, how to start it and how to exit from it,
- and what are the various ways that it can be used.
- X
- @menu
- * What is Calc::
- * About This Manual::
- * Notations Used in This Manual::
- * Using Calc::
- * Demonstration of Calc::
- * New for Calc 2.00::
- * History and Acknowledgements::
- @end menu
- X
- @node What is Calc, About This Manual, Getting Started, Getting Started
- @section What is Calc?
- X
- @noindent
- @dfn{Calc} is an advanced calculator and mathematical tool that runs as
- part of the GNU Emacs environment. Very roughly based on the HP-28/48
- series of calculators, its many features include:
- X
- @itemize @bullet
- @item
- Choice of algebraic or RPN (stack-based) entry of calculations.
- X
- @item
- Arbitrary precision integers and floating-point numbers.
- X
- @item
- Arithmetic on rational numbers, complex numbers (rectangular and polar),
- error forms with standard deviations, open and closed intervals, vectors
- and matrices, dates and times, infinities, sets, quantities with units,
- and algebraic formulas.
- X
- @item
- Mathematical operations such as logarithms and trigonometric functions.
- X
- @item
- Programmer's features (bitwise operations, non-decimal numbers).
- X
- @item
- Financial functions such as future value and internal rate of return.
- X
- @item
- Number theoretical features such as prime factorization and arithmetic
- modulo @i{M} for any @i{M}.
- X
- @item
- Algebraic manipulation features, including symbolic calculus.
- X
- @item
- Moving data to and from regular editing buffers.
- X
- @item
- ``Embedded mode'' for manipulating Calc formulas and data directly
- inside any editing buffer.
- X
- @item
- Graphics using GNUPLOT, a versatile (and free) plotting program.
- X
- @item
- Easy programming using keyboard macros, algebraic formulas,
- algebraic rewrite rules, or extended Emacs Lisp.
- @end itemize
- X
- Calc tries to include a little something for everyone; as a result it is
- large and might be intimidating to the first-time user. If you plan to
- use Calc only as a traditional desk calculator, all you really need to
- read is the ``Getting Started'' chapter of this manual and possibly the
- first few sections of the tutorial. As you become more comfortable with
- the program you can learn its additional features. In terms of efficiency,
- scope and depth, Calc cannot replace a powerful tool like Mathematica@c{\trademark}
- @asis{ (tm)}.
- But Calc has the advantages of convenience, portability, and availability
- of the source code. And, of course, it's free!
- X
- @node About This Manual, Notations Used in This Manual, What is Calc, Getting Started
- @section About This Manual
- X
- @ifinfo
- @noindent
- This manual is divided into three major sections: The ``Getting
- Started'' chapter you are reading now, the Calc tutorial (chapter 2),
- and the Calc reference manual (the remaining chapters and appendices).
- The printed version may be in two volumes, the Tutorial and the
- Reference. If so, both volumes will include a copy of the
- ``getting started'' chapter.
- @end ifinfo
- @iftex
- @noindent
- This manual is divided into three major sections: The ``Getting
- Started'' chapter you are reading now, the Calc tutorial (chapter 2),
- and the Calc reference manual (the remaining chapters and appendices).
- @c [when-split]
- @c This manual has been printed in two volumes, the @dfn{Tutorial} and the
- @c @dfn{Reference}. Both volumes include a copy of the ``Getting Started''
- @c chapter.
- @end iftex
- X
- At the end of the present chapter is a brief ``demonstration'' which
- illustrates the major features of Calc in just a couple of pages. If
- you are in a hurry to use Calc, this will show you everything you need
- to know to begin.
- X
- The tutorial chapter walks you through the various parts of Calc
- with lots of hands-on examples and explanations. If you are new
- to Calc and you have some time, try going through at least the
- beginning of the tutorial. The tutorial includes over 50 exercises
- with answers. These exercises give you some guided practice with
- Calc, as well as pointing out some interesting and unusual ways
- to use Calc's features.
- X
- The reference section discusses Calc in complete depth. The reference
- can be read from start to finish if you want to learn every aspect
- of Calc. Or, you can look in the table of contents or the Concept
- Index to find the parts of the manual that discuss the things you
- need to know.
- X
- You can access this manual on-line at any time within Calc by
- pressing the @kbd{h i} key sequence. Outside of the Calc window,
- you can press @kbd{M-# i} to read the manual on-line. Also, you
- can jump directly to the Tutorial by pressing @kbd{h t} or @kbd{M-# t},
- or to the Summary by pressing @kbd{h s} or @kbd{M-# s}. Within Calc,
- you can also go to the part of the manual describing any Calc key,
- function, or variable using @w{@kbd{h k}}, @kbd{h f}, or @kbd{h v},
- respectively.
- X
- @node Notations Used in This Manual, Using Calc, About This Manual, Getting Started
- @section Notations Used in This Manual
- X
- @noindent
- This section describes the various notations that are used
- throughout the Calc manual.
- X
- In keystroke sequences, uppercase letters mean you must hold down
- the shift key while typing the letter. Keys pressed with Control
- held down are shown as @kbd{C-x}. Keys pressed with Meta held down
- are shown as @kbd{M-x}. Other notations are @key{RET} for the
- Return key, @key{SPC} for the space bar, @key{TAB} for the Tab key,
- @key{DEL} for the Delete key, and @key{LFD} for the Line-Feed key
- (@kbd{C-j} if you don't have this key on your keyboard).
- X
- Sometimes the @key{RET} key is not shown when it is ``obvious''
- that you must press @kbd{RET} to proceed. For example, the @key{RET}
- is usually omitted in key sequences like @kbd{M-x calc-keypad @key{RET}}.
- X
- Commands are generally shown like this: @kbd{p} (@code{calc-precision})
- or @kbd{M-# k} (@code{calc-keypad}). This means that the command is
- normally used by pressing the @kbd{p} key or @kbd{M-# k} key sequence,
- but it also has the full-name equivalent shown, e.g., @kbd{M-x calc-precision}.
- X
- Commands that correspond to functions in algebraic notation
- are written: @kbd{C} (@code{calc-cos}) [@code{cos}]. This means
- the @kbd{C} key is equivalent to @kbd{M-x calc-cos}, and that
- the corresponding function in an algebraic-style formula would
- be @samp{cos(@var{x})}.
- X
- A few commands don't have key equivalents: @code{calc-sincos}
- [@code{sincos}].@refill
- X
- @node Using Calc, Demonstration of Calc, Notations Used in This Manual, Getting Started
- @section Using Calc
- X
- @noindent
- Calc has several user interfaces that are specialized for
- different kinds of tasks. As well as Calc's standard interface,
- there are Quick Mode, Keypad Mode, and Embedded Mode.
- X
- @c [fix-ref Installation]
- Calc must be @dfn{installed} before it can be used. @xref{Installation},
- for instructions on setting up and installing Calc. We will assume
- you or someone on your system has already installed Calc as described
- there.
- X
- @menu
- * Starting Calc::
- * The Standard Interface::
- * Quick Mode Overview::
- * Keypad Mode Overview::
- * Standalone Operation::
- * Embedded Mode Overview::
- * Other M-# Commands::
- @end menu
- X
- @node Starting Calc, The Standard Interface, Using Calc, Using Calc
- @subsection Starting Calc
- X
- @noindent
- On most systems, you can type @kbd{M-#} to start the Calculator.
- The notation @kbd{M-#} is short for @kbd{@key{META}-#}. On most
- keyboards this means holding down the @key{META} (or @key{ALT}) and
- @key{SHIFT} keys while typing @kbd{3}.
- X
- @cindex META key
- If you don't have a @key{META} key on your keyboard, you can type
- @key{ESC} first, then @kbd{#}, to accomplish the same thing. If you
- don't even have an @key{ESC} key, you can fake it by holding down
- @key{CTRL} or @key{CONTROL} while typing a left square bracket
- (that's @kbd{C-[} in Emacs notation).@refill
- X
- @kbd{M-#} is a @dfn{prefix key}; when you press it, Emacs waits for
- you to press a second key to complete the command. In this case,
- you will follow @kbd{M-#} with a letter (upper- or lower-case, it
- doesn't matter for @kbd{M-#}) that says which Calc interface you
- want to use.
- X
- To get Calc's standard interface, type @kbd{M-# c}. To get
- Keypad Mode, type @kbd{M-# k}. Type @kbd{M-# ?} to get a brief
- list of the available options, and type a second @kbd{?} to get
- a complete list.
- X
- To ease typing, @kbd{M-# M-#} (or @kbd{M-# #} if that's easier)
- also works to start Calc. It starts the same interface (either
- @kbd{M-# c} or @w{@kbd{M-# k}}) that you last used, selecting the
- @kbd{M-# c} interface by default. (If your installation has
- a special function key set up to act like @kbd{M-#}, hitting that
- function key twice is just like hitting @kbd{M-# M-#}.)
- X
- If @kbd{M-#} doesn't work for you, you can always type explicit
- commands like @kbd{M-x calc} (for the standard user interface) or
- @w{@kbd{M-x calc-keypad}} (for Keypad Mode). First type @kbd{M-x}
- (that's @key{META} with the letter @kbd{x}), then, at the prompt,
- type the full command (like @kbd{calc-keypad}) and press Return.
- X
- If you type @kbd{M-x calc} and Emacs still doesn't recognize the
- command (it will say @samp{[No match]} when you try to press
- @key{RET}), then Calc has not been properly installed.
- X
- The same commands (like @kbd{M-# c} or @kbd{M-# M-#}) that start
- the Calculator also turn it off if it is already on.
- SHAR_EOF
- true || echo 'restore of calc.texinfo failed'
- fi
- echo 'End of part 30'
- echo 'File calc.texinfo is continued in part 31'
- echo 31 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-