all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* compilation-mode support for Guile backtrace
@ 2014-08-08 11:05 Jan Nieuwenhuizen
  2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 11:05 UTC (permalink / raw)
  To: emacs-devel, guile-user

Hi,

Still wondering about my previous set of Guile/Emacs integration
patches, here is the next set: backtraces.

Please apply, or enlighten me.

Greetings, Jan




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 11:05 compilation-mode support for Guile backtrace Jan Nieuwenhuizen
@ 2014-08-08 11:05 ` Jan Nieuwenhuizen
  2014-08-08 13:29   ` Stefan Monnier
  2014-08-08 13:47   ` Eli Zaretskii
  2014-08-08 11:05 ` [PATCH 2/3] Add Guile backtrace example Jan Nieuwenhuizen
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 11:05 UTC (permalink / raw)
  To: emacs-devel, guile-user

	* progmodes/compile.el (compilation-error-regexp-alist-alist):
	Add Guile regexpses.
	(compilation-dynamic-guile-load-path-p)
	(compilation-guile-get-load-path-command)
	(compilation-guile-load-path): New variable.
	(compilation-guile-in-find-file): New function.
---
 lisp/ChangeLog            |  9 +++++++++
 lisp/progmodes/compile.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b3da957..b66d48a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2014-08-08  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* progmodes/compile.el (compilation-error-regexp-alist-alist):
+	Add Guile regexpses.
+	(compilation-dynamic-guile-load-path-p)
+	(compilation-guile-get-load-path-command)
+	(compilation-guile-load-path): New variable.
+	(compilation-guile-in-find-file): New function.
+
 2014-08-05  Jan Nieuwenhuizen  <janneke@gnu.org>
 
 	* progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 000d719..98d098c4 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -129,6 +129,34 @@ and a string describing how the process finished.")
 
 (defvar compilation-num-errors-found)
 
+(defcustom compilation-dynamic-guile-load-path-p nil
+  "If non-nil, Guile's load path is retrieved by running guile."
+  :type 'boolean
+  :group 'compilation
+  :version "24.3.2")
+
+(defcustom compilation-guile-get-load-path-command "guile -c '(write %load-path)'"
+  "Guile command to print %load-path to stdout."
+  :type 'string
+  :group 'compilation
+  :version "24.3.2")
+
+(defcustom compilation-guile-load-path '("/usr/share/guile/2.0" "/usr/share/guile/site")
+  "Path to locate Guile soure files for incomplete (Guile %load-path based) error messages.  If compilation-guile-load-path-p is non-nil, it is dynamically set from Guile."
+  :type 'list
+  :group 'compilation
+  :version "24.3.2")
+
+(defun compilation-guile-in-find-file ()
+  (let ((file-name (match-string 1)))
+    (if (file-exists-p file-name)
+        file-name
+      (if (and compilation-dynamic-guile-load-path-p
+               (not (compilation-guile-load-path)))
+          (setq guile-load-path (read (shell-command-to-string compilation-guile-get-load-path-command))))
+      (or (locate-file file-name compilation-guile-load-path)
+          file-name))))
+
 ;; If you make any changes to `compilation-error-regexp-alist-alist',
 ;; be sure to run the ERT test in test/automated/compile-tests.el.
 ;; emacs -batch -l compile-tests.el -f ert-run-tests-batch-and-exit
@@ -477,6 +505,8 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
      ;;
      "^\\([^ \t\r\n(]+\\) (\\([0-9]+\\):\\([0-9]+\\)) "
      1 2 3)
+    (guile-file "^In \\(.+\\):\n" compilation-guile-in-find-file)
+    (guile-line "^ *\\([0-9]+\\): *\\([0-9]+\\)" nil 1 2)
     )
   "Alist of values for `compilation-error-regexp-alist'.")
 
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] Add Guile backtrace example.
  2014-08-08 11:05 compilation-mode support for Guile backtrace Jan Nieuwenhuizen
  2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
