I am basically executing:
ocamlmktop -o mytoplevel 1.cmo 2.cmo
and I get by an executable toplevel. The question is how do I make aquamacs run that toplevel?
It depends of the Emacs mode that you use to develop in OCaml under Aquamacs. As tuareg-mode is by far the most popular choice, I consider this case.
You usually start an OCaml toplevel with the command M-x tuareg-run-ocaml which prompts for a toplevel to start. You can here enter the path to your custom toplevel.
The toplevel proposed by tuareg-run-ocaml is actually the value of the variable tuareg-interactive-program, you can take advantage of this to define a custom tuareg-run-mytoplevel function with:
(defun tuareg-run-mytoplevel ()
(interactive)
(let ((tuareg-interactive-program "/path/to/mytoplevel"))
(tuareg-run-ocaml)))
If you put this definition in your ~/.emacs, you can then use the command M-x tuareg-run-mytoplevel to start your own toplevel.
Related
I heavily used gdb before, and now give lldb a shot. I like gdb's start command very much, but I can't find the equivalent one from lldb's manual. Now I can only use "b main" followed by run compound instead. So just curious whether there is an equivalent one in lldb? Or I can only use the compound of "b main" and run commands as a work-around.
You are correct, lldb doesn't have a dedicated start command. The stated motivation for that command is that gdb supports lots of runtimes that don't use a "main" symbol. That makes determining where user code begins non-trivial, and it's useful to have a command that figures that out for you. We haven't had a need for that in lldb yet.
If you always use start to run programs in gdb, then you can just set a breakpoint on main in your ~/.lldbinit file. That will get copied to any new targets that get made in your lldb session, and run will behave exactly like start (for runtimes that use a main symbol).
If it's something you would use a lot but not always, you could make your own version fairly easily using the python extension point in the command interpreter:
https://lldb.llvm.org/use/python-reference.html#create-a-new-lldb-command-using-a-python-function
Also, feel free to file an Enhancement Request with http://bugs.llvm.org.
Is there a way I can make emacs compile and run my code in an external console window with the command M-x compile (what I mean by external console window is that I want it to run my code in a new console window like it does when I run my C++ code in visual studio).
I want emacs to automatically open up a new console window and run the executable after M-x compile like this:
Normally with Emacs, when you want some obscure (i.e. some simple, or special to your use case) automation, you just write a command, which does what you want.
Here is such an example. Following Elisp code calls a function and-run, when compilation is finished (through using hook compilation-finish-functions).
(defun and-run (&rest _)
"run after comilation, an not elaborated example function"
(interactive)
(let ((exe "./test.out")
(prevent-closing (concat "echo \"Press Enter to continue\"" ";"
"read"))
(terminal "xterm -e"))
(when (file-exists-p exe)
(let ((my-command (concat exe ";" prevent-closing)))
(shell-command (format "%s %s" terminal (shell-quote-argument my-command)))))))
(add-hook 'compilation-finish-functions #'and-run)
Since I'm no Windows user you have to make some small adaptions to this function, in order to be able to run it on Windows.
Note: there is also a compilation-start-hook, if you e.g. want to compare file-modification times of your exe.
Since everything is 32-bit, I used :set makeprg=mingw32-make, and then tried compiling via :!make, which gave the following error message:
'make' is not recognized as an internal or external command, operable program or batch file.
shell returned 1
I tried the basic "Goodbye World" stuff:
#include <iostream>
int main() {
std::cout << "Goodbye World";
return 0;
}
What am I doing wrong? Other than being a noob.
:!make doesn't run 'makeprg'. It runs make. Since you are specifically trying to run mingw32-make.exe, presumably you don't have an executable named make.exe. (See :help :!)
:make runs 'makeprg'. (See :help :make, :help 'makeprg')
my goal is to see the "Goodbye World" either in console or terminal or any observable way. Would this require additional tinkering to the _vimrc file?
You would rather want to do it by tinkering with your makefile. Any arguments to :make will be passed to 'makeprg'. If you defined targets clean (to remove the Make artefacts) or run (to execute the product of your Make), you will be able to write :mak clean or :mak run in Vim to run those targets. Obviously, you can create your own commands and/or mappings to make those :make commands faster.
Note (and I completely overlooked this myself, silly me) that when you run a simple code, such as the one above, that does not need extensive file managements and Makefiles, all you need to go is :!gcc % for C and :!g++ % for C++. I believe (and I may be wrong, but this is a simple observation) that in Vim, :! indicates the following commands are to be executed in the system Command Prompt, and gcc/g++ is the command to invoke the GNU Compiler for C and C++ respectively. Finally, % is used to indicate the current filename, with all extensions intact. This is extremely useful in cases of keymapping, as I have done via the following:
nnoremap <F5> :!g++ %<CR>|"Press Func.5 to Compile via GNU Comp.
How do I load cl-opengl and lispbuilder-sdl-image automatically at emacs startup?
now i have to slime-compile-load these commands in emacs at startup to use cl-opengl and image:
(asdf:load-system :cl-opengl)
(asdf:load-system :cl-glu)
(asdf:load-system :cl-glut)
(asdf:load-system :cl-glut-examples)
(asdf:load-system :lispbuilder-sdl-image)
because when i put in .emacs i get error message below and emacs starts with white interface(normally black):
Symbol's function definition is void: asdf:load-systemSymbol's function definition is void: asdf:load-system
Emacs doesn't run common lisp. If what you want to do is load them when you start common lisp check your distribution's documentation. In the case of sbcl just put the expresions inside of the file .sbclrc in your home directory. Althought I would recommend using quicklisp to fetch the packages for you. So ql:quickload instead of asdf:load-system
I have been trying to figure out a way to efficiently save a program, compile it and then run it in emacs. I have succeeded only partially in it.
I use smart-compile.el to make the job easier ( http://emacswiki.org/emacs/smart-compile.el ).
In that I have edited the C++ relevant portion to the below so that a program compiles and runs when I type M-x smart-compile RET followed by a RET.
(defcustom smart-compile-alist '(
;; g++-3 is used instead of g++ as the latter does not
;; work in Windows. Also '&& %n' is added to run the
;; compiled object if the compilation is successful
("\\.[Cc]+[Pp]*\\'" . "g++-3 -O2 -Wall -pedantic -Werror
-Wreturn-type %f -lm -o %n && %n")
..
To give an example, for a program sqrt.cpp, smart-compile auto generates following compile command:
g++-3 -O2 -Wall -pedantic -Werror -Wreturn-type sqrt.cpp -lm -o sqrt && sqrt
This works as long as my .cpp does not have any cin statement. For codes with cin statements, the console window shows the point where the user is supposed to input data. But I am unable to input anything and the Compilations status stays stuck at running.
In order to make the codes with user input work, I have to remove the && FILENAME part and then manually run ./FILENAME in emacs' eshell.
I am running emacs 24.3 in Windows. I have Cygwin installed and its bin added to the Windows environment variable Path (that's why g++-3 compilation works).
I would appreciate if someone could guide me how to save-compile-run user input required .cpp programs in emacs using a single command. Or at least how do I need to modify the above g++-3 command to make compile+run work for user input programs.
Thanks!
Emacs is programmable, so if something requires two steps, you can write a command that combines them. The simples code would look like this:
(defun save-compile-execute ()
(interactive)
(smart-compile 1) ; step 1: compile
(let ((exe (smart-compile-string "%n"))) ; step 2: run in *eshell*
(with-current-buffer "*eshell*"
(goto-char (point-max))
(insert exe)
(eshell-send-input))
(switch-to-buffer-other-window "*eshell*")))
The above code is simple, but it has one flaw: it doesn't wait for the compilation to finish. Since smart-compile doesn't support a flag for synchronous compilation, this must be achieved by temporarily hooking into the compilation-finish-functions, which makes the code more complex:
(require 'cl) ; for lexical-let
(defun do-execute (exe)
(with-current-buffer "*eshell*"
(goto-char (point-max))
(insert exe)
(eshell-send-input))
(switch-to-buffer-other-window "*eshell*"))
(defun save-compile-execute ()
(interactive)
(lexical-let ((exe (smart-compile-string "./%n"))
finish-callback)
;; when compilation is done, execute the program
;; and remove the callback from
;; compilation-finish-functions
(setq finish-callback
(lambda (buf msg)
(do-execute exe)
(setq compilation-finish-functions
(delq finish-callback compilation-finish-functions))))
(push finish-callback compilation-finish-functions))
(smart-compile 1))
The command can be run with M-x save-compile-execute RET or by binding it to a key.