Hello, the following patch corrects a warning that emacs emits,
wrongly, when the user does C-c C-r to find all references to a
variable.

The function ada-gnat-xref-all creates a buffer named
"gnatfind-compile" and runs a "gnat find" command in it.
This compilation command uses the emacs variable compilation-environment,
which is buffer-local.

Emacs objects to the use of let to bind values to buffer-local
variables because let does not know which binding of the variable
to change.  The danger it tries to avoid is to "let" a variable,
change current buffers and then exit from the "let".  This is not
what ada-gnat-xref-all does but that still triggers the warning.
setq does the right thing, as it knows which binding of the variable
to change.  This is explained in the Emacs Lisp manual, in quite
obscure terms IMHO.


Index: ada-mode/ada-gnat-xref.el
==================================================================
--- ada-mode/ada-gnat-xref.el
+++ ada-mode/ada-gnat-xref.el
@@ -158,15 +158,15 @@
          (project-file (when ada-prj-current-file
                          (concat "-p" ada-prj-current-file)))
(cmd (format "gnat find -a -r %s %s:%s:%d:%d %s" dirs identifier file line col project-file)))

     (with-current-buffer (gnat-run-buffer); for default-directory
-      (let ((compilation-environment (ada-prj-get 'proc_env))
-           (compilation-error "reference")
+      (let ((compilation-error "reference")
            ;; gnat find uses standard gnu format for output, so don't
            ;; need to set compilation-error-regexp-alist
            )
+        (setq compilation-environment (ada-prj-get 'proc_env))
        (when (ada-prj-get 'gpr_file)
(setq cmd (concat cmd " -P" (file-name-nondirectory (ada-prj-get 'gpr_file)))))

         (if append
             (flet ((erase-buffer nil (goto-char (point-max))))



--
Ludovic Brenta.


_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to