Fix `electric-pair-backward-delete-char' error at bob
authorJoão Távora <joaotavora@gmail.com>
Mon, 3 Feb 2014 00:28:57 +0000 (00:28 +0000)
committerJoão Távora <joaotavora@gmail.com>
Mon, 3 Feb 2014 00:28:57 +0000 (00:28 +0000)
* lisp/elec-pair.el (electric-pair-backward-delete-char): Don't error
when at beginning of (possibly narrowed) buffer.

lisp/ChangeLog
lisp/elec-pair.el

index 9b69228..542e686 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-03  João Távora  <joaotavora@gmail.com>
+
+       * elec-pair.el (electric-pair-backward-delete-char): Don't error
+       when at beginning of (possibly narrowed) buffer.
+
 2014-02-02  Daniel Colascione  <dancol@dancol.org>
 
        * help-at-pt.el (help-at-pt-string,help-at-pt-maybe-display): Also
index a2d637e..bf02e5f 100644 (file)
@@ -174,13 +174,14 @@ non-nil, `backward-delete-char-untabify'."
   (interactive "*p\nP")
   (let* ((prev (char-before))
          (next (char-after))
-         (syntax-info (electric-pair-syntax-info prev))
+         (syntax-info (and prev
+                           (electric-pair-syntax-info prev)))
          (syntax (car syntax-info))
          (pair (cadr syntax-info)))
-    (when (and (if (functionp electric-pair-delete-adjacent-pairs)
+    (when (and next pair
+               (if (functionp electric-pair-delete-adjacent-pairs)
                    (funcall electric-pair-delete-adjacent-pairs)
                  electric-pair-delete-adjacent-pairs)
-               next
                (memq syntax '(?\( ?\" ?\$))
                (eq pair next))
       (delete-char 1 killflag))