From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Max Rydahl Andersen" Subject: Re: avoiding "First item of list cannot move without its subtree" Date: Wed, 22 Feb 2017 08:22:15 +0100 Message-ID: <627E7E70-7578-4B73-A6A7-2ABFAD907AFB@redhat.com> References: <2F92B854-9322-45EA-8753-A6CAA3717974@redhat.com> <87h93oygic.fsf@nicolasgoaziou.fr> <87tw7ovvkc.fsf@nicolasgoaziou.fr> <31A5D5FB-7629-4A6A-9727-D419A7D8096D@redhat.com> <87d1ebtpkh.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=_MailMate_B01DC650-709D-4C34-ABEA-6563311887B8_=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgRFo-0001Pz-0A for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 02:22:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgRFk-00082v-0o for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 02:22:23 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36330) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cgRFj-00082Q-ND for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 02:22:19 -0500 Received: by mail-wm0-f51.google.com with SMTP id i186so2566898wmf.1 for ; Tue, 21 Feb 2017 23:22:19 -0800 (PST) In-Reply-To: <87d1ebtpkh.fsf@nicolasgoaziou.fr> 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" To: Nicolas Goaziou Cc: Org-mode --=_MailMate_B01DC650-709D-4C34-ABEA-6563311887B8_= Content-Type: text/plain; format=flowed On 21 Feb 2017, at 18:35, Nicolas Goaziou wrote: > "Max Rydahl Andersen" writes: > >> Any pointers on how to do this ? >> >> I tried this but no luck to get hooked in: >> >> ``` >> (defadvice org-fix-list-indent >> (around org-list-indent-item-generic) >> "Advise list indention to trigger creation of star instead" >> (message "DO MAGIC!") >> (ad-do-it) >> ) >> ``` >> >> But with this "DO MAGIC!" does not show up. > > The function to advice is `org-shiftmetaleft', not > `org-fix-list-indent'. > > Anyway, you can also add something like the following to > `org-shiftmetaleft-hook': > > (defun my-shiftmetaleft () > (interactive) > (let* ((element (org-element-at-point)) > (list-parent (org-element-lineage element '(item > plain-list) t))) > (when (and list-parent > (= (line-beginning-position) > (org-element-property :post-affiliated element))) > (call-interactively > (if (org-element-lineage list-parent '(item)) ;not at top > level > #'org-outdent-item-tree > #'org-ctrl-c-star)) > t))) Thanks! I did this but still no effect ;/ What am I doing wrong ? ``` (add-hook 'org-shiftmetaleft-hook (lambda () (interactive) (let* ((element (org-element-at-point)) (list-parent (org-element-lineage element '(item plain-list) t))) (when (and list-parent (= (line-beginning-position) (org-element-property :post-affiliated element))) (call-interactively (if (org-element-lineage list-parent '(item)) ;not at top level #'org-outdent-item-tree #'org-ctrl-c-star)) t)))) ``` /max http://about.me/maxandersen --=_MailMate_B01DC650-709D-4C34-ABEA-6563311887B8_= Content-Type: text/html Content-Transfer-Encoding: quoted-printable

On 21 Feb 2017, at 18:35, Nicolas Goaziou wrote:

"= Max Rydahl Andersen" <manderse@redhat.com> writes:

Any pointer= s on how to do this ?

I tried this but no luck to get hooked in:

```
(defadvice org-fix-list-indent
(around org-list-indent-item-generic)
"Advise list indention to trigger creation of star instead"
(message "DO MAGIC!")
(ad-do-it)
)
```

But with this "DO MAGIC!" does not show up.

The function to advice is `org-shiftmetaleft= ', not
`org-fix-list-indent'.

Anyway, you can also add something like the following to
`org-shiftmetaleft-hook':

(defun my-shiftmetaleft ()
(interactive)
(let* ((element (org-element-at-point))
(list-parent (org-element-lineage element '(item plain-list) t= )))
(when (and list-parent
(=3D (line-beginning-position)
(org-element-property :post-affiliated element)))
= (call-interactively
(if (org-element-lineage list-parent '(item)) ;not at top level<= br> #'org-outdent-item-tree
#'org-ctrl-c-star))
t)))

Thanks! I did this but still no effect ;/

What am I doing wrong ?

(add-hook 'org-sh=
iftmetaleft-hook =

      (lambda ()
        (interactive)
        (let* ((element (org-element-at-point))
           (list-parent (org-element-lineage element '(item plain-list) t=
)))
          (when (and list-parent
             (=3D (line-beginning-position)
                (org-element-property :post-affiliated element)))
        (call-interactively
         (if (org-element-lineage list-parent '(item)) ;not at top level
             #'org-outdent-item-tree
           #'org-ctrl-c-star))
        t))))

/max
http://ab= out.me/maxandersen

--=_MailMate_B01DC650-709D-4C34-ABEA-6563311887B8_=--