From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Fill column indicator functionality Date: Mon, 18 Mar 2019 19:10:47 +0200 Message-ID: <83y35cumzs.fsf@gnu.org> References: <20190318010313.rec67ljatygf5xlf@Ergus> <837ecwx3ao.fsf@gnu.org> <20190318114249.ouqxfghhw5dfr5ry@Ergus> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="118379"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 18 18:11:05 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5vmx-000UcD-Qj for ged-emacs-devel@m.gmane.org; Mon, 18 Mar 2019 18:11:03 +0100 Original-Received: from localhost ([127.0.0.1]:44703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5vmw-0001PY-NY for ged-emacs-devel@m.gmane.org; Mon, 18 Mar 2019 13:11:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5vmr-0001PT-GL for emacs-devel@gnu.org; Mon, 18 Mar 2019 13:10:58 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5vmr-0008FK-6P; Mon, 18 Mar 2019 13:10:57 -0400 Original-Received: from [176.228.60.248] (port=4704 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h5vmq-0003m3-KB; Mon, 18 Mar 2019 13:10:56 -0400 In-reply-to: <20190318114249.ouqxfghhw5dfr5ry@Ergus> (message from Ergus on Mon, 18 Mar 2019 12:42:49 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234333 Archived-At: > Date: Mon, 18 Mar 2019 12:42:49 +0100 > From: Ergus > Cc: emacs-devel@gnu.org > > 1) How to access a specific buffer variable defined in buffer.c from > xdisp.c Obviously there is a connection throw the 'it' struct, but maybe > it is not the proper way to read it. There's no need to do anything with 'struct it' for this purpose. Just do something like int fc = BVAR (current_buffer, fill_column); This works for any variable that is actually a field of 'struct buffer'. And when the display engine works on displaying some window, that window's buffer is always stored in current_buffer. > (BTW: why there is not a header file for xdisp?) There is: dispextern.h. The name is not xdisp.h for historical reasons. > That could reduce the size of xdisp.c moving all the documentation > and comments to the header. This is C, not C++; we don't put code commentary on header files, we put it near the implementation, i.e. mostly in *.c files (except for macros and inline functions that are defined in the headers). > 2) The question about caching that was not only because of performance > concerns, but also for code cleanup; because setting the variables in > the redisplay call will localize the 'if' asserts to one place and > reduce some code repeats (the potential reduce of operations / > display_line is just a good side effect in this case.) I don't think I understand the concern here, unless it's about what you say below: > The point is that right now we have code in 4 parts in this file and any > correction requires to touch these 4 parts (add_space_at_end , > extend_face gui part, extend_face tui part and Lisp variable > declarations). If anyone touches this code apart from me, the workflow > could be very error prone, but also there are like 10-15 lines that are > repeated in the 3 places without a real need because the values only > change from time to time. > > if (!NILP (Vdisplay_fill_column_indicator) > && (it->w->pseudo_window_p == 0) > && (!NILP (Vdisplay_fill_column_indicator_column)) > && FIXNATP (Vdisplay_fill_column_indicator_character)) > { > int fill_column_indicator_column = -1; > > if (EQ (Vdisplay_fill_column_indicator_column, Qt)) > fill_column_indicator_column = fill_column; > else if (FIXNATP (Vdisplay_fill_column_indicator_column)) > fill_column_indicator_column = > XFIXNAT (Vdisplay_fill_column_indicator_column); You can make this a macro or a short function, and thus avoid the repetition. We have quite a few macros in xdisp.c, for similar reasons.