From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KC3qM2utZF/IBQAA0tVLHw (envelope-from ) for ; Fri, 18 Sep 2020 12:51:55 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id OJqjL2utZF+zEAAAbx9fmQ (envelope-from ) for ; Fri, 18 Sep 2020 12:51:55 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BF19B9404D7 for ; Fri, 18 Sep 2020 12:51:54 +0000 (UTC) Received: from localhost ([::1]:33862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJFrj-00084h-IX for larch@yhetil.org; Fri, 18 Sep 2020 08:51:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJFqs-00080Y-Ig for emacs-orgmode@gnu.org; Fri, 18 Sep 2020 08:50:58 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:33653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJFqq-00064M-EV for emacs-orgmode@gnu.org; Fri, 18 Sep 2020 08:50:58 -0400 Received: by mail-pg1-x52c.google.com with SMTP id s65so3431293pgb.0 for ; Fri, 18 Sep 2020 05:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=L0D377johqAVdsTC1JSEKx0H6i/DPo+3oQYFiU9OADQ=; b=rIPb4Q/bLzySXHZHulBiQWqo+9kLb83sRdNNBzhw0cSJznQTU+UOvKY+J4fS2QwSm3 2yLI/u6GOO30IB0yxf32nkq9dwahgFEmsEk43ejmsUMfJdDqZfHuNMsoI/EztRQmdpum cQEBzR+hPwuztDtqySoCQRDmauUD3AfKnwBEHBnwEOqszPNuMQXR83dl8Gr+nUVXq/KM 8Abe2CMA81wfwT67/r2HoT3oXwy9rTgDO7IPDqPug43tnSAiiki7vhpeZ9PTek/SNq9C fAQHa1XoanylK3b6CIukULm0abJKIMAhTen+Wj9cmbfXx5csC75aLPC2gPO9eHL0/xrA ThzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=L0D377johqAVdsTC1JSEKx0H6i/DPo+3oQYFiU9OADQ=; b=iuv8X4hysnKtpHmugu0CFRu3gAm0DxQBUpIyKKWTh7mrZ+TyrgeO8VeC8ChTZyjbh2 ViH245HvxCoAUb8cAVYY4NZVWrWlUz39oKCBmlpcONovzBzA6y91oXxKUaPniYyzHoQK QuwREraW2vOV/UqbDpjCmEND8x1yUZVMiAjB4nggT/mgMBpum7Nohsi+ScHx7n9shqwR 3F9icIY+n56k32LjAKHppAoBBtytFjyq1ult5/ZpUjJgo2ZSodz/RhhbnZOpmi5XhZZL 5Iw/zub5QtjQR7iO83c0hY+YTUKFAVyIca2nQRfp6YgH9M63vccG/MY0r3BzH3PpgwZZ yDPw== X-Gm-Message-State: AOAM531QwzYFejlXl7Z5xS+jEA6ReLJib/3hnVepO5Y3bv9YAHBBZlpL 1sZhgdTQjUx1O7fpbGe2duc= X-Google-Smtp-Source: ABdhPJw7U7w/Ta1t/0EdNtWt59cVf83+Axh0KmW/moCcIGZRcl453e3oUyqfFhWOYBuW4MCzeMuh0w== X-Received: by 2002:a63:161e:: with SMTP id w30mr26040818pgl.255.1600433451675; Fri, 18 Sep 2020 05:50:51 -0700 (PDT) Received: from localhost ([104.250.131.79]) by smtp.gmail.com with ESMTPSA id y197sm3331616pfc.220.2020.09.18.05.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 05:50:50 -0700 (PDT) From: Ihor Radchenko To: Jeff Filipovits , Adam Spiers Subject: Re: variable-pitch-mode misaligns org-mode heading tags In-Reply-To: <877dst5fdf.fsf@gmail.com> References: <87wo1483r5.fsf@protesilaos.com> <87v9gnl4on.fsf@gnu.org> <87mu1znrf1.fsf@ucl.ac.uk> <87eenbj9p2.fsf@gnu.org> <878sdblyz3.fsf@gmail.com> <20200916162143.xyg7j5rg6xalmv2j@ionian.linksys.moosehall> <87mu1pa6jd.fsf@gmail.com> <20200916225553.hrtxitzt46dzln7i@ionian.linksys.moosehall> <877dst5fdf.fsf@gmail.com> Date: Fri, 18 Sep 2020 20:49:50 +0800 Message-ID: <87lfh745ch.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Protesilaos Stavrou , emacs-orgmode@gnu.org, Eric S Fraga Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=rIPb4Q/b; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: 8QAKijLLzGHj I somehow missed this thread. I have a (mostly) working code achieving the same thing in my personal config. The code is below. Hope it can give you some more ideas. I am using font-lock for tag alignment. (add-hook 'org-mode-hook (lambda () (font-lock-add-keywords 'org-mode '(yant/org-align-tags) t)) 100) (add-hook 'org-mode-hook (lambda () (add-to-list 'font-lock-extra-managed-props 'org-tag-aligned))) (defun yant/org-align-tags (limit &optional force) "Align all the tags in org buffer." (save-match-data (when (eq major-mode 'org-mode) (while (re-search-forward "^\\*+ \\(.+?\\)\\([ \t]+\\)\\(:\\(?:[^ \n]+:\\)+\\)$" limit t) (when (and (match-string 2) (or force (not (get-text-property (match-beginning 2) 'org-tag-aligned)))) (with-silent-modifications (put-text-property (match-beginning 2) (match-end 2) 'org-tag-aligned t) (put-text-property (if (>= 2 (- (match-end 2) (match-beginning 2))) (match-beginning 2) ;; multiple whitespaces may mean that we are in process of typing (1+ (match-beginning 2))) (match-end 2) 'display `(space . (:align-to (- right (,(+ 3 ;; no idea, but otherwise it is sometimes not enough (string-display-pixel-width org-ellipsis) (string-display-pixel-width (or (match-string 3) "")))))))))))))) (defun string-display-pixel-width (string &optional mode) "Calculate pixel width of STRING. Optional MODE specifies major mode used for display." (with-temp-buffer (with-silent-modifications (setf (buffer-string) string)) (when (fboundp mode) (funcall mode) (font-lock-fontify-buffer)) (if (get-buffer-window (current-buffer)) (car (window-text-pixel-size nil (line-beginning-position) (point))) (set-window-buffer nil (current-buffer)) (car (window-text-pixel-size nil (line-beginning-position) (point)))))) Jeff Filipovits writes: > Adam Spiers writes: > >> Hrm, no this isn't good enough. For graphical windows we still >> need >> to set the display text properties to align all tags when the >> buffer >> initially loads. AFAICS there's currently no code to trigger >> this, so >> it would need to be added, and for large files this might >> actually >> cause problems with file loading time unless it was done in the >> background (a bit like fontification can be done). > > > > The upside of this is that it enabled me do to some hacking so now > I can use a variable pitch font in the mu4e headers view and keep > the columns aligned, which makes mu4e much prettier. > > > -- > Jeff Filipovits > Spears & Filipovits, LLC > 1126 Ponce de Leon Avenue > Atlanta, GA 30306 > 678.237.9302 (direct) > jeff@civil-rights.law > > All emails confidential to the fullest extent of the law.