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

Autoload fish without having to (require) it #4

Closed
mcandre opened this Issue Aug 8, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@mcandre

mcandre commented Aug 8, 2014

It's possible to defer loading fish-mode.el until a fish script is opened, for .fish extensions, and maybe even shebangs as well. For reference code, see:

https://github.com/mcandre/vimrc-mode/blob/master/vimrc-mode.el#L1225-L1227

Related to #3 (comment).

@wwwjfy

This comment has been minimized.

Owner

wwwjfy commented Aug 8, 2014

Thanks for advice.
I read the documentation and tried. It seems I still need to manually add it to auto-mode-alist in emacs configurations.
So I'm confused about the autoload. What's it used for, while I have to execute it in init.el anyway? Is it to save the time to execute when (require 'fish-mode), and execute when add-to-list?

I can understand the autoload for define-derived-mode, but not adding to auto-mode-alist.

I'm new to elisp, thanks for your help. :)

@mcandre

This comment has been minimized.

mcandre commented Aug 8, 2014

No problem, I'm new to elisp as well!

;;;###autoload ... is a special elisp comment that Emacs uses to register major modes with file extensions at the time the package is installed. That way, users don't have to do anything to setup the mode for their files. They no longer need (require '...mode) in their .emacs configuration, nor do they have to type M-x ...mode to enter ruby-mode for .rb files, for example.

Built-in modes like ruby-mode tend to use ;;;###autoload ..., as well as popular third-party modes like stylus-mode and vimrc-mode.

;;;###autoload ... can register both .fish file extensions and #!.*( |\/fish\\' shebangs. See this ergoemacs tutorial for reference.

http://ergoemacs.org/emacs/emacs_auto-activate_a_major-mode.html

Would you mind giving this another try?

I'd also recommend asking #emacs on Freenode for help, they're a great resource for troubleshooting Emacs / Elisp issues.

@wwwjfy wwwjfy closed this in 60e9bd7 Aug 9, 2014

@wwwjfy

This comment has been minimized.

Owner

wwwjfy commented Aug 9, 2014

Thanks!
I'm learning how autoload works. Please check if this commit works.

@mcandre

This comment has been minimized.

mcandre commented Aug 9, 2014

Works perfectly! Thanks for putting in the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment