w3m-session

Introduction

w3m-session (Lisp:w3m-session.el) provides persistent emacs-w3m browsing sessions. When quitting w3m (or, if you request it, at any other time while using it) you can save the current w3m session (that is, the set of open tabs and the URLs they’re visiting). Upon restarting emacs-w3m (possibly after restarting Emacs itself) you’ll have the possibity of recovering the saved session (that is, of re-opening the saved tabs and URLs). You also have at your disposal a command to recover the saved session at any other time. In addition, w3m-session auto-saves periodically your current session, so that you can recover it later on (for instance, after closing Emacs without saving).

Installation

Just put the file somewhere on your Emacs load path and add the following line to your .emacs file:

  (require 'w3m-session)

After restarting Emacs (or evaluating the form above), each time you start emacs-w3m with ‘w3m’ you’ll get a prompt asking whether your last browsing session should be loaded. Likewise, when quitting the browser, you’ll have the possibility of saving your current session (overwriting the previous one).

In addition, two new interactive functions are defined:

  w3m-session-load  --  load the last stored session
  w3m-session-save  --  save the current session
  w3m-session-set-autosave-period -- set the period for autosave (secs)

These functions can be invoked at any time while running emacs-w3m. Optionally, you can bind them to key shortcuts with the proper variations of the following elisp magic in your .emacs:

 (defun w3m-add-keys ()
   (define-key w3m-mode-map "S" 'w3m-session-save)
   (define-key w3m-mode-map "L" 'w3m-session-load))
 (add-hook 'w3m-mode-hook 'w3m-add-keys)

(but remember that those are interactive functions, so you don’t need the shortcuts to use them).

Customization

A new customization group, w3m-session, is available. There you can customize the following variables:

  w3m-session-load-always     -- if t, `w3m-session-load' will *not* ask
                               for confirmation (default nil)
  w3m-session-save-always     -- if t, `w3m-session-load' will *not* ask
                               for confirmation (default nil)
  w3m-session-show-titles     -- if t, the load prompt will list the
                               session URL titles (default t)
  w3m-session-duplicate-tabs  -- what to do when loading a session that
                               contains a URL already open
  w3m-session-file            -- the file where w3m session info
                               is stored (default "~/.w3m-session")
  w3m-session-autosave-period -- the period, in seconds, for automatic
                               session backup file updating.

You can also customize them in your .emacs file, to wit:

  (setq w3m-session-file "~/.emacs.d/w3m-session")
  (setq w3m-session-save-always nil)
  (setq w3m-session-load-always nil)
  (setq w3m-session-show-titles t)
  (setq w3m-session-duplicate-tabs 'ask) ;  'never, 'always, 'ask

3 Responses to “w3m-session”

  1. labsji Says:

    Thanks for the tip. This is something I’ve been looking for. Very thoughtful customization indeed.

  2. piyo Says:

    Thank you for this library.

    At version 0.3.5:
    Regarding byte compiling this file, it seems that (eval-when-compile (require ‘cl)) is necessary, because incf is not defined.


Leave a Reply