Emacs freezes after Loading /etc/emacs/site-start.d/50dictionaries-common.el - emacs

I've got trouble with my emacs. It freezes after launch (even with --debug-init) I cannot perform any action with that emacs window, and I have to kill its process rather than close (C-x C-c or any other keystroke doesn't work).
With this message in scratch buffer:
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
However it does launch with -q option.
I found that after removing elpa/ directory package installer has problems with installing helm-company (it simply freezes there instead), and that's what I know so far.
Any ideas how to fix it?

Related

On launch emacs makes "ding" sound and displays "<noname> is undefined" message

I was using a very old version of Emacs on Windows 7 Professional 64 bit so I upgraded to Emacs 25.3.1 64 bit. The installation went well.
When I ran Emacs, I started reading the messages in the initial buffer and then I heard a "ding" sound and the message "<noname> is undefined" was displayed.
I started typing into the buffer and approximately 10 seconds after the first "ding" sound there was another and the message "<noname> is undefined" message was displayed again.
If I try to enter text into the buffer or enter a command, I'm interrupted by the "ding" and "<noname> is undefined" message. This makes Emacs useless.
Thinking that perhaps there was something in my Emacs initialization file which is no longer valid, I closed Emacs and renamed the Emacs initialization file, then launched Emacs again. Same "ding" sound and same message.
I'm not sure what "noname" Emacs is complaining about or how to fix it. It is now almost 3 AM (US Eastern time) so I'm going to get some sleep and attack this in the daylight hours.
Oh! One other thing - I access the Windows 7 Professional 64 bit box via Remote Desktop, as the computer is in a facility in another state.
Any idea as to what is going on?
More Information:
I rebooted after installing the new version of Emacs. When the computer rebooted it automatically launched the DishAnywhere player.
Normally I kill the DishAnywhere player shortly after launch, but last night I didn't, so DishAnywhere was running when I launched Emacs.
Today I've run some experiments and found:
-- If DishAnywhere is running and I launch Emacs, Emacs will "Ding" and display the "<noname> is undefined" message every 10 seconds.
-- If I exit Emacs and kill off DishAnywhere, then launch Emacs, Emacs runs correctly - no "Ding" or error message.
-- If I launch DishAnywhere AFTER Emacs has started running, no "Ding" or error message.
-- If I then exit Emacs, wait a few minutes, and then launch Emacs again (while DishAnywhere is running), Emacs runs correctly - no "Ding" or error message.
So...
If DishAnywhere runs BEFORE Emacs is launched, Emacs has a problem, "Dings" and displays an error message.
If Emacs is launched BEFORE DishAnywhere and is running when DishAnywhere is launched, then Emacs runs correctly.
The workaround is to:
Kill DishAnywhere before launching Emacs, then launch DishAnywhere.
But the question is what is the interaction between DishAnywhere and Emacs that causes the issue?
Does this happen when you start Emacs using emacs -Q? If so then use M-x report-emacs-bug, providing a recipe of what you are doing and what you see.
If not (which is what I'm guessing) then recursively bisect your init file to find the culprit code. You can use command comment-region to comment out a block of code. If you use C-u with comment-region then it uncomments a block of code.
Comment out 1/2, then 3/4, then 7/8, ... of your init file, to narrow the problematic part. This is a binary search, so it is very quick to do, even if it means restarting Emacs multiple times.

It is possible (and normal practice) to byte-compile files other than .emacs?

I'm using some plugins and I byte-compiled my .emacs but the start up still slow. Do I hava to byte-compile my prlugins too? (for instance, yasnippet.el -> yasnippet.elc)?
Byte compiled files load up faster so I'd recommend that you byte compile everything as Pascal suggested. I also keep this in my init file so automatically byte compile all the emacs lisp files I edit and save.
(add-hook 'emacs-lisp-mode-hook '(lambda ()
(add-hook 'after-save-hook 'emacs-lisp-byte-compile t t))) ;; Automatically byte-compile emacs-lisp files upon save
Emacs can feel slow to start up even without any .emacs or plugins :)
It is a good idea to compile plug-ins, that's as much time shaved from start-up. Compiling the .emacs configuration file is less usual (because it changes more often and is typically small anyway), but why not?
You probably already know this, but .el files can be byte-compiled using: M-x byte-compile-file or M-x byte-recompile-directory .
You can use emacs server to speed things up, then it only takes time to start the server the first time.
The way to start an Emacs server is to run Emacs as a daemon, using the ‘--daemon’ command-line option. When Emacs is started this way, it calls server-start after initialization, and returns control to the calling terminal instead of opening an initial frame; it then waits in the background, listening for edit requests.
Once an Emacs server is set up, you can use a shell command called emacsclient to connect to the existing Emacs process and tell it to visit a file. If you set the EDITOR environment variable to ‘emacsclient’, programs such as mail will use the existing Emacs process for editing.
From: http://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html
You'll likely find something use here: http://www.emacswiki.org/emacs/AutoRecompile
A great selection of tips for automatically byte-compiling files, when you save them or when you load them, and even caching the compiled files in a certain directory.

