emacs cannot load file highlight-current-line file-error

312 Views Asked by At

Emacs version : GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601) of 2013-03-18 on MARVIN

Copied the code for highlight-current-line from here. Created a text-file in .emacs.d, pasted the entire text on page in the text-file and saved it as highlight-current-line.el in the same folder.

Added the following lines to .emacs :

(add-to-list 'load-path "~/.emacs.d/")
(require 'highlight-current-line)   
(global-hl-line-mode t)
(set-face-background 'hl-line "white")
(setq highlight-current-line-globally t)

Restarted emacs and got this message :

Warning (initialization): An error occurred while loading `c:/Users/Owner/AppData/Roaming/.emacs':

File error: Cannot open load file, highlight-current-line

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.

Started emacs in debug mode and got this error in backtrace:

Debugger entered--Lisp error: (file-error "Cannot open load file" "highlight-current-line") require(highlight-current-line)
eval-buffer(# nil "c:/Users/Owner/AppData/Roaming/.emacs" nil t) ; Reading at buffer position 1209
load-with-code-conversion("c:/Users/Owner/AppData/Roaming/.emacs" "c:/Users/Owner/AppData/Roaming/.emacs" t t) load("~/.emacs" t t)

My system : Windows 7 32bit

2

There are 2 best solutions below

1
Flame of udun On BEST ANSWER

Turns out copying text into notepad, saving it with .el in the file name and All files in the file type simply saves the file as highlight-current-line.el.txt .

I used the Save link as option in the dropdown menu on the download link instead, which worked perfectly.

3
Chris On

Once upon a time it made sense to copy snippets from EmacsWiki into your configuration, but between new high-quality built-in features and third-party package repositories like MELPA that is rarely the case anymore.

Your version of Emacs should be new enough to include hl-line.el, which contains a some useful functions:

To make the cursor even more visible, you can use HL Line mode, a minor mode that highlights the line containing point. Use M-x hl-line-mode to enable or disable it in the current buffer. M-x global-hl-line-mode enables or disables the same mode globally.

To enable highlighting of the current line globally, simply add

(global-hl-line-mode)

to your init file.

Edit: Upon re-reading your question, I see that you are already using hl-line.el, though this is interspersed with things relating to highlight-current-line.el. I recommend removing the following lines from your configuration:

(add-to-list 'load-path "~/.emacs.d/") ;; Unless you need it for another reason
(require 'highlight-current-line)   
(setq highlight-current-line-globally t)

You can additionally remove the t from you call to (global-hl-line-mode), since this function turns the feature on when called from lisp.