ada-mode-users
[Top][All Lists]
Advanced

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

[Ada-mode-users] [patch] Making compilation-error local to gnatfind-comp


From: Ludovic Brenta
Subject: [Ada-mode-users] [patch] Making compilation-error local to gnatfind-compe while let-bound!
Date: Thu, 29 Sep 2016 19:28:18 +0200
User-agent: Roundcube Webmail/0.5.3

[resending to the correct mailing list]

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.

--
Ludovic Brenta.



reply via email to

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