Previous: , Up: Calculator Internals   [Contents][Index] Hooks

Hooks are variables which contain Lisp functions (or lists of functions) which are called at various times. Calc defines a number of hooks that help you to customize it in various ways. Calc uses the Lisp function run-hooks to invoke the hooks shown below. Several other customization-related variables are also described here. To run code after Calc has loaded, use with-eval-after-load.

Variable: calc-start-hook

This hook is called as the last step in a M-x calc command. At this point, the Calc buffer has been created and initialized if necessary, the Calc window and trail window have been created, and the “Welcome to Calc” message has been displayed.

Variable: calc-mode-hook

This hook is called when the Calc buffer is being created. Usually this will only happen once per Emacs session. The hook is called after Emacs has switched to the new buffer, the mode-settings file has been read if necessary, and all other buffer-local variables have been set up. After this hook returns, Calc will perform a calc-refresh operation, set up the mode line display, then evaluate any deferred calc-define properties that have not been evaluated yet.

Variable: calc-trail-mode-hook

This hook is called when the Calc Trail buffer is being created. It is called as the very last step of setting up the Trail buffer. Like calc-mode-hook, this will normally happen only once per Emacs session.

Variable: calc-end-hook

This hook is called by calc-quit, generally because the user presses q or C-x * c while in Calc. The Calc buffer will be the current buffer. The hook is called as the very first step, before the Calc window is destroyed.

Variable: calc-window-hook

If this hook is non-nil, it is called to create the Calc window. Upon return, this new Calc window should be the current window. (The Calc buffer will already be the current buffer when the hook is called.) If the hook is not defined, Calc will generally use split-window, set-window-buffer, and select-window to create the Calc window.

Variable: calc-trail-window-hook

If this hook is non-nil, it is called to create the Calc Trail window. The variable calc-trail-buffer will contain the buffer which the window should use. Unlike calc-window-hook, this hook must not switch into the new window.

Variable: calc-embedded-mode-hook

This hook is called the first time that Embedded mode is entered.

Variable: calc-embedded-new-buffer-hook

This hook is called each time that Embedded mode is entered in a new buffer.

Variable: calc-embedded-new-formula-hook

This hook is called each time that Embedded mode is enabled for a new formula.

Variable: calc-edit-mode-hook

This hook is called by calc-edit (and the other “edit” commands) when the temporary editing buffer is being created. The buffer will have been selected and set up to be in calc-edit-mode, but will not yet have been filled with text. (In fact it may still have leftover text from a previous calc-edit command.)

Variable: calc-mode-save-hook

This hook is called by the calc-save-modes command, after Calc’s own mode features have been inserted into the Calc init file and just before the “End of mode settings” message is inserted.

Variable: calc-reset-hook

This hook is called after C-x * 0 (calc-reset) has reset all modes. The Calc buffer will be the current buffer.

Variable: calc-other-modes

This variable contains a list of strings. The strings are concatenated at the end of the modes portion of the Calc mode line (after standard modes such as “Deg”, “Inv” and “Hyp”). Each string should be a short, single word followed by a space. The variable is nil by default.

Variable: calc-mode-map

This is the keymap that is used by Calc mode. The best time to adjust it is probably in a calc-mode-hook. If the Calc extensions package (calc-ext.el) has not yet been loaded, many of these keys will be bound to calc-missing-key, which is a command that loads the extensions package and “retypes” the key. If your calc-mode-hook rebinds one of these keys, it will probably be overridden when the extensions are loaded.

Variable: calc-digit-map

This is the keymap that is used during numeric entry. Numeric entry uses the minibuffer, but this map binds every non-numeric key to calcDigit-nondigit which generally calls exit-minibuffer and “retypes” the key.

Variable: calc-alg-ent-map

This is the keymap that is used during algebraic entry. This is mostly a copy of minibuffer-local-map.

Variable: calc-store-var-map

This is the keymap that is used during entry of variable names for commands like calc-store and calc-recall. This is mostly a copy of minibuffer-local-completion-map.

Variable: calc-edit-mode-map

This is the (sparse) keymap used by calc-edit and other temporary editing commands. It binds RET, LFD, and C-c C-c to calc-edit-finish.

Variable: calc-mode-var-list

This is a list of variables which are saved by calc-save-modes. Each entry is a list of two items, the variable (as a Lisp symbol) and its default value. When modes are being saved, each variable is compared with its default value (using equal) and any non-default variables are written out.

Variable: calc-local-var-list

This is a list of variables which should be buffer-local to the Calc buffer. Each entry is a variable name (as a Lisp symbol). These variables also have their default values manipulated by the calc and calc-quit commands; see Multiple Calculators. Since calc-mode-hook is called after this list has been used the first time, your hook should add a variable to the list and also call make-local-variable itself.

Previous: I/O and Formatting Functions, Up: Calculator Internals   [Contents][Index]