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
Parallel editing for Magik in Emacs
Emacs can apply one edit at many source locations through multiple cursors, turning repetitive Magik changes from a sequence of manual operations into a controlled parallel edit. This is particularly valuable when renaming variables, updating repeated calls or inserting temporary diagnostics across several branches of a method.
The technique works best as part of a disciplined Smallworld development workflow. Emacs provides the editing efficiency, while Smallworld’s development tools remain responsible for compilation, execution and runtime validation. With the cursor set narrowly scoped and every change reviewed, multiple cursors can shorten editing sessions without hiding semantic mistakes.
Install and configure multiple cursors
Install the multiple-cursor package through Emacs Package Menu or with M-x package-install, then enter multiple-cursor. Use a trusted package archive, and inspect the package source or signature where the archive provides one. The package adds commands rather than changing Magik syntax mode, so it works in any Magik buffer.
Common installations bind C-c C-p to mc/edit-mc-returns and C-c C-n to mc/edit-mc-n. Other releases or personal configurations may differ, so use M-x to discover commands before replacing existing shortcuts. Keeping the defaults is often safer for teams sharing an Emacs configuration between Sydney, Melbourne and Brisbane offices.
Security matters when installing development tools. If an unofficial external download page appears in a search result, treat it as untrusted and obtain multiple-cursor from the configured package archive instead. A careful installation protects source code, credentials and Smallworld repository access.
Build a precise cursor set
Place the point at a candidate location and invoke M-x mc/set-mark; repeating the command at additional positions creates a manual cursor set. This suits changes across a few selected calls where an automatic pattern would capture too much. The exact C-SPC behaviour depends on the installed version and the binding already used for ordinary Emacs marking.
For repeated identifiers, M-x mc/mark-all-occurrences-of-string provides a quicker route. Type the exact text, confirm the marked positions and then enter the replacement. A regexp version is available through M-x mc/mark-all-occurrences-of-regexp, but broad patterns can select comments, quoted text and unrelated properties as well as executable code.
Keep the search area small. Select the relevant method or region and use M-x narrow-to-region, or rely on Magik mode’s navigation facilities, before marking occurrences. M-x mc/toggle-global-mode is useful for experiments, yet applying it to an entire repository makes the active cursor count difficult to understand. Escape leaves multiple-cursor mode, while M-x widen restores a narrowed buffer.
Apply parallel edits without losing control
Start with a reversible operation such as renaming a local variable or replacing an identical method argument. Check the cursor positions before typing, and inspect the result immediately afterwards. Multiple-cursor edits are normally grouped into one undo step, so C-x u provides a practical safety net when a selection includes the wrong occurrence.
A useful drill is to perform the change, review it and undo it before trying again with a larger cursor set. This forces the editor habit of checking scope before editing. It also exposes problems such as a similarly named variable in another method or a text fragment inside a comment, both of which are common in large Smallworld source trees.
Not every repeated fragment has the same meaning. Magik method calls can be dynamically resolved, and identical-looking calls may sit on different execution paths. Parallel editing is safest for local variables, literal argument values and formatting changes. Treat method renaming, transaction boundaries and changes to control-flow keywords as review-heavy operations requiring Smallworld compilation and tests.
Exploit Magik syntax patterns
Magik identifiers and keywords are generally case-insensitive, whereas Emacs searches normally distinguish case unless case-fold-search is enabled. Enable folding for the operation or write a case-insensitive regexp when it matters. Quoted strings still need exact treatment because changing their contents may alter messages, identifiers stored as data or user-facing text.
Local-variable renames are a strong starting point. Mark every occurrence of a temporary collection name within one _method block, then replace it with a descriptive name. Review the method boundaries before marking, because the same temporary name may legitimately exist in a nested procedure or a separate method. Preserve Magik’s established indentation and naming conventions rather than using the parallel edit to introduce unrelated formatting.
Repeated branches and repeated calls offer other productive patterns. A cursor set can insert a probe before each selected invocation, or add a consistent argument to several calls. Indentation may differ between insertion points, so reindent only after the insertion and inspect nested _if, _loop and _endif structures. Parallel editing repeats text; it does not understand whether every destination accepts the same syntactic context.
Work with collections and database results
Magik code often traverses collections, hash tables, vectors and mapped records. When several transformations use the same temporary variable, a parallel rename can make the intended data flow easier to see. The useful operation is not a blind replacement but a coordinated edit that reflects how each collection is queried, filtered and returned.
Emacs cannot replace the Smallworld runtime. Validate changed methods in the appropriate Smallworld development environment, using a transactor or the organisation’s established debugging workflow. Check collection sizes, null handling and transaction behaviour with representative data. A source-level edit that looks consistent can still expose an invalid assumption about records returned from a database.
Australian land administration, infrastructure, utilities and mining workflows make this distinction especially important. Customer identifiers or precise asset locations may be present in operational repositories. If a demonstration uses personal information, check whether the Commonwealth Privacy Act 1988 and the relevant state or territory legislation apply. Use synthetic records for lessons and screen-casts, particularly in Victoria, where the Privacy and Data Protection Act 2014 may also be relevant.
Debug and review coordinated changes
Placing temporary probes at several suspected call sites is one of the strongest debugging uses for multiple cursors. Each selected invocation can receive a consistent trace expression, after which the Smallworld debugger or transaction log reveals which path executes. Label probes individually when necessary, since identical parallel insertions can otherwise produce repetitive log output that is difficult to interpret.
Review the resulting diff rather than relying on memory. Emacs’s comparison tools can highlight the changed method, and Smallworld compilation can catch syntax or typing failures that Emacs cannot. Keep the distinction clear between the Emacs debugger and a Magik debugger: debug-on-error may help with an Emacs Lisp fault, but it will not diagnose a failing Magik method or database operation.
Many Australian developers alternate between a home office, a shared workplace and a client site. Recording a short screen-cast with the Magik buffer, cursor positions and Smallworld result visible can make a parallel edit easier to explain during a distributed review. Remove live records, credentials and internal repository details before sharing the recording.
Make the workflow repeatable
Store useful Magik and Emacs bindings in a project-specific configuration file so a colleague can reproduce the same cursor commands. Include a short rehearsal file containing synthetic methods with repeated variables and calls. This gives the team a controlled environment for testing commands, reviewing undo behaviour and documenting any configuration assumptions.
Keep demonstrations independent of workstation-specific resources. Use a narrow search scope, record the command sequence and show the final Smallworld validation result. Teams spanning Perth and Brisbane should agree on a commit window and include timestamps, since Australian states can differ by two hours and daylight-saving changes affect scheduling.
A repeatable procedure also makes training easier. New Magik programmers can learn cursor selection, editing and cancellation in a small file before applying it to production code. The same habit reduces accidental replacements when a developer works late or moves between an office keyboard and a personal laptop. Efficiency is valuable only when another developer can understand and reproduce the result.
Install multiple-cursor today and run a ten-minute drill on a synthetic Magik method: create a narrow cursor set, rename a local variable, review the diff, undo the change and repeat with a regexp. Subscribe to Magik Emacs for practical tutorials, extensions and screen-casts that connect efficient Emacs editing with rigorous Smallworld validation.
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.