Emacs Extensions for
GE Smallworld Magik Development
Screen-casts, tutorials, and productivity tools for Magik programmers who use Emacs. From tab-mode and code folding to the Magik Debugger and object inspector — explore features built by a developer, for developers.
Learn MoreNine screen-casts published between November 2010 and January 2011 — covering everything from ECB mode to the Tree Item GUI control. Read the story behind the project →
Get in Touch
Using Avy In Emacs For Fast Magik Code Navigation
Large Magik applications can make ordinary cursor movement feel surprisingly slow. A method file may contain long declaration blocks, repeated object names, generated code, and several similar method calls. Searching with incremental search is useful, but it often requires typing an exact fragment and then checking whether Emacs stopped at the right occurrence.
Avy offers a different approach. It places short labels over visible matches, allowing you to jump to a character, word, line, or symbol with a few keystrokes. For Magik developers using Emacs, this creates a rapid navigation layer that works alongside method folding, debugging, object inspection, and the usual Smallworld development tools.
Why Avy Fits Magik Source Files
Avy is especially effective when the destination is visible somewhere in the current buffer or in another displayed window. Instead of remembering a long method name, you can identify the target visually and press its label. This is valuable in Magik files where several related methods may share a naming pattern but differ in suffixes or specialisation.
For example, a Magik source file might contain several _method declarations, calls to new(), collection operations, or references to a particular slot. avy-goto-char can take you to a visible character, while avy-goto-char-2 narrows the target using a two-character sequence. avy-goto-word-1 is useful when the target is a distinct identifier, and avy-goto-line works well when the destination is a known part of a folded or expanded code block.
The important distinction is that Avy is a visual jump tool rather than a semantic Magik index. It does not need to understand every class, exemplar, pragma, or method relationship before it can help. That makes it useful in legacy code, generated files, and mixed buffers where language-aware navigation may be incomplete.
Installing And Activating Avy
Install Avy through your preferred Emacs package manager. With use-package, a compact configuration might look like this:
(use-package avy
:ensure t
:bind (("C-:" . avy-goto-char)
("C-c j c" . avy-goto-char-2)
("C-c j w" . avy-goto-word-1)
("C-c j l" . avy-goto-line)))
The exact key choices are personal. Avoid replacing a key used by your Magik major mode, debugger, or Smallworld workflow. Many developers reserve a short prefix such as C-c j for jumps, leaving ordinary Emacs movement and mode-specific commands unchanged.
Avy also provides avy-goto-char-timer, which is often a good default for source code. It lets you type a short character sequence within a brief interval, then displays labels for matching locations. A practical setting is:
(setq avy-timeout-seconds 0.3)
If your Magik buffers use a dark theme, check the label faces and background contrast. Labels should be immediately visible without obscuring punctuation or indentation. The command M-x customize-group RET avy RET provides a convenient way to inspect the available visual settings.
Choosing The Right Jump Command
Use avy-goto-char when one distinctive character is enough to reduce the candidates. In a method containing several calls, jumping to a colon, opening parenthesis, or underscore may produce too many labels, while a less common letter can isolate the intended location. Press the label shown beside the target, and point moves there.
avy-goto-char-2 is usually better for Magik identifiers. Type two characters from the beginning or middle of the name, then select the label. A sequence such as ma, gr, or fi may locate a method, grammar object, or field reference without requiring the whole identifier. This is particularly useful when names use consistent prefixes across a large Smallworld application.
Word-based commands are convenient when the Magik major mode supplies a suitable syntax table. However, language modes can differ in how they classify underscores, periods, and other punctuation. If avy-goto-word-1 does not recognise a Magik name as expected, use the character-timer command or a two-character jump instead. The fallback is quick and avoids spending time adjusting syntax settings for a single navigation task.
Moving Through Methods And Collections
A common Magik editing sequence is to find a method declaration, inspect its implementation, and then move between several related calls. Avy can support each step. Search or method navigation can take you to the correct file, while Avy handles the final movement within the visible source. From a method declaration, avy-goto-line can move to a return statement, exception branch, or collection loop without repeated C-n presses.
Folding makes these jumps more powerful. When method bodies are collapsed, use a method-navigation command or search to open the relevant section, then use Avy to select a visible line or identifier. If the required target is hidden inside a folded region, Avy cannot select it until that text is displayed. This limitation is useful: it keeps the label overlay focused on what you can currently inspect.
Avy is also useful during collection analysis. Suppose a Magik method builds a property list, traverses a collection, and then passes the result to another object. A two-character jump can move between repeated collection variables, while line jumping can move directly to the loop or transformation step. The result is less reliance on exact search strings and fewer accidental matches in comments or nearby methods.
Combining Avy With Debugging And Inspection
When a debugger stops at a Magik expression, the next task is often to inspect a variable and then compare it with several nearby uses. Avy lets you move rapidly among those uses while preserving the current debugging context. This is helpful when a stack frame contains a long method with multiple branches that manipulate the same object.
The workflow can be simple: inspect the current object, use avy-goto-char-2 to visit each relevant reference, and return to the debugger command or source location as needed. Avy does not replace object inspection or a debugger’s frame navigation. It reduces the mechanical movement between the places where those tools are most useful.
Avy actions can also be configured for operations beyond moving point. Depending on the command and version, actions can copy, kill, or teleport text at a selected location. Treat these as an advanced layer and test them in an ordinary editing buffer first. In production Magik code, a plain jump followed by a deliberate edit is usually safer than combining selection and modification until the behaviour is familiar.
For teams, small configuration files are easier to maintain when navigation and editing actions are separated. Bind the basic jump commands first, document any custom Avy action keys, and keep the configuration compatible with the Emacs versions used by the project. This matters in Australian utility and government environments, where development desktops may be managed centrally and upgrades can occur on a slower schedule than in a small startup.
Building A Practical Magik Navigation Routine
A useful routine begins with the least specific tool that can solve the problem. Use method navigation when you need a declaration in another file, incremental search when you know a distinctive phrase, and Avy when the target is already visible. This division prevents Avy from becoming a replacement for every search command.
For a Melbourne or Sydney team sharing a large Smallworld codebase, consistent key bindings are valuable because developers may move between client sites, virtual desktops, and remote sessions. A Brisbane or Perth developer working with a server hosted in another state may also notice the benefit of short, low-latency local commands. Avy performs its labelling in Emacs, so it can feel responsive even when the wider development environment is remote.
Australian organisations should also consider what appears in screen recordings and shared debugging sessions. Magik buffers can contain asset identifiers, customer information, coordinates, or operational data. Under the Privacy Act 1988, personal information must be handled appropriately, and internal policies may place further limits on captured screens. Configure recordings and collaboration tools so Avy demonstrations show synthetic or approved source data rather than sensitive production material.
A short practice routine helps establish muscle memory. Open a representative Magik file, try a character jump, repeat with two characters, move to a line, and then test the commands in a folded method. Adjust the timeout and label faces only after the basic commands feel natural. This is a modest investment for developers working in Australia’s relatively specialised Smallworld market, where preserving productivity in established codebases can matter more than adopting a completely new editor.
Comparing Navigation Options In Emacs
Avy works best as part of a navigation toolkit. It is faster than repeated cursor movement for visible targets, while semantic commands remain stronger when the destination is defined by Magik structure rather than screen position. The following comparison shows where each approach fits.
| Navigation approach | Best use in Magik | Main strength | Limitation |
|---|---|---|---|
avy-goto-char |
A visible punctuation mark or distinctive character | Very fast visual selection | Can show many labels |
avy-goto-char-2 |
Repeated method names, slots, or calls | Narrows targets with two characters | Requires the target to be visible |
avy-goto-word-1 |
Distinct identifiers or keywords | Convenient for word-like names | Depends on syntax-table behaviour |
avy-goto-line |
A known visible line in a long method | Direct movement across the buffer | Does not understand code structure |
| Incremental search | A known method, variable, or phrase | Finds text beyond the visible area | Requires typing an accurate search |
| Magik method navigation | Definitions and related methods | Uses language or mode knowledge | May need configuration and complete indexes |
| Imenu or project indexing | Symbols across files | Suitable for large codebases | Slower to configure and less visual |
Start with two or three commands rather than binding every Avy feature. A strong initial setup is avy-goto-char-2, avy-goto-line, and avy-goto-char-timer. Add word navigation when the Magik mode handles identifiers consistently. This keeps the workflow memorable and reduces conflicts with existing Emacs packages.
Avy becomes most effective when it is attached to a clear decision: “The target is visible, so jump visually.” With that rule, method search, code folding, debugging, and object inspection each retain their purpose while Avy removes the slowest part of moving around the current source.
Add Avy to your Magik Emacs configuration, choose a small set of memorable bindings, and test them on the methods you edit most often. HydePark Consulting’s Magik-focused resources can help extend that workflow with language-aware navigation, debugging practices, and other productivity techniques for Smallworld development.
Core Features
Tab Mode & ECB
Quick tab switching and Emacs Code Browsing mode for navigating Magik codebases efficiently.
Magik Smeller
Code analysis tool that helps identify potential issues in Magik source files.
Code Folding
Hide/Show mode for collapsing and expanding Magik code blocks to focus on what matters.
Visual Bookmarks
Quick visual bookmarks for jumping between key locations in your Smallworld session buffers.
Object Inspector
Inspect Magik objects and display them in an Emacs Deep Print buffer for detailed examination.
Magik Debugger
Set breakpoints and monitor slots and variables directly from within Emacs.
Development Tools
Direct links between Emacs and the Smallworld Development Tools application, including Click Monitor.
Screen-casts & Tutorials
Screen-cast 1: Tab Mode, ECB & More
Covers tab-mode, ECB, Magik Smeller, code folding, visual bookmarks, pragma toggling, moving code, external editor, and MS Explorer.
Screen-cast 5: Object Inspection & Deep Print
Inspect a Magik object, prompt for an expression evaluated within a Smallworld session, and display results in a Deep Print buffer.
Screen-cast 7: Magik Debugger
Useful tools for application developers: Object Inspector and Magik Debugger with breakpoints and slot/variable monitoring.
Screen-cast 9: Tree Item GUI Control
Tree Item is a GUI control providing extensive facilities for displaying lists with rows, columns, trees, and in-place editing.