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: Fri, 21 Nov 2014 11:33:37 +0100 Message-ID: <87mw7kn8qm.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> <87ppcitc7x.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416566066 11285 80.91.229.3 (21 Nov 2014 10:34:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Nov 2014 10:34:26 +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 Fri Nov 21 11:34: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 1XrlXf-00071i-Ny for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Nov 2014 11:34:19 +0100 Original-Received: from localhost ([::1]:39888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrlXf-0005Vq-Av for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Nov 2014 05:34:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrlXU-0005Vb-Jw for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 05:34:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrlXO-0007BI-Bg for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 05:34:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrlXO-0007BE-8j for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 05:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XrlXN-0004fb-T0 for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 05:34:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Nov 2014 10:34: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.141656602217920 (code B ref 19102); Fri, 21 Nov 2014 10:34:01 +0000 Original-Received: (at 19102) by debbugs.gnu.org; 21 Nov 2014 10:33:42 +0000 Original-Received: from localhost ([127.0.0.1]:40300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrlX3-0004ex-Hl for submit@debbugs.gnu.org; Fri, 21 Nov 2014 05:33:42 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:52839) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrlX1-0004ep-Np for 19102@debbugs.gnu.org; Fri, 21 Nov 2014 05:33:40 -0500 Original-Received: from rosalinde.fritz.box ([89.245.122.145]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MELdk-1XlByE2QvI-00FPDO; Fri, 21 Nov 2014 11:33:38 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:fJ+cZYys1zl8eYsGY19OrgN2Qp3C9Evja7dx0x3jEe9s6Z6vTFX BiuhHIBaB32I3VKNQOrMTWAF+C0NSpGij87xjO6mrcqKLwgPqblzZccJVckM5pBsw4ppvPA z4xo4kmGFW4ZB04uCOPvLzuY48vBpaIiYdfFfCHpQ+yvGyMSX6JSU0lqCrxq2j4kie51/2j MiL+aOQduJzKGX6+J6nQA== 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:96367 On Thu, 20 Nov 2014 23:43:10 +1000 Paul Rankin wrote: > Stephen Berman 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