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
Find Magik method references across files with Emacs Occur
Large Smallworld estates often spread one Magik method across packages, generated sources and client-specific overlays. A rename that looks local in one editor can therefore affect dozens of files that never appear in the same directory. Opening each buffer and scanning with C-s becomes slow, especially when the method is called through a package-qualified name.
Emacs' Occur provides a faster feedback loop: it collects matching lines in a dedicated buffer while leaving the source intact. Built-in occur examines the current buffer, and related commands can apply the same idea across buffers or a directory tree. The key is to choose a scope that matches the question, use an Emacs-compatible regular expression, and distinguish definitions from executable references.
Search at the right scope
Occur is deliberately a small, local command. With point in a Magik file, run M-x occur, enter a method-name pattern and inspect the resulting *Occur* buffer. This is ideal when reviewing one module or checking how a particular procedure behaves in its immediate context.
The broader workflow depends on search breadth, result presentation and whether you want to revisit source files directly:
| Workflow | Scope | Result view | Best fit for Magik |
|---|---|---|---|
M-x occur |
Current buffer | One compact occurrence buffer | Checking definitions and nearby callers |
| Multi-occur | Selected buffers or a directory tree | Matches grouped for interactive navigation | Finding references across several Magik files |
M-x rgrep |
Directory tree through ripgrep | Compilation-style hits with paths | Broad, fast repository-wide sweeps |
| Xoccur | Files or directories | Grouped matches with file labels | Repeated project-wide searches |
For a refactor or impact review, the useful command is the multi-file variant rather than repeated single-buffer searches. If your setup lacks it, the broader Emacs extensions collection provides options for grouped, project-aware results. Keep a simple current-file search available as the first diagnostic step.
Build a Magik-friendly pattern
Magik method names can be plain identifiers or package-qualified forms such as sw:person_2.name, and their punctuation matters. A loose pattern may match a comment, a similarly named procedure or a longer identifier. Decide whether you want every textual occurrence or only syntactic call sites, then anchor the name accordingly.
Emacs regular expressions differ from those used by ripgrep, Perl and many programming languages. Word boundaries are \< and \>, alternation is \|, and grouping uses \( and \). For example, \(foo_method\|bar_method\)\> finds either complete word without requiring an unsupported shorthand. Escape a literal dot as \. when the package qualifier contains one.
Case sensitivity is useful for exact identifiers, but it can conceal a casing mistake. During discovery, temporarily enable case-insensitive matching to expose inconsistent variants; before changing code, rerun the search with case-fold-search set to nil. Search definitions and calls separately when you need a defensible impact list, because a single combined expression makes review harder.
Search a project tree
Start with the smallest reliable root, commonly a Magik package directory beneath a development checkout. In a multi-occur.el setup, use M-x multi-occur with a list of maintained Magik files, or M-x multi-occur-in-directories if your version provides that directory-oriented command. The Xoccur interface can also search a directory directly. Supply an Emacs regular expression, not a ripgrep expression, and wait for the grouped result buffer.
Large estates need exclusions. Generated output, temporary overlays, backup files and copied vendor code can contain stale names that are irrelevant to the edit. Restrict the search to maintained sources or exclude known output directories. If the tree is too broad, search one package at a time and use package qualifiers to prevent unrelated methods with the same local name from crowding the results.
M-x rgrep is a useful fallback when the directory contains many file types. It searches from Emacs but places hits in a compilation-style buffer, so paths and line numbers are prominent. The pattern follows ripgrep rules, including its own alternation and word-boundary syntax, which makes it essential to switch regex dialects deliberately rather than copying the previous pattern unchanged. Test the command on a small subtree before widening it.
Work with the results
An Occur buffer gives a quick inventory without replacing your working buffer. Use n and p to move through matches, then use the command bound to open or switch to the original location. Multi-occurrence modes can also group hits under file names, which makes it easier to see whether one file contains every problematic call. The original buffer remains editable, so the list acts as a work queue rather than a read-only report.
Refine the pattern instead of manually scanning every hit. Add the package qualifier when local names repeat, require an opening parenthesis for executable calls, or remove comment-only matches by narrowing the file scope. Emacs can convert the current incremental search into an occurrence list with M-x isearch-occur, so an exploratory C-s can become a structured review.
Record a successful pattern in a project note or saved search. For a method rename, keep the definition pattern, the caller pattern and any dynamic references in separate searches. Repeatable queries make peer review clearer and give support colleagues in another Australian office a precise way to reproduce the result.
Separate definitions from callers
Definitions usually have a recognisable _method declaration, while callers generally show the method name followed by parentheses. A definition-focused Emacs pattern can begin with ^[[:space:]]*_method[[:space:]]+ and then match the qualified name. Anchoring at the line start reduces false positives from documentation and strings.
For call sites, search a word-bounded name and the opening parenthesis, such as \<sw:person_2.name\>(. This still finds calls embedded in larger expressions, but it excludes a bare mention in a comment. When the same local name exists in several packages, search each exact qualifier rather than accepting any string ending in that name.
Not every executable reference is a direct call. Methods may be passed as values, stored in tables, selected dynamically or referenced by generated code. Combine exact searches with targeted reads of dispatch layers and configuration data. Occur provides strong evidence for direct references, while a risky refactor still needs checks for indirection, runtime lookup and files outside the normal source tree. A useful final check is to compare the direct-call count with the number of changed files.
Fit the workflow to Australian teams
Australian Magik teams commonly work across Melbourne, Sydney, Brisbane and Perth, with handovers that may cross state borders during the business day. Put the canonical project root and the exact package qualifier in handover notes so a colleague can reproduce a search. Australian English conventions such as “organisation”, “behaviour” and “licence” should be respected in surrounding documentation, although method identifiers themselves must retain their precise spelling.
Shared support rotations also encounter different local clocks. Eastern states move between AEST and AEDT, while Perth remains on AWST, and teams often meet remotely through Microsoft Teams. If an issue log records when a search was run, record the time in UTC and optionally note AEST or AEDT; the saved regex and result list matter more than the display time.
The Australian market includes established Smallworld estates as well as newer deployments with mixed Windows and Unix-based tooling. Emacs may run natively on macOS or Linux, through WSL, or in a remote development environment, so path separators, file-name case and ignored directories can differ. Check the result on the platform used by the target team, and remember that HydePark Consulting’s local support work can require checking client-specific overlays that never appear in a generic training repository.
Make Occur part of your daily loop
Build the habit around one repeatable sequence: use M-x occur for the active file, widen to a directory search when the name crosses packages, and refine with qualifiers before editing. Bind the multi-file command to a convenient key, keep the file selector aligned with the repository, and save the expressions used for the current release.
Before changing a Magik method, capture both its declaration and its direct callers. Review dynamic uses separately, then run the same searches on the developer’s branch and the supported release tree. This catches the practical Australian support issue where one site has an overlay or patch absent from headquarters.
Add the project-root search to your Emacs setup now and use it for the next method rename. Keep the broad sweep reproducible, share the exact pattern with the team, and treat the result list as the first checkpoint before refactoring code.
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.