emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#14000: closed (24.3.50; electric-pair-post-self-in


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#14000: closed (24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses)
Date: Mon, 01 Apr 2013 13:33:04 +0000

Your message dated Mon, 01 Apr 2013 09:28:56 -0400
with message-id <address@hidden>
and subject line Re: bug#14000: 24.3.50; 
electric-pair-post-self-insert-function does not handle nested parentheses
has caused the debbugs.gnu.org bug report #14000,
regarding 24.3.50; electric-pair-post-self-insert-function does not handle 
nested parentheses
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
14000: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14000
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Date: Tue, 19 Mar 2013 18:59:53 +0100
In electric-pair-mode, I type "(("

I get "(()"

I should get "(())"

Fix below.

In GNU Emacs 24.3.50.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-19 on bob.porkrind.org
Bzr revision: 112090 address@hidden
Windowing system distributor `Apple', version 10.3.1187
Configured using:
 `configure --host=x86_64-apple-darwin --build=i686-apple-darwin
 --with-ns'

--- electric.el 2013-03-19 18:51:05.000000000 +0100
+++ electric-fixed.el   2013-03-19 18:55:59.000000000 +0100
@@ -354,7 +354,10 @@
                ;; I find it more often preferable not to pair when the
                ;; same char is next.
                (eq last-command-event (char-after))
-               (eq last-command-event (char-before (1- (point))))
+               (and
+                (eq last-command-event (char-before (1- (point))))
+                (not (eq syntax ?\())
+               )
                ;; I also find it often preferable not to pair next to a word.
                (eq (char-syntax (following-char)) ?w)))
       (save-excursion (insert closer))))))



--- End Message ---
--- Begin Message --- Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Date: Mon, 01 Apr 2013 09:28:56 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
> OK, I maybe should have suggested adding a preference.
> But if you live in a world of paired parentheses (and I thought
> Emacs-Lispers were!) you want to add them in pairs, always.

I installed the patch below,


        Stefan


=== modified file 'lisp/electric.el'
--- lisp/electric.el    2013-01-01 09:11:05 +0000
+++ lisp/electric.el    2013-04-01 13:27:16 +0000
@@ -302,6 +302,26 @@
   :version "24.1"
   :type 'boolean)
 
+(defcustom electric-pair-inhibit-predicate
+  #'electric-pair-default-inhibit
+  "Predicate to prevent insertion of a matching pair.
+The function is called with a single char (the opening char just inserted).
+If it returns non-nil, then `electric-pair-mode' will not insert a matching
+closer."
+  :type '(choice
+          (const :tag "Default" electric-pair-default-inhibit)
+          (const :tag "Always pair" ignore)
+          function))
+
+(defun electric-pair-default-inhibit (char)
+  (or
+   ;; I find it more often preferable not to pair when the
+   ;; same char is next.
+   (eq char (char-after))
+   (eq char (char-before (1- (point))))
+   ;; I also find it often preferable not to pair next to a word.
+   (eq (char-syntax (following-char)) ?w)))
+
 (defun electric-pair-syntax (command-event)
   (and electric-pair-mode
        (let ((x (assq command-event electric-pair-pairs)))
@@ -351,12 +371,7 @@
      ;; Insert matching pair.
      ((not (or (not (memq syntax `(?\( ?\" ?\$)))
                overwrite-mode
-               ;; I find it more often preferable not to pair when the
-               ;; same char is next.
-               (eq last-command-event (char-after))
-               (eq last-command-event (char-before (1- (point))))
-               ;; I also find it often preferable not to pair next to a word.
-               (eq (char-syntax (following-char)) ?w)))
+               (funcall electric-pair-inhibit-predicate last-command-event)))
       (save-excursion (insert closer))))))
 
 (defun electric-pair-will-use-region ()



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]