emacs,ocaml , Determining in emacs the module in which function is defined?


Determining in emacs the module in which function is defined?

Question:

Tag: emacs,ocaml

Say I have the following

open A
open List

let double = map (fun x -> 2*x) [1;2;3]

In emacs with merlin-mode I can place the cursor on map and execute merlin-type-enclosing to get the type of map.

Is there a similar command (in merlin, tuareg, or others) that can tell me map is part of module List, rather than A?


Answer:

merlin-locate (usually bound to C-c C-l) will jump to the correct module.

Note: currently this feature doesn't work reliably. Update: it should work since merlin 2.2


Related:


MELPA pointing to non-existent version of multi-term?


emacs,package,melpa,multi-term
I am trying to use MELPA to install the emacs package "multi-term". When I do package-install multi-term, I get "http://melpa.org/packages/multi-term-20141203.1658.el: Not found". However, a more recent version http://melpa.org/packages/multi-term-20150220.1320.el is on MELPA. Why is emacs not installing this version?

How to define a function with a variable number of arguments?


emacs,elisp
Instead of this: ((lambda (a b) (apply '+ (list a b))) 1 2) it is possible to write this in Scheme: ((lambda args (apply '+ args)) 1 2) Now it is possible to pass more than two arguments to the function. When I try it in Emacs Lisp I get...

Confused when setting an Emacs face


emacs,elisp
(set-face-attribute 'diredp-dir-heading nil '(t (:foreground blue :background dark1))) What should be the right statements to set this face? Bow//...

Performance difference between pattern matching and if-else


performance,pattern-matching,ocaml
Why can OCaml generate efficient machine code for pattern matching and not for if-else tests? I was reading Real World OCaml and I came across this section where they compared the performance of pattern matching to the performance of if-else tests. It turned out that pattern matching in their example...

looking for help in configuring .emacs file for python (python.el),


