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 02:26:15 +0100 Message-ID: <87bnwf8czs.fsf@kitaj.lan> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1396747683 10906 80.91.229.3 (6 Apr 2014 01:28:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Apr 2014 01:28:03 +0000 (UTC) Cc: 17183@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 06 03:27:55 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 1WWbsG-0007w2-Ub for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Apr 2014 03:27:53 +0200 Original-Received: from localhost ([::1]:56455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWbsG-0006hh-3h for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 21:27:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWbrx-0006b4-R8 for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 21:27:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWbrS-0006Wj-Nx for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 21:27:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36035) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWbrS-0006Wb-KW for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 21:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WWbrS-0006U9-7o for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 21:27:02 -0400 X-Loop: help-debbugs@gnu.org 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 01:27:02 +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: Original-Received: via spool by 17183-submit@debbugs.gnu.org id=B17183.139674758224869 (code B ref 17183); Sun, 06 Apr 2014 01:27:02 +0000 Original-Received: (at 17183) by debbugs.gnu.org; 6 Apr 2014 01:26:22 +0000 Original-Received: from localhost ([127.0.0.1]:37215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWbqn-0006T0-CV for submit@debbugs.gnu.org; Sat, 05 Apr 2014 21:26:22 -0400 Original-Received: from mail-wi0-f172.google.com ([209.85.212.172]:43708) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWbql-0006Sr-FC for 17183@debbugs.gnu.org; Sat, 05 Apr 2014 21:26:20 -0400 Original-Received: by mail-wi0-f172.google.com with SMTP id hi2so3220727wib.5 for <17183@debbugs.gnu.org>; Sat, 05 Apr 2014 18:26:18 -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=vWpxGZvMjbqGm4CWjc1Ww14syIHcSPAIqBV595UgL+I=; b=Wz36xG04t63hqeM/7Kliaw7lokxcQMqLNwuWg5FXpWVT3urig5KGPb/CVu9zCysLu8 /UXM2VeF+wM/DWmMOYnqjTkbAZj4om44YTxFCWd7BMDNdVrSmqpeKwDcHU1kP8XbA4se FIdsr+0WJuNdmoWcIr7FW9Euy+GT9hOphBAaNt2G4pz5CYS8lrusYFGGEvq9M5W/FKkk CJ8AZuI5I0PVuQDDnbPkpq9QuZ6r8LRzJY2rY1Bw044I1MHBsEb0t6rUsYj017ZXL+Nr bGVrJ7/oV07hR+sV2lwsO69SyZrvPGajZbhqSIcSVJ/eif1OwHQbrcIyj35qpghVpwKZ UUUg== X-Received: by 10.180.205.204 with SMTP id li12mr15247025wic.34.1396747578586; Sat, 05 Apr 2014 18:26:18 -0700 (PDT) Original-Received: from kitaj.lan.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id jd2sm14099417wic.9.2014.04.05.18.26.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Apr 2014 18:26:17 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 04 Apr 2014 11:03:33 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) 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:87786 Archived-At: 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?=20 =3D=3D=3D modified file 'lisp/ChangeLog' *** lisp/ChangeLog 2014-04-04 23:31:02 +0000 --- lisp/ChangeLog 2014-04-06 01:23:51 +0000 *************** *** 1,3 **** --- 1,11 ---- + 2014-04-06 Jo=C3=A3o T=C3=A1vora +=20 + * elec-pair.el (electric-pair--skip-whitespace): With quote + syntax, ensure not outside string before insertion started. . + (electric-pair-post-self-insert-function): Pass char and syntax to + electric-pair--skip-whitespace. Save point instead of + `save-excursion'. (Bug#17183) +=20 2014-04-04 Jo=C3=A3o T=C3=A1vora =20=20 * elec-pair.el: =3D=3D=3D modified file 'lisp/elec-pair.el' *** lisp/elec-pair.el 2014-04-04 23:31:02 +0000 --- lisp/elec-pair.el 2014-04-06 01:19:47 +0000 *************** *** 151,163 **** (const :tag "Newline" ?\n)) (list character))) =20=20 ! (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-cha= rs)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved)))) =20=20 (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. --- 151,171 ---- (const :tag "Newline" ?\n)) (list character))) =20=20 ! (defun electric-pair--skip-whitespace (char 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 ?\") ! (unwind-protect ! (progn ! (delete-char -1) ! (not (nth 3 (syntax-ppss)))) ! (insert-char char))) ! (skip-chars-forward (apply #'string electric-pair-skip-whitespace-c= hars)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved))))) =20=20 (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. *************** *** 502,521 **** (if (functionp electric-pair-skip-self) (funcall electric-pair-skip-self last-command-= event) electric-pair-skip-self)) ! (save-excursion (when (setq skip-whitespace-info (if (functionp electric-pair-skip-whites= pace) (funcall electric-pair-skip-whitespa= ce) 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 ;; goes in the undo-log and in the intermediate state which might ;; 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)) --- 510,531 ---- (if (functionp electric-pair-skip-self) (funcall electric-pair-skip-self last-command-= event) electric-pair-skip-self)) ! (let ((saved (point))) (when (setq skip-whitespace-info (if (functionp electric-pair-skip-whites= pace) (funcall electric-pair-skip-whitespa= ce) electric-pair-skip-whitespace)) ! (electric-pair--skip-whitespace last-command-event= syntax)) ! (prog1 ! (eq (char-after) last-command-event) ! (goto-char saved))))) ;; This is too late: rather than insert&delete we'd want to only ;; skip (or insert in overwrite mode). The difference is in what ;; goes in the undo-log and in the intermediate state which might ;; 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 last-command-event syntax)) (delete-region (1- pos) (if (eq skip-whitespace-info 'chomp) (point) pos))