From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?G=C3=B6ktu=C4=9F_Kayaalp?= Newsgroups: gmane.emacs.devel Subject: [PATCH] Enable customisation for electric-quote-mode chars Date: Sat, 27 Aug 2016 17:22:31 +0300 Message-ID: <878tvi5m1k.fsf@xi.bootis> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1472308211 12009 195.159.176.226 (27 Aug 2016 14:30:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Aug 2016 14:30:11 +0000 (UTC) Cc: self@gkayaalp.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 27 16:30:07 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdecY-0002g4-Fu for ged-emacs-devel@m.gmane.org; Sat, 27 Aug 2016 16:30:06 +0200 Original-Received: from localhost ([::1]:36201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdecV-0002eT-VM for ged-emacs-devel@m.gmane.org; Sat, 27 Aug 2016 10:30:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdeLA-0005fW-Ie for emacs-devel@gnu.org; Sat, 27 Aug 2016 10:12:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdeL7-0001TA-7R for emacs-devel@gnu.org; Sat, 27 Aug 2016 10:12:08 -0400 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:44194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdeL6-0001Sf-UY for emacs-devel@gnu.org; Sat, 27 Aug 2016 10:12:05 -0400 Original-Received: from mfilter10-d.gandi.net (mfilter10-d.gandi.net [217.70.178.139]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 1EB6E41C07D; Sat, 27 Aug 2016 16:12:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter10-d.gandi.net Original-Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter10-d.gandi.net (mfilter10-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id n8RanOUMTMxI; Sat, 27 Aug 2016 16:12:01 +0200 (CEST) X-Originating-IP: 78.181.205.50 Original-Received: from localhost (unknown [78.181.205.50]) (Authenticated sender: self@gkayaalp.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id C6CF841C074; Sat, 27 Aug 2016 16:11:59 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4b98:c:538::197 X-Mailman-Approved-At: Sat, 27 Aug 2016 10:29:09 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:206829 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This patch enables the user to decide which quote characters to use for curved quotes. Styles change from script to script and from language to language, so it's nicer not to impose any one of the options (for example in Italy and France =E2=80=98guillemets=E2=80=99 are used, which ar= e (=C2=AB) and (=C2=BB), and in German speaking world (=E2=80=9E) and (=E2=80=9C)). I'm not subscribed to the -devel list, so please keep me in the CC; thanks in advance. --=20 =C4=B0. G=C3=B6ktu=C4=9F Kayaalp. http://gkayaalp.com/ --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=electric.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH] Enable customisation for electric-quote-mode chars diff --git a/lisp/electric.el b/lisp/electric.el index e289601..f748c55 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -425,6 +425,14 @@ The variable `electric-layout-rules' says when and how= to insert newlines." :version "25.1" :type 'boolean :safe 'booleanp :group 'electricity) =20 +(defcustom electric-quote-chars '(?=E2=80=98 ?=E2=80=99 ?=E2=80=9C ?=E2=80= =9D) + "List of characters to use as replacements for `electric-quote-mode'. + +The first and the second elements are single quotes, and the +third and the fourth elements are double quotes." + :version "25.1" + :type 'list :safe 'listp :group 'electricity) + (defcustom electric-quote-paragraph t "Non-nil means to use electric quoting in text paragraphs." :version "25.1" @@ -441,7 +449,11 @@ The variable `electric-layout-rules' says when and how= to insert newlines." This requotes when a quoting key is typed." (when (and electric-quote-mode (memq last-command-event '(?\' ?\`))) - (let ((start + (let ((q1 (car electric-quote-chars)) + (q2 (cadr electric-quote-chars)) + (q3 (caddr electric-quote-chars)) + (q4 (cadddr electric-quote-chars)) + (start (if (and comment-start comment-use-syntax) (when (or electric-quote-comment electric-quote-string) (let* ((syntax (syntax-ppss)) @@ -460,27 +472,27 @@ This requotes when a quoting key is typed." (when start (save-excursion (if (eq last-command-event ?\`) - (cond ((and (electric--insertable-p "=E2=80=9C") + (cond ((and (electric--insertable-p (string q3)) (search-backward "=E2=80=98`" (- (point) 2) t)) - (replace-match "=E2=80=9C") + (replace-match (string q3)) (when (and electric-pair-mode (eq (cdr-safe - (assq ?=E2=80=98 electric-pair-text-p= airs)) + (assq q1 electric-pair-text-pairs)) (char-after))) (delete-char 1)) - (setq last-command-event ?=E2=80=9C)) - ((and (electric--insertable-p "=E2=80=98") + (setq last-command-event q3)) + ((and (electric--insertable-p (string q1)) (search-backward "`" (1- (point)) t)) - (replace-match "=E2=80=98") - (setq last-command-event ?=E2=80=98))) - (cond ((and (electric--insertable-p "=E2=80=9D") + (replace-match (string q1)) + (setq last-command-event q1))) + (cond ((and (electric--insertable-p (string q4)) (search-backward "=E2=80=99'" (- (point) 2) t)) - (replace-match "=E2=80=9D") - (setq last-command-event ?=E2=80=9D)) - ((and (electric--insertable-p "=E2=80=99") + (replace-match (string q4)) + (setq last-command-event q4)) + ((and (electric--insertable-p (string q2)) (search-backward "'" (1- (point)) t)) - (replace-match "=E2=80=99") - (setq last-command-event ?=E2=80=99))))))))) + (replace-match (string q2)) + (setq last-command-event q2))))))))) =20 (put 'electric-quote-post-self-insert-function 'priority 10) =20 @@ -497,6 +509,9 @@ and text paragraphs, and these are selectively controll= ed with `electric-quote-comment', `electric-quote-string', and `electric-quote-paragraph'. =20 +Customize `electric-quote-chars' in order to determine which +quote characters to use. + This is a global minor mode. To toggle the mode in a single buffer, use `electric-quote-local-mode'." :global t :group 'electricity --=-=-=--