Skip to content

Conversation

thumphries
Copy link
Contributor

Produces correct autoloads when the source tree has been symlinked. If the source tree is a symlink, CURDIR will always be the dereferenced path, while PWD is usually what we expect. Using CURDIR can lead to some incorrect paths in haskell-mode-autoloads.el.

Context

I noticed this when trying to build a haskell-mode source tree that had been symlinked from another directory (I use GNU Stow to symlink things from a git repo):

[tim@axiom:~] % ls -alr ~/.emacs.d/haskell-mode
lrwxr-xr-x  1 tim  staff  40 21 May 23:31 /Users/tim/.emacs.d/haskell-mode -> ../src/emacs/emacs/.emacs.d/haskell-mode

During cd ~/.emacs.d/haskell-mode && make, the following are true:

CURDIR=/Users/tim/src/emacs/emacs/.emacs.d/haskell-mode
PWD=/Users/tim/.emacs.d/haskell-mode

... and this leads to broken relative paths in haskell-mode-autoloads.el:

Generating autoloads for ../../../../../.emacs.d/haskell-mode/highlight-uses-mode.el...
Generating autoloads for ../../../../../.emacs.d/haskell-mode/highlight-uses-mode.el...done
Generating autoloads for ../../../../../.emacs.d/haskell-mode/inf-haskell.el...
Generating autoloads for ../../../../../.emacs.d/haskell-mode/inf-haskell.el...done
Generating autoloads for ../../../../../.emacs.d/haskell-mode/w3m-haddock.el...
Generating autoloads for ../../../../../.emacs.d/haskell-mode/w3m-haddock.el...done

This fix should not break the build for the regular unsymlinked case. The Makefile shelled out to pwd before commit e4418c3 without incident.

@thumphries
Copy link
Contributor Author

Hmm, $PWD might be a bashism. shelling out might be the way to go.

@gracjan
Copy link
Contributor

gracjan commented May 21, 2016

The $(CURDIR) part is interpreted by make (notice single dollar).

We might get away with relative path, that is a simple $@ should do.

@thumphries
Copy link
Contributor Author

$@ is a relative path, but it seems the code expects something absolute. emacs batch mode seems to drop into /tmp somewhere, so the relative path is meaningless:

usr/local/bin/emacs --eval "(add-to-list 'load-path (expand-file-name \"tests/compat\") 'append)" --eval "(when (boundp 'load-prefer-newer) (setq load-prefer-newer t))" --batch -Q -L . \
        --eval '(setq make-backup-files nil)' \
        --eval '(setq generated-autoload-file "haskell-mode-autoloads.el")' \
        -f batch-update-autoloads "."
Opening output file: no such file or directory, /private/tmp/emacs-W76dlA/emacs-24.4/lisp/haskell-mode-autoloads.el
make: *** [haskell-mode-autoloads.el] Error 255

On my box $PWD is defined and does the right thing for symlinks in csh, ksh, bash and zsh, not sure if it's a portability problem or not.

@gracjan
Copy link
Contributor

gracjan commented May 31, 2016

So the line in question should look something like this:

--eval "(setq generated-autoload-file \"$${PWD}/$@\")"

Note changed quotes, double dollars and shell kind of variable dereference.

Can you test if something like this works for you? If so please force push new commit to this pull request. Thanks.

Produces correct autoloads when the source tree has been symlinked.
@thumphries
Copy link
Contributor Author

Still works as expected with your change. I've rebased and pushed.

Thanks for your patience, Gracjan, and thanks for maintaining haskell-mode.

@gracjan gracjan merged commit 03622cb into haskell:master Jun 1, 2016
@gracjan
Copy link
Contributor

gracjan commented Jul 12, 2016

Note: I've changed this place for Windows compatibility in #1373.

@thumphries
Copy link
Contributor Author

Thanks for the heads up. I've tested it locally and everything behaves correctly 🎉

@gracjan
Copy link
Contributor

gracjan commented Jul 16, 2016

Great! Thanks!

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