Skip to content

kickingvegas/casual-calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTICE

This package has been superseded by the package casual. Please install the package casual from either MELPA or MELPA stable.

Upon installation and upgrade of casual, this package will be uninstalled from your Emacs configuration. Please revisit your configuration of Casual Calc in your initialization file(s) accordingly.

This repository should be treated as an archive. All future development on Casual Calc will be done in the Casual repository.

Casual Calc

An opinionated Transient-based user interface to support the casual usage of Emacs Calc.

docs/images/casual-calc-tmenu.png

Motivation

While Emacs Calc has an embarrassingly rich feature set, for many users this capability is inaccessible due the overwhelming number of keybindings used to access them. These keybindings have a steep learning curve that is quickly lost if not in constant use.

Menus are a user interface (UI) affordance that offer users discoverability and recognition. Providing a hierarchical menu UI over Calc greatly improves its casual use.

Goals

  • To provide a keyboard-driven UI to Calc that is menu based.
  • To allow users experienced with scientific calculators to casually use Calc without requiring reference to its Info manual.

Non-Goals

  • Full coverage of all Calc commands. Casual is not intended to be a power user tool.
  • Strict adherence to default Calc keybindings. Calc’s prompt-first interface resulted in a command keybinding design that embeds context in the key sequence (e.g. v for vector, b for binary). Hierarchical menus make this context implicit, allowing for key reuse in different contexts.
  • Strict adherence to Calc command naming. While Casual Calc is mostly in alignment with Calc’s command naming, there are cases where it will make an opinionated change if the name is deemed too vague or idiomatic.
  • UX Stability (for now). Given that Casual Calc is early in its life-cycle, expect changes to its user experience in terms of menu hierarchy and keybinding choices in future releases.

Asks

As Casual Calc is new, we are looking for early adopters! Your feedback is welcome as it will likely impact Casual’s evolution, particularly with regards to UI.

Requirements

Casual Calc requires usage of

  • Emacs ≥ 29.1
  • Casual Lib ≥ 1.1.0

Install

Casual Calc is available on MELPA.

If installed via list-packages then add this line to your Emacs initialization file.

(require 'casual-calc) ;; optional
(keymap-set calc-mode-map "C-o" #'casual-calc-tmenu)
(keymap-set calc-alg-map "C-o" #'casual-calc-tmenu)

If you use use-package, here is the recipe for installing it.

(use-package calc
  :defer t)

(use-package casual-calc
  :ensure nil
  :bind (:map
         calc-mode-map
         ("C-o" . casual-calc-tmenu)
         :map
         calc-alg-map
         ("C-o" . casual-calc-tmenu))
  :after (calc))

A Note on Package Dependencies

Casual Calc requires Casual Lib which in turn requires a recent installation of Transient 0.6.0+ from either ELPA or MELPA. As an older version of Transient is built-in to the Emacs release, the package manager package.el will not update this package unless the customizable variable package-install-upgrade-built-in is set to t. Set this variable and proceed with installing Casual Calc. Alternately invoking package-install with a prefix (C-u) will temporarily coerce the update of the built-in package. (example: C-u M-x package-install casual-calc)

As Transient is closely tied to Magit, installing the latest version of Magit (via non-GNU ELPA or MELPA) before installing Casual Calc can also pick up the latest version of Transient.

Usage

  1. Invoke M-x calc to launch Calc.
  2. When the point is in the Calc window, invoke C-o (or a binding of your choosing) to launch the Casual Calc interface.

Once raised, the Casual Calc interface can be dismissed via:

  • C-g to dismiss the current menu.
  • C-q to dismiss the interface completely.

For nearly all menus, algebraic entry via the ’ binding is available, as well as basic calculator operations (addition, subtraction, multiplication, division) and stack operations (pop, enter).

Common Menu Actions

Casual Calc is built using Transient menus and as such adopts much of its default behavior.

Each menu item has a key and a label. The key is what is typed by the user to select the menu item. A key can be prefixed with a meta (M-) or control (C-) key. Labels ending with a > character indicates that it will open another menu.

Dismissing a menu regardless of how deep you are in sub-menus can be done by entering C-q. A menu can also be dismissed by entering C-g, but this will return you to the parent menu.

If a mouse is available, a menu item can be selected by moving the mouse cursor over its label and pressing down button 1.

Pressing the ? key will toggle help for all the menu items. Press the key of interest to get help for it. (Note, not all menu items are documented at this time.)

Some menus have arguments (example --rate=) which you can set. You can persist these settings by typing C-x C-s.

Menu item notation The following conventions are used to denote menu items.

If the label ends with a , it is a sub-menu.

If the label ends with an , the command will prompt you for an input value.

If neither the above is in the label then the command is issued using arguments from the stack as needed.

The top of the stack is referred to as (1:), where 1 is the stack index value. Emacs Calc uses a 1-offset for sequences to be consistent with math convention.

Calc Basics

It helps to know some basics about Calc.

  • Calc is a stack-based calculator that supports both RPN and algebraic style entry.
    • By default it uses RPN entry, but this can be changed to algebraic.
  • Stack based operations are always RPN-style.
  • Undo has the keybinding U, redo is D.
  • The top of the stack is referred to as 1:
  • Calc vectors are punctuated with [ and ] (e.g. [2 3]) Matrix values are represented as vectors within a vector. For example, [[1 0] [0 1]] is a square diagonal matrix.
  • Calc vector indexes are 1-offset.
  • Intervals
    • Inclusive intervals are represented as [𝑛..𝑚], where 𝑛 < 𝑚.
    • Exclusive intervals are represented as (𝑛..𝑚), where 𝑛 < 𝑚.
    • Any combination of lower and upper bounds set to be inclusive or exclusive is supported.
  • Complex numbers are entered as (𝑟, 𝑖), where 𝑟 is the real part and 𝑖 is the imaginary.
  • Radix numbers are entered as 𝑏#𝑛 where 𝑏 is the base value and 𝑛 is the number. For example entering 2#0101 will put 5 on the stack.
  • H:M:S values are default entered as ℎ@ 𝑚” 𝑠’.
  • Org-mode active timestamps can be entered into Calc.
  • The top of the stack (1:) can be edited by pressing the ` key.
  • Entering a single quote (‘) will prompt you for an algebraic entry.

Development

For users who wish to help contribute to Casual Calc or personally customize it for their own usage, please read the developer documentation.

Sponsorship

If you enjoy using Casual Calc, consider making a modest financial contribution to help support its development and maintenance.

docs/images/default-yellow.png

See Also

Casual Calc is part of a suite of user interfaces for different Emacs packages called Casual Suite.

Different interfaces include those for I-Search, Dired, Info, Bookmarks, RE-Builder, IBuffer, and others. Learn more about them today!

Acknowledgments

A heartfelt thanks to all the contributors to Calc and Transit. Casual would not be possible without your efforts.