From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#19102: 24.4; outline-move-subtree-up/down error at last and second-last subtree Date: Thu, 20 Nov 2014 11:09:38 +0100 Message-ID: <87ppcitc7x.fsf@rosalinde.fritz.box> References: <87lhn7s522.fsf@rosalinde.fritz.box> <83lhn789tq.fsf@gnu.org> <87h9xvruan.fsf@rosalinde.fritz.box> <83tx1v6mur.fsf@gnu.org> <87a93nrlql.fsf@rosalinde.fritz.box> <83lhn76iex.fsf@gnu.org> <8761easv3s.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416478769 32176 80.91.229.3 (20 Nov 2014 10:19:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Nov 2014 10:19:29 +0000 (UTC) Cc: 19102@debbugs.gnu.org To: Paul Rankin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 20 11:19:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XrOpc-0004P1-9p for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Nov 2014 11:19:20 +0100 Original-Received: from localhost ([::1]:34451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrOgr-0006Aw-S7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Nov 2014 05:10:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrOgi-00069C-PC for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 05:10:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrOgc-0005tU-Cz for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 05:10:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrOgc-0005tH-9V for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 05:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XrOgb-0000JB-Ns for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 05:10:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Nov 2014 10:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19102 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19102-submit@debbugs.gnu.org id=B19102.14164781911163 (code B ref 19102); Thu, 20 Nov 2014 10:10:01 +0000 Original-Received: (at 19102) by debbugs.gnu.org; 20 Nov 2014 10:09:51 +0000 Original-Received: from localhost ([127.0.0.1]:39077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrOgQ-0000Ig-LO for submit@debbugs.gnu.org; Thu, 20 Nov 2014 05:09:50 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:54091) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrOgO-0000IY-3V for 19102@debbugs.gnu.org; Thu, 20 Nov 2014 05:09:48 -0500 Original-Received: from rosalinde.fritz.box ([89.245.126.188]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0Lh7sF-1YLB3M3sf9-00oSe8; Thu, 20 Nov 2014 11:09:40 +0100 In-Reply-To: (Paul Rankin's message of "Thu, 20 Nov 2014 17:22:50 +1000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:SOTsA+mlNzqSmNoH6vGhHNRnzHS/frPowfofvFU9+S+Bz/kOwrD 6UMGQoYQJNdx/5SWFsyhau/MYViK1IeMuYWeTvYyYzAZzbhe7DZ54OkSlmAj26m1D74uBNE spSNY3BQZfCcUzX8LzUX/l85Pdpd38usn7BR0P86B35khXd/03LBhFHwsYrZkszZTg3XAuZ L6OZbmc0P2N9MDA+m60hQ== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96312 On Thu, 20 Nov 2014 17:22:50 +1000 Paul Rankin wrote: > 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))) 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. 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? > 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? Steve Berman