Hot answers tagged

12

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 -nw -c or ... (see options) will be much faster


12

I needed to manage the desktop files just like you; have a separate desktop file for each project and save buffers, emacs variables, etc independently for each. I was able to achieve that using a package called bookmark+, available on Melpa. bookmark+ bookmark+ manages different types of bookmarks, one of those is Desktop Bookmarks. After installing the ...


6

Don't kill the process. Use M-x kill-emacs RET to terminate the server.


5

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 need to restart Emacs or add anything special to the config, so narrowing on the slow down suspect becomes much easier. 2) I (use-package :defer t) all the ...


5

You can save the buffer-local value of comint-input-ring in a global variable when an *ielm* buffer is killed and restore it in inferior-emacs-lisp-mode-hook: ;; global copy of the buffer-local variable (defvar ielm-comint-input-ring nil) (defun set-ielm-comint-input-ring () ;; create a buffer-local binding of kill-buffer-hook (make-local-variable '...


4

Using (setq desktop-path (list my-desktop-dir)) before calling (desktop-save-mode 1) seems to solve the issue: (require 'desktop) (setq desktop-path (list "~/emacs-server")) (desktop-save-mode 1) Note: You will now get a question Save desktop? (y or n) when killing Emacs server and this is the first time you save the desktop..


4

IIUC buffer-undo-list is missing from buffer-local-variables by accident. The accident is that some code clean up ended up making buffer-local-variables use the same loop over some of the buffer's local variables, as the loop used when the garbage collector looks for references in a buffer object. As it turns out, buffer-undo-list needs to be handled ...


4

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 can be done from within Emacs. Note that I use two private functions from desktop.el, namely desktop-owner and desktop-full-lock-name. (require 'desktop) (defun ...


4

I have the following in my equivalent of a .emacs file: (defun my-bury-star-buffers () "Bury all star buffers." (interactive) (mapc (lambda (buf) (when (string-match-p "\\`\\*.*\\*\\'" (buffer-name buf)) (bury-buffer buf))) (buffer-list))) (add-hook 'desktop-after-read-hook #'my-bury-star-buffers) I don't remember where ...


4

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 guess the contents.... For bisection, the idea is that you stop running your .emacs about half way and see if it still takes a lot of time. If it does then you ...


3

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/" t))


3

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 my desktop file when I want to do that. Once loaded, I do automatically save it (but to my mind, if I loaded a desktop file, why wouldn't I want to save it?) ...


3

I believe you can achieve this by setting desktop-file-name-format to "local". Here's what describe-variable says about it: desktop-file-name-format is a variable defined in `desktop.el'. Its value is absolute Documentation: Format in which desktop file names should be saved. Possible values are: absolute -- Absolute file name. tilde -- Relative ...


3

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 saving the state. I'm on Emacs 25.3.1, and this is the code I used: (defvar *my-desktop-save* nil "Should I save the desktop when Emacs is shutting down?") (...


2

There's special-event-map which can be used to handle signals among other things, you can bind a key like [sigusr2] there to a function you'd like to be executed on the respective signal. I'm not so sure whether it works on anything else than SIGUSR1 and SIGUSR2 though. edit: Here's an useful example of how one could use it: (defun my-quit-emacs-...


2

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 restore the saved frameset?"), which in turn checks the function display-graphic-p (i.e., "is this a GUI or a TTY?"). This essentially means that, even though ...


2

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 exists, Emacs auto-saves it every desktop-auto-save-timeout seconds, if that is non-nil and non-zero. I found this information by looking in the elisp manual ...


2

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 prompt displayed in a minibuffer that doesn't exist yet. If the daemon gives you a graphical frame for answering questions arising in its startup-phase you do ...


2

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 Bash shell running in a terminal app under Linux): Ensure you have no emacs* processes running: i.e., there should be null response to pgrep -l emacs If you ...


2

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 people run a single Emacs session. To open a file in the existing Emacs session, use emacsclient (see also the Emacs wiki). Emacsclient has several options to ...


2

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 can modify desktop-restore-eager - set it to a low number and only those will be opened immediately, with the rest being opened lazily.


2

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 whenever the other file was opened at startup when restoring the saved session?


1

You are passing a literal list as the second arg to setq. Instead, you want to substitute the value of the (car...) sexp. You can do that using a backquote construction, telling it to evaluate that (car...) sexp and use the result of the evaluation. You want this: (setq frame-title-format `("%b Desktop: " ,(car (last (split-...


1

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. When your initialization requires user input through one the functions advised with avoid-initial-terminal Emacs waits until you open a text terminal frame. The ...


1

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 argument for desktop-read. After all, that function is about reading a desktop file. Why make it impossible to pass a file to the function? Why make the ...


1

I believe a directory was used primarily because more than one file is saved there. As well as the desktop file itself (desktop-base-file-name) there is also a lock file (desktop-base-lock-name). Those are just variables, so there's nothing stopping you from writing a custom command to read a desktop-base-file-name from the user, derive an appropriate ...


1

I think defering the prompts is going to be difficult in general, but it should be fairly easy to change Emacs so that such prompts immediately signal an error. Not only that, but if you can't answer those prompts without a lot of gymnastics, I think it qualifies as a bug, so I'd recommend you submit a bug report for that.


1

You should be able to set desktop-dirname to the directory of your choice and then every time you save using desktop-save-in-desktop-dir it will save in that directory. You can still use desktop-save and it will provide you with the usual home directory prompt.


1

It seems there have been some changes in 10.12 with the introduction of the 'tabbed' windows option which can affect emacs. I found that when I created new frames, they were on the same 'virtual desktop' where previously, they were on a different virtual desktop (when doing so in fullscreen mode). I found that this was because of a new option under the ...


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