emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: hidestarsfile: "hidestars" for file
Date: Fri, 3 Feb 2012 17:43:06 +0100	[thread overview]
Message-ID: <CALn3zogSGqQpL8NQp+DWzreeFkOytRAddAhwcBYpWV43EdBJ3Q@mail.gmail.com> (raw)

Hi all

Using hooks for file find and for file save I implemented
hidestarsfile: On the fly and inspired by hidestars (a cleaner outline
view: http://orgmode.org/manual/Clean-view.html )
- remove the leading stars from all headings when writing a buffer to
  the file
- reinsert the leading stars when reading a file into the buffer

Following is an example of the _file content_ first with leading stars
as usual and below without leading stars through "#+STARTUP: odd
hidestars hidestarsfile":

#+BEGIN_EXAMPLE
  #+STARTUP: odd hidestars
  [...]
  ***** TODO section
  ******* subsection
  ********* subsubsec
            - bla bla
  ***** section
        - bla bla
  ******* subsection
#+END_EXAMPLE

#+BEGIN_EXAMPLE
  #+STARTUP: odd hidestars hidestarsfile
  [...]
      * TODO section
        * subsection
          * subsubsec
            - bla bla
      * section
        - bla bla
        * subsection
#+END_EXAMPLE

The latter is convenient for better human readability when an Org
file, additionally to Emacs, is read with a file viewer or, for
smaller edits, with an editor not capable of the Org file format. To
change the format for the current file simply add or remove the
keyword hidestarsfile in the STARTUP line.

hidestarsfile is just a hack and can not become part of the Org core:
- An Org file with hidestarsfile can not contain list items with a
  star as bullet due to the syntax conflict at read time.
- An Org file with hidestarsfile can almost not be edited with an Org
  mode without added functionality of hidestarsfile as long as the
  file is not converted back.

I am still uncertain about if this could be made Org-mode-specific to
cover more use cases: When switching between Org mode and another
major mode like Fundamental mode it would remove and reinsert the
leading stars in the buffer itself, not only in the file. The current
state is that it only reinserts the leading stars in the buffer and
only removes them in the file. It does this regardless of the major
mode, assuming that not-Org-files don't contain the "^#\+STARTUP:"
hidestarsfile keywords. This is a simplification but I think it also
helps to ensure better that it is less prone to the error of loosing
track if it should now remove or reinsert and whether to mark
not-modified. The org-mode-hook is called also when following a link
and sometimes (source blocks?) more than once when just opening a
file. I guess that this tracking could be even harder for leaving Org
mode.

The text until here and the 40 lines of Emacs Lisp are on Worg:
http://orgmode.org/worg/org-hacks.html#hidestarsfile

Are there opinions about making hidestarsfile Org-mode-specific as
mentioned above?

Is there a hook for the event of leaving Org mode or could one be
added for this purpose?

Michael

             reply	other threads:[~2012-02-03 16:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 16:43 Michael Brand [this message]
2012-02-09 18:57 ` hidestarsfile: "hidestars" for file Michael Brand
2012-02-16 17:53   ` Michael Brand
2012-02-26 15:50     ` Michael Brand

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=CALn3zogSGqQpL8NQp+DWzreeFkOytRAddAhwcBYpWV43EdBJ3Q@mail.gmail.com \
    --to=michael.ch.brand@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).