[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
0001-text-use-the-general-undo-adding-mechanism-also-for-.patch
Description: Text Data
0002-text-use-a-per-file-variable-to-store-the-comment-se.patch
Description: Text Data
- [Nano-devel] snipping almost twenty lines out of the commenting code, Benno Schulenberg, 2016/06/01
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Benno Schulenberg, 2016/06/01
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Mike Scalora, 2016/06/01
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code,
Benno Schulenberg <=
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Mike Scalora, 2016/06/03
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Benno Schulenberg, 2016/06/03
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Benno Schulenberg, 2016/06/08
- Re: [Nano-devel] snipping almost twenty lines out of the commenting code, Mike Scalora, 2016/06/09
- [Nano-devel] tabsizes and indentsizes, Benno Schulenberg, 2016/06/11