]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ada-mode/gpr-mode.el
publish ada-mode 5.1.6, wisi 1.0.6, new package ada-ref-man
[gnu-emacs-elpa] / packages / ada-mode / gpr-mode.el
old mode 100755 (executable)
new mode 100644 (file)
index 84f3cc6..1bf11c8
@@ -1,10 +1,9 @@
 ;;; gpr-mode --- major-mode for editing GNAT project files
 
-;; Copyright (C) 2004, 2007, 2008, 2012-2013  Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2007, 2008, 2012-2014  Free Software Foundation, Inc.
 
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
-;; Version: 5.0
 
 ;; This file is part of GNU Emacs.
 
 
 ;; we reuse several ada-mode functions
 (require 'ada-mode)
-
-(defun gpr-align ()
-  "If region is active, apply 'align'. If not, attempt to align
-current construct."
-  (interactive)
-  (if (use-region-p)
-      (progn
-        (align (region-beginning) (region-end))
-        (deactivate-mark))
-
-    (align-current)
-    ))
+(require 'cl-lib)
 
 (defvar gpr-mode-map
   (let ((map (make-sparse-keymap)))
@@ -57,7 +45,7 @@ current construct."
     ;; global-map has C-x ` 'next-error
     (define-key map [return]   'ada-indent-newline-indent)
     (define-key map "\C-c`"    'ada-show-secondary-error)
-    (define-key map "\C-c\C-a" 'gpr-align)
+    ;; comment-dwim is in global map on M-;
     (define-key map "\C-c\C-c" 'compile)
     (define-key map "\C-c\C-e" 'gpr-expand)
     (define-key map "\C-c\C-f" 'gpr-show-parse-error)
@@ -65,11 +53,14 @@ current construct."
             ;; FIXME (later): implement?
     ;; (define-key map "\C-c\C-n" 'ada-next-statement-keyword)
     ;; (define-key map "\C-c\C-p" 'ada-prev-statement-keyword)
-    (define-key map "\C-c\C-S-p" 'gpr-set-as-project)
+    (define-key map "\C-c\C-o"          'ff-find-other-file)
+    (define-key map "\C-c\C-P" 'gpr-set-as-project)
     (define-key map "\C-c\C-t" 'ada-case-read-all-exceptions)
     (define-key map "\C-c\C-w" 'ada-case-adjust-at-point)
     (define-key map "\C-c\C-y" 'ada-case-create-exception)
     (define-key map "\C-c\C-\M-y" (lambda () (ada-case-create-exception nil nil t)))
+    (define-key map "\M-n" 'skeleton-next-placeholder)
+    (define-key map "\M-p" 'skeleton-prev-placeholder)
     map
   )  "Local keymap used for GPR mode.")
 
@@ -87,20 +78,22 @@ current construct."
     ["------"        nil nil]
     ["Find and select project ..." ada-build-prompt-select-prj-file t]
     ["Select project ..."          ada-prj-select                   t]
-    ["Set as current project"      gpr-set-as-project               t]
+    ["Parse and select current file" gpr-set-as-project             t]
     ["Show current project"        ada-prj-show                     t]
+    ["Show project search path"    ada-prj-show-path                t]
     ["Next compilation error"      next-error                       t]
     ["Show secondary error"        ada-show-secondary-error         t]
     ["Show last parse error"       gpr-show-parse-error             t]
+    ["Other file"                  ff-find-other-file               t]
     ("Edit"
-     ["Indent Line"                 indent-for-tab-command         t]
-     ["Indent Lines in Selection"   indent-region                  t]
-     ["Indent Lines in File"        (indent-region (point-min) (point-max))  t]
-     ["Expand skeleton"             gpr-expand                     t] ;; FIXME: only if skeleton
-     ["Align"                       gpr-align                      t]
-     ["Comment Selection"           comment-region                 t]
-     ["Uncomment Selection"         (lambda () (comment-region t)) t]
-     ["Fill Comment Paragraph"      fill-paragraph                 t]
+     ["Indent Line or selection"      indent-for-tab-command         t]
+     ["Indent current statement"      gpr-indent-statement           t]
+     ["Indent Lines in File"          (indent-region (point-min) (point-max))  t]
+     ["Expand skeleton"               gpr-expand                     t]
+     ["Next skeleton placeholder"     skeleton-next-placeholder      t]
+     ["Previous skeleton placeholder" skeleton-prev-placeholder      t]
+     ["Comment/uncomment selection"   comment-dwim                   t]
+     ["Fill Comment Paragraph"        fill-paragraph                 t]
 
      ["Fill Comment Paragraph Justify" ada-fill-comment-paragraph-justify t]
      ["Fill Comment Paragraph Postfix" ada-fill-comment-paragraph-postfix t]
@@ -217,10 +210,19 @@ of the package or project point is in or just after, or nil.")
 (defun gpr-set-as-project (&optional file)
   "Set FILE (default current buffer file) as Emacs project file."
   (interactive)
+  (save-some-buffers t)
+  ;; Kill sessions to catch changed env vars
+  ;; FIXME: need dispatching kill single session
+  (cl-ecase ada-xref-tool
+    (gnat_xref nil)
+    (gnat_inspect (gnat-inspect-kill-all-sessions))
+    (gpr_query (gpr-query-kill-all-sessions))
+    )
   (ada-parse-prj-file (or file (buffer-file-name)))
   (ada-select-prj-file (or file (buffer-file-name))))
 
 ;;;;
+;;;###autoload
 (defun gpr-mode ()
   "The major mode for editing GNAT project files."
 
@@ -245,28 +247,16 @@ of the package or project point is in or just after, or nil.")
         ((?\_ . "w"))))
 
   (gpr-set-ff-special-constructs)
-  (setq ff-search-directories 'ada-project-search-path)
+  (setq ff-search-directories 'compilation-search-path);; includes project search path
 
   (set (make-local-variable 'add-log-current-defun-function)
        'gpr-add-log-current-function)
 
-  ;; used by autofill to break a comment line and continue it on
-  ;; another line. The reason we need this one is that the default
-  ;; behavior does not work correctly with the definition of
-  ;; paragraph-start above when the comment is right after a
-  ;; multi-line subprogram declaration (the comments are aligned under
-  ;; the latest parameter, not under the declaration start).
-  ;; FIXME: need test - should be in gpr-wisi?
-  (set (make-local-variable 'comment-line-break-function)
-       (lambda (&optional soft) (let ((fill-prefix nil))
-                                 (indent-new-comment-line soft))))
-
   (run-hooks 'gpr-mode-hook)
 
   )
 
-;; user needs to add this somewhere:
-;; FIXME: add autoload processing?
+;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.gpr\\'" . gpr-mode))  ; GNAT project files
 
 (provide 'gpr-mode)
@@ -274,4 +264,7 @@ of the package or project point is in or just after, or nil.")
 (unless (featurep 'gpr-indent-engine)
   (require 'gpr-wisi))
 
+(unless (featurep 'gpr-skeletons)
+  (require 'gpr-skel))
+
 ;;; end of file