Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the Emacs site-lisp directory

I am trying to make my Emacs configuration file written for OS X work on Ubuntu. I have this line:

(add-to-list 'load-path "/usr/local/Cellar/emacs/23.3/share/emacs/site-lisp/w3m")

It is used to load emacs-w3m. On OS X I installed Emacs using Homebrew, thus it is in /usr/local/Cellar/.The site-lisp directory on Ubuntu is in a different place. How can I write this line in a way that will work on both operating systems? Is there an Emacs Lisp function to retrieve the site-lisp directory?

like image 416
hekevintran Avatar asked Aug 03 '11 19:08

hekevintran


People also ask

Where is load path Emacs?

On GNU/Linux, the default value of 'load-path' includes two special directories and their descendants: /usr/local/share/emacs/VERSION/site-lisp and /usr/local/share/emacs/site-lisp . The first directory contains packages for a particular Emacs version; the second contains packages for all installed versions of Emacs.

Is Emacs Lisp the same as Lisp?

Emacs Lisp is a dialect of the Lisp programming language used as a scripting language by Emacs (a text editor family most commonly associated with GNU Emacs and XEmacs). It is used for implementing most of the editing functionality built into Emacs, the remainder being written in C, as is the Lisp interpreter.

How do I load a Lisp in Emacs?

To load an Emacs Lisp file, type M-x load-file . This command reads a file name using the minibuffer, and executes the contents of that file as Emacs Lisp code. It is not necessary to visit the file first; this command reads the file directly from disk, not from an existing Emacs buffer.

What does require do in Emacs?

require looks in the global variable features to see whether the desired feature has been provided already. If not, it loads the feature from the appropriate file. This file should call provide at the top level to add the feature to features ; if it fails to do so, require signals an error.


2 Answers

No, there's no way. The site-lisp directory is a convention and only its existence not its path is agreed on.

Either you set a symbolic link on your Mac/Ubuntu or you use a system switch:

(defconst my-lisp-dir (cond
    ((equal system-type 'gnu/linux) "/usr/share/emacs/site-lisp/")
    ((equal system-type 'darwin) (concat "/usr/local/Cellar/emacs/" (number-to-string emacs-major-version) "." (number-to-string emacs-minor-version) "/share/emacs/site-lisp/"))
    (t (concat "/usr/local/emacs/site-lisp/")))

and then

(add-to-list 'load-path (concat my-lisp-dir "w3m"))
like image 97
Michael Markert Avatar answered Sep 28 '22 20:09

Michael Markert


I tried this on my Windows Emacs (23.4.1) and Mac OS Emacs (23.4.1) for my other add-on and it worked.

(concat (car load-path) "/w3m")

Usually, the load-path has the site-lisp as the first item in the list.

like image 30
TX T Avatar answered Sep 28 '22 21:09

TX T