diff options
| author | Juanma Barranquero | 2013-08-08 02:44:22 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2013-08-08 02:44:22 +0200 |
| commit | 2805a6512b464d65d8d8b00a126cde61a08cc291 (patch) | |
| tree | 8db9be44f1f3fc3ed07ba699d93a3eb6600bc842 | |
| parent | a912c0163d1f6fac4d443522b712169c6d31b523 (diff) | |
| download | emacs-2805a6512b464d65d8d8b00a126cde61a08cc291.tar.gz emacs-2805a6512b464d65d8d8b00a126cde61a08cc291.zip | |
* lisp/bindings.el (ctl-x-r-map): Bind ?f to frameset-to-register.
* lisp/register.el: Add support for framesets.
(frameset-frame-id, frameset-frame-with-id)
(frameset-p, frameset-restore, frameset-save): Declare.
(register-alist): Document framesets.
(frameset-session-filter-alist): Declare.
(frameset-to-register): New function.
(jump-to-register): Implement jumping to framesets. Doc fix.
(describe-register-1): Describe framesets.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/bindings.el | 2 | ||||
| -rw-r--r-- | lisp/register.el | 45 |
3 files changed, 54 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 93c10d858e7..9f492ae0ac4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-08-08 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | * register.el (frameset-frame-id, frameset-frame-with-id) | ||
| 4 | (frameset-p, frameset-restore, frameset-save): Declare. | ||
| 5 | (register-alist): Document framesets. | ||
| 6 | (frameset-session-filter-alist): Declare. | ||
| 7 | (frameset-to-register): New function. | ||
| 8 | (jump-to-register): Implement jumping to framesets. Doc fix. | ||
| 9 | (describe-register-1): Describe framesets. | ||
| 10 | |||
| 11 | * bindings.el (ctl-x-r-map): Bind ?f to frameset-to-register. | ||
| 12 | |||
| 1 | 2013-08-07 Juanma Barranquero <lekktu@gmail.com> | 13 | 2013-08-07 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 14 | ||
| 3 | * desktop.el (desktop-save-frameset): Use new frameset-save args. | 15 | * desktop.el (desktop-save-frameset): Use new frameset-save args. |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 005e43b3059..2ea6713216d 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -1220,7 +1220,7 @@ if `inhibit-field-text-motion' is non-nil." | |||
| 1220 | (define-key map "n" 'number-to-register) | 1220 | (define-key map "n" 'number-to-register) |
| 1221 | (define-key map "+" 'increment-register) | 1221 | (define-key map "+" 'increment-register) |
| 1222 | (define-key map "w" 'window-configuration-to-register) | 1222 | (define-key map "w" 'window-configuration-to-register) |
| 1223 | (define-key map "f" 'frame-configuration-to-register) | 1223 | (define-key map "f" 'frameset-to-register) |
| 1224 | map) | 1224 | map) |
| 1225 | "Keymap for subcommands of C-x r.") | 1225 | "Keymap for subcommands of C-x r.") |
| 1226 | (define-key ctl-x-map "r" ctl-x-r-map) | 1226 | (define-key ctl-x-map "r" ctl-x-r-map) |
diff --git a/lisp/register.el b/lisp/register.el index 4876c614642..84305f71d03 100644 --- a/lisp/register.el +++ b/lisp/register.el | |||
| @@ -31,6 +31,12 @@ | |||
| 31 | 31 | ||
| 32 | (eval-when-compile (require 'cl-lib)) | 32 | (eval-when-compile (require 'cl-lib)) |
| 33 | 33 | ||
| 34 | (declare-function frameset-frame-id "frameset" (frame)) | ||
| 35 | (declare-function frameset-frame-with-id "frameset" (id &optional frame-list)) | ||
| 36 | (declare-function frameset-p "frameset" (frameset)) | ||
| 37 | (declare-function frameset-restore "frameset" (frameset &rest keys) t) | ||
| 38 | (declare-function frameset-save "frameset" (frame-list &rest keys) t) | ||
| 39 | |||
| 34 | ;;; Code: | 40 | ;;; Code: |
| 35 | 41 | ||
| 36 | (cl-defstruct | 42 | (cl-defstruct |
| @@ -71,7 +77,9 @@ A list of the form (file-query FILE-NAME POSITION) represents | |||
| 71 | A list of the form (WINDOW-CONFIGURATION POSITION) | 77 | A list of the form (WINDOW-CONFIGURATION POSITION) |
| 72 | represents a saved window configuration plus a saved value of point. | 78 | represents a saved window configuration plus a saved value of point. |
| 73 | A list of the form (FRAME-CONFIGURATION POSITION) | 79 | A list of the form (FRAME-CONFIGURATION POSITION) |
| 74 | represents a saved frame configuration plus a saved value of point.") | 80 | represents a saved frame configuration plus a saved value of point. |
| 81 | A list of the form (FRAMESET FRAME-ID POSITION) | ||
| 82 | represents a saved frameset plus the value of point in frame FRAME-ID.") | ||
| 75 | 83 | ||
| 76 | (defgroup register nil | 84 | (defgroup register nil |
| 77 | "Register commands." | 85 | "Register commands." |
| @@ -132,16 +140,32 @@ Argument is a character, naming the register." | |||
| 132 | ;; of point in the current buffer, so record that separately. | 140 | ;; of point in the current buffer, so record that separately. |
| 133 | (set-register register (list (current-frame-configuration) (point-marker)))) | 141 | (set-register register (list (current-frame-configuration) (point-marker)))) |
| 134 | 142 | ||
| 143 | (defvar frameset-session-filter-alist) | ||
| 144 | |||
| 145 | (defun frameset-to-register (register &optional _arg) | ||
| 146 | "Store the current frameset in register REGISTER. | ||
| 147 | Use \\[jump-to-register] to restore the frameset. | ||
| 148 | Argument is a character, naming the register." | ||
| 149 | (interactive "cFrameset to register: \nP") | ||
| 150 | (set-register register | ||
| 151 | (list (frameset-save nil | ||
| 152 | :app 'register | ||
| 153 | :filters frameset-session-filter-alist) | ||
| 154 | ;; frameset-save does not include the value of point | ||
| 155 | ;; in the current buffer, so record that separately. | ||
| 156 | (frameset-frame-id nil) | ||
| 157 | (point-marker)))) | ||
| 158 | |||
| 135 | (defalias 'register-to-point 'jump-to-register) | 159 | (defalias 'register-to-point 'jump-to-register) |
| 136 | (defun jump-to-register (register &optional delete) | 160 | (defun jump-to-register (register &optional delete) |
| 137 | "Move point to location stored in a register. | 161 | "Move point to location stored in a register. |
| 138 | If the register contains a file name, find that file. | 162 | If the register contains a file name, find that file. |
| 139 | \(To put a file name in a register, you must use `set-register'.) | 163 | \(To put a file name in a register, you must use `set-register'.) |
| 140 | If the register contains a window configuration (one frame) or a frame | 164 | If the register contains a window configuration (one frame) or a frameset |
| 141 | configuration (all frames), restore that frame or all frames accordingly. | 165 | \(all frames), restore that frame or all frames accordingly. |
| 142 | First argument is a character, naming the register. | 166 | First argument is a character, naming the register. |
| 143 | Optional second arg non-nil (interactively, prefix argument) says to | 167 | Optional second arg non-nil (interactively, prefix argument) says to |
| 144 | delete any existing frames that the frame configuration doesn't mention. | 168 | delete any existing frames that the frameset doesn't mention. |
| 145 | \(Otherwise, these frames are iconified.)" | 169 | \(Otherwise, these frames are iconified.)" |
| 146 | (interactive "cJump to register: \nP") | 170 | (interactive "cJump to register: \nP") |
| 147 | (let ((val (get-register register))) | 171 | (let ((val (get-register register))) |
| @@ -157,6 +181,16 @@ delete any existing frames that the frame configuration doesn't mention. | |||
| 157 | ((and (consp val) (window-configuration-p (car val))) | 181 | ((and (consp val) (window-configuration-p (car val))) |
| 158 | (set-window-configuration (car val)) | 182 | (set-window-configuration (car val)) |
| 159 | (goto-char (cadr val))) | 183 | (goto-char (cadr val))) |
| 184 | ((and (consp val) (frameset-p (car val))) | ||
| 185 | (let ((iconify-list (if delete nil (frame-list))) | ||
| 186 | frame) | ||
| 187 | (frameset-restore (car val) | ||
| 188 | :filters frameset-session-filter-alist | ||
| 189 | :reuse-frames (if delete t :keep)) | ||
| 190 | (mapc #'iconify-frame iconify-list) | ||
| 191 | (when (setq frame (frameset-frame-with-id (cadr val))) | ||
| 192 | (select-frame-set-input-focus frame) | ||
| 193 | (goto-char (nth 2 val))))) | ||
| 160 | ((markerp val) | 194 | ((markerp val) |
| 161 | (or (marker-buffer val) | 195 | (or (marker-buffer val) |
| 162 | (error "That register's buffer no longer exists")) | 196 | (error "That register's buffer no longer exists")) |
| @@ -269,6 +303,9 @@ The Lisp value REGISTER is a character." | |||
| 269 | ((and (consp val) (frame-configuration-p (car val))) | 303 | ((and (consp val) (frame-configuration-p (car val))) |
| 270 | (princ "a frame configuration.")) | 304 | (princ "a frame configuration.")) |
| 271 | 305 | ||
| 306 | ((and (consp val) (frameset-p (car val))) | ||
| 307 | (princ "a frameset.")) | ||
| 308 | |||
| 272 | ((and (consp val) (eq (car val) 'file)) | 309 | ((and (consp val) (eq (car val) 'file)) |
| 273 | (princ "the file ") | 310 | (princ "the file ") |
| 274 | (prin1 (cdr val)) | 311 | (prin1 (cdr val)) |