;;; calc-embed.el --- embed Calc in a buffer
;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;; 2005, 2006 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
-;; Maintainer: Jay Belanger <belanger@truman.edu>
+;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
;; 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.
+
;; 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.
-
-;; 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.
+;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
))
-;;; Format of calc-embedded-info vector:
-;;; 0 Editing buffer.
-;;; 1 Calculator buffer.
-;;; 2 Top of current formula (marker).
-;;; 3 Bottom of current formula (marker).
-;;; 4 Top of current formula's delimiters (marker).
-;;; 5 Bottom of current formula's delimiters (marker).
-;;; 6 String representation of current formula.
-;;; 7 Non-nil if formula is embedded within a single line.
-;;; 8 Internal representation of current formula.
-;;; 9 Variable assigned by this formula, or nil.
-;;; 10 List of variables upon which this formula depends.
-;;; 11 Evaluated value of the formula, or nil.
-;;; 12 Mode settings for current formula.
-;;; 13 Local mode settings for current formula.
-;;; 14 Permanent mode settings for current formula.
-;;; 15 Global mode settings for editing buffer.
-
-
-;;; calc-embedded-active is an a-list keyed on buffers; each cdr is a
-;;; sorted list of calc-embedded-infos in that buffer. We do this
-;;; rather than using buffer-local variables because the latter are
-;;; thrown away when a buffer changes major modes.
+;; Format of calc-embedded-info vector:
+;; 0 Editing buffer.
+;; 1 Calculator buffer.
+;; 2 Top of current formula (marker).
+;; 3 Bottom of current formula (marker).
+;; 4 Top of current formula's delimiters (marker).
+;; 5 Bottom of current formula's delimiters (marker).
+;; 6 String representation of current formula.
+;; 7 Non-nil if formula is embedded within a single line.
+;; 8 Internal representation of current formula.
+;; 9 Variable assigned by this formula, or nil.
+;; 10 List of variables upon which this formula depends.
+;; 11 Evaluated value of the formula, or nil.
+;; 12 Mode settings for current formula.
+;; 13 Local mode settings for current formula.
+;; 14 Permanent mode settings for current formula.
+;; 15 Global mode settings for editing buffer.
+
+
+;; calc-embedded-active is an a-list keyed on buffers; each cdr is a
+;; sorted list of calc-embedded-infos in that buffer. We do this
+;; rather than using buffer-local variables because the latter are
+;; thrown away when a buffer changes major modes.
(defvar calc-embedded-original-modes nil
"The mode settings for Calc buffer when put in embedded mode.")
(defvar calc-embedded-firsttime-buf)
(defvar calc-embedded-firsttime-formula)
+;; The following is to take care of any minor modes which override
+;; a Calc command.
+(defvar calc-override-minor-modes-map
+ (make-sparse-keymap)
+ "A list of keybindings that might be overwritten by minor modes.")
+
+;; Add any keys that might be overwritten here.
+(define-key calc-override-minor-modes-map "`" 'calc-edit)
+
+(defvar calc-override-minor-modes
+ (cons t calc-override-minor-modes-map))
+
(defun calc-do-embedded (calc-embed-arg end obeg oend)
(if calc-embedded-info
truncate-lines (nth 2 mode)
buffer-read-only nil)
(use-local-map (nth 1 mode))
+ (setq minor-mode-overriding-map-alist
+ (remq calc-override-minor-modes minor-mode-overriding-map-alist))
(set-buffer-modified-p (buffer-modified-p))
(calc-embedded-restore-original-modes)
(or calc-embedded-quiet
- (message "Back to %s mode" mode-name))))
+ (message "Back to %s mode" (format-mode-line mode-name)))))
(t
(if (buffer-name (aref calc-embedded-info 0))
buffer-read-only t)
(set-buffer-modified-p (buffer-modified-p))
(use-local-map calc-mode-map)
+ (setq minor-mode-overriding-map-alist
+ (cons calc-override-minor-modes
+ minor-mode-overriding-map-alist))
(setq calc-no-refresh-evaltos nil)
(and chg calc-any-evaltos (calc-wrapper (calc-refresh-evaltos)))
(let (str)
(let ((val (save-excursion
(set-buffer (aref info 1))
(let ((calc-language nil)
- (math-expr-opers math-standard-opers))
+ (math-expr-opers (math-standard-ops)))
(math-read-expr str)))))
(if (eq (car-safe val) 'error)
(progn
(aset info 8 val)
(calc-embedded-update info 14 t t))))
+;;;###autoload
(defun calc-do-embedded-activate (calc-embed-arg cbuf)
(calc-plain-buffer-only)
(if calc-embed-arg
(provide 'calc-embed)
-;;; arch-tag: 1b8f311e-fba1-40d3-b8c3-1d6f68fd26fc
+;; Local variables:
+;; generated-autoload-file: "calc-loaddefs.el"
+;; End:
+
+;; arch-tag: 1b8f311e-fba1-40d3-b8c3-1d6f68fd26fc
;;; calc-embed.el ends here