Beginner issue: Errors loading .el files in Emacs - emacs

I'm an Emacs beginner. I just installed a Emacs on Linux. I want to integrate Emacs with gdb.
Based on some instruction from the internet, I downloaded 2 .el files: multi-gdb-ui.el and multi-gud.el. I put these 2 files in
/tmp/test/emacs/multi-gdb-ui.el
and
/tmp/test/emacs/multi-gud.el
I created a new .emacs file. I only put the following lines in it:
[root#localhost ~]# cat .emacs
(setq gdb-many-windows t)
;; this is used for GDB
(load-library "/tmp/test/emacs/multi-gud.el")
(load-library "/tmp/test/emacs/multi-gdb-ui.el")
Then I launched Emacs. But I got many errors. It asked me to launch it with --debug-init,
so I ran the following:
emacs --debug-init
I got these errors:
Debugger entered--Lisp error: (void-variable overlay-arrow-variable-list)
add-to-list(overlay-arrow-variable-list gud-overlay-arrow-position)
eval-buffer(#<buffer *load*<2>> nil "/tmp/test/emacs/multi-gud.el" nil t)
load-with-code-conversion("/tmp/test/emacs/multi-gud.el" "/tmp/shili/emacs/multi-gud.el" nil nil)
load("/tmp/shili/emacs/multi-gud.el")
load-library("/tmp/shili/emacs/multi-gud.el")
eval-buffer(#<buffer *load*> nil "~/.emacs" nil t)
load-with-code-conversion("/root/.emacs" "~/.emacs" t t)
load("~/.emacs" t t)
#[nil "^H\205\227^# ▒=\203^Q^#▒^H▒Q\2025^# ▒=\203'^#▒▒▒▒#\203#^#▒\2025^#▒\2025^# ▒=\2031^#▒\2025^#▒^H▒Q^Z▒^S▒\n▒\211#\210^K▒=\203F^#▒^S^K\203\210^#▒^K!▒\232\203$
command-line()
normal-top-level()
So how can I load these 2 .el files successfully?

The issue appears to be caused because the folders containing the source files at issue have apparently not been added to the load-path of Emacs. In this particular case, the original poster may either add the following directories to the load-path (i.e., /tmp/shili/emacs/ and /tmp/test/emacs/); or, the source files at issue may be placed inside an Emacs directory that is already wired with the load-path.
The following links contain relevant documentation relating to the load-path, which may be helpful in that regard:
http://www.emacswiki.org/emacs/LoadPath
http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html

Related

Error with Kieran Healy's emacs starter kit

I have installed Kieran Healy's emacs social sciences starter kit. I have changed the name of the file kjhealy.org to ljs.org (as per his instructions). The starter kit settings seem to load, but I get the following error.
Warning (initialization): An error occurred while loading
‘/Users/ljs/.emacs.d/init.el’:
File error: Cannot open load file, No such file or directory, ob-shell
When I open emacs with the --debug-init files, I get the following:
Debugger entered--Lisp error: (void-function package-initialize)
(package-initialize)
eval-buffer(#<buffer *load*> nil "/Users/ljs/.emacs.d/init.el" nil t)
; Reading at buffer position 403
load-with-code-conversion("/Users/ljs/.emacs.d/init.el"
"/Users/ljs/.emacs.d/init.el" t t)
load("/Users/ljs/.emacs.d/init" t t)
#[nil "^H\205\276^# \306=\203^Q^#\307^H\310Q\202A^#
\311=\2033^#\312\307\313\314#\203#^#\315\202A^#\312\307\313\$
command-line()
normal-top-level()
Any help with this greatly appreciated.
The underlying reason for this problem is that the file ob-sh.el was renamed to ob-shell.el and the corresponding babel language became shell. That happened in version 8.2.5 (more precisely, it's commit 583e7ab17:
$ git describe 583e7ab17
release_8.2.4-332-g583e7ab17
so 332 commits after 8.2.4).
So if your version of emacs is 8.2.4 or earlier, you have to use sh as the babel language and load the file ob-sh.el. For 8.2.5 and later (including the current version that is distributed with emacs), you have to use shell as the babel language and load the file ob-shell.el.
Hope that clarifies.

Newly created Emacs init file won't load

Brand-new Emacs 24.5 64-bit install on Win7 did not seem to include an init.el file and I needed one for settings for a plug-in I want to use, so I created one in Emacs at C:\Users\brinklec\AppData\Roaming.emacs.d. Restarting Emacs, got the apparently famous
Warning (initialization): An error occurred while loading `c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el':
File error: Cannot open load file, no such file or directory, use-package
I did not initially understand the reference to "use-package" at the end of the error, and the preceding wording apparently misled me to think it was init.el that Emacs was saying it c ould not load.
Manual load gives the same error. However, Emacs can open and successfully resave the file.
I saw a bunch of similar issues, but all seemed to involve other files referenced in an already existing and successfully loaded init.el. I thought my issue was different, but now maybe not?
Contents of my init.el come from recommended config for ENSIME plug-in (verbatim except for first comment line below):
;;; ~/.emacs.d/init.el
;; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
use-package-always-ensure t
sentence-end-double-space nil)
;; buffer local variables
(setq-default
indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
;; modes
(electric-indent-mode 0)
;; global keybindings
(global-unset-key (kbd "C-z"))
;; the package manager
(require 'package)
(setq
use-package-always-ensure t
package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
Debug output from --debug-init:
Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "use-package")
require(use-package)
eval-buffer(#<buffer *load*> nil "c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" nil t) ; Reading at buffer position 841
load-with-code-conversion("c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" "c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" t t)
load("c:/Users/brinklec/AppData/Roaming/.emacs.d/init" t t)
#[0 "\205\262
Adding the following expression right before the final (require 'use-package) seems to have resolved the error (though I'm also no longer getting the helpful greeting screen on startup):
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))

error on invalid function: abbrev

I used to use Emacs in windows, recently I want to try Ubuntu 14.04. I used the same settings, same init.el, same packages. but I got an error when start Emacs under Ubuntu.
I am not an elisp programmer, and I hope I can get some help here. I am using Prelude for Emacs 24, but even I run emacs with -Q, the same error is still there....
The errors are as follows:
Debugger entered--Lisp error: (invalid-function "abbrev")
"abbrev"("convenience" "matching")
byte-code("\300\301\302\303\304\305\306\307\310\311\312\"&\207" [define-package "company" "20140731.944" "Modular text completion framework" ((emacs "24.1") (cl-lib "0.5")) :url "http://company-mode.github.io/" :keywords "abbrev" "convenience" "matching"] 11)
load("/home/zhijia/.emacs.d/elpa/company-20140731.944/company-pkg" nil t)
package-load-descriptor("/home/zhijia/.emacs.d/elpa" "company-20140731.944")
package-maybe-load-descriptor("company" "20140731.944" "/home/zhijia/.emacs.d/elpa")
package-load-all-descriptors()
package-initialize()
byte-code("\302\303!\210\302\304!\210\305\306\307\310#\210\311\312\"\313 \207" [prelude-dir package-user-dir require cl package add-to-list package-archives ("melpa" . "http://melpa.milkbox.net/packages/") t expand-file-name "elpa" package-initialize] 4)
require(prelude-packages)
eval-buffer(#<buffer *load*> nil "/home/zhijia/.emacs.d/init.el" nil t) ; Reading at buffer position 4156
load-with-code-conversion("/home/zhijia/.emacs.d/init.el" "/home/zhijia/.emacs.d/init.el" nil nil)
load("/home/zhijia/.emacs.d/init.el" nil nil t)
load-file("~/.emacs.d/init.el")
call-interactively(load-file record nil)
command-execute(load-file record)
execute-extended-command(nil "load-file")
call-interactively(execute-extended-command nil nil)
Delete ~/.emacs.d/elpa, restart Emacs, and let Prelude install all packages again.
It looks like you've stumbled across incompatibilities between package.el in different Emacs versions. I'm not sure why, though. Normally errors like this only occur when upgrading from Emacs 23 to 24, or when upgrading from Emacs 24.3 to the (not yet released) Emacs 24.4. Neither of these seem to be the case here, though.
You are getting this error with emacs -Q as well, because emacs -Q still loads all user-installed packages from ~/.emacs.d/elpa.
It seems you need to remove the ~/emacs.d/elpa/company-XXX and re-install it.
Even if you call it with -Q, it still has a startup file that checks the ~/.emacs.d/ directory.
Try first to remove the .elc files before to remove everything.

Emacs sr-speedbar cannot open loadfile, sr-speedbar

I'm having difficulty following the instructions for installing speedbar on Emacs.
step 1. Put Lisp:sr-speedbar.el in your load-path, add
(require 'sr-speedbar)
ok put "sr-speedbar.el" in my load-path. (first of all I am making the assumption my load-path is my .emacs.d directory in my root directory.
I go to this link: http://www.emacswiki.org/emacs/sr-speedbar.el
hit the download button, which I end up having to copy/paste the entire file, save it as sr-speedbar.el inside my .emacs.d directory.
~/.emacs.d now has sr-speedbar.el and my .emacs file has the below code:
1 (add-to-list 'load-path "~/.emacs.d/evil")..
2 (require 'evil)..
3 (evil-mode 1)
4 (require 'sr-speedbar)
~
~
so i close out emacs, open it back up and get this error:
Warning (initialization): An error occurred while loading `/Users/johncurry/.emacs':
File error: Cannot open load file, sr-speedbar
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.
so I $ emacs --debug-init
Debugger entered--Lisp error: (file-error "Cannot open load file" "sr-speedbar"$
require(sr-speedbar)
eval-buffer(#<buffer *load*> nil "/Users/johncurry/.emacs" nil t) ; Reading$
load-with-code-conversion("/Users/johncurry/.emacs" "/Users/johncurry/.emacs"$
load("~/.emacs" t t)
#[0 "^H\205\262^# \306=\203^Q^#\307^H\310Q\202;^# \311=\204^^^#\307^H\312$
command-line()
normal-top-level()
sr-speedbar-open returns no match inside emacs. Any idea how to get this wrong? I'm sure it's just me not understanding the instructions, but I need help with this.
I had the same problem. When I checked the load path of emacs I found that the ~/.emacs.d directory wasn't part of the path.
You can check you load-path use the following command
C-h v load-path RET
To add the path I added the following to my .emacs file.
;; Add the ~/.emacs.d/lisp directory and all subdirectories to the load path of emacs
(let ((default-directory "~/.emacs.d/lisp/"))
(normal-top-level-add-subdirs-to-load-path))
I already had some files in the .emacs.d directory so I add a lisp directory so I wouldn't break anything.
I then reloaded my .emacs file and everything worked.
To reload your .emacs file use the following command
M-x load-file RET .emacs RET
source: https://www.emacswiki.org/emacs/LoadPath

emacs24 semantic completion

I'm trying to get semantic completions working with emacs 24 and the version of cedet that comes with it. Completions work for classes I defined in my own source file, but completion isn't working for the standard library or STL stuff Here is my emacs config:
(require 'cedet)
(require 'semantic)
(require 'semantic/ia)
(require 'semantic/bovine/gcc)
(semantic-add-system-include "/usr/include/c++/4.6.3" 'c++-mode)
(setq semantic-default-submodes
'(global-semantic-idle-scheduler-mode
global-semanticdb-minor-mode
global-semantic-idle-summary-mode
global-semantic-idle-completions-mode
global-semantic-highlight-func-mode
global-semantic-decoration-mode
global-semantic-mru-bookmark-mode))
(setq semanticdb-default-save-directory "~/.semanticdb/"
semantic-complete-inline-analyzer-idle-displayor-class 'semantic-displayor-ghost)
(semantic-mode t)
In my ~/.semanticdb directory I only see "!usr!include!c++!4.6!x86_64-linux-gnu!bits!semantic.cache", which isn't even using the version I specified in the config.
When I try M-x semantic-analyze-possible-completions on a std::list, for example, I get an error saying: "Cannot find types for std::list"
Any suggestions for how to debug this or how to fix it?
I was installing today a fresh Ubuntu 13.04 on my new SSD,
and here are my steps to configure CEDET ( I checked that it gives completions for std::list).
Basic setup
Get a fresh emacs and build it from source.
It's as easy as
./configure && make && sudo make install
Add to .emacs
(semantic-mode 1)
That's the whole setup.
Testing
Run emacs without loading anything:
emacs -q test.cc
Enter the code
#include <list>
int main() {
std::list lst;
lst.$
return 0;
}
M-x semantic-mode
with point at $, M-x semantic-ia-show-variants
Troubleshooting
If stuff doesn't work, it's likely that the semanticdb is corrupt.
Just find where it is, for me it's semanticdb-default-save-directory="~/.emacs.d/semanticdb",
and remove everything from there.
Then, when visiting a source file, call semantic-force-refresh.