[erlang-questions] Patch for erlang.el (optional debug_info on compile)

Bill Clementson billclem@REDACTED
Wed May 30 18:55:51 CEST 2007


Hi all, 

At present, erlang-mode doesn't provide any way to compile an erlang
file for debug - you have to manually do the debug compile in an
Erlang shell. This bugs me (bad pun!), so I've created a patch for
erlang.el that does a debug compile if the standard compile function
is called with a prefix arg (e.g. - "C-c C-k" does a "normal" compile
and "C-u C-c C-k" does a compile with "debug_info").

Attached is the patch (for erlang-mode version 2.5.2)

-- 
Bill Clementson

--- /usr/local/lib/erlang/lib/tools-2.5.1/emacs/erlang.el	2006-05-03 01:26:49.000000000 -0700
+++ ./erlang.el	2007-05-30 09:24:39.000000000 -0700
@@ -5570,9 +5570,11 @@
 	    (replace-match "" t t))))))
 
 
-(defun inferior-erlang-compile ()
+(defun inferior-erlang-compile (arg)
   "Compile the file in the current buffer.
 
+With prefix arg, compiles for debug.
+
 Should Erlang return `{error, nofile}' it could not load the object
 module after completing the compilation.  This is due to a bug in the
 compile command `c' when using the option `outdir'.
@@ -5584,7 +5586,7 @@
   2) Set the Emacs variable `erlang-compile-use-outdir' to nil.
      To do so, place the following line in your `~/.emacs'-file:
         (setq erlang-compile-use-outdir nil)"
-  (interactive)
+  (interactive "P")
   (save-some-buffers)
   (or (inferior-erlang-running-p)
       (save-excursion
@@ -5592,7 +5594,7 @@
   (or (inferior-erlang-running-p)
       (error "Error starting inferior Erlang shell"))
   (let ((dir (file-name-directory (buffer-file-name)))
-	;;; (file (file-name-nondirectory (buffer-file-name)))
+;;; (file (file-name-nondirectory (buffer-file-name)))
 	(noext (substring (buffer-file-name) 0 -4))
 	;; Hopefully, noone else will ever use these...
 	(tmpvar "Tmp7236")
@@ -5602,12 +5604,16 @@
     (inferior-erlang-wait-prompt)
     (setq end (inferior-erlang-send-command
 	       (if erlang-compile-use-outdir
-		   (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir)
+		   (if current-prefix-arg 
+		       (format "c(\"%s\", [{outdir, \"%s\"}, debug_info])." noext dir)
+		     (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir))
 		 (format
 		  (concat
 		   "f(%s), {ok, %s} = file:get_cwd(), "
 		   "file:set_cwd(\"%s\"), "
-		   "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s.")
+		   (if current-prefix-arg 
+		       "%s = c(\"%s\", [debug_info]), file:set_cwd(%s), f(%s), %s."
+		     "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s."))
 		  tmpvar2 tmpvar
 		  dir
 		  tmpvar2 noext tmpvar tmpvar tmpvar2))




More information about the erlang-questions mailing list