Changeset - c584e55ee1e7
[Not reviewed]
0 2 0
Sergey Pashinin - 13 years ago 2013-05-07 02:26:32
sergey@pashinin.com
new var wg-restore-remote-buffers - restore remote dirs or not
2 files changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/workgroups-specialbufs.el
Show inline comments
 
;;; special buffer serdes functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;
 
;; TODO: Possibly add restore-special-data customization option
 
;; TODO: These could be a little more thorough
 
;;
 

	
 
(require 'dflet)
 
(require 'workgroups-misc)
 

	
 
;; Dired
 

	
 
(defun wg-deserialize-dired-buffer (buf)
 
  "Deserialize Dired buffer."
 
  (wg-dbind (this-function params) (wg-buf-special-data buf)
 
    (let ((dir (car params)))
 
      (if (file-exists-p dir)
 
          (dired dir))
 
      (if (or wg-restore-remote-buffers (not (wg-is-file-remote dir)))
 
          (if (file-exists-p dir)
 
              (dired dir)))
 
      (current-buffer))))
 

	
 
(defun wg-serialize-dired-buffer (buffer)
 
  "Serialize Dired buffer."
 
  (with-current-buffer buffer
 
    (when (eq major-mode 'dired-mode)
 
      (list 'wg-deserialize-dired-buffer
 
            (wg-take-until-unreadable (list (or (buffer-file-name) default-directory)))
 
            ))))
 

	
 
;; Info buffer serdes
 

	
 
(defun wg-deserialize-Info-buffer (buf)
 
  "Deserialize an Info buffer."
 
  (require 'info)
 
  (wg-aif (cdr (wg-buf-special-data buf))
 
      (apply #'Info-find-node it)
 
    (info))
 
  (current-buffer))
 

	
 
(defun wg-serialize-Info-buffer (buffer)
 
  "Serialize an Info buffer."
 
  (with-current-buffer buffer
 
    (when (eq major-mode 'Info-mode)
 
      (wg-when-boundp (Info-current-file Info-current-node)
 
        (list 'wg-deserialize-Info-buffer
 
              Info-current-file
 
              Info-current-node)))))
 

	
 

	
 
;; help buffer serdes
 

	
 
(defun wg-deserialize-help-buffer (buf)
 
  "Deserialize a help buffer.
 
See `wg-serialize-help-buffer'."
 
  (require 'help-mode)
 
  (wg-dbind (this-function item stack forward-stack) (wg-buf-special-data buf)
 
    (condition-case err
 
        (apply (car item) (cdr item))
 
      (error (message "%s" err)))
 
    (wg-awhen (get-buffer "*Help*")
 
      (set-buffer it)
 
      (wg-when-boundp (help-xref-stack help-xref-forward-stack)
 
        (setq help-xref-stack stack
 
              help-xref-forward-stack forward-stack))
 
      (current-buffer))))
 

	
 
(defun wg-serialize-help-buffer (buffer)
src/workgroups-variables.el
Show inline comments
 
@@ -195,96 +195,104 @@ necessary to properly restore the original value of the variable.
 
For example, in the case of `major-mode' it should funcall the
 
value (a major-mode function symbol) rather than just assigning
 
it to `major-mode'."
 
  :type 'alist
 
  :group 'workgroups)
 

	
 
(defcustom wg-special-buffer-serdes-functions
 
  '(wg-serialize-Info-buffer
 
    wg-serialize-dired-buffer
 
    wg-serialize-org-agenda-buffer
 
    wg-serialize-help-buffer
 
    wg-serialize-ielm-buffer
 
    wg-serialize-shell-buffer
 
    wg-serialize-eshell-buffer
 
    wg-serialize-term-buffer
 
    wg-serialize-magit-buffer
 
    )
 
  "List of functions providing special buffer serialization/deserialization.
 
An entry should be either a function symbol or a lambda, and should
 
accept a single Emacs buffer object as an argument.
 

	
 
When a buffer is to be serialized, it is passed to each of these
 
functions in turn until one returns non-nil, or the list ends.  A
 
return value of nil indicates that the function can't handle
 
buffers of that type.  A non-nil return value indicates that it
 
can.  The first non-nil return value becomes the buffer's special
 
serialization data.  The return value should be a cons, with a
 
deserialization function (a function symbol or a lambda) as the car,
 
and any other serialization data as the cdr.
 

	
 
When it comes time to deserialize the buffer, the deserialization
 
function (the car of the cons mentioned above) is passed the
 
wg-buf object, from which it should restore the buffer.  The
 
special serialization data itself can be accessed
 
with (cdr (wg-buf-special-data <wg-buf>)).  The deserialization
 
function must return the restored Emacs buffer object.
 

	
 
See the definitions of the functions in this list for examples of
 
how to write your own."
 
  :type 'alist
 
  :group 'workgroups)
 

	
 
(defcustom wg-default-buffer "*scratch*"
 
  "Buffer made visible a window when the window's actual buffer
 
can't be restored.  Also used when a blank workgroup is created."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
;; What to restore:
 

	
 
(defcustom wg-restore-remote-buffers t
 
  "nil means do not restore buffers that get \"t\" with
 
`wg-is-file-remote'"
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-associated-buffers t
 
  "Non-nil means restore all buffers associated with the
 
workgroup on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-frame-position nil
 
  "Non-nil means restore frame position on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-scroll-bars t
 
  "Non-nil means restore scroll-bar settings on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-fringes t
 
  "Non-nil means restore fringe settings on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-margins t
 
  "Non-nil means restore margin settings on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-point t
 
  "Non-nil means restore `point' on workgroup restore.
 
This is included mainly so point restoration can be suspended
 
during `wg-morph' -- you probably want this non-nil."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-point-max t
 
  "Controls point restoration when point is at `point-max'.
 
If `point' is at `point-max' when a wconfig is created, put
 
`point' back at `point-max' when the wconfig is restored, even if
 
`point-max' has increased in the meantime.  This is useful in,
 
say, irc buffers where `point-max' is constantly increasing."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-mark t
 
  "Non-nil means restore mark data on workgroup restore."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-restore-window-dedicated-p t
0 comments (0 inline, 0 general)