Skip to content

Commit

Permalink
Check plugins are enabled if required.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Hutchings committed Jun 24, 2010
1 parent bac3b39 commit 0bcf5eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
31 changes: 31 additions & 0 deletions ditz-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
(defconst ditz-config-filename ".ditz-config"
"File name of the Ditz config file.")

(defconst ditz-plugin-filename ".ditz-plugins"
"File name of the Ditz plugin file.")

(defconst ditz-issue-id-regex "\\([a-z][a-z-]*-[0-9]+\\)"
"Regex for issue id.")

Expand Down Expand Up @@ -231,26 +234,31 @@
(defun ditz-claim ()
"Claim an issue."
(interactive)
(ditz-require "issue-claiming")
(ditz-call-process "claim" (ditz-current-issue) 'switch t))

(defun ditz-unclaim ()
"Unclaim an issue."
(interactive)
(ditz-require "issue-claiming")
(ditz-call-process "unclaim" (ditz-current-issue) 'switch t))

(defun ditz-show-claimed ()
"Show list of claimed issues."
(interactive)
(ditz-require "issue-claiming")
(ditz-call-process "claimed" ditz-todo-release 'switch))

(defun ditz-show-unclaimed ()
"Show list of unclaimed issues."
(interactive)
(ditz-require "issue-claiming")
(ditz-call-process "unclaimed" ditz-todo-release 'switch))

(defun ditz-show-mine ()
"Show list of my issues."
(interactive)
(ditz-require "issue-claiming")
(ditz-call-process "mine" ditz-todo-release 'switch))

(defun ditz-set-component ()
Expand Down Expand Up @@ -505,6 +513,7 @@ current directory or the one with the .ditz-config file in it."

;; Get issue directory name from config file.
(with-current-buffer buf
(erase-buffer)
(insert-file-contents configfile nil nil nil t)
(goto-char (point-min))
(if (search-forward "issue_dir: ")
Expand Down Expand Up @@ -541,6 +550,28 @@ current directory or the one with the .ditz-config file in it."
(setq curdir (directory-file-name (file-name-directory curdir))))))
(expand-file-name configfile)))

(defun ditz-plugin-file ()
"Return pathname of the Ditz plugin file."
(let* ((configfile (ditz-config-file))
(parentdir (file-name-directory configfile)))
(concat parentdir ditz-plugin-filename)))

(defun ditz-require (plugin)
"Raise error if a plugin is not enabled."

(let ((pluginfile (ditz-plugin-file))
(buf (get-buffer-create "*ditz-plugins*"))
(enabled nil))
(with-current-buffer buf
(erase-buffer)
(if (file-exists-p pluginfile)
(insert-file-contents pluginfile nil nil nil t))
(goto-char (point-min))
(if (search-forward plugin nil t)
(setq enabled t)))
(unless enabled
(error "Ditz '%s' plugin is not enabled" plugin))))

(defun ditz-show-thing ()
"Show current thing in another window."
(cond ((or (ditz-current-buffer-p "todo")
Expand Down
8 changes: 6 additions & 2 deletions issues/issue-58b630173191bcdded467449330556d7312379d4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ type: :task
component: ditz-mode
release: "0.3"
reporter: Glenn Hutchings <zondo42@googlemail.com>
status: :unstarted
disposition:
status: :closed
disposition: :fixed
creation_time: 2010-06-24 14:19:03.940792 Z
references: []

Expand All @@ -16,3 +16,7 @@ log_events:
- Glenn Hutchings <zondo42@googlemail.com>
- created
- ""
- - 2010-06-24 14:52:23.214101 Z
- Glenn Hutchings <zondo42@googlemail.com>
- closed with disposition fixed
- ""

0 comments on commit 0bcf5eb

Please sign in to comment.