* bug#35600: 27.0.50; uncomment-region fails correctly to reverse the action of comment-region.
@ 2019-05-06 10:11 Alan Mackenzie
2019-05-07 8:59 ` bug#35600: [Patch]: " Alan Mackenzie
[not found] ` <handler.35600.B.155713747728843.ack@debbugs.gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: Alan Mackenzie @ 2019-05-06 10:11 UTC (permalink / raw)
To: 35600
Hello, Emacs.
In the master branch:
With indent-tabs-mode t, and tab-width (say) 8, start off with the
following two line of Emacs lisp:
(if (null bs-state)
(ignore)
^
<tab>
(the first of these lines being indented by four spaces, the second by a
<tab>).
Mark the two lines, and execute M-x comment-region. We get this:
;; (if (null bs-state)
;; (ignore)
^
<tab>
(where all the space is space characters except for the <tab> just
before "(ignore)").
Now execute M-x uncomment-region. This should restore the region to
what it started as. Instead one gets:
(if (null bs-state)
(ignore)
^^^^ ^
SPCs <tab>
, there now being four spurious spaces before the <tab> preceding
"(ignore)". This is a bug.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In uncomment-region-default-1, the variable `spt' gets set to the result
of comment-search-forward, the ";" at the beginning of the comment on
the current line. The function then narrows to between `spt' and BO
next line.
In this narrowed region, the function removes the comment starter.
Because of the narrowing, it cannot take any account of the spaces at
the start of the line.
Possibly, uncomment-region needs to be amended so that that narrowing
includes any space preceding the comment starter, and that space gets
properly handled.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#35600: [Patch]: Re: bug#35600: 27.0.50; uncomment-region fails correctly to reverse the action of comment-region.
2019-05-06 10:11 bug#35600: 27.0.50; uncomment-region fails correctly to reverse the action of comment-region Alan Mackenzie
@ 2019-05-07 8:59 ` Alan Mackenzie
[not found] ` <handler.35600.B.155713747728843.ack@debbugs.gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2019-05-07 8:59 UTC (permalink / raw)
To: 35600
Hello, Emacs.
On Mon, May 06, 2019 at 10:11:00 +0000, Alan Mackenzie wrote:
> In the master branch:
> With indent-tabs-mode t, and tab-width (say) 8, start off with the
> following two line of Emacs lisp:
> (if (null bs-state)
> (ignore)
> ^
> <tab>
> (the first of these lines being indented by four spaces, the second by a
> <tab>).
> Mark the two lines, and execute M-x comment-region. We get this:
> ;; (if (null bs-state)
> ;; (ignore)
> ^
> <tab>
> (where all the space is space characters except for the <tab> just
> before "(ignore)").
> Now execute M-x uncomment-region. This should restore the region to
> what it started as. Instead one gets:
> (if (null bs-state)
> (ignore)
> ^^^^ ^
> SPCs <tab>
> , there now being four spurious spaces before the <tab> preceding
> "(ignore)". This is a bug.
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> In uncomment-region-default-1, the variable `spt' gets set to the result
> of comment-search-forward, the ";" at the beginning of the comment on
> the current line. The function then narrows to between `spt' and BO
> next line.
> In this narrowed region, the function removes the comment starter.
> Because of the narrowing, it cannot take any account of the spaces at
> the start of the line.
> Possibly, uncomment-region needs to be amended so that that narrowing
> includes any space preceding the comment starter, and that space gets
> properly handled.
Here is a patch which fixes the bug a little differently. After removing
a comment starter, if there are obtrusive spaces left before a <tab>,
they get removed:
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 9d919ccbbe..ab2be080a3 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1001,7 +1001,15 @@ uncomment-region-default-1
(re-search-forward sre (line-end-position) t))
(replace-match "" t t nil (if (match-end 2) 2 1)))))
;; Go to the end for the next comment.
- (goto-char (point-max))))))
+ (goto-char (point-max)))
+ ;; Remove any obtrusive spaces left preceding a tab at `spt'.
+ (when (and (eq (char-after spt) ?\t) (eq (char-before spt) ? )
+ (> tab-width 0))
+ (save-excursion
+ (goto-char spt)
+ (let* ((fcol (current-column))
+ (slim (- (point) (mod fcol tab-width))))
+ (delete-char (- (skip-chars-backward " " slim)))))))))
(set-marker end nil))
(defun uncomment-region-default (beg end &optional arg)
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#35600: 27.0.50; uncomment-region fails correctly to reverse the action of comment-region.
[not found] ` <handler.35600.B.155713747728843.ack@debbugs.gnu.org>
@ 2019-05-10 7:36 ` Alan Mackenzie
0 siblings, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2019-05-10 7:36 UTC (permalink / raw)
To: 35600-done
The bug has been fixed in master.
--
Alan Mackenzie (Nuremberg, Germany).
On Mon, May 06, 2019 at 10:12:02 +0000, GNU bug Tracking System wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
> This is an automatically generated reply to let you know your message
> has been received.
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
> Your message has been sent to the package maintainer(s):
> bug-gnu-emacs@gnu.org
> If you wish to submit further information on this problem, please
> send it to 35600@debbugs.gnu.org.
> Please do not send mail to help-debbugs@gnu.org unless you wish
> to report a problem with the Bug-tracking system.
> --
> 35600: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=35600
> GNU Bug Tracking System
> Contact help-debbugs@gnu.org with problems
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-10 7:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-06 10:11 bug#35600: 27.0.50; uncomment-region fails correctly to reverse the action of comment-region Alan Mackenzie
2019-05-07 8:59 ` bug#35600: [Patch]: " Alan Mackenzie
[not found] ` <handler.35600.B.155713747728843.ack@debbugs.gnu.org>
2019-05-10 7:36 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).