Questions tagged [require]

50 questions
33
votes
3 answers

When should I use autoload instead of require?

From what I understand require is used to load large chunks of code (something like modules) although it can also load individual functions. Autoload on the other side, only registers functions and defers the loading to execution time. I've recently…
caisah
  • 4,056
  • 1
  • 23
  • 43
26
votes
1 answer

What does (require 'package) mean for emacs and how does it differ from load-file?

I just began using emacs a few days ago and I read somewhere that (require 'package-name) is not needed when the said package is installed using package-install. But why, what does (require 'package-name) actually do and how does it differ from…
Chakravarthy Raghunandan
  • 3,132
  • 2
  • 18
  • 42
8
votes
1 answer

require vs. package-initialize?

Ok, this is a noob question but I've digging into this enough that I think it's reasonable to ask :) My question: In one's .emacs / init.el file, can one use require to load packages that were installed via the emacs package manager? If so,…
MikeTheTall
  • 659
  • 4
  • 11
8
votes
1 answer

Require a file in the current directory without setting load-path

I have test code that wants to require some utility code in the same directory. I would prefer to not update the load-path, as most of the time, I do not want me or any other user who has checked out this code to be looking in this directory. It…
Troy Daniels
  • 487
  • 2
  • 13
5
votes
2 answers

Prevent byte-compiler warnings after requiring features

In Elisp packages, we sometimes want to use a feature only if the user has installed another package without specifying that package as a dependency for our own. E.g. (when (require 'markdown-mode nil 'noerror) (markdown-mode)) This, however,…
Tianxiang Xiong
  • 3,848
  • 16
  • 27
4
votes
1 answer

Should I use "require" or "load" when writing my own configuration?

I am following this tutorial, and the author is doing something like this: ~/.emacs.d/init.el ;; add your modules path (add-to-list 'load-path "~/.emacs.d/custom/") ;; load your modules (require 'setup-foo) (require…
nalzok
  • 665
  • 6
  • 18
4
votes
1 answer

Soft-require a feature, then conditionally run more commands

What's the idiomatic Emacs way to soft-require a feature, then use that feature if it's available? The require function allows “soft require” by specifying a non-nil third argument: (require 'projectile nil 'missing-okay) What's the best way to…
bignose
  • 627
  • 3
  • 15
4
votes
2 answers

Deep eager macroexpansion

This works: (require 'clojure-mode) (when (member 'clojure-mode my-packages) (define-clojure-indent (-> 1) (->> 1))) This gives the error Wrong type argument: listp, 1: (when (member 'clojure-mode my-packages) (require 'clojure-mode) …
Resigned June 2023
  • 1,502
  • 15
  • 20
4
votes
1 answer

How to Find Out Where a File is Being Required?

Using benchmark-init, I see that helm files (helm-elisp, helm-mode, helm, etc.) are being required, but I don't have "(require 'helm)" or "(require 'helm-config)" or "(helm-mode 1)" anywhere in my init file. I'm using use-package, and all…
noctuid
  • 429
  • 3
  • 11
2
votes
1 answer

Function load raises error on loading an existing file

I started getting an error on loading theme files and tracked it down to the (load) function being called by (load-theme). I tried to isolate the problem with the following test function and am still puzzled: (defun test-load () (let ((file…
Daniel Doherty
  • 418
  • 4
  • 12
2
votes
1 answer

Undefined-function error about function called by my function

I have recently moved to emacs as my mail client. I am using message-mode to write and send email through notmuch. Specifically, the major mode is called Message[Notmuch]. I would like to remap C-c C-c (mail-send-and-exit) and C-c C-s (mail-send) to…
johngarg
  • 21
  • 2
2
votes
1 answer

For convenience, how should I load a package whenever a specific other package loads?

I have a package that enhances the functionality of another package. To save the user the effort of any additional configurating, I would like my package to load automatically if the larger package loads. (In my example, my package is a Flycheck…
mavit
  • 211
  • 1
  • 5
2
votes
1 answer

How to tell if a emacs library is loaded?

Is there a function that will tell me for a given library foo if (require 'foo) has previously happened?
Setjmp
  • 129
  • 3
2
votes
1 answer

(error "Required feature `cl-macs' was not provided")

On Windows Emacs v24.2.1 I get error: (error "Required feature `cl-macs' was not provided") I byte-compile my .emacs and here is code: (with-no-warning (require 'cl-macs)) Actually (load "cl-macs") succeed but cl-macs.el lack (provide 'cl-macs)…
gavenkoa
  • 3,352
  • 19
  • 36
1
vote
1 answer

Encountering void-variable sh-mode-map for define-key

I am using the function tika-keymap-showhrk which takes a list of modes, then constructs the associated -map variable value for use with define-key. But I get the error Debugger entered--Lisp error: (void-variable sh-mode-map) …
Dilna
  • 1,173
  • 3
  • 10
1
2 3 4