From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Rankin 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 17:22:50 +1000 Message-ID: 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 1416468202 10871 80.91.229.3 (20 Nov 2014 07:23:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Nov 2014 07:23:22 +0000 (UTC) Cc: 19102@debbugs.gnu.org To: Stephen Berman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 20 08:23:16 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 1XrM5E-0004QW-Hb for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Nov 2014 08:23:16 +0100 Original-Received: from localhost ([::1]:33937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrM5D-00023S-Vd for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Nov 2014 02:23:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrM55-00023L-Jd for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 02:23:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrM50-0007zI-Jz for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 02:23:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrM50-0007zE-GM for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 02:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XrM50-0004b3-7q for bug-gnu-emacs@gnu.org; Thu, 20 Nov 2014 02:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Rankin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Nov 2014 07:23:02 +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.141646818117667 (code B ref 19102); Thu, 20 Nov 2014 07:23:02 +0000 Original-Received: (at 19102) by debbugs.gnu.org; 20 Nov 2014 07:23:01 +0000 Original-Received: from localhost ([127.0.0.1]:38952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrM4z-0004ai-1s for submit@debbugs.gnu.org; Thu, 20 Nov 2014 02:23:01 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:56215) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrM4w-0004aZ-3Q for 19102@debbugs.gnu.org; Thu, 20 Nov 2014 02:22:58 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id DFBBA20377; Thu, 20 Nov 2014 02:22:57 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 20 Nov 2014 02:22:57 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=tilk.co; h= x-sasl-enc:references:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-type; s=mesmtp; bh=yJofvpjyFdfX bbJxM/VdM6lEzNA=; b=mKneZmYJEMYgNKdgnPQMgssaZBSOeylgB3AGUPRYmsxJ spimoYfiB9BzXccBM5J00pRDTLt9wHRbctDdxoln6lJAvNOqwzfrs9cUAjf7Jk/d JfIBj3qPh6Imz0NTjYinG2O/l+UsPIH6I2FiKi0oBwRl14rWL+V5ExJgKRr8Gvw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:references:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-type; s= smtpout; bh=yJofvpjyFdfXbbJxM/VdM6lEzNA=; b=N59B5vHygRL6HkcqgSBS clUoAdAK95jBrHuuq9yPU3e3wJ4CbavW1dbCvkCekQtai9aiSs+kyQYCxKaY6EWX KNNZUQkc/v5lIbWemd/LboNMVILflnFn5N7jq4AecSOf/IN6GYMjKOnReCOXiAZW LkPYovjdZI9lKOLr6pFBn1Q= X-Sasl-enc: 9A2a5VTNTb39xT2Osjj4CeuDq8DBXBRiKru9osIL/XGW 1416468176 Original-Received: from Paul-Rankins-MacBook-Pro.local (unknown [202.0.190.43]) by mail.messagingengine.com (Postfix) with ESMTPA id E0C4668017B; Thu, 20 Nov 2014 02:22:55 -0500 (EST) In-reply-to: <8761easv3s.fsf@rosalinde.fritz.box> 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:96309 Stephen Berman writes: > On Wed, 19 Nov 2014 22:32:06 +0200 Eli Zaretskii wrote: > >>> From: Stephen Berman >>> 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