[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: frameset-to-register
From: |
Juanma Barranquero |
Subject: |
Re: frameset-to-register |
Date: |
Mon, 5 Aug 2013 15:11:13 +0200 |
On Mon, Aug 5, 2013 at 7:12 AM, Juanma Barranquero <address@hidden> wrote:
> This code adds a new frameset-to-register command.
Or, a bit cleaner:
=== modified file 'lisp/register.el'
--- lisp/register.el 2013-03-26 02:49:05 +0000
+++ lisp/register.el 2013-08-05 12:50:18 +0000
@@ -132,6 +132,20 @@
;; of point in the current buffer, so record that separately.
(set-register register (list (current-frame-configuration) (point-marker))))
+(defun frameset-to-register (register &optional _arg)
+ "Store the current frameset in register REGISTER.
+Use \\[jump-to-register] to restore the frameset.
+Argument is a character, naming the register."
+ (interactive "cFrameset to register: \nP")
+ (set-register register
+ (list (frameset-save nil
+ :filters frameset-live-filter-alist
+ :properties '(:app register))
+ ;; frameset-save does not include the value of point
+ ;; in the current buffer, so record that separately.
+ (frameset-frame-id nil)
+ (point-marker))))
+
(defalias 'register-to-point 'jump-to-register)
(defun jump-to-register (register &optional delete)
"Move point to location stored in a register.
@@ -157,6 +171,14 @@
((and (consp val) (window-configuration-p (car val)))
(set-window-configuration (car val))
(goto-char (cadr val)))
+ ((and (consp val) (frameset-p (car val)))
+ (frameset-restore (car val)
+ :filters frameset-live-filter-alist
+ :reuse-frames t)
+ (let ((frame (frameset-locate-frame-id (cadr val))))
+ (when frame
+ (select-frame-set-input-focus frame)
+ (goto-char (nth 2 val)))))
((markerp val)
(or (marker-buffer val)
(error "That register's buffer no longer exists"))
@@ -269,6 +291,9 @@
((and (consp val) (frame-configuration-p (car val)))
(princ "a frame configuration."))
+ ((and (consp val) (frameset-p (car val)))
+ (princ "a frameset."))
+
((and (consp val) (eq (car val) 'file))
(princ "the file ")
(prin1 (cdr val))