From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Newsgroups: gmane.emacs.bugs Subject: bug#17183: can't insert a quote pair before another Date: Sun, 06 Apr 2014 13:46:59 +0100 Message-ID: <87vbum7hh8.fsf@kitaj.lan> References: <87bnwf8czs.fsf@kitaj.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1396796786 16143 80.91.229.3 (6 Apr 2014 15:06:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Apr 2014 15:06:26 +0000 (UTC) To: 17183@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 06 17:06:19 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1WWoeH-0000b3-C5 for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Apr 2014 17:06:17 +0200 Original-Received: from localhost ([::1]:58333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWoeG-0007RV-SH for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Apr 2014 11:06:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWoe7-0007LC-V6 for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:06:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWoe2-0004qR-C0 for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:06:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWoe2-0004qN-8P for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WWoe1-0000Bq-PE for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:06:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Apr 2014 15:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17183 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1396796732685 (code B ref -1); Sun, 06 Apr 2014 15:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Apr 2014 15:05:32 +0000 Original-Received: from localhost ([127.0.0.1]:38188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWodW-0000Ay-VF for submit@debbugs.gnu.org; Sun, 06 Apr 2014 11:05:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42956) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWodT-0000Al-F5 for submit@debbugs.gnu.org; Sun, 06 Apr 2014 11:05:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWodK-0004br-Pm for submit@debbugs.gnu.org; Sun, 06 Apr 2014 11:05:24 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWodK-0004bn-Ml for submit@debbugs.gnu.org; Sun, 06 Apr 2014 11:05:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWodE-0005pY-Vo for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:05:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWod9-0004Vp-Pt for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:05:12 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:32854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWod9-0004Uy-Ez for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 11:05:07 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WWod6-0007sZ-5b for bug-gnu-emacs@gnu.org; Sun, 06 Apr 2014 17:05:04 +0200 Original-Received: from 66.207.108.93.rev.vodafone.pt ([93.108.207.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Apr 2014 17:05:04 +0200 Original-Received: from joaotavora by 66.207.108.93.rev.vodafone.pt with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Apr 2014 17:05:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 178 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 66.207.108.93.rev.vodafone.pt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) Cancel-Lock: sha1:bez/6PPtb7J5D/Lhihj0IVRaUBs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:87800 Archived-At: joaotavora@gmail.com (João Távora) writes: > Stefan Monnier writes: > >> Package: Emacs >> Version: 24.3.50 > >> but instead I had to use C-q " twice, which was rather unpleasant. > > Yes seen it. Rather unpleasant indeed. How does this look? Actually, this is slightly simpler. New tests should make my intention clear as well === modified file 'lisp/ChangeLog' *** lisp/ChangeLog 2014-04-05 18:33:55 +0000 --- lisp/ChangeLog 2014-04-06 12:43:30 +0000 *************** *** 1,3 **** --- 1,10 ---- + 2014-04-06 João Távora + + * elec-pair.el (electric-pair--skip-whitespace): With quote + syntax, ensure not outside string before insertion started. . + (electric-pair-post-self-insert-function): Pass syntax to + electric-pair--skip-whitespace. (Bug#17183) + 2014-04-05 Glenn Morris * help.el (view-lossage): Doc tweak. === modified file 'lisp/elec-pair.el' *** lisp/elec-pair.el 2014-02-23 00:19:11 +0000 --- lisp/elec-pair.el 2014-04-06 12:33:49 +0000 *************** *** 151,163 **** (const :tag "Newline" ?\n)) (list character))) ! (defun electric-pair--skip-whitespace () "Skip whitespace forward, not crossing comment or string boundaries." ! (let ((saved (point)) ! (string-or-comment (nth 8 (syntax-ppss)))) ! (skip-chars-forward (apply #'string electric-pair-skip-whitespace-chars)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved)))) (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. --- 151,168 ---- (const :tag "Newline" ?\n)) (list character))) ! (defun electric-pair--skip-whitespace (syntax) "Skip whitespace forward, not crossing comment or string boundaries." ! (let* ((saved (point)) ! (ppss (syntax-ppss)) ! (string-or-comment (nth 8 ppss))) ! (unless (and ! (eq syntax ?\") ! (not (nth 3 (save-excursion ! (syntax-ppss (1- (point))))))) ! (skip-chars-forward (apply #'string electric-pair-skip-whitespace-chars)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved))))) (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. *************** *** 489,495 **** (if (functionp electric-pair-skip-whitespace) (funcall electric-pair-skip-whitespace) electric-pair-skip-whitespace)) ! (electric-pair--skip-whitespace)) (eq (char-after) last-command-event)))) ;; This is too late: rather than insert&delete we'd want to only ;; skip (or insert in overwrite mode). The difference is in what --- 494,500 ---- (if (functionp electric-pair-skip-whitespace) (funcall electric-pair-skip-whitespace) electric-pair-skip-whitespace)) ! (electric-pair--skip-whitespace syntax)) (eq (char-after) last-command-event)))) ;; This is too late: rather than insert&delete we'd want to only ;; skip (or insert in overwrite mode). The difference is in what *************** *** 497,503 **** ;; be visible to other post-self-insert-hook. We'll just have to ;; live with it for now. (when skip-whitespace-info ! (electric-pair--skip-whitespace)) (delete-region (1- pos) (if (eq skip-whitespace-info 'chomp) (point) pos)) --- 502,508 ---- ;; be visible to other post-self-insert-hook. We'll just have to ;; live with it for now. (when skip-whitespace-info ! (electric-pair--skip-whitespace syntax)) (delete-region (1- pos) (if (eq skip-whitespace-info 'chomp) (point) pos)) === modified file 'test/ChangeLog' *** test/ChangeLog 2014-03-25 07:34:30 +0000 --- test/ChangeLog 2014-04-06 12:44:19 +0000 *************** *** 1,3 **** --- 1,11 ---- + 2014-04-06 João Távora + + * automated/electric-tests.el (electric-pair-define-test-form): + More readable test docstrings. + (whitespace-skipping-for-quotes-not-ouside) + (whitespace-skipping-for-quotes-only-inside) + (whitespace-skipping-for-quotes-in-text-mode): New tests. + 2014-03-24 Barry O'Reilly * automated/undo-tests.el (undo-test-marker-adjustment-nominal): === modified file 'test/automated/electric-tests.el' *** test/automated/electric-tests.el 2014-01-01 07:43:34 +0000 --- test/automated/electric-tests.el 2014-04-06 12:41:35 +0000 *************** *** 114,121 **** mode extra-desc)) () ! ,(format "With \"%s\", try input %c at point %d. \ ! Should %s \"%s\" and point at %d" fixture char (1+ pos) --- 114,121 ---- mode extra-desc)) () ! ,(format "With |%s|, try input %c at point %d. \ ! Should %s |%s| and point at %d" fixture char (1+ pos) *************** *** 341,346 **** --- 341,371 ---- :test-in-code nil :test-in-comments t) + (define-electric-pair-test whitespace-skipping-for-quotes-not-ouside + " \" \"" "\"-----" :expected-string "\"\" \" \"" + :expected-point 2 + :bindings '((electric-pair-skip-whitespace . chomp)) + :test-in-strings nil + :test-in-code t + :test-in-comments nil) + + (define-electric-pair-test whitespace-skipping-for-quotes-only-inside + " \" \"" "---\"--" :expected-string " \"\"" + :expected-point 5 + :bindings '((electric-pair-skip-whitespace . chomp)) + :test-in-strings nil + :test-in-code t + :test-in-comments nil) + + (define-electric-pair-test whitespace-skipping-for-quotes-in-text-mode + " \" \"" "---\"--" :expected-string " \"\"\" \"" + :expected-point 5 + :modes '(text-mode) + :bindings '((electric-pair-skip-whitespace . chomp)) + :test-in-strings nil + :test-in-code t + :test-in-comments nil) + ;;; Pairing arbitrary characters ;;;