eval-when-compile not being honored? - emacs

I'm attempting to install ace-jump-mode for emacs 24.1.50.1.
I've installed it with M-x package-install, and calling M-x ace-jump-mode activates it and prompts for a letter, but upon entering a letter, I get the error:
Symbol's function definition is void: every
Running emacs -q (and then running (add-to-list 'load-path "~/.emacs.d/elpa") like I have in my .emacs file) allows me to load ace-jump-mode and it functions without an issue. Assuming thus that the error exists in my .emacs, I commented out everything in my .emacs, and reopened emacs regularly, but still get the error.
From some searching around, I think the issue is the code in ace-jump-mode.el
(eval-when-compile
(require 'cl))
is not working correctly when I don't use emacs -q. When I M-x load-library cl, everything works fine.
I imagine that since I can't find any references to this online, its not a common bug, so it must be an issue with my config. I know I could just load cl in my .emacs, but I don't see the need to load the entire package just for one function.
Does anyone know how to fix this? Or, how to load only one function from cl?
Thanks.

Emacs is self documenting, C-h f every will show you that this
function is defined in cl-extra not cl, but loading cl autoloads it, so
it does become available.
Some things with how cl is loaded may have changed with Emacs 24, which
broke this library, I'm not certain. Like you found out, the easiest fix is
to just
(require 'cl)
in your init file. This isn't as a big deal as you make it out. A lot of
libraries you might use will do this anyway, so it's likely you're just
changing the order things get loaded.
The alternative is to just submit a patch to the author of ace-jump-mode
that avoids using every, which is more inconvenient.
Finally, if you ever got ace-jump-mode to work it was because you loaded the
uncompiled ".el" file instead of the compiled ".elc" file, which would have
run (require 'cl), meaning that both cl and cl-seq will have been loaded
somewhere along the way. So there is no magic that can make this work
without loading those files.

(eval-when-compile <foo>) means that <foo> is only executed when compiling the file (or when running it uncompiled). So if you compile your file, the resulting file won't load cl, which is a problem since every is only defined when cl is loaded. (eval-when-compile <foo>) is used to load macros (such as ignore-errors), since these are only needed during compilation, but every is not a macro, hence your problem.

Related

emacs font setting does not load at start

I put my font setting at a separate font_settings.el file and load it with:
(load-library "font_settings")
at the end of init.el.
But every time I start Emacs, emacs seems not load the settings.
I have to eval-buffer to evaluate init.el to let it work.
So it seems the settings are OK but loading sequence or the way I load it is not right...
Any thoughts?
The code of font_settings.el is here (too long):
http://pastebin.com/ExpY1mTy
Is font_settings.el in your load-path? If not, put it there or add the directory that contains it:
(add-to-list 'load-path "/the/full/directory/name/my-directory/")
See the Emacs manual, node Lisp Libraries.
You can check whether the library was actually loaded by using C-h v load-history. (Alternatively, you can check whether something that the library defines actually gets defined.)

org mode with clojure - can't get export to work

EDIT I've also asked this question on emacs.stackexchange
I'm a relative emacs newbie and have set up my emacs (24.4.1) to work with clojure as described here.
The gist of it is that I am now using the latest org-mode from git and loading it in my init.el (I am using prelude btw) as below:
(add-to-list 'load-path "~/repos/org-mode/lisp")
(require 'org)
(require 'ob-clojure)
I am trying to use org to write a literate clojure program that I can export to markdown. Clojure and babel now work well, evaluation works etc, but when I try to export my org file I get an error.
load-with-code-conversion: Symbol's value as variable is void: p
The stack trace when I set toggle-debug-on-error is:
Debugger entered--Lisp error: (void-variable p)
eval-buffer(#<buffer *load*> nil
"/Users/krisfoster/repos/org-mode/lisp/ox.el" nil t)
; Reading at buffer position 229233
load-with-code-conversion("/Users/krisfoster/repos/org-mode/lisp/ox.el"
"/Users/krisfoster/repos/org-mode/lisp/ox.el" nil t)
autoload-do-load((autoload "ox" "Export dispatcher for Org mode.\n
\nIt provides an access to common export related tasks in a
buffer.\nIts interface comes in two flavors: standard and
expert.\n\nWhile both share the same set of bindings, only the
former\ndisplays the valid keys associations in a dedicated
buffer.\nScrolling (resp. line-wise motion) in this buffer is done
with\nSPC and DEL (resp. C-n and C-p) keys.\n\nSet variable `org-
export-dispatch-use-expert-ui' to switch to one\nflavor or the
other.\n\nWhen ARG is \\[universal-argument], repeat the last
export action, with the same set\nof options used back then, on
the current buffer.\n\nWhen ARG is \\[universal-argument] \\
[universal-argument], display the asynchronous export
stack.\n\n(fn &optional ARG)" t nil) org-export-dispatch)
command-execute(org-export-dispatch)
I tried to resolve this by (require-ing the various org export packages, the ones in the clone of the org git repo that is, from within my init.el. But no dice - in fact that generated yet more issues. I have tried debugging but can't figure out what is wrong. I am suspecting I need to be requiring something but don't know what.
I have my init.el here - init.el gist
Any-one have any ideas what I am doing wrong?
Thanks in advance.
There was a bug in org-mode around the time you made this post, so the problem may be resolved. However, I noticed a few issues with your init file. Some things which might help
Use the lisp package manager to install your packages (ELPA). This will make your life much easier. The org guys maintain an ELPA repository which is updated regularly and will likely be a little more stable than just pulling in the repo. They have a version called org-plus-contrib which I use and find quite good. Just add
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
You state that your running prelude, but I can't see anything in your init which is loading prelude (only a call to a function which turns off the guru-mode). Prelude is pretty good and quite popular, but if your going to use it, you need to 'drink the cool aid' that is, do things in the prelude way. For example, prelude comes with org-mode and uses ELPA to install it. You need to be careful your not get a blend of org versions. Another alternative to prelude which I found very good is Steve Purcell's emacs.d. I found it a little easier to work with YMMV, but it may be worth checking out as it has good support for the mac. See emacs.d
It is a really good idea to break up your emacs init script into separate files. This makes it easy to comment out lots of stuff when your trying to track down a problem and allows you to just focus on the key bits your trying to get working. I maintain my init.el file as an org file and use babel to generate all the lisp code. You can have a look at it on github. I originally started with Purcell's emacs.d and then borrowed with pride (stole) much of it to go into my own config. It isn't a fine example of how to configure emacs, but might help with your setup
I notice your attempting to use cider as the backend 'evaluator' for clojure code. Note that you only need to do this if you want to have blocks of clojure in your org file which you want to evaluate and then use the result. You don't need to do this if all you want to do is generate *.clj files from your org code. Instead, you just want to 'tangle' your org file, which will generate the updated clj source files, which you can then work on. This keeps things a lot simpler and avoids problems arising when you try to do things with your org file that attempt to evaluate the clojure code and fail. Note also that I expect you would need to do a bit more than just set cider as the backend evaluator - cide is just an interface to a repl. You would need a repl as well.

org-mode broken dynamic clock: Symbol's function definition is void: org-defvaralias

For months I've been enjoying use of the org dynamic clock block (C-c C-x C-r) to help with my hour clocking. Suddenly I find it's not working, though. The only things I've changed is downloading the list-packages org-contrib and org-mode.
M-x org-version
Org-mode version 7.8.11
Attempt to update/add dynamic block (C-c C-x C-r)
Symbol's function definition is void: org-defvaralias
I tried to do manual execution of defuns in some of the org .el files, but that just made things worse. Any suggestions on the cleanest way to fix this?
I actually can't even clock-in anymore, with the same error.
I have verified that this is a result of the org-contrib install from ELPA, which seems to break it. This is sad, since I was putting good use to other org-contrib files.
I finally got around to fixing this. The key resource was http://orgmode.org/manual/Installation.html, and the solution boils down to two things I was doing wrong when I tried to install through the list-packages:
Remember to start have emacs running without having opened ANY org files or org-config settings. Best way to do this is M-xkill-emacs and start again with emacs -q.
Add to the top of your .emacs file:
;; Configure before loading org mode (package-initialize)
(package-initialize)
I've written a little more about it here.
I don't know if that helps, but you could try:
M-x load-library RET org-compat RET.
Even if it works, this is not the solution, simply an ugly workaround.
Try asking your question on the orgmode mailing list, it gets more audience there.

Emacs desktop-save-mode startup error

After adding the following code in my .emacs file, comes up some error during startup of emacs. I am a newbie of emacs, is there some one can help me figure out where are the errors come from?
Added code in .emacs:
;; Auto-saving the Desktop
(require 'desktop)
(desktop-save-mode 1)
(defun my-desktop-save ()
(interactive)
;; Don't call desktop-save-in-desktop-dir, as it prints a message.
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'my-desktop-save)
Errors:
Looking at the function definition for what's breaking, it seems that the error is that prj-file is NIL in line 492. (The other expand-filename call in the function shouldn't ever have a nil, since it's the car of a non-nil list of filenames).
Now, prj-file is the first filename in /home/shenyan/Test/memcached-1.4.11 matching the regexp "\\(Root\\)?ProjStep.ede" and presumably there isn't one. Since memcached presumably doesn't have an EDE project file, what's gone wrong must be that line 508's call to ede-project-p did something weird when called with this subdirectory of /home/shenyan/Test/.
I can't work out exactly why that happened, but you can debug things quite easily. First bring up your *scratch* buffer to type emacs lisp easily. To check my guess, insert the following code into the buffer
(ede-directory-project-p "/home/shenyan/Test/memcached-1.4.11")
and run it by hitting C-x C-e with cursor on the closing bracket. If it returns nil I was wrong. Otherwise, you've found the culprit and should probably debug it further by hunting through the bits of ede-directory-project-p in ede-files.el.
Probably what's going on is that your /home/shenyan/Test/ directory has something that tells EDE to search subdirectories (or maybe that's the default?) and then the memcached subdirectory has a file whose name makes EDE think it should be searched for a project file. If you work out exactly what happened, you might consider submitting a bug to the EDE developers: they probably shouldn't error out if the project file doesn't exist.

Emacs: How do I reverse `load-path`?

The question arises with connection to the problem of adding child dirs to the load-path. Here's a solution. Unfortunately - it seems to revert the load-path. I tried to fix it myself, but can't do and need help.
So my question is: how do I revert a load-path.
I tried (setq load-path (reverse load-path)) but it fails - which suggests that load-path is not a list...
Edit:
Reversing load path works, indeed - I don't know what I did wrong when I tried it before posting.
I'm facing a very strange problem simple.el shadows sunrise-commander.el - while it supposed to load before that. I thought - the problem is in the order in which I have dirs in a load path - but now - when I reversed the load-path - progmodes dir is before the sunrise one - the problem is still around. I'm puzzled.
I'll reformulate my question then: how do I make sure that a given extension is loading after the core Emacs's code?
Edit 2:
In case shadow doesn't mean, what I think - my actual problem is that many sunrise-commander and icicles keys are binded to core emacs functions. For example when I use icicles M-p is binded to
M-p runs the command recenter-top-bottom, which is an interactive
compiled Lisp function in `window.el'.
While it should be previous-history-element. Similarly, when I use sunrise-commander M-u is binded to
M-u runs the command subword-backward, which is an interactive
compiled Lisp function in `subword.el'.
while it realy should be sr-history-next.
Edit 3:
Oh I solved it! In the old days I used to install emacs things system-wide, thru synaptic package manager. Then I came with a resolution - that this way it is impossible to have my customizations with me. And after that I maintain a local emacs and emacs packages. So all I has to do is to remove all the system-wide emacs stuff.
** Edit 4**:
Nope it is not that. It way ErgoEmacs keybindings extension. After I commented it out I have M-n and M-p working fine in icicles. Though RET in Sunrise commander still calls dired function - not the sunrise one. Hopefully will solve it later.
Extensions are loaded by either require or load. The load-path simply specifies a list of folders in which require will search. Imagine you have the .emacs.d/vendor dir full of Emacs extensions and it's added to your load-path (the order of entries in the load path doesn't matter unless the same extension is in several of the folders there - something known as load-path shadowing, that can be examined with M-x list-load-path-shadows). You can do one of two things at this point:
(require 'extension)
;; or
(load "~/emacs.d/vendor/extension.el)
require has the added benefit, that it wouldn't load a library twice. So, to answer you question - to make sure that an extensions is loaded after the core (very few things are loaded automatically by Emacs) it just has to be required or loaded after the stuff you want it loaded after.
After you second edit I think you should take a look at this great article on keybindings in Emacs.
Not sure if it matters, but regarding "how do I load something before simple.el": you can't because simple.el is preloaded in the `emacs' executable, so it's loaded long before the .emacs is loaded.