annotate lisp/log-edit.el @ 90621:d8a2b76fe3d4

(Qunicode_sip): Extern it.
author Kenichi Handa <handa@m17n.org>
date Tue, 17 Oct 2006 12:33:26 +0000
parents 2ecafc6d5db7
children f1d13e615070
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; log-edit.el --- Major mode for editing CVS commit messages
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67194
diff changeset
4 ;; 2005, 2006 Free Software Foundation, Inc.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5
70292
2b77fa42947f Update my email address.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68651
diff changeset
6 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 ;; Keywords: pcl-cvs cvs commit log
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; any later version.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63255
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63255
diff changeset
24 ;; Boston, MA 02110-1301, USA.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26 ;;; Commentary:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 ;; Todo:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 ;; - Move in VC's code
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 ;; - Add compatibility for VC's hook variables
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 ;;; Code:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (eval-when-compile (require 'cl))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 (require 'add-log) ; for all the ChangeLog goodies
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 (require 'pcvs-util)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 (require 'ring)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
40 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;;;; Global Variables
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
42 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (defgroup log-edit nil
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
45 "Major mode for editing RCS and CVS commit messages."
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 :group 'pcl-cvs
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
47 :group 'vc ; It's used by VC.
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
48 :version "21.1"
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 :prefix "log-edit-")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 ;; compiler pacifiers
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (defvar cvs-buffer)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
54
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
55 ;; The main keymap
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
56
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (easy-mmode-defmap log-edit-mode-map
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 `(("\C-c\C-c" . log-edit-done)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ("\C-c\C-a" . log-edit-insert-changelog)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 ("\C-c\C-f" . log-edit-show-files)
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
61 ("\M-n" . log-edit-next-comment)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
62 ("\M-p" . log-edit-previous-comment)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
63 ("\M-r" . log-edit-comment-search-backward)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
64 ("\M-s" . log-edit-comment-search-forward)
51065
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
65 ("\C-c?" . log-edit-mode-help))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
66 "Keymap for the `log-edit-mode' (to edit version control log messages)."
51065
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
67 :group 'log-edit)
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
68
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
69 ;; Compatibility with old names. Should we bother ?
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
70 (defvar vc-log-mode-map log-edit-mode-map)
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
71 (defvar vc-log-entry-mode vc-log-mode-map)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72
33180
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
73 (easy-menu-define log-edit-menu log-edit-mode-map
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
74 "Menu used for `log-edit-mode'."
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
75 '("Log-Edit"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
76 ["Done" log-edit-done
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
77 :help "Exit log-edit and proceed with the actual action."]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
78 "--"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
79 ["Insert ChangeLog" log-edit-insert-changelog]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
80 ["Add to ChangeLog" log-edit-add-to-changelog]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
81 "--"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
82 ["List files" log-edit-show-files
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
83 :help "Show the list of relevant files."]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
84 "--"
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
85 ["Previous comment" log-edit-previous-comment]
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
86 ["Next comment" log-edit-next-comment]
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
87 ["Search comment forward" log-edit-comment-search-forward]
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
88 ["Search comment backward" log-edit-comment-search-backward]))
33180
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
89
33061
3cbd3cc4cc8b (log-edit-confirm): Fix the default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32816
diff changeset
90 (defcustom log-edit-confirm 'changed
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 "*If non-nil, `log-edit-done' will request confirmation.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 If 'changed, only request confirmation if the list of files has
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 changed since the beginning of the log-edit session."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 :type '(choice (const changed) (const t) (const nil)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (defcustom log-edit-keep-buffer nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 "*If non-nil, don't hide the buffer after `log-edit-done'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 :type 'boolean)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101
49616
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
102 (defvar cvs-commit-buffer-require-final-newline t)
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
103 (make-obsolete-variable 'cvs-commit-buffer-require-final-newline
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
104 'log-edit-require-final-newline)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 (defcustom log-edit-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 cvs-commit-buffer-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 "*Enforce a newline at the end of commit log messages.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 Enforce it silently if t, query if non-nil and don't do anything if nil."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 :type '(choice (const ask) (const t) (const nil)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 (defcustom log-edit-setup-invert nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 "*Non-nil means `log-edit' should invert the meaning of its SETUP arg.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 If SETUP is 'force, this variable has no effect."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 :type 'boolean)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 (defcustom log-edit-hook '(log-edit-insert-cvs-template
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 log-edit-insert-changelog)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 "*Hook run at the end of `log-edit'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 :group 'log-edit
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
123 :type '(hook :options (log-edit-insert-changelog
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
124 log-edit-insert-cvs-rcstemplate
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
125 log-edit-insert-cvs-template
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
126 log-edit-insert-filenames)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127
28340
b90fe8a937ae (log-edit-mode-hook): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28338
diff changeset
128 (defcustom log-edit-mode-hook (if (boundp 'vc-log-mode-hook) vc-log-mode-hook)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 "*Hook run when entering `log-edit-mode'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 :type 'hook)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 (defcustom log-edit-done-hook nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 "*Hook run before doing the actual commit.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 This hook can be used to cleanup the message, enforce various
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 conventions, or to allow recording the message in some other database,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 such as a bug-tracking system. The list of files about to be committed
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 can be obtained from `log-edit-files'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 :group 'log-edit
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
140 :type '(hook :options (log-edit-set-common-indentation
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 log-edit-add-to-changelog)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142
49616
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
143 (defvar cvs-changelog-full-paragraphs t)
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
144 (make-obsolete-variable 'cvs-changelog-full-paragraphs
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
145 'log-edit-changelog-full-paragraphs)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
146
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
147 (defvar log-edit-changelog-full-paragraphs cvs-changelog-full-paragraphs
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
148 "*If non-nil, include full ChangeLog paragraphs in the log.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 This may be set in the ``local variables'' section of a ChangeLog, to
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 indicate the policy for that ChangeLog.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 A ChangeLog paragraph is a bunch of log text containing no blank lines;
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 a paragraph usually describes a set of changes with a single purpose,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 but perhaps spanning several functions in several files. Changes in
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 different paragraphs are unrelated.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
157 You could argue that the log entry for a file should contain the
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 full ChangeLog paragraph mentioning the change to the file, even though
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 it may mention other files, because that gives you the full context you
63255
4f2b9ea9b006 (log-edit-changelog-full-paragraphs): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 62707
diff changeset
160 need to understand the change. This is the behavior you get when this
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 variable is set to t.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
163 On the other hand, you could argue that the log entry for a change
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 should contain only the text for the changes which occurred in that
63255
4f2b9ea9b006 (log-edit-changelog-full-paragraphs): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 62707
diff changeset
165 file, because the log is per-file. This is the behavior you get
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 when this variable is set to nil.")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 ;;;; Internal global or buffer-local vars
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 (defconst log-edit-files-buf "*log-edit-files*")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 (defvar log-edit-initial-files nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 (defvar log-edit-callback nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (defvar log-edit-listfun nil)
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
174 (defvar log-edit-parent-buffer nil)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
176 ;;; Originally taken from VC-Log mode
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
177
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
178 (defconst log-edit-maximum-comment-ring-size 32
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
179 "Maximum number of saved comments in the comment ring.")
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
180 (defvar log-edit-comment-ring (make-ring log-edit-maximum-comment-ring-size))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
181 (defvar log-edit-comment-ring-index nil)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
182 (defvar log-edit-last-comment-match "")
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
183
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
184 (defun log-edit-new-comment-index (stride len)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
185 "Return the comment index STRIDE elements from the current one.
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
186 LEN is the length of `log-edit-comment-ring'."
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
187 (mod (cond
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
188 (log-edit-comment-ring-index (+ log-edit-comment-ring-index stride))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
189 ;; Initialize the index on the first use of this command
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
190 ;; so that the first M-p gets index 0, and the first M-n gets
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
191 ;; index -1.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
192 ((> stride 0) (1- stride))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
193 (t stride))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
194 len))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
195
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
196 (defun log-edit-previous-comment (arg)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
197 "Cycle backwards through comment history.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
198 With a numeric prefix ARG, go back ARG comments."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
199 (interactive "*p")
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
200 (let ((len (ring-length log-edit-comment-ring)))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
201 (if (<= len 0)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
202 (progn (message "Empty comment ring") (ding))
51065
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
203 ;; Don't use `erase-buffer' because we don't want to `widen'.
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
204 (delete-region (point-min) (point-max))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
205 (setq log-edit-comment-ring-index (log-edit-new-comment-index arg len))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
206 (message "Comment %d" (1+ log-edit-comment-ring-index))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
207 (insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index)))))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
208
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
209 (defun log-edit-next-comment (arg)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
210 "Cycle forwards through comment history.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
211 With a numeric prefix ARG, go forward ARG comments."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
212 (interactive "*p")
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
213 (log-edit-previous-comment (- arg)))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
214
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
215 (defun log-edit-comment-search-backward (str &optional stride)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
216 "Search backwards through comment history for substring match of STR.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
217 If the optional argument STRIDE is present, that is a step-width to use
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
218 when going through the comment ring."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
219 ;; Why substring rather than regexp ? -sm
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
220 (interactive
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
221 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
222 (unless stride (setq stride 1))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
223 (if (string= str "")
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
224 (setq str log-edit-last-comment-match)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
225 (setq log-edit-last-comment-match str))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
226 (let* ((str (regexp-quote str))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
227 (len (ring-length log-edit-comment-ring))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
228 (n (log-edit-new-comment-index stride len)))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
229 (while (progn (when (or (>= n len) (< n 0)) (error "Not found"))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
230 (not (string-match str (ring-ref log-edit-comment-ring n))))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
231 (setq n (+ n stride)))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
232 (setq log-edit-comment-ring-index n)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
233 (log-edit-previous-comment 0)))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
234
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
235 (defun log-edit-comment-search-forward (str)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
236 "Search forwards through comment history for a substring match of STR."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
237 (interactive
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
238 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
239 (log-edit-comment-search-backward str -1))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
240
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
241 (defun log-edit-comment-to-change-log (&optional whoami file-name)
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
242 "Enter last VC comment into the change log for the current file.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
243 WHOAMI (interactive prefix) non-nil means prompt for user name
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
244 and site. FILE-NAME is the name of the change log; if nil, use
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
245 `change-log-default-name'.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
246
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
247 This may be useful as a `log-edit-checkin-hook' to update change logs
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
248 automatically."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
249 (interactive (if current-prefix-arg
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
250 (list current-prefix-arg
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
251 (prompt-for-change-log-name))))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
252 (let (;; Extract the comment first so we get any error before doing anything.
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
253 (comment (ring-ref log-edit-comment-ring 0))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
254 ;; Don't let add-change-log-entry insert a defun name.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
255 (add-log-current-defun-function 'ignore)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
256 end)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
257 ;; Call add-log to do half the work.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
258 (add-change-log-entry whoami file-name t t)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
259 ;; Insert the VC comment, leaving point before it.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
260 (setq end (save-excursion (insert comment) (point-marker)))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
261 (if (looking-at "\\s *\\s(")
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
262 ;; It starts with an open-paren, as in "(foo): Frobbed."
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
263 ;; So remove the ": " add-log inserted.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
264 (delete-char -2))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
265 ;; Canonicalize the white space between the file name and comment.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
266 (just-one-space)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
267 ;; Indent rest of the text the same way add-log indented the first line.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
268 (let ((indentation (current-indentation)))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
269 (save-excursion
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
270 (while (< (point) end)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
271 (forward-line 1)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
272 (indent-to indentation))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
273 (setq end (point))))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
274 ;; Fill the inserted text, preserving open-parens at bol.
51065
35933dc8e248 Don't require vc.el anymore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51063
diff changeset
275 (let ((paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
51063
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
276 (beginning-of-line)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
277 (fill-region (point) end))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
278 ;; Canonicalize the white space at the end of the entry so it is
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
279 ;; separated from the next entry by a single blank line.
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
280 (skip-syntax-forward " " end)
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
281 (delete-char (- (skip-syntax-backward " ")))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
282 (or (eobp) (looking-at "\n\n")
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
283 (insert "\n"))))
66dd7f2dd70a (vc-log-mode-map, vc-maximum-comment-ring-size, vc-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49616
diff changeset
284
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
285 ;; Compatibility with old names.
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
286 (define-obsolete-variable-alias 'vc-comment-ring 'log-edit-comment-ring "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
287 (define-obsolete-variable-alias 'vc-comment-ring-index 'log-edit-comment-ring-index "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
288 (define-obsolete-function-alias 'vc-previous-comment 'log-edit-previous-comment "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
289 (define-obsolete-function-alias 'vc-next-comment 'log-edit-next-comment "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
290 (define-obsolete-function-alias 'vc-comment-search-reverse 'log-edit-comment-search-backward "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
291 (define-obsolete-function-alias 'vc-comment-search-forward 'log-edit-comment-search-forward "22.1")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
292 (define-obsolete-function-alias 'vc-comment-to-change-log 'log-edit-comment-to-change-log "22.1")
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
293
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
294 ;;;
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
295 ;;; Actual code
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
296 ;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297
54422
4f7b9dbf832e (log-edit-font-lock-keywords): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54417
diff changeset
298 (defvar log-edit-font-lock-keywords
54417
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
299 '(("\\`\\(Summary:\\)\\(.*\\)"
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
300 (1 font-lock-keyword-face)
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
301 (2 font-lock-function-name-face))))
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
302
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 ;;;###autoload
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
304 (defun log-edit (callback &optional setup listfun buffer &rest ignore)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 "Setup a buffer to enter a log message.
33061
3cbd3cc4cc8b (log-edit-confirm): Fix the default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32816
diff changeset
306 \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 Mark and point will be set around the entire contents of the
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 buffer so that it is easy to kill the contents of the buffer with \\[kill-region].
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 Once you're done editing the message, pressing \\[log-edit-done] will call
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
311 `log-edit-done' which will end up calling CALLBACK to do the actual commit.
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
312 LISTFUN if non-nil is a function of no arguments returning the list of files
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
313 that are concerned by the current operation (using relative names).
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
314 If BUFFER is non-nil `log-edit' will jump to that buffer, use it to edit the
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
315 log message and go back to the current buffer when done. Otherwise, it
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
316 uses the current buffer."
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
317 (let ((parent (current-buffer)))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
318 (if buffer (pop-to-buffer buffer))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
319 (when (and log-edit-setup-invert (not (eq setup 'force)))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
320 (setq setup (not setup)))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
321 (when setup (erase-buffer))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
322 (log-edit-mode)
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
323 (set (make-local-variable 'log-edit-callback) callback)
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
324 (set (make-local-variable 'log-edit-listfun) listfun)
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
325 (if buffer (set (make-local-variable 'log-edit-parent-buffer) parent))
40478
4d0323a1ed72 (log-edit): Run hook after `log-edit-files'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37694
diff changeset
326 (set (make-local-variable 'log-edit-initial-files) (log-edit-files))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
327 (when setup (run-hooks 'log-edit-hook))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
328 (goto-char (point-min)) (push-mark (point-max))
65582
4d1085b02d64 Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents: 64762
diff changeset
329 (message "%s" (substitute-command-keys
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
330 "Press \\[log-edit-done] when you are done editing."))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (define-derived-mode log-edit-mode text-mode "Log-Edit"
28338
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
333 "Major mode for editing version-control log messages.
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
334 When done editing the log entry, just type \\[log-edit-done] which
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
335 will trigger the actual commit of the file(s).
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
336 Several other handy support commands are provided of course and
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
337 the package from which this is used might also provide additional
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
338 commands (under C-x v for VC, for example).
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
339
29375
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
340 \\{log-edit-mode-map}"
54417
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
341 (set (make-local-variable 'font-lock-defaults)
ae0720c5c65c (log-edit-font-lock-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52791
diff changeset
342 '(log-edit-font-lock-keywords t))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
343 (make-local-variable 'log-edit-comment-ring-index))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 (defun log-edit-hide-buf (&optional buf where)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 (when (setq buf (get-buffer (or buf log-edit-files-buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 (let ((win (get-buffer-window buf where)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 (if win (ignore-errors (delete-window win))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 (bury-buffer buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 (defun log-edit-done ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 "Finish editing the log message and commit the files.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 If you want to abort the commit, simply delete the buffer."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 (interactive)
29042
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
355 ;; Get rid of trailing empty lines
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
356 (goto-char (point-max))
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
357 (skip-syntax-backward " ")
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
358 (when (equal (char-after) ?\n) (forward-char 1))
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
359 (delete-region (point) (point-max))
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
360 ;; Check for final newline
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
361 (if (and (> (point-max) (point-min))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
362 (/= (char-before (point-max)) ?\n)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (or (eq log-edit-require-final-newline t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 (and log-edit-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (y-or-n-p
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (format "Buffer %s does not end in newline. Add one? "
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (buffer-name))))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (goto-char (point-max))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 (insert ?\n)))
29375
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
371 (let ((comment (buffer-string)))
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
372 (when (or (ring-empty-p log-edit-comment-ring)
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
373 (not (equal comment (ring-ref log-edit-comment-ring 0))))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
374 (ring-insert log-edit-comment-ring comment)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 (let ((win (get-buffer-window log-edit-files-buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 (if (and log-edit-confirm
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 (not (and (eq log-edit-confirm 'changed)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (equal (log-edit-files) log-edit-initial-files)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 (progn
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 (log-edit-show-files)
65689
96187e7edd1b 2005-09-25 Romain Francoise <romain@orebokech.com>
Romain Francoise <romain@orebokech.com>
parents: 65582
diff changeset
381 (not (y-or-n-p "Really commit? "))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 (progn (when (not win) (log-edit-hide-buf))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (message "Oh, well! Later maybe?"))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 (run-hooks 'log-edit-done-hook)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 (log-edit-hide-buf)
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
386 (unless (or log-edit-keep-buffer (not log-edit-parent-buffer))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
387 (cvs-bury-buffer (current-buffer) log-edit-parent-buffer))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 (call-interactively log-edit-callback))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (defun log-edit-files ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 "Return the list of files that are about to be committed."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 (ignore-errors (funcall log-edit-listfun)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394 (defun log-edit-mode-help ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 "Provide help for the `log-edit-mode-map'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (if (eq last-command 'log-edit-mode-help)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (describe-function major-mode)
65582
4d1085b02d64 Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents: 64762
diff changeset
399 (message "%s"
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 (substitute-command-keys
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 "Type `\\[log-edit-done]' to finish commit. Try `\\[describe-function] log-edit-done' for more help."))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
403 (defcustom log-edit-common-indent 0
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
404 "Minimum indentation to use in `log-edit-set-common-indentation'."
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
405 :group 'log-edit
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
406 :type 'integer)
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
407
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
408 (defun log-edit-set-common-indentation ()
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
409 "(Un)Indent the current buffer rigidly to `log-edit-common-indent'."
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 (let ((common (point-max)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413 (while (< (point) (point-max))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 (if (not (looking-at "^[ \t]*$"))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (setq common (min common (current-indentation))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 (forward-line 1))
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
417 (indent-rigidly (point-min) (point-max)
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
418 (- log-edit-common-indent common)))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 (defun log-edit-show-files ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 "Show the list of files to be committed."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 (let* ((files (log-edit-files))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
424 (buf (get-buffer-create log-edit-files-buf)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (with-current-buffer buf
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 (log-edit-hide-buf buf 'all)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 (setq buffer-read-only nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 (erase-buffer)
33232
abfd948c10d4 (log-edit-show-files): Use cvs-insert-strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33180
diff changeset
429 (cvs-insert-strings files)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 (setq buffer-read-only t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (save-selected-window
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (cvs-pop-to-buffer-same-frame buf)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (shrink-window-if-larger-than-buffer)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 (selected-window)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 (defun log-edit-insert-cvs-template ()
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
438 "Insert the template specified by the CVS administrator, if any.
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
439 This simply uses the local CVS/Template file."
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 (interactive)
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
441 (when (or (interactive-p) (= (point-min) (point-max)))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
442 (when (file-readable-p "CVS/Template")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
443 (insert-file-contents "CVS/Template"))))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
444
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
445 (defun log-edit-insert-cvs-rcstemplate ()
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
446 "Insert the rcstemplate from the CVS repository.
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
447 This contacts the repository to get the rcstemplate file and
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
448 can thus take some time."
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
449 (interactive)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
450 (when (or (interactive-p) (= (point-min) (point-max)))
67194
b4ad6ef2b752 (log-edit-insert-cvs-rcstemplate): Ignore stderr.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67183
diff changeset
451 (when (file-readable-p "CVS/Root")
b4ad6ef2b752 (log-edit-insert-cvs-rcstemplate): Ignore stderr.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67183
diff changeset
452 ;; Ignore the stderr stuff, even if it's an error.
b4ad6ef2b752 (log-edit-insert-cvs-rcstemplate): Ignore stderr.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67183
diff changeset
453 (call-process "cvs" nil '(t nil) nil
b4ad6ef2b752 (log-edit-insert-cvs-rcstemplate): Ignore stderr.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67183
diff changeset
454 "checkout" "-p" "CVSROOT/rcstemplate"))))
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
455
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
456 (defun log-edit-insert-filenames ()
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
457 "Insert the list of files that are to be committed."
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
458 (interactive)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
459 (insert "Affected files: \n"
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
460 (mapconcat 'identity (log-edit-files) " \n")))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 (defun log-edit-add-to-changelog ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 "Insert this log message into the appropriate ChangeLog file."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 ;; Yuck!
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
466 (unless (string= (buffer-string) (ring-ref log-edit-comment-ring 0))
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
467 (ring-insert log-edit-comment-ring (buffer-string)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 (dolist (f (log-edit-files))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 (let ((buffer-file-name (expand-file-name f)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (save-excursion
51368
cc73795bc08a (log-edit-maximum-comment-ring-size, log-edit-comment-ring)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51065
diff changeset
471 (log-edit-comment-to-change-log)))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
473 (defvar log-edit-changelog-use-first nil)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
474 (defun log-edit-insert-changelog (&optional use-first)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
475 "Insert a log message by looking at the ChangeLog.
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
476 The idea is to write your ChangeLog entries first, and then use this
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
477 command to commit your changes.
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
478
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
479 To select default log text, we:
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
480 - find the ChangeLog entries for the files to be checked in,
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
481 - verify that the top entry in the ChangeLog is on the current date
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
482 and by the current user; if not, we don't provide any default text,
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
483 - search the ChangeLog entry for paragraphs containing the names of
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
484 the files we're checking in, and finally
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
485 - use those paragraphs as the log text.
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
486
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
487 If the optional prefix arg USE-FIRST is given (via \\[universal-argument]),
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
488 or if the command is repeated a second time in a row, use the first log entry
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
489 regardless of user name or time."
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
490 (interactive "P")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
491 (let ((log-edit-changelog-use-first
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
492 (or use-first (eq last-command 'log-edit-insert-changelog))))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
493 (log-edit-insert-changelog-entries (log-edit-files)))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
494 (log-edit-set-common-indentation)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
495 (goto-char (point-min))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
496 (when (looking-at "\\*\\s-+")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
497 (forward-line 1)
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
498 (when (not (re-search-forward "^\\*\\s-+" nil t))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
499 (goto-char (point-min))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
500 (skip-chars-forward "^():")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
501 (skip-chars-forward ": ")
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
502 (delete-region (point-min) (point)))))
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
503
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
504 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505 ;;;; functions for getting commit message from ChangeLog a file...
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 ;;;; Courtesy Jim Blandy
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
507 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
509 (defun log-edit-narrow-changelog ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510 "Narrow to the top page of the current buffer, a ChangeLog file.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 Actually, the narrowed region doesn't include the date line.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 A \"page\" in a ChangeLog file is the area between two dates."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 (or (eq major-mode 'change-log-mode)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
514 (error "log-edit-narrow-changelog: current buffer isn't a ChangeLog"))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 ;; Skip date line and subsequent blank lines.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 (forward-line 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 (if (looking-at "[ \t\n]*\n")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 (goto-char (match-end 0)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 (let ((start (point)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 (forward-page 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
525 (narrow-to-region start (point))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
526 (goto-char (point-min))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
527
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
528 (defun log-edit-changelog-paragraph ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 "Return the bounds of the ChangeLog paragraph containing point.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 If we are between paragraphs, return the previous paragraph."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 (beginning-of-line)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 (if (looking-at "^[ \t]*$")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 (skip-chars-backward " \t\n" (point-min)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 (list (progn
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (goto-char (match-end 0)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 (point))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 (if (re-search-forward "^[ \t\n]*$" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 (match-beginning 0)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 (point)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
543 (defun log-edit-changelog-subparagraph ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544 "Return the bounds of the ChangeLog subparagraph containing point.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 A subparagraph is a block of non-blank lines beginning with an asterisk.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 If we are between sub-paragraphs, return the previous subparagraph."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
548 (end-of-line)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 (if (search-backward "*" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 (list (progn (beginning-of-line) (point))
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
551 (progn
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552 (forward-line 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 (if (re-search-forward "^[ \t]*[\n*]" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554 (match-beginning 0)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 (point-max))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (list (point) (point)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
558 (defun log-edit-changelog-entry ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 "Return the bounds of the ChangeLog entry containing point.
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
560 The variable `log-edit-changelog-full-paragraphs' decides whether an
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 \"entry\" is a paragraph or a subparagraph; see its documentation string
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562 for more details."
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
563 (if log-edit-changelog-full-paragraphs
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
564 (log-edit-changelog-paragraph)
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
565 (log-edit-changelog-subparagraph)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
566
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
567 (defvar user-full-name)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
568 (defvar user-mail-address)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
569 (defun log-edit-changelog-ours-p ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
570 "See if ChangeLog entry at point is for the current user, today.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
571 Return non-nil iff it is."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572 ;; Code adapted from add-change-log-entry.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 (let ((name (or (and (boundp 'add-log-full-name) add-log-full-name)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
574 (and (fboundp 'user-full-name) (user-full-name))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575 (and (boundp 'user-full-name) user-full-name)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
576 (mail (or (and (boundp 'add-log-mailing-address) add-log-mailing-address)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
577 ;;(and (fboundp 'user-mail-address) (user-mail-address))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
578 (and (boundp 'user-mail-address) user-mail-address)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
579 (time (or (and (boundp 'add-log-time-format)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
580 (functionp add-log-time-format)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
581 (funcall add-log-time-format))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
582 (format-time-string "%Y-%m-%d"))))
67183
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
583 (looking-at (if log-edit-changelog-use-first
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
584 "[^ \t]"
2ff424a9019b *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65689
diff changeset
585 (regexp-quote (format "%s %s <%s>" time name mail))))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
586
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
587 (defun log-edit-changelog-entries (file)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588 "Return the ChangeLog entries for FILE, and the ChangeLog they came from.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589 The return value looks like this:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590 (LOGBUFFER (ENTRYSTART . ENTRYEND) ...)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
591 where LOGBUFFER is the name of the ChangeLog buffer, and each
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
592 \(ENTRYSTART . ENTRYEND\) pair is a buffer region."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
593 (save-excursion
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
594 (let ((changelog-file-name
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
595 (let ((default-directory
52791
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
596 (file-name-directory (expand-file-name file)))
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
597 (visiting-buffer (find-buffer-visiting file)))
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
598 ;; If there is a buffer visiting FILE, and it has a local
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
599 ;; value for `change-log-default-name', use that.
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
600 (if (and visiting-buffer
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
601 (local-variable-p 'change-log-default-name
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
602 visiting-buffer))
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
603 (save-excursion
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
604 (set-buffer visiting-buffer)
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
605 change-log-default-name)
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
606 ;; `find-change-log' uses `change-log-default-name' if set
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
607 ;; and sets it before exiting, so we need to work around
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
608 ;; that memoizing which is undesired here
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
609 (setq change-log-default-name nil)
2ea08fedb58f (log-edit-changelog-entries): Prefer local value of
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
610 (find-change-log)))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
611 (set-buffer (find-file-noselect changelog-file-name))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
612 (unless (eq major-mode 'change-log-mode) (change-log-mode))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
613 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
614 (if (looking-at "\\s-*\n") (goto-char (match-end 0)))
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
615 (if (not (log-edit-changelog-ours-p))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
616 (list (current-buffer))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
617 (save-restriction
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
618 (log-edit-narrow-changelog)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
619 (goto-char (point-min))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
620
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
621 ;; Search for the name of FILE relative to the ChangeLog. If that
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
622 ;; doesn't occur anywhere, they're not using full relative
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
623 ;; filenames in the ChangeLog, so just look for FILE; we'll accept
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
624 ;; some false positives.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
625 (let ((pattern (file-relative-name
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
626 file (file-name-directory changelog-file-name))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
627 (if (or (string= pattern "")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
628 (not (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
629 (search-forward pattern nil t))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
630 (setq pattern (file-name-nondirectory file)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
631
62707
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
632 (setq pattern (concat "\\(^\\|[^[:alnum:]]\\)"
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
633 pattern
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
634 "\\($\\|[^[:alnum:]]\\)"))
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
635
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
636 (let (texts)
62707
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
637 (while (re-search-forward pattern nil t)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
638 (let ((entry (log-edit-changelog-entry)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
639 (push entry texts)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
640 (goto-char (elt entry 1))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
641
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
642 (cons (current-buffer) texts))))))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
643
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
644 (defun log-edit-changelog-insert-entries (buffer regions)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
645 "Insert those regions in BUFFER specified in REGIONS.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
646 Sort REGIONS front-to-back first."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
647 (let ((regions (sort regions 'car-less-than-car))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
648 (last))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
649 (dolist (region regions)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
650 (when (and last (< last (car region))) (newline))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
651 (setq last (elt region 1))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
652 (apply 'insert-buffer-substring buffer region))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
653
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
654 (defun log-edit-insert-changelog-entries (files)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
655 "Given a list of files FILES, insert the ChangeLog entries for them."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
656 (let ((buffer-entries nil))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
657
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
658 ;; Add each buffer to buffer-entries, and associate it with the list
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
659 ;; of entries we want from that file.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
660 (dolist (file files)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
661 (let* ((entries (log-edit-changelog-entries file))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
662 (pair (assq (car entries) buffer-entries)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
663 (if pair
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
664 (setcdr pair (cvs-union (cdr pair) (cdr entries)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
665 (push entries buffer-entries))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
666
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
667 ;; Now map over each buffer in buffer-entries, sort the entries for
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
668 ;; each buffer, and extract them as strings.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
669 (dolist (buffer-entry buffer-entries)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
670 (log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
671 (when (cdr buffer-entry) (newline)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
672
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
673 (provide 'log-edit)
28338
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
674
62707
08bad0f3de3f (log-edit-changelog-entries): Distinguish between
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
675 ;; arch-tag: 8089b39c-983b-4e83-93cd-ed0a64c7fdcc
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
676 ;;; log-edit.el ends here