Coq IDE icon missing from favorites - coq

I installed Coq and Coq IDE from here. Everything went smooth.
I launched the Coq IDE from terminal, then I right clicked it to add it to my favorites and that was not possible. When I looked for its icon in my programs it wasn't there. I'm on Ubuntu 18.04, can it be done?

You can create your own coqide.desktop in ~/.local/share/applications by imitating the ones present in /usr/share/applications.
The difficulty is that the opam installation may include multiple switches, each with one version of Coq. Thus it is not clear what binary must be pointed to by the shortlink you want to create.
I see two solutions:
choosing the version of Coq present in the current global opam switch. That's what I used for a few months a year ago. If the current opam switch does not contain a Coq binary, launching CoqIDE from the shortlink silently fails. I think I used a command similar to zsh -ic coqide (because zsh is my main shell, you may adapt this command to your own shell). I call zsh so that it loads the opam environment and can find the right coqide. The -i may not be necessary, but I remembered that without it, zsh was not loading the opam environment in my case.
choosing the version of Coq present in a given switch. You just have to adapt the previous point so that the right switch is selected before calling coqide. This gives
zsh -ic "eval $(opam env --switch myswitch) coqide"
I am not sure that running an executable by calling the shell is a good practice (I would say it is not), but at least it works and I do not see how to load the opam environment without such a hack.

Related

How to get started with OCaml on VSC?

I started learning OCaml several days ago. I installed everything and tested a small program on Atom which worked ok.
But I don't really understand how to work on VSC. I created a file 'test.ml',but how can I run it ?
Thanks in advance
Assuming VSC is Visual Studio Code (and you're on a Unix-like system):
If you want editing support such as auto-completions, you need to install OCaml Platform extension for VS Code by following installation steps outlined here. Note that the instructions indicate that you need to also have ocaml-lsp-server installed.
If you need to run test.ml as a program, you should do in the VS Code terminal:
$ ocamlc -o test test.ml # compile 'test.ml' into an executable 'test'
$ ./test # to run the program
Note that VS Code doesn't have a ready button to run an OCaml file as an executable (not yet at least).
Newcomers to OCaml are recommended to explore language either with ocaml or utop REPL.
How to get utop: Assuming you have opam installed, you should opam install utop. Aforementioned opam is a package manager for OCaml, that can also help you manage OCaml versions and is indispensable if you want to get serious about OCaml development.
Then you'll be able to launch utop in terminal, and inside utop, you can execute test.ml with
#use "test.ml"
assuming that utop was launched from the folder containing test.ml.
You should be able to do the same with ocaml REPL that is installed along with OCaml compiler, but it's much less convenient.

Adding click autocompletion to conda env activate script

I'm using a Python library which uses click autocompletion. Since I've installed the library in a conda env, I'd like the autocomplete to be associated with it. (Also, since it isn't installed in my primary Python env, adding eval "$(_FOO_BAR_COMPLETE=source_zsh foo-bar)" to my .zshrc doesn't work.) The documentation for the library I'm using says "if gradient was installed in a virtual environment, the following has to be added to the activate script":
eval "$(_GRADIENT_COMPLETE=source gradient)"
I originally added this to ~/miniconda3/envs/my_env/lib/python3.6/venv/scripts/common/activate, but the autocompletion didn't work. Running
source ~/miniconda3/envs/my_env/lib/python3.6/venv/scripts/common/activate
does work, but my shell prepends via __VENV_DIR__ to the prompt, and the fact that this doesn't happen automatically when I run conda activate myenv makes me think this is the wrong way to do it (for one, it isn't disabled when I do conda deactivate my_env).
What I'm looking for is the canonical way to add a script to run upon conda activate x, then end upon conda deactivate x. This seems very close, but it's for adding shell variables with export and unset. Is there a way to do it with click's autocomplete?
Following a small modification of the instructions in the docs seemed to work for me - I placed the eval statement in env_vars.sh, and nothing in deactivate.d.
My understanding is that export is persistent in the shell throughout sessions, and so must be undone with a corresponding unset. Whereas eval only works for that session, so as soon as the conda env is deactivated it no longer has an effect.
Would be happy to hear more from someone with a deeper understanding of bash/conda under the hood!

Elpy to allow pyenv to work on a project basis

