[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36307: 26.2; Interaction between electric-pair and electric-quote
From: |
Gustavo Barros |
Subject: |
bug#36307: 26.2; Interaction between electric-pair and electric-quote |
Date: |
Wed, 18 Sep 2019 17:26:17 -0300 |
User-agent: |
mu4e 1.2.0; emacs 26.3 |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#36307: 26.2; Interaction between electric-pair and electric-quote,
Gustavo Barros <=