0

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

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Flame of udun
  • 2,136
  • 7
  • 35
  • 79

2 Answers2

2

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.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 1
    This provides useful information about another way to highlight the current line. But it does not provide an answer to the question, which is how to debug what is wrong - why is the file the OP expected to load not getting loaded. – Drew Mar 06 '15 at 22:26
  • @Drew, that's a good point. However I'm going to leave it up, since in my opinion it's generally good advice and it should solve the related problem. With Emacs 24 there's no need (or excuse) to load unversioned, largely uncontrolled snippets. I will always advise replacing copy-pasted config snippets with equivalent built-ins or `package.el` packages where possible. – ChrisGPT was on strike Mar 06 '15 at 22:38
  • 1
    @Chris +1 for the `hl-line.el` suggestion. I found the solution on my own though. 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. – Flame of udun Mar 07 '15 at 04:26
2

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.

Flame of udun
  • 2,136
  • 7
  • 35
  • 79
  • 1
    I'm glad you figured this out. Don't forget to [accept your own answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) to show that you've found a solution. – ChrisGPT was on strike Mar 09 '15 at 12:47