Giter Site home page Giter Site logo

cpitclaudel / company-coq Goto Github PK

View Code? Open in Web Editor NEW
348.0 11.0 30.0 23.33 MB

A Coq IDE build on top of Proof General's Coq mode

License: GNU General Public License v3.0

Python 3.80% Coq 8.65% Awk 0.06% Makefile 0.61% Emacs Lisp 85.76% Shell 0.85% TeX 0.27%
proof-general coq integrated-development-environment company-mode emacs proof-assistant

company-coq's Introduction

Company-coq

GPL 3 MELPA DOI

A collection of extensions for Proof General's Coq mode.

See screenshots below, or jump right to setup instructions and try the tutorial with M-x company-coq-tutorial after setting up!

Setup

MELPA

Both proof-general and company-coq are on MELPA, a repository of Emacs packages. Skip this step if you already use MELPA. Otherwise, add the following to your .emacs and restart Emacs:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

Proof General and Company-Coq

Install and byte-compile Proof General, Company-Coq, and its dependencies by typing successively:

  • M-x package-refresh-contents RET
  • M-x package-install RET proof-general RET
  • M-x package-install RET company-coq RET

(some dependencies will produce a few warnings; that's OK).

To enable company-coq automatically, add the following to your .emacs:

;; Load company-coq when opening Coq files
(add-hook 'coq-mode-hook #'company-coq-mode)

Then restart and launch the tutorial with M-x company-coq-tutorial!

Screenshots

Prettification of operators, types, and subscripts

Prettification of math symbols (disabled) Prettification of math symbols (enabled)

Auto-completion

Auto-completion of tactics, with documentation Auto-completion of commands, with documentation

Auto-completion of local definitions Fuzzy auto-completion of module names

Auto-completion of hypotheses Auto-completion of search results Unicode math symbols

Auto-completion of user-defined tactic notations Source browser (requires symbol completion)

Snippets and smart commands

Insertion of new match cases

Insertion of new match goal rules

Fully explicit intros (smart intros)

Outlines, code folding, and jumping to definition

Outline of Coq source files

Code folding

Jumping to definition (cross references)

Help with errors

Diffs of unification errors Documentation for (documented) error messages

Misc. extensions of Proof General

Highlighting of deprecated forms Special syntax for titles in comments Quick help (inline docs)

Help with Unicode input Details about prettifications

Citing

Use M-x company-coq-cite to insert the BibTeX entries for Coq, Proof General, and company-coq in the current buffer.

@InProceedings{CompanyCoq2016,
  Title     = {Company-Coq: Taking Proof General one step closer to a real IDE},
  Author    = {Pit-Claudel, Clément and Courtieu, Pierre},
  Booktitle = {CoqPL'16: The Second International Workshop on Coq for PL},
  Year      = {2016},
  Month     = jan,
  Doi       = {10.5281/zenodo.44331},
  Url       = {http://hdl.handle.net/1721.1/101149}
}

Quick start guide

You can check out the interactive tutorial by pressing M-x company-coq-tutorial RET. See also the screenshots above!

company-coq should be pretty transparent. Completion windows will pop up when company-coq has suggestions to make. By default, this would be when you start writing a tactic name or a command. You can also launch manual completion by using C-RET (or whatever was originally assigned to proof-script-complete in Coq mode).

Once auto-completion has started, the following key bindings are available:

  • RET selects a completion
  • C-g interrupts completion.
  • C-h and <f1> display documentation for the currently highlighted keyword, identifier, or tactic.
  • C-M-v scrolls down in the documentation window.
  • C-w opens source view when available (alternatively, pressing M-. browses to the definition of the identifier at point).

Selecting a completion often inserts a snippet with holes at the current point (company-coq uses yasnippet as the snippet backend). You can move between holes by using <tab> and S-<tab>.

Loading company-coq also binds the following keys:

  • M-RET inserts a new match case (| _ => _).
  • M-S-RET inserts a new match goal rule (| [ H: _ |- _ ] => _).
  • C-c C-a C-x extracts the current goal into a separate lemma.
  • C-down-mouse-1 (i.e. C-click) shows an inline quick help box for the identifier under point. The box disappears when the mouse is released. Pressing the <menu> key or M-F12 also works.
  • M-. jumps to the source of the identifier at point, when available.
  • C-c C-d opens the documentation of the identifier at point (for theorems and definitions; for tactics, use C-h during completion).
  • C-c C-, opens an outline of the code in a separate buffer (using occur).
  • C-c C-/ folds the current definition, or all definitions in the file if repeated.
  • C-c C-\ unfolds the current definition, or all definitions in the file if repeated.
  • S-TAB folds or unfolds the current bullet or curly-brace-delimited block. With C-u, S-TAB folds all bullets and braces in the current buffer.
  • C-c C-& looks up (grep) the current word in files in the current directory's subtree.
  • C-c C-a C-e tries to match the last output to a documented error message, and displays the relevant section of the manual if it finds one.
  • C-c C-a C-d parses the last unification error, and shows a diff of the two types that can't unify. If there is no such error, C-c C-a C-d shows a diff comparing the last goal to the previous one.

Tips

  • Most completion engines support fuzzy matching: you can type Require Import C.N..Ab.ZPa and press RET to insert Coq.Numbers.Integer.Abstract.ZParity, and typing setrewin is enough to insert setoid_rewrite term in ident. You can (and must) omit spaces: SLD will insert Set Ltac Debug (of course SetLtDeb will also work), and ULD will insert Unset Ltac Debug.
  • Using M-S-RET to insert new cases in a match goal saves a lot of time (and finger contortions). For the match itself, use mgw (for match goal with).
  • The point-and-click feature (quick help) also works in non-graphic mode, if you enable xterm-mouse-mode.
  • company-coq improves on some of Proof General's features. Try C-c C-a RET nat RET.
  • Try right-clicking on a [Require Import] statement.
  • Use a__b to display ab.

company-coq is implemented as a collection of small modules implementing independent features; check out M-x customize-variable RET company-coq-disabled-features RET and M-x customize-group RET company-coq RET for more info!

Troubleshooting

Empty squares in place of math operators, or incorrect line spacing

If you see blank squares appear where there should be math symbols (forall, exists, etc.), or if some lines suddenly become very tall, you may be missing a proper math font. See Installing a math font, or insert the following snippet in your .emacs to disable symbols beautification:

;; Disable symbol prettification
(setq company-coq-disabled-features '(prettify-symbols))

On the other hand, if you like the prettification feature a lot, you can enable it in the terminal:

(setq company-coq-features/prettify-symbols-in-terminals t)

Technical note: Proof General also offers a Unicode keywords facility. company-coq's implementation is based on the prettify-symbols-mode facility found in Emacs 24.4+, yielding a more compact (and faster?) implementation.

Advanced topics

Installing a math font

For prettification to work properly, you'll need a font with proper symbol support. Symbola (up to version 10.23), FreeMono, XITS Math, Segoe UI Symbol, Latin Modern, and Cambria Math will all work. If Emacs doesn't fallback properly, you can use the following snippet (change XITS Math and DejaVu sans Mono to the Unicode font you just downloaded and to your usual monospace font, respectively):

(set-fontset-font t 'unicode (font-spec :name "XITS Math") nil 'prepend)
(set-fontset-font t 'greek (font-spec :name "DejaVu sans Mono") nil 'prepend)

Or, in Emacs < 25:

(dolist (ft (fontset-list))
  (set-fontset-font ft 'unicode (font-spec :name "YOUR-USUAL-FONT"))
  (set-fontset-font ft 'unicode (font-spec :name "XITS Math") nil 'append))

Fixing math indentation

Using a variable-width font for symbols will break indentation. See this other project of mine to download a monospace-friendly symbols font. You'll want to replace the snippet above by following (adjusting Latin Modern Math and DejaVu sans Mono as appropriate):

(set-fontset-font t 'unicode (font-spec :name "Latin Modern Math Monospacified for DejaVu sans Mono") nil 'prepend)

Or, in Emacs < 25:

(dolist (ft (fontset-list))
  (set-fontset-font ft 'unicode (font-spec :name "YOUR-USUAL-FONT"))
  (set-fontset-font ft 'unicode (font-spec :name "Latin Modern Math Monospacified for YOUR-USUAL-FONT") nil 'append))

Folding all goals when a file is opened

Adding the following header to a Coq file will make company-coq hide the bodies of all bullets when the file is opened. You can also customize the company-coq-initial-state variable to apply the setting globally.

(* -*- company-coq-initial-fold-state: bullets; -*- *)

Showing alerts for long-running proofs

If possible, company-coq will use the alert library to display notifications when long-running proofs complete. alert is only needed on Windows and OSX; on Linux systems with DBus this should work out of the box. You can try it out by running the snippet below and opening another application while the proof runs; after 10 seconds company-coq will show a notification.

Goal True.
  Fail timeout 10 repeat pose 1.

Registering your own symbols and math operators

For a single file

Add the following header to a Coq file, save, and run M-x revert-buffer to prettify squiggly arrows.

(* -*- company-coq-local-symbols: (("<~>" . ?↭) ("~>" . ?↝) ("<~" . ?↜)); -*- *)

Alternatively, you can use a special comment at the end of the file:

(* Local Variables: *)
(* company-coq-local-symbols: (("<~>" . ?↭) ("~>" . ?↝) ("<~" . ?↜)) *)
(* End: *)

Tip: you can use M-x add-file-local-variable to add this sort of variables.

For a single project

Create a .dir-locals.el file at the root of your project, and add following contents to it:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((coq-mode
  (company-coq-dir-local-symbols
   (("<~>" . ?↭) ("~>" . ?↝) ("<~" . ?↜)))))

Tip: you can use M-x add-dir-local-variable to add this sort of variables.

For all Coq files

Adjust and use the following snippet to register your own prettifications for all Coq files. This must run before (company-coq-mode), so it must be added after the company-coq setup code above.

(add-hook 'coq-mode-hook
          (lambda ()
            (setq-local prettify-symbols-alist
                        '((":=" . ?≜) ("Proof." . ?∵) ("Qed." . ?■)
                          ("Defined." . ?□) ("Time" . ?⏱) ("Admitted." . ?😱)))))

Greek symbols can be obtained using the following mappings:

'(("Alpha" . ) ("Beta" . ) ("Gamma" . )
  ("Delta" . ) ("Epsilon" . ) ("Zeta" . )
  ("Eta" . ) ("Theta" . ) ("Iota" . )
  ("Kappa" . ) ("Lambda" . ) ("Mu" . )
  ("Nu" . ) ("Xi" . ) ("Omicron" . )
  ("Pi" . ) ("Rho" . ) ("Sigma" . )
  ("Tau" . ) ("Upsilon" . ) ("Phi" . )
  ("Chi" . ) ("Psi" . ) ("Omega" . )
  ("alpha" . ) ("beta" . ) ("gamma" . )
  ("delta" . ) ("epsilon" . ) ("zeta" . )
  ("eta" . ) ("theta" . ) ("iota" . )
  ("kappa" . ) ("lambda" . ) ("mu" . )
  ("nu" . ) ("xi" . ) ("omicron" . ?ο)
  ("pi" . ) ("rho" . ) ("sigma" . )
  ("tau" . ) ("upsilon" . ) ("phi" . )
  ("chi" . ) ("psi" . ) ("omega" . ))

in which case you may want to use a custom font for Greek characters:

(dolist (ft (fontset-list))
  (set-fontset-font ft 'greek (font-spec :name "DejaVu Sans Mono")))

Tip: to add multi-character substitutions, you may want to consult issue #201.

Autocompleting symbols and tactics defined externally

The procedure above will give you auto-completion and documentation for tactics, commands, and theorems that you define locally, but not for theorem names and symbols defined in the libraries you load. To get the latter, add the following to your .emacs, before (company-coq-mode):

(setq company-coq-live-on-the-edge t)

Installing from source

Use Cask.

Special thanks

Many thanks to Pierre Courtieu for his work on Proof General, and to Jonathan Leivent and Jason Gross for their tireless bug reports and suggestions!

company-coq's People

Contributors

aa755 avatar anton-trunov avatar carlolson avatar cpitclaudel avatar dwoos avatar erikmd avatar infernalknight avatar mattam82 avatar soraros avatar tchajed avatar txyyss avatar vzaliva avatar wetneb avatar wilcoxjay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

company-coq's Issues

company-coq.el:64:1:Error: Cannot open load file: no such file or directory, company

I just installed cask and tried building company-coq (I was previously running from sources), and got this:

il@jess:~/git/company-coq$ make
env --unset INSIDE_EMACS EMACS=emacs cask clean-elc
env --unset INSIDE_EMACS EMACS=emacs cask build
Compiling /home/jil/git/company-coq/company-coq-abbrev.el...
Wrote /home/jil/git/company-coq/company-coq-abbrev.elc
Compiling /home/jil/git/company-coq/company-coq-pkg.el...
Wrote /home/jil/git/company-coq/company-coq-pkg.elc
Compiling /home/jil/git/company-coq/company-coq-tg.el...
Wrote /home/jil/git/company-coq/company-coq-tg.elc
Compiling /home/jil/git/company-coq/company-coq-utils.el...
Wrote /home/jil/git/company-coq/company-coq-utils.elc
Compiling /home/jil/git/company-coq/company-coq.el...

In toplevel form:
company-coq.el:64:1:Error: Cannot open load file: no such file or directory, company
env --unset INSIDE_EMACS EMACS=emacs cask package
Wrote /home/jil/git/company-coq/dist/company-coq-readme.txt

Note that I have company in my .emacs.d/elpa folder, so what is going wrong?

Make show-parens-mode and prettify-symbols-mode optional

Hello,

how can I prevent company-coq from enabling show-parens-mode and prettify-symbols-mode?

The former is redundant for me since I use Smartparens, and I find the latter pretty distracting, and rather prefer to see my Coq source as is.

Fields of Inductive/Record/Class not available in completion

Consider the following code

Record foofoofoo : Type := { barbarbar : nat }.

The type foofoofoo is available in completions later in the file, but the field barbarbar is not.

The problem extends to Inductives and Classes as well.

Would it be possible to add these?

I am using coq 8.5beta2 (unpatched) with cvs trunk PG and MELPA company-coq.

Thanks for making this awesome plugin!

Completion of constants from other files does not work even if Coq is patched with SearchMinimal.patch

In 8.4pl6+ltacprof+SearchMinimal, the command Set Search Minimal. succeeds with no warning (Set Search Minimal2. succeeds with the warning Warning: There is no option Search Minimal2.), but the log in *coq* begins

Welcome to Coq 8.4pl6 (January 2016)
�Warning: /home/jgross/Documents/repos/fiat/src/Common/Tactics was previously
 bound to Fiat.Common.Tactics; it is remapped to <>�

<prompt>Coq < 1 || 0 < </prompt>Redirect "/tmp/coq5789WNY" Test Search Output Name Only.
Error: Unknown command of the non proof-editing mode.

<prompt>Coq < 1 || 0 < </prompt>Print Grammar tactic.

No completion for `nat_rect`

Not for bool_rect nor Datatypes.nat_rect either. For that matter, there's no completion for Coq.Init.Datatypes.*, nor Init.Datatypes.* nor Datatypes.nat

image

image

Suggestions about suggestion ordering

  • reflexivity should come before refine <term>
  • constructor should come before constructor num
  • discriminate (with no arguments, possibly all the variants) should come before discrR (which doesn't even seem to exist?)
    image
  • Goal Prop should not suggest Proposition # : #._Proof._#_Qed.
  • Goal Set should not suggest Search @{term_pattern}
  • Goal Type should not suggest Typeclasses eauto :=.

Feel free to edit this and crossout any that are fixed.

How do I disable the scrolling in buffer, when typing something to complete?

Sorry, I read your responds late in Issue #8 .
When using auto-complete-context and auto-complete-search-results,
the scrolling in buffer *goals* or *response* is somewhat annoying.
I already read some code in company-coq.el, and guess the problem may
in the function company-coq-search-then-scroll-up.
Your code is beautiful ~

I read the detail in Issue #8 , and reinstalled company-coq and PG, but problem
not disappeared.

Detailed situation:
For example, when I open an empty ".v" file, and type SearchAbout "_",
then there's a list lemmas in *response* buffer.
I find the lemma True_rect in line 81 is what I need.
Then, naturally, I keep typing "apply True_rect" while staring at *response*.
To my annoy, as I'm just typing "apply True" and the company menu is appearing,
*response* buffer automatically scrolls to the beginning of the buffer, and I lose
my focus. ( In my window, I need to use several PageDown jumping to line 81 from line 1)

Version information:
Emacs: 24.3
company-coq: 20150718 from melpa
PG: latest from github

Thank for your help~

'nat' is shown as [

Using GNU FreeMono font in AquaMacs instead of 'nat' is shown as [.
I also tried several other fonts.

screenshot 2015-06-25 11 59 52

Other math symbols like arrows and quantifiers are shown correctly.

C-c, C-RET should hide the dropdown box

I know it means that I'm not making good use of the completion (so maybe you will mark this as an intentional WontFix), but it might be nice if, when I type reflexivity and press C-c C-RET, I'm not left with an inconsistently blue buffer (which becomes consistent when I close the dropdown), and instead the dropdown autocloses.

"?" should not count as operator character when followed by alphanumeric

When a ? is followed immediately (no whitespace in between) by an alphanumeric, I believe that Coq in 8.5 has to parse the result is an evar (or pattern binding, or rewrite scheme, or intropattern, but these don't show up in the goals window). If so, this should be taken into account with character folding. I have a prefix operator symbol that I'm trying to fold, but when it operates on an evar, it's not folding due to the ?.

Unwanted "Company-Coq--Keybindings" mode.

I followed the config,

(require 'company-coq)
(add-hook 'coq-mode-hook #'company-coq-initialize).

However, "Company-Coq--Keybindings" mode is always on.
Especially, in term-mode, hitting space calls "company-coq-maybe-exit-snippet", preventing insertion of space.

prevent ++ from becoming ⧺ when it is a proof script bullet

The second level proof script bullet ++ shouldn't get folded into ⧺, as this both looks strange and confuses indenting. Can symbol folding get turned off in certain spots?

Ideally, it would be nice to have proof script bullets highlighted in some way so that they look like buttons - and when depressed, they hide/show that part of the proof script tree. I know hide/show and outline minor modes are supposed to do this, but have they ever worked with Coq proof scripts?

Feature wish

In proofgeneral we now have a somehow-working auto insertion of the "as" close for induction and destruct (provided they are on a single tactic), and inversion (provided you are lucky :)).

Try it with latest pg by hitting C-c C-a [ when the next command is a destruct/induction without "as" close.

the feature wish is:

It would be nice to auto-insert the as close when one types as!, as for intros!.

Best,
P.

Is there a way to turn off auto-completion in comments?

Many words I use in comments are tactic names (change, replace, introduce, apply), so the auto-completion drop-down lists keep popping up on me while writing comments, which is somewhat annoying. Is there a way to disable all auto-completion only in comments? I may still do completion in comments, but I would rather rely on dabbrev (M-/), since it stays out of sight until used.

� is not a rooster

Not sure if there's any (good?) way to fix this, but I figured it might be useful to note that the rooster doesn't show up in my remote emacs (maybe because I had to compile without support for tiffs and gifs?):
image

Feature wish: real-time extraction buffer

Clement,

I don't know if this is better for PG or company-coq, or perhaps neither, but maybe you can give me some advice on how to go about creating it. The idea is to have a buffer that shows the extraction of the current function as it changes due to tactics. Of course this might not appeal to many, as programming-by-proving is a very small niche (I'm hoping to make it bigger, and something like this would help) - so I would like to take a crack at the necessary elisp myself.

Here's my notes on this:

How to arrange for an extraction in real-time window in PG.

Use the following:

Axiom unfinishedGoal : forall (i : nat)(T : Type), T.

(which would naturally have to be injected into coqtop prior to anything else
from emacs) to finish off each subgoal of the definition being proved, tagging
each with the number of that subgoal (starting with 0 for the current one, if
there is one, else 1). Then Qed the definition. Then End any enclosing
sections. Then call Extraction on the definition - use highlighting on
unfinishedGoal calls. We could also check if any goal ins in Prop - because
those won't show up - and for each of them, output something else. However,
there might be non-Prop goals that are descendent of Prop goals, and those
don't show up either. So, maybe it is just better that not all i's for
unfinishedGoal i show up in the extraction, and leave it at that. We can
certainly specially highlight the current goal if it exists in the extraction.

There might be focus issues, and a requirement for proper usage of bullets
and/or {}. But, Coq now produces messaging on that, so we need to parse it.
This can be left for later - as we don't currently use {}.

Another issue is shelved goals that we need to do Grab Existential Variables
for. Those as well need to get unfinishedGoal treatment - but what should
their numbers be? Maybe we have a different axiom for them.

Extraction mode should only bother trying to run when the function's return
type is not in Prop.

The extraction should remain visible until proof mode is started on a new
function. Maybe put it in the response buffer? Or another buffer?

Another way to finish off the function, without having to deal with bullets
and Grab Existential Variables is to call Show Existentials - and for each
one, use the new named goal selector to admit it with an unfinishedGoal
axiom. Will this always have the first unfinishedGoal correspond to the
current selected goal? No - so maybe the better idea is to finish off the
current goal and then do Show Existentials to finish off the rest. This gets
past the need for bullets, but not for closing braces. It also gets past the
need for Grab Existential Variables.

Qed is often slow, sometime too slow to wait for in between tactic steps.
That probably means we will need to make this asynchronous with the ability to
stop things if the user moves on to the next tactic before its done.

So, the first prototype should:

  1. if a goal is open under focus, finish it with apply (unfinishedGoal 0) - so
    that unfinishedGoal 0 always corresponds to the "current" goal. How do we
    tell if there is a current goal in focus? There's probably a function in PG
    or company-coq for that.
  2. call Show Existentials, parse the output to get the evar names. The
    parsing should be easy, as the output is always "Existential n = ?Name : ..."
    with all other lines indented. Use the form
    "[Name]: apply (unfinishedGoal n)." to solve each.
  3. close out the definition with Qed - maybe "Qed exporting" is better, so
    that any abstracted subgoals don't get inlined.
  4. End any opened Sections. Leave this out until later?
  5. call Extraction on the function, highlight the "unfinishedGoal N" calls
    present in the output, maybe with special highlighting for unfinishedGoal 0,
    and put the output in the response buffer.
  6. Initially do all of the above only when triggered by some emacs command,
    but eventually hook it to the end of PG's Next, Undo, and Goto - if using the
    response buffer for the extraction, that way it will appear after any tactic
    output without hiding that output.
  7. Maybe only do the above when proving a result that is not a Prop.
  8. Undo all of the above before returning control to the user.

Possible source of confusion: the variable names (and even the function, type
and ctor names) in OCaml may be different from Coq. For people doing
extraction, it might make sense to use a naming convention that keeps the need
for differences to a minimum.

Font Beautification Adds Extra Whitespace Padding

Hello again,

As before, awesome work on this plugin! I had gone for a while without updating it, and it looks like you've added some exciting new features.

However, I notice a problem with the font beautification: some symbols (the "mathcal" symbols for Prop and Nat, as well as some of the arrows) get inserted with a large amount of space above and below them, as you can see in the following picture:

font-prettify

(There should be no whitespace above the line I selected, and only one line of whitespace below; but there is a great deal of whitespace that's been added to the line to "pad" the script P)

Right now I'm using DejaVu Sans Mono as my font, although this problem seems to happen regardless of what font I choose. Also, I am on emacs 24.4.1, on Ubuntu 15.04, using the current MELPA version of company-coq.

Best,
Mario

Can't build company-coq: init.el is missing

I tried building company-coq, and got this:

jil@jess:~/git/company-coq$ make elc
emacs -L . --batch --eval '(setq byte-compile-error-on-warn t)'
--script ~/.emacs.d/init.el -f batch-byte-compile .el
Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50ocaml-mode.el (source)...
Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
Loading /etc/emacs/site-start.d/51tuareg-mode.el (source)...
Cannot open load file: no such file or directory, /home/jil/.emacs.d/init.el
Makefile:16: recipe for target 'elc' failed
make: *
* [elc] Error 255

I don't have an init.el file in my .emacs.d. If you need some particular init script, maybe you should include it with the company-coq sources?

Title in comment are not compatible with coqdoc

Currently the comments detected by company-coq as "section titles" and displayed with wider fonts are not the one coqdoc considers as such. In particular, (*** foo *) is not considered a title, but (** * foo *) is. subtitle are.

It would be nice that company-coq stick to this syntax.

Excerpt of coqdoc documentation (https://coq.inria.fr/distrib/current/refman/Reference-Manual017.html#sec579):

Sections.

Sections are introduced by 1 to 4 leading stars (i.e. at the beginning of the line) followed by a space. One star is a section, two stars a sub-section, etc. The section title is given on the remaining of the line. Example:

(** * Well-founded relations

   In this section, we introduce...  *)

enter should not merely end completion of completly typed-in keyword

The following case keeps biting me:

match foo with
pattern => idtac

When I hit enter after fully typing idtac, all that happens is that completion is aborted. Which forces me to type a second enter to start the next line. However, my fingers won't cooperate, and start typing the next line after hitting the first enter, so I end up with:

match foo with
pattern => idtacend

or "idtac|another pattern" or something like that. Same for other optional extra arg cases, like with fail, constructor, etc.

Would it be possible to have enter both stop the attempt at further completion AND do a newline-and-indent in the case where the user completely typed a complete valid keyword themselves? Is there already such an option?

Reverting the processed part by typing inside of it generates "error in process filter: Symbol's value as variable is void: coq-hyp-name-in-goal-or-response-regexp"

Type:

Goal True. C-c C-RET

and emacs will hang briefly (O(3 seconds)) and display this error message. Same thing happens again if I then type the BACKSPACE key.

image

If it matters, my .emacs is:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
    '("marmalade" .
      "http://marmalade-repo.org/packages/"))
(package-initialize)


;(load-file "~/Programs/PG/generic/proof-site.el")
(load-file "~/Programs/ProofGeneral/generic/proof-site.el")

(defun my-other-delete-trailing-blank-lines ()
  "Deletes all blank lines at the end of the file, even the last one"
  (interactive)
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-max))
      (delete-blank-lines)
      (let ((trailnewlines (- (abs (skip-chars-backward "\n\t")) 1)))
        (if (> trailnewlines 0)
                (progn
                        (delete-char trailnewlines)))))))
(add-hook 'before-save-hook 'my-other-delete-trailing-blank-lines)
;; Prevent Emacs from extending file when
;; pressing down arrow at end of buffer.
(setq next-line-add-newlines nil)
;; Silently ensure newline at end of file
(setq require-final-newline t)
;; or make Emacs ask about missing newline
;; (setq require-final-newline 'ask)
(add-hook 'before-save-hook 'delete-trailing-whitespace)

(load-file (let ((coding-system-for-read 'utf-8))
                (shell-command-to-string "agda-mode locate")))


(defun my-agda-hook ()
  (local-set-key (kbd "C-c ,") 'agda2-goal-and-context)
  (local-set-key (kbd "C-c .") 'agda2-goal-and-context-and-inferred))

(require 'agda-input)

(defun my-coq-hook ()
  (local-set-key (kbd "C-c RET") 'proof-goto-point)
  (set-input-method "Agda")
  (company-coq-initialize)
  (define-key company-active-map [remap company-complete-common] #'company-indent-or-complete-common)
)

(add-hook 'coq-mode-hook 'my-coq-hook)
(add-hook 'agda2-mode-hook 'my-agda-hook)


(global-set-key (kbd "C-c C-a C-u") #'company-coq-diff-unification-error)

(setq company-coq-dynamic-autocompletion t)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(proof-prog-name-ask t)
 '(safe-local-variable-values (quote ((coq-prog-args "-emacs" "-compat" "8.4" "-R" "." "Fiat" "-top" "BooleanRecognizerOptimized") (coq-prog-args "-emacs" "-compat" "8.4" "-require" "Coq.Compat.AdmitAxiom" "-R" "." "Fiat" "-top" "BooleanRecognizerOptimized")))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

intros! missing whitespace after period for multiple autogenerated intros

When intros! generates several calls to intros, they are separated with a period without whitespace.

Consider the following Coq script (23 True hypotheses imply False):

Goal True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> True -> False.

Now, when doing intros! here is the generated sequence of tactic calls:

intros H H0 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20.intros H21.

There should be a whitespace after "H20." so that intros can be considered as a tactic call rather than a name qualified by the "H20" namespace.

In other words, there should be a whitespace after each "intros ... ." tactic line generated by intros! for each line output by Show Intros.

(This seemingly small bug can be annoying for autogenerated lemmas with many hypotheses.)

SearchAny In Coq-8.4pl4/pl5

This plugin looks awesome! I noticed that the only available version of the SearchAny enhancement for Coq that you provide seems to be built on Coq 8.4pl2 (https://github.com/cpitclaudel/coq/tree/V8.4pl2-SearchAny).

Because I used 8.4pl4 for my work, I created a patch of the differences between 8.4pl2-SearchAny and 8.4pl2. For convenience, I've created a gist containing the patch: https://gist.github.com/mmalvarez/6496f2ecbfe2fd661d52

I've been able to successfully apply this patch to Coq 8.4pl4 and 8.4pl5, which allows for the use of the symbol-search features of company-coq in these versions of Coq. It might be worthwhile to put the patch into the company-coq repository, or a link to the patch it into its readme, for the benefit of others who use these versions.

Thanks!

Company: Front-end company-pseudo-tooltip-unless-just-one-frontend error "Wrong type argument: number-or-marker-p, nil" on command post-command

screenshot from 2015-09-05 14 08 04

After updating all of my emacs packages just now, I pasted the code at the bottom into a fresh emacs buffer /tmp/foo5.v (with the Edit->Paste terminal menu), and then pressed the down arrow key while emacs was pasting. This is emacs inside ssh inside screen inside ssh. Holding down C-g killed it after a while.

Is it possible to make company-coq not try to do anything complicated while pasting code?

Pasted code:

Require Coq.Lists.List.
Global Set Implicit Arguments.
Import Coq.Lists.List.
Class IndexBound {A : Set} (a : A) (Bound : list A) :=
  { ibound :> nat;
    boundi : nth_error Bound ibound = Some a}.
Global Arguments ibound {A} [a Bound] _ .
Global Arguments boundi {A} [a Bound] _.
Record BoundedIndex {A : Set} (Bound : list A) :=
  { bindex : A;
    indexb :> IndexBound bindex Bound }.

Context {A : Type} {C : Set}.
Variable (projAC : A -> C).
Axiom None_neq_Some : forall (AnyT AnyT' : Type) (a : AnyT), None = Some a -> AnyT'.

Definition nth_Bounded'
           (Bound : list A)
           (c : C)
           (a_opt : option A)
           (nth_n : option_map projAC a_opt = Some c)
: A := match a_opt as x
             return (option_map projAC x = Some c) -> A with
         | Some a => fun _ => a
         | None => fun f => None_neq_Some _ f
       end nth_n.

Axiom nth_error_map : forall n As c_opt, nth_error (map projAC As) n = c_opt -> option_map projAC (nth_error As n) = c_opt.

Definition nth_Bounded
           (Bound : list A)
           (idx : BoundedIndex (map projAC Bound))
: A := nth_Bounded' Bound (nth_error Bound (ibound idx))
                    (nth_error_map _ _ (boundi idx)).

Program Definition nth_Bounded_ind2
        (P : forall As, BoundedIndex (map projAC As)
                        -> BoundedIndex (map projAC As)
                        -> A -> A -> Prop)
: forall (Bound : list A)
         (idx : BoundedIndex (map projAC Bound))
         (idx' : BoundedIndex (map projAC Bound)),
    match nth_error Bound (ibound idx), nth_error Bound (ibound idx') with
      | Some a, Some a' => P Bound idx idx' a a'
      | _, _ => True
    end
    -> P Bound idx idx' (nth_Bounded _ idx) (nth_Bounded _ idx'):=
  fun Bound idx idx' =>
    match (nth_error Bound (ibound idx)) as e, (nth_error Bound (ibound idx')) as e'
          return
          (forall (f : option_map _ e = Some (bindex idx))
                  (f' : option_map _ e' = Some (bindex idx')),
             (match e, e' with
                | Some a, Some a' => P Bound idx idx' a a'
                | _, _ => True
              end)
             -> P Bound idx idx'
                  (match e as e'' return
                         option_map _ e'' = Some (bindex idx)
                         -> A
                   with
                     | Some a => fun _ => a
                     | _ => fun f => _
                   end f)
                  (match e' as e'' return
                         option_map _ e'' = Some (bindex idx')
                         -> A
                   with
                     | Some a => fun _ => a
                     | _ => fun f => _
                   end f')) with
      | Some a, Some a' => fun _ _ H => _
      | _, _ => fun f => _
    end (nth_error_map _ _ (boundi idx))
        (nth_error_map _ _ (boundi idx')).

Lemma nth_Bounded_eq
: forall (Bound : list A)
         (idx idx' : BoundedIndex (map projAC Bound)),
    ibound idx = ibound idx'
    -> nth_Bounded Bound idx = nth_Bounded Bound idx'.
Proof.
  intros.
  eapply nth_Bounded_ind2 with (idx := idx) (idx' := idx').
  simpl.
  pattern (nth_error Bound (ibound idx')); case_eq (nth_error Bound (ibound idx')) || fail "too early".
  Undo.
  unfold Exc; case_eq (nth_error Bound (ibound idx')) || fail "too early".
  Undo.
  case_eq (nth_error Bound (ibound idx')).

If I spam C-g, it seems to consistently end up at -> P Bou in Program Definition nth_Bounded_ind2.

visual diff of goals before/after tactic

The visual diff of long type mismatch error messages is certainly useful, but can a similar thing be done about goals? I have a few tactics that, when I apply them, make very subtle changes to the goal context - sometimes so subtle and in such a large goal that I have to undo/redo them several times before realizing what changed. It would be nice to have a visual diff to highlight that type of change.

Reading through long goals has more issues. I do have a tactic that uses the new multiple-identically-typed-hyps-per-line feature to minimize the number of lines in a goal, but I am always wishing for more help with long complex goals. One thing I do on occasion is place the cursor in the goal and regexp search for a particular hyp to get emacs to highlight all spots in other hyps and conclusion where it is used. I think it would be helpful if there were ways to do such helpful highlighting while keeping the cursor in the proof script, for instance. Just brainstorming...

[M-RET] Add support for "Inductive"

First of all, thanks for this great extension.

Secondly, it would be great if company-coq-insert-match-rule-simple also worked on other situations that are similar to (but not the same as) match rules.

For instance hitting M-RET at the end of the following

Inductive day : Type :=
| monday : day

Could yield the following

Inductive day : Type :=
| monday : day
| _ : 

Displaying the completion list should not reset position in the *goals* buffer

When I have a large goal, and I am scrolled to a particular point in the *goals* buffer, if I type something, and the completion drop-down shows up, the *goals* buffer resets to its default scroll point, much the same way that it does when I execute Show. or C-c C-p. This is annoying, as it means I can't refer to a particular point in the goal while typing things.

Inline Docs

I have been looking at your inline docs feature and I think its really cool and could be used in a lot of different libraries. Did you take it from somewhere or is it unique to this project? If it is unique do you think it would be possible for someone such as myself to create a library using it which could be used elsewhere? It seems to me that too many emacs libraries just open another buffer and window which is nice in some cases because it allows one to use the same window management tools they use for everything else, but is not ideal because its less temporary and kind of out of the way from the code you are looking at at that moment.

In particular I am looking at ways to improve emacs-eclim for java development and I think borrowing this feature could really help.

If you are ok with it. I might look into writing a simple library which wraps up your inline doc feature so that other libraries can benefit from it. Let me know what you think.

Using prettify-symbols-alist only impacts source buffer, not goals or response buffers

I tried adding this to my .emacs:

(add-hook 'coq-mode-hook
          (lambda ()
            (set (make-local-variable 'prettify-symbols-alist)
                 '((":=" . ?≝)
           ("Proof." . ?∵)
           ("Qed." . ?■)
                   ("Defined." . ?□)
           ("Time" . ?⏱)
           ("Admitted." . ?😱)
           ("#+" . ?⨥)
           ("#-" . ?⨪)
           ))
        (company-coq-initialize)
        ))

and adds the new prettified symbols in the source window, but does nothing in the goals or response windows. Do I need some other setting?

when cursor is on bullet, some key bindings are missing

This is of course using the new bullet-based subproof folder in massive-cleanup. When stepping through a proof, my cursor landed on the next bullet, and I tried to do C-c C-u to undo a proof step, and emacs complained that there was no binding for that key. So, apparently, the keymap being used when the cursor is on a bullet has to inherit from the normal keymap for the proof buffer.

Be more flexible on the goal parsing

Hi,

I am planning to commit in coq trunk the fact that the goal is displayed in a more compact way in emacs mode. And the lemma extraction seems to make strong hypothesis on the way goals are displayed.

In particular in the compacted display:

  1. Several hypothesis may be on the line (separated by 3 spaces)
  2. Hypothesis are not indented by 2 spaces anymore

You end up with goal looking like this (notice that there is on space at beginning lines):

x : nat   y : bool   z : nat
H : x=1
H' : y = true
====================
...

It would be nice to support this.

YASnippet dependency

Hello,

is there a chance to make the YASnippet dependency optional? I'd love to use Company in Coq buffers, but I don't use YASnippet at all.

The script P folding for Prop takes up several lines

I know that emacs way of dealing with fonts involves black magic - so this might just be a manifestation of my local environment. The script P used as the folding of Prop takes up what appears to be several lines, even though the character itself doesn't. I temporarily worked around this by changing the mapping in company-coq-prettify-symbols-alist to use a different fancy P.

The same is apparently true for the script N for nat, and a few other symbols. Here's (hopefully, if attaching a file works) a screen shot of the etc/symbols file - note that those apparently blank lines aren't lines at all:

screenshot-symbols

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.