tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

provide correct feature #74

Closed tarsius closed 11 years ago

tarsius commented 11 years ago

The feature has to match the filename; otherwise (require FEATURE) won't work.

tarsius commented 11 years ago

ping

tamzinblake commented 11 years ago

Can you give an example? I haven't run into this problem.

Also, if this is true, then it would probably be better to change the filename rather than the mode name.

tarsius commented 11 years ago

From the elisp info page:

 -- Function: require feature &optional filename noerror
     This function checks whether FEATURE is present in the current
     Emacs session (using `(featurep FEATURE)'; see below).  The
     argument FEATURE must be a symbol.

     If the feature is not present, then `require' loads FILENAME with
     `load'.  If FILENAME is not supplied, then the name of the symbol
     FEATURE is used as the base file name to load.  However, in this
     case, `require' insists on finding FEATURE with an added `.el' or
     `.elc' suffix (possibly extended with a compression suffix); a
     file whose name is just FEATURE won't be used.  (The variable
     `load-suffixes' specifies the exact required Lisp suffixes.)

     If NOERROR is non-`nil', that suppresses errors from actual
     loading of the file.  In that case, `require' returns `nil' if
     loading the file fails.  Normally, `require' returns FEATURE.

     If loading the file succeeds but does not provide FEATURE,
     `require' signals an error, `Required feature FEATURE was not
     provided'.

It doesn't mention trying with suffix -mode removed or added. And it does mention that failing to provide the correct feature will cause an error. So... it is true :-)

$ echo "(provide 'foo-mode)" > somewhere/in/load-path/foo.el
M-x eval-expression RET (require 'foo-mode) RET
Debugger entered--Lisp error: (file-error "Cannot open load file" "foo-mode")
  require(foo-mode)
  eval((require (quote foo-mode)) nil)
  eval-expression((require (quote foo-mode)) nil)
  call-interactively(eval-expression t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)
M-x eval-expression RET (require 'foo) RET
Debugger entered--Lisp error: (error "Required feature `foo' was not provided")
  require(foo)
  eval((require (quote foo)) nil)
  eval-expression((require (quote foo)) nil)
  call-interactively(eval-expression t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)

If you haven't run into this problem then this is because you load the library differently; e.g. using load-file or with the help of extracted autoload definitions.

Yes, renaming the file is another option.

tarsius commented 11 years ago

Have you decided how to fix this problem yet?

tarsius commented 11 years ago

ping

tamzinblake commented 11 years ago

Does that work?