GNU bug report logs - #36307
26.2; Interaction between electric-pair and electric-quote

Previous Next

Package: emacs;

Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>

Date: Thu, 20 Jun 2019 13:21:02 UTC

Severity: minor

Merged with 36309

Found in version 26.2

Full log


Message #13 received at 36307 <at> debbugs.gnu.org (full text, mbox):

From: Gustavo Barros <gusbrs.2016 <at> gmail.com>
To: 36307 <at> debbugs.gnu.org
Subject: Re: 26.2; Interaction between electric-pair and electric-quote
Date: Wed, 18 Sep 2019 17:26:17 -0300
Hi all,

On Wed, Jun 26 2019, Gustavo Barros wrote:

> In this respect, I've reached a temporary workaround to inhibit the 
> pairing in
> a left word boundary (no bliss yet for del-sel though):
>
> #+begin_src emacs-lisp
> (defun my/electric-quote-inhibit-pair (orig-fun &rest args)
>  (apply orig-fun args)
>  (when (eq (char-syntax (following-char)) ?w); only before words.
>    (pcase electric-quote-chars
>      (`(,q< ,q> ,q<< ,q>>)
>       (save-excursion
>         (cond ((search-backward (string q>) (1- (point)) t)
>                (replace-match ""))
>               ((search-backward (string q>>) (1- (point)) t)
>                (replace-match ""))))))))
> (advice-add 'electric-quote-post-self-insert-function
>            :around #'my/electric-quote-inhibit-pair)
> #+end_src
>

In case this might be useful to anyone, I’ve improved this somewhat to 
handle better the case where point is mid-word:

#+begin_src emacs-lisp
(defun my/electric-quote-inhibit-pair (orig-fun &rest args)
 (if (and
      (not (eq (char-syntax (preceding-char)) ?w)); no word char before 
      point
      (eq (char-syntax (following-char)) ?w)); word char after point
     ;; If at the beginning of a word
     (progn
       (apply orig-fun args)
       (pcase electric-quote-chars
         (`(,q< ,q> ,q<< ,q>>)
          (save-excursion
            (cond ((search-backward (string q>) (1- (point)) t)
                   (replace-match ""))
                  ((search-backward (string q>>) (1- (point)) t)
                   (replace-match "")))))))
   ;; Else do as usual
   (apply orig-fun args)))

(advice-add 'electric-quote-post-self-insert-function
           :around #'my/electric-quote-inhibit-pair)
#+end_src


Best regards,
Gustavo.




This bug report was last modified 3 years and 244 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.