@ 2014-08-08 11:05 ` Jan Nieuwenhuizen
  2014-08-08 11:05 ` [PATCH 3/3] Add tests for Guile compile regexps Jan Nieuwenhuizen
  2014-08-08 13:33 ` compilation-mode support for Guile backtrace Eli Zaretskii
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 11:05 UTC (permalink / raw)
  To: emacs-devel, guile-user

	* compilation.txt (file): Add Guile backtrace example.
---
 etc/ChangeLog       |  4 ++++
 etc/compilation.txt | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/etc/ChangeLog b/etc/ChangeLog
index c0db914..67a70e0 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-08  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* compilation.txt (file): Add Guile backtrace example.
+
 2014-07-21  Dmitry Antipov  <dmantipov@yandex.ru>
 
 	* TODO: remove frame height remark.
diff --git a/etc/compilation.txt b/etc/compilation.txt
index e835c57..84da6b9 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -261,6 +261,24 @@ file:G:/cygwin/dev/build-myproj.xml:54: Compiler Adapter 'javac' can't be found.
 {standard input}:27041: Warning: end of file not at end of a line; newline inserted
 
 
+* Guile backtraces
+
+Backtrace:
+In ice-9/boot-9.scm:
+ 157: 6 [catch #t #<catch-closure 196e3e0> ...]
+In unknown file:
+   ?: 5 [apply-smob/1 #<catch-closure 196e3e0>]
+In ice-9/boot-9.scm:
+  63: 4 [call-with-prompt prompt0 ...]
+In ice-9/eval.scm:
+ 432: 3 [eval # #]
+In unknown file:
+   ?: 2 [eval (main (command-line)) #<directory (gud-break) 1962510>]
+In /home/janneke/vc/guile/examples/gud-break.scm:
+1038: 1 [main ("gud-break.scm")]
+1033: 0 [stderr "~a:hello world\n" (# # #)]
+
+
 * Lucid Compiler, lcc 3.x
 
 symbol: lcc
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] Add tests for Guile compile regexps.
  2014-08-08 11:05 compilation-mode support for Guile backtrace Jan Nieuwenhuizen
  2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
  2014-08-08 11:05 ` [PATCH 2/3] Add Guile backtrace example Jan Nieuwenhuizen
@ 2014-08-08 11:05 ` Jan Nieuwenhuizen
  2014-08-08 13:33 ` compilation-mode support for Guile backtrace Eli Zaretskii
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 11:05 UTC (permalink / raw)
  To: emacs-devel, guile-user

	* automated/compile-tests.el (compile--test-error-line): Grok FILE
	being nil.  Allows for Guile tests to pass.
	(compile-tests--test-regexps-data): Add Guile tests.
---
 test/ChangeLog                  | 6 ++++++
 test/automated/compile-tests.el | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/test/ChangeLog b/test/ChangeLog
index 4339dc5..92b0d12 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-08  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* automated/compile-tests.el (compile--test-error-line): Grok FILE
+	being nil.  Allows for Guile tests to pass.
+	(compile-tests--test-regexps-data): Add Guile tests.
+
 2014-08-03  Glenn Morris  <rgm@gnu.org>
 
 	* automated/Makefile.in (check-tar): New rule.
diff --git a/test/automated/compile-tests.el b/test/automated/compile-tests.el
index 6c169ee..e231331 100644
--- a/test/automated/compile-tests.el
+++ b/test/automated/compile-tests.el
@@ -190,6 +190,10 @@
      1 nil 54 "G:/cygwin/dev/build-myproj.xml")
     ("{standard input}:27041: Warning: end of file not at end of a line; newline inserted"
      1 nil 27041 "{standard input}")
+    ;; Guile
+    ("In foo.scm:\n" 1 nil nil "foo.scm")
+    ("  63:4 [call-with-prompt prompt0 ...]" 1 4 63 nil)
+    ("1038: 1 [main (\"gud-break.scm\")]" 1 1 1038 nil)
     ;; lcc
     ("E, file.cc(35,52) Illegal operation on pointers" 1 52 35 "file.cc")
     ("W, file.cc(36,52) blah blah" 1 52 36 "file.cc")
@@ -338,7 +342,8 @@ END-LINE, if that matched.")
 	    (setq end-line (cdr line) line (car line)))
 	(and (equal (compilation--loc->col loc) col)
 	     (equal (compilation--loc->line loc) line)
-	     (equal (caar (compilation--loc->file-struct loc)) file)
+	     (or (not file) 
+                 (equal (caar (compilation--loc->file-struct loc)) file))
 	     (or (null end-col)
 	     	 (equal (car (cadr (nth 2 (compilation--loc->file-struct loc))))
 	     		end-col))
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
@ 2014-08-08 13:29   ` Stefan Monnier
  2014-08-08 17:43     ` Jan Nieuwenhuizen
  2014-08-08 13:47   ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2014-08-08 13:29 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user, emacs-devel

> @@ -477,6 +505,8 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
>       ;;
>       "^\\([^ \t\r\n(]+\\) (\\([0-9]+\\):\\([0-9]+\\)) "
>       1 2 3)
> +    (guile-file "^In \\(.+\\):\n" compilation-guile-in-find-file)
> +    (guile-line "^ *\\([0-9]+\\): *\\([0-9]+\\)" nil 1 2)
>      )
>    "Alist of values for `compilation-error-regexp-alist'.")
 
