lean4-htt/src/emacs
2017-06-28 10:43:19 -07:00
..
features test(emacs/features): add ecukes template 2014-09-11 12:33:49 -07:00
test chore(emacs/lean-util): delete old code 2016-12-27 21:41:02 -08:00
.gitignore chore(emacs): fix cask warnings 2016-10-21 15:42:29 -07:00
Cask refactor(src/emacs/*): remove dependence on fill-column-indicator 2016-12-08 14:53:09 -08:00
CMakeLists.txt fix(CMakeLists.txt): quote CMake variables 2015-03-28 22:38:11 -04:00
eri.el feat(emacs/eri.el): add eri.el (from agda mode) 2014-08-30 14:57:34 -07:00
lean-company.el feat(frontends/lean/interactive,emacs): highlight current tactic parameter 2017-03-17 18:20:44 -07:00
lean-debug.el fix(emacs/lean-debug): disable undo in lean-debug buffer 2017-02-21 10:55:15 -08:00
lean-flycheck.el fix(emacs/lean-flycheck): typo 2017-02-04 13:50:22 -08:00
lean-hole.el fix(emacs/lean-hole): fix end position computation 2017-06-18 08:08:40 +02:00
lean-info.el feat(emacs): Add a right-click menu to the Emacs mode 2017-06-16 12:23:55 +02:00
lean-input.el fix(emacs/lean-input): remove overloading of \b abbreviation 2017-02-21 10:54:19 -08:00
lean-message-boxes.el fix(emacs): Improve cursor motion with output boxes 2017-06-16 12:39:52 +02:00
lean-mode.el feat(emacs): Add a right-click menu to the Emacs mode 2017-06-16 12:23:55 +02:00
lean-pkg.el feat(emacs): support leanpkg.path files 2017-05-01 14:11:38 -07:00
lean-require.el refactor(src/emacs/*): remove dependence on fill-column-indicator 2016-12-08 14:53:09 -08:00
lean-right-click.el feat(emacs): Add a right-click menu to the Emacs mode 2017-06-16 12:23:55 +02:00
lean-server.el feat(emacs): Add a right-click menu to the Emacs mode 2017-06-16 12:23:55 +02:00
lean-settings.el feat(emacs): Add the display of Lean messages in transient boxes 2017-06-15 14:15:07 +02:00
lean-syntax.el feat(emacs): highlight escaped identifiers 2017-06-28 10:43:19 -07:00
lean-type.el fix(emacs/lean-type): replace non-stable function 2017-06-08 22:58:51 +02:00
lean-util.el feat(shell/completion,emacs/lean-company): provide doc string and location with completion candidate 2017-01-10 16:19:32 +01:00
lean.pgm chore(CMakeLists.txt): move Lean logo to make sure we can test leanemacs without installing Lean 2015-01-31 17:38:49 -08:00
load-lean.el refactor(src/emacs/*): remove dependence on fill-column-indicator 2016-12-08 14:53:09 -08:00
Makefile fix(emacs/Makefile): add missing Makefile 2014-09-14 23:14:42 -07:00
README.md feat(emacs): Add the display of Lean messages in transient boxes 2017-06-15 14:15:07 +02:00

This is the emacs mode for the Lean theorem prover.

Quick-start

If you have built lean from source, all that is necessary is to call the leanemacs_build script which automatically installs all the dependencies and opens up emacs with lean-mode loaded:

~/projects/lean/bin/leanemacs_build

If you have installed lean from a binary package, you can run leanemacs.

Trying It Out

If things are working correctly, you should see the word Lean in the Emacs mode line when you open a file with extension .lean. If you type

#check id

the word #check will be underlined, and hovering over it will show you the type of id. The mode line will show FlyC:0/1, indicating that there are no errors and one piece of information displayed.

Key Bindings and Commands

Key Function
M-. jump to definition in source file (lean-find-definition)
S-SPC auto complete identifiers, options, imports, etc. (company-complete)
C-c C-k shows the keystroke needed to input the symbol under the cursor
C-c C-x execute lean in stand-alone mode (lean-std-exe)
C-c SPC run a command on the hole at point (lean-hole)
C-c C-g toggle showing current tactic proof goal (lean-toggle-show-goal)
C-c C-n toggle showing next error in dedicated buffer (lean-toggle-next-error)
C-c C-b toggle showing output in inline boxes (lean-message-boxes-toggle)
C-c C-r restart the lean server (lean-server-restart)
C-c ! n flycheck: go to next error
C-c ! p flycheck: go to previous error
C-c ! l flycheck: show list of errors

In the default configuration, the Flycheck annotation FlyC:n/n indicates the number of errors / responses from Lean; clicking on FlyC opens the Flycheck menu.

Message Boxes

To view the output of commands such as check and print in boxes in the buffer, enable the feature using C-c C-b. If you then type

#check id

a box appears after the line showing the type of id. Customize lean-message-boxes-enabled-captions to choose categories of boxes. In particular, add "trace output" to the list to see proof states and other traces in the buffer.

Requirements

lean-mode requires Emacs 24 or later and the following packages, which can be installed via M-x package-install: dash, dash-functional, f, s, company, and flycheck

Installation

You can also include lean-mode permanently in your emacs init file. In this case, just put the following code in your Emacs init file (typically ~/.emacs.d/init.el):

;; You need to modify the following two lines:
(setq lean-rootdir "~/projects/lean")
(setq lean-emacs-path "~/projects/lean/src/emacs")

(setq lean-mode-required-packages '(company dash dash-functional f
                               flycheck let-alist s seq))

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(let ((need-to-refresh t))
  (dolist (p lean-mode-required-packages)
    (when (not (package-installed-p p))
      (when need-to-refresh
        (package-refresh-contents)
        (setq need-to-refresh nil))
      (package-install p))))

(setq load-path (cons lean-emacs-path load-path))

(require 'lean-mode)

If you already have the dependencies installed, the following three lines suffice:

;; You need to modify the following two lines:
(setq lean-rootdir "~/projects/lean")
(setq load-path (cons "~/projects/lean/src/emacs" load-path))
(require 'lean-mode)

Known Issues and Possible Solutions

Unicode

If you experience a problem rendering unicode symbols on emacs, please download the following fonts and install them on your machine:

Then, have the following lines in your emacs setup to use DejaVu Sans Mono font:

(when (member "DejaVu Sans Mono" (font-family-list))
  (set-face-attribute 'default nil :font "DejaVu Sans Mono-11"))

You may also need to install emacs-unicode-fonts package.

  • Run M-x package-refresh-contents, M-x package-install, and type unicode-fonts.
  • Add the following lines in your emacs setup:
(require 'unicode-fonts)
(unicode-fonts-setup)

"Variable binding depth exceeds max-specpdl-size" Error

See Issue 906 for details. Moritz Kiefer reported that proofgeneral comes with an old version of mmm-mode (0.4.8, released in 2004) on ArchLinux and it caused this problem. Either removing proofgeneral or upgrading mmm-mode to the latest version (0.5.1 as of 2015 Dec) resolves this issue.

Contributions

Contributions are welcome!

Install Cask if you haven't already, then:

$ cd /path/to/lean/src/emacs
$ cask

Run all tests with:

$ make