emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error in post-command-hook (completion-in-region--postch): (wrong-ty


From: Stefan Monnier
Subject: Re: Error in post-command-hook (completion-in-region--postch): (wrong-type-argument stringp nil)
Date: Fri, 24 Aug 2012 11:46:13 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> (defun nrepl-complete-at-point ()
>   (interactive)
>   (let ((sap (symbol-at-point)))
>     (when (and sap (not (in-string-p)))
>       (nrepl-send-string "(require 'complete.core)" "user" 'identity)
>       (let ((form (format "(complete.core/completions \"%s\" *ns*)" sap))
>           (bounds (bounds-of-thing-at-point 'symbol)))
>       (let ((completions (car (read-from-string
>                                (plist-get (nrepl-send-string-sync form 
> nrepl-buffer-ns)
>                                           :value)))))
>         (when completions
>           ;; TODO: Remove me again!
>           (assert (null (remove-if 'stringp completions)))
>           (list (car bounds) (cdr bounds) completions)))))))

The completion-in-region-mod calls to completion-at-point-functions
don't care much about the "completions" part of the triplet you return,
so the nrepl-send-string* are a complete waste.
Same for potentially other cases such as when auto-complete calls
completion-at-point-functions to try and decide whether or not there's
potentially something to complete at point.

IOW, nrepl-complete-at-point should return something more like
(guaranteed 100% untested):

   (defun nrepl-complete-at-point ()
     (interactive)
     (let ((sap (symbol-at-point)))
       (when (and sap (not (in-string-p)))
         (let ((bounds (bounds-of-thing-at-point 'symbol)))
           (list (car bounds) (cdr bounds)
                 (completion-table-dynamic
                  (lambda (str)
                    (nrepl-send-string "(require 'complete.core)"
                                       "user" 'identity)
                    (let ((form (format "(complete.core/completions \"%s\" 
*ns*)" str)))
                      (car (read-from-string
                            (plist-get (nrepl-send-string-sync
                                        form nrepl-buffer-ns)
                                       :value)))))))))))


-- Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]