From: Paul Rankin <paul@tilk.co>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 19102@debbugs.gnu.org
Subject: bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree
Date: Thu, 20 Nov 2014 17:22:50 +1000 [thread overview]
Message-ID: <m24mtuwd2t.fsf@tilk.co> (raw)
In-Reply-To: <8761easv3s.fsf@rosalinde.fritz.box>
Stephen Berman <stephen.berman@gmx.net> writes:
> On Wed, 19 Nov 2014 22:32:06 +0200 Eli Zaretskii <eliz@gnu.org> wrote:
>
>>> From: Stephen Berman <stephen.berman@gmx.net>
>>> Cc: paul@tilk.co, 19102@debbugs.gnu.org
>>> Date: Wed, 19 Nov 2014 21:14:42 +0100
>>>
>>> > Wouldn't using eolp instead of the comparison solve that problem more
>>> > easily?
>>>
>>> Well, that eliminates the wrong-type-argument error in the current code,
>>> but it instead signals "End of buffer"
>>
>> From forward-char? If so, you could avoid the call if eobp. Or wrap
>> the call in condition-case and ignore errors.
>
> Those solutions work only if there's an empty line after the last
> subtree. If there isn't, I can't see any way other than my patch.
>
>>> Do you see any other problems with the patch or more room for
>>> improvement?
>>
>> I was worried by the complexity of maybe-forward-char, but maybe now
>> it is much simpler.
>
> I simplified it just a bit more, but that's all I can think of. I also
> had overlooked a side-effect of the error signaled when trying to move
> the last subtree down: it leaves a dangling newline; this is avoided
> using with-demoted-errors. The revised patch is appended.
>
> Steve Berman
I needed to rewrite this for functionality with my own package, so I
rewrote it very arrogantly and this is what I came up with...
(defun fountain-outline-shift-down (&optional arg)
(interactive "p")
(outline-back-to-heading)
(let* ((move-func
(if (< 0 arg)
'outline-get-next-sibling
'outline-get-last-sibling))
(end-point-func
'(lambda ()
(outline-end-of-subtree)
(if (and (eolp)
(not (bolp))
(eobp))
(open-line 1))
(unless (eobp)
(forward-char 1))
(point)))
(beg (point))
(end
(save-excursion
(funcall end-point-func)))
(folded
(save-excursion
(outline-end-of-heading)
(outline-invisible-p)))
(insert-point (make-marker))
(i (abs arg)))
(goto-char beg)
(while (< 0 i)
(or (funcall move-func)
(progn (goto-char beg)
(message "Cannot move past superior level")))
(setq i (1- i)))
(if (< 0 arg) ; what does this bit do??
(funcall end-point-func))
(move-marker insert-point (point))
(insert (delete-and-extract-region beg end))
(goto-char insert-point)
(if folded
(hide-subtree))
(set-marker insert-point nil)))
The only thing I'm not sure about is the line marked above. This is not
intended for Emacs, just wanna see if I'm on the right track :)
--
Paul W. Rankin
http://www.paulwrankin.com
next prev parent reply other threads:[~2014-11-20 7:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 8:29 bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree Paul Rankin
2014-11-19 13:17 ` Stephen Berman
2014-11-19 15:54 ` Eli Zaretskii
2014-11-19 17:09 ` Stephen Berman
2014-11-19 18:56 ` Eli Zaretskii
2014-11-19 20:14 ` Stephen Berman
2014-11-19 20:32 ` Eli Zaretskii
2014-11-19 22:07 ` Stephen Berman
2014-11-20 6:46 ` Paul Rankin
2014-11-20 10:08 ` Stephen Berman
2014-11-20 13:26 ` Paul Rankin
2014-11-20 16:21 ` Eli Zaretskii
2014-11-21 10:32 ` Stephen Berman
2014-11-21 10:42 ` Eli Zaretskii
2014-11-21 17:31 ` Stephen Berman
2014-11-21 19:56 ` Eli Zaretskii
2014-11-21 20:04 ` Stephen Berman
2014-11-22 3:49 ` Paul Rankin
2014-11-22 16:32 ` Stefan Monnier
2014-11-22 16:45 ` Eli Zaretskii
2014-11-22 22:20 ` Stephen Berman
2014-11-24 4:07 ` Stefan Monnier
2014-11-25 21:58 ` Stephen Berman
2014-11-26 2:34 ` Paul Rankin
2014-11-26 13:38 ` Stephen Berman
2014-11-20 7:22 ` Paul Rankin [this message]
2014-11-20 10:09 ` Stephen Berman
2014-11-20 13:43 ` Paul Rankin
2014-11-21 10:33 ` Stephen Berman
2014-11-26 2:43 ` Stefan Monnier
2014-11-26 13:38 ` Stephen Berman
2014-11-26 15:54 ` Stefan Monnier
2014-11-26 19:04 ` Stephen Berman
2014-11-26 22:11 ` Stefan Monnier
2014-11-26 22:25 ` Stephen Berman
2014-11-27 2:18 ` Stefan Monnier
2014-11-27 10:12 ` Stephen Berman
2014-11-27 17:15 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24mtuwd2t.fsf@tilk.co \
--to=paul@tilk.co \
--cc=19102@debbugs.gnu.org \
--cc=stephen.berman@gmx.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.