add planner-multi support to planner-authz
[planner-el.git] / planner-log-edit.el
blob091529c70464e42711aaf5c047ab37a30a616db1
1 ;;; planner-log-edit.el --- Record VC commits as a note in todays planner file
3 ;; Copyright (C) 2004 Simon Winwood (sjw AT cse.unsw.edu.au)
4 ;; Parts copyright (C) 2004 Free Software Foundation, Inc.
5 ;; Parts copyright (C) 2004 Dryice Dong Liu (dryice AT liu.com.cn)
6 ;; Parts copyright (C) 2005 Yann Hodique (yann.hodique AT gmail.com)
8 ;; Author: Simon Winwood <sjw@cse.unsw.edu.au>
9 ;; Version: 0.1
10 ;; Keywords: planner, vc, pcl-cvs, log-edit
12 ;; This file is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
17 ;; This file is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
24 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; This file records cvs (and VC) commits into todays planner file.
31 ;;; Contributors:
33 ;; Dryice Dong Liu (dryice AT liu.com.cn) provided the
34 ;; `planner-log-edit-quote-filenames-flag' option and patched the code
35 ;; to use it.
37 ;; Yann Hodique added the possibility to ignore patterns before
38 ;; inserting commit messages as notes (useful for psvn) via the new
39 ;; `planner-log-edit-flush-regexp-list' option.
41 ;;; Code:
43 (require 'planner)
44 (require 'log-edit)
46 (defgroup planner-log-edit nil
47 "Planner options for log-edit."
48 :prefix "planner-log-edit-"
49 :group 'planner)
51 (defcustom planner-log-edit-include-files-flag
53 "Non-nil means include a list of committed files in the note."
54 :type 'boolean
55 :group 'planner-log-edit)
57 (defcustom planner-log-edit-quote-filenames-flag
58 nil
59 "Non-nil means quote the file names with \"=\"."
60 :type 'boolean
61 :group 'planner-log-edit)
63 (defcustom planner-log-edit-notice-commit-function t
64 "Function that should return non-nil if this commit should be noted.
65 The function will be run in the log buffer."
66 :type '(choice
67 (const :tag "Always note commits" t)
68 function)
69 :group 'planner-log-edit)
71 (defcustom planner-log-edit-flush-regexp-list
72 nil
73 "List of regexps to flush before inserting note"
74 :type '(repeat regexp)
75 :group 'planner-log-edit)
77 (defcustom planner-log-edit-module-name-function 'planner-log-edit-cvs-module
78 "Function that should return a name for the current module."
79 :type 'function
80 :group 'planner-log-edit)
82 (defun planner-log-edit-quote-file-maybe (arg)
83 "Quote ARG if `planner-log-edit-quote-filenames-flag is non-nil."
84 (if planner-log-edit-quote-filenames-flag
85 (concat "=" arg "=")
86 arg))
88 (defun planner-log-edit-cvs-module ()
89 (condition-case nil
90 (when (fboundp 'cvs-get-module) (cvs-get-module))))
92 ;;;###autoload
93 (defun planner-log-edit-add-note ()
94 "Add a note describing the commit to the current planner page."
95 (let* ((buffer (current-buffer))
96 (files (log-edit-files))
97 ;; This should be a function call into log-edit, but until it
98 ;; exists ...
99 (module-name (funcall planner-log-edit-module-name-function)))
100 (if (if (functionp planner-log-edit-notice-commit-function)
101 (funcall planner-log-edit-notice-commit-function)
102 planner-log-edit-notice-commit-function)
103 (save-excursion
104 (save-window-excursion
105 (planner-create-note nil)
106 (insert "Commit"
107 (if module-name
108 (concat " in "
109 (planner-log-edit-quote-file-maybe
110 module-name))
111 ""))
112 (newline)
113 (when planner-log-edit-include-files-flag
114 (insert "Files: ")
115 (insert (mapconcat 'planner-log-edit-quote-file-maybe files " "))
116 (newline)
117 (newline))
118 (insert
119 (with-temp-buffer
120 (insert-buffer-substring buffer)
121 (goto-char (point-min))
122 (mapc (lambda (regexp)
123 (flush-lines regexp))
124 planner-log-edit-flush-regexp-list)
125 (buffer-string)))
126 ;(insert-buffer-substring buffer)
127 )))))
129 (add-hook 'log-edit-done-hook 'planner-log-edit-add-note)
131 (provide 'planner-log-edit)
133 ;;; planner-log-edit.el ends here