This article was originally published as a blog entry at http://alweb.dk/blog/anders/kate_named_sessions and is now donated to this website.
The biggest change in Kate (http://kate.kde.org, http://www.kate-editor.org) in the KDE 3.5 series is definitely the introduction of named sessions. Instead of defaulting to one instance, Kate now as a standard allows you to run many instances.
And not even that, it will allow you to keep those sessions, with the list of open files as well as the instance specific GUI configuration. This is a big change in behavior, but once you get used to it, you will hopefully appreciate the benefits.
If not, it is still possible to restore the old-style kate behavior by utilizing the various related commandline and configuration options. You will of course loose at least some of the advantages of named settings, but if you desire keeping things as they were, you probably do not care a lot.
Because this is new, there are of course problems and unforeseen issues. Due to busyness with real life, I have not had a chance to get much into named sessions prior to the KDE 3.5/Kate 2.5 release, but I have been working hard on enhancing the named sessions experience for KDE 3.5.1/Kate 2.5.1 and upwards.
Read on for more about how it works, what have been fixed so far and some ideas for future improvements.
Basically, a Kate session is a instance of the application with its own set of open documents and its own window setup (toolbars, toolviews, editor frame[s]). The session can be named and saved with the file list and optional the window setup, so that it can easily be restored again.
If you edit a lot of text files for different purposes, such sessions can make your life much easier. I for example have sessions for various websites I maintain and for my various KDE related projects. When I want to work on a project, I open the session and have the setup as I left it last time I used it. For one thing, the named sessions feature will obsolete the filelist loader plug-in that some of you may have used.
You can create a new session in many ways:
--start <New session name>. If the session with the specified name does not exist, it is created.
There are equally easy ways to open a session once you have some:
kate --start YourSession in the exec property)If I want to open one or more files and forget about them again, I can just open then in an anonymous session which will not be saved.
If I want to add files to a running session from outside, I can use command line options to do so. In Kate 2.5 that means any running instance (—use) or an instance selected by its process ID (PID) (—use —pid PID).
Kate saves your sessions pr. default, but you can have it ask you or not save sessions if that suits your work flow better (I’m personally happy with this default, although i sometimes forgets to close some files that I’m done with).
As indicated above, Kate has tree new command line options to support named sessions:
-s, --start <name>--use so that when both is specified only the specified session will be reused, if it is not running it will be started or created.-u, --use--pid <PID> (or, in the future, --start >name<) the first instance found by DCOP (the one with the lowest PID) will be used.-p, --pid <pid>Sessions have gotten their own panel in Kate’s configuration dialog, with so far tree options allowing you to tweak the behavior.
Many users have grown accustomed to the old style behavior, where Kate would run only one instance and all files would be forwarded to that instance. We know from the bugs database (http://bugs.kde.org) and mailling list (http://lists.kde.org/?l=kwrite-devel) that many users got a bit confused when kate didn’t behave as usual, and given the lack of warning and documentation of the new behavior that is not suprising.
To restore the old style behavior, you can follow this strategy:
kate --use %U--use automatically. If you use bash as your shell, add something like alias kate="kate --use" to your ~/.bashrc file.Be warned though that until KDE 3.5.1 is released (soon!) you will experience some problems with this: when opening files from the KDE environment with --use, you get a KIO error about not being able to launch kate. As indicated, this has been fixed in the 3.5 branch of KDE and if you compile KDE yourself, get this version of the kdebase module to fix those problems.
I have tried to do a few improvements in Kate 2.5.1 because there is quite some time until we get to KDE 4. Most are really bug fixes, although mostly for unreported issues. Many but not all are related to named sessions.
Improvements include
--start <name> will work with --use.kdeinit not being able to launch kate is history.A very obvious step is to include more configurations in the session data. This could include
In Kate 2.5.1 the pid is exported to the environment variable KATE_PID so that you can alias kate with kate -up $KATE_PID if that is set, in Kate 2.5.2 this will not be nessecary anymore, Kate will automatically select the current instance if the KATE_PID variable is set.
One thing that has lead to quite a few complaints is the removal of the project support in Kate. This came as a suprise to us developers, as we all found the project support very poor, but it appears that it has been used and appreciated by quite a few users. Adding project support on the top of named sessions would be good, and I am considering how it can be done in a nice and flexible way. My own demands are that any file can be a member of a project, and I would like to see some sort of project type that would support various commands such as building software, synchronizing directories etc.
Comments
Sessions - Editor Component
Would it be possible/practical for the Editor Component options be part of the Sessions settings so that different sessions can have their own editor settings ?
The removed project feature...
First I want to underline, that I’m very happy about all that work being done by open source workers, last not least by all working at kate.
But the removal of the project feature was really a decision being much poorer than the feature has been itself. I know, it wasn’t ever a serious programming project management component, but it was much better than nothing. Currently there is nothing but some plugin attempts wich could run as replacement for this old project feature.
What I need for my software projects is full control over all project files: some source code files within several folders, some makefiles, that’s it. I don’t want nor need those confusing, complex and oversized project files and mechanisms like added by kdevelop. Just search and make calls being needed, and fortune, if their filename-line-outputs via double-click automatically lead into the sourcecode files itself. I just need fast access to some files I manually added to the project. Not all to be opened, there are too much. But only these project files within the project list.
And that leads me to the reason why I write this comment: I feel, that there is not much enough thinking about the right place for configuration around. In general, not only concerning Kate.
I work within folders and subfolders, and these mostly contain files being concerned to one or some of my projects, software or other, and there are typical file formats used, and a set of tools like Kate being used for these files and projects. Often the special surface version of these tools differs from project to project, depending on its type. And, last the main point for me, most of those my file based projects I save into an versioning system like SVN. I end working by checking in, and start by checking out the project - but mostly in the mean time I change my location, thanks to the intranets and last not least the internet I can work where ever I am. The only thing is, that often I can’t start exactly where I ended my work, because settings are not saved project-depentent.
To save configuration (with, possibly, locally used plugins!) can lead to unsafety. Maybe there should be started some thinking about renewed old concepts. Configuration XML-based into the folders, but optionally encoded, decoding combined with commands to the access rights possibilities of the used OS, and possibly combined with the current user login data. Have a look at the boom of so-called “portable apps” (wich better should be called transportable apps), there is some need for those solutions.
nicely explained
the idea behind sessions seems great, but until they are seamless and fully understood by users, they really degrade overall impression of kate. i really think we need to give users the choice by adding “turn on sessions” in the kate settings. if this is off, then the session menu should disappear and kate should open only one instance. i think sessions should be off by default.
Thanks for this awesome
Thanks for this awesome feature, which is now indispensable; I can’t imagine using any other editor unless it had this facility. I’d been using Debian Sarge with an older version of Kate for much too long past its sell-by date and was looking forward to using the new Kate 2.5.5 once I upgraded. I am seriously impressed and it does everything I could wish for :-) I now have 5+ instances of Kate loading up automatically at boot time with my most important sessions, and others are easily loadable when needed.Thank you very much for this information.
Still not clear how sessions work
Sorry, maybe I am too stupid, but I still haven’t understood how sessions work. I have heard that they are very useful and I thought, I can save my text files related to project A, B, C… separately. In fact, all files are mixed up and most are empty after a certain period of time. Sometimes I create a new session and later I found out that I have overwritten an existing text (the window was empty but once there have been text).
All the desciption is too technical and I still don’t know how it works and how to use it. Sorry, but as most features in KDE: Sounds nice, but not usable.
Kate is a goddess!
Thanks for this awesome feature, which is now indispensable; I can’t imagine using any other editor unless it had this facility. I’d been using Debian Sarge with an older version of Kate for much too long past its sell-by date and was looking forward to using the new Kate 2.5.5 once I upgraded. I am seriously impressed and it does everything I could wish for :-) I now have 5+ instances of Kate loading up automatically at boot time with my most important sessions, and others are easily loadable when needed.
Cheers, Malcolm Smith
How to remove saved session
Hello I didn’t find how to remove saved session from session list?
site
Your drupal site is nice but I can’t get to the 2nd page of articles. It just gives me a blank page. With Developers nd HOWTO’s Hardly worth signing up to the bugs list. Hal
Reusing Windows
The whole idea of sessions is just great, but I personally found it poorly implemented. Why the sessions aren’t update automatically, just when I save them ? We could at least have a way to NOT open a new window everytime I call kate from the command line and ask it to use an existing session. It’d be the best of both worlds, the old one, where I could simply call kate lots of times and it’d just keep adding documents to the open kate window, and the new one, where I could have this behaviour done on a session basis.
Kate Project was very different from session !!!
Doesn’t matter if only few people use kate’s projects… It was very very stupid to remove that feature !! Because now, there is no alternative for people like me that use kate’s projects… becuase Session are completly different !! There’s no common points !! I’m starting using Kate only because kate’s project feature !!! Because it was so simple and efficient !! If somethings is poor doesn’t imply that is useless !!
Are all my kateproject files useless???
I have been using kate to edit my R scripts for statistical analysis of many research projects. For each separate experiment I could add the data files and several separate scripts together as a .kateproject. I had just become quite efficient getting things done in this manner. Was all of this for nothing? Do I have to now create a named session for each one of these projects? and open them up by name at the command line???
I really hope this functionality can be restored. Until then I will have to once again search for a good R script editor…
This is all very well...
…but I liked restricting kate to a single session. For one thing, it meant that I could bring up the instance of Kate I was using with its appropriate KDE keyboard shortcut (such as CTRL+ALT+K), rather than Alt-tabbing my way through a program list. For another, it meant I could type
into a console to open every file matching that pattern in an existing Kate session. Wonderful little tool, but since I upgraded Kubuntu to Dapper yesterday, apparently it’s no longer useful.