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

Bill Clementson billclem@REDACTED
Fri Jun 8 02:35:10 CEST 2007


Bill Clementson <billclem@REDACTED> writes:
> 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)

I've updated the patch for erlang.el version 2.5.3 (which is the one
that is in R11B-4) and added functionality so that "C-u C-c C-k" now
does a compile with both "debug_info" and "export_all".

--
Bill Clementson

--- /usr/local/lib/erlang/lib/tools-2.5.4/emacs/erlang.el	2007-03-02 07:14:38.000000000 -0800
+++ /Users/bc/Desktop/erlang.el	2007-06-07 17:21:14.000000000 -0700
@@ -5599,9 +5599,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'.
@@ -5613,7 +5615,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
@@ -5621,7 +5623,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")
@@ -5631,12 +5633,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, export_all])." 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, export_all]), 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-patches mailing list