Posts

Showing posts from November, 2021

Formula Editor in GNU Emacs

Image
    Here's a simple formula editor using SVG for quick note taking in GNU Emacs. Presently, it's a single line editor. You can use arrow keys to move around, Shift+arrow keys for selection and backspace for deleting characters. Use Ctrl + x prefix for special actions like grouping (g), fractions (f) and exponents (e). (require 'formula)   M-x formula-mode Code: https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/svg.el https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/formula.el   How it works? In the video, an event loop is started in the scratch buffer. All the edit operations update text and text property in a temporary buffer, say a.txt. Based on this information, in-memory SVG DOM is updated. Ultimately, the display engine updates the view with this SVG image.

SVG Hack for Emacs Display Engine

Image
    Here's throwing an idea into the wild. How about using SVG for rendering in the Emacs display engine? The attached image shows the rendering as a proof of concept for feasibility. The top window shows the SVG rendering of the buffer shown in the bottom window. One obvious advantage is precise positioning of content including inline popups for auto-completion. This also precludes any major changes to the display engine data structures. Other use cases include feature filled tooltips, inline completion popup, multi-column layouts, watermarks etc In this hack, the elisp code navigates from (window-start) to (window-end) reading a line of text from associated buffer and displaying the same in SVG. I've used (read-event) and (lookup-key) to allow for key translations for navigation commands. Hopefully with a tighter integration, all of this will not be required. Positioning of point is one open area. We would need the bounding box of text for accurate positioning. We have thr

PCB Design in GNU Emacs

Image
Gerber For fun, here's a Gerber file generated from SVG footprints drawn in GNU Emacs . Note: gerbv displays polygon pad incorrectly as circle in fast mode . You should use use normal mode for this. Or else use gerbview . 3D Model If you have properly modeled footprints (1:1 scale, XY plane of the 3D model on the PCB and origin at the center of the bounding box), then you can easily generate 3D view of the assembly. In this screenshot, you can see the generated model being rendered by view3dscene. The code expects eda:url attribute to point to the 3D model (.wrl file for VRML 2.0). The shape with eda:type="board" is used as the PCB. (require 'gerber) (setq canvas-plugin-map pcb-canvas-map) Fancy fonts on Silkscreen Do you want fancy fonts on your PCB silkscreen? You can use a Hershey font or stroke font in SVG format to achieve the desired result. A small collection of these fonts are available at https://gitlab.com/oskay/svg-fonts . Code: https://gitlab.com/at

SPICE simulation in GNU Emacs (From schematics)

Image
Now you can design and run SPICE simulation for simple circuits in GNU Emacs. Since the circuit and graphs are in SVG format, you can easily annotate and share it on the web or embed it in a document.   Video tutorial for configuring the circuit diagram, running the simulation and plotting the results is below:  Video tutorial for drawing the circuit diagram using widgets is below:   Code:   https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/svg.el https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/spice-mode.el   Setup: Setup is covered in following blog posts. https://lifeofpenguin.blogspot.com/2021/10/svg-widget-in-gnu-emacs.html https://lifeofpenguin.blogspot.com/2021/10/spice-simulation-in-gnu-emacs.html Additionally, we need to make special spice plugin (defined in spice-mode.el) available to canvas-mode. This makes plugin keybindings available via C-x in canvas-mode. To do this, add following to .emacs (setq canvas-plugin-map spice-canvas-map)   How does it work? SVG is an