summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorKen Manheimer <klm@digicool.com>2003-03-03 17:09:44 (GMT)
committerKen Manheimer <klm@digicool.com>2003-03-03 17:09:44 (GMT)
commited6000a993b5648bce306988e327bdf95c5129d5 (patch)
tree24933a3491cd4ddd7ae33e091297143275215a63 /Misc
parent5125c76b689da26beec7dd4e60595ce0dd661d93 (diff)
downloadcpython-ed6000a993b5648bce306988e327bdf95c5129d5.zip
cpython-ed6000a993b5648bce306988e327bdf95c5129d5.tar.gz
cpython-ed6000a993b5648bce306988e327bdf95c5129d5.tar.bz2
py-pdbtrack-grub-for-buffer(): Rectified some logic errors i
introduced when shifting around some code, and added some redundancy to reduce chances of hitting the wrong source code. (This is experimental - it will improve the accuracy, but will reduce the ability of the user to deliberately select the buffer they want the buffer grubbing stuff to find. I think the accuracy improvement will be worth it, but am not sure, so may remove this.)
Diffstat (limited to 'Misc')
-rw-r--r--Misc/python-mode.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index c8423f1..f654d8a 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -386,6 +386,13 @@ support for features needed by `python-mode'.")
Currently-active file is at the head of the list.")
(defvar py-pdbtrack-is-tracking-p nil)
+(defvar py-pdbtrack-last-grubbed-buffer nil
+ "Record of the last buffer used when the source path was invalid.
+
+This buffer is consulted before the buffer-list history for satisfying
+`py-pdbtrack-grub-for-buffer', since it's the most often the likely
+prospect as debugging continues.")
+(make-variable-buffer-local 'py-pdbtrack-last-grubbed-buffer)
(defvar py-pychecker-history nil)
@@ -1379,24 +1386,29 @@ problem as best as we can determine."
(defun py-pdbtrack-grub-for-buffer (funcname lineno)
"Find most recent buffer itself named or having function funcname.
-Must have a least int(lineno) lines in it."
+We first check the last buffer this function found, if any, then walk
+throught the buffer-list history for python-mode buffers that are
+named for funcname or define a function funcname."
(let ((buffers (buffer-list))
- ;(buffers (list (get-buffer "workflow_do_action.py")))
curbuf
got)
+ (if (and py-pdbtrack-last-grubbed-buffer
+ (member py-pdbtrack-last-grubbed-buffer buffers))
+ ; Prefer last grubbed buffer by putting it at the front of the list:
+ (setq buffers (cons py-pdbtrack-last-grubbed-buffer buffers)))
(while (and buffers (not got))
(setq buf (car buffers)
buffers (cdr buffers))
- (if (or (save-excursion (set-buffer buf)
- (string= major-mode "python-mode"))
- (and (string-match funcname (buffer-name buf))
+ (if (and (save-excursion (set-buffer buf)
+ (string= major-mode "python-mode"))
+ (or (string-match funcname (buffer-name buf))
(string-match (concat "^\\s-*\\(def\\|class\\)\\s-+"
funcname "\\s-*(")
(buffer-substring (point-min buf)
(point-max buf)
buf))))
(setq got buf)))
- got))
+ (setq py-pdbtrack-last-grubbed-buffer got)))
(defun py-postprocess-output-buffer (buf)
"Highlight exceptions found in BUF.
03-161-120/+85 * | fix commentBenjamin Peterson2012-03-151-2/+2 * | perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)Benjamin Peterson2012-03-153-38/+29 * | free AST's dictBenjamin Peterson2012-03-151-1/+7 * | Issue #14184: mergeNed Deily2012-03-13