From: Stephen Berman <stephen.berman@gmx.net>
To: Paul Rankin <paul@tilk.co>
Cc: 19102@debbugs.gnu.org
Subject: bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree
Date: Fri, 21 Nov 2014 11:33:37 +0100 [thread overview]
Message-ID: <87mw7kn8qm.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: <m2d28jzj8y.fsf@tilk.co>
On Thu, 20 Nov 2014 23:43:10 +1000 Paul Rankin <paul@tilk.co> wrote:
> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> This basically does the same thing as the patch I proposed -- adding a
>> newline if necessary to ensure forward movement -- except that if there
>> was no empty line after the last subtree, your code leaves the added
>> newline dangling. If you add that bit then there is effectively no
>> difference between your version and mine.
>
> For my package's purposes I think it might be better to have that
> dangling newline created it's not already there, but yeah, not for
> outline-mode. (This may be a faux pas on my part.)
Actually, the faux pas seems to have been mine, see my latest reply to
Eli Zaretskii.
> However, how about this for the dangling line code?
>
> (unless empty-last-line
> (save-excursion
> (goto-char (point-max))
> (if (and (bolp) (eolp))
> (delete-char -1)))))
>
>
> That way it doesn't execute if it doesn't need to. Or am I over-thinking
> it?
I guess that could save a few CPU cycles, but I guess the issue is moot
now.
>> However, yours is slightly shorter and slightly cleaner, since it
>> avoids a couple of setq's of let-bound variables, so maybe it's the
>> better fix (after adding the line deletion bit; also, it's not
>> necessary and AFAIK stylistically discouraged to quote a lambda form;
>> and finally, I'm not sure if open-line is more or less appropriate
>> here than newline -- maybe both are too heavyweight and (insert "\n")
>> or even (terpri) would suffice?
>
> Awesome, thanks. I'm not proposing any of my code go into Emacs, so go
> with whatever you think is best.
>
>>> 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 :)
>>
>> The line you marked tests whether we're moving the subtree down
>> (positive arg) and if so ensures we find the insertion point after it.
>> Or are you asking about something else?
>
> Thanks. Yes that was all, please do not be under any impression that I
> have any idea what I'm doing.
Well, you seem to have at least as much an idea about this as I do (you
probably shouldn't take that as a compliment ;-).
> I did find some problems with saving match data though, so just for the
Yes, the match data should be saved.
> heck of it, I've pasted the function I ended up going with for my
> package (it probably looks like I rewrote things from your patch just to
> be contrary, but it's just to fit with the internal style of the
> package):
> (defun fountain-outline-shift-down (&optional n)
> (interactive "p")
> (outline-back-to-heading)
> (let* ((move-func
> (if (< 0 n)
> 'outline-get-next-sibling
> 'outline-get-last-sibling))
> (end-point-func
> (lambda ()
> (outline-end-of-subtree)
> (if (and (eobp)
> (eolp)
> (not (bolp)))
> (insert-char ?\n))
> (unless (eobp)
> (forward-char 1))
> (point)))
> (beg (point))
> (folded
> (save-match-data
> (outline-end-of-heading)
> (outline-invisible-p)))
> (end
> (save-match-data
> (funcall end-point-func)))
> (insert-point (make-marker))
> (i (abs n)))
> (goto-char beg)
> (while (< 0 i)
> (or (funcall move-func)
> (progn (goto-char beg)
> (message "Cannot shift past higher level")))
> (setq i (1- i)))
> (if (< 0 n)
> (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)))
As far as I'm concerned it's fine to commit your fix (though probably
without the unrelated more or less stylistic differences); but since I'm
not the maintainer of outline.el nor a core Emacs maintainer, it's up to
(at least one of) them.
Steve Berman
next prev parent reply other threads:[~2014-11-21 10:33 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
2014-11-20 10:09 ` Stephen Berman
2014-11-20 13:43 ` Paul Rankin
2014-11-21 10:33 ` Stephen Berman [this message]
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=87mw7kn8qm.fsf@rosalinde.fritz.box \
--to=stephen.berman@gmx.net \
--cc=19102@debbugs.gnu.org \
--cc=paul@tilk.co \
/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.