Commit 4b117065 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/frameset.el: Stop using obsolete registerv objects

(frameset-register): New type.
(register-val-jump-to): Define on this new type, replacing
frameset--jump-to-register.
(register-val-describe): Define on this new type, replacing
frameset--print-register.
(frameset-to-register): Use new frameset-make-register.
(frameset--reuse-frame): η-reduce.
parent dd5ea0a0
Pipeline #1819 failed with stage
in 25 seconds
......@@ -970,8 +970,7 @@ is the parameter alist of the frame being restored. Internal use only."
;; that frame has already been loaded (which can happen after
;; M-x desktop-read).
(setq frame (frameset--find-frame-if
(lambda (f id)
(frameset-frame-id-equal-p f id))
#'frameset-frame-id-equal-p
display (frameset-cfg-id parameters)))
;; If it has not been loaded, and it is not a minibuffer-only frame,
;; let's look for an existing non-minibuffer-only frame to reuse.
......@@ -1350,15 +1349,17 @@ All keyword parameters default to nil."
;; Register support
;;;###autoload
(defun frameset--jump-to-register (data)
"Restore frameset from DATA stored in register.
Called from `jump-to-register'. Internal use only."
(cl-defstruct (frameset-register
(:constructor nil)
(:constructor frameset-make-register (frameset frame-id point)))
frameset frame-id point)
(cl-defmethod register-val-jump-to ((data frameset-register) arg)
(frameset-restore
(aref data 0)
(frameset-register-frameset data)
:filters frameset-session-filter-alist
:reuse-frames (if current-prefix-arg t 'match)
:cleanup-frames (if current-prefix-arg
:reuse-frames (if arg t 'match)
:cleanup-frames (if arg
;; delete frames
nil
;; iconify frames
......@@ -1371,20 +1372,21 @@ Called from `jump-to-register'. Internal use only."
('ignored (delete-frame frame))))))
;; Restore selected frame, buffer and point.
(let ((frame (frameset-frame-with-id (aref data 1)))
(let ((frame (frameset-frame-with-id (frameset-register-frame-id data)))
(marker (frameset-register-point data))
buffer window)
(when frame
(select-frame-set-input-focus frame)
(when (and (buffer-live-p (setq buffer (marker-buffer (aref data 2))))
(when (and (buffer-live-p
(setq buffer (marker-buffer marker)))
(window-live-p (setq window (get-buffer-window buffer frame))))
(set-frame-selected-window frame window)
(with-current-buffer buffer (goto-char (aref data 2)))))))
(with-current-buffer buffer (goto-char marker))))))
;;;###autoload
(defun frameset--print-register (data)
(cl-defmethod register-val-describe ((data frameset-register) _verbose)
"Print basic info about frameset stored in DATA.
Called from `list-registers' and `view-register'. Internal use only."
(let* ((fs (aref data 0))
(let* ((fs (frameset-register-frameset data))
(ns (length (frameset-states fs))))
(princ (format "a frameset (%d frame%s, saved on %s)."
ns
......@@ -1400,16 +1402,14 @@ Argument is a character, naming the register.
Interactively, reads the register using `register-read-with-preview'."
(interactive (list (register-read-with-preview "Frameset to register: ")))
(set-register register
(registerv-make
(vector (frameset-save nil
:app 'register
:filters frameset-session-filter-alist)
;; frameset-save does not include the value of point
;; in the current buffer, so record that separately.
(frameset-frame-id nil)
(point-marker))
:print-func #'frameset--print-register
:jump-func #'frameset--jump-to-register)))
(frameset-make-register
(frameset-save nil
:app 'register
:filters frameset-session-filter-alist)
;; frameset-save does not include the value of point
;; in the current buffer, so record that separately.
(frameset-frame-id nil)
(point-marker))))
(provide 'frameset)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment