annotate lisp/log-edit.el @ 50677:152c21ba1618

(emacs-lisp-mode-syntax-table): Give @ prefix syntax.
author Richard M. Stallman <rms@gnu.org>
date Thu, 24 Apr 2003 01:36:13 +0000
parents 43c9ef374660
children 66dd7f2dd70a d7ddb3e565de
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
34304
dd613770eb0f Fix copyright years.
Dave Love <fx@gnu.org>
parents: 33232
diff changeset
3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords: pcl-cvs cvs commit log
49616
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
7 ;; Revision: $Id: log-edit.el,v 1.18 2003/02/04 11:34:12 lektu Exp $
28088
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
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
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 (require 'vc)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
41 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;;;; Global Variables
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
43 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 (defgroup log-edit nil
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
46 "Major mode for editing RCS and CVS commit messages."
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 :group 'pcl-cvs
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
48 :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
49 :version "21.1"
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 :prefix "log-edit-")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 ;; compiler pacifiers
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (defvar cvs-buffer)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (easy-mmode-defmap log-edit-mode-map
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 `(("\C-c\C-c" . log-edit-done)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ("\C-c\C-a" . log-edit-insert-changelog)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 ("\C-c\C-f" . log-edit-show-files)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ("\C-c?" . log-edit-mode-help))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
60 "Keymap for the `log-edit-mode' (to edit version control log messages)."
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 :group 'log-edit
28338
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
62 :inherit (if (boundp 'vc-log-entry-mode) vc-log-entry-mode
8da42323f5d5 (log-edit-mode-map): Inherit from vc-log-mode-map
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28088
diff changeset
63 (if (boundp 'vc-log-mode-map) vc-log-mode-map)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64
33180
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
65 (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
66 "Menu used for `log-edit-mode'."
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
67 '("Log-Edit"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
68 ["Done" log-edit-done
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
69 :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
70 "--"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
71 ["Insert ChangeLog" log-edit-insert-changelog]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
72 ["Add to ChangeLog" log-edit-add-to-changelog]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
73 "--"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
74 ["List files" log-edit-show-files
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
75 :help "Show the list of relevant files."]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
76 "--"
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
77 ["Previous comment" vc-previous-comment]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
78 ["Next comment" vc-next-comment]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
79 ["Search comment forward" vc-comment-search-forward]
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
80 ["Search comment backward" vc-comment-search-reverse]))
8700cd9cdd26 (log-edit-menu): New menu.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33061
diff changeset
81
33061
3cbd3cc4cc8b (log-edit-confirm): Fix the default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32816
diff changeset
82 (defcustom log-edit-confirm 'changed
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 "*If non-nil, `log-edit-done' will request confirmation.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 If 'changed, only request confirmation if the list of files has
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 changed since the beginning of the log-edit session."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 :type '(choice (const changed) (const t) (const nil)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (defcustom log-edit-keep-buffer nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 "*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
91 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 :type 'boolean)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93
49616
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
94 (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
95 (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
96 'log-edit-require-final-newline)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 (defcustom log-edit-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 cvs-commit-buffer-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 "*Enforce a newline at the end of commit log messages.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 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
102 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 :type '(choice (const ask) (const t) (const nil)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 (defcustom log-edit-setup-invert nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 "*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
107 If SETUP is 'force, this variable has no effect."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 :type 'boolean)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 (defcustom log-edit-hook '(log-edit-insert-cvs-template
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 log-edit-insert-changelog)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 "*Hook run at the end of `log-edit'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 :type '(hook :options (log-edit-insert-cvs-template
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 log-edit-insert-changelog)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117
28340
b90fe8a937ae (log-edit-mode-hook): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28338
diff changeset
118 (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
119 "*Hook run when entering `log-edit-mode'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 :group 'log-edit
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 :type 'hook)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 (defcustom log-edit-done-hook nil
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 "*Hook run before doing the actual commit.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 This hook can be used to cleanup the message, enforce various
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 conventions, or to allow recording the message in some other database,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 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
128 can be obtained from `log-edit-files'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 :group 'log-edit
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
130 :type '(hook :options (log-edit-set-common-indentation
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 log-edit-add-to-changelog)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132
49616
43c9ef374660 (cvs-commit-buffer-require-final-newline, cvs-changelog-full-paragraphs): Add
Juanma Barranquero <lekktu@gmail.com>
parents: 49597
diff changeset
133 (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
134 (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
135 'log-edit-changelog-full-paragraphs)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
136
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
137 (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
138 "*If non-nil, include full ChangeLog paragraphs in the log.
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 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
140 indicate the policy for that ChangeLog.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 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
143 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
144 but perhaps spanning several functions in several files. Changes in
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 different paragraphs are unrelated.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
147 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
148 full ChangeLog paragraph mentioning the change to the file, even though
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 it may mention other files, because that gives you the full context you
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 need to understand the change. This is the behaviour you get when this
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 variable is set to t.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
153 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
154 should contain only the text for the changes which occurred in that
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
155 file, because the log is per-file. This is the behaviour you get
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 when this variable is set to nil.")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 ;;;; Internal global or buffer-local vars
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 (defconst log-edit-files-buf "*log-edit-files*")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 (defvar log-edit-initial-files nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 (defvar log-edit-callback nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 (defvar log-edit-listfun nil)
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
164 (defvar log-edit-parent-buffer nil)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
166 ;;;
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
167 ;;; Actual code
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
168 ;;;
28088
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 ;;;###autoload
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
171 (defun log-edit (callback &optional setup listfun buffer &rest ignore)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 "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
173 \\<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
174 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
175 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
176 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
177 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
178 `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
179 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
180 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
181 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
182 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
183 uses the current buffer."
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
184 (let ((parent (current-buffer)))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
185 (if buffer (pop-to-buffer buffer))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
186 (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
187 (setq setup (not setup)))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
188 (when setup (erase-buffer))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
189 (log-edit-mode)
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
190 (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
191 (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
192 (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
193 (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
194 (when setup (run-hooks 'log-edit-hook))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
195 (goto-char (point-min)) (push-mark (point-max))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
196 (message (substitute-command-keys
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
197 "Press \\[log-edit-done] when you are done editing."))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 (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
200 "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
201 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
202 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
203 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
204 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
205 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
206
29375
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
207 \\{log-edit-mode-map}"
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
208 (make-local-variable 'vc-comment-ring-index))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 (defun log-edit-hide-buf (&optional buf where)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 (when (setq buf (get-buffer (or buf log-edit-files-buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (let ((win (get-buffer-window buf where)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (if win (ignore-errors (delete-window win))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (bury-buffer buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 (defun log-edit-done ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 "Finish editing the log message and commit the files.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 If you want to abort the commit, simply delete the buffer."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 (interactive)
29042
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
220 ;; Get rid of trailing empty lines
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
221 (goto-char (point-max))
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
222 (skip-syntax-backward " ")
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
223 (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
224 (delete-region (point) (point-max))
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
225 ;; Check for final newline
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
226 (if (and (> (point-max) (point-min))
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
227 (/= (char-before (point-max)) ?\n)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 (or (eq log-edit-require-final-newline t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 (and log-edit-require-final-newline
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 (y-or-n-p
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (format "Buffer %s does not end in newline. Add one? "
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 (buffer-name))))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (goto-char (point-max))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 (insert ?\n)))
29375
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
236 (let ((comment (buffer-string)))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
237 (when (or (ring-empty-p vc-comment-ring)
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
238 (not (equal comment (ring-ref vc-comment-ring 0))))
29375
429ae71326c2 (log-edit-mode): Make vc-comment-ring-index local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29042
diff changeset
239 (ring-insert vc-comment-ring comment)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (let ((win (get-buffer-window log-edit-files-buf)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (if (and log-edit-confirm
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 (not (and (eq log-edit-confirm 'changed)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 (equal (log-edit-files) log-edit-initial-files)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 (progn
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 (log-edit-show-files)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (not (y-or-n-p "Really commit ? "))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 (progn (when (not win) (log-edit-hide-buf))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 (message "Oh, well! Later maybe?"))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (run-hooks 'log-edit-done-hook)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 (log-edit-hide-buf)
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
251 (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
252 (cvs-bury-buffer (current-buffer) log-edit-parent-buffer))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 (call-interactively log-edit-callback))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 (defun log-edit-files ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 "Return the list of files that are about to be committed."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (ignore-errors (funcall log-edit-listfun)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 (defun log-edit-insert-changelog ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 "Insert a log message by looking at the ChangeLog.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 The idea is to write your ChangeLog entries first, and then use this
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 command to commit your changes.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 To select default log text, we:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 - find the ChangeLog entries for the files to be checked in,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 - verify that the top entry in the ChangeLog is on the current date
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 and by the current user; if not, we don't provide any default text,
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 - search the ChangeLog entry for paragraphs containing the names of
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 the files we're checking in, and finally
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 - use those paragraphs as the log text."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 (interactive)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
273 (log-edit-insert-changelog-entries (log-edit-files))
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
274 (log-edit-set-common-indentation)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
275 (goto-char (point-min))
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
276 (when (looking-at "\\*\\s-+")
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
277 (forward-line 1)
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
278 (when (not (re-search-forward "^\\*\\s-+" nil t))
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
279 (goto-char (point-min))
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
280 (skip-chars-forward "^():")
29042
09b4758f4aea (log-edit-done): Cleanup trailing empty lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28860
diff changeset
281 (skip-chars-forward ": ")
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
282 (delete-region (point-min) (point)))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 (defun log-edit-mode-help ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 "Provide help for the `log-edit-mode-map'."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 (if (eq last-command 'log-edit-mode-help)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 (describe-function major-mode)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 (message
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 (substitute-command-keys
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 "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
292
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
293 (defcustom log-edit-common-indent 0
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
294 "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
295 :group 'log-edit
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
296 :type 'integer)
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
297
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
298 (defun log-edit-set-common-indentation ()
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
299 "(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
300 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 (let ((common (point-max)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 (while (< (point) (point-max))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 (if (not (looking-at "^[ \t]*$"))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (setq common (min common (current-indentation))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 (forward-line 1))
36616
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
307 (indent-rigidly (point-min) (point-max)
61f696f7e5f9 (log-edit-common-indent): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34652
diff changeset
308 (- log-edit-common-indent common)))))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 (defun log-edit-show-files ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 "Show the list of files to be committed."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 (let* ((files (log-edit-files))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 (editbuf (current-buffer))
34405
ef4ba02580f0 (log-edit-parent-buffer): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34304
diff changeset
315 (buf (get-buffer-create log-edit-files-buf)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 (with-current-buffer buf
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 (log-edit-hide-buf buf 'all)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318 (setq buffer-read-only nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 (erase-buffer)
33232
abfd948c10d4 (log-edit-show-files): Use cvs-insert-strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33180
diff changeset
320 (cvs-insert-strings files)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 (setq buffer-read-only t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 (save-selected-window
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 (cvs-pop-to-buffer-same-frame buf)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 (shrink-window-if-larger-than-buffer)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 (selected-window)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 (defun log-edit-insert-cvs-template ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 "Insert the template specified by the CVS administrator, if any."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (when (file-readable-p "CVS/Template")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (insert-file-contents "CVS/Template")))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
333
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 (defun log-edit-add-to-changelog ()
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 "Insert this log message into the appropriate ChangeLog file."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 (interactive)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 ;; Yuck!
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 (unless (string= (buffer-string) (ring-ref vc-comment-ring 0))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 (ring-insert vc-comment-ring (buffer-string)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 (dolist (f (log-edit-files))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 (let ((buffer-file-name (expand-file-name f)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (vc-comment-to-change-log)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
346 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 ;;;; functions for getting commit message from ChangeLog a file...
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 ;;;; Courtesy Jim Blandy
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
349 ;;;;
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
351 (defun log-edit-narrow-changelog ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 "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
353 Actually, the narrowed region doesn't include the date line.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 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
355 (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
356 (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
357
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 ;; Skip date line and subsequent blank lines.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 (forward-line 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 (if (looking-at "[ \t\n]*\n")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (goto-char (match-end 0)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (let ((start (point)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (forward-page 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (narrow-to-region start (point))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 (goto-char (point-min))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
370 (defun log-edit-changelog-paragraph ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371 "Return the bounds of the ChangeLog paragraph containing point.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
372 If we are between paragraphs, return the previous paragraph."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 (beginning-of-line)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 (if (looking-at "^[ \t]*$")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 (skip-chars-backward " \t\n" (point-min)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 (list (progn
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 (goto-char (match-end 0)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 (point))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (if (re-search-forward "^[ \t\n]*$" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 (match-beginning 0)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (point)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
385 (defun log-edit-changelog-subparagraph ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 "Return the bounds of the ChangeLog subparagraph containing point.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 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
388 If we are between sub-paragraphs, return the previous subparagraph."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (end-of-line)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 (if (search-backward "*" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 (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
393 (progn
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394 (forward-line 1)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 (if (re-search-forward "^[ \t]*[\n*]" nil t)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 (match-beginning 0)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (point-max))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (list (point) (point)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
400 (defun log-edit-changelog-entry ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 "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
402 The variable `log-edit-changelog-full-paragraphs' decides whether an
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 \"entry\" is a paragraph or a subparagraph; see its documentation string
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 for more details."
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
405 (if log-edit-changelog-full-paragraphs
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
406 (log-edit-changelog-paragraph)
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
407 (log-edit-changelog-subparagraph)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409 (defvar user-full-name)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (defvar user-mail-address)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
411 (defun log-edit-changelog-ours-p ()
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 "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
413 Return non-nil iff it is."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 ;; Code adapted from add-change-log-entry.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (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
416 (and (fboundp 'user-full-name) (user-full-name))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 (and (boundp 'user-full-name) user-full-name)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 (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
419 ;;(and (fboundp 'user-mail-address) (user-mail-address))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 (and (boundp 'user-mail-address) user-mail-address)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 (time (or (and (boundp 'add-log-time-format)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 (functionp add-log-time-format)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 (funcall add-log-time-format))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (format-time-string "%Y-%m-%d"))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (looking-at (regexp-quote (format "%s %s <%s>" time name mail)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
427 (defun log-edit-changelog-entries (file)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 "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
429 The return value looks like this:
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 (LOGBUFFER (ENTRYSTART . ENTRYEND) ...)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 where LOGBUFFER is the name of the ChangeLog buffer, and each
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 \(ENTRYSTART . ENTRYEND\) pair is a buffer region."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (save-excursion
32816
f4923452ea45 (log-edit): Add :version and a :group for vc.
Dave Love <fx@gnu.org>
parents: 29398
diff changeset
434 (let ((changelog-file-name
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 (let ((default-directory
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 (file-name-directory (expand-file-name file))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 ;; `find-change-log' uses `change-log-default-name' if set
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 ;; and sets it before exiting, so we need to work around
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 ;; that memoizing which is undesired here
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 (setq change-log-default-name nil)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (find-change-log))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 (set-buffer (find-file-noselect changelog-file-name))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 (unless (eq major-mode 'change-log-mode) (change-log-mode))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 (goto-char (point-min))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 (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
446 (if (not (log-edit-changelog-ours-p))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 (list (current-buffer))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 (save-restriction
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
449 (log-edit-narrow-changelog)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (goto-char (point-min))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 40478
diff changeset
451
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 ;; 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
453 ;; doesn't occur anywhere, they're not using full relative
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 ;; 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
455 ;; some false positives.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (let ((pattern (file-relative-name
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 file (file-name-directory changelog-file-name))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (if (or (string= pattern "")
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (not (save-excursion
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 (search-forward pattern nil t))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 (setq pattern (file-name-nondirectory file)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 (let (texts)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (while (search-forward pattern nil t)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
465 (let ((entry (log-edit-changelog-entry)))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (push entry texts)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 (goto-char (elt entry 1))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 (cons (current-buffer) texts))))))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
471 (defun log-edit-changelog-insert-entries (buffer regions)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 "Insert those regions in BUFFER specified in REGIONS.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 Sort REGIONS front-to-back first."
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 (let ((regions (sort regions 'car-less-than-car))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 (last))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 (dolist (region regions)
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 (when (and last (< last (car region))) (newline))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (setq last (elt region 1))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 (apply 'insert-buffer-substring buffer region))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
481 (defun log-edit-insert-changelog-entries (files)
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 "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
483 (let ((buffer-entries nil))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 ;; 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
486 ;; of entries we want from that file.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 (dolist (file files)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
488 (let* ((entries (log-edit-changelog-entries file))
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489 (pair (assq (car entries) buffer-entries)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (if pair
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 (setcdr pair (cvs-union (cdr pair) (cdr entries)))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 (push entries buffer-entries))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 ;; 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
495 ;; each buffer, and extract them as strings.
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 (dolist (buffer-entry buffer-entries)
28860
40a22b85650e (cvs-changelog-full-paragraphs): Mark obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28340
diff changeset
497 (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
498 (when (cdr buffer-entry) (newline)))))
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 (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
501
28088
b442dfc3cef0 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502 ;;; log-edit.el ends here