package ecaml

  1. Overview
  2. Docs
Library for writing Emacs plugin in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=87e76473915e12d718096100a5c4d15d98aba6f99ecbf21814b7389e8c28bb25

doc/src/ecaml/selected_window.ml.html

Source file selected_window.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
open! Core
open! Async_kernel
open! Import

let other_window = Funcall.Wrap.("other-window" <: int @-> return nil)
let height = Funcall.Wrap.("window-height" <: nullary @-> return int)
let width = Funcall.Wrap.("window-width" <: nullary @-> return int)
let get = Funcall.Wrap.("selected-window" <: nullary @-> return Window.t)
let select_window = Funcall.Wrap.("select-window" <: Window.t @-> bool @-> return nil)

let set ?(move_to_front_of_buffer_list = true) window =
  select_window window (not move_to_front_of_buffer_list)
;;

module Blocking = struct
  let switch_to_buffer = Funcall.Wrap.("switch-to-buffer" <: Buffer.t @-> return nil)
end

let switch_to_buffer buffer =
  Value.Private.run_outside_async [%here] (fun () -> Blocking.switch_to_buffer buffer)
;;

let switch_to_buffer_other_window =
  let switch_to_buffer_other_window =
    Funcall.Wrap.("switch-to-buffer-other-window" <: Buffer.t @-> return nil)
  in
  fun buffer ->
    Value.Private.run_outside_async [%here] (fun () ->
      switch_to_buffer_other_window buffer)
;;

let split_horizontally_exn =
  Funcall.Wrap.("split-window-horizontally" <: nullary @-> return nil)
;;

let split_sensibly_exn = Funcall.Wrap.("split-window-sensibly" <: nullary @-> return nil)

let split_vertically_exn =
  Funcall.Wrap.("split-window-vertically" <: nullary @-> return nil)
;;

let quit =
  let quit = Funcall.Wrap.("quit-window" <: nullary @-> return nil) in
  fun () -> Value.Private.run_outside_async [%here] quit
;;

let save_window_excursion sync_or_async f =
  Save_wrappers.save_window_excursion sync_or_async f
;;

let save_selected_window f = Save_wrappers.save_selected_window f

let set_temporarily sync_or_async window ~f =
  Save_wrappers.with_selected_window sync_or_async (window |> Window.to_value) f
;;

let find_file =
  let find_file = Funcall.Wrap.("find-file" <: string @-> return nil) in
  fun path -> Value.Private.run_outside_async [%here] (fun () -> find_file path)
;;

let find_file_other_window =
  let find_file_other_window =
    Funcall.Wrap.("find-file-other-window" <: string @-> return nil)
  in
  fun path ->
    Value.Private.run_outside_async [%here] (fun () -> find_file_other_window path)
;;

let view_file =
  let view_file = Funcall.Wrap.("view-file" <: string @-> return nil) in
  fun path -> Value.Private.run_outside_async [%here] (fun () -> view_file path)
;;
OCaml

Innovation. Community. Security.