GNU bug report logs -
#30908
woman2-roff-buffer fails to restore set-text-properties, etc. on error
Previous Next
Reported by: Ivan Shmakov <ivan <at> siamics.net>
Date: Thu, 22 Mar 2018 18:13:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 25.1.1
Fixed in version 27.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30908 in the body.
You can then email your comments to 30908 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30908
; Package
emacs
.
(Thu, 22 Mar 2018 18:13:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ivan Shmakov <ivan <at> siamics.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 22 Mar 2018 18:13:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Package: emacs
Version: 25.1.1
Tags: patch
The woman2-roff-buffer function uses unwind-protect to restore
the canonically-space-region, insert-and-inherit and
set-text-properties functions it temporarily overrides.
Unfortunately, the first thing (conditionally) called in the
‘unwind’ branch is the woman2-format-paragraphs function, which
may result in error, thus precluding said restoration, leading to:
set-text-properties is an alias for ‘ignore’.
(set-text-properties &rest IGNORE)
Do nothing and return nil.
This function accepts any number of arguments, but ignores them.
Please thus consider the patch MIMEd.
--
FSF associate member #7257 np. Sacred Armor of Antiriad — Traxer
[Message part 2 (text/diff, inline)]
--- woman.el.~1~ 2017-11-05 15:00:52.696647297 +0000
+++ woman.el 2018-03-22 17:47:44.014986089 +0000
@@ -3710,13 +3710,14 @@ defun woman2-roff-buffer ()
(set-marker to (woman-find-next-control-line)))
;; Call the appropriate function:
(funcall fn to)))
- (if (not (eobp)) ; This should not happen, but ...
- (woman2-format-paragraphs (copy-marker (point-max) t)
- woman-left-margin))
- (fset 'canonically-space-region canonically-space-region)
- (fset 'set-text-properties set-text-properties)
- (fset 'insert-and-inherit insert-and-inherit)
- (set-marker to nil))))
+ (unwind-protect
+ (if (not (eobp)) ; This should not happen, but ...
+ (woman2-format-paragraphs (copy-marker (point-max) t)
+ woman-left-margin))
+ (fset 'canonically-space-region canonically-space-region)
+ (fset 'set-text-properties set-text-properties)
+ (fset 'insert-and-inherit insert-and-inherit)
+ (set-marker to nil)))))
(defun woman-find-next-control-line (&optional pat)
"Find and return start of next control line.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30908
; Package
emacs
.
(Fri, 23 Mar 2018 00:53:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 30908 <at> debbugs.gnu.org (full text, mbox):
Ivan Shmakov <ivan <at> siamics.net> writes:
> --- woman.el.~1~ 2017-11-05 15:00:52.696647297 +0000
> +++ woman.el 2018-03-22 17:47:44.014986089 +0000
> @@ -3710,13 +3710,14 @@ defun woman2-roff-buffer ()
> + (unwind-protect
> + (if (not (eobp)) ; This should not happen, but ...
> + (woman2-format-paragraphs (copy-marker (point-max) t)
> + woman-left-margin))
> + (fset 'canonically-space-region canonically-space-region)
> + (fset 'set-text-properties set-text-properties)
> + (fset 'insert-and-inherit insert-and-inherit)
> + (set-marker to nil)))))
Shouldn't this rather be combined into the existing unwind-protect
around the while?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30908
; Package
emacs
.
(Fri, 23 Mar 2018 03:25:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 30908 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>>>>> Noam Postavsky <npostavs <at> gmail.com> writes:
>>>>> Ivan Shmakov <ivan <at> siamics.net> writes:
>> @@ -3710,13 +3710,14 @@ defun woman2-roff-buffer ()
>> + (unwind-protect
>> + (if (not (eobp)) ; This should not happen, but ...
>> + (woman2-format-paragraphs (copy-marker (point-max) t)
>> + woman-left-margin))
>> + (fset 'canonically-space-region canonically-space-region)
>> + (fset 'set-text-properties set-text-properties)
>> + (fset 'insert-and-inherit insert-and-inherit)
>> + (set-marker to nil)))))
> Shouldn’t this rather be combined into the existing unwind-protect
> around the while?
Due to the (not (eobp)) guard, I’ve assumed that the
woman2-format-paragraphs call in the ‘unwind’ branch is for some
sort of fallback processing (in the case the while loop fails.)
If the call ended up there by mistake, indeed a progn should be
used, as per the updated patch MIMEd.
--
FSF associate member #7257 http://am-1.org/~ivan/
[Message part 2 (text/diff, inline)]
--- - 2018-03-23 02:20:53.907229515 +0000
+++ 81FOuhEi.el 2018-03-23 02:20:39.083966234 +0000
@@ -3673,46 +3673,47 @@
(fset 'insert-and-inherit (symbol-function 'insert))
(fset 'set-text-properties 'ignore)
(unwind-protect
- (while
- ;; Find next control line:
- (re-search-forward woman-request-regexp nil t)
- (cond
- ;; Construct woman function to call:
- ((setq fn (intern-soft
- (concat "woman2-"
- (setq woman-request (match-string 1)))))
- ;; Delete request or macro name:
- (woman-delete-match 0))
- ;; Unrecognized request:
- ((prog1 nil
- ;; (WoMan-warn ".%s request ignored!" woman-request)
- (WoMan-warn-ignored woman-request "ignored!")
- ;; (setq fn 'woman2-LP)
- ;; AVOID LEAVING A BLANK LINE!
- ;; (setq fn 'woman2-format-paragraphs)
- ))
- ;; .LP assumes it is at eol and leaves a (blank) line,
- ;; so leave point at end of line before paragraph:
- ((or (looking-at "[ \t]*$") ; no argument
- woman-ignore) ; ignore all
- ;; (beginning-of-line) (kill-line)
- ;; AVOID LEAVING A BLANK LINE!
- (beginning-of-line) (woman-delete-line 1))
- (t (end-of-line) (insert ?\n))
- )
- (if (not (or fn
- (and (not (memq (following-char) '(?. ?')))
- (setq fn 'woman2-format-paragraphs))))
- ()
- ;; Find next control line:
- (if (equal woman-request "TS")
- (set-marker to (woman-find-next-control-line "TE"))
- (set-marker to (woman-find-next-control-line)))
- ;; Call the appropriate function:
- (funcall fn to)))
- (if (not (eobp)) ; This should not happen, but ...
- (woman2-format-paragraphs (copy-marker (point-max) t)
- woman-left-margin))
+ (progn
+ (while
+ ;; Find next control line:
+ (re-search-forward woman-request-regexp nil t)
+ (cond
+ ;; Construct woman function to call:
+ ((setq fn (intern-soft
+ (concat "woman2-"
+ (setq woman-request (match-string 1)))))
+ ;; Delete request or macro name:
+ (woman-delete-match 0))
+ ;; Unrecognized request:
+ ((prog1 nil
+ ;; (WoMan-warn ".%s request ignored!" woman-request)
+ (WoMan-warn-ignored woman-request "ignored!")
+ ;; (setq fn 'woman2-LP)
+ ;; AVOID LEAVING A BLANK LINE!
+ ;; (setq fn 'woman2-format-paragraphs)
+ ))
+ ;; .LP assumes it is at eol and leaves a (blank) line,
+ ;; so leave point at end of line before paragraph:
+ ((or (looking-at "[ \t]*$") ; no argument
+ woman-ignore) ; ignore all
+ ;; (beginning-of-line) (kill-line)
+ ;; AVOID LEAVING A BLANK LINE!
+ (beginning-of-line) (woman-delete-line 1))
+ (t (end-of-line) (insert ?\n))
+ )
+ (if (not (or fn
+ (and (not (memq (following-char) '(?. ?')))
+ (setq fn 'woman2-format-paragraphs))))
+ ()
+ ;; Find next control line:
+ (if (equal woman-request "TS")
+ (set-marker to (woman-find-next-control-line "TE"))
+ (set-marker to (woman-find-next-control-line)))
+ ;; Call the appropriate function:
+ (funcall fn to)))
+ (if (not (eobp)) ; This should not happen, but ...
+ (woman2-format-paragraphs (copy-marker (point-max) t)
+ woman-left-margin)))
(fset 'canonically-space-region canonically-space-region)
(fset 'set-text-properties set-text-properties)
(fset 'insert-and-inherit insert-and-inherit)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30908
; Package
emacs
.
(Fri, 23 Mar 2018 10:22:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 30908 <at> debbugs.gnu.org (full text, mbox):
Ivan Shmakov <ivan <at> siamics.net> writes:
> > Shouldn’t this rather be combined into the existing unwind-protect
> > around the while?
>
> Due to the (not (eobp)) guard, I’ve assumed that the
> woman2-format-paragraphs call in the ‘unwind’ branch is for some
> sort of fallback processing (in the case the while loop fails.)
Hmm, looking at this again, I'm not sure. That is, it's clearly
fallback processing in case the loop ends before going through the whole
buffer. But does it also make sense as fallback processing when some
kind of error was signaled in the loop? I don't know.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30908
; Package
emacs
.
(Thu, 26 Apr 2018 12:02:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 30908 <at> debbugs.gnu.org (full text, mbox):
tags 30908 fixed
close 30908 27.1
quit
Noam Postavsky <npostavs <at> gmail.com> writes:
> Ivan Shmakov <ivan <at> siamics.net> writes:
>
>> > Shouldn’t this rather be combined into the existing unwind-protect
>> > around the while?
>>
>> Due to the (not (eobp)) guard, I’ve assumed that the
>> woman2-format-paragraphs call in the ‘unwind’ branch is for some
>> sort of fallback processing (in the case the while loop fails.)
>
> Hmm, looking at this again, I'm not sure. That is, it's clearly
> fallback processing in case the loop ends before going through the whole
> buffer. But does it also make sense as fallback processing when some
> kind of error was signaled in the loop? I don't know.
I've decided that it doesn't make sense to do any further processing
once we've hit an error.
[1: 66dbb787a2]: 2018-04-26 07:37:48 -0400
Ensure woman2-roff-buffer restores functions on error (Bug#30908)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=66dbb787a22d4ae1d513a3ee27e22eed395f5676
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 26 Apr 2018 12:02:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
30908 <at> debbugs.gnu.org and Ivan Shmakov <ivan <at> siamics.net>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 26 Apr 2018 12:02:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 25 May 2018 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 26 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.