emacs,python.el
My emacs version is 24.5, using in built python. I have written these lines in my .emacs for it: (require 'python) (setq python-shell-interpreter "C:/Python34") The problem is none of the commands (when I am trying to run test.py) are working. I have tried several commands named like M-x python-shell-* and...

Exceed evaluation depth when forward function in Emacs Lisp


emacs,lisp,elisp
Here is just a simplified code snipped I have not managed to work. I do not understand what is wrong. (defun enumerate-indicies (func) (let ((index 0)) (while (< index 5) (funcall func index) (setq index (1+ index))))) (defun enumerate-multiplied-indicies (func) (enumerate-indicies #'(lambda (index) (funcall func (* 10 index))))) The following...

Task Dependency in org-mode


emacs,org-mode
I am trying to setup org-capture or org file for following issue: Task A is the major task. It depend upon minor tasks B and Task C. Now in org-agenda view, I should be able to see Task B and Task C. When they are done, I should be able...

org-mode agenda view matching tag and todo state


emacs,org-mode
I would like to create an agenda view with org-agenda-custom-commands, which will connect capabilities todo-tree and tags-tree. That's what I want to achieve, this sparse tree suited to such a search C-c / m JOB+TODO="NEXT"...

Function applied to too many arguments in lablgtk


gtk,ocaml
I need some help understanding why the following code will not compile. I am attempting to place a GSourceView2 inside a vertical box in lablgtk. I've adapted the code from this Ocaml article open GMain open GdkKeysyms let locale = GtkMain.Main.init () let main () = let window = GWindow.window...

ESS produces “Variable binding depth exceeds max-specpdl-size”


r,emacs,ess
I am trying ESS (Emacs Speaks Statistics). The problem is: Ctrl-P and the up-arrow are disabled on any buffer because of the following error: Variable binding depth exceeds max-specpdl-size The trigger is the following line in .emacs.el (require 'ess-site) This line is needed to load ESS. If I delete this...

How to start Emacs For Mac OS X from the command line without blocking?


osx,emacs
A tip from the website of Emacs For Mac OS X suggests executing the following script to start it from the command line: #!/bin/sh /Applications/Emacs.app/Contents/MacOS/Emacs "[email protected]" However, this will block the command line until Emacs.app exists. Is there a way to start it from the command line without blocking?...

Getting `which-func-mode` output as a string in Emacs lisp


emacs
I am trying to retrieve the output which-function-mode as a string in Emacs. I am going to create a keyboard binding shortcut that copies it to my clipboard. It seems like this (which-func-mode ("" which-func-format " ")) is used to insert which-function into Emacs header line. However, I can't seem...

#use “str.cma” and #use “name.mli” in Eclipse


ocaml
How do I use "str.cma" in Eclipse? Also, how do I link name.ml to name.mli? I would usually do #use "name.mli" in "name.ml" when using Emacs....

How to correctly start a process from a specific directory with Lwt


ocaml,ocaml-lwt
It is easy to start a process from a specific directory with Lwt using the functions Sys.getpwd, Lwt_unix.chdir and Lwt_process.exec: Use Sys.getpwd to save the current working directory Use Lwt_unix.chdir to change to the specific directory Use Lwt_process.exec to start the external process Use Lwt_unix.chdir to change to the saved...

How do EMACS Lisp programmers read text files for non-editing purposes?


file-io,emacs,elisp
What do EMACS Lisp programmers do, when they want to write something roughly the equivalent of... for line in open("foo.txt", "r", encoding="utf-8").readlines(): ...(split on ws and call a fn, or whatever)... ..? When I look in the EMACS lisp help, I see functions about opening files into text editing buffers...

Elisp: how to make this function short


emacs,macros,elisp
I am implementing an plugin, which a lot of project types are remembered. For example: angular, meteor, ember, rails ... And keyed arguments are used. The function creates an hash table with provided keys and values, and assign the hash table to another hash table. Code below: (defun jst-remember-project-type (type...

What are the most common bugs in OCaml/Haskell/Scala programs? [closed]


scala,haskell,types,ocaml
Now when we have these fancy type-systems to prevent null-pointer bugs and memory bugs and all, what common bugs are left? Can these bugs be prevented with different type-systems or further programming language research? Edit: Do we know what bugs are common in functional programming? Edit 2: -3 question with...

Is there an OCaml equivalent of the [] attribute for DUs in F#?


f#,ocaml,discriminated-union
In F# programs I prefer to use [<RequireQualifiedAccess>] type MyType = | FirstOption of string | SecondOption of int so that in code that uses MyType I am forced to write MyType.FirstOption instead of just FirstOption. Is there any way to force this in OCaml?...

Does OCaml have C-like round() and trunc() functions?


floating-point,ocaml
OCaml's standard library includes several floating-point functions equivalent to C ones, such as mod_float for C's fmod(), the exponentiation operator ** for C's pow(), and other functions such as ceil, log, etc. But does it also include equivalents for round() and trunc()? There is truncate/int_of_float, but their type is float...

OCaml: Removing duplicates from a list while maintaining order from the right


ocaml
I just read this thread and find it interesting. I implement the remove from the left function in a few minutes: (* * remove duplicate from left: * 1 2 1 3 2 4 5 -> 1 2 3 4 5 * *) let rem_from_left lst = let rec is_member...

Emacs dired, what controls the color of the title line of a directory


emacs,dired
As the picture shown in attachment, what is the variable, if any, that controls the color of the title line of the directory? I'm trying to change the darkgreen to grey.

Result value of elisp code stored in a file?


emacs,elisp,emacs24,dot-emacs
Looking for a way how evaluate elisp code stored in an external file and pass its result as a function argument. Example demonstrating what I'd like to achieve follows: ;; content of my_template.el '(this is a list) ;; content of .emacs where result of my_template.el has to be used (define-auto-insert...

Unit testing OCaml modules with pa_ounit


unit-testing,ocaml,ounit
I have a simple module to test with a few inline pa_ounit tests, i've setup the directory in the oasis style and got it all to build. For a reference I've been using: https://github.com/janestreet/textutils How would one execute the unit-tests for the above repo? I'm assuming there's an executable .ml...

Making socket communication using bin_prot


sockets,ocaml,communication
I want to make Socket communication using bin_prot in OCaml. However, I can't find any detailed explanation or example to do that. I made Socket communication in the other way before, so I know the flow of it. Do you have good explanations or examples to make Socket communication using...

EMACS-Live + Slime error at startup


emacs,common-lisp,slime,kubuntu
Ok, I must be missing something obvious. I'm getting stuck since yesterday to launch Emacs-live + slime. I'm using EMACS 24.3.1, installed Emacs-live and it worked well (if I start emacs-live without Slime it works), downloaded Slime-Pack from git and added this line to .emacs-live.el (live-append-packs '(~/.live-packs/slime-pack/)) I'm on a...

Emacs hotkey for diffing buffer from file without reading (confirming) buffer name


emacs,elisp
I have made a hotkey that calls the diff-buffer-with-file command but then you have to hit enter to confirm that the file you are on is the one to correctly diff: (global-set-key (kbd "C-c e") 'diff-buffer-with-file). I looked up the documentation and saw that you also give &optional BUFFER, so...

Emacs code hints in minibuffer. How do I get them?


emacs,code-hinting
I've looked all over the internet for this, and since I'm new to Emacs, I don't know what to search for. I'm not looking for mini-buffer completion for commands and such. I'm looking for code hints in the mini-buffer, as shown in this gif. I couldn't care less about the...

ocaml regex issue on “{{”


regex,ocaml
I am trying to match "{{" in a string: let regexp = Str.regexp_string "{{" let _ = if Str.string_match regexp "a{{hello}}" 0 then print_string "yes" else print_string "no" This prints "no". Why is this not matching? "{" is not a special character: $^.*+?[] Unless I am reading the manual incorrectly,...

OCaml record acceding itself


ocaml,record
I'm reading an OCaml code where lots of record are defined. These record are defining functions for an interactive command line tool. Type for these records is: { name : string ; help : string ; run : string list -> unit } where name is the name of the...

Error in Dired sorting on Windows (with Cygwin Emacs)


windows,emacs,cygwin,dired
In a Cygwin Emacs on Windows, in Dired, if I try to sort by time (for example), I get the error: insert-directory: Listing directory failed but `access-file' worked In a Windows Emacs binary on Windows, I do not have any problem, but Emacs uses its own implementation of ls IIUC....

Emacs bindings documentation


emacs,elisp
I am writing some bindings to lambdas in my ~/.emacs and would like to have a description of what the function does appear when I do (for example) C-c ?. I tried to put a string immediately after lambda () but that still does nothing. How do I get something...

C99-style hexadecimal floating-point constants in OCaml


floating-point,ocaml,floating-point-conversion
In OCaml, how can I parse C99-style floating-point constants (either as literals or inside strings) in hexadecimal, such as 0x1.b000000000000p4? It seems that they are not valid literals: # let c = 0x1.b000000000000p4;; Characters 12-27: let c = 0x1.b000000000000p4;; ^^^^^^^^^^^^^^^ Error: Unbound record field b000000000000p4 And there seems to be...

OCaml error in basic loop


ocaml
I'm new with OCaml. I'm making a function working this way : I have "tab" in the scope which represents a 2D map, and three parameters, x, y and u. x and y represent the position of the player, and u the direction of the bomb (right, top left etc.)....

OCaml Unbound value List.assoc


ocaml
I'm compiling a module with a function that calls List.assoc, it fails to build giving me "Unbound value List.assoc" ... i've tried other List functions and they work fine, it also works fine in utop. I can reproduce this by compiling an ml file using corebuild and this code open...

org-mode built-in table editor on windows


windows,emacs,org-mode
I am using org-mode version 8.2.2 and Emacs 24.2.1 on Windows 7 and have been struggling with the alignment of org-mode tables. Creating a simple table in org-mode using the build in editor gives me an unaligned table unaligned table columns | first col | second col | third col...

How to get Emacs to sort lines by length?


sorting,emacs,elisp
I'd like to be able to highlight a region in Emacs and then sort the region by line length. The closest I've found is the following code which I think will sort by length: (sort-subr t #'forward-line #'end-of-line nil nil (lambda (l1 l2) (apply #'< (mapcar (lambda (range) (- (cdr...

Three-address code and symbol tables


compiler-construction,ocaml,abstract-syntax-tree,intermediate-language,symbol-table
I am working on a hobby retargetable C compiler in OCaml and I'm building it bottom up. So far I have an annotated AST type, abridged: type 'e expr = | Int of 'e * int | Var of 'e * var | Neg of 'e * 'e expr |...

Struct member selected from type, it is not visible and will not be selected


unix,ocaml
I have a function that uses the Unix lib for its time functions: let rfc822 (t: Unix.tm) : string = Printf.sprintf "%s, %s %s %d %s:%s:%s %s" (List.nth short_days t.tm_wday) (padInt t.tm_yday 2 "0") (List.nth short_month t.tm_mon) (t.tm_year + 1900) (padInt t.tm_hour 2 "0") (padInt t.tm_min 2 "0") (padInt t.tm_sec...

custom-set-variables add blank space on subsequent uses


emacs,elisp
I followed the emacs haskell tutorial, and couldn't understand some of its language regarding the use of custom-set-variables in the text quoted below. It seems that custom-set-variables should be used in one way on first usage, and another way (with added blank space) on subsequent uses. My questions are: What...

Run bash script from ocaml


ocaml
I think that what i mean is in the title. I have tried to search if it is possible to run bash script from ocaml like from java or from php but i could not find. i know that we can use ocaml as a scripting language but it is...

Configuring Flycheck to work with C++11


c++,c++11,emacs,flycheck
I am having significant trouble configuring flycheck for C++11. Right now, flycheck is flagging things like std::to_string(). The checker I am using is just g++. What can I add in the .emacs file such that flycheck will assume C++11 by default?

ocamlbuild specify output location/name


ocaml,ocamlbuild
Can I specify the build location and file name with the ocamlbuild tool? I would like to be able to say (in pseudocode): ocamlbuild myapp.ml -b native -o bin/myapp ...

Emacs - selection not showing in windowed mode


emacs
I have Emacs on a Kubuntu 15.04 OS and I have a problem in showing the selected region; if I run emacs in the terminal windows with -nw option, I can set marks and I see the selected region highlighted; but if emacs starts in a window, the selected region...

Shell (zsh) through Emacs?


emacs,zsh
I usually run emacs in a terminal to work. I would like to run a shell inside a emacs window. I've found the shell command, but I would like to run the zsh I usually use inside (with my own configuration). Is it possible? EDIT : I succeeded to run...

Modify a matrix in ocaml


matrix,ocaml
I want to write a function that is modify every elements inside a matrix. But I have some problem when compiling. Warning 10: this expression should have type unit. I think because all function in ocaml need to return to a value or unit, so if I implement two tasks...

OCaml native executable with linked C library


ocaml
What's the simplest command line to produce a native OCaml executable from a set of OCaml and C sources which use a C library that needs to be included via -l<lib>, such as -lm? For instance, the following code illustrates a (contrived) example where it would be necessary: // test.c...

emacs: Symbol's function definition is void: loop


emacs,elisp,emacs-prelude
I am testing on loading packages in emacs init.el (Emacs 24.3). I followed a blog by the author of emacs prelude to automatically load packages, and copied the code there into my init.el as in the bottom. However, I got an error message about the loop function/symbol, which says: Symbol's...

Call Rmath via Ctypes from Ocaml on OS X


r,osx,ocaml,dylib
I want to use R's mathematical functions as provided in libRmath from Ocaml. I successfully installed the library via brew tap homebrew science && brew install --with-librmath-only r. I end up with a .dylib in /usr/local/lib and a .h in /usr/local/include. Following the Ocaml ctypes tutorial, i do this in...

Ocamlfind command not found


centos,make,ocaml,opam,ocamlfind
I'm running into an issue installing a package that's reliant on ocamlfind but I'm getting an ocamlfind: command not found error when making. I have installed ocamlfind with the ocaml package manager and have tried reinstalling using "opam reinstall ocamlfind". I have also tried the 'eval opam config env' command...

Error: Reference to undefined global `Num'


ocaml,bignum
I'm trying to use the Num module in OCaml (bignums and big fractions). Some things seem to be working, while others seem not to, and I'm not able to generate a single, complete example. For instance: # Num.Int(234);; - : Num.num = Num.Int 234 # Num.mult_num;; Characters -1--1: Num.mult_num;; Error:...