I've used Emacs for all my coding projects so far. Soon I will start some python projects for the first time and would love to stick to Emacs for these as well.
I was looking into elpy which seems to provide already alot of desired functionality. The part I was not able to figure out completely is the following. I like to define virtual environments and python version to be used on a project basis. Let's say I start a project A, then I would use pyenv-virtualenv or pyenv-virtualenvwrapper to set it up
pyenv virtualenv 3.4.2 my-virtual-env-3.4.2
by doing this I've linked the python version 3.4.2 to that specific virtualenv / project. I have two questions regarding this in combination with elpy.
Question: This is a rather basic one. All the above can be achieved via the terminal. What is the advantage to emacs to support this? The workflow for me would be: Create project with associated virtualenv and python version. Activate virtualenv and start coding in emacs. If I need to install a package I will run pip in the terminal to ensure virtualenv is captured properly. There must be a reason why it's beneficial to support this in emacs. With my lack of knowledge I just don't see it :)
As pointed out there is for sure a good reason why we want emacs / elpy to support this. My second question would then be
**Question: How can I achieve this in emacs? Lokks like this blog has a solution. I was wondeirng if someone already tried this setup if it is a neat solution with makes sense conceptually. **
Well I strongly guess the goal is to use more features than just syntax highlighting: flycheck/flake8/linting, refactoring, elpy's test runner to use the right python version, install a pip package directly from emacs, stuff like this. You can carry on doing this in the terminal, but once you want an emacs feature, you'll need to set it up.
IĀ found two modes to do that (see wikemacs python page and doubled-checked on melpa): pyenv-mode (in melpa) and pyenv-mode-auto (change the version when there is a .python-version file).

How to install Coq

I have been installing Coq using the download links from the https://coq.inria.fr/ for both Windows and Mac. However, when I try coqc or coqtop on terminal or command prompt I get error messages saying that the command is not found. Although with that being said, I can still run Coq almost perfectly fine on the Coq IDE but when I compile buffer, in particularly the exercises from Software Foundations, i get the following message.
Running: coqc -I '/Users/zhangsheng/Desktop/G/repos/Coqy/cis500' '/Users/zhangsheng/Desktop/G/repos/Coqy/cis500/Basics.v' 2>&1
From what I understand, 2>&1 seems to be some form of misdirection and I feel that is the reason why coqc and coqtop don't seem to work on my terminal/command prompt.
Could someone kindly suggest the 'best' way to install Coq on either Mac or Windows or both such that I don't get the problems I mentioned above?
Although I am not a Windows or OSX user, I imagine that you're having this problem because the Coq installer does not update the system's PATH variable. This variable is a list of directories used by the terminal to look up the programs corresponding to commands you type. If you don't want to install Coq via a different method, you should probably find where the coqc and coqtop binaries are installed, and add these directories to your PATH. Here are a few references on how to do this: OSX, Windows.

How do I get eshell working correctly in emacs?

For some reason, when I type in commands I'm used to on linux, it works perfectly, as it does in bash... But in eshell, it doesn't work.
I've narrowed the problem to a trivial and small sample, as follows:
$ du
c:/Program: command not found
$ which bash
c:/Program Files (x86)/Git/bin/bash.exe
How do I get this working? (du is whatever it is by default... It's implemented in elisp, I haven't made any unusual changes there, that is, it's a compiled lisp function in `em-unix.el')
I would've expected something along the lines of "You have used 1.3 GiB of disk space", rather than that command not found error.
It doesn't use bash.exe, but it can use du.exe, when present.
On my system:
c: gutov $ which bash.exe
which: no bash.exe in ...
c: gutov $ which du.exe
h:/Apps/System/gnuwin32/bin/du.exe
From your error message I can tell that it calls some command and fails because it doesn't properly quote the path to executable (which contains spaces). Maybe you should do M-x report-emacs-bug.
Overall, I recommend:
1) Uninstall Git and reinstall it selecting the second option when asked about your PATH environment ("Run Git from the Windows Command Prompt"). This will remove the unix tools packaged with it from PATH.
2) Install in some directory without spaces and add to PATH unix tools from GnuWin32 project, or from Eli Zaretski's ports. The latter contains fewer packages overall, but it has a much faster find, for example. You can mix them.
Alternatively, maybe you can get away with just reinstalling Git into directory without spaces.