From f91647a2543e47f524c74128219fa0ff6b33a461 Mon Sep 17 00:00:00 2001 From: "wojciech.meyer" Date: Thu, 1 Mar 2012 04:56:06 +0100 Subject: [PATCH] Prelimnary support for "require:" command - in progress. Handle links in buttons Ignore-this: 148a3142a2f40cc05f887cb0c53712fb darcs-hash:20120301035606-33bd9-14ca041ed4b73a645a5251a4fff63774490d8766 --- src/lib/uTop_main.ml | 10 ++++++++++ src/top/utop.el | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index d06a0b2..e1f9297 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -652,6 +652,16 @@ module Emacs(M : sig end) = struct | Some ("save-history", code) -> Lwt_main.run (save_history ()); loop_commands history_prev history_next + | Some ("require", arg) -> + begin + let input = read_data () in + send "accept" ""; + try + Topfind.load_deeply [input] + with Fl_package_base.No_such_package(pkg, reason) -> + send "no-such-package" "" + end; + loop_commands history_prev history_next | Some (command, _) -> Printf.ksprintf (send "stderr") "unrecognized command %S!" command; exit 1 diff --git a/src/top/utop.el b/src/top/utop.el index 581425f..688fc34 100644 --- a/src/top/utop.el +++ b/src/top/utop.el @@ -789,10 +789,18 @@ defaults to 0." (defun utop-package-printer (id cols) "Print one findlib package entry." (let ((width (cadr (elt tabulated-list-format 0)))) - (insert-text-button (elt cols 0) 'face nil) + (insert-text-button (elt cols 0) + 'follow-link t + 'action 'utop-require-package-button-action) (insert-char ?\s (- width (length (elt cols 0)))) (insert (elt cols 1) "\n"))) +(defun utop-require-package-button-action (button) + (let ((package (button-label button))) + (when (y-or-n-p (format "Load package `%s'? " package)) + ;; Handle loading of packages + nil))) + (defun utop-list-ocaml-packages (&optional buffer) "Display a list of all ocaml findlib packages" (interactive)