Skip to main content
Share Your Experience: Take the 2024 Developer Survey
14 votes

Speed up Emacs start-up time

Whatever your .emacs and its improvements, you also should consider running emacs as a server at your session's opening : emacs --daemon Now, running emacs with emacsclient -t or emacsclient -...
david's user avatar
  • 273
13 votes

Why can't I list the contents of Desktop on macos using dired?

If you find the problem persists after granting Emacs full disk access: from here on the problem remains because Emacs on MacOS gets launched indirectly, from a Ruby script. Your Emacs binary has full ...
dns's user avatar
  • 131
8 votes

Speed up Emacs start-up time

1) I have found esup to be a very convenient for Emacs startup profiling. You just run M-x esup and get back list of all expressions in your init.el sorted by the time they took to execute. You don't ...
Zaript's user avatar
  • 81
8 votes

desktop-save-mode fails to save window layout

In order for desktop-read (the function used to restore your desktop from a file) to restore the frameset that was saved in the desktop, it must call desktop-restoring-frameset-p (i.e., "should I ...
cyberbisson's user avatar
6 votes

Speed up Emacs start-up time

Side note, it is generally considered a good idea to have your startup code in ~/.emacs.d/init.el rather than ~/.emacs, one less hiden file in your home directory, a suffix so that other editors can ...
icarus's user avatar
  • 1,924
6 votes

Handle stale desktop lock files after emacs/system crash

Building on the accepted answer, this two line solution loads for me without a locked prompt. (setq desktop-load-locked-desktop t) (call-interactively 'desktop-read t (vector "~/.emacs.d/desktops/" ...
בנימן הגלילי's user avatar
6 votes
Accepted

Handle stale desktop lock files after emacs/system crash

You can check if the process is still alive using system command ps -p $PID, then delete the lock file if the process is not still alive. The following modification of init2.el above shows how this ...
Håkon Hægland's user avatar
5 votes
Accepted

Emacs desktop-save-mode - only save desktop when previous desktop was fully restored

There's a hook you can use: desktop-after-read-hook. Add a function to set a variable after the desktop state is restored. Using defadvice around desktop-save, check if the variable is set before ...
Faried Nawaz's user avatar
4 votes

Restoring Emacs desktops with daemon + clients

I suspect you have unremoved desktop lockfiles, which will usually be in your config dir/folder, which is hopefully ~/.emacs.d/. Here's a procedure for testing my hypothesis from a commandline (e.g. a ...
TomRoche's user avatar
  • 632
4 votes
Accepted

How to start lsp-mode connections lazily after desktop is restored?

How about: (use-package lsp-mode :straight t :init (setq lsp-keymap-prefix "C-c l") :hook (python-mode . lsp-deferred)) The doc for lsp-deferred: Signature (lsp-deferred) ...
C4ffeine Add1ct's user avatar
3 votes
Accepted

Limit number of files saved by emacs in desktop-save

You can try https://www.emacswiki.org/emacs/MidnightMode -- by default this will cleanup old buffers once a night. To reduce the delay time on opening emacs with a lot of saved desktop buffers, you ...
Willy Lee's user avatar
  • 470
3 votes

Daemon mode: Defer interactive prompts on startup?

Not exactly what you are asking for but maybe a solution to your original problem: I'd like to know if there is a general way to keep emacs --daemon from hanging forever waiting for an answer to a ...
Tobias's user avatar
  • 33.2k
3 votes
Accepted

How to make emacs prompt yes or no to save the session when desktop-save-mode is on?

My answer at https://stackoverflow.com/a/4485083/324105 might be of interest (even though this is almost the opposite to what you actually asked for). With the custom my-desktop command, I only load ...
phils's user avatar
  • 51.5k
3 votes

How to start lsp-mode connections lazily after desktop is restored?

The accepted answer didn't work for me, since when lsp-mode is already listed as a minor mode in the saved buffers, desktop-read will activate it before lsp-deferred runs. Instead, I'm using this: (...
scry's user avatar
  • 133
2 votes
Accepted

Configuring the number of buffers saved by ido, using ido-use-virtual-buffers?

ido gets its file history from multiple places: If ido-use-virtual-buffers is enabled, ido uses recentf to save buffer history. At history save time (e.g. on emacs shutdown), recentf-files may ...
Croad Langshan's user avatar
2 votes
Accepted

Periodic desktop save

Ordinarily, one would use a timer to repeat a task at given time intervals. However, the manual node on Saving Emacs Sessions states that: When desktop-save-mode is active and the desktop file ...
Dan's user avatar
  • 33.1k
2 votes
Accepted

Why do desktops depend on folders?

I like the question, and I agree with its suggestion. I don't think there is any good reason why desktop.el accepts only a directory (folder) argument and not, alternatively or additionally, a file ...
Drew's user avatar
  • 77.9k
2 votes
Accepted

Daemon mode: Defer interactive prompts on startup?

Our discussion cleared that you do not have any X-server running this renders my first solution useless for you. In the following I present a second solution that works with text terminal frames. ...
Tobias's user avatar
  • 33.2k
2 votes
Accepted

Open another emacs and cause conflicts

You can't usefully have two simultaneous Emacs session that use the same file to store the session state. Each time a session saves its state, it would overwrite the other session's state. Many ...
Gilles 'SO- stop being evil''s user avatar
2 votes
Accepted

desktop-save-mode: prevent emacs from showing each buffer on start-up

The variable desktop-restore-eager can control this. This variable controls how many buffers to restore the moment you start emacs. The rest will be restored quietly when Emacs is idle. So if you set ...
Tyler's user avatar
  • 22.3k
2 votes

How to prompt to ask for confirmation when C-x C-c in emacsclient?

C-x C-c will not prompt to ask for saving desktop, it will exit Emacs immediately. C-xC-c (save-buffers-kill-terminal) does not actually kill the server by default, unless the client invoking it was ...
Basil's user avatar
  • 12.4k
2 votes
Accepted

Why does a certain file always gets opened on startup?

In the desktop file I found I had another TeX file in my saved session whose TeX-master file was a.tex. Closing that file solved the issue. Perhaps auctex or some other TeX-mode was opening a.tex ...
Ricardo's user avatar
  • 131
2 votes

Why can't I list the contents of Desktop on macos using dired?

I followed Nabi and Vinh's solutions. dired worked but not all functions. For example, the sort is not working. A quick search leads me here: https://github.com/d12frosted/homebrew-emacs-plus/issues/...
spacegoing's user avatar
2 votes

The (desktop-save-mode 1) thingy interferes with the (tool-bar-mode -1) thingy

My guess is that you ran a session with tool-bar-mode on and desktop-save-mode on. When you exited that session, a desktop file was saved and that desktop file included tool-bar-mode on. Now you add ...
NickD's user avatar
  • 30.5k
2 votes
Accepted

The (desktop-save-mode 1) thingy interferes with the (tool-bar-mode -1) thingy

Quit Emacs. Find and delete your .emacs.desktop file(s). Restart Emacs. There maybe more than one .emacs.desktop file depending on what your current state was when you last saved. Check ~/.emacs.d/....
nega's user avatar
  • 3,276
2 votes

Is desktop restore expected to override --no-window-system?

-nw means "create the initial frame as a terminal frame", not "create only terminal frames". The resulting Emacs can still create graphical frames, as you've seen. If you don't ...
rpluim's user avatar
  • 5,315
1 vote

How to prompt to ask for confirmation when C-x C-c in emacsclient?

You could try setting confirm-kill-emacs to y-or-n-p in your config: (setq confirm-kill-emacs #'y-or-n-p) Works for me.
eeowaa's user avatar
  • 372
1 vote
Accepted

How to prompt to ask for confirmation when C-x C-c in emacsclient?

I found the answer from https://emacs.stackexchange.com/a/30475/794 The version is tweaked version from the answer in the link (defun ask-before-closing () "Prompt for confirmation for emacsclient(...
CodyChan's user avatar
  • 2,649

Only top scored, non community-wiki answers of a minimum length are eligible