Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rboles/my-projects-el
base: b83fd83a79
...
head fork: rboles/my-projects-el
compare: 8646dff26a
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 61 additions and 7 deletions.
  1. +61 −7 my-project.el
View
68 my-project.el
@@ -18,6 +18,10 @@
;; To open a project:
;;
;; M-x my-project
+;;
+;; To open a project space:
+;;
+;; M-x my-project-space
;;; Code:
@@ -57,8 +61,7 @@ match"
(cdr (assoc name my-project-alist))
)
-(defun my-project-alist-property (name prop &optional val
- )
+(defun my-project-alist-property (name prop &optional val)
"Returns PROP value associated with project identified by NAME.
If VAL is provided, the project alist property is set to VAL and VAL
@@ -73,21 +76,42 @@ returned."
(plist-get plist prop)))
)
+(defun my-project-alist-space-names ()
+ "Returns a list all space names across all projects.
+
+The space name is a concatenation of ``project-name''-``space-name''-
+same as the buffer name created for the space"
+ (let ((projects (my-project-alist-names))
+ (project nil)
+ (names nil))
+ (while projects
+ (setq project (car projects))
+ (setq projects (cdr projects))
+ (let ((spaces (my-project-alist-property project :spaces))
+ (space nil))
+ (while spaces
+ (setq space (car spaces))
+ (setq spaces (cdr spaces))
+ (push (concat project "-" (car space)) names))))
+ names)
+ )
+
(defun my-project (&optional my-project)
- "Opens a workspace"
+ "Opens a project workspace"
(interactive)
(let* ((projects (my-project-alist-names))
(project (if my-project my-project
- (read-string "Project: "
- (car projects)
- (cons 'projects 1))))
+ (completing-read
+ "Project: "
+ (my-project-alist-names)
+ nil t)))
(prefix (my-project-alist-property project :prefix))
(spaces (my-project-alist-property project :spaces))
(space nil))
(while spaces
(setq space (car spaces))
(setq spaces (cdr spaces))
- (message "Opening project %s" project)
+ (message "Opening project: %s" project)
(let ((buf-name (car space))
(buf-path (car (cdr space))))
(find-file (concat prefix buf-path))
@@ -97,6 +121,36 @@ returned."
)
)
+(defun my-project-space (&optional my-project-space)
+ "Opens a project space"
+ (interactive)
+ (let* ((project-space (if my-project-space my-project-space
+ (completing-read
+ "Project space name: "
+ (my-project-alist-space-names)
+ nil t)))
+ (project-name (car (split-string project-space "-")))
+ (space-name (car (cdr (split-string project-space "-"))))
+ (prefix (my-project-alist-property project-name :prefix))
+ (spaces (my-project-alist-property project-name :spaces))
+ (space nil)
+ (done nil))
+ (while (and spaces (not done))
+ (setq space (car spaces))
+ (setq spaces (cdr spaces))
+ (message "Car of space: %s" (car space))
+ (if (string= (car space) space-name)
+ (progn
+ (setq done t)
+ (message "Opening project space: %s"
+ (let ((buf-name (car space))
+ (buf-path (car (cdr space))))
+ (find-file (concat prefix buf-path))
+ (rename-buffer (concat project-name "-" buf-name))))))
+ )
+ )
+ )
+
(provide 'my-project)
;;; my-project.el ends here

No commit comments for this range

Something went wrong with that request. Please try again.