comparison lisp/calc/calc.el @ 58061:3f48c4fde605

(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook) (calc-load-hook): New variables. (calc, calc-trail-display, calc-mode): Removed obsolete sections. (calc-x-paste-text): Removed.
author Jay Belanger <jay.p.belanger@gmail.com>
date Tue, 09 Nov 2004 04:43:03 +0000
parents a18ff071e655
children 5fb84c291168
comparison
equal deleted inserted replaced
58060:4cbffc256922 58061:3f48c4fde605
652 calc-use-selections 652 calc-use-selections
653 calc-assoc-selections 653 calc-assoc-selections
654 calc-word-size 654 calc-word-size
655 calc-internal-prec)) 655 calc-internal-prec))
656 656
657 (defvar calc-mode-hook nil
658 "Hook run when entering calc-mode.")
659
660 (defvar calc-trail-mode-hook nil
661 "Hook run when entering calc-trail-mode.")
662
663 (defvar calc-start-hook nil
664 "Hook run when calc is started.")
665
666 (defvar calc-end-hook nil
667 "Hook run when calc is quit.")
668
669 (defvar calc-load-hook nil
670 "Hook run when calc.el is loaded.")
657 671
658 ;; Verify that Calc is running on the right kind of system. 672 ;; Verify that Calc is running on the right kind of system.
659 (defvar calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version)))) 673 (defvar calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version))))
660 674
661 ;; Set up the standard keystroke (M-#) to run the Calculator, if that key 675 ;; Set up the standard keystroke (M-#) to run the Calculator, if that key
1054 (null calc-settings-file) 1068 (null calc-settings-file)
1055 (equal calc-settings-file user-init-file) 1069 (equal calc-settings-file user-init-file)
1056 (progn 1070 (progn
1057 (setq calc-loaded-settings-file t) 1071 (setq calc-loaded-settings-file t)
1058 (load calc-settings-file t))) ; t = missing-ok 1072 (load calc-settings-file t))) ; t = missing-ok
1059 (if (and (eq window-system 'x) (boundp 'mouse-map))
1060 (substitute-key-definition 'x-paste-text 'calc-x-paste-text
1061 mouse-map))
1062 (let ((p command-line-args)) 1073 (let ((p command-line-args))
1063 (while p 1074 (while p
1064 (and (equal (car p) "-f") 1075 (and (equal (car p) "-f")
1065 (string-match "calc" (nth 1 p)) 1076 (string-match "calc" (nth 1 p))
1066 (string-match "full" (nth 1 p)) 1077 (string-match "full" (nth 1 p))
1067 (setq calc-standalone-flag t)) 1078 (setq calc-standalone-flag t))
1068 (setq p (cdr p)))) 1079 (setq p (cdr p))))
1069 (run-hooks 'calc-mode-hook) 1080 (run-hooks 'calc-mode-hook)
1070 (calc-refresh t) 1081 (calc-refresh t)
1071 (calc-set-mode-line) 1082 (calc-set-mode-line)
1072 ;; The calc-defs variable is a relic. Use calc-define properties instead.
1073 (when (and (boundp 'calc-defs)
1074 calc-defs)
1075 (message "Evaluating calc-defs...")
1076 (calc-need-macros)
1077 (eval (cons 'progn calc-defs))
1078 (setq calc-defs nil)
1079 (calc-set-mode-line))
1080 (calc-check-defines)) 1083 (calc-check-defines))
1081 1084
1082 (defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks 1085 (defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks
1083 (defun calc-check-defines () 1086 (defun calc-check-defines ()
1084 (if (symbol-plist 'calc-define) 1087 (if (symbol-plist 'calc-define)
1161 (if (or (eq full-display t) 1164 (if (or (eq full-display t)
1162 (and (null full-display) calc-full-mode)) 1165 (and (null full-display) calc-full-mode))
1163 (switch-to-buffer (current-buffer) t) 1166 (switch-to-buffer (current-buffer) t)
1164 (if (get-buffer-window (current-buffer)) 1167 (if (get-buffer-window (current-buffer))
1165 (select-window (get-buffer-window (current-buffer))) 1168 (select-window (get-buffer-window (current-buffer)))
1166 (if (and (boundp 'calc-window-hook) calc-window-hook) 1169 (let ((w (get-largest-window)))
1167 (run-hooks 'calc-window-hook) 1170 (if (and pop-up-windows
1168 (let ((w (get-largest-window))) 1171 (> (window-height w)
1169 (if (and pop-up-windows 1172 (+ window-min-height calc-window-height 2)))
1170 (> (window-height w) 1173 (progn
1171 (+ window-min-height calc-window-height 2))) 1174 (setq w (split-window w
1172 (progn 1175 (- (window-height w)
1173 (setq w (split-window w 1176 calc-window-height 2)
1174 (- (window-height w) 1177 nil))
1175 calc-window-height 2) 1178 (set-window-buffer w (current-buffer))
1176 nil)) 1179 (select-window w))
1177 (set-window-buffer w (current-buffer)) 1180 (pop-to-buffer (current-buffer))))))
1178 (select-window w))
1179 (pop-to-buffer (current-buffer)))))))
1180 (save-excursion 1181 (save-excursion
1181 (set-buffer (calc-trail-buffer)) 1182 (set-buffer (calc-trail-buffer))
1182 (and calc-display-trail 1183 (and calc-display-trail
1183 (= (window-width) (frame-width)) 1184 (= (window-width) (frame-width))
1184 (calc-trail-display 1 t))) 1185 (calc-trail-display 1 t)))
1720 (save-excursion 1721 (save-excursion
1721 (set-buffer (aref calc-embedded-info 1)) 1722 (set-buffer (aref calc-embedded-info 1))
1722 (calc-refresh align))) 1723 (calc-refresh align)))
1723 (setq calc-refresh-count (1+ calc-refresh-count))) 1724 (setq calc-refresh-count (1+ calc-refresh-count)))
1724 1725
1725
1726 (defun calc-x-paste-text (arg)
1727 "Move point to mouse position and insert window system cut buffer contents.
1728 If mouse is pressed in Calc window, push cut buffer contents onto the stack."
1729 (x-mouse-select arg)
1730 (if (memq major-mode '(calc-mode calc-trail-mode))
1731 (progn
1732 (calc-wrapper
1733 (calc-extensions)
1734 (let* ((buf (x-get-cut-buffer))
1735 (val (math-read-exprs (calc-clean-newlines buf))))
1736 (if (eq (car-safe val) 'error)
1737 (progn
1738 (setq val (math-read-exprs buf))
1739 (if (eq (car-safe val) 'error)
1740 (error "%s in yanked data" (nth 2 val)))))
1741 (calc-enter-result 0 "Xynk" val))))
1742 (x-paste-text arg)))
1743
1744
1745
1746 ;;;; The Calc Trail buffer. 1726 ;;;; The Calc Trail buffer.
1747 1727
1748 (defun calc-check-trail-aligned () 1728 (defun calc-check-trail-aligned ()
1749 (save-excursion 1729 (save-excursion
1750 (let ((win (get-buffer-window (current-buffer)))) 1730 (let ((win (get-buffer-window (current-buffer))))
1806 (let ((win (get-buffer-window (calc-trail-buffer)))) 1786 (let ((win (get-buffer-window (calc-trail-buffer))))
1807 (if (setq calc-display-trail 1787 (if (setq calc-display-trail
1808 (not (if flag (memq flag '(nil 0)) win))) 1788 (not (if flag (memq flag '(nil 0)) win)))
1809 (if (null win) 1789 (if (null win)
1810 (progn 1790 (progn
1811 (if (and (boundp 'calc-trail-window-hook) calc-trail-window-hook) 1791 (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
1812 (run-hooks 'calc-trail-window-hook) 1792 (set-window-buffer w calc-trail-buffer))
1813 (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
1814 (set-window-buffer w calc-trail-buffer)))
1815 (calc-wrapper 1793 (calc-wrapper
1816 (setq overlay-arrow-string calc-trail-overlay 1794 (setq overlay-arrow-string calc-trail-overlay
1817 overlay-arrow-position calc-trail-pointer) 1795 overlay-arrow-position calc-trail-pointer)
1818 (or no-refresh 1796 (or no-refresh
1819 (if interactive 1797 (if interactive