Fix a couple of problems in changelog generating functions

* lisp/vc/diff-mode.el (diff-add-log-current-defuns): If there is a
scan-error when calling end-of-defun, go to end of hunk.  This can
easily happen since we are calling end-of-defun on a partial code
fragment from a diff.
* lisp/vc/log-edit.el (log-edit-generate-changelog-from-diff): Bind
display-buffer-overriding-action around the log-edit-show-diff call
only.  Otherwise, it can affect, for example, debugger windows
triggered by the diff-add-log-current-defuns call.
This commit is contained in:
Noam Postavsky 2020-03-20 06:00:11 -04:00
parent 9ab85f087f
commit 8709aaddd8
2 changed files with 40 additions and 35 deletions

View file

@ -2247,7 +2247,7 @@ The elements of the alist are of the form (FILE . (DEFUN...)),
where DEFUN... is a list of function names found in FILE." where DEFUN... is a list of function names found in FILE."
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(let ((defuns nil) (let* ((defuns nil)
(hunk-end nil) (hunk-end nil)
(hunk-mismatch-files nil) (hunk-mismatch-files nil)
(make-defun-context-follower (make-defun-context-follower
@ -2267,7 +2267,10 @@ where DEFUN... is a list of function names found in FILE."
(when-let* ((def (and (not eodefun) (when-let* ((def (and (not eodefun)
(funcall goline) (funcall goline)
(add-log-current-defun))) (add-log-current-defun)))
(eof (save-excursion (end-of-defun) (point)))) (eof (save-excursion
(condition-case ()
(progn (end-of-defun) (point))
(scan-error hunk-end)))))
(setq eodefun eof) (setq eodefun eof)
(setq defname def))))))))) (setq defname def)))))))))
(while (while

View file

@ -788,18 +788,20 @@ This command will generate a ChangeLog entries listing the
functions. You can then add a description where needed, and use functions. You can then add a description where needed, and use
\\[fill-paragraph] to join consecutive function names." \\[fill-paragraph] to join consecutive function names."
(interactive) (interactive)
(change-log-insert-entries
(with-current-buffer
(let* ((diff-buf nil) (let* ((diff-buf nil)
;; Unfortunately, `log-edit-show-diff' doesn't have a NO-SHOW ;; Unfortunately, `log-edit-show-diff' doesn't have a
;; option, so we try to work around it via display-buffer ;; NO-SHOW option, so we try to work around it via
;; machinery. ;; display-buffer machinery.
(display-buffer-overriding-action (display-buffer-overriding-action
`(,(lambda (buf alist) `(,(lambda (buf alist)
(setq diff-buf buf) (setq diff-buf buf)
(display-buffer-no-window buf alist)) (display-buffer-no-window buf alist))
. ((allow-no-window . t))))) . ((allow-no-window . t)))))
(change-log-insert-entries (log-edit-show-diff)
(with-current-buffer (progn (log-edit-show-diff) diff-buf) diff-buf)
(diff-add-log-current-defuns))))) (diff-add-log-current-defuns))))
(defun log-edit-insert-changelog (&optional use-first) (defun log-edit-insert-changelog (&optional use-first)
"Insert a log message by looking at the ChangeLog. "Insert a log message by looking at the ChangeLog.