From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simon Law Newsgroups: gmane.emacs.bugs Subject: bug#11531: 24.1.50; electric-pair-mode needs to detect apostrophes in strings or comments Date: Mon, 21 May 2012 00:33:47 -0400 Message-ID: <877gw6qhjo.fsf@sfllaw.ca> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1337574875 29885 80.91.229.3 (21 May 2012 04:34:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 21 May 2012 04:34:35 +0000 (UTC) To: 11531@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 21 06:34:34 2012 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 1SWKKI-00086c-67 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 May 2012 06:34:34 +0200 Original-Received: from localhost ([::1]:40323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKKH-0003Fb-HL for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 May 2012 00:34:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKKE-0003FU-5C for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:34:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWKKC-0006hW-8K for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:34:29 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKKC-0006hM-4r for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:34:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SWKKk-0001m6-7K for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simon Law Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 May 2012 04:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 11531 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.13375748936805 (code B ref -1); Mon, 21 May 2012 04:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 May 2012 04:34:53 +0000 Original-Received: from localhost ([127.0.0.1]:36070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWKKa-0001li-GG for submit@debbugs.gnu.org; Mon, 21 May 2012 00:34:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49706) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWKKU-0001lR-DU for submit@debbugs.gnu.org; Mon, 21 May 2012 00:34:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWKJl-0006gU-7c for submit@debbugs.gnu.org; Mon, 21 May 2012 00:34:04 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:49897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKJl-0006gQ-43 for submit@debbugs.gnu.org; Mon, 21 May 2012 00:34:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKJj-0003F3-3K for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:34:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWKJd-0006g1-Q2 for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:33:58 -0400 Original-Received: from mail-yx0-f169.google.com ([209.85.213.169]:45987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWKJd-0006ft-Ld for bug-gnu-emacs@gnu.org; Mon, 21 May 2012 00:33:53 -0400 Original-Received: by yenm7 with SMTP id m7so4813569yen.0 for ; Sun, 20 May 2012 21:33:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type :x-gm-message-state; bh=tMp1XxoALb5EVEWaI17dFt6YlryGT6Yo5kHqIDVc6GU=; b=mtuScI10f8wVLRGN/FewO/JrFKoBnj/sBLoIU0a15z+4M4wfXXtlwPPCqgHZunGG4I JcAecniAEyZ63dVuXVLPENMTic/06IMJj9lbDIpAHHbzY4KpoLM9MmfdW/5bZg6x4dDK NxxkmjaaXUvIgHbx7LrOoaomVOOMDamhf206O259VB3XrUqAhl76eNgPOScI2LGBfXNz FdojvVn4wZhiT8Q9Ba3EuYNm60SLptS5BUCuTxg1EMeOc+kVmXSOK/1ZBwokcKn7Gagd MRRlv0MdSMuPDboGTm2DJBUCIsty86cFQZ2VFK6egbUGd8EZVczkaYzKvnMXnJx7gBMt MxZQ== Original-Received: by 10.42.141.72 with SMTP id n8mr11530168icu.47.1337574830730; Sun, 20 May 2012 21:33:50 -0700 (PDT) Original-Received: from boson (76-10-168-90.dsl.teksavvy.com. [76.10.168.90]) by mx.google.com with ESMTPS id k6sm11739358igw.14.2012.05.20.21.33.48 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 20 May 2012 21:33:49 -0700 (PDT) X-Gm-Message-State: ALoCoQlb7WJUv8ynAi02b32cGjSp4MQfMksEGbJJ1h8R4uLJDkOa9yOHp7u1ugSK3BjALtzvG3bj X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:60255 Archived-At: Reproduction steps: $ emacs -Q M-x js-mode M-x electric-pair-mode Type: // Simon's comment Press RET Type "Simon's string" Press RET Expected result: // Simon's comment "Simon's string" Actual result: // Simon's comment' "Simon's string'" Notes: Inside a comment or string, in a programming mode, we can try to detect apostophes. An apostrophe is likely if you've inserted a single-quote that immediately follows a word character. Here is my workaround: (defadvice electric-pair-post-self-insert-function (around electric-pair-apostrophe activate) "Fix electric-pair to handle apostrophes inside strings or comments" (let* ((quick-syntax-info (syntax-ppss)) (inside-string (fourth quick-syntax-info)) (inside-comment (fifth quick-syntax-info))) (if (not (eq last-command-event ?\')) ;; Only deal with single-quote characters ad-do-it (let* ((char-before-insert (char-before (1- (point)))) (char-before-syntax (and char-before-insert (char-syntax char-before-insert)))) ;; We want the character before the self-insert-command (if (and (or inside-string inside-comment) (eq char-before-syntax ?w)) ;; Single-quotes inside a string or comment, and immediately ;; following a word, are actually apostrophes and should not ;; be paired. t ad-do-it))))) In GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.2.0) of 2012-05-10 on charichuelo, modified by Debian (emacs-snapshot package, version 2:20120510-1~ppa1~oneiric1) Windowing system distributor `The X.Org Foundation', version 11.0.11004000 Configured using: `configure '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-crt-dir=/usr/lib/x86_64-linux-gnu/' '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed -znocombreloc' 'CPPFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: en_CA.UTF-8 value of $LC_CTYPE: en_CA.UTF-8 value of $LC_MESSAGES: en_CA.UTF-8 value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_CA.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Javascript Minor modes in effect: electric-pair-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-x j s - m o d e M-x e l e c t r i c - p a i r - m o d e / / SPC S i m o n ' s SPC c o m m e n t C-e " S i m o n ' s SPC s t r i n g C-n M-x r e p o r t - e m a c s - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Electric-Pair mode enabled byte-code: End of buffer Load-path shadows: /usr/share/emacs/24.1.50/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cus-start cus-load electric js byte-opt bytecomp byte-compile cconv macroexp json imenu thingatpt cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)