[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19102: 24.4; outline-move-subtree-up/down error at last and second-l
From: |
Paul Rankin |
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 |
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
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, (continued)
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/22
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Eli Zaretskii, 2014/11/22
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/22
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/23
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/25
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Paul Rankin, 2014/11/25
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree,
Paul Rankin <=
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/20
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Paul Rankin, 2014/11/20
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/21
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/25
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stephen Berman, 2014/11/26
- bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree, Stefan Monnier, 2014/11/26