GNU bug report logs -
#36307
26.2; Interaction between electric-pair and electric-quote
Previous Next
Full log
View this message in rfc822 format
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.