-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dir-locals and ship suggested helper hooks instead. #6556
Conversation
.dir-locals led to issues with unsafe local variable warnings. With this method the user is opting in to running this code so there are no warnings.
Copy somewhere, WDYM? Emacs users that are not Emacs expert might need a bit more documentation on how to use this. Can one tweak there |
I'd be very happy for this to be merged so that I can finally The label seems wrong though, it seems this needs some additional work by @SkySkimmer to explain somewhere the exact procedure to configure emacs appropriately? I certainly wouldn't know where "somewhere" is. ;-) |
I talked to @letouzey who would be favorable to merging this as well. |
TBH I was waiting for someone to say they were interested in this approach before doing more work on it. |
Fair enough :) |
It's just a regular emacs package (although a very Coq developer specific one), you put it in the load path (or add to the load path to include it) and |
OK so for instance:
Can you put this in the comments at the top of the file? And also mention the existence of this file in the relevant section of |
The backtrace regex is very mergeable, objects.el not so much IMO. objects.el came up in #819 but I didn't remove it due to inertia. If it should be removed let's do it in another PR. |
I am very satisfied by the documentation and completely incompetent when it comes to reviewing Elisp. @JasonGross: would you do it? |
Maybe we could get comments from PG people? @Matafou @cpitclaudel I don't know who else is there. |
LGTM. Good solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I took a look.
dev/tools/coqdev.el
Outdated
(defun coqdev-setup-compile-command () | ||
"Setup `compilate-command' for Coq development." | ||
(when-let ((dir (coqdev-default-directory))) | ||
(setq-local compile-command (concat "make -C " dir)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to shell-quote-argument on dir
, in case it contains spaces.
dev/tools/coqdev.el
Outdated
|
||
(defun coqdev-setup-compile-command () | ||
"Setup `compilate-command' for Coq development." | ||
(when-let ((dir (coqdev-default-directory))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when-let
is Emacs 25+, but the default is still 24.5 on Debian and Ubuntu
dev/tools/coqdev.el
Outdated
(expand-file-name dir))) | ||
|
||
(defun coqdev-setup-compile-command () | ||
"Setup `compilate-command' for Coq development." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile-command
, I think, not compilate
dev/tools/coqdev.el
Outdated
|
||
(defun coqdev-default-directory () | ||
"Return the Coq repository containing `default-directory'." | ||
(when-let ((dir (locate-dominating-file default-directory "META.coq"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when-let
is Emacs 25+, but the default is still 24.5 on Debian and Ubuntu
dev/tools/coqdev.el
Outdated
Specifically `camldebug-command-name' and `ocamldebug-command-name'." | ||
(when-let ((dir (coqdev-default-directory))) | ||
(setq-local camldebug-command-name (concat dir "dev/ocamldebug-coq")) | ||
(setq-local ocamldebug-command-name (concat dir "dev/ocamldebug-coq")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expand-file-name
is usually better than concat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concat is shorter and we already expanded in coqdev-default-directory, is there still some use we can get out of expand-file-name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too much. I don't think expand-file-name is guaranteed to return a path ending with a "/", but in practice it likely does in most cases.
dev/tools/coqdev.el
Outdated
(when-let ((dir (coqdev-default-directory))) | ||
(setq-local camldebug-command-name (concat dir "dev/ocamldebug-coq")) | ||
(setq-local ocamldebug-command-name (concat dir "dev/ocamldebug-coq")))) | ||
(add-hook 'hack-local-variables-hook #'coqdev-setup-camldebug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that hack-local-variables-hook
is the best to use here. Maybe just tuareg-mode-hook
? Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that hack-local-variables-hook is the best to use here. Maybe just tuareg-mode-hook? Or am I missing something?
ocamldebug
reads ocamldebug-command-name
after moving to the ocamldebug buffer (creating it if it doesn't already exist). If newly created the buffer is in fundamental-mode
at that time. So setting the variable only in ocaml files won't have an effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. That sounds like an ocamldebug
bug.
In that case, since that hook will run in al buffer, it might be better to check the buffer's name before running the actual body of the function.
dev/tools/coqdev.el
Outdated
(defun coqdev-setup-tags () | ||
"Setup `tags-file-name' for Coq development." | ||
(when-let ((dir (coqdev-default-directory))) | ||
(setq-local tags-file-name (concat dir "TAGS")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: when-let
, concat
, and hack-local-variables
;; even though PG sets it with `setq' when there's a _Coqproject. | ||
;; Also makes sense generally, so might make it into PG someday. | ||
(make-variable-buffer-local 'coq-prog-args) | ||
(setq-default coq-prog-args nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a couple files ((C)Morphisms.v and some test suite files) there are file local arguments which we don't want to override, but we don't want to false positive detect the presence of file local arguments when PG set them from _CoqProject in another file (eg the files in Init/, or some 3rd party file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I understand the buffer-local part; but why do you set it to nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case PG modified it before us.
;; are recognized and can be jumped from easily in the *compilation* | ||
;; buffer. | ||
(defvar compilation-error-regexp-alist-alist) | ||
(defvar compilation-error-regexp-alist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a to require
the file that defines these variables; defvar
-ing them is not enough to be able to change them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a to require the file that defines these variables; defvar-ing them is not enough to be able to change them.
How about (with-eval-after-load 'compile ...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for (require 'compile)
, but the with-eval-after-load form works fine too.
b4bfc61
to
d5c7711
Compare
(and alist-alist)
I'm going to leave the |
;; following to your init: | ||
|
||
;; (add-to-list 'load-path "/path/to/coqdev/") | ||
;; (require 'coqdev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add the full path, I think; unless you have > 1 files, it's enough to pass the file name to `require'.
Hi, seeing emacs expert gathered in this thread, may I bounce on the discussion to ask whether someone would have a solution for making This seems a bit tricky to do since emacs has to send something like In the case of Coq however, the name of the module is the basename of the |
@SkySkimmer Do you consider this ready or do you plan to address @cpitclaudel 's comments? |
I think it's ready. |
Alternative to #1136.
People interested in those functions can copy
coqdev.el
somewhere and load it, or copy parts of it to their init. Those not interested can just ignore it.