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.devel Subject: Re: master 91418d27e9: Add new functions for computing character metrics for windows Date: Sat, 30 Apr 2022 18:25:57 +0300 Message-ID: <8335hu8uey.fsf@gnu.org> References: <165123811050.20687.5215165731843845332@vcs2.savannah.gnu.org> <20220429131511.9BD62C01683@vcs2.savannah.gnu.org> <87v8usc7wz.fsf@gnus.org> <83czgzacfk.fsf@gnu.org> <87ilqq4yfc.fsf@gnus.org> <837d768ywx.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28724"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, malsburg@posteo.de, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 30 17:26:36 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nkozT-0007It-WE for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Apr 2022 17:26:36 +0200 Original-Received: from localhost ([::1]:44858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkozS-00052Y-6s for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Apr 2022 11:26:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkoyr-0004LX-HM for emacs-devel@gnu.org; Sat, 30 Apr 2022 11:25:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkoyq-0005CX-PJ; Sat, 30 Apr 2022 11:25:56 -0400 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=DDlgVBXT9ondKpoFNQYM2hNB5Dtgo5p+4R7CnzeaTXk=; b=ay9XMgg7apiE /vES4OMuqJqOi5Ch9Gq+oQ8LcASrpj+fe5AAAODzvkZkwppDd7+xbDIsRMjQi2317PAs2q857588o NbMWn4lcEFdQdBNmNLqTgy7gmrrQvHkWeVdNfFckKYRWuuBtrzuMxC1iZMm3XWHlNfoaIPALE/UNY GuwIFK6GlPZ1sp91PIr3z/ZU3XAPQZRDjWwU7RAFF5jUBHEhKeXHgnblatzCZC455DZZgi1hNDv9d lC/OaJhaxqGVhWIpfNQ5F2qBVPPaSlZxEpknPhstIwxUPB333P3pM3EkLI53Fmp3huCxbRHrW2C4Z 5XgHx7ukRMb2ZJ4Wlqlagg==; Original-Received: from [87.69.77.57] (port=4223 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 1nkoyo-0005aH-Dm; Sat, 30 Apr 2022 11:25:56 -0400 In-Reply-To: (message from Stefan Monnier on Sat, 30 Apr 2022 10:34:58 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289060 Archived-At: > From: Stefan Monnier > Cc: larsi@gnus.org, malsburg@posteo.de, emacs-devel@gnu.org > Date: Sat, 30 Apr 2022 10:34:58 -0400 > > >> But admittedly, in most cases you can use > >> `window-max-characters-per-line only` as a heuristic because of the > >> effect of proportional fonts > > What else can you do when proportional fonts are used, except account > > fro the average width? > > Indeed. But it just means that (unless you do the kind of job that > Lars did in vtable and SHR) the code will always be somewhat broken, and > the difference between using `window-max-characters-per-line` or > `window-body-width` is in which cases it's broken. Emacs is still 85% fixed-pitch. We still don't "have the technology" to work with variable-pitch fonts as simply and efficiently as with fixed-pitch. In this situation, lamenting the fact that an API is less helpful with variable-pitch fonts strikes me as a clear case of premature optimization. > >> and faces > > The function accepts FACE as the argument. So this is accounted for. > > I think you missed to "applied to specific parts of the text": No, I didn't. If someone needs to use text with different faces, then calling this function is a mistake. Any API can be used mistakenly, but that fact doesn't yet mean the API is not useful when used correctly. > > (And I wonder why this sudden crusade against this function.) > > For one, because it's name makes it impossible to find when you're > looking for "one of those functions that returns some notion of text > width". I disagree. But anyway, if you or someone can come up with a better name, and do it soon enough, we can easily rename it. > For two, because this was already a nasty mess and this function just > adds insult to injury, IMO. I cannot disagree more. The function has a place and serves a class of use cases well enough to be justified. It prevents Lisp programs from using low-level interfaces like font-get-glyphs etc., on the one hand, and OTOH is simpler and faster than window-text-pixel-size.