]> code.delx.au - gnu-emacs-elpa/commitdiff
Prepare to move pdbtrack.el aside, until I can recover the good version.
authorKen Manheimer <ken.manheimer@gmail.com>
Fri, 19 Jun 2015 22:04:38 +0000 (18:04 -0400)
committerKen Manheimer <ken.manheimer@gmail.com>
Fri, 19 Jun 2015 22:04:38 +0000 (18:04 -0400)
;;; CRAP. This was extracted from python.el, which lacks some crucial
;;; features of my original pdbtrack code. python-mode.el (available via
;;; marmalade, melpa) has a much more faithful version, including seeking
;;; an existing buffer for a function if the indicated file can't be found
;;; - crucial for doing remote debugging, eg via rpdb.
;;;
;;; I'm going to retire this code, for the moment, until I can recover
;;; pdbtrack (plus whatever improvements may have been developed) from
;;; python-mode.el.

pdbtrack.el

index a374102f9bbcdf16b976520d657570828c6cf349..a61546f077543e5a765ebe68364a289ab1936ae3 100644 (file)
@@ -2,6 +2,16 @@
 
 ;;; Standalone Python PDB dynamic file tracking.
 
+;;; CRAP. This was extracted from python.el, which lacks some crucial
+;;; features of my original pdbtrack code. python-mode.el (available via
+;;; marmalade, melpa) has a much more faithful version, including seeking
+;;; an existing buffer for a function if the indicated file can't be found
+;;; - crucial for doing remote debugging, eg via rpdb.
+;;;
+;;; I'm going to retire this code, for the moment, until I can recover
+;;; pdbtrack (plus whatever improvements may have been developed) from
+;;; python-mode.el.
+
 (define-minor-mode pdbtrack-minor-mode
   "Show lines in source file when Python PDB debugger steps through them."
   nil ":PDBtrack" :require 'pdbtrack :version "2.1"
@@ -100,4 +110,26 @@ Argument OUTPUT is a string with the output from the comint process."
                 pdbtrack-buffers-to-kill nil)))))
   output)
 
+(defun pdbtrack-cherry-pick-buffer (funcname lineno)
+  "Find most recent buffer having name or having function named FUNCNAME.
+We walk the buffer-list history for python-mode buffers that are
+named for funcname or define a function funcname."
+  (let ((buffers (buffer-list))
+        buf
+        got)
+    (while (and buffers (not got))
+      (setq buf (car buffers)
+            buffers (cdr buffers))
+      (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-*(")
+                                 (save-excursion
+                                   (set-buffer buf)
+                                   (buffer-substring (point-min)
+                                                     (point-max))))))
+          (setq got buf)))
+    got))
+
 (provide 'pdbtrack)