aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2021-05-07 10:16:11 +0300
committerEli Zaretskii2021-05-07 10:16:11 +0300
commit127f1f330b67228217fdcc0a552d37a33dc67bb9 (patch)
treef623a39b18e625abb69fe8c8e3a922e893c83700
parente36183ff466f0f3059811022b0e2085acfd03096 (diff)
downloademacs-127f1f330b67228217fdcc0a552d37a33dc67bb9.tar.gz
emacs-127f1f330b67228217fdcc0a552d37a33dc67bb9.zip
Improve doc strings in log-edit.el
* lisp/vc/log-edit.el (log-edit-new-comment-index) (log-edit-maximum-comment-ring-size, log-edit-previous-comment) (log-edit-next-comment, log-edit-comment-search-backward) (log-edit-comment-search-forward) (log-edit-comment-to-change-log) (log-edit-header-contents-regexp, log-edit-font-lock-gnu-style) (log-edit, log-edit-mode, log-edit-fill-entry, log-edit-done) (log-edit-kill-buffer, log-edit-insert-message-template) (log-edit-insert-cvs-template, log-edit-insert-cvs-rcstemplate) (log-edit-rewrite-fixes, log-edit-add-to-changelog) (log-edit-generate-changelog-from-diff) (log-edit-insert-changelog, log-edit-narrow-changelog) (log-edit-changelog-entry, log-edit-changelog-insert-entries) (log-edit-extract-headers): Enhance and reword doc strings.
-rw-r--r--lisp/vc/log-edit.el134
1 files changed, 74 insertions, 60 deletions
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index 0016ac423d4..17468f957cc 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -203,13 +203,15 @@ when this variable is set to nil.")
203;;; Originally taken from VC-Log mode 203;;; Originally taken from VC-Log mode
204 204
205(defconst log-edit-maximum-comment-ring-size 32 205(defconst log-edit-maximum-comment-ring-size 32
206 "Maximum number of saved comments in the comment ring.") 206 "Maximum number of saved commit comments in `log-edit-comment-ring'.")
207(defvar log-edit-comment-ring (make-ring log-edit-maximum-comment-ring-size)) 207(defvar log-edit-comment-ring (make-ring log-edit-maximum-comment-ring-size))
208(defvar log-edit-comment-ring-index nil) 208(defvar log-edit-comment-ring-index nil)
209(defvar log-edit-last-comment-match "") 209(defvar log-edit-last-comment-match "")
210 210
211(defun log-edit-new-comment-index (stride len) 211(defun log-edit-new-comment-index (stride len)
212 "Return the comment index STRIDE elements from the current one. 212 "Return the comment whose index is STRIDE elements away from the current one.
213This accesses `log-edit-comment-ring', which stores commit log comments,
214i.e. descriptions of changes done by commits.
213LEN is the length of `log-edit-comment-ring'." 215LEN is the length of `log-edit-comment-ring'."
214 (mod (cond 216 (mod (cond
215 (log-edit-comment-ring-index (+ log-edit-comment-ring-index stride)) 217 (log-edit-comment-ring-index (+ log-edit-comment-ring-index stride))
@@ -221,7 +223,7 @@ LEN is the length of `log-edit-comment-ring'."
221 len)) 223 len))
222 224
223(defun log-edit-previous-comment (arg) 225(defun log-edit-previous-comment (arg)
224 "Cycle backwards through comment history. 226 "Cycle backwards through VC commit comment history.
225With a numeric prefix ARG, go back ARG comments." 227With a numeric prefix ARG, go back ARG comments."
226 (interactive "*p") 228 (interactive "*p")
227 (let ((len (ring-length log-edit-comment-ring))) 229 (let ((len (ring-length log-edit-comment-ring)))
@@ -234,15 +236,15 @@ With a numeric prefix ARG, go back ARG comments."
234 (insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index))))) 236 (insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index)))))
235 237
236(defun log-edit-next-comment (arg) 238(defun log-edit-next-comment (arg)
237 "Cycle forwards through comment history. 239 "Cycle forwards through VC commit comment history.
238With a numeric prefix ARG, go forward ARG comments." 240With a numeric prefix ARG, go forward ARG comments."
239 (interactive "*p") 241 (interactive "*p")
240 (log-edit-previous-comment (- arg))) 242 (log-edit-previous-comment (- arg)))
241 243
242(defun log-edit-comment-search-backward (str &optional stride) 244(defun log-edit-comment-search-backward (str &optional stride)
243 "Search backwards through comment history for substring match of STR. 245 "Search backwards through VC commit comment history for a match of STR.
244If the optional argument STRIDE is present, that is a step-width to use 246If the optional argument STRIDE is present, that is a step-width to use
245when going through the comment ring." 247when going through the comment ring, `log-edit-comment-ring'."
246 ;; Why substring rather than regexp ? -sm 248 ;; Why substring rather than regexp ? -sm
247 (interactive 249 (interactive
248 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match))) 250 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
@@ -260,16 +262,21 @@ when going through the comment ring."
260 (log-edit-previous-comment 0))) 262 (log-edit-previous-comment 0)))
261 263
262(defun log-edit-comment-search-forward (str) 264(defun log-edit-comment-search-forward (str)
263 "Search forwards through comment history for a substring match of STR." 265 "Search forwards through VC commit comment history for a match of STR."
264 (interactive 266 (interactive
265 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match))) 267 (list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
266 (log-edit-comment-search-backward str -1)) 268 (log-edit-comment-search-backward str -1))
267 269
268(defun log-edit-comment-to-change-log (&optional whoami file-name) 270(defun log-edit-comment-to-change-log (&optional whoami file-name)
269 "Enter last VC comment into the change log for the current file. 271 "Insert the last VC commit comment into the change log for the current file.
270WHOAMI (interactive prefix) non-nil means prompt for user name 272This reuses the text of the last VC commit comment in `log-edit-comment-ring'
271and site. FILE-NAME is the name of the change log; if nil, use 273for the change-log entry of the current file, which is handy when several
272`change-log-default-name'. 274related changes have the same commit comment.
275WHOAMI (interactively, prefix argument) non-nil means prompt for user name
276and email address of the person to whom to attribute the change.
277FILE-NAME is the name of the change log; if nil, use `change-log-default-name'
278Interactively, with prefix argument, prompt for both the name and address of
279the person who did the change and for FILE-NAME.
273 280
274This may be useful as a `vc-checkin-hook' to update change logs 281This may be useful as a `vc-checkin-hook' to update change logs
275automatically." 282automatically."
@@ -328,7 +335,7 @@ automatically."
328 335
329(defconst log-edit-header-contents-regexp 336(defconst log-edit-header-contents-regexp
330 "[ \t]*\\(.*\\(\n[ \t].*\\)*\\)\n?" 337 "[ \t]*\\(.*\\(\n[ \t].*\\)*\\)\n?"
331 "Regular expression matching a header field. 338 "Regular expression matching the header field in `log-edit-mode'.
332The first subexpression is the actual text of the field.") 339The first subexpression is the actual text of the field.")
333 340
334(defun log-edit-match-to-eoh (_limit) 341(defun log-edit-match-to-eoh (_limit)
@@ -388,7 +395,9 @@ The first subexpression is the actual text of the field.")
388 (log-edit--match-first-line (0 'log-edit-summary)))) 395 (log-edit--match-first-line (0 'log-edit-summary))))
389 396
390(defvar log-edit-font-lock-gnu-style nil 397(defvar log-edit-font-lock-gnu-style nil
391 "If non-nil, highlight common failures to follow the GNU coding standards.") 398 "If non-nil, highlight common failures to follow VC commit log conventions.
399The conventions checked are those described in the GNU coding standards
400document.")
392(put 'log-edit-font-lock-gnu-style 'safe-local-variable 'booleanp) 401(put 'log-edit-font-lock-gnu-style 'safe-local-variable 'booleanp)
393 402
394(defconst log-edit-font-lock-gnu-keywords 403(defconst log-edit-font-lock-gnu-keywords
@@ -431,28 +440,28 @@ The first subexpression is the actual text of the field.")
431 440
432;;;###autoload 441;;;###autoload
433(defun log-edit (callback &optional setup params buffer mode &rest _ignore) 442(defun log-edit (callback &optional setup params buffer mode &rest _ignore)
434 "Setup a buffer to enter a log message. 443 "Setup a buffer to enter a VC commit log message.
435The buffer is put in mode MODE or `log-edit-mode' if MODE is nil. 444The buffer is put in mode MODE, or `log-edit-mode' if MODE is nil.
436\\<log-edit-mode-map> 445\\<log-edit-mode-map>
437If SETUP is non-nil, erase the buffer and run `log-edit-hook'. 446If SETUP is non-nil, erase the buffer and run `log-edit-hook'.
438Set mark and point around the entire contents of the buffer, so 447Set mark and point around the entire contents of the buffer, so
439that it is easy to kill the contents of the buffer with 448that it is easy to kill the contents of the buffer with
440\\[kill-region]. Once the user is done editing the message, 449\\[kill-region]. Once the user is done editing the message, he
441invoking the command \\[log-edit-done] (`log-edit-done') will 450or she is expected to invoke the command \\[log-edit-done] (`log-edit-done'),
442call CALLBACK to do the actual commit. 451which will call CALLBACK, a function to do the actual commit.
443 452
444PARAMS if non-nil is an alist of variables and buffer-local 453PARAMS, if non-nil, is an alist of variables and buffer-local
445values to give them in the Log Edit buffer. Possible keys and 454values to give to those variables in the Log Edit buffer. Possible
446associated values: 455keys and associated values are:
447 `log-edit-listfun' -- function taking no arguments that returns the list of 456 `log-edit-listfun' -- function taking no arguments that returns the list of
448 files that are concerned by the current operation (using relative names); 457 files that are concerned by the current operation (using relative names);
449 `log-edit-diff-function' -- function taking no arguments that 458 `log-edit-diff-function' -- function taking no arguments that
450 displays a diff of the files concerned by the current operation. 459 displays a diff of the files concerned by the current operation.
451 `vc-log-fileset' -- the VC fileset to be committed (if any). 460 `vc-log-fileset' -- the VC fileset to be committed (if any).
452 461
453If BUFFER is non-nil `log-edit' will jump to that buffer, use it 462If BUFFER is non-nil, `log-edit' will switch to that buffer, use it
454to edit the log message and go back to the current buffer when 463to edit the log message and go back to the current buffer when
455done. Otherwise, it uses the current buffer." 464done. Otherwise, this function will use the current buffer."
456 (let ((parent (current-buffer))) 465 (let ((parent (current-buffer)))
457 (if buffer (pop-to-buffer buffer)) 466 (if buffer (pop-to-buffer buffer))
458 (when (and log-edit-setup-invert (not (eq setup 'force))) 467 (when (and log-edit-setup-invert (not (eq setup 'force)))
@@ -478,12 +487,12 @@ done. Otherwise, it uses the current buffer."
478 "Press \\[log-edit-done] when you are done editing.")))) 487 "Press \\[log-edit-done] when you are done editing."))))
479 488
480(define-derived-mode log-edit-mode text-mode "Log-Edit" 489(define-derived-mode log-edit-mode text-mode "Log-Edit"
481 "Major mode for editing version-control log messages. 490 "Major mode for editing version-control (VC) commit log messages.
482When done editing the log entry, just type \\[log-edit-done] which 491When done editing the log entry, type \\[log-edit-done], which will
483will trigger the actual commit of the file(s). 492trigger the actual commit of the file(s).
484Several other handy support commands are provided of course and 493Several other handy support commands are provided, and the package
485the package from which this is used might also provide additional 494from which this is used might also provide additional commands (under
486commands (under C-x v for VC, for example). 495the \"C-x v\" prefix for VC commands, for example).
487 496
488\\{log-edit-mode-map}" 497\\{log-edit-mode-map}"
489 (set (make-local-variable 'font-lock-defaults) 498 (set (make-local-variable 'font-lock-defaults)
@@ -513,7 +522,7 @@ commands (under C-x v for VC, for example).
513 (insert "):"))) 522 (insert "):")))
514 523
515(defun log-edit-fill-entry (&optional justify) 524(defun log-edit-fill-entry (&optional justify)
516 "Like \\[fill-paragraph], but handle ChangeLog entries. 525 "Like \\[fill-paragraph], but for filling ChangeLog-formatted entries.
517Consecutive function entries without prose (i.e., lines of the 526Consecutive function entries without prose (i.e., lines of the
518form \"(FUNCTION):\") will be combined into \"(FUNC1, FUNC2):\" 527form \"(FUNCTION):\") will be combined into \"(FUNC1, FUNC2):\"
519according to `fill-column'." 528according to `fill-column'."
@@ -563,7 +572,7 @@ according to `fill-column'."
563 (ring-insert log-edit-comment-ring comment))) 572 (ring-insert log-edit-comment-ring comment)))
564 573
565(defun log-edit-done () 574(defun log-edit-done ()
566 "Finish editing the log message and commit the files. 575 "Finish editing the VC commit log message, and commit the files.
567If you want to abort the commit, simply delete the buffer." 576If you want to abort the commit, simply delete the buffer."
568 (interactive) 577 (interactive)
569 ;; Clean up empty headers. 578 ;; Clean up empty headers.
@@ -610,9 +619,9 @@ If you want to abort the commit, simply delete the buffer."
610 (call-interactively log-edit-callback)))) 619 (call-interactively log-edit-callback))))
611 620
612(defun log-edit-kill-buffer () 621(defun log-edit-kill-buffer ()
613 "Kill the current buffer. 622 "Kill the current VC commit log buffer.
614Also saves its contents in the comment history and hides 623This command saves the contents of the log buffer in the VC commit
615`log-edit-files-buf'." 624comment history, see `log-edit-comment-ring', and hides `log-edit-files-buf'."
616 (interactive) 625 (interactive)
617 (log-edit-hide-buf) 626 (log-edit-hide-buf)
618 (let ((buf (current-buffer))) 627 (let ((buf (current-buffer)))
@@ -694,7 +703,7 @@ different header separator appropriate for `log-edit-mode'."
694 (eobp)))) 703 (eobp))))
695 704
696(defun log-edit-insert-message-template () 705(defun log-edit-insert-message-template ()
697 "Insert the default template with Summary and Author." 706 "Insert the default VC commit log template with Summary and Author."
698 (interactive) 707 (interactive)
699 (when (or (called-interactively-p 'interactive) 708 (when (or (called-interactively-p 'interactive)
700 (log-edit-empty-buffer-p)) 709 (log-edit-empty-buffer-p))
@@ -705,7 +714,7 @@ different header separator appropriate for `log-edit-mode'."
705 (message-position-point))) 714 (message-position-point)))
706 715
707(defun log-edit-insert-cvs-template () 716(defun log-edit-insert-cvs-template ()
708 "Insert the template specified by the CVS administrator, if any. 717 "Insert the commit log template specified by the CVS administrator, if any.
709This simply uses the local CVS/Template file." 718This simply uses the local CVS/Template file."
710 (interactive) 719 (interactive)
711 (when (or (called-interactively-p 'interactive) 720 (when (or (called-interactively-p 'interactive)
@@ -717,7 +726,7 @@ This simply uses the local CVS/Template file."
717 (insert-file-contents "CVS/Template")))) 726 (insert-file-contents "CVS/Template"))))
718 727
719(defun log-edit-insert-cvs-rcstemplate () 728(defun log-edit-insert-cvs-rcstemplate ()
720 "Insert the rcstemplate from the CVS repository. 729 "Insert the RCS commit log template from the CVS repository.
721This contacts the repository to get the rcstemplate file and 730This contacts the repository to get the rcstemplate file and
722can thus take some time." 731can thus take some time."
723 (interactive) 732 (interactive)
@@ -751,7 +760,7 @@ can thus take some time."
751 (insert (mapconcat 'identity files ", ") ": ")))) 760 (insert (mapconcat 'identity files ", ") ": "))))
752 761
753(defun log-edit-add-to-changelog () 762(defun log-edit-add-to-changelog ()
754 "Insert this log message into the appropriate ChangeLog file." 763 "Insert this VC commit log message into the appropriate ChangeLog file."
755 (interactive) 764 (interactive)
756 (log-edit-remember-comment) 765 (log-edit-remember-comment)
757 (dolist (f (log-edit-files)) 766 (dolist (f (log-edit-files))
@@ -765,7 +774,7 @@ can thus take some time."
765 "Non-nil means rewrite (tiny change).") 774 "Non-nil means rewrite (tiny change).")
766 775
767(defvar log-edit-rewrite-fixes nil 776(defvar log-edit-rewrite-fixes nil
768 "Rule to rewrite bug numbers into Fixes: headers. 777 "Rule to rewrite bug numbers into Fixes: headers in commit log messages.
769The value should be of the form (REGEXP . REPLACEMENT) 778The value should be of the form (REGEXP . REPLACEMENT)
770where REGEXP should match the expression referring to a bug number 779where REGEXP should match the expression referring to a bug number
771in the text, and REPLACEMENT is an expression to pass to `replace-match' 780in the text, and REPLACEMENT is an expression to pass to `replace-match'
@@ -783,10 +792,11 @@ to build the Fixes: header.")
783(declare-function diff-add-log-current-defuns "diff-mode" ()) 792(declare-function diff-add-log-current-defuns "diff-mode" ())
784 793
785(defun log-edit-generate-changelog-from-diff () 794(defun log-edit-generate-changelog-from-diff ()
786 "Insert a log message by looking at the current diff. 795 "Insert a VC commit log message by looking at the current diff.
796This command is intended to be uses on the \"*vc-log*\" buffer.
787This command will generate a ChangeLog entries listing the 797This command will generate a ChangeLog entries listing the
788functions. You can then add a description where needed, and use 798changed functions. You can then add a description where needed,
789\\[fill-paragraph] to join consecutive function names." 799and use \\[fill-paragraph] to join consecutive function names."
790 (interactive) 800 (interactive)
791 (change-log-insert-entries 801 (change-log-insert-entries
792 (with-current-buffer 802 (with-current-buffer
@@ -804,21 +814,21 @@ functions. You can then add a description where needed, and use
804 (diff-add-log-current-defuns)))) 814 (diff-add-log-current-defuns))))
805 815
806(defun log-edit-insert-changelog (&optional use-first) 816(defun log-edit-insert-changelog (&optional use-first)
807 "Insert a log message by looking at the ChangeLog. 817 "Insert a VC commit log message by looking at the ChangeLog.
808The idea is to write your ChangeLog entries first, and then use this 818The idea is to write your ChangeLog entries first, and then use this
809command to commit your changes. 819command to commit your changes with that log.
810 820
811To select default log text, we: 821To select default log text, this command:
812- find the ChangeLog entries for the files to be checked in, 822- finds the ChangeLog entries for the files to be checked in;
813- verify that the top entry in the ChangeLog is on the current date 823- verifies that the top entry in the ChangeLog is on the current date
814 and by the current user; if not, we don't provide any default text, 824 and by the current user; if not, it doesn't provide any default text;
815- search the ChangeLog entry for paragraphs containing the names of 825- searches the ChangeLog entry for paragraphs containing the names of
816 the files we're checking in, and finally 826 the files to be checked in; and finally
817- use those paragraphs as the log text. 827- uses those paragraphs as the log text.
818 828
819If the optional prefix arg USE-FIRST is given (via \\[universal-argument]), 829If the optional prefix arg USE-FIRST is given (via \\[universal-argument]),
820or if the command is repeated a second time in a row, use the first log entry 830or if the command is repeated, use the first log entry regardless of user
821regardless of user name or time." 831name or time."
822 (interactive "P") 832 (interactive "P")
823 (save-excursion 833 (save-excursion
824 (let ((eoh (save-excursion (rfc822-goto-eoh) (point)))) 834 (let ((eoh (save-excursion (rfc822-goto-eoh) (point))))
@@ -868,7 +878,7 @@ regardless of user name or time."
868;;;; 878;;;;
869 879
870(defun log-edit-narrow-changelog () 880(defun log-edit-narrow-changelog ()
871 "Narrow to the top page of the current buffer, a ChangeLog file. 881 "Narrow to the top page of the current buffer, which visits a ChangeLog file.
872Actually, the narrowed region doesn't include the date line. 882Actually, the narrowed region doesn't include the date line.
873A \"page\" in a ChangeLog file is the area between two dates." 883A \"page\" in a ChangeLog file is the area between two dates."
874 (or (eq major-mode 'change-log-mode) 884 (or (eq major-mode 'change-log-mode)
@@ -916,7 +926,7 @@ If we are between sub-paragraphs, return the previous subparagraph."
916 926
917(defun log-edit-changelog-entry () 927(defun log-edit-changelog-entry ()
918 "Return the bounds of the ChangeLog entry containing point. 928 "Return the bounds of the ChangeLog entry containing point.
919The variable `log-edit-changelog-full-paragraphs' decides whether an 929The variable `log-edit-changelog-full-paragraphs' determines whether an
920\"entry\" is a paragraph or a subparagraph; see its documentation string 930\"entry\" is a paragraph or a subparagraph; see its documentation string
921for more details." 931for more details."
922 (save-excursion 932 (save-excursion
@@ -1041,8 +1051,12 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each
1041 "\\($\\|[^[:alnum:]]\\)"))))) 1051 "\\($\\|[^[:alnum:]]\\)")))))
1042 1052
1043(defun log-edit-changelog-insert-entries (buffer beg end &rest files) 1053(defun log-edit-changelog-insert-entries (buffer beg end &rest files)
1044 "Insert the text from BUFFER between BEG and END. 1054 "Insert the text from ChangeLog BUFFER between BEG and END.
1045Rename relative filenames in the ChangeLog entry as FILES." 1055Rename relative filenames in the ChangeLog entry with FILES.
1056FILES are supposed to name the same files whose relative filenames
1057are to be replaced, and their names relative to the directory of
1058BUFFER are expected to match the relative file names in the ChangeLog
1059entry."
1046 (let ((opoint (point)) 1060 (let ((opoint (point))
1047 (log-name (buffer-file-name buffer)) 1061 (log-name (buffer-file-name buffer))
1048 (case-fold-search nil) 1062 (case-fold-search nil)
@@ -1124,7 +1138,7 @@ Return t if toggled on (or TOGGLE is nil), otherwise nil."
1124 val)) 1138 val))
1125 1139
1126(defun log-edit-extract-headers (headers comment) 1140(defun log-edit-extract-headers (headers comment)
1127 "Extract headers from COMMENT to form command line arguments. 1141 "Extract headers from VC commit COMMENT to form command line arguments.
1128HEADERS should be an alist with elements (HEADER . CMDARG) 1142HEADERS should be an alist with elements (HEADER . CMDARG)
1129or (HEADER . FUNCTION) associating headers to command line 1143or (HEADER . FUNCTION) associating headers to command line
1130options and the result is then a list of the form (MSG ARGUMENTS...) 1144options and the result is then a list of the form (MSG ARGUMENTS...)