comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon.j.wright@mac.com>
Subject: Re: simple programs -> one file with gps 2008 (gpl)?
Date: Tue, 12 Aug 2008 18:03:56 +0100
Date: 2008-08-12T18:03:56+01:00	[thread overview]
Message-ID: <m21w0up3lv.fsf@mac.com> (raw)
In-Reply-To: 31e658e8-f85a-47dc-9d6d-688935dd9e4f@z66g2000hsc.googlegroups.com

amado.alves@gmail.com writes:

>> > file) Eventually you use this tool to start development from an Ada
>> > text. But normally you only do this once at the start of development,
>> > because compiler messages will point to the 'new' files, so it's more
>> > convenient to edit them instead of the old,...
>>
>> The -r switch to gnatchop causes error messages to refer to the original
>> pre-chopped file.
>
> Indeed! I stand corrected. This is wonderful. You can work based
> on .ada files :-)
> Thanks for pointing this out.

If you are an Emacs user, I have written a minor mode (gnatchop-mode) so
that every time you save the big source file gnatchop (-r) is run on it.

Um, I guess I should offer it to ada-mode -- tried that when AdaCore
were running it, it wasn't general enough for them (but works for me!)

;; gnatchop.el
;; Copyright (C) 2001 Simon Wright <simon@pushface.org>.
;; $Id: gnatchop.el,v 1.1 2001/12/01 06:58:43 simon Exp $

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; Minor mode for use in Ada buffers that don't have the correct file name
;; for use with GNAT, and which therefore need to be "gnatchop"'d before
;; compilation.

;; Reference: Writing GNU Emacs Extensions by Bob Glickstein (O'Reilly
;; & Associates, Inc, 1997).

(defvar gnatchop-mode nil
  "Mode variable for gnatchop minor mode.")

(defun gnatchop-mode (&optional arg)
  "Gnatchop minor mode."
  (interactive "P")
  (make-variable-buffer-local 'gnatchop-mode)
  (make-local-hook 'after-save-hook)
  (setq gnatchop-mode
	(if (null arg)
	    (not gnatchop-mode)
	  (> (prefix-numeric-value arg) 0)))
  (if gnatchop-mode
      (add-hook 'after-save-hook 'gnatchop-file)
    (remove-hook 'after-save-hook 'gnatchop-file))
)

(defun gnatchop-file ()
  "Run gnatchop on current buffer's file after save."
  (if gnatchop-mode
      (progn
	(message (concat "chopping " (buffer-file-name)))
	(let (compilation-read-command
	      (compilation-buffer-name-function
	       (lambda (mode) "*Gnatchop*")))
	  (compile (concat "gnatchop -w -r " (buffer-file-name)))
	  (bury-buffer (get-buffer "*Gnatchop*")))))
)

(if (not (assq 'gnatchop-mode minor-mode-alist))
    (setq minor-mode-alist
	  (cons '(gnatchop-mode " Chop")
		minor-mode-alist)))



  reply	other threads:[~2008-08-12 17:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-08 19:12 simple programs -> one file with gps 2008 (gpl)? Marcus Lauster
2008-08-08 20:25 ` Jeffrey R. Carter
2008-08-08 20:54   ` [Solved] " Marcus Lauster
2008-08-08 21:29   ` Ed Falis
2008-08-11  8:44   ` Lucretia
2008-08-08 22:44 ` amado.alves
2008-08-10 22:25   ` Robert A Duff
2008-08-12 10:21     ` amado.alves
2008-08-12 17:03       ` Simon Wright [this message]
2008-08-13 12:45         ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox