* emacs.py: catch all errors in eargs()
@ 2006-08-30 17:06 Slawomir Nowaczyk
2006-08-30 21:11 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Slawomir Nowaczyk @ 2006-08-30 17:06 UTC (permalink / raw)
Hello,
The following patch ensures that _emacs_out sentinel is *always*
printed, regardless of what "name" could be. This is necessary for
proper handling of eldoc-mode in python.el
Current code hangs emacs on my machine when I enable eldoc-mode and put
point over non-function like "print".
BTW, shouldn't it *always* be possible to interrupt emacs by C-g? In my
case even C-g doesn't work, I have to kill emacs... I assume
accept-process-output is to be blamed, since emacs doesn't consume CPU
so a loop is unlikely? Or is
(while (progn
(accept-process-output proc 5)
(null python-preoutput-result)))
construct unsafe?
The changes below fix the immediate problem for me, so it is not an
important issue, but one sure wishes emacs itself to be more robust in
handling such cases.
**********************************************************************
ChangeLog entry:
2006-08-30 Slawomir Nowaczyk <slawek@cs.lth.se>
* emacs.py: (eargs) Make sure the _emacs_out sentinel is always
printed while exceptions are always caught
**********************************************************************
--- m:/EmacsCVS/EmacsCVS/etc/emacs.py 2006-08-20 20:00:54.471734400 +0200
+++ c:/Emacs/etc/emacs.py 2006-08-30 17:40:38.220960000 +0200
@@ -44,28 +44,34 @@
def eargs (name, imports):
"Get arglist of NAME for Eldoc &c."
+ res = None
try:
- if imports: exec imports
- parts = name.split ('.')
- if len (parts) > 1:
- exec 'import ' + parts[0] # might fail
- func = eval (name)
- if inspect.isbuiltin (func):
- doc = func.__doc__
- if doc.find (' ->') != -1:
- print '_emacs_out', doc.split (' ->')[0]
- elif doc.find ('\n') != -1:
- print '_emacs_out', doc.split ('\n')[0]
- return
- if inspect.ismethod (func):
- func = func.im_func
- if not inspect.isfunction (func): return
- (args, varargs, varkw, defaults) = inspect.getargspec (func)
- # No space between name and arglist for consistency with builtins.
- print '_emacs_out', \
- func.__name__ + inspect.formatargspec (args, varargs, varkw,
- defaults)
- except: pass
+ try:
+ if imports: exec imports
+ parts = name.split ('.')
+ if len (parts) > 1:
+ exec 'import ' + parts[0] # might fail
+ func = eval (name)
+ if inspect.isbuiltin (func):
+ doc = func.__doc__
+ if doc.find (' ->') != -1:
+ res= '_emacs_out %s' % doc.split (' ->')[0]
+ elif doc.find ('\n') != -1:
+ res= '_emacs_out %s' % doc.split ('\n')[0]
+ return
+ if inspect.ismethod (func):
+ func = func.im_func
+ if not inspect.isfunction (func): return
+ (args, varargs, varkw, defaults) = inspect.getargspec (func)
+ # No space between name and arglist for consistency with builtins.
+ res= '_emacs_out %s' % \
+ func.__name__ + inspect.formatargspec (args, varargs, varkw,
+ defaults)
+ except: pass
+ finally: # make sure we *always* output sentinel
+ if res is None:
+ res= '_emacs_out ()'
+ print res
def all_names (object):
"""Return (an approximation to) a list of all possible attribute
**********************************************************************
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
Does a clean house indicate that there is a broken computer in it?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: emacs.py: catch all errors in eargs()
2006-08-30 17:06 emacs.py: catch all errors in eargs() Slawomir Nowaczyk
@ 2006-08-30 21:11 ` Stefan Monnier
2006-08-31 11:19 ` Slawomir Nowaczyk
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2006-08-30 21:11 UTC (permalink / raw)
Cc: emacs-devel
> The following patch ensures that _emacs_out sentinel is *always*
> printed, regardless of what "name" could be. This is necessary for
> proper handling of eldoc-mode in python.el
> Current code hangs emacs on my machine when I enable eldoc-mode and put
> point over non-function like "print".
Thanks, I'll lok at it. But this is large enough with previous
contributions that I'm beginning to feel like I should need until your legal
paperwork comes in before committing it.
> BTW, shouldn't it *always* be possible to interrupt emacs by C-g? In my
Yes.
> case even C-g doesn't work, I have to kill emacs... I assume
Looks like a bug in python.el where we fail to re-enable C-g before doing
the accept-process-output (C-g is disabled by inhibit-quit when running
timers and such). I installed the patch below which should fix it.
Stefan
Index: python.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/python.el,v
retrieving revision 1.45
diff -u -u -b -r1.45 python.el
--- python.el 28 Aug 2006 21:58:27 -0000 1.45
+++ python.el 30 Aug 2006 21:09:30 -0000
@@ -1599,6 +1599,8 @@
instance. Assumes an inferior Python is running."
(let ((symbol (with-syntax-table python-dotty-syntax-table
(current-word))))
+ ;; This is run from timers, so inhibit-quit tends to be set.
+ (with-local-quit
;; First try the symbol we're on.
(or (and symbol
(python-send-receive (format "emacs.eargs(%S, %s)"
@@ -1616,7 +1618,7 @@
(python-send-receive
(format "emacs.eargs(%S, %s)"
(buffer-substring-no-properties (point) point)
- python-imports)))))))))))
+ python-imports))))))))))))
\f
;;;; Info-look functionality.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: emacs.py: catch all errors in eargs()
2006-08-30 21:11 ` Stefan Monnier
@ 2006-08-31 11:19 ` Slawomir Nowaczyk
0 siblings, 0 replies; 3+ messages in thread
From: Slawomir Nowaczyk @ 2006-08-31 11:19 UTC (permalink / raw)
On Wed, 30 Aug 2006 17:11:10 -0400
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
#> > Current code hangs emacs on my machine when I enable eldoc-mode and
#> > put point over non-function like "print".
#>
#> Thanks, I'll lok at it. But this is large enough with previous
#> contributions that I'm beginning to feel like I should need until
#> your legal paperwork comes in before committing it.
That's OK with me... I am travelling at the moment so I do not know if
the papers have already arrived, but if they did I should be able to
sign and mail them back at the beginning of next week.
#> > case even C-g doesn't work, I have to kill emacs... I assume
#>
#> Looks like a bug in python.el where we fail to re-enable C-g before
#> doing the accept-process-output (C-g is disabled by inhibit-quit when
#> running timers and such). I installed the patch below which should
#> fix it.
Thanks, it works much better now.
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
I'd love to change the world, but they won't give me the source code!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-31 11:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-30 17:06 emacs.py: catch all errors in eargs() Slawomir Nowaczyk
2006-08-30 21:11 ` Stefan Monnier
2006-08-31 11:19 ` Slawomir Nowaczyk
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.