From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jorgen Schaefer Newsgroups: gmane.emacs.devel Subject: minibuffer.el completion bug with markers Date: Sat, 21 Sep 2013 21:34:21 +0200 Message-ID: <20130921213421.4e7b91ec@forcix.kollektiv-hamburg.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1379792083 9757 80.91.229.3 (21 Sep 2013 19:34:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Sep 2013 19:34:43 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 21 21:34:43 2013 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 1VNSx1-0003sn-61 for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 21:34:43 +0200 Original-Received: from localhost ([::1]:32992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNSx0-0001D4-NN for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 15:34:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNSwr-0001Ct-5m for emacs-devel@gnu.org; Sat, 21 Sep 2013 15:34:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VNSwj-0000g8-Rm for emacs-devel@gnu.org; Sat, 21 Sep 2013 15:34:33 -0400 Original-Received: from istinn.electusmatari.com ([83.169.37.145]:39337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNSwj-0000g0-Ld for emacs-devel@gnu.org; Sat, 21 Sep 2013 15:34:25 -0400 Original-Received: from forcix.kollektiv-hamburg.de (x2f02774.dyn.telefonica.de [2.240.39.116]) by istinn.electusmatari.com (Postfix) with ESMTPSA id 95ED1D1000DF for ; Sat, 21 Sep 2013 21:34:23 +0200 (CEST) X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.20; i486-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 83.169.37.145 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:163542 Archived-At: Hello! The recent changes to minibuffer.el broke completion functions when they use markers to define where the completed text starts and ends. Reproduction: (with-temp-buffer (cl-flet ((test/completion-at-point () (list (copy-marker (point-min)) (copy-marker (point)) 'test/completion-table)) (test/completion-table (string pred action) (if (eq action 'lambda) nil "test: "))) (let ((completion-at-point-functions '(test/completion-at-point))) (insert "TEST") (completion-at-point) (assert (equal (buffer-string) "test: "))))) This errors out in `completion--replace' because the call to `delete-region' calculates the end point to delete based on (- end beg), where end can have moved at this point due to the insertion of text using `insert-and-inherit'. Simple fix: --- lisp/minibuffer.el 2013-09-16 19:09:24 +0000 +++ lisp/minibuffer.el 2013-09-21 19:26:47 +0000 @@ -873,8 +873,9 @@ (setq end (- end suffix-len)) (setq newtext (substring newtext 0 (- suffix-len)))) (goto-char beg) - (insert-and-inherit newtext) - (delete-region (point) (+ (point) (- end beg))) + (let ((length (- end beg))) + (insert-and-inherit newtext) + (delete-region (point) (+ (point) length))) (forward-char suffix-len))) (defcustom completion-cycle-threshold nil Regards, Jorgen