From mboxrd@z Thu Jan 1 00:00:00 1970 From: Georgiy Tugai Subject: Re: Special alignment in org-mode Date: Fri, 29 Apr 2016 03:04:04 +0930 Message-ID: <20160428173404.GA21189@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2oS5YaxWCcQjTEyO" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avppT-0005Ww-TR for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 13:34:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avppN-0000QG-Pi for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 13:34:19 -0400 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]:35273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avppN-0000Pi-Ge for emacs-orgmode@gnu.org; Thu, 28 Apr 2016 13:34:13 -0400 Received: by mail-pa0-x235.google.com with SMTP id iv1so34703565pac.2 for ; Thu, 28 Apr 2016 10:34:13 -0700 (PDT) Received: from gmail.com ([101.166.208.194]) by smtp.googlemail.com with ESMTPSA id b140sm16637245pfb.19.2016.04.28.10.34.07 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2016 10:34:08 -0700 (PDT) Content-Disposition: inline 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: emacs-orgmode@gnu.org --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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! >=20 > This solution works fairly well with the headers themselves, but the actu= al > 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? >=20 > David >=20 > On Wed, Apr 27, 2016 at 9:47 AM John Kitchin > wrote: >=20 > > 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 indicat= ors > > > 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 > > --2oS5YaxWCcQjTEyO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXIkmMAAoJEFTCINVvWbOZNiMIAIENoduQZJjw3fI8vZ2gsoSl kJZvoytzcFpYau5TC3uZDQNr994BMLFkjMbCBx8O55mU9c6EFZPvxtNun4RSFJpM 7p3VwBWJvt40AsUuXgEFc/6lHOLlSPIzCp+sbr3nnpSwcbEprTRcokhKgUloJQf4 dH1r1iUaC4L5abQ3PA0Stkd8LvLNBzIVSrWxZ8YzONDxErJ3gAc4xUwifvrFXKXE eFek3QDNdQeYWyEh36EfQAGh8zpjzYWEFzfMVu0Qn+CBu5jmtsicouHjIdjKmzwT 89KvZFsNJYj4Gxzof16ETjgMZRRKhjMZvUynfWdq4HAb0/0c/H2EvzS9IarD3jI= =72rm -----END PGP SIGNATURE----- --2oS5YaxWCcQjTEyO--