Loaded autopair.el causes errors in pre-command-hook

Bug #1035846 reported by Urs Fleisch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Undecided
Unassigned

Bug Description

Reproduction:

Use the following emacs initialization file (e.g. ~/.emacs.d/init.el):
---
(delete-selection-mode t)
(setq py-install-directory "~/.emacs.d/vendor/components-python-mode")
(add-to-list 'load-path py-install-directory)
(autoload 'python-mode "python-components-mode" "Python editing mode." t)
---

Start Emacs, open a text file and a Python file, switch between the two files using the "Buffers" menu.
Errors occur, as can be seen in the "*Messages*" buffer:

Error in pre-command-hook: (wrong-type-argument symbolp (lambda nil (interactive) (switch-to-buffer example.txt)))
Error in pre-command-hook: (wrong-type-argument symbolp (lambda nil (interactive) (switch-to-buffer example.py)))

Reason for errors:

autopair.el as delivered with wraps an advice around delete-selection-pre-hook, which calls autopair-should-autowrap(), which calls (symbol-name this-command). However, in the described case, this-command is not a symbol, but (lambda nil (interactive) (switch-to-buffer #<buffer example.txt>)).

Fix:

Replaces autopair-should-autowrap with the current version in Git, which has this bug fixed.

---
=== modified file 'autopair/autopair.el'
--- autopair/autopair.el 2012-07-16 07:16:17 +0000
+++ autopair/autopair.el 2012-08-12 10:15:43 +0000
@@ -1171,11 +1171,11 @@
 (put 'autopair-newline 'delete-selection t)

 (defun autopair-should-autowrap ()
- (let ((name (symbol-name this-command)))
- (and autopair-mode
- (not (eq this-command 'autopair-backspace))
- (string-match "^autopair" (symbol-name this-command))
- (autopair-calculate-wrap-action))))
+ (and autopair-mode
+ (not (eq this-command 'autopair-backspace))
+ (symbolp this-command)
+ (string-match "^autopair" (symbol-name this-command))
+ (autopair-calculate-wrap-action)))

 (defadvice cua--pre-command-handler-1 (around autopair-override activate)
   "Don't actually do anything if autopair is about to autowrap. "

---

This patch can also be found in my branch lp:~ufleisch/python-mode/improve-completion.

Related branches

Revision history for this message
Urs Fleisch (ufleisch) wrote :
Changed in python-mode:
milestone: none → 6.0.11
Changed in python-mode:
status: New → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.