org-projectile tweaks.
This commit is contained in:
parent
4af66fcd60
commit
096c3487b9
27
init.el
27
init.el
@ -277,13 +277,15 @@ The current directory is assumed to be the project's root otherwise."
|
||||
(or (--reduce-from
|
||||
(or acc
|
||||
(let* ((cache-key (format "%s-%s" it dir))
|
||||
(cache-value (gethash cache-key projectile-project-root-cache)))
|
||||
(cache-value (gethash cache-key
|
||||
projectile-project-root-cache)))
|
||||
(if cache-value
|
||||
(if (eq cache-value 'no-project-root)
|
||||
nil
|
||||
cache-value)
|
||||
(let ((value (funcall it dir)))
|
||||
(puthash cache-key (or value 'no-project-root) projectile-project-root-cache)
|
||||
(puthash cache-key (or value 'no-project-root)
|
||||
projectile-project-root-cache)
|
||||
value))))
|
||||
nil
|
||||
projectile-project-root-files-functions)
|
||||
@ -331,20 +333,17 @@ The current directory is assumed to be the project's root otherwise."
|
||||
|
||||
(eval-after-load 'subword '(diminish 'subword-mode))
|
||||
|
||||
(display-time-mode 1)
|
||||
|
||||
;; =============================================================================
|
||||
;; use-package
|
||||
;; =============================================================================
|
||||
|
||||
;; Set path from shell.
|
||||
(use-package exec-path-from-shell
|
||||
:ensure t
|
||||
:config (exec-path-from-shell-initialize))
|
||||
|
||||
(use-package load-dir
|
||||
:ensure t
|
||||
:config
|
||||
(progn
|
||||
(add-to-list 'load-dirs "~/.emacs.d/load.d")
|
||||
(defvar site-lisp "/usr/share/emacs24/site-lisp/")
|
||||
(when (file-exists-p site-lisp) (add-to-list 'load-dirs site-lisp))))
|
||||
|
||||
(use-package tramp
|
||||
:commands tramp
|
||||
:config
|
||||
@ -506,6 +505,14 @@ The current directory is assumed to be the project's root otherwise."
|
||||
:commands string-inflection-toggle
|
||||
:bind ("C-c l" . string-inflection-toggle))
|
||||
|
||||
(use-package load-dir
|
||||
:ensure t
|
||||
:config
|
||||
(progn
|
||||
(add-to-list 'load-dirs "~/.emacs.d/load.d")
|
||||
(defvar site-lisp "/usr/share/emacs24/site-lisp/")
|
||||
(when (file-exists-p site-lisp) (add-to-list 'load-dirs site-lisp))))
|
||||
|
||||
;; =============================================================================
|
||||
;; Non-Programming Stuff
|
||||
;; =============================================================================
|
||||
|
@ -1,11 +1,63 @@
|
||||
;;; org-projectile.el --- Repository todo management for org-mode
|
||||
|
||||
;; Copyright (C) 2014 Ivan Malison
|
||||
|
||||
;; Author: Ivan Malison <IvanMalison@gmail.com>
|
||||
;; Keywords: org projectile todo
|
||||
;; URL: https://github.com/IvanMalison/org-projectile
|
||||
;; Version: 0.0.0
|
||||
|
||||
;; 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:
|
||||
|
||||
;; This package aims to provide an easy interface to creating per
|
||||
;; project org-mode TODO headings.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-capture)
|
||||
(require 'projectile)
|
||||
|
||||
(defvar org-projectile:projects-file "~/org/projects.org")
|
||||
|
||||
(defun org-projectile:project-root-of-filepath (filepath)
|
||||
"Retrieves the root directory of the project to which filepath
|
||||
belongs, if available."
|
||||
(file-truename
|
||||
(let ((dir (file-truename filepath)))
|
||||
(--reduce-from
|
||||
(or acc
|
||||
(let* ((cache-key (format "%s-%s" it dir))
|
||||
(cache-value (gethash cache-key projectile-project-root-cache)))
|
||||
(if cache-value
|
||||
(if (eq cache-value 'no-project-root)
|
||||
nil
|
||||
cache-value)
|
||||
(let ((value (funcall it dir)))
|
||||
(puthash cache-key (or value 'no-project-root) projectile-project-root-cache)
|
||||
value))))
|
||||
nil
|
||||
projectile-project-root-files-functions))))
|
||||
|
||||
(defun org-projectile:project-todo-entry (&optional todo-format)
|
||||
(unless todo-format (setq todo-format "* TODO %?\n"))
|
||||
`("p" "Project Todo" entry
|
||||
(file+function ,org-projectile:projects-file
|
||||
(lambda () (let ((heading (org-projectile:insert-heading-for-filename
|
||||
(org-capture-get :original-file))))
|
||||
(lambda () (let ((heading
|
||||
(org-projectile:insert-heading-for-filename
|
||||
(org-capture-get :original-file))))
|
||||
(org-projectile:insert-or-goto-heading heading)
|
||||
(org-end-of-line)
|
||||
heading)))
|
||||
@ -13,7 +65,7 @@
|
||||
|
||||
(defun org-projectile:project-heading-from-file (filename)
|
||||
(file-name-nondirectory
|
||||
(directory-file-name (project-root-of-file filename))))
|
||||
(directory-file-name (org-projectile:project-root-of-filepath filename))))
|
||||
|
||||
(defun org-projectile:insert-heading-for-filename (filename)
|
||||
(let ((project-heading
|
||||
@ -24,22 +76,21 @@
|
||||
project-heading))
|
||||
|
||||
(defun org-projectile:known-projects ()
|
||||
(delete-dups `(,@(mapcar #'org-projectile:project-heading-from-file (projectile-relevant-known-projects))
|
||||
,@(org-map-entries (lambda () (nth 4 (org-heading-components))) nil (list org-projectile:projects-file)
|
||||
(lambda () (when (< 1 (nth 1 (org-heading-components))) (point)))))))
|
||||
|
||||
|
||||
(defun org-projectile:project-todo-completing-read ()
|
||||
(interactive)
|
||||
(org-projectile:capture-for-project
|
||||
(projectile-completing-read "Record TODO for project:"
|
||||
(org-projectile:known-projects))))
|
||||
(delete-dups `(,@(mapcar #'org-projectile:project-heading-from-file
|
||||
(projectile-relevant-known-projects))
|
||||
,@(org-map-entries
|
||||
(lambda () (nth 4 (org-heading-components))) nil
|
||||
(list org-projectile:projects-file)
|
||||
(lambda ()
|
||||
(when (< 1 (nth 1 (org-heading-components)))
|
||||
(point)))))))
|
||||
|
||||
(defun org-projectile:capture-for-project (heading)
|
||||
(org-capture-set-plist (org-projectile:project-todo-entry))
|
||||
(with-current-buffer (find-file-noselect org-projectile:projects-file)
|
||||
(org-projectile:project-heading heading))
|
||||
(org-capture-set-target-location `(file+headline ,org-projectile:projects-file ,heading))
|
||||
(org-capture-set-target-location `(file+headline
|
||||
,org-projectile:projects-file ,heading))
|
||||
(org-capture-place-template))
|
||||
|
||||
(defun org-projectile:insert-or-goto-heading (heading)
|
||||
@ -66,5 +117,12 @@
|
||||
(org-beginning-of-line)
|
||||
(org-set-property "CATEGORY" heading))
|
||||
|
||||
(require 'org-capture)
|
||||
(require 'projectile)
|
||||
;;;###autoload
|
||||
(defun org-projectile:project-todo-completing-read ()
|
||||
(interactive)
|
||||
(org-projectile:capture-for-project
|
||||
(projectile-completing-read "Record TODO for project:"
|
||||
(org-projectile:known-projects))))
|
||||
|
||||
(provide 'org-projectile)
|
||||
;;; org-projectile.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user