emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Bastien <bzg@altern.org>
Cc: public-emacs-orgmode-mXXj517/zsQ@plane.gmane.org,
	Sebastien Vauban
	<public-wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@plane.gmane.org>
Subject: Re: Inserting a comma as prefix of headlines (in Org code blocks)
Date: Thu, 28 Feb 2013 00:29:44 +0100	[thread overview]
Message-ID: <87vc9dpc7r.fsf@gmail.com> (raw)
In-Reply-To: <878v69nz7u.fsf@bzg.ath.cx> (Bastien's message of "Wed, 27 Feb 2013 23:55:49 +0100")



Bastien <bzg@altern.org> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> Ok then another binding. I still think freeing "," key is the best thing
>> to do. More on this below.
>
> Users will still be able to use the "," so this will not really fix
> the issue.

That's the whole point: leave the ability to escape the headline
manually (without using "C-q ,"), as Org should be unable to do so.

> The fact that (org-in-block-p '("src")) returns a non-nil value in
>
> #+begin_src org
> ** H12
> #+end_src
>
> is not wrong in the context of checking whether a speed command should
> be prevented or not.  It might be wrong in other contexts, but for
> this purpose it is not.

It is wrong because there's no block here, although it finds one.
Functions should not be built on erroneous assumptions like this.

> That's similar to TAB, which comma-escapes the content of the block
> instead of cycling through the folding states, because it knows it is
> in a src block.

It cannot know. If there's a headline amidst a "block", that "block"
dissolves because its opening line is separated from the closing one.

Again, headlines are first-class objects in Org. A command shouldn't
pretend there is no headline when point is on one. TAB has to cycle in
this case (like it does in an example block, for example), even if it
looks strange on trivial examples.

>>   1. "stars + space" at column 0 define a headline. No exception. Most
>>      of Org code (reasonably) assumes this, so we should not let users
>>      think otherwise.
>
> Yes.  But it is not because the cursor is at the beginning of a
> headline that every function should behave the same.  TAB does not,
> speed commands do not either.

Since headlines are the base of Org syntax, I think it should be
expected that commands always behave consistently on them.

There is no more important context than a headline. Ignoring it may look
useful on a couple of examples, but we're shooting ourselves in the
foot. Think about it, for example:

  #+begin_src something
  ...
  more than one screenful of lines
  ...
  * Headline
  ...
  more than one screenful of lines
  #+end_src

Appending a comma to "* Headline" after pressing TAB may be surprising
if the user has forgotten about the context.

Another example:

  #+BEGIN_src emacs-lisp
  * H1
  ** H11
  #+END_src

Press TAB on any of the headlines. It will neither cycle them nor add
a comma in front of them.

This hack is not worth it. It's far better to have a simple rule to
handle them: "If you need to have a star at column 0 in a block, put
a comma before it.". One line in the manual is better than scores of
loc, which can always be fooled under certain circumstances.

>>   2. Do not rely on `org-in-block-p'. Please use `org-element-at-point'
>>      or `org-element-context' instead. These are not broken, and they
>>      are fast enough for any interactive use (but let's not use them for
>>      fontification yet).
>
> Btw, can you think of cases where it would be nice to have
> `org-element-context' check against a wider context than the closest
> one?

`org-element-context' already provides access to wider context
through :parent property. In the following example:

  *bold _and_ underlined text*

with, point on "and",

  (org-element-type (org-element-property :parent (org-element-context)))

will return `bold' and

  (org-element-type
    (org-element-property :parent
      (org-element-property :parent (org-element-context))))

will return `paragraph'.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2013-02-27 23:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27  8:56 Inserting a comma as prefix of headlines (in Org code blocks) Sebastien Vauban
2013-02-27  9:22 ` Bastien
2013-02-27  9:43 ` Nicolas Goaziou
2013-02-27 12:16   ` Bastien
2013-02-27 12:54     ` Nicolas Goaziou
2013-02-27 22:55       ` Bastien
2013-02-27 23:29         ` Nicolas Goaziou [this message]
2013-02-28  8:54           ` Bastien
2013-02-28  9:56             ` Nicolas Goaziou
2013-02-28 10:15               ` Bastien
2013-02-28 10:52                 ` Nicolas Goaziou
2013-02-28 11:17               ` Achim Gratz
2013-02-28 21:23                 ` Nicolas Goaziou
2013-02-28 16:17               ` François Pinard
2013-02-28 17:02                 ` Yagnesh Raghava Yakkala
2013-02-28 19:26                   ` François Pinard
2013-02-28 20:06                     ` Yagnesh Raghava Yakkala
2013-03-01 16:23                       ` Takafumi Arakaki

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=87vc9dpc7r.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=bzg@altern.org \
    --cc=public-emacs-orgmode-mXXj517/zsQ@plane.gmane.org \
    --cc=public-wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@plane.gmane.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).