|
- ;;; projectorg.el ---
-
- ;; Copyright (C) 2019 Maxime Wack
-
- ;; Author: Maxime Wack <maximewack@free.fr>
- ;; Version: 0.1
-
- ;; This file is not part of GNU Emacs.
-
- ;; This program is free software: you can redistribute it and/or modify
- ;; it under the terms of the GNU General Public License as published by
- ;; the Free Software Foundation, either version 3 of the License, or
- ;; (at your option) any later version.
-
- ;; This program is distributed in the hope that it will be useful,
- ;; but 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.
-
- ;; You should have received a copy of the GNU General Public License
- ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- ;;; Commentary:
-
- ;; Project management using org, projectile and skeletor
-
- ;;; Code:
-
- ;;;; Variables
-
- (defvar projectorg-projects-root ""
- "Where all projects are rooted.
-
- This is the directory where projects are stored.
- Can contain subdirectories.
- The projectorg-org-dir subdirectory contains the notes file for each project, as well as the general notes files and the projects list file.")
-
- (defvar projectorg-org-dir "org/"
- "Directory inside projectorg-projects-root containing the org files.
-
- Defaults to \"org\"
- Contains the general notes files, the projects list files and each project notes file.")
-
- ;;;; Functions
-
- (defun projectorg/project-name ()
- "Return the full project name.
-
- It is the result of substracting the projectorg-projects-root string from the beginning of the path of the project, as returned by projectile-project-p."
- (when (projectile-project-p)
- (let ((project-path (projectile-project-p)))
- (and
- (string= (substring project-path 0 (length projectorg-projects-root))
- projectorg-projects-root)
- (substring project-path (length projectorg-projects-root) -1)))))
-
- (defun projectorg/notes-file ()
- "Returns the notes-file location.
-
- It is an org file, with the same name as the project (including subdirectories), located in the *org* directory in projectorg-projects-root."
- (let ((project-name (projectorg/project-name)))
- (when project-name
- (concat projectorg-projects-root "org/" project-name ".org"))))
-
- (defun projectorg/go-to-inbox ()
- "Go to org-default-notes-file."
- (interactive)
- (find-file-other-window org-default-notes-file))
-
- (defun projectorg/go-to-notes ()
- "Go to the projects' notes file if it exists in the *org* directory, or go to default notes file."
- (interactive)
- (let ((notes-file (projectorg/notes-file)))
- (if (or (and (eq projectile-require-project-root 'prompt)
- (not (projectile-project-p)))
- (not (file-exists-p notes-file)))
- (projectorg/go-to-inbox)
- (find-file-other-window notes-file))))
-
- (defun projectorg/add-to-project-list (FILENAME &optional WILDCARDS)
- "Add the currently visited project to the projectile list.
-
- And switch to a perspective for the project."
-
- (when (projectile-project-p FILENAME)
- (persp-switch (projectile-project-name (projectile-project-root FILENAME)))
- (projectile-add-known-project (projectile-project-root FILENAME))))
-
- (defun projectorg/remove-from-project-list ()
- (interactive)
- (let ((proj (projectile-project-name)))
- (projectile-remove-current-project-from-known-projects)
- (projectile-kill-buffers)
- (persp-kill proj)))
-
-
- (provide 'projectorg)
-
- ;;; projectorg.el ends here
|