### Define Emacs Lisp Modes and Functions Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Demonstrates the definition of Emacs Lisp major and minor modes, as well as utility functions. Includes examples of standard definitions and those intended for autoloading. ```emacs-lisp (define-derived-mode foo-mode ...) ;;;###autoload (define-minor-mode foo-minor-mode ...) ;;;###autoload (defun foo-setup) ... ;;; bad ;;;###autoload (defun foo--internal) ... ``` -------------------------------- ### Example: Create and Render Build Dependencies Graph Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org This example illustrates creating a graph for build dependencies, including source files, object files, and the final program. It uses `dag-draw-create-graph`, `dag-draw-add-node`, and `dag-draw-add-edge`, followed by layout and ASCII rendering. ```emacs-lisp (setq build-graph (dag-draw-create-graph)) ;; Source files (dag-draw-add-node build-graph 'utils-h "utils.h") (dag-draw-add-node build-graph 'utils-c "utils.c") (dag-draw-add-node build-graph 'main-c "main.c") ;; Object files (dag-draw-add-node build-graph 'utils-o "utils.o") (dag-draw-add-node build-graph 'main-o "main.o") ;; Executable (dag-draw-add-node build-graph 'program "program") ;; Dependencies (dag-draw-add-edge build-graph 'utils-h 'utils-c) (dag-draw-add-edge build-graph 'utils-c 'utils-o) (dag-draw-add-edge build-graph 'utils-h 'main-c) (dag-draw-add-edge build-graph 'main-c 'main-o) (dag-draw-add-edge build-graph 'utils-o 'program) (dag-draw-add-edge build-graph 'main-o 'program) (dag-draw-layout-graph build-graph) (dag-draw-render-graph build-graph 'ascii) ``` -------------------------------- ### Emacs Lisp Docstring Formatting Examples Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Demonstrates correct and incorrect formatting for Emacs Lisp docstrings. Proper formatting ensures readability when viewed by users. Incorrect indentation on subsequent lines can lead to a poor user experience. ```emacs-lisp (defun goto-line (line &optional buffer) "Go to LINE, counting from line 1 at beginning of buffer. If called interactively, a numeric prefix argument specifies LINE; without a numeric prefix argument, read LINE from the minibuffer..." ...) ``` ```emacs-lisp (defun goto-line (line &optional buffer) "Go to LINE, counting from line 1 at beginning of buffer. If called interactively, a numeric prefix argument specifies LINE; without a numeric prefix argument, read LINE from the minibuffer..." ...) ``` ```emacs-lisp (defun goto-line (line &optional buffer) "Go to LINE, counting from line 1 at beginning of buffer. If called interactively, a numeric prefix argument specifies LINE; without a numeric prefix argument, read LINE from the minibuffer..." ...) ``` -------------------------------- ### Example: Create and Render Course Prerequisites Graph Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org This example demonstrates creating a graph representing course prerequisites using `dag-draw-create-graph`, `dag-draw-add-node`, and `dag-draw-add-edge`. It then lays out the graph and renders it in ASCII format. ```emacs-lisp (setq course-graph (dag-draw-create-graph)) ;; First year courses (dag-draw-add-node course-graph 'cs101 "Intro to CS") (dag-draw-add-node course-graph 'math101 "Calculus I") (dag-draw-add-node course-graph 'math102 "Calculus II") ;; Second year courses (dag-draw-add-node course-graph 'cs201 "Data Structures") (dag-draw-add-node course-graph 'cs202 "Algorithms") (dag-draw-add-node course-graph 'math201 "Linear Algebra") ;; Third year courses (dag-draw-add-node course-graph 'cs301 "Machine Learning") ;; Prerequisites (dag-draw-add-edge course-graph 'cs101 'cs201) (dag-draw-add-edge course-graph 'cs201 'cs202) (dag-draw-add-edge course-graph 'math101 'math102) (dag-draw-add-edge course-graph 'math102 'math201) (dag-draw-add-edge course-graph 'cs202 'cs301) (dag-draw-add-edge course-graph 'math201 'cs301) (dag-draw-layout-graph course-graph) (dag-draw-render-graph course-graph 'ascii) ``` -------------------------------- ### Example: Visualize Project Tasks with Dependencies Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org This comprehensive example defines a function `visualize-project-tasks` that creates a graph of project tasks and their dependencies. It adds nodes for tasks and edges for prerequisites, then lays out and renders the graph into an Emacs buffer named '*Project Tasks*'. ```emacs-lisp (defun visualize-project-tasks () "Create a visualization of project tasks." (let ((graph (dag-draw-create-graph))) ;; Define tasks (dag-draw-add-node graph 'requirements "Requirements") (dag-draw-add-node graph 'architecture "Architecture") (dag-draw-add-node graph 'ui-design "UI Design") (dag-draw-add-node graph 'backend "Backend Dev") (dag-draw-add-node graph 'frontend "Frontend Dev") (dag-draw-add-node graph 'integration "Integration") (dag-draw-add-node graph 'testing "Testing") (dag-draw-add-node graph 'deployment "Deployment") ;; Define dependencies (dag-draw-add-edge graph 'requirements 'architecture) (dag-draw-add-edge graph 'requirements 'ui-design) (dag-draw-add-edge graph 'architecture 'backend) (dag-draw-add-edge graph 'architecture 'frontend) (dag-draw-add-edge graph 'ui-design 'frontend) (dag-draw-add-edge graph 'backend 'integration) (dag-draw-add-edge graph 'frontend 'integration) (dag-draw-add-edge graph 'integration 'testing) (dag-draw-add-edge graph 'testing 'deployment) ;; Layout and display (dag-draw-layout-graph graph) ;; Insert into a buffer (with-current-buffer (get-buffer-create "*Project Tasks*") (erase-buffer) (insert "Project Task Dependencies\n") (insert "========================\n\n") (insert (dag-draw-render-graph graph 'ascii)) (goto-char (point-min)) (pop-to-buffer (current-buffer))))) ``` -------------------------------- ### Install beads-mcp Server Source: https://github.com/trevoke/dag-draw.el/blob/congruence/AGENTS.md This command installs the beads MCP server using pip, which is recommended for use with Claude or MCP-compatible clients. This enables using 'mcp__beads__*' functions instead of CLI commands. ```bash pip install beads-mcp ``` -------------------------------- ### Install dag-draw from Source (Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Clones the dag-draw.el repository from GitHub and provides instructions to add it to your Emacs load path. ```bash git clone https://github.com/example/dag-draw.el.git ``` -------------------------------- ### Simple Text Renderer Example for dag-draw Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org An example of a basic text-only renderer for dag-draw. This function initializes an output string and can be extended to generate simple text representations of the graph. ```emacs-lisp (defun dag-draw-render-simple-text (graph) "Simple text-only renderer (no graphics)." (let ((output "")) ;; ... rest of the renderer logic ... output)) ``` -------------------------------- ### Using provide Statement at End of Emacs Lisp Library Files Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This example shows the standard practice of ending an Emacs Lisp library file with a `provide` statement and a comment. This allows dependent libraries to use `require` to load the file. ```emacs-lisp (provide 'foo) ;;; foo.el ends here ``` -------------------------------- ### Emacs Lisp: Avoiding Superfluous Comments Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Illustrates the practice of avoiding comments that merely state the obvious, emphasizing that code should be self-explanatory. Shows an example of a superfluous comment. ```emacs-lisp ;; bad (1+ counter) ; increments counter by one ``` -------------------------------- ### Install Dag-Draw from Source (Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md Provides instructions for cloning the dag-draw.el repository from GitHub and running the test suite using `eldev test`. This is intended for development purposes. ```bash git clone https://github.com/example/dag-draw.el.git cd dag-draw.el eldev test # Run test suite ``` -------------------------------- ### Install Dag-Draw using package.el (Elisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md Shows the Emacs Lisp code snippet to install the 'dag-draw' package using the built-in `package.el` manager, assuming the package will be available in repositories. ```elisp (package-install 'dag-draw) ``` -------------------------------- ### Create and Render Workflow Graph with Highlighting (Elisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md This Elisp code snippet shows the process of creating a workflow graph with multiple nodes and edges, then rendering it with a specific node highlighted. It's useful for building step-by-step guides or visualizing the progress of a process, such as software installation. ```elisp ;; Define the workflow (setq install-graph (dag-draw-create-graph)) (dag-draw-add-node install-graph 'download "Download") (dag-draw-add-node install-graph 'extract "Extract Files") (dag-draw-add-node install-graph 'configure "Configure") (dag-draw-add-node install-graph 'install "Install") (dag-draw-add-edge install-graph 'download 'extract) (dag-draw-add-edge install-graph 'extract 'configure) (dag-draw-add-edge install-graph 'configure 'install) (dag-draw-layout-graph install-graph) ;; User is on step 2 (extract) (dag-draw-render-graph install-graph 'ascii 'extract) ``` -------------------------------- ### Install dag-draw using package.el (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Installs the dag-draw package using Emacs' built-in package manager (package.el), assuming it's available on MELPA. ```emacs-lisp M-x package-install RET dag-draw RET ``` -------------------------------- ### Clone Repository in Bash Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org This bash command demonstrates how to clone a Git repository, which is the first step in setting up the development environment for dag-draw.el. It assumes you have Git installed and are in the directory where you want to place the cloned repository. ```bash git clone ``` -------------------------------- ### Emacs Lisp: `seq-do` vs. `mapcar` for List Operations Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Explains when to use `seq-do` or `dolist` instead of `mapcar` when the intention is not to collect results. Demonstrates the correct usage for loading files and applying functions. ```emacs-lisp ;;; good (font-lock-add-keywords nil (mapcar 'downcase list-of-crazy-cased-words)) (seq-do 'load list-of-files-to-load) ;;; bad (mapcar 'load list-of-files-to-load) ``` -------------------------------- ### Emacs Lisp 'let' Binding Alignment Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Demonstrates the recommended practice for vertically aligning bindings within an Emacs Lisp 'let' form to improve readability. ```emacs-lisp ;; good (let ((thing1 "some stuff") ``` -------------------------------- ### Create and Render a Simple Graph in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md Illustrates the basic workflow of creating a graph, adding nodes and edges, and then rendering it using ASCII format with dag-draw.el. This is a step-by-step guide for beginners. ```emacs-lisp (require 'dag-draw) ;; 1. Create a graph (setq my-graph (dag-draw-create-graph)) ;; 2. Add your nodes (dag-draw-add-node my-graph 'start "Start Here") (dag-draw-add-node my-graph 'middle "Do Work") (dag-draw-add-node my-graph 'done "Finish") ;; 3. Connect them (dag-draw-add-edge my-graph 'start 'middle) (dag-draw-add-edge my-graph 'middle 'done) ;; 4. Layout and render (dag-draw-layout-graph my-graph) (dag-draw-render-graph my-graph 'ascii) ``` -------------------------------- ### Emacs Lisp: Using `dolist` for Iteration with Lambdas Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Demonstrates the correct use of `dolist` for iterating over a list when performing actions with a lambda function, contrasting it with the less idiomatic use of `mapc` for this purpose. ```emacs-lisp ;;; good (dolist (map (list c-mode-map c++-mode-map)) (define-key map "\C-c\C-c" 'compile)) ;;; bad (mapc (lambda (map) (define-key map "\C-c\C-c" 'compile)) (list c-mode-map c++-mode-map)) ``` -------------------------------- ### Emacs Lisp: Using 'with-eval-after-load' vs 'eval-after-load' Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Recommends using 'with-eval-after-load' over 'eval-after-load' for executing code after a library is loaded. 'with-eval-after-load' is generally preferred for its cleaner syntax and direct execution of forms. ```emacs-lisp ;; good (with-eval-after-load "foo" (bar) (baz)) ;; bad (eval-after-load "foo" '(progn (bar) (baz))) ``` -------------------------------- ### Emacs Lisp Commenting Conventions Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Provides guidelines for writing effective comments in Emacs Lisp, including heading comments, top-level comments, fragment comments, margin comments, and the importance of spacing and capitalization. ```emacs-lisp ;;; Frob Grovel ;; This is where Frob grovels and where Grovel frobs. ;; This section of code has some important implications: ;; 1. Foo. ;; 2. Bar. ;; 3. Baz. (defun fnord (zarquon) ;; If zob, then veeblefitz. (quux zot mumble ; Zibblefrotz. frotz)) ``` -------------------------------- ### Emacs Lisp: Using 'not' and 'null' Correctly Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Explains the proper usage of 'not' and 'null' in Emacs Lisp. 'not' is used for general negation, while 'null' is specifically for checking if a list is empty (nil). ```emacs-lisp ;; good (if (null lst) ...) (if (or (not foo) something) ...) ;; bad (if (not lst)) (if (and (null foo) bar) ...) ``` -------------------------------- ### Avoiding Hard Quoting Lambdas in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This example demonstrates why hard-quoting lambda expressions should be avoided as it prevents byte-compilation. It shows the preferred method and the discouraged quoted version. ```emacs-lisp ;;; Good (lambda (x) (car x)) ;;; Ok, but redundant. #'(lambda (x) (car x)) ;;; Bad '(lambda (x) (car x)) ``` -------------------------------- ### Emacs Lisp Comment Annotations (End-of-line) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Shows an example of using a comment annotation at the end of a line for cases where the problem is self-evident and documentation would be redundant. This usage is intended to be exceptional. ```emacs-lisp (defun bar ()) ``` -------------------------------- ### Avoiding -face Suffix for Face Names in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This example shows the recommended practice of not ending Emacs face names with '-face'. It contrasts the correct 'defface widget-inactive' with the discouraged 'defface widget-inactive-face'. ```emacs-lisp ;; good (defface widget-inactive ...) ;; bad (defface widget-inactive-face ...) ``` -------------------------------- ### Get All Edges in Graph - Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Retrieves a list of all edge structures present in the graph. This function is useful for iterating through and inspecting all connections within the graph. The example shows how to iterate and print the source and destination nodes of each edge. ```emacs-lisp (dolist (edge (dag-draw-get-edges graph)) (message "Edge: %s -> %s" (dag-draw-edge-from-node edge) (dag-draw-edge-to-node edge))) ``` -------------------------------- ### Emacs Lisp: Grouping Related 'def' Forms Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org An exception to the rule of using empty lines between top-level forms. This example shows how to group related 'def' constants together without intervening empty lines for better organization. ```emacs-lisp ;; good (defconst min-rows 10) (defconst max-rows 20) (defconst min-cols 15) (defconst max-cols 30) ``` -------------------------------- ### Configuration Variables Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Customization options for graph rendering and layout. ```APIDOC ## Configuration Variables ### dag-draw-default-node-separation Default minimum horizontal separation between nodes. *Type*: Integer *Default*: 20 Used when creating graphs in high-resolution mode. Larger values create more spacing. *Example*: ```emacs-lisp (setq dag-draw-default-node-separation 30) ``` ### dag-draw-default-rank-separation Default minimum vertical separation between ranks. *Type*: Integer *Default*: 25 Used when creating graphs in high-resolution mode. Larger values create more spacing. *Example*: ```emacs-lisp (setq dag-draw-default-rank-separation 50) ``` ### dag-draw-ascii-node-separation Horizontal spacing between nodes in ASCII mode (characters). *Type*: Integer *Default*: 6 Used when coordinate-mode is 'ascii. This is the number of characters between adjacent nodes. *Example*: ```emacs-lisp (setq dag-draw-ascii-node-separation 10) ``` ### dag-draw-ascii-rank-separation Vertical spacing between ranks in ASCII mode (rows). *Type*: Integer *Default*: 5 Used when coordinate-mode is 'ascii. This is the number of rows between adjacent ranks. *Example*: ```emacs-lisp (setq dag-draw-ascii-rank-separation 7) ``` ### dag-draw-default-output-format Default output format for rendered graphs. *Type*: Symbol ('ascii, 'svg, or 'dot) *Default*: 'svg *Example*: ```emacs-lisp (setq dag-draw-default-output-format 'ascii) ``` ``` -------------------------------- ### Using Sharp Quote (#') for Function Names in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This example highlights the benefit of using the sharp quote (`#'`) when referring to function names. It improves byte-compilation warnings and can affect macro behavior, contrasting it with the less preferred single quote. ```emacs-lisp ;; good (cl-remove-if-not #'evenp numbers) (global-set-key (kbd "C-l C-l") #'redraw-display) (cl-labels ((butterfly () (message "42"))) (funcall #'butterfly)) ;; bad (cl-remove-if-not 'evenp numbers) (global-set-key (kbd "C-l C-l") 'redraw-display) (cl-labels ((butterfly () (message "42"))) (funcall 'butterfly)) ``` -------------------------------- ### Using -- for Private Definitions and p/-p for Predicates in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This section details naming conventions for private top-level definitions (using '--') and predicate functions (ending in 'p' or '-p'). Examples illustrate correct and incorrect naming. ```emacs-lisp ;; good (defun palindromep ...) (defun only-one-p ...) ;; bad (defun palindrome? ...) ; Scheme style (defun is-palindrome ...) ; Java style ``` -------------------------------- ### Track Tutorial Progress with ASCII Markers in Elisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md This Elisp code snippet demonstrates how to use ASCII markers to visually indicate the progress of tutorial lessons. It adds nodes for different lesson states (completed, current, future) and renders the graph using ASCII characters. Dependencies include the dag-draw library. ```elisp (setq tutorial (dag-draw-create-graph)) ;; Completed lessons get checkmarks (dag-draw-add-node tutorial 'intro "Introduction" (ht (:ascii-marker "✓ "))) (dag-draw-add-node tutorial 'basics "Basic Concepts" (ht (:ascii-marker "✓ "))) ;; Current lesson gets an arrow (dag-draw-add-node tutorial 'advanced "Advanced Topics" (ht (:ascii-marker "→ "))) ;; Future lessons have no marker (dag-draw-add-node tutorial 'expert "Expert Level") (dag-draw-add-edge tutorial 'intro 'basics) (dag-draw-add-edge tutorial 'basics 'advanced) (dag-draw-add-edge tutorial 'advanced 'expert) (dag-draw-layout-graph tutorial) (dag-draw-render-graph tutorial 'ascii) ``` -------------------------------- ### Get Node Attributes - Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Retrieves the attribute hash table associated with a given node. This hash table can contain various properties that control the node's appearance and behavior. An empty hash table is returned if no attributes are set. Example shows retrieving the 'color' attribute. ```emacs-lisp (dag-draw-node-attributes node) ``` ```emacs-lisp (setq attrs (dag-draw-node-attributes node)) (ht-get attrs "color") ; => "red" ``` -------------------------------- ### Run All Tests (Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/CLAUDE.md Executes all tests using the 'eldev' tool with minimal output. This is the standard command for running the test suite. ```bash ~/bin/eldev test -B ``` -------------------------------- ### Configure beads MCP Server Source: https://github.com/trevoke/dag-draw.el/blob/congruence/AGENTS.md This JSON snippet shows how to add the beads MCP server configuration to the MCP client's config file (e.g., ~/.config/claude/config.json). This allows the MCP client to interact with the beads issue tracking system. ```json { "beads": { "command": "beads-mcp", "args": [] } } ``` -------------------------------- ### Create and Render a Simple Graph (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Demonstrates the basic workflow for creating a simple three-node directed graph using dag-draw.el. It includes creating the graph, adding nodes and edges, and rendering it in ASCII format. ```emacs-lisp (require 'dag-draw) ;; Step 1: Create a graph (setq my-graph (dag-draw-create-graph)) ;; Step 2: Add nodes (dag-draw-add-node my-graph 'start "Start Here") (dag-draw-add-node my-graph 'middle "Do Work") (dag-draw-add-node my-graph 'done "Finish") ;; Step 3: Connect them with edges (dag-draw-add-edge my-graph 'start 'middle) (dag-draw-add-edge my-graph 'middle 'done) ;; Step 4: Layout and render (dag-draw-layout-graph my-graph) (dag-draw-render-graph my-graph 'ascii) ``` -------------------------------- ### Create Graph from Configuration (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Illustrates building a graph from a configuration structure, such as a plist. The graph's nodes and edges are defined within the configuration, and then extracted using `plist-get` before being passed to `dag-draw-create-from-spec`. ```emacs-lisp ;; Store graph structure in configuration (defvar workflow-config '(:nodes ((review :label "Code Review") (test :label "Testing")) :edges ((review test)))) (dag-draw-create-from-spec :nodes (plist-get workflow-config :nodes) :edges (plist-get workflow-config :edges)) ``` -------------------------------- ### Emacs Lisp: Handling Interactive Command Arguments Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/Emacs-Programming-Tips.html Demonstrates the recommended way to handle default argument values in Emacs Lisp's `interactive` function. It shows how to provide `nil` for region or position arguments and compute defaults in the function body, ensuring correct recomputation on command repetition. ```Emacs Lisp (defun foo (pos) (interactive (list (if specified specified-pos))) (unless pos (setq pos default-pos)) ...) ``` ```Emacs Lisp (defun foo (pos) (interactive (list (if specified specified-pos default-pos))) ...) ``` -------------------------------- ### Get All Edges from Graph (Elisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md Retrieves a list of all edges present in the graph. This function is useful for inspecting or manipulating the connections within the graph structure. ```elisp (dag-draw-get-edges graph) ``` -------------------------------- ### Run Tests with Full Debugging (CI Command - Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/CLAUDE.md Runs tests with extensive debugging flags enabled, suitable for Continuous Integration environments. The -p, -d, t, and T flags provide comprehensive output for analysis. ```bash ~/bin/eldev -p -dtT test ``` -------------------------------- ### SVG Fill Color (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Sets the background fill color for an SVG node. This example uses light green to indicate a 'Passed' status. ```emacs-lisp (dag-draw-add-node graph 'success "Passed" (ht (:svg-fill "#90ee90"))) ``` -------------------------------- ### Access Node Label (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Gets the display label associated with a node. The label is returned as a string. This is commonly used for displaying node information. ```emacs-lisp (dag-draw-node-label node) ``` -------------------------------- ### Batch Create DAG with Visual Properties using Elisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/README.md This example demonstrates creating a graph with nodes that have custom visual properties like fill color, stroke, and ASCII markers. These properties can be defined directly in the node specification and are used during rendering. The snippet also shows how to combine status data with graph generation to automatically update visual properties. ```elisp (setq status-graph (dag-draw-create-from-spec :nodes '((todo :label "TODO" :svg-fill "#e0e0e0") (active :label "In Progress" :ascii-marker "→ " :ascii-highlight t :svg-fill "#ffd700" :svg-stroke "#ff8c00" :svg-stroke-width 2) (done :label "Done" :ascii-marker "✓ " :svg-fill "#90ee90" :svg-stroke "#228b22" :svg-stroke-width 2)) :edges '((todo active) (active done)))) (dag-draw-layout-graph status-graph) (dag-draw-render-graph status-graph 'ascii) ``` ```elisp (defun create-status-graph (tasks) "Create graph with status-based visual properties." (let ((nodes (mapcar (lambda (task) (let ((id (plist-get task :id)) (label (plist-get task :label)) (status (plist-get task :status))) (append (list id :label label) (cond ((eq status 'done) '(:ascii-marker "✓ " :svg-fill "#90ee90")) ((eq status 'active) '(:ascii-highlight t :svg-fill "#ffd700")) (t '(:svg-fill "#e0e0e0")))))) tasks)) (edges (cl-loop for task in tasks for id = (plist-get task :id) for deps = (plist-get task :dependencies) append (mapcar (lambda (dep) (list dep id)) deps)))) (dag-draw-create-from-spec :nodes nodes :edges edges))) ``` -------------------------------- ### Create New Issues with bd Source: https://github.com/trevoke/dag-draw.el/blob/congruence/AGENTS.md These commands demonstrate how to create new issues using bd. They allow specifying the issue title, type (bug, feature, task), priority, and dependencies. The '--json' flag ensures JSON output. ```bash bd create "Issue title" -t bug|feature|task -p 0-4 --json bd create "Issue title" -p 1 --deps discovered-from:bd-123 --json ``` -------------------------------- ### Get Graph Edges List (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Returns a list of all edge structures present in the graph. Each element in the list represents an edge connecting two nodes. ```emacs-lisp (dag-draw-graph-edges graph) ``` -------------------------------- ### Run Tests with Backtraces for Debugging (Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/CLAUDE.md Executes all tests and enables backtraces, which are helpful for debugging issues. This command provides more detailed output when tests fail. ```bash ~/bin/eldev test ``` -------------------------------- ### Emacs Lisp: Using 'unless' Instead of 'when (not ...)' Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Illustrates the use of 'unless' for conditional execution when the condition is negated. This is more idiomatic and readable than using 'when' with 'not'. ```emacs-lisp ;; good (unless pred (foo) (bar)) ;; bad (when (not pred) (foo) (bar)) ``` -------------------------------- ### Run Specific Test File (Bash) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/CLAUDE.md Executes tests from a particular file within the test suite. This allows for focused testing of specific components or features. ```bash ~/bin/eldev test -B --file="test/organizing-test.el" ``` -------------------------------- ### SVG Stroke Styling (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Customizes the border (stroke) of an SVG node, setting both its color and width. This example uses gold fill with an orange border for a 'Warning' status. ```emacs-lisp (dag-draw-add-node graph 'warning "Alert" (ht (:svg-fill "#ffd700") ; Gold fill (:svg-stroke "#ff8c00") ; Orange border (:svg-stroke-width 2))) ``` -------------------------------- ### Imperative vs. Declarative Graph Creation (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Compares two methods of building a graph: imperative, where nodes and edges are added one by one, and declarative, where the entire graph structure is defined at once using `dag-draw-create-from-spec`. The declarative approach is shown to be more concise. ```emacs-lisp ;; Imperative (step-by-step): (setq graph (dag-draw-create-graph)) (dag-draw-add-node graph 'a "Task A") (dag-draw-add-node graph 'b "Task B") (dag-draw-add-node graph 'c "Task C") (dag-draw-add-edge graph 'a 'b) (dag-draw-add-edge graph 'b 'c) ;; 8 lines for 3 nodes, 2 edges ``` ```emacs-lisp ;; Declarative (all at once): (setq graph (dag-draw-create-from-spec :nodes '((a :label "Task A") (b :label "Task B") (c :label "Task C")) :edges '((a b) (b c)))) ;; 5 lines for same graph ``` -------------------------------- ### Get or Set Graph Coordinate Mode (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Returns the current coordinate system mode of the graph, which can be either 'ascii' or 'high-res'. This mode can also be changed using `setf`. ```emacs-lisp (dag-draw-graph-coordinate-mode graph) ``` ```emacs-lisp (setf (dag-draw-graph-coordinate-mode graph) 'high-res) ``` -------------------------------- ### Add Nodes with Visual Properties (Emacs Lisp) Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/dag-draw.org Demonstrates adding nodes to a graph with various visual properties for ASCII and SVG rendering. Includes examples for task completion markers, highlighting, custom SVG colors, and stroke styles. Requires the 'ht' library. ```emacs-lisp (require 'ht) ;; Completed task with checkmark (dag-draw-add-node graph 'done "Research" (ht (:ascii-marker "✓ "))) ;; In-progress task with double border (dag-draw-add-node graph 'active "Implementation" (ht (:ascii-highlight t) (:ascii-marker "→ "))) ;; SVG with custom colors (dag-draw-add-node graph 'critical "Fix Bug" (ht (:svg-fill "#ff4444") (:svg-stroke "#cc0000") (:svg-stroke-width 3))) ``` -------------------------------- ### Prefixing Unused Local Variables with _ in Emacs Lisp Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org This snippet demonstrates the convention of prefixing unused lexical variables with an underscore to improve code readability. It shows both correct and incorrect usage. ```emacs-lisp ;; good (lambda (x _y) x) ;; bad (lambda (x y) x) ``` -------------------------------- ### Emacs Lisp 'if' Form Indentation Source: https://github.com/trevoke/dag-draw.el/blob/congruence/doc/emacs-lisp-style-guide.org Specifies the indentation for the 'then' clause of an Emacs Lisp 'if' form. The 'then' clause should be indented by 4 spaces relative to the 'if' keyword. ```emacs-lisp ;; good (if something then-clause else-clause) ;; bad (if something then-clause else-clause) ```