From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Daniel Elliott" Newsgroups: gmane.emacs.devel Subject: GUD octave support Date: Sun, 18 Nov 2007 00:42:29 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1195374093 11078 80.91.229.12 (18 Nov 2007 08:21:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Nov 2007 08:21:33 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 18 09:21:40 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ItfPP-0002Er-5x for ged-emacs-devel@m.gmane.org; Sun, 18 Nov 2007 09:21:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ItfPB-0004Pq-Cb for ged-emacs-devel@m.gmane.org; Sun, 18 Nov 2007 03:21:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ItcvQ-00058s-Vf for emacs-devel@gnu.org; Sun, 18 Nov 2007 00:42:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ItcvP-00058g-Bd for emacs-devel@gnu.org; Sun, 18 Nov 2007 00:42:31 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ItcvP-00058d-3o for emacs-devel@gnu.org; Sun, 18 Nov 2007 00:42:31 -0500 Original-Received: from py-out-1112.google.com ([64.233.166.177]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ItcvO-0000S1-Qy for emacs-devel@gnu.org; Sun, 18 Nov 2007 00:42:30 -0500 Original-Received: by py-out-1112.google.com with SMTP id a73so5608057pye for ; Sat, 17 Nov 2007 21:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=wDXRT5zSHFBDrIBN0aj7lkff9OLL3DJ6xYAZiUPAY7g=; b=WSWrQtaJibnETrXFukjNYxjBoxf+a4UuPiGWPYhhiOwLCnBlVCLClou8whVCidSI1EyKWHQX6cG4a2pJb+5ti/dFrqLbwan+FtlmLseVsphKMQItGNhEQ/AVl3g1DdLPMysYmxg20Xt4Di2Ti654rt/v5Xv++PQzrBIwIngCEYw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=IEcmDSh29vMk08xy8CBBIUwOdpSsztb9vUkiMpIw+OamhxDicyKJa9zVtDj58HNmuEhfOmBqMjSXRsrRmHIBI6pPaSWu2kGoIXAbW8owa8CeA8JumuyjyH+LYc5upp7RiBwoh4+WgtVQ32ZDA96ppMZ8UpeL4YvlTRrtF83B8/0= Original-Received: by 10.65.150.18 with SMTP id c18mr8221870qbo.1195364549537; Sat, 17 Nov 2007 21:42:29 -0800 (PST) Original-Received: by 10.64.21.3 with HTTP; Sat, 17 Nov 2007 21:42:29 -0800 (PST) Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-Mailman-Approved-At: Sun, 18 Nov 2007 03:21:19 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83520 Archived-At: Hello, This is my first crack at adding octave support in GUD. It still needs to have some of the features from the octave-inf mode included if possible within the GUD framework. It is a little rough, but appears to be stable and robust. original is the version supplied debian (etch, i beleive) *** original.el 2007-11-17 22:50:35.000000000 -0600 --- gud.el 2007-11-17 22:34:58.000000000 -0600 *************** gud, see `gud-mode'." *** 2332,2337 **** --- 2332,2462 ---- ;; End of debugger-specific information ;; + ;; ====================================================================== + ;; octave debugger functions + + (defvar gud-octavedb-command-name "octave") + + ;;; History of argument lists passed to octavedb + (defvar gud-octavedb-history nil) + + (defun gud-octavedb-massage-args (file args) + ;; just use the default arguments from octave-inf + '("-i" "--no-line-editing" "-q" "--traditional")) + + (setq gud-octavedb-marker-regexp + "keyboard: stopped in\s\\(.*\\)\sat line \\([0-9]+\\)") + + (defun gud-octavedb-marker-filter (string) + + (setq gud-marker-acc (concat gud-marker-acc string)) + (let ((output "")) + + + ;; Process all the complete markers in this chunk. + (while (string-match gud-octavedb-marker-regexp gud-marker-acc) + (setq + + ;; Extract the frame position from the marker. + gud-last-frame + (cons (match-string 1 gud-marker-acc) + (string-to-number (match-string 2 gud-marker-acc))) + + ;; Append any text before the marker to the output we're going + ;; to return - we don't include the marker in this text. + output (concat output + (substring gud-marker-acc 0 (match-beginning 0))) + ;; Set the accumulator to the remaining text. + gud-marker-acc (substring gud-marker-acc (match-end 0)))) + + ;; Does the remaining text look like it might end with the + ;; beginning of another marker? If it does, then keep it in + ;; gud-marker-acc until we receive the rest of it. Since we + ;; know the full marker regexp above failed, it's pretty simple to + ;; test for marker starts. + + ;; DLE: i doubt this is applicable to octave's debug mode + (if (string-match "\032.*\\'" gud-marker-acc) + (progn + ;; Everything before the potential marker start can be output. + (setq output (concat output (substring gud-marker-acc + 0 (match-beginning 0)))) + + ;; Everything after, we save, to combine with later input. + (setq gud-marker-acc + (substring gud-marker-acc (match-beginning 0)))) + + (setq output (concat output gud-marker-acc) + gud-marker-acc "")) + + output)) + + (defvar octavedb-path '()) + (defvar octavedb-init-file-locations '(~/.octaverc)) + + (defun octavedb-paths-from-init (init-file) + (switch-to-buffer (find-file init-file)) + (keep-lines "addpath") + (goto-char (point-min)) + (while (re-search-forward "addpath(\"\\(.*?\\)\".*" (point-max) nil) + (setq octavedb-path (cons (match-string 1) octavedb-path))) + ;; kill file without saving + + ) + + + (defun octavedb-find-file (full-paths) + (if (or (not full-paths) (file-regular-p (car full-paths))) + (car full-paths) + (octavedb-find-file (cdr full-paths))) + ) + + (defun gud-octavedb-find-file (f) + (when (not octavedb-path) + (setq octavedb-path (octavedb-paths-from-init "~/.octaverc"))) + (if (file-regular-p f) + (set-buffer (find-file-noselect f)) + (let* ((found-file (octavedb-find-file (mapcar (lambda (x) (concat x "/" f)) octavedb-path)))) + (if found-file + (set-buffer (find-file-noselect found-file)) + ;; DLE: ask the user for the path + ;; DLE: add the path to our path list + (set-buffer (find-file-noselect f))))) + ) + + + + + ;;;###autoload + (defun octavedb (command-line) + "Run octavedb starting with FILE + The directory containing FILE becomes the initial working directory + and source-file directory for your debugger." + ;; (interactive + ;; (list (read-from-minibuffer "Run which octave: " + ;; (if (consp gud-octavedb-history) + ;; (car gud-octavedb-history) + ;; gud-octavedb-command-name) + ;; nil nil + ;; '(gud-octavedb-history . 1)))) + (setq command-line gud-octavedb-command-name) + + (gud-common-init command-line 'gud-octavedb-massage-args + 'gud-octavedb-marker-filter 'gud-octavedb-find-file) + + ;; DLE: try to add temporary break point + (gud-def gud-break "dbstop(\"%f\",%l)" "\C-b" "Set breakpoint at current line.") + (gud-def gud-remove "dbclear(\"%f\",%l)" "\C-d" "Remove breakpoint at current line") + (gud-def gud-step "dbstep" "\C-s" "Step one source line with display.") + (gud-def gud-next "dbnext" "\C-n" "Step one line (skip functions).") + (gud-def gud-cont "dbcont" "\C-r" "Continue with display.") + + (setq comint-prompt-regexp "debug>\\|>>") + (setq paragraph-start comint-prompt-regexp) + (run-hooks 'octavedb-mode-hook) + ) ;; When we send a command to the debugger via gud-call, it's annoying ;; to see the command and the new prompt inserted into the debugger's