How do I byte-compile everything in my .emacs.d directory?

I have decided to check out Emacs, and I liked it very much. Now, I'm using the Emacs Starter Kit, which sort of provides better defaults and some nice customizations to default install of Emacs.
I have customized it a little, added some stuff like yasnippet, color-themes, unbound, and other stuff. I've set up a github repository where I keep all of the customizations so I can access them from multiple places or in case something goes bad and I lose my .emacs.d directory.
All of this is very nice, but there is a problem: Emacs takes about 1-2 seconds to load. AFAIK I can compile individual .el files with M-x byte-compile-file to .elc, and it works. But there are a lot of .el files, and I wonder if there is a way to compile them all with a simple command or something, to speed up the loading of Emacs. My Emacs is not always open, and I open and close it quite frequently, especially after I've set it up as a default editor for edit command in Total Commander to get used to it faster (yeah, windows xp here).
My Emacs version is 22.3. And yes, the default Emacs installation without any customizations fires up instantly.
I am not sure which version is preferred when loading, the .el or compiled .elc one by the way O.o
So, is there an elisp command or Emacs command line switch to make Emacs byte-compile everything in .emacs.d directory?
C-u 0 M-x byte-recompile-directory
will compile all the .el files in the directory and in all subdirectories below.
The C-u 0 part is to make it not ask about every .el file that does not have a .elc counterpart.
To automatically byte compile everything that needs byte compiling each time I start emacs, I put the following after my changes to load-path at the top of my .emacs file:
(byte-recompile-directory (expand-file-name "~/.emacs.d") 0)
Surprisingly, it doesn't add much to my startup time (unless something needs to be compiled).
To speed up my emacs, I first identified the slow parts using profile-dotemacs.el and then replaced them with autoloads.
You can use the --batch flag to recompile from the command line.
To recompile all, do
emacs --batch --eval '(byte-recompile-directory "~/.emacs.d")'
or to recompile a single file as from a Makefile,
emacs --batch --eval '(byte-compile-file "your-elisp-file.el")'
This is swaying a bit from the question, but to solve the problem of loading slowly you can use the new daemon feature in Emacs 23.
"If you have a lot of support packages,
emacs startup can be a bit slow.
However, emacs 23 brings emacs
--daemon, which enables you to start emacs in the background (for example
when you log in). You can instantly
pop up new emacs windows (frames) with
emacsclient. Of course, you could
already have an emacs 'server' in
older versions, but being able to
start it in the background makes this
a much nicer solution"
From http://emacs-fu.blogspot.com/2009/07/emacs-23-is-very-near.html
The command I use is M-x byte-force-recompile RET, it then asks the directory so, for example, I give it ~/.emacs.d/elpa/. It then recompiles everything in there, usually no need to delete .elc files first or mess with it in other ways.
For my using spacemacs, the command is spacemacs/recompile-elpa. The command byte-recompile-directory does not compile any file.

Stop tramp-mode running on emacs' startup

I was trying out tramp-mode, but now I cannot seem to get rid of it.. Whenever I start emacs, it spends about 20 seconds going through various tramp-related initialisations..
tramp: Waiting 60s for prompt from remote shell
tramp: Setting up remote shell environment
..and so on.
How on earth do I unload tramp? grep'ing my ~/.emacs.d found nothing aside from the plugin itself (which doesn't seem to be loaded anywhere..)
I've cleared the recent-files history, but that made no difference..
Aha, I found where tramp was being loaded:
Loading /Users/dbr/.recentf...done
Loading tramp-mode..
I had a two files in my ~/.recentf file-history which were opened with tramp, removing them stops tramp from loading..
I just found this section of the emacs wiki explaining the problem,
When using TrampMode with recentf.el, it’s advisable to turn off the cleanup feature of recentf that attempts to stat all the files and remove them from the recently accessed list if they are readable. Tramp means that this requires recentf to open up a remote site which will block your emacs process at the most inopportune times.
(require 'recentf)
(setq recentf-auto-cleanup 'never) ;; disable before we start recentf!
(recentf-mode 1)
Another possibility is a listing in ~/.ido.last, if you are using ido-mode. In that case, the remedy is just "rm ~/.ido.last".
It sounds to me like you have a file that is opened via tramp and is being reopened at startup. Have to set emacs to restore your session?
From the tramp faq:
How can I disable tramp?
Shame on you, why did you read until now?
If you just want to have Ange-FTP as default remote files access package, you should > apply the following code:
(setq tramp-default-method "ftp")
Unloading tramp can be achieved by applying M-x tramp-unload-tramp. This resets also > the Ange-FTP plugins.
Note that I haven't tried this but hope it works for you!

emacs recompile file while running

How do you recompile emacs-lisp scripts from within emacs without problems? I've tried batch-recompile-direcory, but this causes weird glitches with the recompiled files until I restart emacs. Is there any way to do this so that no errors are caused?
This page of the GNU Emacs Reference manual taks about reloading files and/or libraries.
You definitely have to explicitey reload the new file with M-x load-library, unless there is another emacs mechanism that forces it to reload the newly byte-compiled function.