emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Georgiy Tugai <georgiy.tugai@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Special alignment in org-mode
Date: Fri, 29 Apr 2016 03:04:04 +0930	[thread overview]
Message-ID: <20160428173404.GA21189@gmail.com> (raw)
In-Reply-To: <CADvADoWg9THGqpUmUgFbVXYdSdejCQjmwTMaBT7kEmx1bW_AzA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2945 bytes --]

I believe that org-indent-mode (#+STARTUP: indent) might do what you
want with the content, although I expect that it will interfere with the
specialized overlays for right-aligning the *'s.

On 28 Apr, David Cao wrote:
> Hi!
> 
> This solution works fairly well with the headers themselves, but the actual
> content beneath the headers stays to the side of the buffer (as pictured:
> http://i.imgur.com/nGv8XBI.png).
> Would there be any way to fix this?
> 
> David
> 
> On Wed, Apr 27, 2016 at 9:47 AM John Kitchin <jkitchin@andrew.cmu.edu>
> wrote:
> 
> > 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
> >

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-04-28 17:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  5:01 Special alignment in org-mode David Cao
2016-04-27 16:47 ` John Kitchin
2016-04-28  2:56   ` David Cao
2016-04-28 17:34     ` Georgiy Tugai [this message]
2016-04-28 17:39     ` John Kitchin
2016-04-29  2:24       ` David Cao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160428173404.GA21189@gmail.com \
    --to=georgiy.tugai@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).