From 67466f2c7f00576cc2e0c2993c57b014f5d11452 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 19 May 2010 19:58:19 +0200 Subject: [PATCH] make some features configurable --- eproject-config.el | 4 +-- eproject.cfg | 7 +--- eproject.el | 99 +++++++++++++++++++++++++++++------------------------- eproject.txt | 26 ++++++++++---- 4 files changed, 75 insertions(+), 61 deletions(-) diff --git a/eproject-config.el b/eproject-config.el index a3acec9..09b2173 100644 --- a/eproject-config.el +++ b/eproject-config.el @@ -2,11 +2,11 @@ ;; ;; eproject-config.el --- project workspaces for emacs --- UI part ;; -;; Copyright (C) 2008,2009 grischka +;; Copyright (C) 2008-2010 grischka ;; ;; Author: grischka -- grischka@users.sourceforge.net ;; Created: 24 Jan 2008 -;; Version: 0.3 +;; Version: 0.4 ;; ;; This program is free software, released under the GNU General ;; Public License (GPL, version 2). For details see: diff --git a/eproject.cfg b/eproject.cfg index 8bb4835..cc610ed 100644 --- a/eproject.cfg +++ b/eproject.cfg @@ -34,16 +34,11 @@ )) (unless prj-list - (let* ((cfg (expand-file-name prj-default-cfg eproject-directory)) - (cfg-local (concat cfg ".local")) - ) - (condition-case nil (copy-file cfg cfg-local) (error nil)) (setq prj-list (list (list "eproject" (directory-file-name eproject-directory) - (file-name-nondirectory cfg-local) ))) (run-with-idle-timer 1.0 nil '(lambda () (message " *** Welcome to eproject ***")) - ))) + )) diff --git a/eproject.el b/eproject.el index 167fdc9..44437cb 100644 --- a/eproject.el +++ b/eproject.el @@ -2,7 +2,7 @@ ;; ;; eproject.el --- project workspaces for emacs ;; -;; Copyright (C) 2008,2009 grischka +;; Copyright (C) 2008-2010 grischka ;; ;; Author: grischka -- grischka@users.sourceforge.net ;; Created: 24 Jan 2008 @@ -23,28 +23,35 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; User-configurable items: -;; The default tools for new projects, -(defun prj-default-config () - (setq prj-tools (copy-tree '( - ("Make" "make" "f9") - ("Clean" "make clean" "C-f9") - ("Run" "echo run what" "f8") - ("Stop" "-e eproject-killtool" "C-f8") - ("---") - ("Configure" "./configure") - ("---") - ("Explore Project" "nautilus --browser `pwd` &") - ("XTerm In Project" "xterm &") - ))) +(defvar prj-default-config '( + ("Make" "make" "f9") + ("Clean" "make clean" "C-f9") + ("Run" "echo run what" "f8") + ("Stop" "-e eproject-killtool" "C-f8") + ("---") + ("Configure" "./configure") + ("---") + ("Explore Project" "nautilus --browser `pwd` &") + ("XTerm In Project" "xterm &") + ) + "*The default tools menu for new projects in eproject." ) +(defvar prj-set-default-directory nil + "*Should eproject set the project directory as default-directory +for all project files (nil/t).") -;; Should the project directory be set as default-directory -;; for all project files (nil/t): -(defvar prj-set-default-directory nil) +(defvar prj-set-framepos nil + "*Should eproject restore the last frame position/size (nil/t).") +(defvar prj-set-compilation-frame nil + "*Should eproject show compilation output in the other frame (nil/t).") + +(defvar prj-set-multi-isearch nil + "*Should eproject setup multi-isearch in the project files (nil/t).") + +;; End of user-configurable items ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; no user-configurable items below (probably) ;; There is a global file (~/.emacs.d/eproject.lst) (defun prj-globalfile () @@ -54,7 +61,6 @@ )) ;; with the list of all projects - (defvar prj-list) ;; and the project that was open in the last session (if any) @@ -121,10 +127,9 @@ (setq prj-removed-files nil) (setq prj-curfile nil) (setq prj-config nil) - (setq prj-tools nil) (setq prj-tools-fns nil) + (setq prj-tools (copy-tree prj-default-config)) (prj-reset-functions) - (prj-default-config) ) (defun prj-reset-functions () @@ -154,7 +159,7 @@ (defvar eproject-directory) ;; eproject version that created the files -(defvar eproject-version "0.3") +(defvar eproject-version "0.4") ;; Configuration UI (eval-and-compile @@ -462,7 +467,9 @@ do not belong to project files" )) (when dir (setq dir (directory-file-name dir)) - (setq name (file-name-nondirectory dir)) + (unless name + (setq name (file-name-nondirectory dir)) + ) (when (and cfg (string-equal cfg prj-default-cfg)) (setq cfg nil) ) @@ -923,7 +930,7 @@ do not belong to project files" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Run make and other commands -(defun prj-setup-tool-window () +(defun prj-compilation-in-frame (cmd) (let ((bn "*compilation*") w h b c f) (unless (get-buffer-window bn t) (setq b (get-buffer-create bn)) @@ -938,7 +945,11 @@ do not belong to project files" (setq w (split-window w h)) )) (set-window-buffer w b) - ))) + )) + (let ((display-buffer-reuse-frames t) (f (selected-frame))) + (compile cmd) + (select-frame-set-input-focus f) + )) (defun prj-run (cmd) (cond ((string-match "^-e +" cmd) @@ -948,7 +959,10 @@ do not belong to project files" ) (command-execute cmd) ) - ((let ((b (current-buffer)) (old-dir default-directory) (new-dir ".")) + ((let ((b (current-buffer)) + (old-dir default-directory) + (new-dir ".") + ) (when (string-match "^-in +\\([^[:space:]]+\\) +" cmd) (setq new-dir (match-string-no-properties 1 cmd)) (setq cmd (substring cmd (match-end 0))) @@ -958,17 +972,16 @@ do not belong to project files" ) (cd new-dir) (cond ((string-match "\\(.+\\)& *$" cmd) - (start-process-shell-command "eproject-async" nil (match-string 1 cmd)) + (start-process-shell-command + "eproject-async" nil (match-string 1 cmd)) (message (match-string 1 cmd)) ) + (prj-set-compilation-frame + (prj-compilation-in-frame cmd) + ) (t - (unless (or (fboundp 'ecb-activate) (fboundp 'ewm-init)) - (prj-setup-tool-window) - ) - (let ((display-buffer-reuse-frames t) (f (selected-frame))) - (compile cmd) - (select-frame-set-input-focus f) - ))) + (compile cmd) + )) (with-current-buffer b (cd old-dir)) )))) @@ -1111,7 +1124,7 @@ do not belong to project files" )) (defun prj-isearch-setup () - (cond (prj-current + (cond ((and prj-set-multi-isearch prj-current) (setq multi-isearch-next-buffer-function 'prj-isearch-function) (setq multi-isearch-pause 'initial) (add-hook 'isearch-mode-hook 'multi-isearch-setup) @@ -1145,17 +1158,11 @@ do not belong to project files" (eproject-open prj-last-open) ;; restore frame position - (unless (fboundp 'ewm-init) - (when (and prj-frame-pos prj-initial-frame) - (modify-frame-parameters prj-initial-frame prj-frame-pos) - ;; emacs bug: when it's too busy it doesn't set frames correctly. - (sit-for 0.2) - )))) - - (when (fboundp 'ecb-activate) - (ecb-activate) - ) - ) + (when (and prj-set-framepos prj-frame-pos prj-initial-frame) + (modify-frame-parameters prj-initial-frame prj-frame-pos) + ;; emacs bug: when it's too busy it doesn't set frames correctly. + (sit-for 0.2) + )))) (defun prj-command-line-switch (option) (setq prj-last-open (pop argv)) diff --git a/eproject.txt b/eproject.txt index b140066..654e72f 100644 --- a/eproject.txt +++ b/eproject.txt @@ -12,6 +12,15 @@ between files. + New in version 0.4: + ------------------- + + - Project configuration file (eproject.cfg) may exist under a different + name and/or directory (Allows multiple projects in the same directory) + + - Optional support for multi-isearch in the project files + + Keys ==== @@ -71,9 +80,7 @@ A trailing '&' enables asynchronous execution without redirection. Relative paths refer to the project directory. - A new project is initialized with default tool commands. If you wish - to have a different default set, please edit 'prj-default-config' in - eproject.el near the top. + A new project is initialized with default tool commands. Settings: @@ -109,6 +116,13 @@ emacs -project + Configuration: + -------------- + + There are some variables at top of eproject.el that you might want + to edit. + + eproject commands: ------------------ @@ -150,9 +164,9 @@ License ======= - eproject 0.3 + eproject 0.4 - Copyright (C) 2008,2009 grischka@users.sourceforge.net + Copyright (C) 2008-2010 grischka@users.sourceforge.net This program is free software, released under the GNU General Public License (GPL), Version 2. For details see: @@ -163,5 +177,3 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - Jan 24, 2009 -- grischka -- 2.11.4.GIT