From 6c58b1f44886bb6a87c3bc804c9c71786f48eb7b Mon Sep 17 00:00:00 2001 From: Ken Manheimer Date: Sun, 17 Jan 2016 19:33:05 -0500 Subject: [PATCH] Remove more residue from old repo. --- aside/pdbtrack.el | 135 ---------------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 aside/pdbtrack.el diff --git a/aside/pdbtrack.el b/aside/pdbtrack.el deleted file mode 100644 index a61546f07..000000000 --- a/aside/pdbtrack.el +++ /dev/null @@ -1,135 +0,0 @@ -;;; pdbtrack - Track source file lines as you run python/pdb in an emacs shell. - -;;; 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" - - (add-hook 'comint-output-filter-functions - 'pdbtrack-comint-output-filter-function) - (make-local-variable 'pdbtrack-buffers-to-kill) - (make-local-variable 'pdbtrack-tracked-buffer) -) - -(defcustom pdbtrack-stacktrace-info-regexp - "> \\([^\"(<]+\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_<>]+\\)()" - "Regular Expression matching stacktrace information. -Used to extract the current line and module being inspected." - :type 'string - :group 'python - :safe 'stringp) - -(defvar pdbtrack-tracked-buffer nil - "Variable containing the value of the current tracked buffer. -Never set this variable directly, use -`pdbtrack-set-tracked-buffer' instead.") - -(defcustom pdbtrack-remove-new-buffers-after-tracking t - "Remove buffers visited for the sake of tracking, on pdb session conclusion." - :type 'boolean - :group 'python) -(defvar pdbtrack-buffers-to-kill nil - "List of buffers to be deleted after tracking finishes.") - -(defun pdbtrack-set-tracked-buffer (file-name) - "Set the buffer for FILE-NAME as the tracked buffer. -Internally it uses the `pdbtrack-tracked-buffer' variable. -Returns the tracked buffer." - (let ((file-buffer (get-file-buffer - (concat (file-remote-p default-directory) - file-name)))) - (if file-buffer - (setq pdbtrack-tracked-buffer file-buffer) - (setq file-buffer (find-file-noselect file-name)) - (when (not (member file-buffer pdbtrack-buffers-to-kill)) - (add-to-list 'pdbtrack-buffers-to-kill file-buffer))) - file-buffer)) - -(defun pdbtrack-comint-output-filter-function (output) - "Move overlay arrow to current pdb line in tracked buffer. -Argument OUTPUT is a string with the output from the comint process." - (when (and pdbtrack-minor-mode (not (string= output ""))) - (let* ((full-output (ansi-color-filter-apply - (buffer-substring comint-last-input-end (point-max)))) - (line-number) - (file-name - (with-temp-buffer - (insert full-output) - ;; When the debugger encounters a pdb.set_trace() - ;; command, it prints a single stack frame. Sometimes - ;; it prints a bit of extra information about the - ;; arguments of the present function. When ipdb - ;; encounters an exception, it prints the _entire_ stack - ;; trace. To handle all of these cases, we want to find - ;; the _last_ stack frame printed in the most recent - ;; batch of output, then jump to the corresponding - ;; file/line number. - (goto-char (point-max)) - (when (re-search-backward pdbtrack-stacktrace-info-regexp nil t) - (setq line-number (string-to-number - (match-string-no-properties 2))) - (match-string-no-properties 1))))) - (if (and file-name line-number) - (let* ((tracked-buffer - (pdbtrack-set-tracked-buffer file-name)) - (shell-buffer (current-buffer)) - (tracked-buffer-window (get-buffer-window tracked-buffer)) - (tracked-buffer-line-pos)) - (with-current-buffer tracked-buffer - (set (make-local-variable 'overlay-arrow-string) "=>") - (set (make-local-variable 'overlay-arrow-position) (make-marker)) - (setq tracked-buffer-line-pos (progn - (goto-char (point-min)) - (forward-line (1- line-number)) - (point-marker))) - (when tracked-buffer-window - (set-window-point - tracked-buffer-window tracked-buffer-line-pos)) - (set-marker overlay-arrow-position tracked-buffer-line-pos)) - (pop-to-buffer tracked-buffer) - (switch-to-buffer-other-window shell-buffer)) - (when pdbtrack-tracked-buffer - (with-current-buffer pdbtrack-tracked-buffer - (set-marker overlay-arrow-position nil)) - (when (not pdbtrack-remove-new-buffers-after-tracking) - (mapc #'(lambda (buffer) - (ignore-errors (kill-buffer buffer))) - pdbtrack-buffers-to-kill)) - (setq pdbtrack-tracked-buffer nil - 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) -- 2.39.2