Skip to content

An Emacs Major Mode for editing Answer Set Programs

License

Notifications You must be signed in to change notification settings

llaisdy/clingo-mode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clingo-mode

A major mode for editing Potassco Answer Set Programs files (.lp).

From the Potassco website:

Answer Set Programming (ASP) offers a simple and powerful modeling language to solve combinatorial problems. With our tools you can concentrate on an actual problem, rather than a smart way of implementing it.

Features

  • Syntax highlighting
  • Commenting functionality
  • Run clingo from emacs
  • Some smart indentation (inherited from parent prolog-mode)

Keybindings

  • C-c C-b Call clingo with the current buffer
  • C-c C-e Call clingo with the current buffer as encoding and some user provided instance
  • C-c C-r Call clingo with the currently selected region

The above will all prompt for clingo command-line options (e.g., -c n=3 -n 0, etc.). If there is one, the prompt will show the previous options string used, and will use that by default if an empty string is input (ie just return with no input). To run with no options, ignoring any default, a space can be entered here.

  • C-c C-c Comment region
  • C-c C-u Uncomment region

Installation

Melpa

clingo-mode is available through the https://github.com/melpa/melpa repository. This is the recommended way to install.

You can either install clingo-mode by hand with:

M-x package-install [RET] clingo-mode [RET]

or place the following snippet into your Emacs init file:

(unless (package-installed-p 'clingo-mode)
  (package-refresh-contents)
  (package-install 'clingo-mode))

The package can also be installed with use-package:

(use-package clingo-mode)

Manually

Download the clingo-mode.el file from this repository. Either put it into your emacs load path and call (require 'clingo-mode) in your init file or load it directly with (load "~/path/to/clingo-mode.el")

Afterwards opening an .lp file triggers clingo-mode or call M-x clingo-mode within an open asp file.

Further work

  • IMPORTANT clingo-run-region is currently unsafe. The region is sent to clingo as a string, so any quotes or escape characters will affect what reaches clingo.
  • Smart indentation based on nesting depth
  • Refactoring of predicates/variables (complete buffer and #program parts)
  • Color compilation output
  • Smart rearrangement of compilation output (predicates separated, table…)
  • yas-snippet for rules; constraints; soft constraints; generation?
  • sync as much as possible with vim-syntax-clingo
  • integrations with org-mode, company, etc.

Contributions

Contributions, via issues, ideas and pull requests, are very welcome!

License

Copyright (c) 2020 by Ivan Uemlianin
Copyright (c) 2017 by Henrik Jürges

Distributed under the GNU General Public License v3; see LICENSE or type C-h C-c to view it.

About

An Emacs Major Mode for editing Answer Set Programs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 100.0%