From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Greselin Newsgroups: gmane.emacs.help Subject: How to control pairing of quotes in text-mode with electric-pair-mode? Date: Fri, 5 Jul 2019 11:40:49 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="67038"; mail-complaints-to="usenet@blaine.gmane.org" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 05 14:43:49 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hjNZ6-000HMs-9q for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Jul 2019 14:43:48 +0200 Original-Received: from localhost ([::1]:52718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjNZ4-0005J9-64 for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Jul 2019 08:43:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43370) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjKip-00063K-2N for help-gnu-emacs@gnu.org; Fri, 05 Jul 2019 05:41:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hjKin-0000NQ-BF for help-gnu-emacs@gnu.org; Fri, 05 Jul 2019 05:41:38 -0400 Original-Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:46829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hjKih-00006Q-9j for help-gnu-emacs@gnu.org; Fri, 05 Jul 2019 05:41:33 -0400 Original-Received: by mail-pl1-x633.google.com with SMTP id c2so2785072plz.13 for ; Fri, 05 Jul 2019 02:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=6uDcJFEl8L2gcdkUwts2OhtW37H7Tz6rpC9+uHUVasw=; b=E8qyisO2SCqhLZWjI/TD5uKuARSoJrJFXT2wxwspJ36pNlh0YisRc7ljpXeoQpG9gX G0Bi2aNYo6WKgHgCpU0nlF7dOWLTGu+RsSE53hlRVt9xYwRkV5niIAWlNsJ8e0jntNTq Xn+EyrvF9HeQS+h4rJlcnfdfaLpCcFaItt6Tx4QK5Pd27twoxZuHJUjk9AnlhGnyDyWf KHGD/qkD5vM3uFX7lRtQoI9hzGyp1g2TGzg91aGmd1kO5N6Hm4e8YC+JSsKOeAsMV+gO Yo/pmQ02zB4gSalo08CWi77WU3uKGO85d8UMCeJj/Mfgf9TtyvtW6PxsLpE/X4IaehX2 vRJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=6uDcJFEl8L2gcdkUwts2OhtW37H7Tz6rpC9+uHUVasw=; b=EPFKKVRiIErMTau9a/oWHNsOkrbYqM1SjW0UiGkBHLUYtagYcaJ1C84DzzEPK5VSVG xTdiPbcvdAUdLboDosUaDOeW0fFLuWuzKsNoM7kCli61LpXvCHYnSaepj0wuQxkCdI6N d8RcuH/5T6cdD2jIkndPIaCY4Lh75l98dsh/6c3p/ilH161ogm/GRUixqiynJZJgDosl XwH/1unJWMJt8Z3qO1EWe2amerdL3cBHAtN4Rp+x7kRLF/F6JT5ZZkhNu547gS3oRIKL ku+laMOZuTKIK/f7PRvY4GnbJW6MqnLaTPUtl16aSAcJb5Z1+bcYKyGEC6povcJlhgBM O3FQ== X-Gm-Message-State: APjAAAU9Vw3WUQOWUHBwDhW46XICpMNPp355HjzLM4yJWlPNfQzpx/MA w/rtYXUd+EImSjSQl3fZOQWFe40D3yEHNar8sebGth/0 X-Google-Smtp-Source: APXvYqwDt5aUXGopJuZ0p1HVSpkrCRrWo8WxT9G3pXN2M8Kj5GCOLrJdy/DZYf4Oi7jsnX+gLsmaiepsKF0QtykkzRo= X-Received: by 2002:a17:902:2aa9:: with SMTP id j38mr4117067plb.206.1562319685980; Fri, 05 Jul 2019 02:41:25 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::633 X-Mailman-Approved-At: Fri, 05 Jul 2019 08:42:59 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121104 Archived-At: Hello, I'd like 'electric-pair-mode' not to pair quotes at the end of words or following punctuation characters, as in "=E2=80=A6end of quote" or "=E2=80= =A6 end of quote." I've written this function for 'electric-pair-inhibit-predicate', based on 'electric-pair-conservative-inhibit': (defun my-electric-pair-inhibit (char) (or ;; Do not pair when the same char is next. (eq char (char-after)) ;; Do not pair right before a word. (eq (char-syntax (following-char)) ?w) ;; After a word or a punctuation character, pair parentheses but do not pair quotes. (when (and (> (point) 2) (char-equal char ?\")) (or (eq (char-syntax (char-before (1- (point)))) ?w) (eq (char-syntax (char-before (1- (point)))) ?.))))) It works fine in 'emacs-lisp-mode' but it doesn't in 'text-mode': quotes are still paired around words. I've noticed that it's the same with 'electric-pair-inhibit-predicate' set to 'electric-pair-conservative-inhibit', which should suppress pairing at the beginning of words: in 'emacs-lisp-mode' both parentheses and quotes are not paired at the beginning of words, but in 'text-mode' only parentheses pairing is suppressed. All the best, Andrea