Project management with org, projectile and skeletor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.4KB

  1. ;;; projectorg.el ---
  2. ;; Copyright (C) 2019 Maxime Wack
  3. ;; Author: Maxime Wack <maximewack@free.fr>
  4. ;; Version: 0.1
  5. ;; This file is not part of GNU Emacs.
  6. ;; This program is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; This program is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; Project management using org, projectile and skeletor
  18. ;;; Code:
  19. ;;;; Variables
  20. (defvar projectorg-projects-root ""
  21. "Where all projects are rooted.
  22. This is the directory where projects are stored.
  23. Can contain subdirectories.
  24. The projectorg-org-dir subdirectory contains the notes file for each project, as well as the general notes files and the projects list file.")
  25. (defvar projectorg-org-dir "org/"
  26. "Directory inside projectorg-projects-root containing the org files.
  27. Defaults to \"org\"
  28. Contains the general notes files, the projects list files and each project notes file.")
  29. ;;;; Functions
  30. (defun projectorg/project-name ()
  31. "Return the full project name.
  32. 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."
  33. (when (projectile-project-p)
  34. (let ((project-path (projectile-project-p)))
  35. (and
  36. (string= (substring project-path 0 (length projectorg-projects-root))
  37. projectorg-projects-root)
  38. (substring project-path (length projectorg-projects-root) -1)))))
  39. (defun projectorg/notes-file ()
  40. "Returns the notes-file location.
  41. It is an org file, with the same name as the project (including subdirectories), located in the *org* directory in projectorg-projects-root."
  42. (let ((project-name (projectorg/project-name)))
  43. (when project-name
  44. (concat projectorg-projects-root "org/" project-name ".org"))))
  45. (defun projectorg/go-to-inbox ()
  46. "Go to org-default-notes-file."
  47. (interactive)
  48. (find-file-other-window org-default-notes-file))
  49. (defun projectorg/go-to-notes ()
  50. "Go to the projects' notes file if it exists in the *org* directory, or go to default notes file."
  51. (interactive)
  52. (let ((notes-file (projectorg/notes-file)))
  53. (if (or (and (eq projectile-require-project-root 'prompt)
  54. (not (projectile-project-p)))
  55. (not (file-exists-p notes-file)))
  56. (projectorg/go-to-inbox)
  57. (find-file-other-window notes-file))))
  58. (defun projectorg/add-to-project-list (FILENAME &optional WILDCARDS)
  59. "Add the currently visited project to the projectile list.
  60. And switch to a perspective for the project."
  61. (when (projectile-project-p FILENAME)
  62. (persp-switch (projectile-project-name (projectile-project-root FILENAME)))
  63. (projectile-add-known-project (projectile-project-root FILENAME))))
  64. (defun projectorg/remove-from-project-list ()
  65. (interactive)
  66. (let ((proj (projectile-project-name)))
  67. (projectile-remove-current-project-from-known-projects)
  68. (projectile-kill-buffers)
  69. (persp-kill proj)))
  70. (provide 'projectorg)
  71. ;;; projectorg.el ends here