nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] snipping almost twenty lines out of the commenting code


From: Benno Schulenberg
Subject: Re: [Nano-devel] snipping almost twenty lines out of the commenting code
Date: Fri, 03 Jun 2016 11:22:04 +0200

On Thu, Jun 2, 2016, at 05:42, Mike Scalora wrote:
> Not resetting comment_seq on each use (now that it is a file global)
> appears to have a strange side effect for syntaxes without a comment
> setting. A file with a syntax that has no comment setting inherits the
> last comment sequence that was used on a previous file [...]

Ah.  Hadn't thought of that.  Fixed in the first patch.

> Calling discard_until() makes things work a bit different in a subtle
> way. It deletes the redo side of the undo stack. If the comment action
> had changed a line it would have been lost so it's not a serious
> effect but different in a small way.

True, it would be nicer if a noop would not lose any redo history.

Thinking about it, a better way to prevent the unwanted undo item
presented itself.  It even gets rid of the file_changed bool.  See the
first patch again.

> I'm not a fan of using a global to eliminate a function but given how
> much you value fewer lines and the historical use of globals in the
> codebase I guess it's the thing to do.

I don't like globals either.  We could pass it to add_undo(), but that
would mean that twenty other calls would have to pass NULL -- that's a
waste too.  I tried a different way in the second patch, but that doesn't
make things cleaner either.  And... only now it occurs to me to just set
openfile->current_undo->strdata right after the add_undo in do_comment.
Pfff, easy.  No need for any global.  Just a little tweaking of the undo
item after creating it because it's too much work to pass the data.

Benno

-- 
http://www.fastmail.com - Faster than the air-speed velocity of an
                          unladen european swallow

Attachment: 0001-text-use-the-general-undo-adding-mechanism-also-for-.patch
Description: Text Data

Attachment: 0002-text-use-a-per-file-variable-to-store-the-comment-se.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]