Menu

Pydb + xemacs?

2007-04-20
2012-12-10
  • James B. Reese

    James B. Reese - 2007-04-20

    Has anyone gotten pydb to work within xemacs? Which version of the latter? How did you get it to work?

     
    • Rajish

      Rajish - 2007-08-06

      Well not exactly pydb, but mdb. I had to hack it a bit. I can see that the problem is similar.

      First initialization of gud is different in xemacs:
      ---------- function mdb
      ; was
      ;   (list (read-from-minibuffer "Run mdb (like this): "
      ;                   (if (consp gud-mdb-history)
      ;                   (car gud-mdb-history)
      ;                 (concat gud-mdb-command-name
      ;                     " "))
      ;                   gud-minibuffer-local-map nil
      ;                   '(gud-mdb-history . 1))))
      ; better is:
         (list (read-shell-command "Run mdb (like this): "
                                   (if (consp gud-mdb-history)
                                       (car gud-mdb-history)
                                     (concat gud-mdb-command-name
                            " "))
                                   '(gud-mdb-history . 1))))

      ; was:
      ;   (gud-common-init command-line 'gud-mdb-massage-args
      ;            'gud-mdb-marker-filter 'gud-mdb-find-file)
      ; should be:
        (gud-overload-functions '((gud-massage-args . gud-mdb-massage-args)
                      (gud-marker-filter . gud-mdb-marker-filter)
                      (gud-find-file . gud-mdb-find-file)
                      ))
        (gud-common-init command-line "mdb")
      ----------
      Just do M-x replace-string mdb ret pydb ret)

      Second - in xemacs gud there is no variable gud-marker-acc so I had to define it myself (at the top of mdb.el - in your case pydb.el):
      ----------
      ;; Non-existent variable in xemacs GUD implememntation
      (defvar gud-marker-acc "")
      ----------
      I know this is quite ugly hack, but it's quick and it works.

      Third - I had to tweak the gud-mdb-massage-args to concatenate 'file' with 'args' as they get separated in xemacs implementation of gud. But in pydb it looks simpler so maybe it isn't necessary:

      ----------
      (defun gud-mdb-massage-args (file args) ;(cons args file))
        (let* ((new-args (list "--debugger"))
               (seen-e nil)
               (shift (lambda ()
                    (setq new-args (cons (car args) new-args))
                        (if (equal "-f" (car args))                    ;new code
                            (setq new-args (cons file new-args)))      ;new code
                    (setq args (cdr args)))))
         
          ;; Pass all switches and -e scripts through.
          (while (and args
                  (string-match "^-" (car args))
                  (not (equal "-" (car args)))
                  (not (equal "--" (car args))))
            (funcall shift))
         
          (if (and (not file) (or (not args)                         ;new code
                  (string-match "^-" (car args))))                   ;new code
              (error "Can't use stdin as the script to debug"))
          ;; This is the program name.
          (funcall shift)

        (while args
          (funcall shift))
       
        (nreverse new-args)))

      ------------

      And third and maybe the most important: there is already working python debugging mode for xemacs, and it's included in debug module (/usr/lib/xemacs/xemacs-packages/lisp/debug/pdb.el). On my gentoo box:
      --------
      equery belongs /usr/lib/xemacs/xemacs-packages/lisp/debug/pdb.el
      [ Searching for file(s) /usr/lib/xemacs/xemacs-packages/lisp/debug/pdb.el in *... ]
      app-xemacs/xemacs-packages-sumo-2007.04.27 (/usr/lib/xemacs/xemacs-packages/lisp/debug/pdb.el)
      app-xemacs/debug-1.18 (/usr/lib/xemacs/xemacs-packages/lisp/debug/pdb.el)
      ---------

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.