From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel 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 Message-ID: References: <87393cd7cu.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1345823184 15694 80.91.229.3 (24 Aug 2012 15:46:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Aug 2012 15:46:24 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 24 17:46:25 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T4w5Y-0007gn-Nf for ged-emacs-devel@m.gmane.org; Fri, 24 Aug 2012 17:46:24 +0200 Original-Received: from localhost ([::1]:39721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4w5W-0003hQ-SQ for ged-emacs-devel@m.gmane.org; Fri, 24 Aug 2012 11:46:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4w5R-0003gm-LV for emacs-devel@gnu.org; Fri, 24 Aug 2012 11:46:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4w5Q-00074W-5B for emacs-devel@gnu.org; Fri, 24 Aug 2012 11:46:17 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:28823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4w5Q-00074K-0g for emacs-devel@gnu.org; Fri, 24 Aug 2012 11:46:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu0/O+KG6/2dsb2JhbAA7CbQRgQiCFgEFVjMLNBIUGA2IRboJixiCDoMeA6MzgViDBYE6Bw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="196612409" Original-Received: from 206-248-161-186.dsl.teksavvy.com (HELO pastel.home) ([206.248.161.186]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 24 Aug 2012 11:46:14 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 0CF0958914; Fri, 24 Aug 2012 11:46:13 -0400 (EDT) In-Reply-To: <87393cd7cu.fsf@thinkpad.tsdh.de> (Tassilo Horn's message of "Fri, 24 Aug 2012 10:25:37 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152807 Archived-At: > (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