[<<][emacs][>>][..]
Wed Apr 22 09:50:59 EDT 2020

Merge with upstream?

Maybe it's time to merge with upstream.  Many of the mods I made are
no longer necessary.  So here's a list.  I'm parking it in a zwizwa
branch.  Let's just see what happens if I just don't use these...

I'm now running 
https://github.com/massemanet/distel/commit/f9c5067e8b31661c87af9a8eecca1bd4bdce026b

tom@panda:~/exo/distel$ git diff 0ca3d73d90e87e72bdcaeb7de2126553ad5742fd
diff --git a/elisp/derl.el b/elisp/derl.el
index 2361245..4fcc7e8 100644
--- a/elisp/derl.el
+++ b/elisp/derl.el
@@ -28,8 +28,13 @@ mynode@cockatoo, FSM is the net-fsm process of the connection.")
 
 (defvar derl-cookie nil
   "*Cookie to use in distributed erlang connections, or NIL.
+When NIL, we use derl-node-to-cookie or read ~/.erlang.cookie.")
+
+(defvar derl-node-to-cookie nil
+  "*Function mapping node to cookie.
 When NIL, we read ~/.erlang.cookie.")
 
+
 ;; Local variables
 
 (defvar-local derl-connection-node nil
@@ -211,11 +216,16 @@ complete and we become live."
   "Generate a message digest as required for the specification's
 gen_digest() function:
   (md5 (concat challenge-as-ascii-decimal cookie))"
+  (message (format "dbg: derl.el: %s" derl-connection-node))
   (derl-hexstring-to-binstring
    (md5 (concat (derl-cookie) (derl-int32-to-decimal challenge)))))
 
+(message "dbg: derl.el")
+
 (defun derl-cookie ()
   (or derl-cookie
+      (and derl-node-to-cookie
+           (funcall derl-node-to-cookie derl-connection-node))
       (with-temp-buffer
         (insert-file-contents (concat (getenv "HOME") "/.erlang.cookie"))
         (while (search-forward "\n" nil t)
diff --git a/elisp/erl-service.el b/elisp/erl-service.el
index 7bda273..badefa0 100644
--- a/elisp/erl-service.el
+++ b/elisp/erl-service.el
@@ -890,6 +890,11 @@ Value is non-nil if search is successful."
 
 ;;;; Completion
 
+;; [tom] This replaced distel:modules/1 and distel:functions/1 with
+;; distel:code_modules/1 and distel:code_functions/2, which do not use
+;; XREF.  The latter misses some references for reasons I cannot
+;; figure out.
+
 (defun erl-complete (node)
   "Complete the module or remote function name at point."
   (interactive (list (erl-target-node)))
@@ -913,13 +918,13 @@ Value is non-nil if search is successful."
                   (pref (match-string 2 str))
                   (beg (+ beg (match-beginning 2))))
               (erl-spawn
-                (erl-send-rpc node 'distel 'functions (list mod pref))
+                (erl-send-rpc node 'distel 'code_functions (list mod pref))
                 (&erl-receive-completions "function" beg end pref buf
                                           continuing
                                           #'erl-complete-sole-function)))
           ;; completing just a module
           (erl-spawn
-            (erl-send-rpc node 'distel 'modules (list str))
+            (erl-send-rpc node 'distel 'code_modules (list str))
             (&erl-receive-completions "module" beg end str buf continuing
                                       #'erl-complete-sole-module)))))))
 
diff --git a/elisp/erl.el b/elisp/erl.el
index 010a004..2fb71a0 100644
--- a/elisp/erl.el
+++ b/elisp/erl.el
@@ -101,7 +101,7 @@ passed back to Emacs.")
 Processes spawned by other processes will inherit their GL, but
 \"brand new\" ones will use this.")
 
-(defvar erl-popup-on-output t
+(defvar erl-popup-on-output nil
   "Popup *erl-output* when new output arrives.")
 
 (defvar erl-stop-on-error nil
diff --git a/elisp/erlext.el b/elisp/erlext.el
index 3739d6c..c8a1629 100644
--- a/elisp/erlext.el
+++ b/elisp/erlext.el
@@ -297,11 +297,11 @@
 
 (defun erlext-write-float (n)
   (cond
-   ((fboundp 'frexp)
-    ;; Function `frexp' was introduced in emacs 24.1;
-    ;; Erlang R11B-4 and later is able to decode this representation.
-    (erlext-write1 (erlext-get-code 'newFloat))
-    (mapc #'erlext-write1 (erlext-encode-ieee-double n)))
+;   ((fboundp 'frexp)
+;    ;; Function `frexp' was introduced in emacs 24.1;
+;    ;; Erlang R11B-4 and later is able to decode this representation.
+;    (erlext-write1 (erlext-get-code 'newFloat))
+;    (mapc #'erlext-write1 (erlext-encode-ieee-double n)))
    (t
     (erlext-write1 (erlext-get-code 'float))
     (let ((f (format "%.20e" n)))
diff --git a/elisp/net-fsm.el b/elisp/net-fsm.el
index 4fedae7..117defe 100644
--- a/elisp/net-fsm.el
+++ b/elisp/net-fsm.el
@@ -47,11 +47,14 @@ addition to being passed as an argument.")
 ;; External API
 ;; ----------------------------------------------------------------------
 
+
+
 (defun fsm-open-socket (host port)
   (let ((buf (generate-new-buffer " *net-fsm*")))
     (fsm-with-error-cleanup (kill-buffer buf)
       (let ((p (open-network-stream "netfsm" buf host port)))
         (set-process-coding-system p 'no-conversion 'no-conversion)
+        (set-process-query-on-exit-flag p nil)
         (when (fboundp 'set-process-filter-multibyte)
           (set-process-filter-multibyte p nil))
         p))))
@@ -265,6 +268,7 @@ buffer."
 (defun fsm-replace-process-buffer (process buffer)
   (let ((oldbuffer (process-buffer process)))
     (set-process-buffer process buffer)
-    (kill-buffer oldbuffer)))
+    (kill-buffer oldbuffer)
+    ))
 
 (provide 'net-fsm)
diff --git a/src/distel.erl b/src/distel.erl
index b02ecc9..b5bc4d6 100644
--- a/src/distel.erl
+++ b/src/distel.erl
@@ -23,6 +23,8 @@
 -export([apropos/2, describe/4, get_arglists/2]).
 -export([xref_callgraph/1, who_calls/3, rebuild_callgraph/0]).
 
+-export([code_modules/1, code_functions/2]).
+
 -include_lib("kernel/include/file.hrl").
 
 -import(lists, [any/2,
@@ -684,16 +686,36 @@ stack_pos(#attach{stack={Pos,_Max}}) -> Pos.
 %% ----------------------------------------------------------------------
 
 modules(Prefix) ->
-  case otp_doc:modules(Prefix) of
-    {ok,Ans} -> {ok,Ans};
-    {error,_}-> xref_modules(Prefix)
-  end.
+    %% log:info("modules()~n"),
+    case otp_doc:modules(Prefix) of
+        {ok,Ans} -> {ok,Ans};
+        {error,_} -> xref_modules(Prefix)
+    end.
 functions(Mod, Prefix) ->
   case otp_doc:functions(Mod,Prefix) of
     {ok,Ans} -> {ok,Ans};
     {error,_}-> xref_functions(Mod,Prefix)
   end.
 
+%% Alternatives, bypassing xref since it doesn't list everything and I
+%% can't figure out why.  See corresponding modification in
+%% erl-service.el
+code_modules(Prefix) ->
+    {ok, filter_prefix(Prefix, [atom_to_list(M) || {M,_Src} <- code:all_loaded()])}.
+code_functions(Mod, Prefix) ->
+    MI = try Mod:module_info(exports) catch _:_ -> [] end,
+    {ok, filter_prefix(Prefix, [atom_to_list(F) || {F,_Nargs} <- MI])}.
+filter_prefix(Prefix, List) ->
+    Re = "^" ++ Prefix,
+    lists:filter(
+      fun(M) -> 
+              case re:run(M, Re) of
+                  {match,_} -> true;
+                  _ -> false
+              end
+      end,
+      List).
+
 xref_completions(F,A) ->
     fun(server) -> distel_completions;
        (opts)   -> [{xref_mode, modules}];
@@ -702,7 +724,9 @@ xref_completions(F,A) ->
     end.
 
 rebuild_completions() ->
-    xref_rebuild(xref_completions("",[])).
+    Opts = xref_completions("",[]),
+    %% log:info("Opts: ~p~n", [Opts]),
+    xref_rebuild(Opts).
 
 %% Returns: [ModName] of all modules starting with Prefix.
 %% ModName = Prefix = string()
@@ -1089,3 +1113,5 @@ get_code_path(XREF) ->
         true ->
             code:get_path()
     end.
+
+




[Reply][About]
[<<][emacs][>>][..]