Skip to content
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

Don't spuriously modify tags-table-list's global value #978

Merged
merged 1 commit into from
Nov 2, 2015

Conversation

purcell
Copy link
Member

@purcell purcell commented Nov 2, 2015

As part of #592, commit 2b4e49c modified this code to alter the global
value of tags-table-list as a side-effect, but this change was incorrect
and causes problems elsewhere.

Specifically, consider the following scenario:

  • User tries to jump to a definition with haskell-mode-jump-to-def-or-tag
  • That function falls back to haskell-mode-tag-find, which then calls
    haskell-mode-jump-to-tag

This results in a call to haskell-process-generate-tags, which tries to
run hasktags, whether or not it is installed. As a side effect, the
global value of tags-table-list is set to include
"/project/root/dir/TAGS", which was probably not even created
properly (most people won't have hasktags installed).

Then, imagine we're working in an unrelated project, and use Emacs'
built-in completion-at-point functionality (or company-mode, which wraps
it). Now, the tags-completion-at-point-function (enabled by default)
sees and uses the modified value of tags-table-list, and errors noisily
when called because that file does not exist. And even if it didn't
error, the tags would not be relevant to the current project.

In other words, this code either breaks or disrupts completion
everywhere beyond the current haskell project.

So, the correct solution here is to leave tags-table-list unchanged:
users such as the author of 2b4e49c should instead use directory-local
variables to set tags-table-list or tags-file-name locally to their
haskell project.

As part of haskell#592, commit 2b4e49c modified this code to alter the global
value of tags-table-list as a side-effect, but this change was incorrect
and causes problems elsewhere.

Specifically, consider the following scenario:

- User tries to jump to a definition with haskell-mode-jump-to-def-or-tag
- That function falls back to haskell-mode-tag-find, which then calls
  haskell-mode-jump-to-tag

This results in a call to haskell-process-generate-tags, which tries to
run hasktags, whether or not it is installed. As a side effect, the
global value of tags-table-list is set to include
"/project/root/dir/TAGS", which was probably not even created
properly (most people won't have hasktags installed).

Then, imagine we're working in an unrelated project, and use Emacs'
built-in completion-at-point functionality (or company-mode, which wraps
it). Now, the tags-completion-at-point-function (enabled by default)
sees and uses the modified value of tags-table-list, and errors noisily
when called because that file does not exist. And even if it didn't
error, the tags would not be relevant to the current project.

In other words, this code either breaks or disrupts completion
everywhere beyond the current haskell project.

So, the correct solution here is to leave tags-table-list unchanged:
users such as the author of 2b4e49c should instead use directory-local
variables to set tags-table-list or tags-file-name locally to their
haskell project.
gracjan added a commit that referenced this pull request Nov 2, 2015
Don't spuriously modify tags-table-list's global value
@gracjan gracjan merged commit bb95ef5 into haskell:master Nov 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants