From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?iso-8859-1?Q?Jo=E3o_T=E1vora?=) Newsgroups: gmane.emacs.devel Subject: Re: Emacs pretest Date: Mon, 31 Mar 2014 16:55:29 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1396281359 17803 80.91.229.3 (31 Mar 2014 15:55:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Mar 2014 15:55:59 +0000 (UTC) Cc: Sean Sieger , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 31 17:55:55 2014 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 1WUeYy-0002jo-Mf for ged-emacs-devel@m.gmane.org; Mon, 31 Mar 2014 17:55:52 +0200 Original-Received: from localhost ([::1]:49833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUeYy-0007fU-Ci for ged-emacs-devel@m.gmane.org; Mon, 31 Mar 2014 11:55:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUeYm-0006af-4k for emacs-devel@gnu.org; Mon, 31 Mar 2014 11:55:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUeYh-0001zF-6i for emacs-devel@gnu.org; Mon, 31 Mar 2014 11:55:40 -0400 Original-Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:34690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUeYg-0001yk-Qu for emacs-devel@gnu.org; Mon, 31 Mar 2014 11:55:35 -0400 Original-Received: by mail-wi0-f173.google.com with SMTP id z2so1835212wiv.0 for ; Mon, 31 Mar 2014 08:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=5Sf5zE1xnFT1bZ0Uh8LnPNjL5RJYgklWHxUdHp8I32k=; b=ut2EaRDh1tHf6g9ur03y/3IlIZdSNHliAOLV2R7iw9JHRRm38E8ym7Jmqmo1Oq8nLZ ir4er3XouidVkpDyLKKG4+IIyvNl0P/iSZHbRMrCTtnhFFkaFq3L1yuuPear13Fq+nYC pTVWNdE0u5KKNeND0IN+9WypFFHf60/4CrTbb1p76Y9xQ0k0w5kjW0n1U6rK6ZUUc1xn Rhf0V/Anktlucwd4XXe0qLT1gZH5zyQMMZ1Bza+8We2lPGHz2UnqNFJWxiRozkpMDXzF /5jpzP9OmC+mcjrCDff+zOfbXbHVKw+b8BONuTEUE2NI1qmp+LN+WTFlXYiLGspk5xqJ vi5w== X-Received: by 10.180.79.73 with SMTP id h9mr13479440wix.3.1396281332981; Mon, 31 Mar 2014 08:55:32 -0700 (PDT) Original-Received: from BELMONTE.yourcompany.com (a81-84-241-129.static.cpe.netcabo.pt. [81.84.241.129]) by mx.google.com with ESMTPSA id gz1sm27410219wib.14.2014.03.31.08.55.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 08:55:32 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 31 Mar 2014 09:27:30 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d 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:171217 Archived-At: Stefan Monnier writes: > I think we're ready for the first pretest. Sean, can you take care of > it? I'd like to commit a minor functional change to lisp/elec-pair.el. I've been holding on to it for lazyness. Is it too late? Jo=E3o diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 747bbcf..aa08b90 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2014-03-31 Jo=E3o T=E1vora + + * elec-pair.el (electric-pair-inhibit-if-helps-balance): Inhibit + quote pairing if `point-max' is inside an unterminated string. + (electric-pair--looking-at-unterminated-string-p): + Delete. + (electric-pair--in-unterminated-string-p): New function. + 2014-03-29 Juri Linkov =20 * dired-aux.el (dired-compress-file): Don't use string-match-p diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index 52ad9bc..77d4bd2 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -364,18 +364,17 @@ If point is not enclosed by any lists, return ((t) . = (t))." (funcall ended-prematurely-fn))))))) (cons innermost outermost))) =20 -(defun electric-pair--looking-at-unterminated-string-p (char) - "Return non-nil if following string starts with CHAR and is unterminated= ." - ;; FIXME: ugly/naive - (save-excursion - (skip-chars-forward (format "^%c" char)) - (while (not (zerop (% (save-excursion (skip-syntax-backward "\\")) 2))) - (unless (eobp) - (forward-char 1) - (skip-chars-forward (format "^%c" char)))) - (and (not (eobp)) - (condition-case nil - (progn (forward-sexp) nil) +(defun electric-pair--in-unterminated-string-p (char) + "Say if inside an unterminated string started with CHAR" + (let* ((ppss (syntax-ppss)) + (relevant-ppss (if (nth 4 ppss) ; in comment + (electric-pair--syntax-ppss) + ppss)) + (string-delim (nth 3 relevant-ppss))) + (and (or (eq t string-delim) + (eq char string-delim)) + (condition-case nil (progn (scan-sexps (nth 8 relevant-ppss) 1) + nil) (scan-error t))))) =20 (defun electric-pair--inside-string-p (char) @@ -409,7 +408,9 @@ happened." (t (eq (cdr outermost) pair))))) ((eq syntax ?\") - (electric-pair--looking-at-unterminated-string-p char)))) + (save-excursion + (goto-char (point-max)) + (electric-pair--in-unterminated-string-p char))))) (insert-char char))))) =20 (defun electric-pair-skip-if-helps-balance (char) diff --git a/test/ChangeLog b/test/ChangeLog index 5e5a8ae..1d3fb7b 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2014-03-31 Jo=E3o T=E1vora + + * automated/electric-tests.el (inhibit-if-strings-mismatched): + Change from `inhibit-only-of-next-is-mismatched'. + 2014-03-24 Barry O'Reilly =20 * automated/undo-tests.el (undo-test-marker-adjustment-nominal): diff --git a/test/automated/electric-tests.el b/test/automated/electric-tes= ts.el index e3ffd1a..c43b87f 100644 --- a/test/automated/electric-tests.el +++ b/test/automated/electric-tests.el @@ -295,9 +295,9 @@ Should %s \"%s\" and point at %d" :bindings `((electric-pair-text-syntax-table . ,prog-mode-syntax-table))) =20 -(define-electric-pair-test inhibit-only-if-next-is-mismatched +(define-electric-pair-test inhibit-if-strings-mismatched "\"foo\"\"bar" "\"" - :expected-string "\"\"\"foo\"\"bar" + :expected-string "\"\"foo\"\"bar" :expected-point 2 :test-in-strings nil :bindings `((electric-pair-text-syntax-table