Quick comments:
- You can collapse all three patches into a single one.
- Both of those Guile regexps are much too generic (i.e. likely to
  appear in non-Guile output), while the corresponding handler you
  provide is clearly very Guile-specific.  This is a *serious* problem.
- I think a good way to solve it would be to push the problem upstream ;-)
  IOW, convince the Guile guys to follow the GNU convention.  This could
  look somewhat like:

   * Guile backtraces
   
   Backtrace:
   /some/where/ice-9/boot-9.scm:157:
      6 [catch #t #<catch-closure 196e3e0> ...]
   unknown file:?:
      5 [apply-smob/1 #<catch-closure 196e3e0>]
   /some/where/ice-9/boot-9.scm:63:
      4 [call-with-prompt prompt0 ...]
   /some/where/ice-9/eval.scm:432:
      3 [eval # #]
   unknown file:?:
      2 [eval (main (command-line)) #<directory (gud-break) 1962510>]
   /home/janneke/vc/guile/examples/gud-break.scm:1038:
      1 [main ("gud-break.scm")]
      0 [stderr "~a:hello world\n" (# # #)]

  With the above, you might not even need to change compile.el.  Tho,
  admittedly, the above lines might end up highlighted as "errors"
  whereas they should probably be treated as "info", so some annotation
  on the "FILE:LINE:" lines would be helpful to let Emacs know that it's
  not an "error" location, but just an "info".  Not sure if the GNU
  conventions already include such an annotation, but I can't see why
  that couldn't be arranged.


        Stefan



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: compilation-mode support for Guile backtrace
  2014-08-08 11:05 compilation-mode support for Guile backtrace Jan Nieuwenhuizen
                   ` (2 preceding siblings ...)
  2014-08-08 11:05 ` [PATCH 3/3] Add tests for Guile compile regexps Jan Nieuwenhuizen
@ 2014-08-08 13:33 ` Eli Zaretskii
  3 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2014-08-08 13:33 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user, emacs-devel

> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Fri,  8 Aug 2014 13:05:53 +0200
> 
> Still wondering about my previous set of Guile/Emacs integration
> patches

For the Emacs side: please be patient.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
  2014-08-08 13:29   ` Stefan Monnier
@ 2014-08-08 13:47   ` Eli Zaretskii
  2014-08-08 13:53     ` Jan Nieuwenhuizen
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2014-08-08 13:47 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user, emacs-devel

> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Fri,  8 Aug 2014 13:05:54 +0200
> 
> +(defcustom compilation-guile-load-path '("/usr/share/guile/2.0" "/usr/share/guile/site")

Not a good idea, IMO.  This is inherently system-dependent, and
doesn't support Guile installations with non-default $(prefix).  IOW,
it's unreliable.

How about invoking the Guile executable and asking it to emit the
path?  That would be reliable and portable.

> +  "Path to locate Guile soure files for incomplete (Guile %load-path based) error messages.  If compilation-guile-load-path-p is non-nil, it is dynamically set from Guile."

Please break the doc string into lines that are shorter than 75
columns, that's our coding practice.

Thanks.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 13:47   ` Eli Zaretskii
@ 2014-08-08 13:53     ` Jan Nieuwenhuizen
  2014-08-08 13:57       ` Eli Zaretskii
  2014-08-08 14:34       ` Emilio Lopes
  0 siblings, 2 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 13:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: guile-user, emacs-devel

Eli Zaretskii writes:

>> +(defcustom compilation-guile-load-path '("/usr/share/guile/2.0"
>> "/usr/share/guile/site")
>
> Not a good idea, IMO.  This is inherently system-dependent, and
> doesn't support Guile installations with non-default $(prefix).  IOW,
> it's unreliable.
>
> How about invoking the Guile executable and asking it to emit the
> path?  That would be reliable and portable.

Yes, I am doing that here

    +(defcustom compilation-guile-get-load-path-command "guile -c '(write %load-path)'"
    +  "Guile command to print %load-path to stdout."
    +  :type 'string
    +  :group 'compilation
    +  :version "24.3.2")

but have turned it off by default...  Possibly just always do this?

> Please break the doc string into lines that are shorter than 75
> columns, that's our coding practice.

Thanks for your comments!  I'm working on a patch right now for Guile to
use GNU standard error/info messages as per Stefan's suggestion.

Greetings, Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 13:53     ` Jan Nieuwenhuizen
@ 2014-08-08 13:57       ` Eli Zaretskii
  2014-08-08 14:34       ` Emilio Lopes
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2014-08-08 13:57 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user, emacs-devel

> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Cc: guile-user@gnu.org, emacs-devel@gnu.org
> Date: Fri, 08 Aug 2014 15:53:11 +0200
> 
>     +(defcustom compilation-guile-get-load-path-command "guile -c '(write %load-path)'"

OK, but for portability to non-Posix platforms, please use only ".."
quotes, as '..' quoting is Posix-specific.

> Thanks for your comments!  I'm working on a patch right now for Guile to
> use GNU standard error/info messages as per Stefan's suggestion.

Thank you for your work.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 13:53     ` Jan Nieuwenhuizen
  2014-08-08 13:57       ` Eli Zaretskii
@ 2014-08-08 14:34       ` Emilio Lopes
  1 sibling, 0 replies; 11+ messages in thread
From: Emilio Lopes @ 2014-08-08 14:34 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: Eli Zaretskii, guile-user, emacs-devel

2014-08-08 15:53 GMT+02:00 Jan Nieuwenhuizen <janneke@gnu.org>:
>     +(defcustom compilation-guile-get-load-path-command "guile -c '(write %load-path)'"

In such cases it's good practice to have a variable called
`compilation-guile-program' (set to "guile" by default), so
that the user can change it in case his "guile" is not in path or is
called something else.

 Emilio



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] Support Guile backtraces in compilation mode.
  2014-08-08 13:29   ` Stefan Monnier
@ 2014-08-08 17:43     ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Nieuwenhuizen @ 2014-08-08 17:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: guile-user, emacs-devel

Stefan Monnier writes:

> Quick comments:
> - You can collapse all three patches into a single one.

Done.

> - Both of those Guile regexps are much too generic (i.e. likely to
>   appear in non-Guile output), while the corresponding handler you
>   provide is clearly very Guile-specific.  This is a *serious* problem.

Yes, I see your point.  I have removed the code for to get at the
absolute file name

> - I think a good way to solve it would be to push the problem upstream
> ;-)

and will try to get that bit moved upstream. :-)

>   IOW, convince the Guile guys to follow the GNU convention.  This could
>   look somewhat like:

>    * Guile backtraces
>    
>    Backtrace:
>    /some/where/ice-9/boot-9.scm:157:
>       6 [catch #t #<catch-closure 196e3e0> ...]

Sure.  Finding ice-9/boot-9.scm etc will have to be done by the user
until this is changed in Guile.

>    /home/janneke/vc/guile/examples/gud-break.scm:1038:

but the bits in most user code should work.

>   With the above, you might not even need to change compile.el.

Yes, I'm trying another, much simpler, incarnation of this patch
for all the guile versions that are in the field right now, and
will be for many years to come.

>   Tho,
>   admittedly, the above lines might end up highlighted as "errors"
>   whereas they should probably be treated as "info", so some annotation
>   on the "FILE:LINE:" lines would be helpful to let Emacs know that it's
>   not an "error" location, but just an "info".  Not sure if the GNU
>   conventions already include such an annotation, but I can't see why
>   that couldn't be arranged.

That would be nice too.  We'll see where this goes.

Thanks!  Greetings, Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-08-08 17:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-08 11:05 compilation-mode support for Guile backtrace Jan Nieuwenhuizen
2014-08-08 11:05 ` [PATCH 1/3] Support Guile backtraces in compilation mode Jan Nieuwenhuizen
2014-08-08 13:29   ` Stefan Monnier
2014-08-08 17:43     ` Jan Nieuwenhuizen
2014-08-08 13:47   ` Eli Zaretskii
2014-08-08 13:53     ` Jan Nieuwenhuizen
2014-08-08 13:57       ` Eli Zaretskii
2014-08-08 14:34       ` Emilio Lopes
2014-08-08 11:05 ` [PATCH 2/3] Add Guile backtrace example Jan Nieuwenhuizen
2014-08-08 11:05 ` [PATCH 3/3] Add tests for Guile compile regexps Jan Nieuwenhuizen
2014-08-08 13:33 ` compilation-mode support for Guile backtrace Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.