diff options
| author | Stefan Monnier | 2003-05-31 16:43:30 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-31 16:43:30 +0000 |
| commit | 9fe89a26bf222e0ff1b711d3b4a3e0040218bdfc (patch) | |
| tree | 19b37324c0e1d967222a39672171fc36107062fd | |
| parent | e47525c4429eb22d838bae8e67b2699bee40763e (diff) | |
| download | emacs-9fe89a26bf222e0ff1b711d3b4a3e0040218bdfc.tar.gz emacs-9fe89a26bf222e0ff1b711d3b4a3e0040218bdfc.zip | |
(log-edit-maximum-comment-ring-size, log-edit-comment-ring)
(log-edit-comment-ring-index, log-edit-last-comment-match): Rename vars from
vc-maximum-comment-ring-size, vc-comment-ring, vc-comment-ring-index,
and vc-last-comment-match.
(log-edit-new-comment-index, log-edit-previous-comment)
(log-edit-next-comment, log-edit-comment-search-backward)
(log-edit-comment-search-forward, log-edit-comment-to-change-log):
Rename funs from vc-new-comment-index, vc-previous-comment,
vc-next-comment, vc-comment-search-reverse, vc-comment-search-forward,
and vc-comment-to-change-log.
| -rw-r--r-- | lisp/log-edit.el | 108 |
1 files changed, 61 insertions, 47 deletions
diff --git a/lisp/log-edit.el b/lisp/log-edit.el index 28da8d8217c..9526a39123c 100644 --- a/lisp/log-edit.el +++ b/lisp/log-edit.el | |||
| @@ -57,10 +57,10 @@ | |||
| 57 | `(("\C-c\C-c" . log-edit-done) | 57 | `(("\C-c\C-c" . log-edit-done) |
| 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 | ("\M-n" . vc-next-comment) | 60 | ("\M-n" . log-edit-next-comment) |
| 61 | ("\M-p" . vc-previous-comment) | 61 | ("\M-p" . log-edit-previous-comment) |
| 62 | ("\M-r" . vc-comment-search-reverse) | 62 | ("\M-r" . log-edit-comment-search-backward) |
| 63 | ("\M-s" . vc-comment-search-forward) | 63 | ("\M-s" . log-edit-comment-search-forward) |
| 64 | ("\C-c?" . log-edit-mode-help)) | 64 | ("\C-c?" . log-edit-mode-help)) |
| 65 | "Keymap for the `log-edit-mode' (to edit version control log messages)." | 65 | "Keymap for the `log-edit-mode' (to edit version control log messages)." |
| 66 | :group 'log-edit) | 66 | :group 'log-edit) |
| @@ -81,10 +81,10 @@ | |||
| 81 | ["List files" log-edit-show-files | 81 | ["List files" log-edit-show-files |
| 82 | :help "Show the list of relevant files."] | 82 | :help "Show the list of relevant files."] |
| 83 | "--" | 83 | "--" |
| 84 | ["Previous comment" vc-previous-comment] | 84 | ["Previous comment" log-edit-previous-comment] |
| 85 | ["Next comment" vc-next-comment] | 85 | ["Next comment" log-edit-next-comment] |
| 86 | ["Search comment forward" vc-comment-search-forward] | 86 | ["Search comment forward" log-edit-comment-search-forward] |
| 87 | ["Search comment backward" vc-comment-search-reverse])) | 87 | ["Search comment backward" log-edit-comment-search-backward])) |
| 88 | 88 | ||
| 89 | (defcustom log-edit-confirm 'changed | 89 | (defcustom log-edit-confirm 'changed |
| 90 | "*If non-nil, `log-edit-done' will request confirmation. | 90 | "*If non-nil, `log-edit-done' will request confirmation. |
| @@ -170,19 +170,19 @@ when this variable is set to nil.") | |||
| 170 | (defvar log-edit-listfun nil) | 170 | (defvar log-edit-listfun nil) |
| 171 | (defvar log-edit-parent-buffer nil) | 171 | (defvar log-edit-parent-buffer nil) |
| 172 | 172 | ||
| 173 | ;;; Taken from VC-Log mode | 173 | ;;; Originally taken from VC-Log mode |
| 174 | 174 | ||
| 175 | (defconst vc-maximum-comment-ring-size 32 | 175 | (defconst log-edit-maximum-comment-ring-size 32 |
| 176 | "Maximum number of saved comments in the comment ring.") | 176 | "Maximum number of saved comments in the comment ring.") |
| 177 | (defvar vc-comment-ring (make-ring vc-maximum-comment-ring-size)) | 177 | (defvar log-edit-comment-ring (make-ring log-edit-maximum-comment-ring-size)) |
| 178 | (defvar vc-comment-ring-index nil) | 178 | (defvar log-edit-comment-ring-index nil) |
| 179 | (defvar vc-last-comment-match "") | 179 | (defvar log-edit-last-comment-match "") |
| 180 | 180 | ||
| 181 | (defun vc-new-comment-index (stride len) | 181 | (defun log-edit-new-comment-index (stride len) |
| 182 | "Return the comment index STRIDE elements from the current one. | 182 | "Return the comment index STRIDE elements from the current one. |
| 183 | LEN is the length of `vc-comment-ring'." | 183 | LEN is the length of `log-edit-comment-ring'." |
| 184 | (mod (cond | 184 | (mod (cond |
| 185 | (vc-comment-ring-index (+ vc-comment-ring-index stride)) | 185 | (log-edit-comment-ring-index (+ log-edit-comment-ring-index stride)) |
| 186 | ;; Initialize the index on the first use of this command | 186 | ;; Initialize the index on the first use of this command |
| 187 | ;; so that the first M-p gets index 0, and the first M-n gets | 187 | ;; so that the first M-p gets index 0, and the first M-n gets |
| 188 | ;; index -1. | 188 | ;; index -1. |
| @@ -190,66 +190,64 @@ LEN is the length of `vc-comment-ring'." | |||
| 190 | (t stride)) | 190 | (t stride)) |
| 191 | len)) | 191 | len)) |
| 192 | 192 | ||
| 193 | (defun vc-previous-comment (arg) | 193 | (defun log-edit-previous-comment (arg) |
| 194 | "Cycle backwards through comment history. | 194 | "Cycle backwards through comment history. |
| 195 | With a numeric prefix ARG, go back ARG comments." | 195 | With a numeric prefix ARG, go back ARG comments." |
| 196 | (interactive "*p") | 196 | (interactive "*p") |
| 197 | (let ((len (ring-length vc-comment-ring))) | 197 | (let ((len (ring-length log-edit-comment-ring))) |
| 198 | (if (<= len 0) | 198 | (if (<= len 0) |
| 199 | (progn (message "Empty comment ring") (ding)) | 199 | (progn (message "Empty comment ring") (ding)) |
| 200 | ;; Don't use `erase-buffer' because we don't want to `widen'. | 200 | ;; Don't use `erase-buffer' because we don't want to `widen'. |
| 201 | (delete-region (point-min) (point-max)) | 201 | (delete-region (point-min) (point-max)) |
| 202 | (setq vc-comment-ring-index (vc-new-comment-index arg len)) | 202 | (setq log-edit-comment-ring-index (log-edit-new-comment-index arg len)) |
| 203 | (message "Comment %d" (1+ vc-comment-ring-index)) | 203 | (message "Comment %d" (1+ log-edit-comment-ring-index)) |
| 204 | (insert (ring-ref vc-comment-ring vc-comment-ring-index))))) | 204 | (insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index))))) |
| 205 | 205 | ||
| 206 | (defun vc-next-comment (arg) | 206 | (defun log-edit-next-comment (arg) |
| 207 | "Cycle forwards through comment history. | 207 | "Cycle forwards through comment history. |
| 208 | With a numeric prefix ARG, go forward ARG comments." | 208 | With a numeric prefix ARG, go forward ARG comments." |
| 209 | (interactive "*p") | 209 | (interactive "*p") |
| 210 | (vc-previous-comment (- arg))) | 210 | (log-edit-previous-comment (- arg))) |
| 211 | 211 | ||
| 212 | (defun vc-comment-search-reverse (str &optional stride) | 212 | (defun log-edit-comment-search-backward (str &optional stride) |
| 213 | "Search backwards through comment history for substring match of STR. | 213 | "Search backwards through comment history for substring match of STR. |
| 214 | If the optional argument STRIDE is present, that is a step-width to use | 214 | If the optional argument STRIDE is present, that is a step-width to use |
| 215 | when going through the comment ring." | 215 | when going through the comment ring." |
| 216 | ;; Why substring rather than regexp ? -sm | 216 | ;; Why substring rather than regexp ? -sm |
| 217 | (interactive | 217 | (interactive |
| 218 | (list (read-string "Comment substring: " nil nil vc-last-comment-match))) | 218 | (list (read-string "Comment substring: " nil nil log-edit-last-comment-match))) |
| 219 | (unless stride (setq stride 1)) | 219 | (unless stride (setq stride 1)) |
| 220 | (if (string= str "") | 220 | (if (string= str "") |
| 221 | (setq str vc-last-comment-match) | 221 | (setq str log-edit-last-comment-match) |
| 222 | (setq vc-last-comment-match str)) | 222 | (setq log-edit-last-comment-match str)) |
| 223 | (let* ((str (regexp-quote str)) | 223 | (let* ((str (regexp-quote str)) |
| 224 | (len (ring-length vc-comment-ring)) | 224 | (len (ring-length log-edit-comment-ring)) |
| 225 | (n (vc-new-comment-index stride len))) | 225 | (n (log-edit-new-comment-index stride len))) |
| 226 | (while (progn (when (or (>= n len) (< n 0)) (error "Not found")) | 226 | (while (progn (when (or (>= n len) (< n 0)) (error "Not found")) |
| 227 | (not (string-match str (ring-ref vc-comment-ring n)))) | 227 | (not (string-match str (ring-ref log-edit-comment-ring n)))) |
| 228 | (setq n (+ n stride))) | 228 | (setq n (+ n stride))) |
| 229 | (setq vc-comment-ring-index n) | 229 | (setq log-edit-comment-ring-index n) |
| 230 | (vc-previous-comment 0))) | 230 | (log-edit-previous-comment 0))) |
| 231 | 231 | ||
| 232 | (defun vc-comment-search-forward (str) | 232 | (defun log-edit-comment-search-forward (str) |
| 233 | "Search forwards through comment history for a substring match of STR." | 233 | "Search forwards through comment history for a substring match of STR." |
| 234 | (interactive | 234 | (interactive |
| 235 | (list (read-string "Comment substring: " nil nil vc-last-comment-match))) | 235 | (list (read-string "Comment substring: " nil nil log-edit-last-comment-match))) |
| 236 | (vc-comment-search-reverse str -1)) | 236 | (log-edit-comment-search-backward str -1)) |
| 237 | 237 | ||
| 238 | 238 | (defun log-edit-comment-to-change-log (&optional whoami file-name) | |
| 239 | |||
| 240 | (defun vc-comment-to-change-log (&optional whoami file-name) | ||
| 241 | "Enter last VC comment into the change log for the current file. | 239 | "Enter last VC comment into the change log for the current file. |
| 242 | WHOAMI (interactive prefix) non-nil means prompt for user name | 240 | WHOAMI (interactive prefix) non-nil means prompt for user name |
| 243 | and site. FILE-NAME is the name of the change log; if nil, use | 241 | and site. FILE-NAME is the name of the change log; if nil, use |
| 244 | `change-log-default-name'. | 242 | `change-log-default-name'. |
| 245 | 243 | ||
| 246 | This may be useful as a `vc-checkin-hook' to update change logs | 244 | This may be useful as a `log-edit-checkin-hook' to update change logs |
| 247 | automatically." | 245 | automatically." |
| 248 | (interactive (if current-prefix-arg | 246 | (interactive (if current-prefix-arg |
| 249 | (list current-prefix-arg | 247 | (list current-prefix-arg |
| 250 | (prompt-for-change-log-name)))) | 248 | (prompt-for-change-log-name)))) |
| 251 | (let (;; Extract the comment first so we get any error before doing anything. | 249 | (let (;; Extract the comment first so we get any error before doing anything. |
| 252 | (comment (ring-ref vc-comment-ring 0)) | 250 | (comment (ring-ref log-edit-comment-ring 0)) |
| 253 | ;; Don't let add-change-log-entry insert a defun name. | 251 | ;; Don't let add-change-log-entry insert a defun name. |
| 254 | (add-log-current-defun-function 'ignore) | 252 | (add-log-current-defun-function 'ignore) |
| 255 | end) | 253 | end) |
| @@ -281,6 +279,22 @@ automatically." | |||
| 281 | (or (eobp) (looking-at "\n\n") | 279 | (or (eobp) (looking-at "\n\n") |
| 282 | (insert "\n")))) | 280 | (insert "\n")))) |
| 283 | 281 | ||
| 282 | ;; Compatibility with old names. | ||
| 283 | (defvaralias 'vc-comment-ring 'log-edit-comment-ring) | ||
| 284 | (make-obsolete-variable 'vc-comment-ring 'log-edit-comment-ring "21.5") | ||
| 285 | (defvaralias 'vc-comment-ring-index 'log-edit-comment-ring-index) | ||
| 286 | (make-obsolete-variable 'vc-comment-ring-index 'log-edit-comment-ring-index "21.5") | ||
| 287 | (defalias 'vc-previous-comment 'log-edit-previous-comment) | ||
| 288 | (make-obsolete 'vc-previous-comment 'log-edit-previous-comment "21.5") | ||
| 289 | (defalias 'vc-next-comment 'log-edit-next-comment) | ||
| 290 | (make-obsolete 'vc-next-comment 'log-edit-next-comment "21.5") | ||
| 291 | (defalias 'vc-comment-search-reverse 'log-edit-comment-search-backward) | ||
| 292 | (make-obsolete 'vc-comment-search-reverse 'log-edit-comment-search-backward "21.5") | ||
| 293 | (defalias 'vc-comment-search-forward 'log-edit-comment-search-forward) | ||
| 294 | (make-obsolete 'vc-comment-search-forward 'log-edit-comment-search-forward "21.5") | ||
| 295 | (defalias 'vc-comment-to-change-log 'log-edit-comment-to-change-log) | ||
| 296 | (make-obsolete 'vc-comment-to-change-log 'log-edit-comment-to-change-log "21.5") | ||
| 297 | |||
| 284 | ;;; | 298 | ;;; |
| 285 | ;;; Actual code | 299 | ;;; Actual code |
| 286 | ;;; | 300 | ;;; |
| @@ -323,7 +337,7 @@ the package from which this is used might also provide additional | |||
| 323 | commands (under C-x v for VC, for example). | 337 | commands (under C-x v for VC, for example). |
| 324 | 338 | ||
| 325 | \\{log-edit-mode-map}" | 339 | \\{log-edit-mode-map}" |
| 326 | (make-local-variable 'vc-comment-ring-index)) | 340 | (make-local-variable 'log-edit-comment-ring-index)) |
| 327 | 341 | ||
| 328 | (defun log-edit-hide-buf (&optional buf where) | 342 | (defun log-edit-hide-buf (&optional buf where) |
| 329 | (when (setq buf (get-buffer (or buf log-edit-files-buf))) | 343 | (when (setq buf (get-buffer (or buf log-edit-files-buf))) |
| @@ -352,9 +366,9 @@ If you want to abort the commit, simply delete the buffer." | |||
| 352 | (goto-char (point-max)) | 366 | (goto-char (point-max)) |
| 353 | (insert ?\n))) | 367 | (insert ?\n))) |
| 354 | (let ((comment (buffer-string))) | 368 | (let ((comment (buffer-string))) |
| 355 | (when (or (ring-empty-p vc-comment-ring) | 369 | (when (or (ring-empty-p log-edit-comment-ring) |
| 356 | (not (equal comment (ring-ref vc-comment-ring 0)))) | 370 | (not (equal comment (ring-ref log-edit-comment-ring 0)))) |
| 357 | (ring-insert vc-comment-ring comment))) | 371 | (ring-insert log-edit-comment-ring comment))) |
| 358 | (let ((win (get-buffer-window log-edit-files-buf))) | 372 | (let ((win (get-buffer-window log-edit-files-buf))) |
| 359 | (if (and log-edit-confirm | 373 | (if (and log-edit-confirm |
| 360 | (not (and (eq log-edit-confirm 'changed) | 374 | (not (and (eq log-edit-confirm 'changed) |
| @@ -453,12 +467,12 @@ To select default log text, we: | |||
| 453 | "Insert this log message into the appropriate ChangeLog file." | 467 | "Insert this log message into the appropriate ChangeLog file." |
| 454 | (interactive) | 468 | (interactive) |
| 455 | ;; Yuck! | 469 | ;; Yuck! |
| 456 | (unless (string= (buffer-string) (ring-ref vc-comment-ring 0)) | 470 | (unless (string= (buffer-string) (ring-ref log-edit-comment-ring 0)) |
| 457 | (ring-insert vc-comment-ring (buffer-string))) | 471 | (ring-insert log-edit-comment-ring (buffer-string))) |
| 458 | (dolist (f (log-edit-files)) | 472 | (dolist (f (log-edit-files)) |
| 459 | (let ((buffer-file-name (expand-file-name f))) | 473 | (let ((buffer-file-name (expand-file-name f))) |
| 460 | (save-excursion | 474 | (save-excursion |
| 461 | (vc-comment-to-change-log))))) | 475 | (log-edit-comment-to-change-log))))) |
| 462 | 476 | ||
| 463 | ;;;; | 477 | ;;;; |
| 464 | ;;;; functions for getting commit message from ChangeLog a file... | 478 | ;;;; functions for getting commit message from ChangeLog a file... |