Hi Nicolas,
Hi All,
On Sun, 05 Jul 2020 at 17:49, Gustavo Barros <gusbrs.2...@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.