Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Don't fail when syntax entry is missing for closing parens #2

Closed
wants to merge 1 commit into from

2 participants

Steve Purcell João Távora
Steve Purcell

In the case of some buffers, e.g. *urlparse-temp*, there is no syntax entry for closing parens. When trying to enable autopair-global-mode with such buffers open, an error results due to autopair assuming there is such an entry. This commit prevents that error by binding 'autopair-skip-close-maybe only if such a syntax entry exists.

(This behavior was observed in Emacs 24.)

Steve Purcell Don't fail when syntax entry is missing for closing parens
In the case of some buffers, e.g. `*urlparse-temp*`, there is no syntax entry for closing parens. When trying to enable `autopair-global-mode` with such buffers open, an error results due to autopair assuming there is such an entry. This commit prevents that error by binding 'autopair-skip-close-maybe only if such a syntax entry exists.

(This behavior was observed in Emacs 24.)
ea9472b
João Távora
Owner

Well spotted, and a protection is in order, but can I ask :-)

  • What is the purpose of having a syntax of "(" with no closing delimiter? Autopairing will probably fail a lot in this situation. Maybe the when could be moved one line higher up into the cond's condition...

  • Do you need even need autopair in *urlparse-temp*? I suspect not, but it's a global mode... Maybe some kind of deactivation in temp buffers should be default. But what heuristic to use? *scratch* look like a temp buffer but autopair is quite useful there. Perhaps this is a different issue already.

Steve Purcell

a) I don't know why the syntax table was like that in the temp buffer, which was simply in Fundamental Mode.

b) Autopair is certainly not needed in that buffer. I guess that you could skip enabling autopair if the syntax table appears broken. Also in read-only buffers, perhaps. I've wondered myself about how to make that judgement.

In the absence of good heuristics, this workaround is at least somewhat helpful.

João Távora capitaomorte closed this in bc9bb4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 22, 2012
Steve Purcell Don't fail when syntax entry is missing for closing parens
In the case of some buffers, e.g. `*urlparse-temp*`, there is no syntax entry for closing parens. When trying to enable `autopair-global-mode` with such buffers open, an error results due to autopair assuming there is such an entry. This commit prevents that error by binding 'autopair-skip-close-maybe only if such a syntax entry exists.

(This behavior was observed in Emacs 24.)
ea9472b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  autopair.el
3  autopair.el
@@ -412,7 +412,8 @@ syntax table and the local value of `autopair-extra-pairs'."
412 412
           (cond ((eq class (car (string-to-syntax "(")))
413 413
                  ;; syntax classes "opening parens" and "close parens"
414 414
                  (define-key map (string char) 'autopair-insert-opening)
415  
-                 (define-key map (string pair) 'autopair-skip-close-maybe))
  415
+                 (when pair
  416
+                   (define-key map (string pair) 'autopair-skip-close-maybe)))
416 417
                 ((eq class (car (string-to-syntax "\"")))
417 418
                  ;; syntax class "string quote
418 419
                  (define-key map (string char) 'autopair-insert-or-skip-quote))
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.