With a little side of applesauce...

Sunday, January 28, 2007

EMACS - python-mode 100% CPU usage

After installing:

ii emacs-snapshot-bin-common 20060915-1 The GNU Emacs editor’s shared, architecture
ii emacs-snapshot-common 20060915-1 The GNU Emacs editor’s common infrastructure
ii emacs-snapshot-gtk 20060915-1 The GNU Emacs editor (with GTK+ 2.x support)
ii python-mode 1.0-2 Emacs-lisp python-mode and doctest-mode for
ii semantic 1.0pre3-1 Parser Infrastructure for Emacsen

I found that emacs was taking up 100% cpu after opening a python file for editing. I traced it down to semantic, and the following patch:


--- semantic-idle.el 2005/09/30 20:20:43 1.34
+++ semantic-idle.el 2006/09/12 01:16:12 1.35
@@ -1,10 +1,10 @@
;;; semantic-idle.el --- Schedule parsing tasks in idle time

-;;; Copyright (C) 2003, 2004, 2005 Eric M. Ludlam
+;;; Copyright (C) 2003, 2004, 2005, 2006 Eric M. Ludlam

;; Author: Eric M. Ludlam
;; Keywords: syntax
-;; X-RCS: $Id: semantic-idle.el,v 1.34 2005/09/30 20:20:43 zappo Exp $
+;; X-RCS: $Id: semantic-idle.el,v 1.35 2006/09/12 01:16:12 zappo Exp $

;; This file is not part of GNU Emacs.

@@ -286,12 +286,9 @@
(when (zerop (recursion-depth))
(unwind-protect
(semantic-safe "idle error: %S"
- ;; Disable the auto parse timer while re-parsing
- (semantic-idle-scheduler-kill-timer)
;; Handle re-parsing and other scheduled services
(save-match-data (semantic-idle-core-handler)))
- ;; Enable again the auto parse timer
- (semantic-idle-scheduler-setup-timer))))
+ )))

;;; REPARSING
;;


http://cedet.cvs.sourceforge.net/cedet/cedet/semantic/semantic-idle.el?r1=1.34&r2=1.35&view=patch

fixed the issue. Here is how:

1. copy the patch text into ~/downloads/semantic-idle.patch

2. sudo cp /usr/share/emacs/site-lisp/semantic/semantic-idle.el ~/downloads/

3. patch semantic-idle.el semantic-idle.patch
4. emacs -batch -f batch-byte-compile ~/downloads/semantic-idle.el

5. sudo cp ~/downloads/semantic-idle.el /usr/share/emacs/site-lisp/semantic/

6. sudo cp ~/downloads/semantic-idle.elc /usr/share/emacs-snapshot/site-lisp/semantic/
7. start emacs-snapshot

I’m still unclear as to how you can recompile the /usr/share/emacs/site-lisp/semantic/*.el files, and push them out to every ${FLAVOR} of emacs, but the steps above will work for now…

No comments: