Giter VIP home page Giter VIP logo

desktop-plus's Introduction

desktop+

Build-Status Coverage-Status Tag MELPA License

desktop+ extends desktop by providing more features related to sessions persistance.

  1. Instead of relying on Emacs' starting directory to choose the session Emacs restarts, sessions are manipulated by name. All information about them is stored into a centralized directory.

  2. Desktop sessions by default save only buffers associated to "real" files. Desktop+ extends this by handling also "special buffers". The list of currently supported special buffer types is:

    • compilation buffers (in compilation-mode)
    • terminal buffers (in term-mode)
    • org agenda & todo lists (in org-agenda-mode)
    • indirect buffers (a.k.a clones).
    • man pages (in Man-mode)
    • shell buffers (in shell-mode)

Installation

desktop+ can be found on MELPA and it's the recommended way of installing it.

Otherwise, you can install it manually. First install desktop+ dependencies: dash and f. Then:

  1. clone the git repository:

    $ git clone https://github.com/ffevotte/desktop-plus.git
  2. tell emacs where to find it, for example by adding a snippet like this in your init.el file:

    (add-to-list 'load-path "/path/to/desktop-plus")
    (require 'desktop+)

Usage

From Emacs

Named sessions

Two functions are defined to manipulate desktop sessions by name:

  • desktop-create: create a new session and give it a name.

  • desktop-load: change the current session; the new session to be loaded is identified by its name, as given during session creation using desktop-create. The currently active session is identified in the title bar.

As a special case, if the session name is left blank when calling one of these two functions, a name is automatically derived from the current working directory (see "Auto-named sessions" below).

Once created or loaded, sessions are automatically saved when exiting emacs or changing session.

Auto-named sessions

It is also possible to create and load sessions without explicitly specifying a name. These sessions are then automatically named after the current working directory. This can be done either by leaving the session name blank when calling desktop-create or desktop-load, or by using their dedicated counterparts:

  • desktop-create-auto: create a new auto-named session.

  • desktop-load-auto: load a previously created auto-named session.

From the shell command-line

If you want to invoke Emacs from the command-line and specify a session to load at startup, you can define the following useful bash function:

function emacs-desktop () {
  emacs --eval '(desktop-load "'"$1"'")'
}

You can then invoke a named session directly from the command-line:

$ emacs-desktop my-session

or an auto-named session:

$ cd /path/to/working/directory
$ emacs-desktop

Customization

  • desktop+-base-dir: directory where all information about desktop sessions are stored. The default value is "~/.emacs.d/desktops/".

  • desktop+-frame-title-function: function called to get the new frame title format when the session changes. This function must take the desktop session name as a string argument and return a frame title format suitable for setting frame-title-format.

    Customize it to change the way session names are displayed. For example:

    (defun my/desktop-frame-title-function (desktop-name)
      (list (concat "%b - Emacs [" desktop-name "]")))
    
    (setq desktop+-frame-title-function
          'my/desktop-frame-title-function)
  • desktop+-special-buffer-handlers: list of special buffer types which should be handled specially. The default value contains all known types. You can remove some of them if you want.

    ;; remove items from the list if you don't want a specific special buffer
    ;; type to be handled.
    ;;
    ;; The value of this variable should be changed before `desktop+` is loaded.
    (setq desktop+-special-buffer-handlers
          '(term-mode
            compilation-mode
            org-agenda-mode
            indirect-buffer
            Man-mode
            shell-mode))

API

  • (desktop+-add-handler NAME PRED SAVE-FN LOAD-FN)

    Add handlers for special buffers.

    NAME is a symbol identifying the handler for later activation or deactivation.

    PRED should be a unary function used as a predicate to determine whether a buffer should be handled specially. When called in a buffer which should be handled, PRED should return non-nil.

    SAVE-FN should be a function taking no parameter, returning a list of all relevant parameters for the current buffer, which is assumed to be in the given major mode.

    LOAD-FN should be a function of the form (lambda (name &rest args) ...) allowing to restore a buffer named NAME in major mode MODE, from information stored in ARGS, as determined by SAVE-FN..

Contributing

If you make improvements to this code or have suggestions, please do not hesitate to fork the repository or submit bug reports on github. The repository's URL is:

https://github.com/ffevotte/desktop-plus.git

Contributors

  • Dryvenn introduced auto-named sessions;
  • Brian Malehorn contributed Man-mode and shell-mode buffers handling.

Thanks!

License

Copyright (C) 2014-2017 François Févotte.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

desktop-plus's People

Contributors

bmalehorn avatar ffevotte avatar syohex avatar yveoch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

desktop-plus's Issues

missing desktop-load

The documentation says that, after installing desktop+, I should be able to call the functions:

desktop-create:
desktop-load

However, only desktop-create exists.

After I install desktop+, I see only these desktop* functions
image

Should I really be using the desktop+* functions?

This is on GNU Emacs 25.1.1 (i686-w64-mingw32) of 2016-11-16 (windows 10) and having installed elpa/desktop+-20170107.1332

Note: Before I install desktop+, I see these desktop* functions
image

Also save repl

Hello!
I'm using racket-repl-mode pretty often. I've tried to add it to desktop+-special-buffer-handlers, but to no avail - racket-REPL buffers are simply lost upon loading a session using desktop+. What changes should be added to my .emacs to also save racket-REPL (and possibly other similar, e.g. SLIME) buffers in the session?..

Is there a way to prevent flycheck to check buffers that are not on when restoring?

I'm currently using desktop and have the issue described in the title. I just stumbled on this package and am willing to give it a try as the features will be useful.

However I'm hoping this package has (more) control over the behavior when restoring sessions.

I was thinking of:

  1. Prevent flycheck checks when buffers are created as restoring is occurring
  2. Call flycheck-buffer for each visible buffers once restoring has finished

Is 1. possible with desktop-plus? ie. detect that the session is being restored and temporarily remove mode-enabled from flycheck-check-syntax-automatically

Use ido-mode when loading a desktop

Use ido-mode for selection of desktop names. When loading a desktop it would be nice to get completions/search from ido. This would make available desktops easily visible in the modeline and allows faster selection.

How to save and restore a desktop in emacs?

Whatever desktop I save, after restarting emacs it's lost. What settings are required to simply reload one python (.py) buffer and a terminal (anyone is fine e.g. term, multiterm, ansi, eshell etc.) beside?

My workflow:

  1. Open file (sample.py)
  2. Open terminal
  3. m-x desktop+-create 'foo'
  4. Restart emacs after some time and doing anything else
  5. m-x desktop+-load (select foo in minibuffer)
  6. Get a completely different desktop than created in step 3

'(desktop-save nil) in init.el makes no difference

auto save

As far as I understand (adn experienced), desktop-plus only saves when exiting emacs or switching desktops. Is it possible to save more frequently, eg every 10 mins or on auto-save-hook or similar? Thank you very much!

Open desktop session by name from command line?

Hello! Excellent package you've done. Is there a way to load a desktop session by name form the command line? Something like:

emacs --eval "(desktop-load my-session-name)"

I am no lisp expert.

Thanks!

org mode agenda view isn't loaded

I've created a new desktop with 4 frames. However, my agenda view dispatcher doesn't get loaded.
I suppose it should work, shouldn't it?

desktop+ not saving term/shell buffer

I was happy with inbuilt desktop but it could not retain the term/shell buffers. Everytime I quit emacs, it asks to kill the term/shells. Then I read the ability of desktop+ to retain the term/shell and installed it M-x package-install after going through the github doc.
I have removed the line desktop-save-mode from init file.

I have 2 questions-

  1. In new emacs session (having shell windows), I saved the session with desktop+create, verified its existence on the disk, but when quitting emacs, in minibuffer, I still get the same message as with desktop (to kill the running processes i.e. the term/shell buffers).
    How can I retain the session shell windows as mentioned in the doc?

  2. Another question is that I need to desktop+load after opening emacs to load the session even of the default dir. What can I add in the init file to load the default session and not a blank emacs. I tried desktop+-save-mode 1 as mentioned in the github page but this gives as error in the init file.
    Even puttting (require 'desktop+) does not load the saved session.

Deletion of desktops

It would be nice to have a feature to delete desktops. Currently one can create new desktops and load them, but to delete them one has to manually delete the corresponding folder.
I've tried the function desktop-remove but this only removes the desktop file and not the folder or the other files therein. As a consequence desktop+-load still shows the (now deleted) desktop, but can't restore the buffers.

[win7] "can't find .emacs.buffers" error

I've had this problem on windows 7. The path to the file was garbled with '//', which clearly prevented .emacs.buffers from loading. This simple fix did the trick:

(defun desktop+--buffers-file ()
(concat desktop-dirname ".emacs-buffers"))

Is it a bug in your original desktop+--buffers-file?

Next release?

Hi,

I would like to package desktop-plus for Gentoo.

Could you please tag a new release? The latest one seems to be quite outdated.

Save indirect buffers

Would it be also possible to save indirect buffers? I use those a lot with large org files, often having several indirect buffers open, but currently this extension only saves the main buffer.

Missing .emacs-buffers file

Desktop+ works the first time after I install it, but then breaks because it can't find a .emacs-buffers file.

Immediately after I install desktop+, I can use desktop+-create to save a configuration, kill emacs, and then reload the config with desktop+-load. This works perfectly.

However, if I save a new configuration, kill emacs, and then try to reload the first confguration, then I get the error message:

image

After that I can't create or load sessions until I uninstall/reinstall desktop+ and also delete .emacs.d/desktops.

This is on GNU Emacs 25.1.1 (i686-w64-mingw32) of 2016-11-16 (windows 10) and having installed elpa/desktop+-20170107.1332

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.