From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Special alignment in org-mode Date: Wed, 27 Apr 2016 12:47:21 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avScX-00037n-JN for emacs-orgmode@gnu.org; Wed, 27 Apr 2016 12:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avScU-00011E-CF for emacs-orgmode@gnu.org; Wed, 27 Apr 2016 12:47:25 -0400 Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:33178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avScU-000117-7P for emacs-orgmode@gnu.org; Wed, 27 Apr 2016 12:47:22 -0400 Received: by mail-qk0-x22e.google.com with SMTP id n63so21178505qkf.0 for ; Wed, 27 Apr 2016 09:47:22 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: David Cao Cc: emacs-orgmode@gnu.org I think this does approximately what you want: #+BEGIN_SRC emacs-lisp :results none (require 'ov) (defun org-max-heading-depth () "Get maximum depth of a heading." (let ((max-depth 0) depth) (org-map-entries (lambda () (when (> (setq depth (car (org-heading-components))) max-depth) (setq max-depth depth)))) max-depth)) (defun org-right-align-overlay () "Put an overlay on headline * to right align to maximum depth. Should be run while on the headline." (interactive) (let* ((diff (- (org-max-heading-depth) (car (org-heading-components)))) ov) (while (and (setq ov (ov-at (match-beginning 1))) (overlay-get ov 'right-align)) (delete-overlay ov)) ;; (setq ov (make-overlay (line-beginning-position) (+ 1 (line-beginning-position)))) (setq ov (make-overlay (match-beginning 1) (+ 1 (match-beginning 1)))) (overlay-put ov 'before-string (make-string diff ? )) (overlay-put ov 'right-align t))) (defun org-right-align-clear () (interactive) (ov-clear 'right-align)) (defun align-matcher (&optional limit) (while (re-search-forward org-heading-regexp limit t) (org-right-align-overlay))) (add-to-list 'org-font-lock-hook 'align-matcher) #+END_SRC Its only light tested, and may be slow on a long document because it is checking the maximum depth each time. You could set this to a constant, e.g. 8 if it is too slow. David Cao writes: > Hello, > > I was wondering if there is any way to right-align the header indicators > while left-aligning the actual content. Unfortunately I haven't been able > to find any mention of such a feature online. > > For example: > > * My fancy org file > ** Header 2 > Some content here > *** Header 3 > > Thanks in advance! > David -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu