Skip to content

Commit 8709aad

Browse files
committed
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.
1 parent 9ab85f0 commit 8709aad

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

lisp/vc/diff-mode.el

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,29 +2247,32 @@ The elements of the alist are of the form (FILE . (DEFUN...)),
22472247
where DEFUN... is a list of function names found in FILE."
22482248
(save-excursion
22492249
(goto-char (point-min))
2250-
(let ((defuns nil)
2251-
(hunk-end nil)
2252-
(hunk-mismatch-files nil)
2253-
(make-defun-context-follower
2254-
(lambda (goline)
2255-
(let ((eodefun nil)
2256-
(defname nil))
2257-
(list
2258-
(lambda () ;; Check for end of current defun.
2259-
(when (and eodefun
2260-
(funcall goline)
2261-
(>= (point) eodefun))
2262-
(setq defname nil)
2263-
(setq eodefun nil)))
2264-
(lambda (&optional get-current) ;; Check for new defun.
2265-
(if get-current
2266-
defname
2267-
(when-let* ((def (and (not eodefun)
2268-
(funcall goline)
2269-
(add-log-current-defun)))
2270-
(eof (save-excursion (end-of-defun) (point))))
2271-
(setq eodefun eof)
2272-
(setq defname def)))))))))
2250+
(let* ((defuns nil)
2251+
(hunk-end nil)
2252+
(hunk-mismatch-files nil)
2253+
(make-defun-context-follower
2254+
(lambda (goline)
2255+
(let ((eodefun nil)
2256+
(defname nil))
2257+
(list
2258+
(lambda () ;; Check for end of current defun.
2259+
(when (and eodefun
2260+
(funcall goline)
2261+
(>= (point) eodefun))
2262+
(setq defname nil)
2263+
(setq eodefun nil)))
2264+
(lambda (&optional get-current) ;; Check for new defun.
2265+
(if get-current
2266+
defname
2267+
(when-let* ((def (and (not eodefun)
2268+
(funcall goline)
2269+
(add-log-current-defun)))
2270+
(eof (save-excursion
2271+
(condition-case ()
2272+
(progn (end-of-defun) (point))
2273+
(scan-error hunk-end)))))
2274+
(setq eodefun eof)
2275+
(setq defname def)))))))))
22732276
(while
22742277
;; Might need to skip over file headers between diff
22752278
;; hunks (e.g., "diff --git ..." etc).

lisp/vc/log-edit.el

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -788,18 +788,20 @@ This command will generate a ChangeLog entries listing the
788788
functions. You can then add a description where needed, and use
789789
\\[fill-paragraph] to join consecutive function names."
790790
(interactive)
791-
(let* ((diff-buf nil)
792-
;; Unfortunately, `log-edit-show-diff' doesn't have a NO-SHOW
793-
;; option, so we try to work around it via display-buffer
794-
;; machinery.
795-
(display-buffer-overriding-action
796-
`(,(lambda (buf alist)
797-
(setq diff-buf buf)
798-
(display-buffer-no-window buf alist))
799-
. ((allow-no-window . t)))))
800-
(change-log-insert-entries
801-
(with-current-buffer (progn (log-edit-show-diff) diff-buf)
802-
(diff-add-log-current-defuns)))))
791+
(change-log-insert-entries
792+
(with-current-buffer
793+
(let* ((diff-buf nil)
794+
;; Unfortunately, `log-edit-show-diff' doesn't have a
795+
;; NO-SHOW option, so we try to work around it via
796+
;; display-buffer machinery.
797+
(display-buffer-overriding-action
798+
`(,(lambda (buf alist)
799+
(setq diff-buf buf)
800+
(display-buffer-no-window buf alist))
801+
. ((allow-no-window . t)))))
802+
(log-edit-show-diff)
803+
diff-buf)
804+
(diff-add-log-current-defuns))))
803805

804806
(defun log-edit-insert-changelog (&optional use-first)
805807
"Insert a log message by looking at the ChangeLog.

0 commit comments

Comments
 (0)