1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Remove useless unwind-protect forms, or make them useful as intended

* lisp/imenu.el (imenu--generic-function):
* lisp/mail/yenc.el (yenc-decode-region):
* lisp/textmodes/table.el (table-recognize-region):
* test/lisp/dired-tests.el (dired-test-directory-files):
* test/lisp/hl-line-tests.el (hl-line-tests-sticky):
Fix unwind-protect bracketing mistakes that caused the unwind code to
be misplaced.
* lisp/strokes.el (strokes-read-stroke): Fix a bracketing mistake that
misplaced the unwind code, and another one that misplaced the
else-clause of an `if` form.
* test/lisp/gnus/mml-sec-tests.el (mml-secure-test-fixture): Fix a
bracketing mistake that misplaced the unwind code, and remove
superfluous condition-case.

* lisp/mwheel.el (mouse-wheel-global-text-scale):
* lisp/speedbar.el (speedbar-stealthy-updates)
(speedbar-fetch-dynamic-etags):
* lisp/emacs-lisp/edebug.el (edebug--recursive-edit):
* lisp/emacs-lisp/package.el (package--read-pkg-desc):
* lisp/cedet/semantic.el (semantic-refresh-tags-safe):
* lisp/emulation/viper-cmd.el (viper-escape-to-state):
* lisp/emulation/viper-cmd.el (viper-file-add-suffix):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/mail/feedmail.el (feedmail-send-it-immediately)
(feedmail-deduce-address-list):
* lisp/mail/mailclient.el (mailclient-send-it):
* lisp/mail/smtpmail.el (smtpmail-deduce-address-list):
* lisp/mh-e/mh-print.el (mh-ps-print-range):
* lisp/textmodes/reftex-index.el (reftex-index-this-phrase):
* test/lisp/emacs-lisp/ert-tests.el (ert-test-run-tests-batch):
(ert-test-run-tests-batch-expensive):
Remove unwind-protect forms that are apparently useless, some since a
prior edit that removed their purpose, some since their first
appearance.

* test/lisp/subr-tests.el (subr-test--frames-2):
Insert dummy unwind form in backtrace test code.
This commit is contained in:
Mattias Engdegård 2023-04-07 16:29:32 +02:00
parent 211618293d
commit 7c0c2b1bb5
21 changed files with 440 additions and 465 deletions

View file

@ -658,50 +658,49 @@ Deleting old (> %s day(s)) incoming mail file `%s'." diff bfile)
;; If getting from mail spool directory, use movemail to move
;; rather than just renaming, so as to interlock with the
;; mailer.
(unwind-protect
(save-excursion
(setq errors (generate-new-buffer " *mail source loss*"))
(let ((default-directory "/"))
(setq result
;; call-process looks in exec-path, which
;; contains exec-directory, so will find
;; Mailutils movemail if it exists, else it will
;; find "our" movemail in exec-directory.
;; Bug#31737
(apply
#'call-process
(append
(list
mail-source-movemail-program
nil errors nil from to)))))
(when (file-exists-p to)
(set-file-modes to mail-source-default-file-modes 'nofollow))
(if (and (or (not (buffer-modified-p errors))
(zerop (buffer-size errors)))
(and (numberp result)
(zerop result)))
;; No output => movemail won.
t
(set-buffer errors)
;; There may be a warning about older revisions. We
;; ignore that.
(goto-char (point-min))
(if (search-forward "older revision" nil t)
t
;; Probably a real error.
(subst-char-in-region (point-min) (point-max) ?\n ?\ )
(goto-char (point-max))
(skip-chars-backward " \t")
(delete-region (point) (point-max))
(goto-char (point-min))
(when (looking-at "movemail: ")
(delete-region (point-min) (match-end 0)))
;; Result may be a signal description string.
(unless (yes-or-no-p
(format "movemail: %s (%s return). Continue? "
(buffer-string) result))
(error "%s" (buffer-string)))
(setq to nil)))))))
(save-excursion
(setq errors (generate-new-buffer " *mail source loss*"))
(let ((default-directory "/"))
(setq result
;; call-process looks in exec-path, which
;; contains exec-directory, so will find
;; Mailutils movemail if it exists, else it will
;; find "our" movemail in exec-directory.
;; Bug#31737
(apply
#'call-process
(append
(list
mail-source-movemail-program
nil errors nil from to)))))
(when (file-exists-p to)
(set-file-modes to mail-source-default-file-modes 'nofollow))
(if (and (or (not (buffer-modified-p errors))
(zerop (buffer-size errors)))
(and (numberp result)
(zerop result)))
;; No output => movemail won.
t
(set-buffer errors)
;; There may be a warning about older revisions. We
;; ignore that.
(goto-char (point-min))
(if (search-forward "older revision" nil t)
t
;; Probably a real error.
(subst-char-in-region (point-min) (point-max) ?\n ?\ )
(goto-char (point-max))
(skip-chars-backward " \t")
(delete-region (point) (point-max))
(goto-char (point-min))
(when (looking-at "movemail: ")
(delete-region (point-min) (match-end 0)))
;; Result may be a signal description string.
(unless (yes-or-no-p
(format "movemail: %s (%s return). Continue? "
(buffer-string) result))
(error "%s" (buffer-string)))
(setq to nil))))))
(when (buffer-live-p errors)
(kill-buffer errors))
;; Return whether we moved successfully or not.