Limit number of files saved by emacs in desktop-save
I tend not to delete buffers in emacs, so over time, the number of buffers tends to grow to a hundred or more. (At the moment, *Buffer List*
has 144 lines.)
Many of these files are java files, and with my configuration, loading a Java file takes a second or two. This means that starting emacs can take a few minutes.
Is there a way to limit the number of buffers that are saved by the desktop? Ideally, I would like to drop buffers that I have not visited in a while.
I tried this:
(advice-add 'no-save-unseen-buffers :before-while 'desktop-save-buffer-p
(lambda (buffer &optional rest)
(let ((last-time (with-current-buffer buffer buffer-display-time)))
(when (and last-time
(< (time-to-seconds (time-subtract (current-time) last-time))
(* 2 7 24 60 60)))))))
but it does not seem to have an effect.
Advice on how to make the above code work, a completely different approach or package that does what I want are all fine answers.
desktop
migrated from superuser.com Feb 26 at 20:13
This question came from our site for computer enthusiasts and power users.
add a comment |
I tend not to delete buffers in emacs, so over time, the number of buffers tends to grow to a hundred or more. (At the moment, *Buffer List*
has 144 lines.)
Many of these files are java files, and with my configuration, loading a Java file takes a second or two. This means that starting emacs can take a few minutes.
Is there a way to limit the number of buffers that are saved by the desktop? Ideally, I would like to drop buffers that I have not visited in a while.
I tried this:
(advice-add 'no-save-unseen-buffers :before-while 'desktop-save-buffer-p
(lambda (buffer &optional rest)
(let ((last-time (with-current-buffer buffer buffer-display-time)))
(when (and last-time
(< (time-to-seconds (time-subtract (current-time) last-time))
(* 2 7 24 60 60)))))))
but it does not seem to have an effect.
Advice on how to make the above code work, a completely different approach or package that does what I want are all fine answers.
desktop
migrated from superuser.com Feb 26 at 20:13
This question came from our site for computer enthusiasts and power users.
add a comment |
I tend not to delete buffers in emacs, so over time, the number of buffers tends to grow to a hundred or more. (At the moment, *Buffer List*
has 144 lines.)
Many of these files are java files, and with my configuration, loading a Java file takes a second or two. This means that starting emacs can take a few minutes.
Is there a way to limit the number of buffers that are saved by the desktop? Ideally, I would like to drop buffers that I have not visited in a while.
I tried this:
(advice-add 'no-save-unseen-buffers :before-while 'desktop-save-buffer-p
(lambda (buffer &optional rest)
(let ((last-time (with-current-buffer buffer buffer-display-time)))
(when (and last-time
(< (time-to-seconds (time-subtract (current-time) last-time))
(* 2 7 24 60 60)))))))
but it does not seem to have an effect.
Advice on how to make the above code work, a completely different approach or package that does what I want are all fine answers.
desktop
I tend not to delete buffers in emacs, so over time, the number of buffers tends to grow to a hundred or more. (At the moment, *Buffer List*
has 144 lines.)
Many of these files are java files, and with my configuration, loading a Java file takes a second or two. This means that starting emacs can take a few minutes.
Is there a way to limit the number of buffers that are saved by the desktop? Ideally, I would like to drop buffers that I have not visited in a while.
I tried this:
(advice-add 'no-save-unseen-buffers :before-while 'desktop-save-buffer-p
(lambda (buffer &optional rest)
(let ((last-time (with-current-buffer buffer buffer-display-time)))
(when (and last-time
(< (time-to-seconds (time-subtract (current-time) last-time))
(* 2 7 24 60 60)))))))
but it does not seem to have an effect.
Advice on how to make the above code work, a completely different approach or package that does what I want are all fine answers.
desktop
desktop
edited Feb 26 at 22:56
Drew
49k463107
49k463107
asked Feb 26 at 20:07
Troy DanielsTroy Daniels
1554
1554
migrated from superuser.com Feb 26 at 20:13
This question came from our site for computer enthusiasts and power users.
migrated from superuser.com Feb 26 at 20:13
This question came from our site for computer enthusiasts and power users.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
I would expect you can also combinedesktop
andmidnight
more explicitly with(add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "583"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f48080%2flimit-number-of-files-saved-by-emacs-in-desktop-save%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
I would expect you can also combinedesktop
andmidnight
more explicitly with(add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
add a comment |
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.
I would expect you can also combinedesktop
andmidnight
more explicitly with(add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
add a comment |
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.
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.
answered Feb 26 at 20:24
Willy LeeWilly Lee
33018
33018
I would expect you can also combinedesktop
andmidnight
more explicitly with(add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
add a comment |
I would expect you can also combinedesktop
andmidnight
more explicitly with(add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
I would expect you can also combine
desktop
and midnight
more explicitly with (add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
I would expect you can also combine
desktop
and midnight
more explicitly with (add-hook 'desktop-save-hook 'clean-buffer-list)
– phils
Feb 26 at 21:11
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
Ooh, that's a good idea.
– Willy Lee
Feb 26 at 21:40
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
The midnight mode page also says that, as of about 10 years ago, desktop does not preserve buffer-display-time, which would explain why my code did not usually work.
– Troy Daniels
Feb 26 at 21:53
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f48080%2flimit-number-of-files-saved-by-emacs-in-desktop-save%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown