help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: When do you prefer frames instead of windows?


From: H. Dieter Wilhelm
Subject: Re: When do you prefer frames instead of windows?
Date: Mon, 24 Nov 2014 23:12:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Raffaele Ricciardi <rfflrccrd@gmail.com> writes:

> The usefulness of frames is evident for buffers that update their
> content according to the current buffer (like Speedbar and
> ECB). Besides this kind of use, when do you prefer frames instead of
> windows?

To preserve sane window layouts despite a multitude of major modes.

For example: Barry Margolin pointed out that he prefers 4 ansi terminals
in a "shell frame".  I like to have a "file manager" frame with two
dired buffers side by side. Gnus literally "demands" his own frame in
its default mode of operation!

Here's an illustration of my frame setup which is based on Alan
Mackenzie work, so that I'm able to open frames with predefined window
layouts according to various tasks or - if a task frame already exists,
just switch to it.

;; ======================================================================
;; `frames' based on Alan Mackenzie's setup

(set-frame-name "Work")
(modify-frame-parameters (selected-frame) '((acm-no . 2)))
(find-file "~/org/blog/dddlll.org")

(defun assign-acm-no (frame)
  "FRAME is a (typically newly created) frame.  Give it an acm-no
frame-parameter if there is one free (in the range 0..11).
Return that number or nil."
  (let ((assigned (make-bool-vector 12 nil)) (f (frame-list)) n)
    (while f
      (if (setq n (frame-parameter (car f) 'acm-no))
          (aset assigned n t))
      (setq f (cdr f)))
    (setq n 0)
    (while (and (< n 12) (aref assigned n))
      (setq n (1+ n)))
    (if (= n 12)
        nil
      (modify-frame-parameters frame `((acm-no . ,n)))
      n)))

;(add-hook 'after-make-frame-functions 'assign-acm-no)

(defun find-acm-no-frame (n)
  "Return the frame with parameter (acm-no . N), or nil."
  (let ((f (frame-list)))
    (while (and f (not (eq (frame-parameter (car f) 'acm-no) n)))
      (setq f (cdr f)))
    (car f)))

(defun focus-frame-acm-no (n)
  "Select the frame with acm-no frame-parameter N, or do nothing."
  (let ((frame (find-acm-no-frame n)))
    (when frame (select-frame-set-input-focus frame))
    (framep frame)))

;; frame 2, 3, ...
(defun focus-or-make-named-frame ( no)
  "bla"
  (unless (focus-frame-acm-no no)
    (let ((frame (make-frame-command)))
      (select-frame-set-input-focus frame)
      (cond
       ((= no 1)
        (modify-frame-parameters frame '((acm-no . 1)))
        (set-frame-name "F1 Informations, info, eww")
        (unless (get-buffer "*info*")
          (info))
        )
       ((= no 2)
        (modify-frame-parameters frame '((acm-no . 2)))
        (set-frame-name "F2 Work")
        )
      ((= no 3)
        (modify-frame-parameters frame '((acm-no . 3)))
        (set-frame-name "F3 Communications Gnus, BBDB")
        (unless (get-buffer "*Group*")
          (gnus-unplugged))
        )
       ((= no 4)
        (modify-frame-parameters frame '((acm-no . 4)))
        (set-frame-name "F4 OS terminal, shell")
        (split-window-horizontally)
        (unless (get-buffer "*terminal*")
          (term "/bin/bash"))
        )
       ((= no 5)
        (modify-frame-parameters frame '((acm-no . 5)))
        (set-frame-name "Time Management and Planning")
        (unless (get-buffer "*Calendar*")
          (calendar))
        )
       ((= no 6)
        (modify-frame-parameters frame '((acm-no . 6)))
        (set-frame-name "Programming and Configuration")
        (unless (get-buffer "init.el")
          (find-file "~/.emacs.d/init.el"))
        )
       ((= no 7)
        (modify-frame-parameters frame '((acm-no . 7)))
        (set-frame-name "Dired File Manipulations")
        (dired "~"))
       ((= no 8)
        (modify-frame-parameters frame '((acm-no . 8)))
        (set-frame-name "Helper Frame"))
       ((= no 9)
        (modify-frame-parameters frame '((acm-no . 9)))
        (set-frame-name "ERC"))
       ((= no 10)
        (modify-frame-parameters frame '((acm-no . 9)))
        (set-frame-name "Image Dired"))
       ))))

(global-set-key [f1]  (lambda () "Switch to frame 1"  (interactive) 
(focus-or-make-named-frame 1)))
(global-set-key [f2]  (lambda () "Switch to frame 2"  (interactive) 
(focus-or-make-named-frame 2)))
(global-set-key [f3]  (lambda () "Switch to frame 3"  (interactive) 
(focus-or-make-named-frame 3)))
(global-set-key [f4]  (lambda () "Switch to frame 4"  (interactive) 
(focus-or-make-named-frame 4)))
(global-set-key [f5]  (lambda () "Switch to frame 5"  (interactive) 
(focus-or-make-named-frame 5)))
(global-set-key [f6]  (lambda () "Switch to frame 6"  (interactive) 
(focus-or-make-named-frame 6)))
(global-set-key [f7]  (lambda () "Switch to frame 7"  (interactive) 
(focus-or-make-named-frame 7)))
(global-set-key [f8]  (lambda () "Switch to frame 8"  (interactive) 
(focus-or-make-named-frame 8)))
(global-set-key [f9]  (lambda () "Switch to frame 9"  (interactive) 
(focus-or-make-named-frame 9)))
(global-set-key [f10] (lambda () "Switch to frame 10" (interactive) 
(focus-or-make-named-frame 10)))
;; F11 is toggle full-screen
;; (global-set-key [f12] (lambda () "Switch to frame 12" (interactive) 
(focus-or-make-named-frame 12)))


   Dieter
-- 
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany



reply via email to

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