Skip to content

Commit

Permalink
Merge pull request #52 from rjbou/opammconf
Browse files Browse the repository at this point in the history
Use opam var/env/exec instead of opam config x
  • Loading branch information
kit-ty-kate authored Sep 4, 2024
2 parents cfc575f + bca56e7 commit 9f68861
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions emacs/emacs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ let base_setup =
(split-string (opam-shell-command-to-string "opam switch list -s --safe") "\n")
nil t nil nil default))))
(let* ((switch-arg (if (= 0 (length switch)) "" (concat "--switch " switch)))
(command (concat "opam config env --safe --sexp " switch-arg))
(command (concat "opam env --safe --sexp " switch-arg))
(env (opam-shell-command-to-string command)))
(when (and env (not (string= env "")))
(dolist (var (car (read-from-string env)))
Expand All @@ -163,7 +163,7 @@ let base_setup =
(opam-update-env nil)

(defvar opam-share
(let ((reply (opam-shell-command-to-string "opam config var share --safe")))
(let ((reply (opam-shell-command-to-string "opam var share --safe")))
(when reply (substring reply 0 -1))))

(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
Expand Down
10 changes: 6 additions & 4 deletions opam
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
opam-version: "1.2"
opam-version: "2.0"
name: "user-setup"
version: "0.7"
maintainer: "Louis Gesbert <[email protected]>"
authors: "Louis Gesbert <[email protected]>"
homepage: "https://github.com/OCamlPro/opam-user-setup"
bug-reports: "https://github.com/OCamlPro/opam-user-setup/issues"
license: "ISC"
dev-repo: "https://github.com/OCamlPro/opam-user-setup.git"
dev-repo: "git+https://github.com/OCamlPro/opam-user-setup.git"
build: [make]
depends: [
"ocaml" {>= "3.12.1"}
"ocamlfind" {build}
"cmdliner"
"re"
]
depopts: ["tuareg" "merlin" "ocp-indent" "ocp-index"]
available: [ocaml-version >= "3.12.1"]
available: opam-version >= "2.1"
post-messages: [
"To setup or update your editors, run 'opam user-setup install'."
{success}
]
tags: [ "org:ocamlpro" "flags:plugin" ]
tags: [ "org:ocamlpro" ]
flags: plugin
2 changes: 1 addition & 1 deletion ousMisc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let lines_to_file ?(remove_if_empty=false) lines f =
close_out oc

let opam_var v =
let cmd = Printf.sprintf "opam config var %s" v in
let cmd = Printf.sprintf "opam var %s" v in
match lines_of_command cmd with
| [value] -> value
| _ -> failwith (Printf.sprintf "Bad answer from '%s'" cmd)
Expand Down
2 changes: 1 addition & 1 deletion ousMisc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ val lines_of_command: string -> lines
(** Writes a list of lines to a file. [remove_if_empty] defaults to false. *)
val lines_to_file: ?remove_if_empty:bool -> lines -> string -> unit

(** Query OPAM for a variable (see 'opam config list') *)
(** Query OPAM for a variable (see 'OPAMCLI=2.0 opam config list' or 'opam var --cli 2.1') *)
val opam_var: string -> string

(** The current user's home directory (as given by environment variable HOME) *)
Expand Down
2 changes: 1 addition & 1 deletion sublime/files/ocp-index/sublime_ocp_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SublimeOCPIndex():
def run_ocp(self, command, includes, module, query, context, moreArgs, settings):
bin_path = which('ocp-index')
if bin_path is None:
opam_process = subprocess.Popen('opam config var bin', stdout=subprocess.PIPE, shell=True)
opam_process = subprocess.Popen('opam var bin', stdout=subprocess.PIPE, shell=True)
bin_path = opam_process.stdout.read().decode('utf-8').rstrip() + '/ocp-index'

args = [bin_path, command]
Expand Down
2 changes: 1 addition & 1 deletion test/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ ENV OPAMVERBOSE 1
ENV OCAMLRUNPARAM b
RUN opam pin add user-setup ous/
RUN opam user-setup install
RUN cd ous && opam config exec -- make
RUN cd ous && opam exec -- make
2 changes: 1 addition & 1 deletion vim/vim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ inoremap <C-U> <C-G>u<C-U>

let base_setup = [ dotvimrc, Text (lines_of_string
{vim|
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = system("opam var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')

let s:opam_configuration = {}
Expand Down

0 comments on commit 9f68861

Please sign in to comment.