Running my own code when during Emacs startup - emacs

Let's say I have my own elisp code in ~/bin/hello.el.
The ~/.emacs file has the following code to run hello.el at startup.
(add-to-list 'load-path "~/bin/elisp")
(require 'hello)
But, I get the following error message.
Warning (initialization): An error occurred while loading `/Users/smcho/.emacs':
error: Required feature `hello' was not provided
What's wrong with this?

Does hello.el provide hello? It should start with (provide 'hello). See the elisp manual. Does (load "hello.el") work?

You have to put something like that in your LISP code:
(provide 'hello)

If you added ~/bin/elisp to your load-path, then Emacs won't find a file in ~/bin. In this case, Emacs would try to load ~/bin/elisp/hello.el, and if it can't find that, then it will look for a file named hello.elc or hello.el (in that order) in the other parts of your load-path.
Also, as others have mentioned, hello.el needs to have a (provide 'hello) in it (typically at the end).

Related

how to open ede projects after closing emacs

I've tried to find an answer to this specific question but had no luck. Or maybe I'm simply asking the wrong question.
To keep it simple: I follow the emacs' EDE Quick Start guide. Everything flows just fine and I get the expected results.
The problem arises when i close emacs and try to open the project again.
At that point I get the infamous "Corrupt object on disk" error.
I see it can be used another kind of project (ede-cpp-root-project) but it lacks all basic functionalities that should be hand-made, but that's not what I'm interested in. I would like to use ede-proj-project.
I'm interested in understanding why this happens. Why I can't open a project that worked just fine before closing emacs? What's changed just by closing emacs?
Am I missing something?
FYI: If it is useful information, I'm using emacs version 25.3.1 but I've tried few other earlier versions with the same result.
PS: As you can probably tell, I'm not really skilled so, please, forgive me if it is an annoying question.
I had the same problem.
Copy this into your .emacs startup configuration file
(require 'cedet)
(require 'eieio)
(require 'eieio-speedbar)
(require 'eieio-opt)
(require 'eieio-base)
(require 'ede/source)
(require 'ede/base)
(require 'ede/auto)
(require 'ede/proj)
(require 'ede/proj-archive)
(require 'ede/proj-aux)
(require 'ede/proj-comp)
(require 'ede/proj-elisp)
(require 'ede/proj-info)
(require 'ede/proj-misc)
(require 'ede/proj-obj)
(require 'ede/proj-prog)
(require 'ede/proj-scheme)
(require 'ede/proj-shared)
I found the solution here:
https://emacs.stackexchange.com/questions/17950/ede-load-project
which lead to CEDE project:
https://www.emacswiki.org/emacs/CEDET_Quickstart
It worked for me. - GNU Emacs 25.2.2

emacs can't find its things in its own load path

the following is output from a terminal session demonstrating that I, hopefully actually set this up right.
~ $cat .emacs
(require 'package)
(custom-set-variables
;;lots of comments generated by computer
'(package-archives (quote(("gnu" . "http://elpa.gnu.org/packages")
("marmalade" . "http://marmalade-repo.org/packages")
("melpa" . "http://melpa.milkbox.net/packages/")
("org" . "http://orgmode.org/elpa")))))
(custom-set-faces
;;again lots of comments added by the computer
)
(add-to-list 'load-path "/usr/share/emacs/24.3/site-lisp/mu4e")
~ $ ls /usr/share/emacs/24.3/site-lisp/mu43
#there are a lot of files here, but I am only going to show 2 right now
mu4e.elc
mu4e.el
... and yet emacs M-x mu4e returns [no match]. I have checked to load-path variable, and it is there. What am I doing wrong?
You need to add one more thing so that mu4e is loaded. There are two different ways to do this.
First, you could add (require 'mu4e) after you've added the path to your load-path. This will immediately load mu4e.
Alternatively, you could add the following:
(autoload 'mu4e "mu4e" "Launch mu4e and show the main window" t)
This will tell Emacs to load it lazily (i.e. not until you actually use it). Autoloading is documented here. (This is essentially done for you for packages installed via package.el - it's the same mechanism, you just don't need to specify it yourself).
The benefit of autoloads is that Emacs's initial startup is faster, since rather than loading every package right away it waits until you use them.

Loading packages installed through 'package.el' in Emacs24 [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Emacs 24 Package System Initialization Problems
I am using Emacs 24. I have the ELPA and Marmalade repos added. Using 'package' I installed 'auto-complete'. I have the following lines added to my init.el:
(require 'auto-complete-config)
(ac-config-default)
When I start Emacs, I get the error
File error: Cannot open load file, auto-complete-config
But then I use
M-x load-file
and load the same ~/.emacs.d/init.el file, it then works fine with the prompt saying
Loading /home/user/.emacs.d/init.el (source)...done
How is the usual loading different from the 'M-x load-file' command? In the start of the init.el file I do the following, is this somehow effecting the package from loading.
(add-to-list 'load-path "~/.emacs.d")
(load "custom_code")
As mentioned in the comment below: The answer by phils to the duplicate question is probably more helpful than this one
This almost certainly means that your init.el file is getting run before the code that sorts out the packages for package.el. The latter code adds the directory with the auto-complete library to your load path.
I'm still using ELPA, rather than package.el. With elpa, there's a snippet that looks like this that gets installed at the bottom of your .emacs.
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
As the comment suggests, you probably want to put your equivalent package.el initialization code before the stuff that loads init.el.
Finally: I notice you mention adding .emacs.d to your load-path. The Emacs load path is not recursive, so that probably won't do what you need (assuming that your libraries live in subdirectories). Years ago, I wrote this snippet to load up various libraries of elisp code that I'd written. You might find it useful. (Obviously, it'll only work on unixy systems with a shell and a find command. It's reasonably slow, but this seems to be shell-command-to-string, which takes several milliseconds even running "echo hello" or the like)
(defun find-elisp-dirs (dir)
"Find all directories below DIR containing elisp sources, ignoring those"
(split-string
(shell-command-to-string
(format "find %s -iname '*.el' -printf '%%h\\n' | sort -u"
(expand-file-name dir t)))))

Wrong number of arguments: called-interactively-p, 1

~/.emacs
;; http://cx4a.org/software/auto-complete/manual.html
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
when I load emacs, it complains the error as "Wrong number of arguments: called-interactively-p, 1". In other words, emacs finds error until the line (ac-config-default).
when I check the file .emacs.d/auto-complete.elc, I found the string "called-interactively-p".
Question> I have used the same setting for ubuntu without problems. Now I am switching centos 6.2. Is there a way that I fix this problem?
emacs --debug-init shows the following errors:
͂
It is worth mentioning that this error may arise if you move your emacs.d directory from one machine to another.
If this is the case, removing the compiled *.elc files should do the trick.
In recent Emacsen, called-interactively-p requires an argument.
Do C-h f ac-quick-help RET, then replace (called-interactively-p) by (called-interactively-p 'any) and recompile/reload. Or send this bug to the package's author.
[ As I mentioned recently in some other stackoverflow question, it is strongly recommended to not put "~/.emacs.d" in your load-path since the ~/.emacs.d directory can/will hold configuration files whose name clashes with real emacs packages. I.e. put the auto-complete files in a *sub*directory of ~/.emacs.d. ]
Your error looks very strange: while called-interactively-p is declared in Emacs-23 as taking exactly 1 argument, it actually accepts 0 arguments as well (to ease up the pain for external packages that want to support both Emacs-22 and Emacs-23).
So seems to be something else in your config which somehow redefines called-interactively-p.

Emacs Rinari won't load at startup

Hey, I wanted to try out some rails. And since I don't want to use any fancy IDE. I thought I could try rails out using emacs with Rinari. Anyway I got some problem which I couldn't find any solution on google for it.
Basically I have a clean .emacs and I added the necessary lines for it
;; Interactively Do Things (highly recommended, but not strictly required)
(require 'ido)
(ido-mode t)
;; Rinari
(add-to-list 'load-path "~/home/stardust/rinari")
(require 'rinari)
The only thing that's change is the location for where I extracted Rinari. When I try to open emacs with these changes I get this error. Anyone who might know what the problem is?
Warning (initialization): An error occurred while loading `/home/stardust/.emacs':
File error: Cannot open load file, rinari
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
I suspect the ~ in front of the path to Rinari is superfluous and should be removed.