From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Force character display width Date: Thu, 8 Jun 2017 00:28:16 +0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1496857065 28832 195.159.176.226 (7 Jun 2017 17:37:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 7 Jun 2017 17:37:45 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 07 19:37:41 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIetp-0007IJ-F1 for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Jun 2017 19:37:41 +0200 Original-Received: from localhost ([::1]:45439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIetu-0000aw-HR for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Jun 2017 13:37:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIel6-00043v-W6 for help-gnu-emacs@gnu.org; Wed, 07 Jun 2017 13:28:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIel6-0006Kh-3z for help-gnu-emacs@gnu.org; Wed, 07 Jun 2017 13:28:41 -0400 Original-Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:35816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIel5-0006Hn-Tw for help-gnu-emacs@gnu.org; Wed, 07 Jun 2017 13:28:40 -0400 Original-Received: by mail-wm0-x236.google.com with SMTP id x70so62530338wme.0 for ; Wed, 07 Jun 2017 10:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to :content-transfer-encoding; bh=CTaBkj3hFzumQV+4OvwxsGCw9I9Fl3v1nEYu6Up5w00=; b=EE0FSpqElCb8K6LIGo6FOIXQpzLzOeT1E8Wk/rWiW5LVYldbcMuzGHIAB+EBbV3XDr GYdYQj0ORM4Xw4oUEJN4Us3QiUNDWXQSIy9z2mSUxGsswJdxTGLr+uSbFj5hdcgyNh29 fpr1Im33DfVeMWsEWarxEenBUqRkZlRoISkyS4owKceOl3eVm5lOT0dK2AO74wpJgESp unm4NvlEtxK+idHR5Jen8puN34XEL8EBEruqqJ5qIojL0rV79R9S/War20I7M5LBsq6J kjb6sAsL3AE0TblcC2JmOwWTMuOEQOfi1XSkOm/+iy/pWrjIfBmAjLAgCIJKPIxTzH4E zyhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:content-transfer-encoding; bh=CTaBkj3hFzumQV+4OvwxsGCw9I9Fl3v1nEYu6Up5w00=; b=kQvpoGaY/KVPCvV3eC5Kst8AeS4zONEFhklVLjj28xvJ/3q5xtMGmbERc8LFp467Cl hAaWpU/+ffCt/cid7rmknfAtAUBJS8tssJUTLgqTpWUUNTzkJumBIILfphovbUI4OGbc 0dq/22+a+wiD3TWfPWJbiTKYyTGVxEqAtb2+DLvl9LASuMpfrz0BiuUne9hmstzsjnsP JK88aJoSosYcmx3nI7JQKdnLhfbbs0LTAS5oP7TB9Co6JQ2wLtW4Mm8EyQrYV+JamZof 5jmnE8f8gPok4vrk9HygGPxnW1QugGw+oXhkFeA4ZFZYwjtxFs1Gbrs8fzeGxKaeflgh h2Ww== X-Gm-Message-State: AKS2vOxNplA2ayvV3QNv3n0VRPxTev4Myq7pCy8CDRkteWdSKOQafyoQ bLlAnmwZCxlOOOQ0eDx+nQA9QR69wP1r X-Received: by 10.28.55.69 with SMTP id e66mr584968wma.16.1496856516873; Wed, 07 Jun 2017 10:28:36 -0700 (PDT) Original-Received: by 10.223.164.93 with HTTP; Wed, 7 Jun 2017 10:28:16 -0700 (PDT) X-Google-Sender-Auth: 7JBYgZpdkRxZaIwBrYUXkUtWseU X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113395 Archived-At: Hello, everybody. I am trying to customize Ibuffer to display the read-only status differently. By default, it displays a percent sign if the buffer is read-only, and a space if not. I want it to display a lock character (=F0=9F=94=92 U+1f512 LOCK) instead of the percent sign. Of course this is = all on a GUI frame. That was the big picture. Now for the XY problem :) (define-ibuffer-column yk-read-only (:name "R") nil (if (buffer-local-value 'buffer-read-only buffer) "=F0=9F=94=92" " ")) This would work in the ideal world where my font of choice has full Unicode coverage. That is not the case. My default font is Liberation Mono and the lock is displayed in Symbola. The widths do not match, so the columns do not line up perfectly. This leads me to the idea that I need to somehow tweak the lock character so that it takes up exactly one character cell; or, alternatively, tweak the space so it takes as much space as the lock; or tweak both that they take up the same width. I can achieve the desired effect by changing font size: (propertize "=F0=9F=94=92" 'display '(height 0.75)) but this strikes me as inelegant and prone to breaking if I ever change fon= ts. I suppose I could calculate the factor dynamically if I could get the pixel width of the lock character. However, the only thing I can find on that path is the =E2=80=98window-text-pixel-size=E2=80=99 function which= requires the text being measured to already be in the buffer. I=E2=80=99d prefer to avoid fiddling with a temporary buffer and window. I could use the same character for both cases, but propertize it with different faces. That will solve the display problem at the cost of breaking semantics. I could also do this: (concat (if (yk-buffer-read-only-p buffer) "=F0=9F=94=92" " ") (propertize " " 'display '(space . (:align-to 3.5)))) This will break if I ever decide to move the column to a different position, and is also slightly fragile against font changes. I also tried using a string of two spaces and the following composition: (compose-chars ?\s '(Br . Bc) ?=F0=9F=94=92 '(Bc . Bl) ?\s) which do occupy the same width, but there are visual glitches when cursor passes that point in the buffer. Am I overlooking some other option?