all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <jwvpq6gqowh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87393cd7cu.fsf@thinkpad.tsdh.de> (Tassilo Horn's message of "Fri, 24 Aug 2012 10:25:37 +0200")

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



  parent reply	other threads:[~2012-08-24 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24  8:25 Error in post-command-hook (completion-in-region--postch): (wrong-type-argument stringp nil) Tassilo Horn
2012-08-24  9:44 ` Thien-Thi Nguyen
2012-08-24 11:23   ` Tassilo Horn
2012-08-24 13:07     ` Thien-Thi Nguyen
2012-08-24 16:23       ` Tassilo Horn
2012-08-24 16:58         ` Thien-Thi Nguyen
2012-08-24 18:12           ` Tassilo Horn
2012-08-24 15:46 ` Stefan Monnier [this message]
2012-08-24 18:20   ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvpq6gqowh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.