[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Neat features in Eclipse editor
From: |
paul r |
Subject: |
Re: Neat features in Eclipse editor |
Date: |
Tue, 25 Mar 2008 11:08:34 +0100 |
2008/3/25, Richard Stallman <address@hidden>:
> When you switch from workspace A to workspace B, does your current
> window configuration get recorded as workspace A?
Yes, it does.
> The configurations should have names, not single letters.
I firstly had an implementation using names. Then I changed it for
single letters, because it saves a lot of time when switching. But
this can be changed back easily.
> This predefined "gud" perspective should have a window
> for displaying source, and windows for displaying other things.
> Each window should have tabs for switching between the various
> things you can view in that window.
I often use mode hooks to call `workspace-goto-or-create' before, so
that mode-specific automatic windows reorganisation happen in a
dedicated workspace. I then use C-c C-d space to swap workspaces. As
an example, calendar/diary is hooked so that I'm taken to workspace
'c' before windows reorganisation happens.
Concerning the tabs, I'm not sure to see what they are. But if I
understand correctly, my opinion is that buffer switching is superior
and less intrusive. But, clearly, buffer switching prompt should be
dependant of current worspace/window/subframe etc. so that the choice
proposed, the order of buffer, the completion mechanism etc make you
reach what you are after quickly, and avoid unrelated buffers prompt
pollution.
>
> Your code might be the start of this feature, but a convenient
> smooth perspectives feature would do a lot more than this.
No doubt. A friend of mine knows eclipse, I'll ask for a demo.
I noticed some typo in the previous past of the workspaces code, sorry
about that, below is the exact same code with typo corrected.
-- Paul
;; DEFINITION
;;-----------
;;
;; Multi-workspaces
;; Author : Paul Rivier <paul dot r dot ml at gmail dot com>
;;
;; Load this file, then use C-c C-d [any character] to switch
;; to workspace specified
;; Special keys are :
;; - TAB to show workspaces list
;; - space to swap with last workspace
;; - DEL to kill current workspace
;; - RET to restore current workspace to its saved state
;;;;;;;;;;;;;;;;;;
;; DEPENDENCIES ;;
;;;;;;;;;;;;;;;;;;
(eval-when-compile (require 'cl))
;;;;;;;;;;;;;;;
;; VARIABLES ;;
;;;;;;;;;;;;;;;
(defvar current-workspace nil "Workspace you are currently in")
(defvar default-workspace ?1
"This workspace will be created at init time. You can not delete
this workspace. When killing a workspace, you fallback to
default-workspace.")
(defvar workspaces-list nil "List of open workspaces")
;;;;;;;;;;;;;;;;;;;;;
;; GLOBAL BINDINGS ;;
;;;;;;;;;;;;;;;;;;;;;
(global-set-key "\C-c\C-d" 'workspace-goto)
;;;;;;;;;;;;;;;
;; FUNCTIONS ;;
;;;;;;;;;;;;;;;
(lexical-let ((last-workspace default-workspace))
;; above : vars -- below : functions
(labels ((workspaces-list-sort
()
;; "Sort list workspaces-list, save and return it."
(setq workspaces-list
(sort workspaces-list
(lambda (a b)
(< (car a) (car b))))))
(workspaces-list-add
(wsid)
;; "Add current configuration to workspaces list under wsid."
(setq workspaces-list
(cons
(cons wsid (current-window-configuration))
workspaces-list))
(workspaces-list-sort))
(workspace-save-current
()
;; "Save current workspace."
(workspace-delete current-workspace)
(workspaces-list-add current-workspace))
(workspace-delete
(wsid)
;; "Delete workspace wsid."
(setq workspaces-list
(assq-delete-all wsid workspaces-list)))
(workspaces-id-list
()
;; "Return a list of workspaces ids."
(mapcar #'car workspaces-list))
(workspace-create-new
(wsid)
;; "Create a new workspace with id wsid."
(workspace-goto ?0)
(workspaces-list-add wsid)
(workspace-goto wsid))
(workspace-kill-current
()
;; "kill the workspace you are currently in"
(if (not (or (eq current-workspace default-workspace)
(eq current-workspace ?0)))
(let ((cws current-workspace)
(lws last-workspace))
(workspace-goto default-workspace)
(workspace-delete cws)
(setq last-workspace default-workspace)
(concat "\nWorkspace "
(char-to-string cws) " killed"))
(concat "\nSpecial workspaces "
(char-to-string current-workspace)
" can not be killed")))
(workspace-exists-p
(wsid)
;; "Return t if workspace wsid exists."
(when (assoc wsid workspaces-list) t)))
;; externaly bound functions
(defun workspaces-init ()
"Initialize workspaces-list and others"
(setq workspaces-list nil)
(workspaces-list-add ?0)
(setq current-workspace ?0)
(workspace-goto-or-create default-workspace))
(defun workspace-goto-or-create (wsid)
"If workspace wsid exists, goto it, else create it."
(if (workspace-exists-p wsid)
(workspace-goto wsid)
(workspace-create-new wsid)))
(defun workspace-goto (wsid)
"Go to another workspace, wsid is workspace identifier. wsid
can be any character, except those mentioned below. Workspace 0
is a template workspace, do not use it unless you know what you
do. Special characters are :
- TAB to show workspaces list
- space to swap with last workspace
- DEL to kill current workspace
- RET to restore current workspace to its saved state"
(interactive "cTo which workspace do you want to go ? ")
(let ((wscfgcons (assoc wsid workspaces-list))
(special ""))
(if wscfgcons
(progn
(unless (eq wsid current-workspace)
(workspace-save-current))
(set-window-configuration (cdr wscfgcons))
(unless (or (eq current-workspace ?0)
(eq wsid current-workspace))
(setq last-workspace current-workspace))
(setq current-workspace wsid)
(when (eq wsid ?0)
(setq special
"\n!-!-! This is template workspace. New workspaces are
based on it.")))
;; Workspace does not exist, it might be a special key
(cond
((eq wsid 9) ; 9 is TAB
())
((eq wsid 13) ; 13 is RET
(workspace-goto current-workspace)
(workspace-save-current))
((eq wsid 32) ; 32 is space
(workspace-goto last-workspace))
((eq wsid 127) ; 127 is DEL (backspace)
(setq special (workspace-kill-current)))
;; it is not a special key, create workspace
(t
(when (y-or-n-p
"This workspace does not exist, should it be created ? ")
(workspace-create-new wsid)))))
(message (concat "Now on workspace " (char-to-string current-workspace)
"\nWorkspaces list is : "
(mapconcat 'char-to-string
(remq ?0 (workspaces-id-list)) " ")
special))))
))
;;;;;;;;;;;
;; HOOKS ;;
;;;;;;;;;;;
;; base workspaces 0 and default are created at startup only
(unless workspaces-list (workspaces-init))
- Re: Window configuration UI, (continued)
- Re: Window configuration UI, Stefan Monnier, 2008/03/25
- Re: Window configuration UI (was: Neat features in Eclipse editor), Richard Stallman, 2008/03/26
- Re: Window configuration UI, Lennart Borgman (gmail), 2008/03/26
- Re: Window configuration UI, Richard Stallman, 2008/03/26
- Re: Window configuration UI, Stefan Monnier, 2008/03/26
- Re: Window configuration UI, Richard Stallman, 2008/03/27
- Re: Window configuration UI, Michael Sperber, 2008/03/29
- Re: Window configuration UI (was: Neat features in Eclipse editor), Nick Roberts, 2008/03/30
- Re: Window configuration UI (was: Neat features in Eclipse editor), Richard Stallman, 2008/03/31
- Re: Window configuration UI, Stefan Monnier, 2008/03/31
- Re: Neat features in Eclipse editor,
paul r <=
- Re: Neat features in Eclipse editor, David Reitter, 2008/03/25
- Re: Neat features in Eclipse editor, paul r, 2008/03/25
- Re: Neat features in Eclipse editor, Richard Stallman, 2008/03/25
- Re: Neat features in Eclipse editor, paul r, 2008/03/25
- Re: Neat features in Eclipse editor, Robert J. Chassell, 2008/03/25
- Re: Neat features in Eclipse editor, Richard Stallman, 2008/03/26
- Re: Neat features in Eclipse editor, Richard Stallman, 2008/03/25
- Re: Neat features in Eclipse editor, Lennart Borgman (gmail), 2008/03/25
- Re: Neat features in Eclipse editor, Mike Mattie, 2008/03/25
- Re: Neat features in Eclipse editor, Evans Winner, 2008/03/25