(message "%S" load-path) and (describe-variable load-path) give different results - emacs

(message "%S" load-path) and (describe-variable 'load-path)
give different results.
Several more path like "/Users/updogliu/.emacs.d/elpa/flycheck-20140323.828" appeared in the latter.
How can I make (require 'flycheck) use the "describe" one load-path?

To setup Flycheck properly, you do not need to require Flycheck. Instead, just enable Global Flycheck Mode:
(add-hook 'after-init-hook #'global-flycheck-mode)
This will enable Flycheck for all supported languages.
To make (require 'flycheck) work in your init.el, you need to add (package-initialize) at the very beginning of your init.el.
(package-initialize) sets up Emacs' built-in package system, which includes adding all packages to the load-path. Emacs calls this automatically, but only after your init.el has been processed, hence the use of after-init-hook to enable Flycheck.
If you added a message call to your init.el without calling (package-initialize) first, you'll hence see the standard load-path without any of your packages.
To make your packages available in your init.el right away, you need to call (package-initialize) manually, at the beginning of your init.el.

Related

How to stop a package from initializing with package-initialize on emacs (slime)

I've been trying to get slime+sbcl working on my emacs (26.3) for a while. I first installed slime via melpa and that didn't work. I finally got slime able to work on a clean emacs (emacs -q) using quicklisp and the following code:
(load "~/quicklisp/slime-helper.el")
(setq inferior-lisp-program "sbcl")
However, when I put it into my actual init file and run it, it doesn't work. I figured that if I put package-enable-at-startup to nil and commented out package-initialize, that slime works. My guess is that the installed slime through melpa is "overriding" the slime initialization using slime-helper. I can't uninstall slime via melpa because of package dependencies and am worried I might mess something up. But I also need all of my packages to initialize except slime. So I was wondering if there was anyway to initialize all my packages, but suppress the slime package.
I think the easiest method would be to disable the loading of "elpa slime" with package-load-list. See its documentation with C-hv package-load-list Return. In short you'd put something like this in your init file.
(require 'package)
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/")
'("gnu" . "https://elpa.gnu.org/packages/"))
(setq package-load-list '((slime nil))) ;; don't load slime
(package-initialize)
(load (expand-file-name "~/quicklisp/slime-helper.el"))
(setq inferior-lisp-program "sbcl")
package-initialize will skip loading slime (and manipulating your load-path), allowing the "quicklisp slime" to appear first on your load-path. This may or may not break dependencies loaded by the package system. If they do break, I'd see if quicklisp can manage them and deal with them that way, or I would manually manage them.

package-install can't find icicles

I'm trying to install icicles in Emacs because I've read it makes for a more clear emacs experience. The problem is, even though I'm loading the Melpa repositories, and Checked melpa for if the package was available (it was) If I try package-install on it, it returns [no match].
I've tried package-refresh-contents to na avail. Please help with this, I could do it manually, but AUGH!
Just for context, here's the contents on my .emacs:
;; packages
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(add-to-list 'load-path "~/.emacs.d/elisp")
(defun require-package (package)
(setq-default highlight-tabs t)
"Install given PACKAGE."
(unless (package-installed-p package)
(unless (assoc package package-archive-contents)
(package-refresh-contents))
(package-install package)))
(package-initialize)
(load-theme 'zenburn t)
(require 'php-mode)
(eval-after-load 'php-mode
'(require 'php-ext))
(add-to-list 'auto-mode-alist '("\\.json$" . js-mode))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes (quote ("f5eb916f6bd4e743206913e6f28051249de8ccfd070eae47b5bde31ee813d55f" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;;
Thanks in advance, all help is very much appreciated
Icicles is no longer distributed on ELPA or MELPA:
NOTE:
Icicles, as well as my other libraries that are on EmacsWiki, used to be obtainable also from MELPA. You may still find some of them there, but they are likely not up-to-date.
As of 2017-10, MELPA has decided to no longer accept Lisp libraries from EmacsWiki. This includes my libraries, even though these libraries are read-only (administrator lock on the wiki pages). Too bad. This means that you must download Icicles and my other libraries only from Emacs Wiki. Sorry about that. I upload Icicles files only to the wiki.
https://www.emacswiki.org/emacs/Icicles_-_Libraries
Solved the problem by doing M-x eval-buffer on my .emacs.

Emacs: can't autostart projectile installed through MELPA

I'm fairly new to emacs. In fact I'm learning the editor and trying to setup something that will replicate "go to a file inside the project" feature known from Code::Blocks or certain plugins of notepad++.
'projectile' fulfills this need, and I installed it through MELPA. Package installed properly, as I can start it with M-x projectile-global-mode and C-c p commands are recognized.
However, if I put it into my .emacs file, Emacs starts with an error:
Symbol's function definition is void: projectile-global-mode
Contents of my .emacs file are as follows:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(global-whitespace-mode 1)
(global-linum-mode 1)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(projectile-global-mode 1)
When I try to (require 'projectile) first, I only end up with another error:
'File error: Cannot open load file, projectile'
I'm using Emacs 24.3.1.
How do I put this on autostart properly?
By default, Emacs initializes packages after evaluated init.el. Hence, in a standard setup, packages are not yet available while init is evaluated.
Use (add-hook 'after-init-hook #'projectile-global-mode) to enable Projectile only after packages are initialized, or explicitly initialize packages at the beginning of your init.el with the following code:
(require 'package)
(setq package-enable-at-startup nil) ; To avoid initializing twice
(package-initialize)
You have to load projectile first, e.g. by using this:
(require 'projectile)
(projectile-global-mode)
you can add
'(initial-major-mode (quote projectile-global-mode))
to your .emacs(or init.el or whatever your file is called) file in the custom-set-variable section.
Alternatively, in newer versions of emacs, the menu Options | Customize Emacs | Specific Option you can type 'initial-major-mode' and this will take you to an interface where emacs can customize itself with that setting. just remember to apply and save

What's the magic behind the ELPA?

I use Aquamacs, and I use ELPA that installs files in ~/.emacs.d/elpa?
What's the magic behind this ELPA? I mean, without ELPA, I should download and install the packages in a specific directory, and add those two lines in .emacs.
(add-to-list 'load-path "PACKAGE_DIRECTORY")
(require 'PACKAGE)
But, with ELPA, I don't see anything added to .emacs or /Users/smcho/Library/Preferences/Aquamacs Emacs/{Preferences.el, customizations.el}. How is this possible?
Added
This is what I found with Aquamacs.
Aquamacs reads ~/Preference/Aquamacs Emacs/Preference, and it has "(add-to-list 'load-path kitfiles-dir)(require 'init)", which reads start kit.
The init.el of start kit has the "(require 'package)(package-initialize)"
~/Library/Preferences/Aquamacs Emacs/aquamacs-emacs-starter-kit/vendor has the package.el
I guess the initialization files are not changed, but the package manager reads the ~/.emacs.d/elpd/* to initialize automatically, as I see ***-autoloads.el in each of it.
Added2
With emacs 24, it seems that package is pre-built. I need only to have these lines in .emacs or .emacs.d/init.el to get ELPA working. Hints from this site.
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(clojure-mode
nrepl))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(package-initialize) will go through all the installed packages (in ~/.emacs.d/elpa/ or similar, depending on configuration), and add them to the load path. One you have run it, take a look at load-path (C-hvload-path), it will have all those subdirectories added. So at this point, file loading will use the normal mechanisms.
You have a (require 'package) (package-initialize) pair somewhere in your initialization files. Package.el does the magic :)

Can't activate 'remember' in org-mode

I can't get 'remember' to work in org-mode of emacs.
I'm on snow leopard.
I added
(global-set-key (kbd "C-M-r") 'org-remember)
to my .emacs file but when I try to use that shortcut it says:
Wrong type argument: commandp, remember
So I added
(org-remember-insinuate)
and when I start emacs it says:
symbol's function definition is void org-remember-insinuate
Ideas?
GNU Emacs 22.1.1
Checking the obvious stuff...
Have you ensured that org-remember was loaded? i.e. by adding this to your .emacs:
(require 'org-remember)
And, while you're at it, have you ensured that remember can load properly also?
(require 'remember)
remember is a separate package from org, which you'll have to download. Check out the wiki page.
You'll want to ensure that the org and remember packages are in your load path before you require the libraries, with something like:
(add-to-list 'load-path "/path/to/orgdir/lisp")
(add-to-list 'load-path "/path/to/remember")
(require 'remember)
(require 'org-remember)
Note: Emacs 22 comes with org-mode, but not a recent version. You need the more recent version in order to get the org-remember package.