|
|
@@ -26,15 +26,42 @@ |
|
|
|
|
|
|
|
;;; Code: |
|
|
|
|
|
|
|
;;;; Variables |
|
|
|
|
|
|
|
(defvar projectorg-projects-root "/home/maxx/Projects/" |
|
|
|
"Where all projects are rooted. |
|
|
|
|
|
|
|
This is the directory where projects are stored. |
|
|
|
Can contain subdirectories. |
|
|
|
The *org* subdirectory contains the notes file for each project, as well as the general notes files and the projects list 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." |
|
|
|
(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." |
|
|
|
(concat projectorg-projects-root "org/" (projectorg/project-name) ".org")) |
|
|
|
|
|
|
|
(defun projectorg/go-to-inbox () |
|
|
|
"Go to org-default-notes-file" |
|
|
|
"Go to org-default-notes-file." |
|
|
|
(interactive) |
|
|
|
(find-file org-default-notes-file)) |
|
|
|
|
|
|
|
(defun projectorg/go-to-notes () |
|
|
|
"Go to notes.org if it exists at the root of a project, org go to default notes file" |
|
|
|
"Go to the projects' notes file if it exists in the *org* directory, or go to default notes file." |
|
|
|
(interactive) |
|
|
|
(let ((notes-file (concat (projectile-project-p) "notes.org"))) |
|
|
|
(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))) |
|
|
@@ -42,7 +69,8 @@ |
|
|
|
(find-file notes-file)))) |
|
|
|
|
|
|
|
(defun projectorg/add-to-project-list () |
|
|
|
(let ((notes-file (concat (projectile-project-p) "notes.org"))) |
|
|
|
"Add the currently visited project to the projectile list." |
|
|
|
(let ((notes-file (projectorg/notes-file))) |
|
|
|
(unless (or (and (eq projectile-require-project-root 'prompt) |
|
|
|
(not (projectile-project-p))) |
|
|
|
(not (file-exists-p notes-file))) |
|
|
|