[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Emacs+ALLPROSE workaround for #line problem

From: Ralf Hemmecke
Subject: [Axiom-developer] Emacs+ALLPROSE workaround for #line problem
Date: Wed, 21 Mar 2007 22:23:33 +0100
User-agent: Thunderbird 2.0b2 (X11/20070116)

Versions of the Aldor compiler up to 1.0.3 (I have not actually checked 1.1.0rc1) cannot properly deal with #line directives.

ALLPROSE is a framework to produce Aldor libraries. Instead of .as files, the sources are noweb files (extension .as.nw). The .as files are actually generated and fed to the compiler. If an error is encountered the filename and line number point to the .as file. That is however *not* the actual source.

If compiling inside Emacs, the 'next-error' command jumps to the .as file and up to now one had to read the ALLPROSE-generated directives like

--#line 240 "sitools/"

to figure out manually where the error in the actual source file is.

With the help and code of Cliff Yap and Jay Belanger, I could now put together some lines that one has to put into the .xemacs/init.el file.
Now M-F12 jumps correctly into the .as.nw file.

Thank you Cliff and thank you Jay.


PS: Since the .as file is still loaded by next-error, does someone know how I can get rid of those buffers in allprose-workaround-aldor-next-error ?

;--Workaround for the Aldor compiler bug of being unable to deal
;-- properly with #line directives
(defvar pamphlet-line-id "--#line ")
(defun find-previous-pamphlet-id-line ()
  (re-search-backward pamphlet-line-id nil t))
;;ALLPROSE spits out lines like
;;--#line 211 "poly/"
(defun allprose-previous-input ()
  "Move to the previous input line."
  (let ((orig (point))
        (pt (find-previous-pamphlet-id-line)))
    (if (not pt)
        (message "No id line found.")
      (let ((n (count-lines pt orig))
        (re-search-forward " +")
        (setq lineno (current-word))
        (re-search-forward " +\"")
        (setq filename (thing-at-point 'filename))
        (find-file filename)
        (goto-line (+ n (string-to-number lineno) -1))))))

(defun allprose-workaround-aldor-next-error ()
  "Move point to the next error position in the corresponding .as.nw file."

(global-set-key [(meta f12)] 'allprose-workaround-aldor-next-error)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]