From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "paul r" Newsgroups: gmane.emacs.devel Subject: Re: Neat features in Eclipse editor Date: Tue, 25 Mar 2008 11:08:34 +0100 Message-ID: References: <873aqia0eh.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1206439817 16568 80.91.229.12 (25 Mar 2008 10:10:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Mar 2008 10:10:17 +0000 (UTC) Cc: pmr@pajato.com, cyd@stupidchicken.com, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 25 11:10:47 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Je66z-0006rr-CR for ged-emacs-devel@m.gmane.org; Tue, 25 Mar 2008 11:10:34 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Je66N-0005q5-Of for ged-emacs-devel@m.gmane.org; Tue, 25 Mar 2008 06:09:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Je65B-0004nx-1H for emacs-devel@gnu.org; Tue, 25 Mar 2008 06:08:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Je658-0004mx-Lj for emacs-devel@gnu.org; Tue, 25 Mar 2008 06:08:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Je657-0004mq-UO for emacs-devel@gnu.org; Tue, 25 Mar 2008 06:08:38 -0400 Original-Received: from fg-out-1718.google.com ([72.14.220.158]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Je657-00084a-CW for emacs-devel@gnu.org; Tue, 25 Mar 2008 06:08:37 -0400 Original-Received: by fg-out-1718.google.com with SMTP id d23so3199293fga.30 for ; Tue, 25 Mar 2008 03:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=lm0duQgcTPq0jACs5WjOTVHLuSbkp/s3FRyZm9kBLTg=; b=B4faC9wZ94x6vait9+4Dt73YzGOnaBRepKqZUOnikV93gujUu4Y0O6U7mKuEi6gUbf+asTfoJ1w7uvIH2vYN+Jj6cRXeqyaaqVTn/7YkqN9F3wppweNJmpewfkltJrWANZ8WR6hCljZsAA0IK4/cXFDfcghDW5bvsXM0gVVtlNk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=M8arQZ0Q/ROGygDE0XB4gMcneq8BaRWS+kevUrMhJCanf6tfecnRp/8r0DFPlmG3ezeQh5RERR15Bpg505UOAEX1hJbfCvm4sLnDd3xRzkyGFkg47xm6snIQE4VtC9a68vNC2TwrRNHa7w2yGhDXbTUfgNWqoNqJu54BZAyQEhs= Original-Received: by 10.82.155.10 with SMTP id c10mr20445797bue.28.1206439714305; Tue, 25 Mar 2008 03:08:34 -0700 (PDT) Original-Received: by 10.82.175.3 with HTTP; Tue, 25 Mar 2008 03:08:34 -0700 (PDT) In-Reply-To: Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:93401 Archived-At: 2008/3/25, Richard Stallman : > 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 ;; ;; 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))