aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuanma Barranquero2013-08-06 14:18:43 +0200
committerJuanma Barranquero2013-08-06 14:18:43 +0200
commit024b38fc4d3e1e09871109f428d80d37166ae032 (patch)
treeceb74910954b528b2c99ce50db6bbfbb8496fcc7 /lisp
parent64e22afeb39dd568082929d945148060d2ac7fa7 (diff)
downloademacs-024b38fc4d3e1e09871109f428d80d37166ae032.tar.gz
emacs-024b38fc4d3e1e09871109f428d80d37166ae032.zip
lisp/frameset.el: Doc fixes.
(frameset, frameset-filter-alist, frameset-filter-params, frameset-save) (frameset--reuse-frame, frameset--minibufferless-last-p, frameset-restore): Doc fixes. (frameset-compute-pos): Rename from frameset--compute-pos, and add docstring. (frameset-move-onscreen): Use frameset-compute-pos. Most changes suggested by Drew Adams <drew.adams@oracle.com>.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/frameset.el76
2 files changed, 56 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 31c5414cae0..0843ca2398a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12013-08-06 Juanma Barranquero <lekktu@gmail.com> 12013-08-06 Juanma Barranquero <lekktu@gmail.com>
2 2
3 * frameset.el (frameset, frameset-filter-alist)
4 (frameset-filter-params, frameset-save, frameset--reuse-frame)
5 (frameset--minibufferless-last-p, frameset-restore): Doc fixes.
6 (frameset-compute-pos): Rename from frameset--compute-pos,
7 and add docstring.
8 (frameset-move-onscreen): Use frameset-compute-pos.
9 Most changes suggested by Drew Adams <drew.adams@oracle.com>.
10
3 * find-lisp.el (find-lisp-line-indent, find-lisp-find-dired-filter): 11 * find-lisp.el (find-lisp-line-indent, find-lisp-find-dired-filter):
4 Fix typos in docstrings. 12 Fix typos in docstrings.
5 13
diff --git a/lisp/frameset.el b/lisp/frameset.el
index 71c26112917..45cf86eb3cc 100644
--- a/lisp/frameset.el
+++ b/lisp/frameset.el
@@ -42,9 +42,12 @@
42 42
43 43
44(cl-defstruct (frameset (:type list) :named 44(cl-defstruct (frameset (:type list) :named
45 ;; Copier and predicate functions are defined below.
45 (:copier nil) 46 (:copier nil)
46 (:predicate nil) 47 (:predicate nil)
47 ;; A BOA constructor, not the default "keywordy" one. 48 ;; A BOA constructor, not the default "keywordy" one.
49 ;; This is for internal use; to create a frameset,
50 ;; the "right" way to do it is with frameset-save.
48 (:constructor make-frameset (properties states))) 51 (:constructor make-frameset (properties states)))
49 52
50 "A frameset encapsulates a serializable view of a set of frames and windows. 53 "A frameset encapsulates a serializable view of a set of frames and windows.
@@ -55,11 +58,10 @@ It contains the following slots, which can be accessed with
55 version A non-modifiable version number, identifying the format 58 version A non-modifiable version number, identifying the format
56 of the frameset struct. Currently its value is 1. 59 of the frameset struct. Currently its value is 1.
57 properties A property list, to store both frameset-specific and 60 properties A property list, to store both frameset-specific and
58 user-defined serializable data (some suggested properties 61 user-defined serializable data (see suggestions below).
59 are described below).
60 states An alist of items (FRAME-PARAMETERS . WINDOW-STATE), in no 62 states An alist of items (FRAME-PARAMETERS . WINDOW-STATE), in no
61 particular order. Each item represents a frame to be 63 particular order. Each item represents a frame to be
62 restored. FRAME-PARAMETERS is a frame's parameter list, 64 restored. FRAME-PARAMETERS is a frame's parameter alist,
63 extracted with (frame-parameters FRAME) and filtered through 65 extracted with (frame-parameters FRAME) and filtered through
64 `frame-parameters-alist' or a similar filter alist. 66 `frame-parameters-alist' or a similar filter alist.
65 WINDOW-STATE is the output of `window-state-get', when 67 WINDOW-STATE is the output of `window-state-get', when
@@ -75,10 +77,14 @@ Some suggested properties:
75 :desc TEXT A description for user consumption (to show in a menu to 77 :desc TEXT A description for user consumption (to show in a menu to
76 choose among framesets, etc.); a string. 78 choose among framesets, etc.); a string.
77 79
80To avoid collisions, it is recommended that applications wanting to add
81private serializable data to `properties' either store all info under a
82single, distinctive name, or use property names with a well-chosen prefix.
83
78A frameset is intended to be used through the following simple API: 84A frameset is intended to be used through the following simple API:
79 85
80 - `frameset-save' captures all or a subset of the live frames, and returns 86 - `frameset-save', the type's constructor, captures all or a subset of the
81 a serializable snapshot of them (a frameset). 87 live frames, and returns a serializable snapshot of them (a frameset).
82 - `frameset-restore' takes a frameset, and restores the frames and windows 88 - `frameset-restore' takes a frameset, and restores the frames and windows
83 it describes, as faithfully as possible. 89 it describes, as faithfully as possible.
84 - `frameset-p' is the predicate for the frameset type. It returns nil 90 - `frameset-p' is the predicate for the frameset type. It returns nil
@@ -166,15 +172,15 @@ See `frameset-filter-alist' for a full description.")
166 172
167This alist is the default value of the :filters arguments of 173This alist is the default value of the :filters arguments of
168`frameset-save' and `frameset-restore' (which see). On saving, 174`frameset-save' and `frameset-restore' (which see). On saving,
169PARAMETERS is the parameter list of each frame processed, and 175PARAMETERS is the parameter alist of each frame processed, and
170FILTERED is the parameter list that gets saved to the frameset. 176FILTERED is the parameter alist that gets saved to the frameset.
171On restoring, PARAMETERS is the parameter list extracted from the 177On restoring, PARAMETERS is the parameter alist extracted from the
172frameset, and FILTERED is the resulting frame parameter list used 178frameset, and FILTERED is the resulting frame parameter alist used
173to restore the frame. 179to restore the frame.
174 180
175Elements of this alist are conses (PARAM . ACTION), where PARAM 181Elements of `frameset-filter-alist' are conses (PARAM . ACTION),
176is a parameter name (a symbol identifying a frame parameter), and 182where PARAM is a parameter name (a symbol identifying a frame
177ACTION can be: 183parameter), and ACTION can be:
178 184
179 nil The parameter is copied to FILTERED. 185 nil The parameter is copied to FILTERED.
180 :never The parameter is never copied to FILTERED. 186 :never The parameter is never copied to FILTERED.
@@ -183,8 +189,11 @@ ACTION can be:
183 FILTER A filter function. 189 FILTER A filter function.
184 190
185FILTER can be a symbol FILTER-FUN, or a list (FILTER-FUN ARGS...). 191FILTER can be a symbol FILTER-FUN, or a list (FILTER-FUN ARGS...).
186FILTER-FUN is called with four arguments CURRENT, FILTERED, PARAMETERS and 192FILTER-FUN is invoked with
187SAVING, plus any additional ARGS: 193
194 (apply FILTER-FUN CURRENT FILTERED PARAMETERS SAVING ARGS)
195
196where
188 197
189 CURRENT A cons (PARAM . VALUE), where PARAM is the one being 198 CURRENT A cons (PARAM . VALUE), where PARAM is the one being
190 filtered and VALUE is its current value. 199 filtered and VALUE is its current value.
@@ -192,6 +201,7 @@ SAVING, plus any additional ARGS:
192 PARAMETERS The complete alist of parameters being filtered, 201 PARAMETERS The complete alist of parameters being filtered,
193 SAVING Non-nil if filtering before saving state, nil if filtering 202 SAVING Non-nil if filtering before saving state, nil if filtering
194 before restoring it. 203 before restoring it.
204 ARGS Any additional arguments specified in the ACTION.
195 205
196FILTER-FUN is allowed to modify items in FILTERED, but no other arguments. 206FILTER-FUN is allowed to modify items in FILTERED, but no other arguments.
197It must return: 207It must return:
@@ -308,15 +318,15 @@ see the docstring of `frameset-filter-alist'."
308 (not (and saving (eq (cdr (assq 'visibility parameters)) 'icon)))) 318 (not (and saving (eq (cdr (assq 'visibility parameters)) 'icon))))
309 319
310(defun frameset-filter-params (parameters filter-alist saving) 320(defun frameset-filter-params (parameters filter-alist saving)
311 "Filter parameter list PARAMETERS and return a filtered list. 321 "Filter parameter alist PARAMETERS and return a filtered alist.
312FILTER-ALIST is an alist of parameter filters, in the format of 322FILTER-ALIST is an alist of parameter filters, in the format of
313`frameset-filter-alist' (which see). 323`frameset-filter-alist' (which see).
314SAVING is non-nil while filtering parameters to save a frameset, 324SAVING is non-nil while filtering parameters to save a frameset,
315nil while the filtering is done to restore it." 325nil while the filtering is done to restore it."
316 (let ((filtered nil)) 326 (let ((filtered nil))
317 (dolist (current parameters) 327 (dolist (current parameters)
318 ;; When saving, the parameter list is temporary, so modifying it 328 ;; When saving, the parameter alist is temporary, so modifying it
319 ;; is not a problem. When restoring, the parameter list is part 329 ;; is not a problem. When restoring, the parameter alist is part
320 ;; of a frameset, so we must copy parameters to avoid inadvertent 330 ;; of a frameset, so we must copy parameters to avoid inadvertent
321 ;; modifications. 331 ;; modifications.
322 (pcase (cdr (assq (car current) filter-alist)) 332 (pcase (cdr (assq (car current) filter-alist))
@@ -417,9 +427,9 @@ FRAME-LIST is a list of frames. Internal use only."
417 "Return the frameset of FRAME-LIST, a list of frames. 427 "Return the frameset of FRAME-LIST, a list of frames.
418Dead frames and non-frame objects are silently removed from the list. 428Dead frames and non-frame objects are silently removed from the list.
419If nil, FRAME-LIST defaults to the output of `frame-list' (all live frames). 429If nil, FRAME-LIST defaults to the output of `frame-list' (all live frames).
420FILTERS is an alist of parameter filters; defaults to `frameset-filter-alist'. 430FILTERS is an alist of parameter filters, or `frameset-filter-alist' if nil.
421PREDICATE is a predicate function, which must return non-nil for frames that 431PREDICATE is a predicate function, which must return non-nil for frames that
422should be saved; it defaults to saving all frames from FRAME-LIST. 432should be saved; if PREDICATE is nil, all frames from FRAME-LIST are saved.
423PROPERTIES is a user-defined property list to add to the frameset." 433PROPERTIES is a user-defined property list to add to the frameset."
424 (let* ((list (or (copy-sequence frame-list) (frame-list))) 434 (let* ((list (or (copy-sequence frame-list) (frame-list)))
425 (frames (cl-delete-if-not #'frame-live-p 435 (frames (cl-delete-if-not #'frame-live-p
@@ -445,7 +455,16 @@ PROPERTIES is a user-defined property list to add to the frameset."
445Its value is only meaningful during execution of `frameset-restore'. 455Its value is only meaningful during execution of `frameset-restore'.
446Internal use only.") 456Internal use only.")
447 457
448(defun frameset--compute-pos (value left/top right/bottom) 458(defun frameset-compute-pos (value left/top right/bottom)
459 "Return an absolute positioning value for a frame.
460VALUE is the value of a positional frame parameter (`left' or `top').
461If VALUE is relative to the screen edges (like (+ -35) or (-200), it is
462converted to absolute by adding it to the corresponding edge; if it is
463an absolute position, it is returned unmodified.
464LEFT/TOP and RIGHT/BOTTOM indicate the dimensions of the screen in
465pixels along the relevant direction: either the position of the left
466and right edges for a `left' positional parameter, or the position of
467the top and bottom edges for a `top' parameter."
449 (pcase value 468 (pcase value
450 (`(+ ,val) (+ left/top val)) 469 (`(+ ,val) (+ left/top val))
451 (`(- ,val) (+ right/bottom val)) 470 (`(- ,val) (+ right/bottom val))
@@ -460,8 +479,8 @@ NOTE: This only works for non-iconified frames."
460 (pcase-let* ((`(,left ,top ,width ,height) (cl-cdadr (frame-monitor-attributes frame))) 479 (pcase-let* ((`(,left ,top ,width ,height) (cl-cdadr (frame-monitor-attributes frame)))
461 (right (+ left width -1)) 480 (right (+ left width -1))
462 (bottom (+ top height -1)) 481 (bottom (+ top height -1))
463 (fr-left (frameset--compute-pos (frame-parameter frame 'left) left right)) 482 (fr-left (frameset-compute-pos (frame-parameter frame 'left) left right))
464 (fr-top (frameset--compute-pos (frame-parameter frame 'top) top bottom)) 483 (fr-top (frameset-compute-pos (frame-parameter frame 'top) top bottom))
465 (ch-width (frame-char-width frame)) 484 (ch-width (frame-char-width frame))
466 (ch-height (frame-char-height frame)) 485 (ch-height (frame-char-height frame))
467 (fr-width (max (frame-pixel-width frame) (* ch-width (frame-width frame)))) 486 (fr-width (max (frame-pixel-width frame) (* ch-width (frame-width frame))))
@@ -529,7 +548,7 @@ If PREDICATE is nil, it is always satisfied. Internal use only."
529(defun frameset--reuse-frame (display frame-cfg) 548(defun frameset--reuse-frame (display frame-cfg)
530 "Look for an existing frame to reuse. 549 "Look for an existing frame to reuse.
531DISPLAY is the display where the frame will be shown, and FRAME-CFG 550DISPLAY is the display where the frame will be shown, and FRAME-CFG
532is the parameter list of the frame being restored. Internal use only." 551is the parameter alist of the frame being restored. Internal use only."
533 (let ((frame nil) 552 (let ((frame nil)
534 mini) 553 mini)
535 ;; There are no fancy heuristics there. We could implement some 554 ;; There are no fancy heuristics there. We could implement some
@@ -591,7 +610,7 @@ Internal use only."
591(defun frameset--restore-frame (frame-cfg window-cfg filters force-onscreen) 610(defun frameset--restore-frame (frame-cfg window-cfg filters force-onscreen)
592 "Set up and return a frame according to its saved state. 611 "Set up and return a frame according to its saved state.
593That means either reusing an existing frame or creating one anew. 612That means either reusing an existing frame or creating one anew.
594FRAME-CFG is the frame's parameter list; WINDOW-CFG is its window state. 613FRAME-CFG is the frame's parameter alist; WINDOW-CFG is its window state.
595For the meaning of FILTERS and FORCE-ONSCREEN, see `frameset-restore'. 614For the meaning of FILTERS and FORCE-ONSCREEN, see `frameset-restore'.
596Internal use only." 615Internal use only."
597 (let* ((fullscreen (cdr (assq 'fullscreen frame-cfg))) 616 (let* ((fullscreen (cdr (assq 'fullscreen frame-cfg)))
@@ -631,7 +650,7 @@ Internal use only."
631 ;; If a frame needs to be created and it falls partially or fully offscreen, 650 ;; If a frame needs to be created and it falls partially or fully offscreen,
632 ;; sometimes it gets "pushed back" onscreen; however, moving it afterwards is 651 ;; sometimes it gets "pushed back" onscreen; however, moving it afterwards is
633 ;; allowed. So we create the frame as invisible and then reapply the full 652 ;; allowed. So we create the frame as invisible and then reapply the full
634 ;; parameter list (including position and size parameters). 653 ;; parameter alist (including position and size parameters).
635 (setq frame (or (and frameset--reuse-list 654 (setq frame (or (and frameset--reuse-list
636 (frameset--reuse-frame display filtered-cfg)) 655 (frameset--reuse-frame display filtered-cfg))
637 (make-frame-on-display display 656 (make-frame-on-display display
@@ -659,7 +678,8 @@ Internal use only."
659 678
660(defun frameset--minibufferless-last-p (state1 state2) 679(defun frameset--minibufferless-last-p (state1 state2)
661 "Predicate to sort frame states in an order suitable for creating frames. 680 "Predicate to sort frame states in an order suitable for creating frames.
662It sorts minibuffer-owning frames before minibufferless ones." 681It sorts minibuffer-owning frames before minibufferless ones.
682Internal use only."
663 (pcase-let ((`(,hasmini1 ,id-def1) (assq 'frameset--mini (car state1))) 683 (pcase-let ((`(,hasmini1 ,id-def1) (assq 'frameset--mini (car state1)))
664 (`(,hasmini2 ,id-def2) (assq 'frameset--mini (car state2)))) 684 (`(,hasmini2 ,id-def2) (assq 'frameset--mini (car state2))))
665 (cond ((eq id-def1 t) t) 685 (cond ((eq id-def1 t) t)
@@ -697,9 +717,9 @@ FORCE-DISPLAY can be:
697 t Frames are restored in the current display. 717 t Frames are restored in the current display.
698 nil Frames are restored, if possible, in their original displays. 718 nil Frames are restored, if possible, in their original displays.
699 :delete Frames in other displays are deleted instead of restored. 719 :delete Frames in other displays are deleted instead of restored.
700 PRED A function called with one argument, the parameter list; 720 PRED A function called with one argument, the parameter alist;
701 it must return t, nil or `:delete', as above but affecting 721 it must return t, nil or `:delete', as above but affecting
702 only the frame that will be created from that parameter list. 722 only the frame that will be created from that parameter alist.
703 723
704FORCE-ONSCREEN can be: 724FORCE-ONSCREEN can be:
705 t Force onscreen only those frames that are fully offscreen. 725 t Force onscreen only those frames that are fully offscreen.