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 More
HydePark Consulting Screen-casts on YouTube RSS via FeedBurner

Nine 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 Emacs Dired to manage Magik source files

Dired, Emacs' built-in directory editor, often surprises developers who stumble into it expecting a plain file list. Once configured for a Magik project, it becomes a practical control panel for browsing .magik files, jumping between session logs, and reorganising source trees without ever leaving the keyboard. For Smallworld practitioners working on utility networks, water assets, or telecommunications infrastructure, this is a quiet productivity win that compounds across long refactors.

Magik codebases tend to live in deep, well-organised hierarchies: product modules, swaf modules, world databases, and per-customer deployment folders. Australian teams maintaining distribution networks in Melbourne's inner suburbs or transmission corridors across regional New South Wales often juggle multiple repositories at once, and Dired's buffer-based model makes that juggling less painful than switching between three separate file explorer windows.

Setting up Dired for a Magik workspace

The fastest way to get going is to open Dired on a project's root with C-x d and point it at a directory that contains both product.def and your swaf modules. Once the buffer is visible, you can mark files with m, unmark with u, and execute bulk operations with % followed by a pattern such as %.magik$. For larger repos, adding (setq dired-listing-switches "-alh") to your init file gives you human-readable sizes, which matters when you are triaging megabyte-sized session traces left behind by a long Smallworld run.

A small but worthwhile habit is to keep a dedicated Dired buffer for each major branch. Pinning one buffer for main and another for an in-progress feature branch lets you compare directory contents side by side using C-x 4 C-o to open the same path in a second window. Many Australian developers who split their week between a Sydney CBD office and remote work from the Central Coast appreciate this approach because it removes a layer of mental context-switching when jumping between code reviews.

If you prefer tree-style views, the dired-subtree package from MELPA slots neatly into the workflow. Inserting it with (require 'dired-subtree) and binding a key like C-c C-t lets you collapse or expand subtrees inline. For teams working on gas network data, where folder depth can stretch to eight or nine levels beneath a gis module, the visual compression saves a great deal of scrolling.

Comparing Dired with other file tools

Tool Strengths Limits in a Magik context Best fit
Dired Keyboard-driven, buffer-based, scriptable Steep learning curve for new Emacs users Daily navigation and bulk operations
Bash ls + find Universal, scriptable, no setup No bulk editing, no visual marks Quick ad-hoc queries
File Explorer / Finder Familiar GUI, thumbnails Mouse-driven, slow for bulk renames One-off file inspection
Magit First-class Git workflow Not a general file manager Version control operations
Projectile / Treemacs Project-aware, sidebar views Adds dependencies, slower startup Cross-project jumping

This view is worth keeping open in a reference buffer while you are still building the Dired habit. The other tools are not rivals so much as complements; a typical Magik session in a Perth office might begin with Treemacs for a high-level glance, fall into Dired for detailed file work, and finish in a Bash shell for deployment scripts.

Navigating Magik source trees efficiently

Movement inside a Dired buffer follows Emacs conventions, so n and p step through entries, > and < shift the cursor to the next and previous directory, and ^ jumps back up the tree. The j command accepts a partial filename and leaps directly to it, which is especially handy when you remember that a method lives in load_magik_source.magik somewhere under a deeply nested sw_product folder. Pair this with isearch inside the buffer (C-s) and you can usually locate any file in a moderately sized repository within a couple of seconds.

For projects hosted across multiple customers, a per-customer Dired bookmark is a lightweight but powerful tool. Recording a bookmark with C-x r m for each deployment — say, sydney-water-cbd, brisbane-stormwater, or perth-power-mesh — gives you a one-keystroke return path. Because Dired reuses the buffer when revisiting a directory, navigation feels almost instant after the first visit. The bookmark-set and bookmark-jump commands integrate with the same machinery used for code bookmarks, so muscle memory carries over.

When the source tree is split across several Git working copies, the dired-jump package, bound to C-x C-j, becomes the bridge. Pressing it from any Magik buffer opens a Dired window on the file's containing directory. Pressing it again jumps to the project's root by climbing past version-control markers. This pattern is common in consulting teams that keep a separate clone per client and rotate between them during a single workday.

Batch operations on Magik source files

Dired's real strength is its ability to operate on many files at once without external scripts. Marking a region with * m and then pressing R renames every selected file, which is useful when migrating from camelCase to snake_case across a legacy module. The % d command flags and deletes files matching a regex, while % m toggles marks based on a pattern. For a one-off cleanup of stale .db files generated by a Magik session, % m followed by %.db$ is faster than any shell pipeline.

Bulk byte-compilation of Magik source is more involved than bulk renaming, but Dired can still help. Mark the relevant files, invoke X to run an external command, and pass a shell snippet such as for f in *; do magik -c "$f"; done. A more disciplined approach is to keep a Makefile at the repo root and trigger make from Dired with !. The output lands in a compilation buffer where M-g n jumps to the next error, which integrates well with Emacs' Magik mode for source navigation.

For tasks that genuinely need a shell, ! drops you into a one-off command, while M-! (or your preferred binding) runs an asynchronous shell. If you are auditing permissions before a release to a customer in the Northern Territory or Western Australia, where infrastructure often lives on hardened servers, you can mark a set of files and run chmod directly from the Dired buffer. The same applies to chown runs coordinated with the local sysadmin.

Pairing Dired with Magik-specific tools

Magik's session-driven nature means that source files are often read at runtime rather than compiled in advance. Dired supports this workflow by letting you open any .magik file with F against a Smallworld image, provided the right wrapper script is in place. A typical setup uses a shell function sw-magik that sets MAGIK_HOME and SMALLWORLD_GIS, then calls the binary; from Dired, ! sw-magik %F opens the marked files inside a live session.

Image and world management also benefits from Dired. Pointing it at a directory of .swm world files lets you rename, copy, or archive them with standard Dired commands. Teams that support field crews in regional Queensland or the Pilbara frequently swap in fresh world files during outage planning, and being able to mark and zip a set of worlds with ! zip -r customer-package.zip %m removes a step from the release checklist.

For inspecting database schemas or collection contents, Magik's showcol and write_object produce text dumps that are often stored alongside the source. Dired can sort by modification time with s and then by size with S, which makes it easy to spot the latest schema snapshot. Pressing g reverts the buffer when a colleague has dropped new files into a shared network drive.

Customising Dired for Smallworld conventions

Default Dired behaviour assumes Unix conventions, so a few targeted customisations make the experience feel native to a Magik developer. Highlighting %.magik files in a distinct colour through dired-mark-extension or dired-hide-details-mode keeps the buffer readable on long Monday-morning standups. Hiding dotfiles by default with (insert-directory "--group-directories-first -Alh --time-style=long-iso") produces a listing style familiar to anyone used to ls on a MacBook in a Brisbane co-working space.

A practical trick is to use dired-omit-mode to hide files that clutter a Magik listing. The variables dired-omit-files and dired-omit-extensions can be set to ignore *.cache, *.db-journal, and other session leftovers. Binding C-x M-o to toggle the mode lets you bring the hidden files back when investigating a strange startup error. Australian teams that have switched to four-day work weeks often appreciate any tweak that reduces visual noise at the start of a focused day.

Color coding for SWAF modules, world files, and product definitions makes the buffer self-documenting. A snippet using dired-font-lock-add-keywords can colour .swaf files in one hue and .magik files in another, which is invaluable when reviewing a change set that mixes build artefacts with code. For a team spread across Adelaide and Hobart, a colour-coded buffer also makes screen-sharing over Teams or Zoom much easier to follow.

Workflow tips for distributed Australian teams

Time zones matter when teammates are spread between Perth, Adelaide, and the east coast, and Dired's lightweight model helps bridge the gap. A shared Dired bookmarks file stored under version control lets each engineer call up the same directory structure regardless of which branch they are on. Combine that with tramp to open Dired on a remote Smallworld server, and the buffer behaves almost exactly like a local listing, with the same key bindings and the same marks.

If your team has adopted a centralised infrastructure documentation approach, a similar idea works for code: keep a DIRECTORIES.md next to each major module that explains the role of every subfolder. Dired can display this file alongside the listing by splitting the window with C-x 3 and opening the markdown file in the other pane. The result is a self-describing workspace that an interstate contractor can navigate on day one.

Backup hygiene is another area where Dired shines. Marking a folder of session logs, archiving it with ! tar czf backup-$(date +%F).tar.gz %m, and then deleting the originals with D is a one-minute ritual that fits comfortably into an end-of-day routine. The same approach scales to scheduled jobs run from cron or systemd timers, which are the patterns most Australian sysadmins have standardised on for production Smallworld hosts.

Open Emacs on your current Magik project, run M-x dired on the root, and try marking a handful of files for your next rename. Within an afternoon, the buffer will feel less like a file list and more like the workbench it was always meant to be.

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

Dark code editor window with syntax-highlighted Magik source code in muted blues and greys, conveying a focused development environment

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.

November 7, 2010
Split-pane Emacs interface with multiple buffers open, warm amber and navy tones against a dark background

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.

January 16, 2011
Debugging interface with breakpoint markers and variable watch panels in subdued teal and charcoal tones

Screen-cast 7: Magik Debugger

Useful tools for application developers: Object Inspector and Magik Debugger with breakpoints and slot/variable monitoring.

January 2011
Tree control GUI element with expandable branches rendered in clean greys and muted blues on a light background

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.

January 20, 2011