1

我将 Distel 用于我的 erlang 开发,但用于完成的函数是在 ibuffer 中打印其输出。我想把它放在带有 ido 支持的 minibuffer 中,有人知道怎么做吗?

这是代码:

(defun erl-complete (node)
  "Complete the module or remote function name at point."
  (interactive (list (erl-target-node)))
  (let ((win (get-buffer-window "*Completions*" 0)))
    (if win (with-selected-window win (bury-buffer))))
  (let ((end (point))
    (beg (ignore-errors 
           (save-excursion (backward-sexp 1)
                   ;; FIXME: see erl-goto-end-of-call-name
                   (when (eql (char-before) ?:)
                 (backward-sexp 1))
                   (point)))))
    (when beg
      (let* ((str (buffer-substring-no-properties beg end))
         (buf (current-buffer))
         (continuing (equal last-command (cons 'erl-complete str))))
    (setq this-command (cons 'erl-complete str))
    (if (string-match "^\\(.*\\):\\(.*\\)$" str)
        ;; completing function in module:function
        (let ((mod (intern (match-string 1 str)))
          (pref (match-string 2 str))
          (beg (+ beg (match-beginning 2))))
          (erl-spawn
        (erl-send-rpc node 'distel '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-receive-completions "module" beg end str buf continuing
                      #'erl-complete-sole-module)))))))

(defun &erl-receive-completions (what beg end prefix buf continuing sole)
  (let ((state (erl-async-state buf)))
    (erl-receive (what state beg end prefix buf continuing sole)
    ((['rex ['ok completions]]
      (when (equal state (erl-async-state buf))
        (with-current-buffer buf
          (erl-complete-thing what continuing beg end prefix
                  completions sole))))
     (['rex ['error reason]]
      (message "Error: %s" reason))
     (other
      (message "Unexpected reply: %S" other))))))
4

1 回答 1

0

Stefan的company-mode建议做了我想要的,所以不需要重写。

感谢您的帮助和时间斯特凡!

于 2013-06-26T08:36:03.880 回答