aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Shmakov2018-03-23 03:24:17 +0000
committerNoam Postavsky2018-04-26 07:37:48 -0400
commit66dbb787a22d4ae1d513a3ee27e22eed395f5676 (patch)
tree60282d2b3105f445502117ade7af5a664b8dfc10
parentb8aa7ecf54c9b164a59f1b0e9f9fe90531dadd20 (diff)
downloademacs-66dbb787a22d4ae1d513a3ee27e22eed395f5676.tar.gz
emacs-66dbb787a22d4ae1d513a3ee27e22eed395f5676.zip
Ensure woman2-roff-buffer restores functions on error (Bug#30908)
* lisp/woman.el (woman2-roff-buffer): Put the fallback paragraph processing inside the protected part of the unwind-protect form, rather than the cleanup forms. Attempting to format paragraphs again after an error has been signaled is unlikely to be helpful. The fallback processing should be triggered only in case the loop terminated normally, but did not reach the end of the buffer for some reason.
-rw-r--r--lisp/woman.el78
1 files changed, 39 insertions, 39 deletions
diff --git a/lisp/woman.el b/lisp/woman.el
index eab97fb34b0..238a7d389c4 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -3663,46 +3663,46 @@ expression in parentheses. Leaves point after the value."
3663 (fset 'insert-and-inherit (symbol-function 'insert)) 3663 (fset 'insert-and-inherit (symbol-function 'insert))
3664 (fset 'set-text-properties 'ignore) 3664 (fset 'set-text-properties 'ignore)
3665 (unwind-protect 3665 (unwind-protect
3666 (while 3666 (progn
3667 ;; Find next control line: 3667 (while
3668 (re-search-forward woman-request-regexp nil t) 3668 ;; Find next control line:
3669 (cond 3669 (re-search-forward woman-request-regexp nil t)
3670 ;; Construct woman function to call: 3670 (cond
3671 ((setq fn (intern-soft 3671 ;; Construct woman function to call:
3672 (concat "woman2-" 3672 ((setq fn (intern-soft
3673 (setq woman-request (match-string 1))))) 3673 (concat "woman2-"
3674 ;; Delete request or macro name: 3674 (setq woman-request (match-string 1)))))
3675 (woman-delete-match 0)) 3675 ;; Delete request or macro name:
3676 ;; Unrecognized request: 3676 (woman-delete-match 0))
3677 ((prog1 nil 3677 ;; Unrecognized request:
3678 ;; (WoMan-warn ".%s request ignored!" woman-request) 3678 ((prog1 nil
3679 (WoMan-warn-ignored woman-request "ignored!") 3679 ;; (WoMan-warn ".%s request ignored!" woman-request)
3680 ;; (setq fn 'woman2-LP) 3680 (WoMan-warn-ignored woman-request "ignored!")
3681 ;; (setq fn 'woman2-LP)
3682 ;; AVOID LEAVING A BLANK LINE!
3683 ;; (setq fn 'woman2-format-paragraphs)
3684 ))
3685 ;; .LP assumes it is at eol and leaves a (blank) line,
3686 ;; so leave point at end of line before paragraph:
3687 ((or (looking-at "[ \t]*$") ; no argument
3688 woman-ignore) ; ignore all
3689 ;; (beginning-of-line) (kill-line)
3681 ;; AVOID LEAVING A BLANK LINE! 3690 ;; AVOID LEAVING A BLANK LINE!
3682 ;; (setq fn 'woman2-format-paragraphs) 3691 (beginning-of-line) (woman-delete-line 1))
3683 )) 3692 (t (end-of-line) (insert ?\n)))
3684 ;; .LP assumes it is at eol and leaves a (blank) line, 3693 (if (not (or fn
3685 ;; so leave point at end of line before paragraph: 3694 (and (not (memq (following-char) '(?. ?')))
3686 ((or (looking-at "[ \t]*$") ; no argument 3695 (setq fn 'woman2-format-paragraphs))))
3687 woman-ignore) ; ignore all 3696 ()
3688 ;; (beginning-of-line) (kill-line) 3697 ;; Find next control line:
3689 ;; AVOID LEAVING A BLANK LINE! 3698 (if (equal woman-request "TS")
3690 (beginning-of-line) (woman-delete-line 1)) 3699 (set-marker to (woman-find-next-control-line "TE"))
3691 (t (end-of-line) (insert ?\n)) 3700 (set-marker to (woman-find-next-control-line)))
3692 ) 3701 ;; Call the appropriate function:
3693 (if (not (or fn 3702 (funcall fn to)))
3694 (and (not (memq (following-char) '(?. ?'))) 3703 (if (not (eobp)) ; This should not happen, but ...
3695 (setq fn 'woman2-format-paragraphs)))) 3704 (woman2-format-paragraphs (copy-marker (point-max) t)
3696 () 3705 woman-left-margin)))
3697 ;; Find next control line:
3698 (if (equal woman-request "TS")
3699 (set-marker to (woman-find-next-control-line "TE"))
3700 (set-marker to (woman-find-next-control-line)))
3701 ;; Call the appropriate function:
3702 (funcall fn to)))
3703 (if (not (eobp)) ; This should not happen, but ...
3704 (woman2-format-paragraphs (copy-marker (point-max) t)
3705 woman-left-margin))
3706 (fset 'canonically-space-region canonically-space-region) 3706 (fset 'canonically-space-region canonically-space-region)
3707 (fset 'set-text-properties set-text-properties) 3707 (fset 'set-text-properties set-text-properties)
3708 (fset 'insert-and-inherit insert-and-inherit) 3708 (fset 'insert-and-inherit insert-and-inherit)