From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Question about align-to behaviour with wrap-mode Date: Mon, 21 Nov 2022 19:42:01 +0200 Message-ID: <838rk42oie.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20070"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 21 18:42:29 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxAoO-00052e-6O for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 21 Nov 2022 18:42:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxAnp-0004JF-S1; Mon, 21 Nov 2022 12:41:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxAnm-0004Hn-RM for help-gnu-emacs@gnu.org; Mon, 21 Nov 2022 12:41:51 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxAnm-0007Si-Fk for help-gnu-emacs@gnu.org; Mon, 21 Nov 2022 12:41:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zRCfum7AyBC3XgRvhmkb/C6s1wiAbNpnFbnnIUCqPd8=; b=YHvvXo/VWCGR OOToWr//bFarMVEXQkx8jahWw828hJfUWywXL4lrVUG/rkgPiOgb1j3XinYx9H4A9gztSI1/rkBto 2cIiQJeTjViXmGseCkQXRjYG5Ut2VrXmO6fVLD7ETdt2ECIZhNumNJJ2TJ/RInJwOr2B1rSNF4Smm +5RMLrqks8qWcGFK7l5fYUwdtVh71APDe4mQHvc2NEy0xQwZOcoS3K3OBCR2rqVX4iupwRRbpH0jB QC035+5otI68q70nyH2aL4MSOn9GAZb/hM2PJVbSlLGlrDbKXT45tmLCiwYcfeAZ/8mR8EqJPlbyY GwWtt067Lle8A/qMmAIKuw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxAnl-00067W-ND for help-gnu-emacs@gnu.org; Mon, 21 Nov 2022 12:41:50 -0500 In-Reply-To: (message from Abdul-Lateef Haji-Ali via Users list for the GNU Emacs text editor on Sun, 20 Nov 2022 22:20:50 +0000) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141087 Archived-At: > Date: Sun, 20 Nov 2022 22:20:50 +0000 > From: Abdul-Lateef Haji-Ali via Users list for the GNU Emacs text editor > > > I noticed what I think is strange behaviour with `:align-to` that I am wondering if it's intended and if there's a way of achieving a desired behaviour. It's intended, yes. > To reproduce in an `emacs -Q`, just run this: > > (progn > (toggle-word-wrap +1) > (goto-char (point-max)) > (insert > (concat "\n\n" > (make-string (- (window-width) 3) 69) > " " > (propertize " " 'display > `(space :align-to (- right > 10))) > "After\n\n"))) > > The word 'After' is not aligned to `(- right 10)` because the text before is too long. Instead "After" is displayed at the beginning of the next line (or broken across two lines if toggle-word-wrap is disabled) and the alignment is ignored. > > If I execute instead > > (progn > (toggle-word-wrap +1) > (goto-char (point-max)) > (insert > (concat "\n\n" > (make-string (window-width) 69) > " " > (propertize " " 'cursor 1 'display > `(space :align-to (- right > 10))) > "After\n\n"))) > > the alignment is "correct" on the second line. I don't see the correct alignment here. I see a behavior similar to the first recipe, as I'd expect. The problem here is that the implementation of align-to takes the width of continuation lines into consideration, i.e. the column doesn't wrap to zero when the line is continued. So if the window is 80-column wide, and you say (space :align-to (- right 10)) that yields 70, but text wrapped to the next line has its horizontal coordinate start from 80, so it is already past 70, and the alignment doesn't happen. The bottom line is that you cannot use relative alignment if your lines can wrap, and hope for that to work. For wrapped lines the alignment must be to absolute column numbers, and it must take the continuation lines into consideration when you calculate the alignment column.