;; Convenient functions to manipulate multiple frames on multiple displays
;; e.g. I often run emacs with 4 frames on 4 different VNC sessions
;; and often need to delete all but the current frame.
(progn ; test idiom: defun some stuff, and then test at end of progn. can eval to test interactively
(defun print-frame-list ()
(interactive)
(reduce 'concat
(mapcar
(lambda (frame) "print frame"
(reduce 'concat
(mapcar (lambda (s) (format "%s" s))
(list
"TITLE=" (frame-parameter frame 'title) "\n"
" NAME=" (frame-parameter frame 'name) "\n"
" explicit-name=" (frame-parameter frame 'explicit-name) "\n"
" display=" (frame-parameter frame 'display) "\n"
" frame-height X frame-width=" (frame-height frame) "x" (frame-width frame) "\n"
" frame-pixel-height X frame-pixel-width=" (frame-pixel-height frame) "x" (frame-pixel-width frame) "\n"
" visibility=" (frame-parameter frame 'visibility) "\n"
)
)
)
)
(frame-list)
)
)
)
(defun delete-frames-except (frame-list-to-be-deleted)
(mapcar 'delete-frame frame-list-to-be-deleted))
(defun non-selected-frames ()
(remove-if 'null (mapcar (lambda (f) (if (eq (selected-frame) f) nil f)) (frame-list))))
(defun delete-frames-except-selected ()
"delete all frames except for the currently selected frame
useful in cleaning up frames scattered over multiple displays, e.g. multip.le VNC sessions"
(interactive)
(delete-frames-except (non-selected-frames))
)
(defun ag-mips-usual-emacs-frames ()
"open my usual emacs frames"
(interactive)
(make-frame-on-display "ubuntu-uarch:1.0")
(make-frame-on-display "ubuntu-uarch:2.0")
;(make-frame-on-display "ubuntu-uarch:3.0")
(make-frame-on-display "ubuntu-uarch:4.0")
)
;; test (manual, hand-checked)
(delete-frames-except-selected)
(ag-mips-usual-emacs-frames)
(print-frame-list)
)
(progn
;; Creating a new menu pane in the menu bar to the right of Tools menu
(define-key-after
global-map
[menu-bar ag-frame-menu]
(cons "Frames" (make-sparse-keymap "hoot hoot"))
'tools )
;; Creating a menu item, under the menu by the id [menu-bar mymenu]
(define-key
global-map
[menu-bar ag-frame-menu dff]
'("delete-frames-except-selected" . delete-frames-except-selected))
;; creating another menu item
(define-key
global-map
[menu-bar ag-frame-menu df.]
'("delete-frame" . delete-frame))
;; creating another menu item
(define-key
global-map
[menu-bar ag-frame-menu uf]
'("usual frames" . ag-mips-usual-emacs-frames))
)