需要帮助重写一个elisp函数来使用minibuffer + ido而不是ibuffer

时间:2013-06-18 12:32:46

标签: elisp ido minibuffer

我正在使用Distel进行erlang开发,但用于完成的函数是在ibuffer中打印输出。相反,我想在带有ido支持的迷你缓冲区中获取它,有没有人知道如何做到这一点?

以下是代码:

(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))))))

1 个答案:

答案 0 :(得分:0)

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

谢谢你的帮助和时间Stefan!