diff options
| author | Stefan Monnier | 2000-12-10 21:08:55 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-12-10 21:08:55 +0000 |
| commit | cdf547492db7cc939df08dfb8a93f67e98289982 (patch) | |
| tree | 0ce8a7dd6f071dc91ec66f6160d084be68dad217 | |
| parent | 7de77417800c0545089beba6def382ad5dc08e5f (diff) | |
| download | emacs-cdf547492db7cc939df08dfb8a93f67e98289982.tar.gz emacs-cdf547492db7cc939df08dfb8a93f67e98289982.zip | |
(log-edit-parent-buffer): New var.
(log-edit): Set it. Add BUFFER argument.
(log-edit-done): Use char-before.
Don't bother checking validity of vc-comment-ring.
Only bury the buffer if log-edit popped it up.
| -rw-r--r-- | lisp/log-edit.el | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/lisp/log-edit.el b/lisp/log-edit.el index a5ca3b641ac..fdb0c3d7400 100644 --- a/lisp/log-edit.el +++ b/lisp/log-edit.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Stefan Monnier <monnier@cs.yale.edu> | 5 | ;; Author: Stefan Monnier <monnier@cs.yale.edu> |
| 6 | ;; Keywords: pcl-cvs cvs commit log | 6 | ;; Keywords: pcl-cvs cvs commit log |
| 7 | ;; Version: $Name: $ | 7 | ;; Version: $Name: $ |
| 8 | ;; Revision: $Id: log-edit.el,v 1.11 2000/11/06 07:01:36 monnier Exp $ | 8 | ;; Revision: $Id: log-edit.el,v 1.12 2000/12/06 19:36:44 fx Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -58,7 +58,7 @@ | |||
| 58 | ("\C-c\C-a" . log-edit-insert-changelog) | 58 | ("\C-c\C-a" . log-edit-insert-changelog) |
| 59 | ("\C-c\C-f" . log-edit-show-files) | 59 | ("\C-c\C-f" . log-edit-show-files) |
| 60 | ("\C-c?" . log-edit-mode-help)) | 60 | ("\C-c?" . log-edit-mode-help)) |
| 61 | "Keymap for the `log-edit-mode' (used when editing cvs log messages)." | 61 | "Keymap for the `log-edit-mode' (to edit version control log messages)." |
| 62 | :group 'log-edit | 62 | :group 'log-edit |
| 63 | :inherit (if (boundp 'vc-log-entry-mode) vc-log-entry-mode | 63 | :inherit (if (boundp 'vc-log-entry-mode) vc-log-entry-mode |
| 64 | (if (boundp 'vc-log-mode-map) vc-log-mode-map))) | 64 | (if (boundp 'vc-log-mode-map) vc-log-mode-map))) |
| @@ -160,31 +160,40 @@ when this variable is set to nil.") | |||
| 160 | (defvar log-edit-initial-files nil) | 160 | (defvar log-edit-initial-files nil) |
| 161 | (defvar log-edit-callback nil) | 161 | (defvar log-edit-callback nil) |
| 162 | (defvar log-edit-listfun nil) | 162 | (defvar log-edit-listfun nil) |
| 163 | (defvar log-edit-parent-buffer nil) | ||
| 163 | 164 | ||
| 164 | ;;;; | 165 | ;;; |
| 165 | ;;;; Actual code | 166 | ;;; Actual code |
| 166 | ;;;; | 167 | ;;; |
| 167 | 168 | ||
| 168 | ;;;###autoload | 169 | ;;;###autoload |
| 169 | (defun log-edit (callback &optional setup listfun &rest ignore) | 170 | (defun log-edit (callback &optional setup listfun buffer &rest ignore) |
| 170 | "Setup a buffer to enter a log message. | 171 | "Setup a buffer to enter a log message. |
| 171 | \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'. | 172 | \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'. |
| 172 | If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run. | 173 | If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run. |
| 173 | Mark and point will be set around the entire contents of the | 174 | Mark and point will be set around the entire contents of the |
| 174 | buffer so that it is easy to kill the contents of the buffer with \\[kill-region]. | 175 | buffer so that it is easy to kill the contents of the buffer with \\[kill-region]. |
| 175 | Once you're done editing the message, pressing \\[log-edit-done] will call | 176 | Once you're done editing the message, pressing \\[log-edit-done] will call |
| 176 | `log-edit-done' which will end up calling CALLBACK to do the actual commit." | 177 | `log-edit-done' which will end up calling CALLBACK to do the actual commit. |
| 177 | (when (and log-edit-setup-invert (not (eq setup 'force))) | 178 | LISTFUN if non-nil is a function of no arguments returning the list of files |
| 178 | (setq setup (not setup))) | 179 | that are concerned by the current operation (using relative names). |
| 179 | (when setup (erase-buffer)) | 180 | If BUFFER is non-nil `log-edit' will jump to that buffer, use it to edit the |
| 180 | (log-edit-mode) | 181 | log message and go back to the current buffer when done. Otherwise, it |
| 181 | (set (make-local-variable 'log-edit-callback) callback) | 182 | uses the current buffer." |
| 182 | (set (make-local-variable 'log-edit-listfun) listfun) | 183 | (let ((parent (current-buffer))) |
| 183 | (when setup (run-hooks 'log-edit-hook)) | 184 | (if buffer (pop-to-buffer buffer)) |
| 184 | (goto-char (point-min)) (push-mark (point-max)) | 185 | (when (and log-edit-setup-invert (not (eq setup 'force))) |
| 185 | (set (make-local-variable 'log-edit-initial-files) (log-edit-files)) | 186 | (setq setup (not setup))) |
| 186 | (message (substitute-command-keys | 187 | (when setup (erase-buffer)) |
| 187 | "Press \\[log-edit-done] when you are done editing."))) | 188 | (log-edit-mode) |
| 189 | (set (make-local-variable 'log-edit-callback) callback) | ||
| 190 | (set (make-local-variable 'log-edit-listfun) listfun) | ||
| 191 | (if buffer (set (make-local-variable 'log-edit-parent-buffer) parent)) | ||
| 192 | (when setup (run-hooks 'log-edit-hook)) | ||
| 193 | (goto-char (point-min)) (push-mark (point-max)) | ||
| 194 | (set (make-local-variable 'log-edit-initial-files) (log-edit-files)) | ||
| 195 | (message (substitute-command-keys | ||
| 196 | "Press \\[log-edit-done] when you are done editing.")))) | ||
| 188 | 197 | ||
| 189 | (define-derived-mode log-edit-mode text-mode "Log-Edit" | 198 | (define-derived-mode log-edit-mode text-mode "Log-Edit" |
| 190 | "Major mode for editing version-control log messages. | 199 | "Major mode for editing version-control log messages. |
| @@ -213,8 +222,8 @@ If you want to abort the commit, simply delete the buffer." | |||
| 213 | (when (equal (char-after) ?\n) (forward-char 1)) | 222 | (when (equal (char-after) ?\n) (forward-char 1)) |
| 214 | (delete-region (point) (point-max)) | 223 | (delete-region (point) (point-max)) |
| 215 | ;; Check for final newline | 224 | ;; Check for final newline |
| 216 | (if (and (> (point-max) 1) | 225 | (if (and (> (point-max) (point-min)) |
| 217 | (/= (char-after (1- (point-max))) ?\n) | 226 | (/= (char-before (point-max)) ?\n) |
| 218 | (or (eq log-edit-require-final-newline t) | 227 | (or (eq log-edit-require-final-newline t) |
| 219 | (and log-edit-require-final-newline | 228 | (and log-edit-require-final-newline |
| 220 | (y-or-n-p | 229 | (y-or-n-p |
| @@ -224,10 +233,8 @@ If you want to abort the commit, simply delete the buffer." | |||
| 224 | (goto-char (point-max)) | 233 | (goto-char (point-max)) |
| 225 | (insert ?\n))) | 234 | (insert ?\n))) |
| 226 | (let ((comment (buffer-string))) | 235 | (let ((comment (buffer-string))) |
| 227 | (when (and (boundp 'vc-comment-ring) | 236 | (when (or (ring-empty-p vc-comment-ring) |
| 228 | (ring-p vc-comment-ring) | 237 | (not (equal comment (ring-ref vc-comment-ring 0)))) |
| 229 | (not (ring-empty-p vc-comment-ring)) | ||
| 230 | (not (equal comment (ring-ref vc-comment-ring 0)))) | ||
| 231 | (ring-insert vc-comment-ring comment))) | 238 | (ring-insert vc-comment-ring comment))) |
| 232 | (let ((win (get-buffer-window log-edit-files-buf))) | 239 | (let ((win (get-buffer-window log-edit-files-buf))) |
| 233 | (if (and log-edit-confirm | 240 | (if (and log-edit-confirm |
| @@ -240,9 +247,8 @@ If you want to abort the commit, simply delete the buffer." | |||
| 240 | (message "Oh, well! Later maybe?")) | 247 | (message "Oh, well! Later maybe?")) |
| 241 | (run-hooks 'log-edit-done-hook) | 248 | (run-hooks 'log-edit-done-hook) |
| 242 | (log-edit-hide-buf) | 249 | (log-edit-hide-buf) |
| 243 | (unless log-edit-keep-buffer | 250 | (unless (or log-edit-keep-buffer (not log-edit-parent-buffer)) |
| 244 | (cvs-bury-buffer (current-buffer) | 251 | (cvs-bury-buffer (current-buffer) log-edit-parent-buffer)) |
| 245 | (when (boundp 'cvs-buffer) cvs-buffer))) | ||
| 246 | (call-interactively log-edit-callback)))) | 252 | (call-interactively log-edit-callback)))) |
| 247 | 253 | ||
| 248 | (defun log-edit-files () | 254 | (defun log-edit-files () |
| @@ -299,7 +305,7 @@ To select default log text, we: | |||
| 299 | (interactive) | 305 | (interactive) |
| 300 | (let* ((files (log-edit-files)) | 306 | (let* ((files (log-edit-files)) |
| 301 | (editbuf (current-buffer)) | 307 | (editbuf (current-buffer)) |
| 302 | (buf (get-buffer-create "*log-edit-files*"))) | 308 | (buf (get-buffer-create log-edit-files-buf))) |
| 303 | (with-current-buffer buf | 309 | (with-current-buffer buf |
| 304 | (log-edit-hide-buf buf 'all) | 310 | (log-edit-hide-buf buf 'all) |
| 305 | (setq buffer-read-only nil) | 311 | (setq buffer-read-only nil) |