From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Kliakhandler Subject: Re: org-do-**mote does not work properly on empty headings Date: Wed, 2 Sep 2015 21:38:06 -0500 Message-ID: References: <87egig47tv.fsf@kyleam.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bdc0dfc732b08051ecead49 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXKQ2-0003UZ-55 for emacs-orgmode@gnu.org; Wed, 02 Sep 2015 22:38:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXKPy-0001pg-Lf for emacs-orgmode@gnu.org; Wed, 02 Sep 2015 22:38:30 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:33128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXKPy-0001pb-GO for emacs-orgmode@gnu.org; Wed, 02 Sep 2015 22:38:26 -0400 Received: by igbkq10 with SMTP id kq10so4541369igb.0 for ; Wed, 02 Sep 2015 19:38:25 -0700 (PDT) In-Reply-To: <87egig47tv.fsf@kyleam.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kyle Meyer Cc: emacs-orgmode@gnu.org --047d7bdc0dfc732b08051ecead49 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Kyle, First, I apologise for the poorly chosen subject. I indeed looks like something in my setup - I am also unable to reproduce with emacs -Q. Since I posted this, I looked further and found that the place where the problem occurs for me is in the function `org-fix-position-after-promote'. I will paste it here for your convenience: ``` > (defun org-fix-position-after-promote () > "Make sure that after pro/demotion cursor position is right." > (let ((pos (point))) > (when (save-excursion > (beginning-of-line 1) > (looking-at org-todo-line-regexp) > (or (equal pos (match-end 1)) (equal pos (match-end 2)))) > (cond ((eobp) (insert " ")) > ((eolp) (insert " ")) > ((equal (char-after) ?\ ) (forward-char 1)))))) ``` Specifically, (equal pos (match-end 2)) evals to t here and to nil on a clean system. I examined the difference between the the two setups. In my setup, the variable `org-todo-line-regexp' is set to: "^\\(\\*+\\)\\(?: +\\(\\(?:C\\(?:ANCELLED\\|OMPLETE\\|REDENTIAL\\)\\|DONE\\|EVENT\\|FUTURE\\|= HABIT\\|N\\(?:OTE\\|UMBER\\)\\|OBJECT\\|PROJECT\\|STARTED\\|T\\(?:EMP\\|ODO= \\)\\|WAITING\\)?\\)\\)?\\(?: +\\(.*?\\)\\)?[ ]*$" (yes, I know - I have too many labels...) In the clean system, the variable is set as follows: "^\\(\\*+\\)\\(?: +\\(TODO\\|DONE\\)\\)?\\(?: +\\(.*?\\)\\)?[ ]*$" Incidentally, the *only* difference between the two is in group 2 which matches in my setup and does not match in the default setup. Just in case it isn't obvious, this variable appears to get autogenerated from my settings. If I'm not mistaken, it looks like the group in my case matches the empty string and then the function decides to add a space since we are at the end of the line. The question then is, why does the empty get matched? Well, I know why; my `org-todo-keywords' is setup as follows: (setq org-todo-keywords > '((type "TODO(t!)" "|" "DONE(d!)" "CANCELLED(c@)") > (type "HABIT(h!)" "|" "DONE(d!)") > (type "WAITING(w@/!)" "FUTURE(f!/@)" "STARTED(s@/!)" "|" > "DONE(d!)") > (type "|" "NOTE(n)" "NUMBER(#)" "CREDENTIAL($)" "OBJECT(o)" > "TEMP(e)") > (type "EVENT(n)") > (type "PROJECT(p!)" "|" "COMPLETE(m@)") > (type "(-)") > )) Disregard that there are key collisions, and notice the last entry, which I made to be able to easily remove the TODO tags altogether. Well, I guess I'll have to lose it. Thanks for the attention! Kosta --=20 Konstantin Kliakhandler http://slumpy.org )=C2=B0) )=C2=B0( (=C2=B0( On 2 September 2015 at 20:20, Kyle Meyer wrote: > Hello, > > Konstantin Kliakhandler writes: > > > Hello, > > > > When I start a new heading and don't add text yet but click > M-right/M-left, > > new spaces are tacked to the end so that when I do begin to write, > > sometimes there are too many spaces at the front. > > [...] > > > Steps to reproduce: > > 1. Make a heading with some text underneath > > 2. M-Return to create a new heading > > 3. M-Right, M-Left would get you to the same heading level, but the > cursor > > would be further to the right than started with. > > I'm unable to reproduce this running 'emacs -Q' with either > release_8.3.1-194-ga2d0cd9 or release_8.3.1. The cursor remains one > space from the last star. > > -- > Kyle > --047d7bdc0dfc732b08051ecead49 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Kyle,

First, I apolog= ise for the poorly chosen subject. I indeed looks like something in my setu= p - I am also unable to reproduce with emacs -Q.

<= br>
Since I posted this, I looked further and found that the plac= e where the problem occurs for me is in the function `org-fix-position-afte= r-promote'. I will paste it here for your convenience:

```
(defun org-fix-position-after-promo= te ()
=C2=A0 "Make sure that after pro/demotion cursor position is = right."
=C2=A0 (let ((pos (point)))
=C2=A0 =C2=A0 (when (save-ex= cursion
=C2=A0 =C2= =A0(beginning-of-line 1)
=C2=A0 =C2=A0(looking-at org-todo-line-regexp)
=C2=A0 =C2=A0(or (equal pos (match-end 1)) = (equal pos (match-end 2))))
=C2=A0 =C2=A0 =C2=A0 (cond ((eobp) (insert &= quot; "))
=C2= =A0 =C2=A0((eolp) (insert " "))
=C2=A0 =C2=A0((equal (char-after) ?\ ) (forward-char = 1))))))
```

Specifically, (= equal pos (match-end 2)) evals to t here and to nil on a clean system. I ex= amined the difference between the the two setups.

= In my setup, the variable `org-todo-line-regexp' is set to:=C2=A0
=
"^\\(\\*+\\)\\(?: +\\(\\(?:C\\(?:ANCELLED\\|OMPLETE\\|REDENTIAL\\= )\\|DONE\\|EVENT\\|FUTURE\\|HABIT\\|N\\(?:OTE\\|UMBER\\)\\|OBJECT\\|PROJECT= \\|STARTED\\|T\\(?:EMP\\|ODO\\)\\|WAITING\\)?\\)\\)?\\(?: +\\(.*?\\)\\)?[ <= span class=3D"" style=3D"white-space:pre"> ]*$"

<= /div>
(yes, I know - I have too many labels...)

In the clean system, the variable is set as follows:
"^\\(= \\*+\\)\\(?: +\\(TODO\\|DONE\\)\\)?\\(?: +\\(.*?\\)\\)?[ ]*$"

Inciden= tally, the *only* difference between the two is in group 2 which matches in= my setup and does not match in the default setup. Just in case it isn'= t obvious, this variable appears to get autogenerated from my settings.
If I'm not mistaken, it looks like the group in my case matches = the empty string and then the function decides to add a space since we are = at the end of the line. The question then is, why does the empty get matche= d?

Well, I know why; my `org-todo-keywords' is= setup as follows:

=C2=A0 (setq o= rg-todo-keywords
=C2=A0 =C2=A0 =C2=A0 =C2=A0 '((type "TODO(t!)&= quot; "|" "DONE(d!)" "CANCELLED(c@)")
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (type "HABIT(h!)" "|" &= quot;DONE(d!)")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (type "WAIT= ING(w@/!)" "FUTURE(f!/@)" "STARTED(s@/!)" "|&= quot; "DONE(d!)")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (type &qu= ot;|" "NOTE(n)" "NUMBER(#)" "CREDENTIAL($)&qu= ot; "OBJECT(o)" "TEMP(e)")
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (type "EVENT(n)")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (type "PROJECT(p!)" "|" "COMPLETE(m@)")=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (type "(-)")
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 ))

Disregard that t= here are key collisions, and notice the last entry, which I made to be able= to easily remove the TODO tags altogether. Well, I guess I'll have to = lose it.

Thanks for the attention!
Kosta=
=C2=A0

<= div>
--=C2=A0
Konstantin = Kliakhandler
=C2=A0 =C2=A0 http://slumpy.org
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 )=C2=B0= ) )=C2=B0( (=C2=B0(

On 2 September 2015 at 20:20, Kyle Meyer <kyl= e@kyleam.com> wrote:
Hello,=

Konstantin Kliakhandler <kosta@slump= y.org> writes:

> Hello,
>
> When I start a new heading and don't add text yet but click M-righ= t/M-left,
> new spaces are tacked to the end so that when I do begin to write,
> sometimes there are too many spaces at the front.

[...]

> Steps to reproduce:
> 1. Make a heading with some text underneath
> 2. M-Return to create a new heading
> 3. M-Right, M-Left would get you to the same heading level, but the cu= rsor
> would be further to the right than started with.

I'm unable to reproduce this running 'emacs -Q' with eit= her
release_8.3.1-194-ga2d0cd9 or release_8.3.1.=C2=A0 The cursor remains one space from the last star.

--
Kyle

--047d7bdc0dfc732b08051ecead49--