emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Gustavo Barros <gusbrs.2016@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org, Shankar Rao <shankar.rao@gmail.com>
Subject: Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
Date: Mon, 06 Jul 2020 11:01:32 -0300	[thread overview]
Message-ID: <873664yc77.fsf@gmail.com> (raw)
In-Reply-To: <87o8ot4rh3.fsf@gmail.com>

Hi Nicolas,
Hi All,

On Sun, 05 Jul 2020 at 17:49, Gustavo Barros <gusbrs.2016@gmail.com> 
wrote:

> A fourth issue is point placement after the emphasis is 
> added. `org-emphasis'
> takes a stance here and places point within the emphasis. I do agree 
> with this
> option, but it is still true that sometimes, one might want or need 
> otherwise.
> This, of course, gets more interesting when 
> `org-hide-emphasis-markers' is t.
> And I actually think this issue is still more general.  One thing is 
> to "add
> emphasis markers to existing text", another is "adding text around 
> existing
> emphasis markers".  The first one is superbly dealt with by this
> implementation of `org-emphasize', the second one, as far as I can 
> see, not
> equally so.

After sleeping over this problem, I think I had an interesting idea to 
allow some control of point position in an intuitive fashion.  I thus 
submit it to the list.

Consider the following suggested behavior for `org-emphasize':  i) 
anything in the direction opposite to the emphasis expansion direction 
is ignored, regardless of whether point is at a word boundary or not on 
that side (this corresponds to the current implementation, but goes 
against my initial suggestion of considering the right boundary of a 
word as "part" of the previous word); ii) point never moves (and this is 
different from the current implementation).

Simple, clear cut rules.  And they would make it possible to control 
whether point is placed within or outside the emphasis markers by 
manipulating point position wrt whitespace /before/ calling 
`org-emphasize'.  So, taking the current forward expansion direction, if 
we wanted to emphasize the following word, we would have: i) if the 
point is placed before whitespace preceding the following word, point 
will be left where is is, which will result to be outside the emphasis 
markers; ii) if point is within a word (which includes the left 
boundary) point will end inside the markers; it also hasn't moved, just 
the marker was applied before it.

Some examples, again assuming forward expansion:

#+begin_src org
foo|·bar
foo·|bar
foo·b|ar
foo·bar|
#+end_src

for `M-o *', the results would be:

#+begin_src org
foo|·*bar*
foo·*|bar*
foo·*b|ar*
foo·bar|
#+end_src

Assuming a backwards expansion direction was to exist (and the more I 
think of this, the more I lean towards preferring this as the default), 
we could do the following.

I'm typing something:

#+begin_src org
foo·bar|
#+end_src

But then I decide to emphasize "bar", and only "bar".  I could go with 
`SPC M-o *' to get:

#+begin_src org
foo·*bar*·|
#+end_src

And be able to just keep on typing:

#+begin_src org
foo·*bar*·baz|
#+end_src

I wouldn't say this goes all the way to solve the "adding text around 
existing emphasis markers" problem.  But, as far as my scrutiny went, I 
do think it goes quite a stretch.  And it is quite simple, which should 
make for "intuitive" hopefully.

WDYT?

Best,
Gustavo.



  reply	other threads:[~2020-07-06 14:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 14:14 [PATCH] Add mode for automatically unhiding emphasis markers in the current region Shankar Rao
2020-06-01 15:33 ` Shankar Rao
2020-06-22  5:40   ` Kyle Meyer
2020-06-22 11:25     ` Gustavo Barros
2020-06-23  0:07       ` Kyle Meyer
2020-06-24 12:53         ` Shankar Rao
2020-06-24 13:49           ` Gustavo Barros
2020-06-24 15:46             ` Nicolas Goaziou
2020-06-24 16:34               ` Shankar Rao
2020-06-26  7:32                 ` Nicolas Goaziou
2020-07-03 15:19                   ` Shankar Rao
2020-07-05 10:50                     ` Nicolas Goaziou
2020-07-05 20:49                       ` Gustavo Barros
2020-07-06 14:01                         ` Gustavo Barros [this message]
2020-07-07 15:57                       ` Shankar Rao
2020-06-24 17:27               ` Gustavo Barros

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=873664yc77.fsf@gmail.com \
    --to=gusbrs.2016@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=shankar.rao@gmail.com \
    /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).