emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

frameset-to-register


From: Juanma Barranquero
Subject: frameset-to-register
Date: Mon, 5 Aug 2013 07:12:23 +0200

This code adds a new frameset-to-register command.

Assuming that it is OK to install it, keybindings in the C-x r space
are scarce. I propose to bind it to C-x r F, which is already co-opted
by frame-configuration-to-register (via C-x r f) and seems mnemonic
enough.

   Juanma




=== modified file 'lisp/register.el'
--- lisp/register.el    2013-03-26 02:49:05 +0000
+++ lisp/register.el    2013-08-05 05:07:08 +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.
+                     (frame-parameter nil 'frameset--id)
+                     (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,18 @@
      ((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)
+      ;; At this point, cl-lib is loaded via frameset.el
+      (let ((frame (cl-find-if (lambda (f)
+                                (string= (frame-parameter f 'frameset--id)
+                                         (cadr val)))
+                              (frame-list))))
+       (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 +295,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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]