emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PROPOSAL] Use prefix arg to control scope of org-narrow-to-subtree.
Date: Fri, 31 May 2019 02:33:03 -0500	[thread overview]
Message-ID: <87y32ncc40.fsf@red-bean.com> (raw)
In-Reply-To: <878svyqxwc.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Thu, 25 Apr 2019 10:42:11 +0200")

On 25 Apr 2019, Nicolas Goaziou wrote:
>Hello,
>
>Karl Fogel <kfogel@red-bean.com> writes:
>
>> My proposal is for each raw prefix arg (each `C-u' prefix) to expand
>> the narrowing level outward/upward by one.  So in the above situation:
>
>I suggest to use a numeric argument for that. M-1 for one level, M-2 for
>two levels, maybe M-0 equivalent to current behaviour. C-u can be
>a shortcut for M-1.

Thanks to you and Alan Tyree for your encouraging replies.

In a followup message, you added:

> Further to my previous message: there is already provision for a
> numerical prefix in org-tree-to-indirect-buffer.  I suppose that it
> and org-narrow-to-subtree should behave the same.

Ahhh, okay, hmmm -- I didn't know about `org-tree-to-indirect-buffer'.  This makes the situation somewhat more complex.  Let me explain:

First, I agree it should be a numeric argument, and we can treat "C-u" specially, making each C-u be equivalent to one increment.  E.g., "C-u" is "M-1", as you said, and "C-u C-u" is "M-2", etc.  This may be a slightly unusual behavior in Emacs, but given the low numbers we're talking about here, and the high convenience of just being able to repeat C-u a certain number of times to indicate that number of levels, I think it's well worth it.

However, my orginal thought was that the number would be relative *from* the level point is currently at.  In other words, if you're in the 5th nested subtree down ("***** " is the most recent heading prefix), then `M-1 org-narrow-to-subtree' would narrow to the next level up -- the 4th-level nesting.

Unfortunately, this is the opposite of how `org-tree-to-indirect-buffer' interprets prefixes:

  "With a numerical prefix ARG, go up to this level and then take that tree.
   If ARG is negative, go up that many levels."

In other words, in `org-tree-to-indirect-buffer', the number is counted down from the absolute reference point of the top level (although you can use a negative number to get the behavior I was proposing for `org-narrow-to-subtree').

I'd like to be consistent with existing commands.  But still, most of the time a user would (I conjecture) want to choose their narrowing level *relative* to the level of where point currently is.  That's certainly what I always want: I'm at a certain nesting level, and either I want to narrow to that level, or to the one right above it, or to the one above that, etc.  I'm always thinking in terms relative to where I am now, not relative to the far-away top level.  In fact, I'm not necessarily even aware of the absolute nesting count of where I am now -- and I don't need to know either, for the purposes of narrowing.

So here's my updated proposal:

Purely numeric prefix arguments behave as in `org-tree-to-indirect-buffer', but each C-u behaves as an increment in the other direction (i.e., the way negative numbers behave for `org-tree-to-indirect-buffer').  Numeric arguments would thus be consistent with `org-tree-to-indirect-buffer', but there would still be a way, using repeated "C-u"s, to quickly and conveniently indicate a nesting level relative to where one currently is.

Thoughts?

Best regards,
-Karl

>> If you offer too many `C-u's, such that the narrowing would be wider
>> than the current surrounding first-level subtree, then there are two
>> possible ways we could handle it:
>>
>> 1) Extra `C-u's are ignored -- just narrow to surrounding 1st-level subtree.
>>
>> 2) Throw an error.
>>
>> I prefer (1), because it would be the more useful behavior, even
>> though (2) would be easier to implement (since `org-back-to-heading'
>> already throws the error).  However, I'd welcome others' feedback on
>> that question, or on any other aspect of this proposal.
>
>1 sounds good.
>
>I think it is a good idea.
>
>Thank you.
>
>Regards,

  reply	other threads:[~2019-05-31  7:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 19:05 [PROPOSAL] Use prefix arg to control scope of org-narrow-to-subtree Karl Fogel
2019-04-24 21:56 ` Alan L Tyree
2019-04-24 22:02 ` Alan L Tyree
2019-04-25  8:42 ` Nicolas Goaziou
2019-05-31  7:33   ` Karl Fogel [this message]
2019-12-01  8:45   ` [PATCH] " Karl Fogel
2019-12-01 13:13     ` Marco Wahl
2019-12-01 15:25       ` Karl Fogel
2019-12-01 15:44         ` Marco Wahl
2019-12-01 15:46           ` Karl Fogel
2019-12-02  8:51     ` Eric Abrahamsen
2019-12-02 15:15     ` Marco Wahl
2019-12-02 18:06       ` Karl Fogel
2019-12-02 18:56         ` Marco Wahl
2019-12-02 19:17           ` Karl Fogel

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=87y32ncc40.fsf@red-bean.com \
    --to=kfogel@red-bean.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).