Stop tramp-mode running on emacs' startup - emacs

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!

Related

Issue disabling lock files in Emacs

I would like to disable emacs lock files. Per this thread it is possible to do it with (setq create-lockfiles nil).
However, when I put this in my .emacs file and start up, the value of this variable (via describe-variable) is t. If I set it manually via set-variable then it sticks and works as expected.
I'm using GNU Emacs 24.5.1, via the Goulet installer for windows. For what it's worth, I tried a fresh install of Emacs on a brand new PC (Win10) and it has the same issue. I also tried commenting out everything except this line in my config file, and it still failed to work.
Why would it not work if put at the end of my .emacs file? Is some other emacs package overwriting this (perhaps ESS)? Is there a way to set it permanently, after everything else is loaded?
Thanks

Emacs Tramp unable to open directory at times

Normally I am able to use tramp just fine to edit files and browse through the remote file system through SSH. Though at seemingly random times I would lose the ability to browse remote folders in emacs.
I get the error message:
Wrong type argument: number-or-marker-p, //DIRED-OPTIONS//
I've tried doing a clean reinstall of emacs without any customizations and the error still happens.
Also sometimes the error happens after browsing 1 or 2 directories while other times I'm able to do five or six directories before the error will appear.
Edit:
I'm using Emacs 23.3 running on OS X 10.6.8
Edit 2:
While I'm still going through the tramp debug log A couple of other pieces of information.
After the error I'm still able to use tramp of open and save files, just not view directory listings.
It seems to happen only when I save to a directory that is version controlled using git.
In the debug log the directory contents are listed out but it is not being outputted to the user
The directory listing inside the debug log show ^M (I usually notice this in the emacs info bar when editing files that have been versioned in git) even when I try to access a non-version controlled directory
The message is useless by itself. You should try to obtain more traces on the tramp behavior in order to find where is the issue. See the Traces and Profiles Section of the TRAMP User Manual.
Sorry to not help more but with another release on another platform…
Update:
Put the following in your emacs file
(require 'tramp)
(setq tramp-verbose 10)
(setq tramp-debug-buffer t)
Then, use tramp. Now, You should have a *debug tramp/method hostname* buffer.
I found out that this happens when I enable:
(setq-default dired-omit-mode t)
But for now I don't know how to make it work with this mode

Emacs desktop doesn't remember TRAMP connections?

I use emacs to edit scripts and code files on several different servers. TRAMP is working very well. However, when I exit emacs, all my tramp connections go away. I tried desktop-save-mode, but only local files show up when I restart emacs. Is there some package that will remember tramp connections? Is this just a configuration issue?
You can customize the variable desktop-buffers-not-to-save to do this:
(setq desktop-buffers-not-to-save "^$")
By default it is set to a regexp that matches TRAMP filenames. I would have expected setting it to nil would have worked, but, alas, it does not.

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.